aboutsummaryrefslogtreecommitdiff
path: root/src/arch/x86_64/asm/io_port.s
blob: 3aec69d1fa1c7fb6ab82547692a1258521110c56 (plain)
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
;***************************************************************************
;* Operating-System Construction                                             *
;*---------------------------------------------------------------------------*
;*                                                                           *
;*                             I O _ P O R T                                 *
;*                                                                           *
;*---------------------------------------------------------------------------*
;* The functions defined here encapsulate the machine instructions 'in' and  *
;* 'out' for class IO_Port.                                                  *
;*****************************************************************************

; EXPORTED FUNCTIONS

[GLOBAL _outb]
[GLOBAL _outw]
[GLOBAL _inb]
[GLOBAL _inw]

; FUNCTION IMPLEMENTATIONS

[SECTION .text]

; OUTB: Byte-wise output via an I/O port.
;
;       C prototype: void outb (int port, int value);

_outb:
	push   rbp
	mov    rbp, rsp
	mov    rdx, rdi
	mov    rax, rsi
	out    dx, al
	pop    rbp
	ret

; OUTW: Word-wise output via an I/O port.
;
;       C prototype: void outw (int port, int value);

_outw:
	push   rbp
	mov    rbp, rsp
	mov    rdx, rdi
	mov    rax, rsi
	out    dx, ax
	pop    rbp
	ret

; INB: Byte-wise input via an I/O port.
;
;      C prototype: unsigned char inb (int port);

_inb:
	push   rbp
	mov    rbp, rsp
	mov    rdx, rdi
	in     al, dx
	pop    rbp
	ret

; INW: Word-wise input via an I/O port.
;
;      C prototype: unsigned short inw (int port);

_inw:
	push   rbp
	mov    rbp, rsp
	mov    rdx, rdi
	in     ax, dx
	pop    rbp
	ret