You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: lib.rs
    path of file: ./repos/Theseus/kernel/ioapic/src
    
    the code of the file until where you have to start completion: #![no_std]

use log::debug;
use spin::Mutex;
use volatile::{Volatile, WriteOnly};
use zerocopy::FromBytes;
use memory::{PageTable, PhysicalAddress, PteFlags, allocate_pages, allocate_frames_at, BorrowedMappedPages, Mutable};
use atomic_linked_list::atomic_map::{AtomicMap, AtomicMapIter};
use apic::ApicId;


/// The system-wide list of all `IoApic`s, of which there is usually one, 
/// but larger systems can have multiple IoApic chips.
static IOAPICS: AtomicMap<u8, Mutex<IoApic>> = AtomicMap::new();


/// Returns an iterator over the list of `IoApic`s.
pub fn get_ioapics() -> AtomicMapIter<'static, u8, Mutex<IoApic>> {
	IOAPICS.iter()
}

/// If an `IoApic` with the given `id` exis
    
    pub fn create(page_table: &mut PageTable, id: u8, phys_addr: PhysicalAddress, gsi_base: u32) -> Result<(), &'static str> {
        let new_page = allocate_pages(1).ok_or("IoApic::new(): couldn't allocate_pages!")?;
        let frame = allocate_frames_at(phys_addr, 1).map_err(|_e| "Couldn't allocate physical frame for IOAPIC")?;
        let ioapic_mapped_page = page_table.map_allocated_pages_to(
            new_page,
            frame, 
            PteFlags::new().valid(true).writable(true).device_memory(true),
        )?;

        let ioapic_regs = ioapic_mapped_page.into_borrowed_mut(0).map_err(|(_mp, err)| err)?;
        let ioapic = IoApic {
            regs: ioapic_regs,
			id,
            _phys_addr: phys_addr,
            gsi_base,
		};

        debug!("Created new IoApic, id: {}, gsi_base: {}, phys_addr: {:#X}", id, gsi_base, phys_addr);
        IOAPICS.insert(id, Mutex::new(ioapic));
        Ok(())
    }