@@ -9,7 +9,7 @@ use std::{fs::File, io::Read, path::Path};
99use super :: iterators:: { MatchIter , Matched } ;
1010use super :: peripheral:: { PeripheralExt , RegisterBlockExt } ;
1111use super :: yaml_ext:: { AsType , GetVal } ;
12- use super :: { abspath, matchname, Config , PatchResult , Spec , VAL_LVL } ;
12+ use super :: { abspath, matchname, update_env , Config , Env , PatchResult , Spec , VAL_LVL } ;
1313use super :: { make_address_block, make_address_blocks, make_cpu, make_interrupt, make_peripheral} ;
1414use super :: { make_dim_element, modify_dim_element, modify_register_properties} ;
1515
@@ -55,6 +55,7 @@ pub trait DeviceExt {
5555 pspec : & str ,
5656 peripheral : & Hash ,
5757 config : & Config ,
58+ env : & Env ,
5859 ) -> PatchResult ;
5960}
6061
@@ -64,6 +65,9 @@ impl DeviceExt for Device {
6465 }
6566
6667 fn process ( & mut self , device : & Hash , config : & Config ) -> PatchResult {
68+ let mut env = Env :: new ( ) ;
69+ update_env ( & mut env, device) ?;
70+
6771 // Handle any deletions
6872 for pspec in device. str_vec_iter ( "_delete" ) ? {
6973 self . delete_peripheral ( pspec)
@@ -154,7 +158,7 @@ impl DeviceExt for Device {
154158 let periphspec = periphspec. str ( ) ?;
155159 if !periphspec. starts_with ( '_' ) {
156160 //val["_path"] = device["_path"]; // TODO: check
157- self . process_peripheral ( periphspec, val. hash ( ) ?, config)
161+ self . process_peripheral ( periphspec, val. hash ( ) ?, config, & env )
158162 . with_context ( || format ! ( "According to `{periphspec}`" ) ) ?;
159163 }
160164 }
@@ -415,13 +419,14 @@ impl DeviceExt for Device {
415419 pspec : & str ,
416420 peripheral : & Hash ,
417421 config : & Config ,
422+ env : & Env ,
418423 ) -> PatchResult {
419424 // Find all peripherals that match the spec
420425 let mut pcount = 0 ;
421426 let ( pspec, ignore) = pspec. spec ( ) ;
422427 for ptag in self . iter_peripherals ( pspec) {
423428 pcount += 1 ;
424- ptag. process ( peripheral, config)
429+ ptag. process ( peripheral, config, env . clone ( ) )
425430 . with_context ( || format ! ( "Processing peripheral `{}`" , ptag. name) ) ?;
426431 }
427432 if !ignore && pcount == 0 {
0 commit comments