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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
/* $NetBSD: conio.S,v 1.7 2011/06/16 13:27:59 joerg Exp $ */
/* PC console handling
originally from: FreeBSD:sys/i386/boot/netboot/start2.S
*/
#include <machine/asm.h>
.text
/**************************************************************************
CLR - Clear screen
**************************************************************************/
ENTRY(conclr)
pusha
call _C_LABEL(prot_to_real) # enter real mode
.code16
/* Clear screen. */
movw $0x0600, %ax
movw $0x0700, %bx
xorw %cx, %cx
movw $0x184f, %dx /* 80x25 */
int $0x10
/* Home cursor. */
movb $0x02, %ah
xorw %bx, %bx
xorw %dx, %dx
int $0x10
calll _C_LABEL(real_to_prot) # back to protected mode
.code32
popa
ret
/**************************************************************************
PUTC - Print a character
**************************************************************************/
ENTRY(conputc)
pusha
call _C_LABEL(prot_to_real) # enter real mode
.code16
#if defined(__minix)
cmp $0x08, %al # backspace?
jne print_char
# Multiline backspace support.
push %ax
movb $0x3, %ah # get cursor position
xorw %bx, %bx
int $0x10
pop %ax
testb %dl, %dl # cursor on first column?
jnz print_char
testb %dh, %dh # cursor not on first row?
jz print_char
decb %dh # move up one row
movb $0x4f, %dl # move to last column
xorw %bx, %bx
movb $0x02, %ah # set cursor position
jmp do_int
print_char:
#endif /* defined(__minix) */
movw $1,%bx
movb $0x0e,%ah
movb %al, %cl
#if defined(__minix)
do_int:
#endif /* defined(__minix) */
int $0x10
calll _C_LABEL(real_to_prot) # back to protected mode
.code32
popa
ret
/**************************************************************************
GETC - Get a character
**************************************************************************/
ENTRY(congetc)
xorl %eax, %eax
pusha
call _C_LABEL(prot_to_real) # enter real mode
.code16
movb $0x0,%ah
int $0x16
movb %al,%bl
calll _C_LABEL(real_to_prot) # back to protected mode
.code32
movb %bl, 28(%esp)
popa
ret
/**************************************************************************
ISSHIFT - Check for keyboard interrupt; via shift key
**************************************************************************/
ENTRY(conisshift)
xorl %eax, %eax
pusha
call _C_LABEL(prot_to_real) # enter real mode
.code16
xor %bx,%bx
movb $0x2,%ah
int $0x16
testb $3,%al
setnz %bl
calll _C_LABEL(real_to_prot) # back to protected mode
.code32
movb %bl, 28(%esp)
popa
ret
/**************************************************************************
ISKEY - Check for keyboard input
**************************************************************************/
ENTRY(coniskey)
xorl %eax, %eax
pusha
call _C_LABEL(prot_to_real) # enter real mode
.code16
xor %bx,%bx
movb $0x1,%ah
int $0x16
setnz %bl
calll _C_LABEL(real_to_prot) # back to protected mode
.code32
movb %bl, 28(%esp)
popa
ret
|