File tree Expand file tree Collapse file tree 2 files changed +23
-26
lines changed Expand file tree Collapse file tree 2 files changed +23
-26
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
2828-  Use CSR helper macros to define ` mstatus `  register
2929-  Use CSR helper macros to define ` mstatush `  register
3030-  Use CSR helper macros to define ` mtvec `  register
31+ -  Use CSR helper macros to define ` mtvendorid `  register
3132
3233## [ v0.12.1]  - 2024-10-20 
3334
Original file line number Diff line number Diff line change 11//! mvendorid register 
22
3- use  core:: num:: NonZeroUsize ; 
4- 
5- /// mvendorid register 
6- #[ derive( Clone ,  Copy ,  Debug ) ]  
7- pub  struct  Mvendorid  { 
8-     bits :  NonZeroUsize , 
3+ read_only_csr !  { 
4+     /// `mvendorid` register 
5+ Mvendorid :  0xF11 , 
6+     mask:  0xffff_ffff , 
7+     sentinel:  0 , 
98} 
109
11- impl  Mvendorid  { 
12-     /// Returns the contents of the register as raw bits 
13- #[ inline]  
14-     pub  fn  bits ( & self )  -> usize  { 
15-         self . bits . get ( ) 
16-     } 
17- 
18-     /// Returns the JEDEC manufacturer ID 
19- #[ inline]  
20-     pub  fn  jedec_manufacturer ( & self )  -> usize  { 
21-         self . bits ( )  >> 7 
22-     } 
10+ read_only_csr_field !  { 
11+     Mvendorid , 
12+     /// Represents the number of continuation bytes (`0x7f`) in the JEDEC manufacturer ID. 
13+ :  [ 7 : 31 ] , 
2314} 
2415
25- read_csr ! ( 0xF11 ) ; 
16+ read_only_csr_field !  { 
17+     Mvendorid , 
18+     /// Represents the final offset field in the JEDEC manufacturer ID. 
19+ :  [ 0 : 6 ] , 
20+ } 
2621
27- /// Reads the CSR 
28- #[ inline]  
29- pub  fn  read ( )  -> Option < Mvendorid >  { 
30-     let  r = unsafe  {  _read ( )  } ; 
31-     // When mvendorid is hardwired to zero it means that the mvendorid 
32-     // csr isn't implemented. 
33-     NonZeroUsize :: new ( r) . map ( |bits| Mvendorid  {  bits } ) 
22+ impl  Mvendorid  { 
23+     /// Gets the JEDEC manufacturer ID decoded into parts: 
24+ /// 
25+ /// - `bank`: the number of continuation bytes (`0x7f`) 
26+ /// - `offset`: specific offset in the JEDEC bank number 
27+ pub  fn  jedec_manufacturer ( & self )  -> ( usize ,  usize )  { 
28+         ( self . bank ( )  as  usize ,  ( 0x80  | self . offset ( ) )  as  usize ) 
29+     } 
3430} 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments