conio.S revision 1.2 1 1.2 dsl /* $NetBSD: conio.S,v 1.2 2003/02/01 14:48:18 dsl Exp $ */
2 1.1 perry
3 1.1 perry /* PC console handling
4 1.1 perry originally from: FreeBSD:sys/i386/boot/netboot/start2.S
5 1.1 perry */
6 1.1 perry
7 1.1 perry #include <machine/asm.h>
8 1.1 perry
9 1.1 perry #define data32 .byte 0x66
10 1.1 perry
11 1.1 perry .text
12 1.1 perry
13 1.1 perry /**************************************************************************
14 1.1 perry PUTC - Print a character
15 1.1 perry **************************************************************************/
16 1.1 perry ENTRY(conputc)
17 1.1 perry push %ebp
18 1.1 perry mov %esp,%ebp
19 1.1 perry push %ecx
20 1.1 perry push %ebx
21 1.1 perry push %esi
22 1.1 perry push %edi
23 1.1 perry
24 1.1 perry movb 8(%ebp),%cl
25 1.1 perry
26 1.1 perry call _C_LABEL(prot_to_real) # enter real mode
27 1.2 dsl .code16
28 1.1 perry
29 1.1 perry movb %cl,%al
30 1.2 dsl movw $1,%bx
31 1.1 perry movb $0x0e,%ah
32 1.1 perry int $0x10
33 1.1 perry
34 1.2 dsl calll _C_LABEL(real_to_prot) # back to protected mode
35 1.2 dsl .code32
36 1.1 perry
37 1.1 perry pop %edi
38 1.1 perry pop %esi
39 1.1 perry pop %ebx
40 1.1 perry pop %ecx
41 1.1 perry pop %ebp
42 1.1 perry ret
43 1.1 perry
44 1.1 perry /**************************************************************************
45 1.1 perry GETC - Get a character
46 1.1 perry **************************************************************************/
47 1.1 perry ENTRY(congetc)
48 1.1 perry push %ebp
49 1.1 perry mov %esp,%ebp
50 1.1 perry push %ebx
51 1.1 perry push %esi
52 1.1 perry push %edi
53 1.1 perry
54 1.1 perry call _C_LABEL(prot_to_real) # enter real mode
55 1.2 dsl .code16
56 1.1 perry
57 1.1 perry movb $0x0,%ah
58 1.1 perry int $0x16
59 1.1 perry movb %al,%bl
60 1.1 perry
61 1.2 dsl calll _C_LABEL(real_to_prot) # back to protected mode
62 1.2 dsl .code32
63 1.1 perry
64 1.1 perry xor %eax,%eax
65 1.1 perry movb %bl,%al
66 1.1 perry
67 1.1 perry pop %edi
68 1.1 perry pop %esi
69 1.1 perry pop %ebx
70 1.1 perry pop %ebp
71 1.1 perry ret
72 1.1 perry
73 1.1 perry /**************************************************************************
74 1.1 perry ISKEY - Check for keyboard interrupt
75 1.1 perry **************************************************************************/
76 1.1 perry ENTRY(coniskey)
77 1.1 perry push %ebp
78 1.1 perry mov %esp,%ebp
79 1.1 perry push %ebx
80 1.1 perry push %esi
81 1.1 perry push %edi
82 1.1 perry
83 1.1 perry call _C_LABEL(prot_to_real) # enter real mode
84 1.2 dsl .code16
85 1.1 perry
86 1.2 dsl xor %bx,%bx
87 1.1 perry movb $0x1,%ah
88 1.1 perry int $0x16
89 1.2 dsl movb $0,%bl
90 1.1 perry jz 1f
91 1.2 dsl incb %bl
92 1.1 perry 1:
93 1.1 perry
94 1.2 dsl calll _C_LABEL(real_to_prot) # back to protected mode
95 1.2 dsl .code32
96 1.1 perry
97 1.1 perry xor %eax,%eax
98 1.1 perry movb %bl,%al
99 1.1 perry
100 1.1 perry pop %edi
101 1.1 perry pop %esi
102 1.1 perry pop %ebx
103 1.1 perry pop %ebp
104 1.1 perry ret
105