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 @@ -531,6 +531,30 @@ impl PciPciBridgeHeader {
531531 let data = unsafe { access. read ( self . 0 , 0x18 ) . get_bits ( 16 ..24 ) } ;
532532 data as u8
533533 }
534+
535+ pub fn update_bus_number < F > ( & self , access : impl ConfigRegionAccess , f : F )
536+ where
537+ F : FnOnce ( BusNumber ) -> BusNumber ,
538+ {
539+ let mut data = unsafe { access. read ( self . 0 , 0x18 ) } ;
540+ let new_bus = f ( BusNumber {
541+ primary : data. get_bits ( 0 ..8 ) as u8 ,
542+ secondary : data. get_bits ( 8 ..16 ) as u8 ,
543+ subordinate : data. get_bits ( 16 ..24 ) as u8 ,
544+ } ) ;
545+ data. set_bits ( 16 ..24 , new_bus. subordinate . into ( ) ) ;
546+ data. set_bits ( 8 ..16 , new_bus. secondary . into ( ) ) ;
547+ data. set_bits ( 0 ..8 , new_bus. primary . into ( ) ) ;
548+ unsafe {
549+ access. write ( self . 0 , 0x18 , data) ;
550+ }
551+ }
552+ }
553+
554+ pub struct BusNumber {
555+ pub primary : u8 ,
556+ pub secondary : u8 ,
557+ pub subordinate : u8 ,
534558}
535559
536560pub const MAX_BARS : usize = 6 ;
You can’t perform that action at this time.
0 commit comments