@@ -33,14 +33,14 @@ pub trait DeviceExt {
3333 fn modify_cpu ( & mut self , cmod : & Hash ) -> PatchResult ;
3434
3535 /// Modify pspec inside device according to pmod
36- fn modify_peripheral ( & mut self , pspec : & str , pmod : & Hash ) -> PatchResult ;
36+ fn modify_peripheral ( & mut self , pspec : & str , pmod : & Hash , env : & Env ) -> PatchResult ;
3737
3838 /// Add pname given by padd to device
39- fn add_peripheral ( & mut self , pname : & str , padd : & Hash ) -> PatchResult ;
39+ fn add_peripheral ( & mut self , pname : & str , padd : & Hash , env : & Env ) -> PatchResult ;
4040
4141 /// Remove registers from pname and mark it as derivedFrom pderive.
4242 /// Update all derivedFrom referencing pname
43- fn derive_peripheral ( & mut self , pname : & str , pderive : & Yaml ) -> PatchResult ;
43+ fn derive_peripheral ( & mut self , pname : & str , pderive : & Yaml , env : & Env ) -> PatchResult ;
4444
4545 /// Move registers from pold to pnew.
4646 /// Update all derivedFrom referencing pold
@@ -95,7 +95,7 @@ impl DeviceExt for Device {
9595 "_peripherals" => {
9696 for ( pspec, pmod) in val. hash ( ) ? {
9797 let pspec = pspec. str ( ) ?;
98- self . modify_peripheral ( pspec, pmod. hash ( ) ?)
98+ self . modify_peripheral ( pspec, pmod. hash ( ) ?, & env )
9999 . with_context ( || {
100100 format ! ( "Modifying peripherals matched to `{pspec}`" )
101101 } ) ?;
@@ -119,7 +119,7 @@ impl DeviceExt for Device {
119119 }
120120
121121 _ => self
122- . modify_peripheral ( key, val. hash ( ) ?)
122+ . modify_peripheral ( key, val. hash ( ) ?, & env )
123123 . with_context ( || format ! ( "Modifying peripherals matched to `{key}`" ) ) ?,
124124 }
125125 }
@@ -134,14 +134,14 @@ impl DeviceExt for Device {
134134 // Handle any new peripherals (!)
135135 for ( pname, padd) in device. hash_iter ( "_add" ) {
136136 let pname = pname. str ( ) ?;
137- self . add_peripheral ( pname, padd. hash ( ) ?)
137+ self . add_peripheral ( pname, padd. hash ( ) ?, & env )
138138 . with_context ( || format ! ( "Adding peripheral `{pname}`" ) ) ?;
139139 }
140140
141141 // Handle any derived peripherals
142142 for ( pname, pderive) in device. hash_iter ( "_derive" ) {
143143 let pname = pname. str ( ) ?;
144- self . derive_peripheral ( pname, pderive)
144+ self . derive_peripheral ( pname, pderive, & env )
145145 . with_context ( || format ! ( "Deriving peripheral `{pname}` from `{pderive:?}`" ) ) ?;
146146 }
147147
@@ -222,11 +222,11 @@ impl DeviceExt for Device {
222222 Ok ( ( ) )
223223 }
224224
225- fn modify_peripheral ( & mut self , pspec : & str , pmod : & Hash ) -> PatchResult {
225+ fn modify_peripheral ( & mut self , pspec : & str , pmod : & Hash , env : & Env ) -> PatchResult {
226226 let mut modified = HashSet :: new ( ) ;
227227 let ptags = self . iter_peripherals ( pspec) . collect :: < Vec < _ > > ( ) ;
228228 if !ptags. is_empty ( ) {
229- let peripheral_builder = make_peripheral ( pmod, true ) ?;
229+ let peripheral_builder = make_peripheral ( pmod, true , env ) ?;
230230 let dim = make_dim_element ( pmod) ?;
231231 for ptag in ptags {
232232 modified. insert ( ptag. name . clone ( ) ) ;
@@ -271,12 +271,12 @@ impl DeviceExt for Device {
271271 Ok ( ( ) )
272272 }
273273
274- fn add_peripheral ( & mut self , pname : & str , padd : & Hash ) -> PatchResult {
274+ fn add_peripheral ( & mut self , pname : & str , padd : & Hash , env : & Env ) -> PatchResult {
275275 if self . get_peripheral ( pname) . is_some ( ) {
276276 return Err ( anyhow ! ( "device already has a peripheral {pname}" ) ) ;
277277 }
278278
279- let pnew = make_peripheral ( padd, false ) ?
279+ let pnew = make_peripheral ( padd, false , env ) ?
280280 . name ( pname. to_string ( ) )
281281 . build ( VAL_LVL ) ?;
282282 let pnew = if let Some ( dim) = make_dim_element ( padd) ? {
@@ -289,7 +289,7 @@ impl DeviceExt for Device {
289289 Ok ( ( ) )
290290 }
291291
292- fn derive_peripheral ( & mut self , pname : & str , pderive : & Yaml ) -> PatchResult {
292+ fn derive_peripheral ( & mut self , pname : & str , pderive : & Yaml , env : & Env ) -> PatchResult {
293293 let ( pderive, info) = if let Some ( pderive) = pderive. as_str ( ) {
294294 (
295295 pderive,
@@ -304,7 +304,7 @@ impl DeviceExt for Device {
304304 } ) ?;
305305 (
306306 pderive,
307- make_peripheral ( hash, true ) ?. derived_from ( Some ( pderive. into ( ) ) ) ,
307+ make_peripheral ( hash, true , env ) ?. derived_from ( Some ( pderive. into ( ) ) ) ,
308308 )
309309 } else {
310310 return Err ( anyhow ! ( "derive: incorrect syntax for {pname}" ) ) ;
0 commit comments