Skip to content

Commit

Permalink
adding inw, inl, outw, outl to be able to send larger data to port
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicolas EYRAUD committed Jun 20, 2022
1 parent f0ed233 commit 8bf954e
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions srcs/io.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,22 @@ pub fn outb(port: u16, cmd: u8) {
}
}

pub fn outw(port: u16, cmd: u16) {
unsafe {
asm!("out dx, ax",
in("dx") port,
in("ax") cmd);
}
}

pub fn outl(port: u16, cmd: u32) {
unsafe {
asm!("out dx, eax",
in("dx") port,
in("eax") cmd);
}
}

pub fn inb(port: u16) -> u8 {
let mut input_byte: u8;
unsafe {
Expand All @@ -17,3 +33,23 @@ pub fn inb(port: u16) -> u8 {
}
input_byte
}

pub fn inw(port: u16) -> u16 {
let mut input_byte: u16;
unsafe {
asm!("in ax, dx",
in("dx") port,
out("ax") input_byte);
}
input_byte
}

pub fn inl(port: u16) -> u32 {
let mut input_byte: u32;
unsafe {
asm!("in eax, dx",
in("dx") port,
out("eax") input_byte);
}
input_byte
}

0 comments on commit 8bf954e

Please sign in to comment.