pub fn insert(&mut self, device: Arc<Mutex<dyn BusDevice>>, base: u64, len: u64) -> Result<()> {
        if len == 0 {
            return Err(Error::Overlap);
        }

        // Reject all cases where the new device's base is within an old device's range.
        if self.get_device(base).is_some() {
            return Err(Error::Overlap);
        }

        // The above check will miss an overlap in which the new device's base address is before the
        // range of another device. To catch that case, we search for a device with a range before
        // the new device's range's end. If there is no existing device in that range that starts
        // after the new device, then there will be no overlap.
        if let Some((BusRange(start, _), _)) = self.first_before(base + len - 1) {
            // Such a device only conflicts with the new device if it also starts after the new
            // device because of our initial `get_device` check above.
            if start >= base {
                return Err(Error::Overlap);
            }
        }

        if self.devices.insert(BusRange(base, len), device).is_some() {
            return Err(Error::Overlap);
        }

        Ok(())
    }
/// Puts the given device at the given address space.
Puts the given device at the given address space.
Puts the given device at the given address space .
pub fn insert(&mut self, device: Arc<Mutex<dyn BusDevice>>, base: u64, len: u64) -> Result<()> {
        if len == 0 {
            return Err(Error::Overlap);
        }
        // Reject all cases where the new device's base is within an old device's range.
        if self.get_device(base).is_some() {
            return Err(Error::Overlap);
        }
        // The above check will miss an overlap in which the new device's base address is before the
        // range of another device. To catch that case, we search for a device with a range before
        // the new device's range's end. If there is no existing device in that range that starts
        // after the new device, then there will be no overlap.
        if let Some((BusRange(start, _), _)) = self.first_before(base + len - 1) {
            // Such a device only conflicts with the new device if it also starts after the new
            // device because of our initial `get_device` check above.
            if start >= base {
                return Err(Error::Overlap);
            }
        }
        if self.devices.insert(BusRange(base, len), device).is_some() {
            return Err(Error::Overlap);
        }
        Ok(())
    }
pub fn insert ( & mut self , device : Arc < Mutex < dyn BusDevice > > , base : u64 , len : u64 ) -> Result < ( ) > { if len == 0 { return Err ( Error :: Overlap ) ; } // Reject all cases where the new device's base is within an old device's range. if self . get_device ( base ) . is_some ( ) { return Err ( Error :: Overlap ) ; } // The above check will miss an overlap in which the new device's base address is before the // range of another device. To catch that case, we search for a device with a range before // the new device's range's end. If there is no existing device in that range that starts // after the new device, then there will be no overlap. if let Some ( ( BusRange ( start , _ ) , _ ) ) = self . first_before ( base + len - 1 ) { // Such a device only conflicts with the new device if it also starts after the new // device because of our initial `get_device` check above. if start >= base { return Err ( Error :: Overlap ) ; } } if self . devices . insert ( BusRange ( base , len ) , device ) . is_some ( ) { return Err ( Error :: Overlap ) ; } Ok ( ( ) ) }
Puts the given device at the given address space.
Puts the given device at the given address space .
&mut self
device
Arc<Mutex<dyn BusDevice>>
base
u64
len
u64
&mut self
device
Arc<Mutex<dyn BusDevice>>
base
u64
len
u64