@@ -76,7 +76,19 @@ pub type InterruptPin = u8;
7676// TODO: documentation
7777pub trait ConfigRegionAccess {
7878 fn function_exists ( & self , address : PciAddress ) -> bool ;
79+
80+ /// Performs a PCI read at `address` with `offset`.
81+ ///
82+ /// # Safety
83+ ///
84+ /// `address` and `offset` must be valid for PCI reads.
7985 unsafe fn read ( & self , address : PciAddress , offset : u16 ) -> u32 ;
86+
87+ /// Performs a PCI write at `address` with `offset`.
88+ ///
89+ /// # Safety
90+ ///
91+ /// `address` and `offset` must be valid for PCI writes.
8092 unsafe fn write ( & self , address : PciAddress , offset : u16 , value : u32 ) ;
8193}
8294
@@ -288,7 +300,7 @@ impl EndpointHeader {
288300 /*
289301 * If bit 0 is `0`, the BAR is in memory. If it's `1`, it's in I/O.
290302 */
291- if bar. get_bit ( 0 ) == false {
303+ if ! bar. get_bit ( 0 ) {
292304 let prefetchable = bar. get_bit ( 3 ) ;
293305 let address = bar. get_bits ( 4 ..32 ) << 4 ;
294306
@@ -358,10 +370,13 @@ impl EndpointHeader {
358370 }
359371 }
360372
361- /// Write to a BAR, setting the address for a device to use. The supplied value must be a valid
362- /// BAR value (refer to the PCIe specification for requirements) and must be of the correct
363- /// size (i.e. no larger than `u32::MAX` for 32-bit BARs). In the case of a 64-bit BAR, the
364- /// supplied slot should be the first slot of the pair.
373+ /// Write to a BAR, setting the address for a device to use.
374+ ///
375+ /// # Safety
376+ ///
377+ /// The supplied value must be a valid BAR value (refer to the PCIe specification for
378+ /// requirements) and must be of the correct size (i.e. no larger than `u32::MAX` for 32-bit
379+ /// BARs). In the case of a 64-bit BAR, the supplied slot should be the first slot of the pair.
365380 pub unsafe fn write_bar (
366381 & mut self ,
367382 slot : u8 ,
@@ -388,7 +403,7 @@ impl EndpointHeader {
388403 }
389404 Ok ( ( ) )
390405 }
391- None => return Err ( BarWriteError :: NoSuchBar ) ,
406+ None => Err ( BarWriteError :: NoSuchBar ) ,
392407 }
393408 }
394409
0 commit comments