1/* $NetBSD: conio.S,v 1.1.1.1 1997/03/14 02:40:32 perry 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#define data32 .byte 0x66 10 11 .text 12 13/************************************************************************** 14PUTC - Print a character 15**************************************************************************/ 16ENTRY(conputc) 17 push %ebp 18 mov %esp,%ebp 19 push %ecx 20 push %ebx 21 push %esi 22 push %edi 23 24 movb 8(%ebp),%cl 25 26 call _C_LABEL(prot_to_real) # enter real mode 27 28 movb %cl,%al 29 data32 30 mov $1,%ebx 31 movb $0x0e,%ah 32 int $0x10 33 34 data32 35 call _C_LABEL(real_to_prot) # back to protected mode 36 37 pop %edi 38 pop %esi 39 pop %ebx 40 pop %ecx 41 pop %ebp 42 ret 43 44/************************************************************************** 45GETC - Get a character 46**************************************************************************/ 47ENTRY(congetc) 48 push %ebp 49 mov %esp,%ebp 50 push %ebx 51 push %esi 52 push %edi 53 54 call _C_LABEL(prot_to_real) # enter real mode 55 56 movb $0x0,%ah 57 int $0x16 58 movb %al,%bl 59 60 data32 61 call _C_LABEL(real_to_prot) # back to protected mode 62 63 xor %eax,%eax 64 movb %bl,%al 65 66 pop %edi 67 pop %esi 68 pop %ebx 69 pop %ebp 70 ret 71 72/************************************************************************** 73ISKEY - Check for keyboard interrupt 74**************************************************************************/ 75ENTRY(coniskey) 76 push %ebp 77 mov %esp,%ebp 78 push %ebx 79 push %esi 80 push %edi 81 82 call _C_LABEL(prot_to_real) # enter real mode 83 84 xor %ebx,%ebx 85 movb $0x1,%ah 86 int $0x16 87 data32 88 jz 1f 89 movb %al,%bl 901: 91 92 data32 93 call _C_LABEL(real_to_prot) # back to protected mode 94 95 xor %eax,%eax 96 movb %bl,%al 97 98 pop %edi 99 pop %esi 100 pop %ebx 101 pop %ebp 102 ret 103