Some laptops return other values for working toucpads. Allow test_aux_port to
[dragonfly.git] / sys / i386 / boot / biosboot / table.c
1 /*
2  * Mach Operating System
3  * Copyright (c) 1992, 1991 Carnegie Mellon University
4  * All Rights Reserved.
5  *
6  * Permission to use, copy, modify and distribute this software and its
7  * documentation is hereby granted, provided that both the copyright
8  * notice and this permission notice appear in all copies of the
9  * software, derivative works or modified versions, and any portions
10  * thereof, and that both notices appear in supporting documentation.
11  *
12  * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
13  * CONDITION.  CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR
14  * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
15  *
16  * Carnegie Mellon requests users of this software to return to
17  *
18  *  Software Distribution Coordinator  or  Software.Distribution@CS.CMU.EDU
19  *  School of Computer Science
20  *  Carnegie Mellon University
21  *  Pittsburgh PA 15213-3890
22  *
23  * any improvements or extensions that they make and grant Carnegie Mellon
24  * the rights to redistribute these changes.
25  *
26  *      from: Mach, Revision 2.2  92/04/04  11:36:43  rpd
27  * $FreeBSD: src/sys/i386/boot/biosboot/table.c,v 1.20 1999/08/28 00:43:15 peter Exp $
28  * $DragonFly: src/sys/i386/boot/biosboot/Attic/table.c,v 1.2 2003/06/17 04:28:34 dillon Exp $
29  */
30
31 /*
32   Copyright 1988, 1989, 1990, 1991, 1992
33    by Intel Corporation, Santa Clara, California.
34
35                 All Rights Reserved
36
37 Permission to use, copy, modify, and distribute this software and
38 its documentation for any purpose and without fee is hereby
39 granted, provided that the above copyright notice appears in all
40 copies and that both the copyright notice and this permission notice
41 appear in supporting documentation, and that the name of Intel
42 not be used in advertising or publicity pertaining to distribution
43 of the software without specific, written prior permission.
44
45 INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
46 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
47 IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
48 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
49 LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
50 NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
51 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
52 */
53
54 #include "boot.h"
55
56 /*  Segment Descriptor
57  *
58  * 31          24         19   16                 7           0
59  * ------------------------------------------------------------
60  * |             | |B| |A|       | |   |1|0|E|W|A|            |
61  * | BASE 31..24 |G|/|0|V| LIMIT |P|DPL|  TYPE   | BASE 23:16 |
62  * |             | |D| |L| 19..16| |   |1|1|C|R|A|            |
63  * ------------------------------------------------------------
64  * |                             |                            |
65  * |        BASE 15..0           |       LIMIT 15..0          |
66  * |                             |                            |
67  * ------------------------------------------------------------
68  */
69
70 struct seg_desc {
71         unsigned short  limit_15_0;
72         unsigned short  base_15_0;
73         unsigned char   base_23_16;
74         unsigned char   p_dpl_type;
75         unsigned char   g_b_a_limit;
76         unsigned char   base_31_24;
77         };
78
79 #define RUN     0               /* not really 0, but filled in at boot time */
80
81 struct seg_desc Gdt[] = {
82         {0x0, 0x0, 0x0, 0x0, 0x0, 0x0},         /* 0x0 : null */
83         {0xFFFF, 0x0, 0x0, 0x9F, 0xCF, 0x0},    /* 0x08 : kernel code */
84                         /* 0x9E? */
85         {0xFFFF, 0x0, 0x0, 0x93, 0xCF, 0x0},    /* 0x10 : kernel data */
86                         /* 0x92? */
87         {0xFFFF, RUN, RUN, 0x9E, 0x40, 0x0},    /* 0x18 : boot code */
88         {0xFFFF, RUN, RUN, 0x92, 0x40, 0x0},    /* 0x20 : boot data */
89         {0xFFFF, RUN, RUN, 0x9E, 0x0, 0x0},     /* 0x28 : boot code, 16 bits */
90         {0xFFFF, 0x0, 0x0, 0x92, 0x0, 0x0},     /* 0x30 : boot data, 16 bits */
91 #ifdef BDE_DEBUGGER
92         /* More for bdb. */
93         {},                                     /* BIOS_TMP_INDEX = 7 : null */
94         {},                                     /* TSS_INDEX = 8 : null */
95         {0xFFFF, 0x0, 0x0, 0xB2, 0x40, 0x0},    /* DS_286_INDEX = 9 */
96         {0xFFFF, 0x0, 0x0, 0xB2, 0x40, 0x0},    /* ES_286_INDEX = 10 */
97         {},                                     /* Unused = 11 : null */
98         {0x7FFF, 0x8000, 0xB, 0xB2, 0x40, 0x0}, /* COLOR_INDEX = 12 */
99         {0x7FFF, 0x0, 0xB, 0xB2, 0x40, 0x0},    /* MONO_INDEX = 13 */
100         {0xFFFF, RUN, RUN, 0x9A, 0x40, 0x0},    /* DB_CS_INDEX = 14 */
101         {0xFFFF, RUN, RUN, 0x9A, 0x0, 0x0},     /* DB_CS16_INDEX = 15 */
102         {0xFFFF, RUN, RUN, 0x92, 0x40, 0x0},    /* DB_DS_INDEX = 16 */
103         {8*18-1, RUN, RUN, 0x92, 0x40, 0x0},    /* GDT_INDEX = 17 */
104 #endif /* BDE_DEBUGGER */
105 };
106
107 #ifdef BDE_DEBUGGER
108 struct idt_desc {
109         unsigned short  entry_15_0;
110         unsigned short  selector;
111         unsigned char   padding;
112         unsigned char   p_dpl_type;
113         unsigned short  entry_31_16;
114 };
115
116 struct idt_desc Idt[] = {
117         {},                                     /* Null (int 0) */
118         {RUN, 0x70, 0, 0x8E, 0},                /* DEBUG_VECTOR = 1 */
119         {},                                     /* Null (int 2) */
120         {RUN, 0x70, 0, 0xEE, 0},                /* BREAKPOINT_VECTOR = 3 */
121 };
122 #endif /* BDE_DEBUGGER */
123
124 struct pseudo_desc {
125         unsigned short  limit;
126         unsigned short  base_low;
127         unsigned short  base_high;
128         };
129
130 struct pseudo_desc Gdtr = { sizeof Gdt - 1, RUN, RUN };
131 #ifdef BDE_DEBUGGER
132 struct pseudo_desc Idtr_prot = { sizeof Idt - 1, RUN, RUN };
133 struct pseudo_desc Idtr_real = { 0x400 - 1, 0x0, 0x0 };
134 #endif
135
136 /*
137  * All initialized data is defined in one file to reduce space wastage from
138  * fragmentation.
139  */
140 char *devs[] = { "wd", "dk", "fd", "wt", "da", 0 };
141 unsigned tw_chars = 0x5C2D2F7C; /* "\-/|" */