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