1/* $NetBSD: conio.S,v 1.7 2011/06/16 13:27:59 joerg Exp $ */ 2 3/* PC console handling 4 originally from: FreeBSD:sys/i386/boot/netboot/start2.S 5 */ 6 7#include <machine/asm.h> 8 9 .text 10 11/************************************************************************** 12CLR - Clear screen 13**************************************************************************/ 14ENTRY(conclr) 15 pusha 16 17 call _C_LABEL(prot_to_real) # enter real mode 18 .code16 19 20 /* Clear screen. */ 21 movw $0x0600, %ax 22 movw $0x0700, %bx 23 xorw %cx, %cx 24 movw $0x184f, %dx /* 80x25 */ 25 int $0x10 26 27 /* Home cursor. */ 28 movb $0x02, %ah 29 xorw %bx, %bx 30 xorw %dx, %dx 31 int $0x10 32 33 calll _C_LABEL(real_to_prot) # back to protected mode 34 .code32 35 36 popa 37 ret 38 39/************************************************************************** 40PUTC - Print a character 41**************************************************************************/ 42ENTRY(conputc) 43 pusha 44 45 call _C_LABEL(prot_to_real) # enter real mode 46 .code16 47 48#if defined(__minix) 49 cmp $0x08, %al # backspace? 50 jne print_char 51 52 # Multiline backspace support. 53 push %ax 54 movb $0x3, %ah # get cursor position 55 xorw %bx, %bx 56 int $0x10 57 pop %ax 58 testb %dl, %dl # cursor on first column? 59 jnz print_char 60 testb %dh, %dh # cursor not on first row? 61 jz print_char 62 decb %dh # move up one row 63 movb $0x4f, %dl # move to last column 64 xorw %bx, %bx 65 movb $0x02, %ah # set cursor position 66 jmp do_int 67 68print_char: 69#endif /* defined(__minix) */ 70 movw $1,%bx 71 movb $0x0e,%ah 72 movb %al, %cl 73#if defined(__minix) 74do_int: 75#endif /* defined(__minix) */ 76 int $0x10 77 78 calll _C_LABEL(real_to_prot) # back to protected mode 79 .code32 80 81 popa 82 ret 83 84/************************************************************************** 85GETC - Get a character 86**************************************************************************/ 87ENTRY(congetc) 88 xorl %eax, %eax 89 pusha 90 91 call _C_LABEL(prot_to_real) # enter real mode 92 .code16 93 94 movb $0x0,%ah 95 int $0x16 96 movb %al,%bl 97 98 calll _C_LABEL(real_to_prot) # back to protected mode 99 .code32 100 101 movb %bl, 28(%esp) 102 103 popa 104 ret 105 106/************************************************************************** 107ISSHIFT - Check for keyboard interrupt; via shift key 108**************************************************************************/ 109ENTRY(conisshift) 110 xorl %eax, %eax 111 pusha 112 113 call _C_LABEL(prot_to_real) # enter real mode 114 .code16 115 116 xor %bx,%bx 117 movb $0x2,%ah 118 int $0x16 119 testb $3,%al 120 setnz %bl 121 122 calll _C_LABEL(real_to_prot) # back to protected mode 123 .code32 124 125 movb %bl, 28(%esp) 126 127 popa 128 ret 129 130/************************************************************************** 131ISKEY - Check for keyboard input 132**************************************************************************/ 133ENTRY(coniskey) 134 xorl %eax, %eax 135 pusha 136 137 call _C_LABEL(prot_to_real) # enter real mode 138 .code16 139 140 xor %bx,%bx 141 movb $0x1,%ah 142 int $0x16 143 setnz %bl 144 145 calll _C_LABEL(real_to_prot) # back to protected mode 146 .code32 147 148 movb %bl, 28(%esp) 149 150 popa 151 ret 152