1 1.7 joerg /* $NetBSD: conio.S,v 1.7 2011/06/16 13:27:59 joerg 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 .text 10 1.1 perry 11 1.1 perry /************************************************************************** 12 1.6 ad CLR - Clear screen 13 1.6 ad **************************************************************************/ 14 1.6 ad ENTRY(conclr) 15 1.7 joerg pusha 16 1.6 ad 17 1.6 ad call _C_LABEL(prot_to_real) # enter real mode 18 1.6 ad .code16 19 1.6 ad 20 1.6 ad /* Clear screen. */ 21 1.6 ad movw $0x0600, %ax 22 1.6 ad movw $0x0700, %bx 23 1.6 ad xorw %cx, %cx 24 1.6 ad movw $0x184f, %dx /* 80x25 */ 25 1.6 ad int $0x10 26 1.6 ad 27 1.6 ad /* Home cursor. */ 28 1.6 ad movb $0x02, %ah 29 1.6 ad xorw %bx, %bx 30 1.6 ad xorw %dx, %dx 31 1.6 ad int $0x10 32 1.6 ad 33 1.6 ad calll _C_LABEL(real_to_prot) # back to protected mode 34 1.6 ad .code32 35 1.6 ad 36 1.7 joerg popa 37 1.6 ad ret 38 1.6 ad 39 1.6 ad /************************************************************************** 40 1.1 perry PUTC - Print a character 41 1.1 perry **************************************************************************/ 42 1.1 perry ENTRY(conputc) 43 1.7 joerg pusha 44 1.1 perry 45 1.1 perry call _C_LABEL(prot_to_real) # enter real mode 46 1.2 dsl .code16 47 1.1 perry 48 1.2 dsl movw $1,%bx 49 1.1 perry movb $0x0e,%ah 50 1.7 joerg movb %al, %cl 51 1.1 perry int $0x10 52 1.1 perry 53 1.2 dsl calll _C_LABEL(real_to_prot) # back to protected mode 54 1.2 dsl .code32 55 1.1 perry 56 1.7 joerg popa 57 1.1 perry ret 58 1.1 perry 59 1.1 perry /************************************************************************** 60 1.1 perry GETC - Get a character 61 1.1 perry **************************************************************************/ 62 1.1 perry ENTRY(congetc) 63 1.7 joerg xorl %eax, %eax 64 1.7 joerg pusha 65 1.1 perry 66 1.1 perry call _C_LABEL(prot_to_real) # enter real mode 67 1.2 dsl .code16 68 1.1 perry 69 1.1 perry movb $0x0,%ah 70 1.1 perry int $0x16 71 1.1 perry movb %al,%bl 72 1.1 perry 73 1.2 dsl calll _C_LABEL(real_to_prot) # back to protected mode 74 1.2 dsl .code32 75 1.1 perry 76 1.7 joerg movb %bl, 28(%esp) 77 1.1 perry 78 1.7 joerg popa 79 1.1 perry ret 80 1.1 perry 81 1.1 perry /************************************************************************** 82 1.3 mycroft ISSHIFT - Check for keyboard interrupt; via shift key 83 1.3 mycroft **************************************************************************/ 84 1.3 mycroft ENTRY(conisshift) 85 1.7 joerg xorl %eax, %eax 86 1.7 joerg pusha 87 1.3 mycroft 88 1.3 mycroft call _C_LABEL(prot_to_real) # enter real mode 89 1.3 mycroft .code16 90 1.3 mycroft 91 1.3 mycroft xor %bx,%bx 92 1.3 mycroft movb $0x2,%ah 93 1.3 mycroft int $0x16 94 1.3 mycroft testb $3,%al 95 1.3 mycroft setnz %bl 96 1.3 mycroft 97 1.3 mycroft calll _C_LABEL(real_to_prot) # back to protected mode 98 1.3 mycroft .code32 99 1.3 mycroft 100 1.7 joerg movb %bl, 28(%esp) 101 1.3 mycroft 102 1.7 joerg popa 103 1.3 mycroft ret 104 1.3 mycroft 105 1.3 mycroft /************************************************************************** 106 1.3 mycroft ISKEY - Check for keyboard input 107 1.1 perry **************************************************************************/ 108 1.1 perry ENTRY(coniskey) 109 1.7 joerg xorl %eax, %eax 110 1.7 joerg pusha 111 1.1 perry 112 1.1 perry call _C_LABEL(prot_to_real) # enter real mode 113 1.2 dsl .code16 114 1.1 perry 115 1.2 dsl xor %bx,%bx 116 1.1 perry movb $0x1,%ah 117 1.1 perry int $0x16 118 1.3 mycroft setnz %bl 119 1.1 perry 120 1.2 dsl calll _C_LABEL(real_to_prot) # back to protected mode 121 1.2 dsl .code32 122 1.1 perry 123 1.7 joerg movb %bl, 28(%esp) 124 1.1 perry 125 1.7 joerg popa 126 1.1 perry ret 127