1 1.4 dsl /* $NetBSD: comio.S,v 1.4 2003/04/16 14:23:11 dsl Exp $ */ 2 1.1 perry 3 1.1 perry /* serial console handling 4 1.1 perry modelled after code in 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.1 perry INIT - Initialization (com number) 13 1.1 perry **************************************************************************/ 14 1.1 perry ENTRY(cominit) 15 1.1 perry push %ebp 16 1.1 perry mov %esp,%ebp 17 1.1 perry push %ebx 18 1.1 perry push %edx 19 1.1 perry push %esi 20 1.1 perry push %edi 21 1.1 perry 22 1.1 perry movl 8(%ebp), %edx 23 1.1 perry 24 1.1 perry call _C_LABEL(prot_to_real) # enter real mode 25 1.3 dsl .code16 26 1.1 perry 27 1.1 perry # Initialize the serial port (dl) to 9600 baud, 8N1. 28 1.1 perry movb $0xe3, %al 29 1.1 perry movb $0, %ah 30 1.1 perry int $0x14 31 1.1 perry mov %ax,%bx 32 1.1 perry 33 1.3 dsl calll _C_LABEL(real_to_prot) # back to protected mode 34 1.3 dsl .code32 35 1.1 perry 36 1.1 perry xor %eax,%eax 37 1.1 perry mov %bx,%ax 38 1.1 perry 39 1.1 perry pop %edi 40 1.1 perry pop %esi 41 1.1 perry pop %edx 42 1.1 perry pop %ebx 43 1.1 perry pop %ebp 44 1.1 perry ret 45 1.1 perry 46 1.1 perry /************************************************************************** 47 1.1 perry PUTC - Print a character (char, com number) 48 1.1 perry **************************************************************************/ 49 1.1 perry ENTRY(computc) 50 1.1 perry push %ebp 51 1.1 perry mov %esp,%ebp 52 1.1 perry push %ecx 53 1.1 perry push %ebx 54 1.1 perry push %edx 55 1.1 perry push %esi 56 1.1 perry push %edi 57 1.1 perry 58 1.1 perry movb 8(%ebp),%cl 59 1.1 perry movl 12(%ebp),%edx 60 1.1 perry 61 1.1 perry call _C_LABEL(prot_to_real) # enter real mode 62 1.3 dsl .code16 63 1.1 perry 64 1.1 perry movb %cl,%al 65 1.1 perry movb $0x01, %ah 66 1.1 perry int $0x14 67 1.1 perry 68 1.1 perry movb %ah,%bl 69 1.1 perry 70 1.3 dsl calll _C_LABEL(real_to_prot) # back to protected mode 71 1.3 dsl .code32 72 1.1 perry 73 1.1 perry xor %eax,%eax 74 1.1 perry movb %bl,%al 75 1.1 perry 76 1.1 perry pop %edi 77 1.1 perry pop %esi 78 1.1 perry pop %edx 79 1.1 perry pop %ebx 80 1.1 perry pop %ecx 81 1.1 perry pop %ebp 82 1.1 perry ret 83 1.1 perry 84 1.1 perry /************************************************************************** 85 1.1 perry GETC - Get a character (com number) 86 1.1 perry **************************************************************************/ 87 1.1 perry ENTRY(comgetc) 88 1.1 perry push %ebp 89 1.1 perry mov %esp,%ebp 90 1.1 perry push %ebx 91 1.1 perry push %edx 92 1.1 perry push %esi 93 1.1 perry push %edi 94 1.1 perry 95 1.1 perry movl 8(%ebp),%edx 96 1.1 perry 97 1.1 perry call _C_LABEL(prot_to_real) # enter real mode 98 1.3 dsl .code16 99 1.1 perry 100 1.1 perry movb $0x02, %ah 101 1.1 perry int $0x14 102 1.3 dsl mov %ax, %bx 103 1.1 perry 104 1.3 dsl calll _C_LABEL(real_to_prot) # back to protected mode 105 1.3 dsl .code32 106 1.1 perry 107 1.1 perry xor %eax,%eax 108 1.2 drochner mov %bx,%ax 109 1.1 perry 110 1.1 perry pop %edi 111 1.1 perry pop %esi 112 1.1 perry pop %edx 113 1.1 perry pop %ebx 114 1.1 perry pop %ebp 115 1.1 perry ret 116 1.1 perry 117 1.1 perry /************************************************************************** 118 1.1 perry ISKEY - Check for keyboard interrupt (com number) 119 1.1 perry **************************************************************************/ 120 1.1 perry ENTRY(comstatus) 121 1.1 perry push %ebp 122 1.1 perry mov %esp,%ebp 123 1.1 perry push %ebx 124 1.1 perry push %edx 125 1.1 perry push %esi 126 1.1 perry push %edi 127 1.1 perry 128 1.1 perry movl 8(%ebp),%edx 129 1.1 perry 130 1.1 perry call _C_LABEL(prot_to_real) # enter real mode 131 1.3 dsl .code16 132 1.1 perry 133 1.1 perry movb $0x03, %ah 134 1.1 perry int $0x14 135 1.1 perry mov %ax,%bx 136 1.1 perry 137 1.3 dsl calll _C_LABEL(real_to_prot) # back to protected mode 138 1.3 dsl .code32 139 1.1 perry 140 1.1 perry xor %eax,%eax 141 1.1 perry mov %bx,%ax 142 1.1 perry 143 1.1 perry pop %edi 144 1.1 perry pop %esi 145 1.1 perry pop %edx 146 1.1 perry pop %ebx 147 1.1 perry pop %ebp 148 1.1 perry ret 149