This commit is contained in:
Cui Chenhao 2026-01-14 14:13:29 +08:00 committed by GitHub
commit 44064d4280
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 23 additions and 0 deletions

View File

@ -178,6 +178,16 @@ impl IoApicAccess {
Self { io_mem }
}
/// # Safety
///
/// 1. ValidReg: The value of `register` should be a valid IOAPIC readable register index.
/// Valid registers include:
/// - ID register (0x00)
/// - Version register (0x01)
/// - Redirection table entries:
/// * Low 32 bits: 0x10 + 2*n
/// * High 32 bits: 0x10 + 2*n + 1
/// Where 0 <= n <= max redirection entry (obtained from the version register)
pub(self) unsafe fn read(&mut self, register: u8) -> u32 {
// SAFETY: This reads data from an I/O APIC register. The safety is upheld by the caller.
unsafe {
@ -187,6 +197,19 @@ impl IoApicAccess {
}
}
/// # Safety
///
/// 1. ValidReg: The value of `register` should be a valid IOAPIC writable register index.
/// Valid registers include:
/// - Redirection table entries:
/// * Low 32 bits: 0x10 + 2*n
/// * High 32 bits: 0x10 + 2*n + 1
/// Where 0 <= n <= max redirection entry (obtained from the version register)
///
/// 2. ValidRegValue: data must be a valid value for register to ensure correct APIC operation and system safety.
/// See the following links for valid bit configurations:
/// - IOREDTBL structure: https://wiki.osdev.org/IOAPIC#IOREDTBL
/// - Full specification: https://pdos.csail.mit.edu/6.828/2016/readings/ia32/ioapic.pdf
pub(self) unsafe fn write(&mut self, register: u8, data: u32) {
// SAFETY: This writes data to an I/O APIC register. The safety is upheld by the caller.
unsafe {