Fully synchronize sys/boot from FreeBSD-5.x, but add / to the module path
[dragonfly.git] / sys / boot / pc98 / boot2 / 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  */
28 /*
29   Copyright 1988, 1989, 1990, 1991, 1992
30    by Intel Corporation, Santa Clara, California.
31
32                 All Rights Reserved
33
34 Permission to use, copy, modify, and distribute this software and
35 its documentation for any purpose and without fee is hereby
36 granted, provided that the above copyright notice appears in all
37 copies and that both the copyright notice and this permission notice
38 appear in supporting documentation, and that the name of Intel
39 not be used in advertising or publicity pertaining to distribution
40 of the software without specific, written prior permission.
41
42 INTEL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
43 INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS,
44 IN NO EVENT SHALL INTEL BE LIABLE FOR ANY SPECIAL, INDIRECT, OR
45 CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
46 LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT,
47 NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION
48 WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
49 */
50
51 /*
52  * $FreeBSD: src/sys/boot/pc98/boot2/table.c,v 1.4 2003/09/08 09:11:20 obrien Exp $
53  * $DragonFly: src/sys/boot/pc98/boot2/Attic/table.c,v 1.3 2003/11/10 06:08:38 dillon Exp $
54  */
55
56 #include "boot.h"
57
58 /*  Segment Descriptor
59  *
60  * 31          24         19   16                 7           0
61  * ------------------------------------------------------------
62  * |             | |B| |A|       | |   |1|0|E|W|A|            |
63  * | BASE 31..24 |G|/|0|V| LIMIT |P|DPL|  TYPE   | BASE 23:16 |
64  * |             | |D| |L| 19..16| |   |1|1|C|R|A|            |
65  * ------------------------------------------------------------
66  * |                             |                            |
67  * |        BASE 15..0           |       LIMIT 15..0          |
68  * |                             |                            |
69  * ------------------------------------------------------------
70  */
71
72 struct seg_desc {
73         unsigned short  limit_15_0;
74         unsigned short  base_15_0;
75         unsigned char   base_23_16;
76         unsigned char   p_dpl_type;
77         unsigned char   g_b_a_limit;
78         unsigned char   base_31_24;
79         };
80
81 #define RUN     0               /* not really 0, but filled in at boot time */
82
83 struct seg_desc Gdt[] = {
84         {0x0, 0x0, 0x0, 0x0, 0x0, 0x0},         /* 0x0 : null */
85         {0xFFFF, 0x0, 0x0, 0x9F, 0xCF, 0x0},    /* 0x08 : kernel code */
86                         /* 0x9E? */
87         {0xFFFF, 0x0, 0x0, 0x93, 0xCF, 0x0},    /* 0x10 : kernel data */
88                         /* 0x92? */
89         {0xFFFF, RUN, RUN, 0x9E, 0x40, 0x0},    /* 0x18 : boot code */
90 #ifdef PC98
91         /*
92          * The limit of boot data should be more than or equal to 0x9FFFF
93          * for saving BIOS parameter and EPSON machine ID into 2'nd T-VRAM,
94          * because base address is normally 0x10000.
95          */
96         {0xFFFF, RUN, RUN, 0x92, 0x4F, 0x0},    /* 0x20 : boot data */
97 #else
98         {0xFFFF, RUN, RUN, 0x92, 0x40, 0x0},    /* 0x20 : boot data */
99 #endif
100         {0xFFFF, RUN, RUN, 0x9E, 0x0, 0x0},     /* 0x28 : boot code, 16 bits */
101         {0xFFFF, 0x0, 0x0, 0x92, 0x0, 0x0},     /* 0x30 : boot data, 16 bits */
102 #ifdef BDE_DEBUGGER
103         /* More for bdb. */
104         {},                                     /* BIOS_TMP_INDEX = 7 : null */
105         {},                                     /* TSS_INDEX = 8 : null */
106         {0xFFFF, 0x0, 0x0, 0xB2, 0x40, 0x0},    /* DS_286_INDEX = 9 */
107         {0xFFFF, 0x0, 0x0, 0xB2, 0x40, 0x0},    /* ES_286_INDEX = 10 */
108         {},                                     /* Unused = 11 : null */
109         {0x7FFF, 0x8000, 0xB, 0xB2, 0x40, 0x0}, /* COLOR_INDEX = 12 */
110         {0x7FFF, 0x0, 0xB, 0xB2, 0x40, 0x0},    /* MONO_INDEX = 13 */
111         {0xFFFF, RUN, RUN, 0x9A, 0x40, 0x0},    /* DB_CS_INDEX = 14 */
112         {0xFFFF, RUN, RUN, 0x9A, 0x0, 0x0},     /* DB_CS16_INDEX = 15 */
113         {0xFFFF, RUN, RUN, 0x92, 0x40, 0x0},    /* DB_DS_INDEX = 16 */
114         {8*18-1, RUN, RUN, 0x92, 0x40, 0x0},    /* GDT_INDEX = 17 */
115 #endif /* BDE_DEBUGGER */
116 };
117
118 #ifdef BDE_DEBUGGER
119 struct idt_desc {
120         unsigned short  entry_15_0;
121         unsigned short  selector;
122         unsigned char   padding;
123         unsigned char   p_dpl_type;
124         unsigned short  entry_31_16;
125 };
126
127 struct idt_desc Idt[] = {
128         {},                                     /* Null (int 0) */
129         {RUN, 0x70, 0, 0x8E, 0},                /* DEBUG_VECTOR = 1 */
130         {},                                     /* Null (int 2) */
131         {RUN, 0x70, 0, 0xEE, 0},                /* BREAKPOINT_VECTOR = 3 */
132 };
133 #endif /* BDE_DEBUGGER */
134
135 struct pseudo_desc {
136         unsigned short  limit;
137         unsigned short  base_low;
138         unsigned short  base_high;
139         };
140
141 struct pseudo_desc Gdtr = { sizeof Gdt - 1, RUN, RUN };
142 #ifdef BDE_DEBUGGER
143 struct pseudo_desc Idtr_prot = { sizeof Idt - 1, RUN, RUN };
144 struct pseudo_desc Idtr_real = { 0x400 - 1, 0x0, 0x0 };
145 #endif
146
147 /*
148  * All initialized data is defined in one file to reduce space wastage from
149  * fragmentation.
150  */
151 char *devs[] = { "wd", "dk", "fd", "wt", "da", "dk", "fd", 0 };
152 unsigned tw_chars = 0x5C2D2F7C; /* "\-/|" */