@@ -29,6 +29,12 @@ pub trait PeripheralExt: InterruptExt + RegisterBlockExt {
2929pub trait ClusterExt : RegisterBlockExt {
3030 /// Work through a cluster, handling all registers
3131 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 ;
3238}
3339
3440/// Collecting methods for processing peripheral interrupt contents
@@ -710,7 +716,7 @@ impl RegisterBlockExt for Peripheral {
710716}
711717
712718impl 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 {
714720 // Handle deletions
715721 if let Some ( deletions) = pmod. get ( & "_delete" . to_yaml ( ) ) {
716722 match deletions {
@@ -881,6 +887,12 @@ impl ClusterExt for Cluster {
881887 }
882888 }
883889
890+ Ok ( ( ) )
891+ }
892+
893+ fn process ( & mut self , pmod : & Hash , pname : & str , config : & Config ) -> PatchResult {
894+ self . pre_process ( pmod, pname, config) ?;
895+
884896 // Handle registers
885897 for ( rspec, register) in pmod {
886898 let rspec = rspec. str ( ) ?;
@@ -890,6 +902,10 @@ impl ClusterExt for Cluster {
890902 }
891903 }
892904
905+ self . post_process ( pmod, pname, config)
906+ }
907+
908+ fn post_process ( & mut self , pmod : & Hash , _pname : & str , config : & Config ) -> PatchResult {
893909 // Expand register arrays
894910 for ( rspec, rmod) in pmod. hash_iter ( "_expand_array" ) {
895911 let rspec = rspec. str ( ) ?;
@@ -1365,7 +1381,7 @@ fn collect_in_cluster(
13651381
13661382 for ( rspec, rmod) in cmod {
13671383 let rspec = rspec. str ( ) ?;
1368- if rspec == "description" || rspec == "dimIncrement" {
1384+ if rspec == "description" || rspec == "dimIncrement" || rspec . starts_with ( '_' ) {
13691385 continue ;
13701386 }
13711387 let mut registers = Vec :: new ( ) ;
@@ -1493,7 +1509,7 @@ fn collect_in_cluster(
14931509 . address_offset ( address_offset) ;
14941510 let mut config = config. clone ( ) ;
14951511 config. update_fields = true ;
1496- let cluster = if single {
1512+ let mut cluster = if single {
14971513 for ( _, ( rmod, mut registers) ) in rdict. into_iter ( ) {
14981514 let mut reg = registers. swap_remove ( 0 ) ;
14991515 let rmod = rmod. hash ( ) ?;
@@ -1538,6 +1554,8 @@ fn collect_in_cluster(
15381554 . build ( VAL_LVL ) ?,
15391555 )
15401556 } ;
1557+ cluster. pre_process ( cmod, cname, & config) ?;
1558+ cluster. post_process ( cmod, cname, & config) ?;
15411559 regs. insert ( place, RegisterCluster :: Cluster ( cluster) ) ;
15421560 Ok ( ( ) )
15431561}
0 commit comments