From 8bf954ef80621a51bbee3dc3be944cac72081dfb Mon Sep 17 00:00:00 2001 From: Nicolas EYRAUD Date: Mon, 20 Jun 2022 15:34:55 +0200 Subject: [PATCH] adding inw, inl, outw, outl to be able to send larger data to port --- srcs/io.rs | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/srcs/io.rs b/srcs/io.rs index 71767128..079f2634 100644 --- a/srcs/io.rs +++ b/srcs/io.rs @@ -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 { @@ -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 +}