@@ -9,7 +9,7 @@ use std::{fs::File, io::Read, path::Path};
9
9
use super :: iterators:: { MatchIter , Matched } ;
10
10
use super :: peripheral:: { PeripheralExt , RegisterBlockExt } ;
11
11
use 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 } ;
13
13
use super :: { make_address_block, make_address_blocks, make_cpu, make_interrupt, make_peripheral} ;
14
14
use super :: { make_dim_element, modify_dim_element, modify_register_properties} ;
15
15
@@ -55,6 +55,7 @@ pub trait DeviceExt {
55
55
pspec : & str ,
56
56
peripheral : & Hash ,
57
57
config : & Config ,
58
+ env : & Env ,
58
59
) -> PatchResult ;
59
60
}
60
61
@@ -64,6 +65,9 @@ impl DeviceExt for Device {
64
65
}
65
66
66
67
fn process ( & mut self , device : & Hash , config : & Config ) -> PatchResult {
68
+ let mut env = Env :: new ( ) ;
69
+ update_env ( & mut env, device) ?;
70
+
67
71
// Handle any deletions
68
72
for pspec in device. str_vec_iter ( "_delete" ) ? {
69
73
self . delete_peripheral ( pspec)
@@ -154,7 +158,7 @@ impl DeviceExt for Device {
154
158
let periphspec = periphspec. str ( ) ?;
155
159
if !periphspec. starts_with ( '_' ) {
156
160
//val["_path"] = device["_path"]; // TODO: check
157
- self . process_peripheral ( periphspec, val. hash ( ) ?, config)
161
+ self . process_peripheral ( periphspec, val. hash ( ) ?, config, & env )
158
162
. with_context ( || format ! ( "According to `{periphspec}`" ) ) ?;
159
163
}
160
164
}
@@ -415,13 +419,14 @@ impl DeviceExt for Device {
415
419
pspec : & str ,
416
420
peripheral : & Hash ,
417
421
config : & Config ,
422
+ env : & Env ,
418
423
) -> PatchResult {
419
424
// Find all peripherals that match the spec
420
425
let mut pcount = 0 ;
421
426
let ( pspec, ignore) = pspec. spec ( ) ;
422
427
for ptag in self . iter_peripherals ( pspec) {
423
428
pcount += 1 ;
424
- ptag. process ( peripheral, config)
429
+ ptag. process ( peripheral, config, env . clone ( ) )
425
430
. with_context ( || format ! ( "Processing peripheral `{}`" , ptag. name) ) ?;
426
431
}
427
432
if !ignore && pcount == 0 {
0 commit comments