@@ -29,6 +29,12 @@ pub trait PeripheralExt: InterruptExt + RegisterBlockExt {
29
29
pub trait ClusterExt : RegisterBlockExt {
30
30
/// Work through a cluster, handling all registers
31
31
fn process ( & mut self , peripheral : & Hash , pname : & str , config : & Config ) -> PatchResult ;
32
+
33
+ /// Work through a cluster, handling all registers
34
+ fn pre_process ( & mut self , peripheral : & Hash , pname : & str , config : & Config ) -> PatchResult ;
35
+
36
+ /// Work through a cluster, handling all registers
37
+ fn post_process ( & mut self , peripheral : & Hash , pname : & str , config : & Config ) -> PatchResult ;
32
38
}
33
39
34
40
/// Collecting methods for processing peripheral interrupt contents
@@ -710,7 +716,7 @@ impl RegisterBlockExt for Peripheral {
710
716
}
711
717
712
718
impl ClusterExt for Cluster {
713
- fn process ( & mut self , pmod : & Hash , _pname : & str , config : & Config ) -> PatchResult {
719
+ fn pre_process ( & mut self , pmod : & Hash , _pname : & str , config : & Config ) -> PatchResult {
714
720
// Handle deletions
715
721
if let Some ( deletions) = pmod. get ( & "_delete" . to_yaml ( ) ) {
716
722
match deletions {
@@ -881,6 +887,12 @@ impl ClusterExt for Cluster {
881
887
}
882
888
}
883
889
890
+ Ok ( ( ) )
891
+ }
892
+
893
+ fn process ( & mut self , pmod : & Hash , pname : & str , config : & Config ) -> PatchResult {
894
+ self . pre_process ( pmod, pname, config) ?;
895
+
884
896
// Handle registers
885
897
for ( rspec, register) in pmod {
886
898
let rspec = rspec. str ( ) ?;
@@ -890,6 +902,10 @@ impl ClusterExt for Cluster {
890
902
}
891
903
}
892
904
905
+ self . post_process ( pmod, pname, config)
906
+ }
907
+
908
+ fn post_process ( & mut self , pmod : & Hash , _pname : & str , config : & Config ) -> PatchResult {
893
909
// Expand register arrays
894
910
for ( rspec, rmod) in pmod. hash_iter ( "_expand_array" ) {
895
911
let rspec = rspec. str ( ) ?;
@@ -1365,7 +1381,7 @@ fn collect_in_cluster(
1365
1381
1366
1382
for ( rspec, rmod) in cmod {
1367
1383
let rspec = rspec. str ( ) ?;
1368
- if rspec == "description" || rspec == "dimIncrement" {
1384
+ if rspec == "description" || rspec == "dimIncrement" || rspec . starts_with ( '_' ) {
1369
1385
continue ;
1370
1386
}
1371
1387
let mut registers = Vec :: new ( ) ;
@@ -1493,7 +1509,7 @@ fn collect_in_cluster(
1493
1509
. address_offset ( address_offset) ;
1494
1510
let mut config = config. clone ( ) ;
1495
1511
config. update_fields = true ;
1496
- let cluster = if single {
1512
+ let mut cluster = if single {
1497
1513
for ( _, ( rmod, mut registers) ) in rdict. into_iter ( ) {
1498
1514
let mut reg = registers. swap_remove ( 0 ) ;
1499
1515
let rmod = rmod. hash ( ) ?;
@@ -1538,6 +1554,8 @@ fn collect_in_cluster(
1538
1554
. build ( VAL_LVL ) ?,
1539
1555
)
1540
1556
} ;
1557
+ cluster. pre_process ( cmod, cname, & config) ?;
1558
+ cluster. post_process ( cmod, cname, & config) ?;
1541
1559
regs. insert ( place, RegisterCluster :: Cluster ( cluster) ) ;
1542
1560
Ok ( ( ) )
1543
1561
}
0 commit comments