Skip to content

Commit 8bf954e

Browse files
author
Nicolas EYRAUD
committed
adding inw, inl, outw, outl to be able to send larger data to port
1 parent f0ed233 commit 8bf954e

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

srcs/io.rs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@ pub fn outb(port: u16, cmd: u8) {
88
}
99
}
1010

11+
pub fn outw(port: u16, cmd: u16) {
12+
unsafe {
13+
asm!("out dx, ax",
14+
in("dx") port,
15+
in("ax") cmd);
16+
}
17+
}
18+
19+
pub fn outl(port: u16, cmd: u32) {
20+
unsafe {
21+
asm!("out dx, eax",
22+
in("dx") port,
23+
in("eax") cmd);
24+
}
25+
}
26+
1127
pub fn inb(port: u16) -> u8 {
1228
let mut input_byte: u8;
1329
unsafe {
@@ -17,3 +33,23 @@ pub fn inb(port: u16) -> u8 {
1733
}
1834
input_byte
1935
}
36+
37+
pub fn inw(port: u16) -> u16 {
38+
let mut input_byte: u16;
39+
unsafe {
40+
asm!("in ax, dx",
41+
in("dx") port,
42+
out("ax") input_byte);
43+
}
44+
input_byte
45+
}
46+
47+
pub fn inl(port: u16) -> u32 {
48+
let mut input_byte: u32;
49+
unsafe {
50+
asm!("in eax, dx",
51+
in("dx") port,
52+
out("eax") input_byte);
53+
}
54+
input_byte
55+
}

0 commit comments

Comments
 (0)