-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathx86.h
61 lines (48 loc) · 1.53 KB
/
x86.h
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
#ifndef KERNAUX_INCLUDED_ASM_X86
#define KERNAUX_INCLUDED_ASM_X86
#ifdef __cplusplus
extern "C" {
#endif
#include <kernaux/arch/x86.h>
#include <kernaux/macro.h>
#include <stdint.h>
inline static uint8_t kernaux_asm_x86_inportb(uint16_t port);
inline static uint16_t kernaux_asm_x86_inportw(uint16_t port);
inline static uint32_t kernaux_asm_x86_inportd(uint16_t port);
inline static void kernaux_asm_x86_outportb(uint16_t port, uint8_t value);
inline static void kernaux_asm_x86_outportw(uint16_t port, uint16_t value);
inline static void kernaux_asm_x86_outportd(uint16_t port, uint32_t value);
uint8_t kernaux_asm_x86_inportb(const uint16_t port)
{
register uint8_t result;
KERNAUX_ASM("inb %1, %0" : "=a" (result) : "dN" (port));
return result;
}
uint16_t kernaux_asm_x86_inportw(const uint16_t port)
{
register uint16_t result;
KERNAUX_ASM("inw %1, %0" : "=a" (result) : "dN" (port));
return result;
}
uint32_t kernaux_asm_x86_inportd(const uint16_t port)
{
register uint32_t result;
KERNAUX_ASM("inl %1, %0" : "=a" (result) : "dN" (port));
return result;
}
void kernaux_asm_x86_outportb(const uint16_t port, const uint8_t value)
{
KERNAUX_ASM("outb %1, %0" : : "dN" (port), "a" (value));
}
void kernaux_asm_x86_outportw(const uint16_t port, const uint16_t value)
{
KERNAUX_ASM("outw %1, %0" : : "dN" (port), "a" (value));
}
void kernaux_asm_x86_outportd(const uint16_t port, const uint32_t value)
{
KERNAUX_ASM("outl %1, %0" : : "dN" (port), "a" (value));
}
#ifdef __cplusplus
}
#endif
#endif