3966e697da
- reorganised the entire project so that the entire kernel is a single codebase rather than a kernel and a libk.
30 lines
533 B
Rust
30 lines
533 B
Rust
//! Functions for IO using ports.
|
|
|
|
use core::arch::asm;
|
|
|
|
#[inline]
|
|
pub fn inb(port: u16) -> u8 {
|
|
let value: u8;
|
|
unsafe {
|
|
asm!(
|
|
"in al, dx",
|
|
out("al") value,
|
|
in("dx") port,
|
|
options(nomem, nostack, preserves_flags)
|
|
);
|
|
}
|
|
value
|
|
}
|
|
|
|
#[inline]
|
|
pub fn outb(port: u16, value: u8) {
|
|
unsafe {
|
|
asm!(
|
|
"out dx, al",
|
|
in("dx") port,
|
|
in("al") value,
|
|
options(nomem, nostack, preserves_flags)
|
|
);
|
|
}
|
|
}
|