comconsole.c (38466) | comconsole.c (39441) |
---|---|
1/* 2 * Copyright (c) 1998 Michael Smith (msmith@freebsd.org) 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 10 unchanged lines hidden (view full) --- 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 * 25 * From Id: probe_keyboard.c,v 1.13 1997/06/09 05:10:55 bde Exp 26 * | 1/* 2 * Copyright (c) 1998 Michael Smith (msmith@freebsd.org) 3 * 4 * Redistribution and use in source and binary forms, with or without 5 * modification, are permitted provided that the following conditions 6 * are met: 7 * 1. Redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer. --- 10 unchanged lines hidden (view full) --- 19 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23 * SUCH DAMAGE. 24 * 25 * From Id: probe_keyboard.c,v 1.13 1997/06/09 05:10:55 bde Exp 26 * |
27 * $Id$ | 27 * $Id: comconsole.c,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $ |
28 */ 29 30#include <stand.h> | 28 */ 29 30#include <stand.h> |
31#include <bootstrap.h> 32#include <btxv86.h> 33#include "libi386.h" |
|
31 | 34 |
32#include "bootstrap.h" 33 34/* in comconsole.S */ 35extern void cominit(int s); 36extern void computc(int c); 37extern int comgetc(void); 38extern int comiskey(void); 39 | |
40static void comc_probe(struct console *cp); 41static int comc_init(int arg); | 35static void comc_probe(struct console *cp); 36static int comc_init(int arg); |
42static int comc_in(void); | 37static void comc_putchar(int c); 38static int comc_getchar(void); 39static int comc_ischar(void); |
43 44struct console comconsole = { 45 "comconsole", 46 "BIOS serial port", 47 0, 48 comc_probe, 49 comc_init, | 40 41struct console comconsole = { 42 "comconsole", 43 "BIOS serial port", 44 0, 45 comc_probe, 46 comc_init, |
50 computc, 51 comc_in, 52 comiskey | 47 comc_putchar, 48 comc_getchar, 49 comc_ischar |
53}; 54 | 50}; 51 |
52#define BIOS_COMPORT 0 53 |
|
55static void 56comc_probe(struct console *cp) 57{ 58 /* XXX check the BIOS equipment list? */ 59 cp->c_flags |= (C_PRESENTIN | C_PRESENTOUT); 60} 61 62static int 63comc_init(int arg) 64{ | 54static void 55comc_probe(struct console *cp) 56{ 57 /* XXX check the BIOS equipment list? */ 58 cp->c_flags |= (C_PRESENTIN | C_PRESENTOUT); 59} 60 61static int 62comc_init(int arg) 63{ |
65 /* XXX arg is unit number, should we use variables instead? */ 66 cominit(arg); 67 return(0); | 64 v86.ctl = V86_FLAGS; 65 v86.addr = 0x14; 66 v86.eax = 0xe3; /* 9600N81 */ 67 v86.edx = BIOS_COMPORT; /* XXX take as arg, or use env var? */ 68 v86int(); 69 return(v86.efl & 1); |
68} 69 | 70} 71 |
72static void 73comc_putchar(int c) 74{ 75 v86.ctl = 0; 76 v86.addr = 0x14; 77 v86.eax = 0x100 | c; 78 v86int(); 79} 80 |
|
70static int | 81static int |
71comc_in(void) | 82comc_getchar(void) |
72{ | 83{ |
73 if (comiskey()) { 74 return(comgetc()); | 84 if (comc_ischar()) { 85 v86.ctl = 0; 86 v86.addr = 0x14; 87 v86.eax = 0x300; 88 v86int(); 89 return(v86.eax); |
75 } else { 76 return(-1); 77 } 78} | 90 } else { 91 return(-1); 92 } 93} |
94 95static int 96comc_ischar(void) 97{ 98 v86.ctl = 0; 99 v86.addr = 0x14; 100 v86.eax = 0x200; 101 v86int(); 102 return(v86.eax & 0x1); 103} |
|