Struct resources::system_allocator::SystemAllocator
source · 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
impl SystemAllocator
sourcepub fn new(
config: SystemAllocatorConfig,
reserve_region_size: Option<u64>,
mmio_address_ranges: &[AddressRange]
) -> Result<Self>
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.
sourcepub fn allocate_irq(&mut self) -> Option<u32>
pub fn allocate_irq(&mut self) -> Option<u32>
Reserves the next available system irq number.
sourcepub fn release_irq(&mut self, irq: u32)
pub fn release_irq(&mut self, irq: u32)
release irq to system irq number pool
sourcepub fn reserve_irq(&mut self, irq: u32) -> bool
pub fn reserve_irq(&mut self, irq: u32) -> bool
Reserves the next available system irq number.
sourcepub fn allocate_gpe(&mut self) -> Option<u32>
pub fn allocate_gpe(&mut self) -> Option<u32>
Reserve the next available system GPE number
fn get_pci_allocator_mut(&mut self, bus: u8) -> Option<&mut AddressAllocator>
pub fn pci_bus_empty(&self, bus: u8) -> bool
sourcepub fn allocate_pci(&mut self, bus: u8, tag: String) -> Option<PciAddress>
pub fn allocate_pci(&mut self, bus: u8, tag: String) -> Option<PciAddress>
Allocate PCI slot location.
sourcepub fn reserve_pci(&mut self, pci_addr: PciAddress, tag: String) -> bool
pub fn reserve_pci(&mut self, pci_addr: PciAddress, tag: String) -> bool
Reserve PCI slot location.
sourcepub fn release_pci(&mut self, pci_addr: PciAddress) -> bool
pub fn release_pci(&mut self, pci_addr: PciAddress) -> bool
release PCI slot location.
sourcepub fn allocate_mmio(
&mut self,
size: u64,
alloc: Alloc,
tag: String,
opts: &AllocOptions
) -> Result<u64>
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
.
fn allocate_mmio_internal( &mut self, size: u64, alloc: Alloc, tag: String, opts: &AllocOptions, mmio_type: MmioType ) -> Result<u64>
sourcepub fn reserve_mmio(&mut self, range: AddressRange) -> Result<()>
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.
sourcepub fn mmio_platform_allocator(&mut self) -> Option<&mut AddressAllocator>
pub fn mmio_platform_allocator(&mut self) -> Option<&mut AddressAllocator>
Gets an allocator to be used for platform device MMIO allocation.
sourcepub fn io_allocator(&mut self) -> Option<&mut AddressAllocator>
pub fn io_allocator(&mut self) -> Option<&mut AddressAllocator>
Gets an allocator to be used for IO memory.
sourcepub fn mmio_allocator(&mut self, mmio_type: MmioType) -> &mut AddressAllocator
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
sourcepub fn mmio_allocator_any(&mut self) -> AddressAllocatorSet<'_>
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.
sourcepub fn mmio_pools(&self) -> Vec<&AddressRange>
pub fn mmio_pools(&self) -> Vec<&AddressRange>
Gets the pools of all mmio allocators.
sourcepub fn reserved_region(&self) -> Option<AddressRange>
pub fn reserved_region(&self) -> Option<AddressRange>
Gets the reserved address space region.
sourcepub fn get_anon_alloc(&mut self) -> Alloc
pub fn get_anon_alloc(&mut self) -> Alloc
Gets a unique anonymous allocation