Deleted Added
full compact
comconsole.c (39441) comconsole.c (39896)
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.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
13 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
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: comconsole.c,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $
27 * $Id: comconsole.c,v 1.2 1998/09/17 23:52:09 msmith Exp $
28 */
29
30#include <stand.h>
31#include <bootstrap.h>
32#include <btxv86.h>
33#include "libi386.h"
34
35static void comc_probe(struct console *cp);
36static int comc_init(int arg);
37static void comc_putchar(int c);
38static int comc_getchar(void);
39static int comc_ischar(void);
40
41struct console comconsole = {
42 "comconsole",
43 "BIOS serial port",
44 0,
45 comc_probe,
46 comc_init,
47 comc_putchar,
48 comc_getchar,
49 comc_ischar
50};
51
52#define BIOS_COMPORT 0
53
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{
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);
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
81static int
82comc_getchar(void)
83{
84 if (comc_ischar()) {
85 v86.ctl = 0;
86 v86.addr = 0x14;
87 v86.eax = 0x300;
88 v86int();
28 */
29
30#include <stand.h>
31#include <bootstrap.h>
32#include <btxv86.h>
33#include "libi386.h"
34
35static void comc_probe(struct console *cp);
36static int comc_init(int arg);
37static void comc_putchar(int c);
38static int comc_getchar(void);
39static int comc_ischar(void);
40
41struct console comconsole = {
42 "comconsole",
43 "BIOS serial port",
44 0,
45 comc_probe,
46 comc_init,
47 comc_putchar,
48 comc_getchar,
49 comc_ischar
50};
51
52#define BIOS_COMPORT 0
53
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{
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);
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
81static int
82comc_getchar(void)
83{
84 if (comc_ischar()) {
85 v86.ctl = 0;
86 v86.addr = 0x14;
87 v86.eax = 0x300;
88 v86int();
89 return(v86.eax);
89 return(v86.eax & 0xff);
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}
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}