File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -449,6 +449,30 @@ macro_rules! read_composite_csr {
449449 } ;
450450}
451451
452+ /// Convenience macro to write a composite value to a CSR register.
453+ ///
454+ /// - `RV32`: writes 32-bits into `hi` and 32-bits into `lo` to create a 64-bit value
455+ /// - `RV64`: writes a 64-bit value into `lo`
456+ #[ macro_export]
457+ macro_rules! write_composite_csr {
458+ ( $hi: expr, $lo: expr) => {
459+ /// Writes the CSR as a 64-bit value
460+ #[ inline]
461+ pub unsafe fn write64( bits: u64 ) {
462+ match ( ) {
463+ #[ cfg( target_arch = "riscv32" ) ]
464+ ( ) => {
465+ $hi( ( bits >> 32 ) as usize ) ;
466+ $lo( bits as usize ) ;
467+ }
468+
469+ #[ cfg( not( target_arch = "riscv32" ) ) ]
470+ ( ) => $lo( bits as usize ) ,
471+ }
472+ }
473+ } ;
474+ }
475+
452476macro_rules! set_pmp {
453477 ( ) => {
454478 /// Set the pmp configuration corresponding to the index.
You can’t perform that action at this time.
0 commit comments