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 movw $1,%bx 49 movb $0x0e,%ah 50 movb %al, %cl 51 int $0x10 52 53 calll _C_LABEL(real_to_prot) # back to protected mode 54 .code32 55 56 popa 57 ret 58 59/************************************************************************** 60GETC - Get a character 61**************************************************************************/ 62ENTRY(congetc) 63 xorl %eax, %eax 64 pusha 65 66 call _C_LABEL(prot_to_real) # enter real mode 67 .code16 68 69 movb $0x0,%ah 70 int $0x16 71 movb %al,%bl 72 73 calll _C_LABEL(real_to_prot) # back to protected mode 74 .code32 75 76 movb %bl, 28(%esp) 77 78 popa 79 ret 80 81/************************************************************************** 82ISSHIFT - Check for keyboard interrupt; via shift key 83**************************************************************************/ 84ENTRY(conisshift) 85 xorl %eax, %eax 86 pusha 87 88 call _C_LABEL(prot_to_real) # enter real mode 89 .code16 90 91 xor %bx,%bx 92 movb $0x2,%ah 93 int $0x16 94 testb $3,%al 95 setnz %bl 96 97 calll _C_LABEL(real_to_prot) # back to protected mode 98 .code32 99 100 movb %bl, 28(%esp) 101 102 popa 103 ret 104 105/************************************************************************** 106ISKEY - Check for keyboard input 107**************************************************************************/ 108ENTRY(coniskey) 109 xorl %eax, %eax 110 pusha 111 112 call _C_LABEL(prot_to_real) # enter real mode 113 .code16 114 115 xor %bx,%bx 116 movb $0x1,%ah 117 int $0x16 118 setnz %bl 119 120 calll _C_LABEL(real_to_prot) # back to protected mode 121 .code32 122 123 movb %bl, 28(%esp) 124 125 popa 126 ret 127