@@ -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, PatchResult , VAL_LVL } ;
12
+ use super :: { abspath, matchname, Config , PatchResult , 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
@@ -21,7 +21,7 @@ pub trait DeviceExt {
21
21
fn iter_peripherals < ' a , ' b > ( & ' a mut self , spec : & ' b str ) -> PerMatchIterMut < ' a , ' b > ;
22
22
23
23
/// Work through a device, handling all peripherals
24
- fn process ( & mut self , device : & Hash , update_fields : bool ) -> PatchResult ;
24
+ fn process ( & mut self , device : & Hash , config : & Config ) -> PatchResult ;
25
25
26
26
/// Delete registers matched by rspec inside ptag
27
27
fn delete_peripheral ( & mut self , pspec : & str ) -> PatchResult ;
@@ -54,7 +54,7 @@ pub trait DeviceExt {
54
54
& mut self ,
55
55
pspec : & str ,
56
56
peripheral : & Hash ,
57
- update_fields : bool ,
57
+ config : & Config ,
58
58
) -> PatchResult ;
59
59
}
60
60
@@ -63,7 +63,7 @@ impl DeviceExt for Device {
63
63
self . peripherals . iter_mut ( ) . matched ( spec)
64
64
}
65
65
66
- fn process ( & mut self , device : & Hash , update_fields : bool ) -> PatchResult {
66
+ fn process ( & mut self , device : & Hash , config : & Config ) -> PatchResult {
67
67
// Handle any deletions
68
68
for pspec in device. str_vec_iter ( "_delete" ) ? {
69
69
self . delete_peripheral ( pspec)
@@ -154,7 +154,7 @@ impl DeviceExt for Device {
154
154
let periphspec = periphspec. str ( ) ?;
155
155
if !periphspec. starts_with ( '_' ) {
156
156
//val["_path"] = device["_path"]; // TODO: check
157
- self . process_peripheral ( periphspec, val. hash ( ) ?, update_fields )
157
+ self . process_peripheral ( periphspec, val. hash ( ) ?, config )
158
158
. with_context ( || format ! ( "According to `{periphspec}`" ) ) ?;
159
159
}
160
160
}
@@ -414,13 +414,13 @@ impl DeviceExt for Device {
414
414
& mut self ,
415
415
pspec : & str ,
416
416
peripheral : & Hash ,
417
- update_fields : bool ,
417
+ config : & Config ,
418
418
) -> PatchResult {
419
419
// Find all peripherals that match the spec
420
420
let mut pcount = 0 ;
421
421
for ptag in self . iter_peripherals ( pspec) {
422
422
pcount += 1 ;
423
- ptag. process ( peripheral, update_fields )
423
+ ptag. process ( peripheral, config )
424
424
. with_context ( || format ! ( "Processing peripheral `{}`" , ptag. name) ) ?;
425
425
}
426
426
if pcount == 0 {
@@ -444,7 +444,7 @@ mod tests {
444
444
fn add_peripherals ( ) {
445
445
let ( mut device, yaml) = test_utils:: get_patcher ( Path :: new ( "add" ) ) . unwrap ( ) ;
446
446
assert_eq ! ( device. peripherals. len( ) , 1 ) ;
447
- device. process ( & yaml, true ) . unwrap ( ) ;
447
+ device. process ( & yaml, & Default :: default ( ) ) . unwrap ( ) ;
448
448
assert_eq ! ( device. peripherals. len( ) , 2 ) ;
449
449
let periph1 = & device. peripherals [ 0 ] ;
450
450
assert_eq ! ( periph1. name, "DAC1" ) ;
@@ -456,7 +456,7 @@ mod tests {
456
456
fn delete_peripherals ( ) {
457
457
let ( mut device, yaml) = test_utils:: get_patcher ( Path :: new ( "delete" ) ) . unwrap ( ) ;
458
458
assert_eq ! ( device. peripherals. len( ) , 3 ) ;
459
- device. process ( & yaml, true ) . unwrap ( ) ;
459
+ device. process ( & yaml, & Default :: default ( ) ) . unwrap ( ) ;
460
460
assert_eq ! ( device. peripherals. len( ) , 1 ) ;
461
461
let remaining_periph = & device. peripherals [ 0 ] ;
462
462
assert_eq ! ( remaining_periph. name, "DAC2" ) ;
@@ -470,7 +470,7 @@ mod tests {
470
470
let dac2 = device. get_peripheral ( "DAC2" ) . unwrap ( ) ;
471
471
assert_ne ! ( dac1. registers, dac2. registers) ;
472
472
473
- device. process ( & yaml, true ) . unwrap ( ) ;
473
+ device. process ( & yaml, & Default :: default ( ) ) . unwrap ( ) ;
474
474
assert_eq ! ( device. peripherals. len( ) , 3 ) ;
475
475
476
476
let dac1 = device. get_peripheral ( "DAC1" ) . unwrap ( ) ;
@@ -496,7 +496,7 @@ mod tests {
496
496
assert_eq ! ( dac1. name, "DAC1" ) ;
497
497
assert_eq ! ( dac1. description, None ) ;
498
498
499
- device. process ( & yaml, true ) . unwrap ( ) ;
499
+ device. process ( & yaml, & Default :: default ( ) ) . unwrap ( ) ;
500
500
501
501
// check device final config
502
502
assert_eq ! ( & device. version, "1.7" ) ;
0 commit comments