1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
pub unsafe fn outb(port: u16, val: u8) {
asm!("outb %al, %dx" :: "{dx}"(port), "{al}"(val));
}
pub unsafe fn inb(port: u16) -> u8 {
let ret: u8;
asm!("inb %dx, %al" : "={ax}"(ret) : "{dx}"(port) :: "volatile");
ret
}
pub unsafe fn outw(port: u16, val: u16) {
asm!("outw %ax, %dx" :: "{dx}"(port), "{al}"(val));
}
pub unsafe fn inw(port: u16) -> u16 {
let ret: u16;
asm!("inw %dx, %ax" : "={ax}"(ret) : "{dx}"(port) :: "volatile");
ret
}
pub unsafe fn outl(port: u16, val: u32) {
asm!("outl %eax, %dx" :: "{dx}"(port), "{al}"(val));
}
pub unsafe fn inl(port: u16) -> u32 {
let ret: u32;
asm!("inl %dx, %eax" : "={ax}"(ret) : "{dx}"(port) :: "volatile");
ret
}
pub unsafe fn outsb(port: u16, buf: &[u8]) {
asm!("rep outsb (%esi), %dx"
:: "{ecx}"(buf.len()), "{dx}"(port), "{esi}"(buf.as_ptr())
: "ecx", "edi");
}
pub unsafe fn insb(port: u16, buf: &mut [u8]) {
asm!("rep insb %dx, (%edi)"
:: "{ecx}"(buf.len()), "{dx}"(port), "{edi}"(buf.as_ptr())
: "ecx", "edi" : "volatile");
}
pub unsafe fn outsw(port: u16, buf: &[u16]) {
asm!("rep outsw (%esi), %dx"
:: "{ecx}"(buf.len()), "{dx}"(port), "{esi}"(buf.as_ptr())
: "ecx", "edi");
}
pub unsafe fn insw(port: u16, buf: &mut [u16]) {
asm!("rep insw %dx, (%edi)"
:: "{ecx}"(buf.len()), "{dx}"(port), "{edi}"(buf.as_ptr())
: "ecx", "edi" : "volatile");
}
pub unsafe fn outsl(port: u16, buf: &[u32]) {
asm!("rep outsl (%esi), %dx"
:: "{ecx}"(buf.len()), "{dx}"(port), "{esi}"(buf.as_ptr())
: "ecx", "edi");
}
pub unsafe fn insl(port: u16, buf: &mut [u32]) {
asm!("rep insl %dx, (%edi)"
:: "{ecx}"(buf.len()), "{dx}"(port), "{edi}"(buf.as_ptr())
: "ecx", "edi" : "volatile");
}