Trait uacpi::kernel_api::KernelApi

source ·
pub trait KernelApi {
Show 37 methods // Required methods unsafe fn raw_memory_read( &self, phys: PhysAddr, byte_width: u8, ) -> Result<u64, Status>; unsafe fn raw_memory_write( &self, phys: PhysAddr, byte_width: u8, val: u64, ) -> Result<(), Status>; unsafe fn raw_io_read( &self, addr: IOAddr, byte_width: u8, ) -> Result<u64, Status>; unsafe fn raw_io_write( &self, addr: IOAddr, byte_width: u8, val: u64, ) -> Result<(), Status>; unsafe fn pci_read( &self, address: PCIAddress, offset: usize, byte_width: u8, ) -> Result<u64, Status>; unsafe fn pci_write( &self, address: PCIAddress, offset: usize, byte_width: u8, val: u64, ) -> Result<(), Status>; unsafe fn io_map(&self, base: IOAddr, len: usize) -> Result<Handle, Status>; unsafe fn io_unmap(&self, handle: Handle); unsafe fn io_read( &self, handle: Handle, offset: usize, byte_width: u8, ) -> Result<u64, Status>; unsafe fn io_write( &self, handle: Handle, offset: usize, byte_width: u8, val: u64, ) -> Result<(), Status>; unsafe fn map(&self, phys: PhysAddr, len: usize) -> *mut c_void; unsafe fn unmap(&self, addr: *mut c_void, len: usize); fn get_ticks(&self) -> u64; fn stall(&self, usec: u8); fn sleep(&self, msec: u8); fn create_mutex(&self) -> Handle; fn destroy_mutex(&self, mutex: Handle); fn acquire_mutex(&self, mutex: Handle, timeout: u16) -> bool; fn release_mutex(&self, mutex: Handle); fn create_spinlock(&self) -> Handle; fn destroy_spinlock(&self, lock: Handle); fn acquire_spinlock(&self, lock: Handle) -> CpuFlags; fn release_spinlock(&self, lock: Handle, cpu_flags: CpuFlags); fn create_event(&self) -> Handle; fn destroy_event(&self, event: Handle); fn wait_for_event(&self, event: Handle, timeout: u16) -> bool; fn signal_event(&self, event: Handle); fn reset_event(&self, event: Handle); fn get_thread_id(&self) -> ThreadId; fn firmware_request(&self, req: FirmwareRequest) -> Result<(), Status>; fn install_interrupt_handler( &self, irq: u32, handler: Box<dyn Fn()>, ) -> Result<Handle, Status>; fn uninstall_interrupt_handler(&self, handle: Handle) -> Result<(), Status>; fn schedule_work( &self, work_type: WorkType, handler: Box<dyn Fn()>, ) -> Result<(), Status>; fn wait_for_work_completion(&self) -> Result<(), Status>; // Provided methods unsafe fn alloc(&self, layout: Layout) -> *mut u8 { ... } unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout) { ... } fn log(&self, log_level: LogLevel, string: &str) { ... }
}

Required Methods§

source

unsafe fn raw_memory_read( &self, phys: PhysAddr, byte_width: u8, ) -> Result<u64, Status>

Reads a value of the specified byte width (1, 2, 4 or 8) from memory.

source

unsafe fn raw_memory_write( &self, phys: PhysAddr, byte_width: u8, val: u64, ) -> Result<(), Status>

Writes a value of the specified byte width (1, 2, 4 or 8) to memory.

source

unsafe fn raw_io_read( &self, addr: IOAddr, byte_width: u8, ) -> Result<u64, Status>

Reads a value of the specified byte width (1, 2 or 4) from io.

source

unsafe fn raw_io_write( &self, addr: IOAddr, byte_width: u8, val: u64, ) -> Result<(), Status>

Writes a value of the specified byte width (1, 2 or 4) to io.

source

unsafe fn pci_read( &self, address: PCIAddress, offset: usize, byte_width: u8, ) -> Result<u64, Status>

Reads a value of the specified byte width (1, 2 or 4) from a 0-based offset within the pci configuration space. Since PCI registers are 32 bits wide this must be able to handle e.g. 1-byte access by reading at the nearest 4-byte aligned offset below, then masking the value to select the target byte.

source

unsafe fn pci_write( &self, address: PCIAddress, offset: usize, byte_width: u8, val: u64, ) -> Result<(), Status>

Writes a value of the specified byte width (1, 2 or 4) to a 0-based offset within the pci configuration space. Since PCI registers are 32 bits wide this must be able to handle e.g. 1-byte access by reading at the nearest 4-byte aligned offset below, then masking everything except the target byte and writing that value with the value put in the target byte back.

source

unsafe fn io_map(&self, base: IOAddr, len: usize) -> Result<Handle, Status>

Maps a SystemIO address at [base, base + len] and return a handle that can be used for reading and writing to the IO range.

source

unsafe fn io_unmap(&self, handle: Handle)

Unmaps an IO range previously mapped with io_map.

source

unsafe fn io_read( &self, handle: Handle, offset: usize, byte_width: u8, ) -> Result<u64, Status>

Reads a value of the specified byte width (1, 2 or 4) from a 0-based offset within a mapped IO range.

source

unsafe fn io_write( &self, handle: Handle, offset: usize, byte_width: u8, val: u64, ) -> Result<(), Status>

writes a value of the specified byte width (1, 2 or 4) to a 0-based offset within a mapped IO range.

source

unsafe fn map(&self, phys: PhysAddr, len: usize) -> *mut c_void

Creates a mapping used to access the physical range [phys, phys + len].

source

unsafe fn unmap(&self, addr: *mut c_void, len: usize)

Unmaps a mapping previously returned from map.

source

fn get_ticks(&self) -> u64

Returns the monotonic count of 100 nanosecond ticks elapsed since boot.

source

fn stall(&self, usec: u8)

Spins for the specified amount of microseconds.

source

fn sleep(&self, msec: u8)

Sleeps for the specifier amount of milliseconds.

source

fn create_mutex(&self) -> Handle

Creates a non-recursive kernel mutex.

source

fn destroy_mutex(&self, mutex: Handle)

Destroys a mutex previously created by create_mutex.

source

fn acquire_mutex(&self, mutex: Handle, timeout: u16) -> bool

Tries to acquire a mutex with a millisecond timeout. A timeout value of 0xFFFF implies infinite wait.

source

fn release_mutex(&self, mutex: Handle)

Releases a previously acquired mutex.

source

fn create_spinlock(&self) -> Handle

Creates a spinlock.

source

fn destroy_spinlock(&self, lock: Handle)

Destroys a spinlock previously created by create_spinlock.

source

fn acquire_spinlock(&self, lock: Handle) -> CpuFlags

Disables interrupts and acquires a spinlock. Returns the previous state of cpu flags that can be used to restore the interrupt state when the lock is released.

source

fn release_spinlock(&self, lock: Handle, cpu_flags: CpuFlags)

Releases a spinlock and restores the previous interrupt state.

source

fn create_event(&self) -> Handle

Creates a semaphore-line event object.

source

fn destroy_event(&self, event: Handle)

Destroys an event previously created by create_event.

source

fn wait_for_event(&self, event: Handle, timeout: u16) -> bool

Waits for an event (counter > 0) with a millisecond timeout. A timeout value of 0xFFFF implies infinite wait. The internal counter is decremented by 1 if the wait was successful. A successful wait is indicated by returning true.

source

fn signal_event(&self, event: Handle)

Signals an event by incrementing its internal counter by 1. This functions may be used in interrupt contexts.

source

fn reset_event(&self, event: Handle)

Resets an event by setting its internal counter to 0.

source

fn get_thread_id(&self) -> ThreadId

Returns a unique identifier of the currently executing thread.

source

fn firmware_request(&self, req: FirmwareRequest) -> Result<(), Status>

Handles a firmware request.

source

fn install_interrupt_handler( &self, irq: u32, handler: Box<dyn Fn()>, ) -> Result<Handle, Status>

Installs an interrupt handler for irq. The returned handle can be used to refer to this handler from other API.

source

fn uninstall_interrupt_handler(&self, handle: Handle) -> Result<(), Status>

Uninstalls an interrupt handler previously installed with install_interrupt_handler.

source

fn schedule_work( &self, work_type: WorkType, handler: Box<dyn Fn()>, ) -> Result<(), Status>

Schedules deferred work for execution. Might be invoked from an interrupt context.

source

fn wait_for_work_completion(&self) -> Result<(), Status>

Blocks until all scheduled work is complete and the work queue is empty.

Provided Methods§

source

unsafe fn alloc(&self, layout: Layout) -> *mut u8

Allocates a block of zeroed memory.

source

unsafe fn dealloc(&self, ptr: *mut u8, layout: Layout)

Deallocates a block of memory.

source

fn log(&self, log_level: LogLevel, string: &str)

Implementors§