pub struct SystemAllocator {
    io_address_space: Option<AddressAllocator>,
    mmio_address_spaces: [AddressAllocator; 2],
    mmio_platform_address_spaces: Option<AddressAllocator>,
    reserved_region: Option<AddressRange>,
    pci_allocator: BTreeMap<u8, AddressAllocator>,
    irq_allocator: AddressAllocator,
    gpe_allocator: AddressAllocator,
    next_anon_id: usize,
}

Fields§

§io_address_space: Option<AddressAllocator>§mmio_address_spaces: [AddressAllocator; 2]§mmio_platform_address_spaces: Option<AddressAllocator>§reserved_region: Option<AddressRange>§pci_allocator: BTreeMap<u8, AddressAllocator>§irq_allocator: AddressAllocator§gpe_allocator: AddressAllocator§next_anon_id: usize

Implementations§

source§

impl SystemAllocator

source

pub fn new( config: SystemAllocatorConfig, reserve_region_size: Option<u64>, mmio_address_ranges: &[AddressRange] ) -> Result<Self>

Creates a new SystemAllocator for managing addresses and irq numbers. Will return an error if base + size overflows u64 (or allowed maximum for the specific type), or if alignment isn’t a power of two.

If reserve_region_size is not None, then a region is reserved from the start of config.high_mmio before the mmio allocator is created.

If mmio_address_ranges is not empty, then config.low_mmio and config.high_mmio are intersected with the ranges specified.

source

pub fn allocate_irq(&mut self) -> Option<u32>

Reserves the next available system irq number.

source

pub fn release_irq(&mut self, irq: u32)

release irq to system irq number pool

source

pub fn reserve_irq(&mut self, irq: u32) -> bool

Reserves the next available system irq number.

source

pub fn allocate_gpe(&mut self) -> Option<u32>

Reserve the next available system GPE number

source

fn get_pci_allocator_mut(&mut self, bus: u8) -> Option<&mut AddressAllocator>

source

pub fn pci_bus_empty(&self, bus: u8) -> bool

source

pub fn allocate_pci(&mut self, bus: u8, tag: String) -> Option<PciAddress>

Allocate PCI slot location.

source

pub fn reserve_pci(&mut self, pci_addr: PciAddress, tag: String) -> bool

Reserve PCI slot location.

source

pub fn release_pci(&mut self, pci_addr: PciAddress) -> bool

release PCI slot location.

source

pub fn allocate_mmio( &mut self, size: u64, alloc: Alloc, tag: String, opts: &AllocOptions ) -> Result<u64>

Allocate a memory-mapped I/O region with properties requested in opts.

source

fn allocate_mmio_internal( &mut self, size: u64, alloc: Alloc, tag: String, opts: &AllocOptions, mmio_type: MmioType ) -> Result<u64>

source

pub fn reserve_mmio(&mut self, range: AddressRange) -> Result<()>

Reserve specified range from pci mmio, get the overlap of specified range with mmio pools, exclude the overlap from mmio allocator.

If any part of the specified range has been allocated, return Error.

source

pub fn mmio_platform_allocator(&mut self) -> Option<&mut AddressAllocator>

Gets an allocator to be used for platform device MMIO allocation.

source

pub fn io_allocator(&mut self) -> Option<&mut AddressAllocator>

Gets an allocator to be used for IO memory.

source

pub fn mmio_allocator(&mut self, mmio_type: MmioType) -> &mut AddressAllocator

Gets an allocator to be used for MMIO allocation. MmioType::Low: low mmio allocator MmioType::High: high mmio allocator

source

pub fn mmio_allocator_any(&mut self) -> AddressAllocatorSet<'_>

Gets a set of allocators to be used for MMIO allocation. The set of allocators will try the low and high MMIO allocators, in that order.

source

pub fn mmio_pools(&self) -> Vec<&AddressRange>

Gets the pools of all mmio allocators.

source

pub fn reserved_region(&self) -> Option<AddressRange>

Gets the reserved address space region.

source

pub fn get_anon_alloc(&mut self) -> Alloc

Gets a unique anonymous allocation

Trait Implementations§

source§

impl Debug for SystemAllocator

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.