2 * Copyright (c) 1992, 1993, 1996
3 * Berkeley Software Design, Inc. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Berkeley Software
18 * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL Berkeley Software Design, Inc. BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * BSDI bios.c,v 2.3 1996/04/08 19:32:19 bostic Exp
39 #define BIOS_copyright 0xfe000
40 #define BIOS_reset 0xfe05b
41 #define BIOS_nmi 0xfe2c3
42 #define BIOS_hdisk_table 0xfe401
43 #define BIOS_boot 0xfe6f2
44 #define BIOS_comm_table 0xfe729
45 #define BIOS_comm_io 0xfe739
46 #define BIOS_keyboard_io 0xfe82e
47 #define BIOS_keyboard_isr 0xfe987
48 #define BIOS_fdisk_io 0xfec59
49 #define BIOS_fdisk_isr 0xfef57
50 #define BIOS_disk_parms 0xfefc7
51 #define BIOS_printer_io 0xfefd2
52 #define BIOS_video_io 0xff065
53 #define BIOS_video_parms 0xff0a4
54 #define BIOS_mem_size 0xff841
55 #define BIOS_equipment 0xff84d
56 #define BIOS_cassette_io 0xff859
57 #define BIOS_video_font 0xffa6e
58 #define BIOS_time_of_day 0xffe6e
59 #define BIOS_timer_int 0xffea5
60 #define BIOS_vector 0xffef3
61 #define BIOS_dummy_iret 0xfff53
62 #define BIOS_print_screen 0xfff54
63 #define BIOS_hard_reset 0xffff0
64 #define BIOS_date_stamp 0xffff5
65 #define BIOS_hardware_id 0xffffe
67 static u_char video_parms[] = {
68 0x38, 40, 0x2d, 10, 0x1f, 6, 0x19, 0x1c, 2, 7, 6, 7, 0, 0, 0, 0,
69 0x71, 80, 0x5a, 10, 0x1f, 6, 0x19, 0x1c, 2, 7, 6, 7, 0, 0, 0, 0,
70 0x38, 40, 0x2d, 10, 0x7f, 6, 0x64, 0x70, 2, 1, 6, 7, 0, 0, 0, 0,
71 0x61, 80, 0x52, 15, 0x19, 6, 0x19, 0x19, 2, 13, 11, 12, 0, 0, 0, 0,
74 static u_char disk_params[] = {
75 0xdf, 2, 0x25, 2, 0x0f, 0x1b, 0xff, 0x54, 0xf6, 0x0f, 8,
78 static u_short comm_table[] = {
79 1047, 768, 384, 192, 96, 48, 24, 12,
88 unsigned long rom_config;
91 ** BIOS equipment list
94 int11(regcontext_t *REGS)
97 (nfloppies ? 1:0) | /* do we have any floppydisks? */
98 (0x2 << 4) | /* 80x25 colour */
99 ((nfloppies-1) << 6) | /* how many floppies? */
100 (nserial << 9) | /* serial ports? */
101 (nparallel << 14); /* parallel ports? */
105 ** get installed memory
108 int12(regcontext_t *REGS)
117 int15(regcontext_t *REGS)
125 case 0x00: /* Get Cassette Status */
127 R_FLAGS |= PSL_C; /* We don't support a cassette */
130 case 0x04: /* Set ABIOS table */
131 R_FLAGS |= PSL_C; /* We don't support it */
136 * XXX - Check scan code in GET8L(sc->sc_eax).
140 get_raw_extmemory_info(REGS);
142 case 0xc0: /* get configuration */
143 debug (D_TRAPS|0x15, "Get configuration\n", R_DX);
144 PUTVEC(R_ES, R_BX, rom_config);
147 case 0xc1: /* get extended BIOS data area */
150 case 0xc2: /* Pointing device */
152 R_AH = 5; /* No pointer */
155 unknown_int2(0x15, R_AX, REGS);
161 extern void int16(regcontext_t *REGS);
162 extern void int17(regcontext_t *REGS);
163 extern void int1a(regcontext_t *REGS);
177 strcpy((char *)BIOS_copyright,
178 "Copyright (C) 1993 Krystal Technologies/BSDI");
180 *(u_short *)BIOS_reset = 0xffcd;
181 *(u_short *)BIOS_nmi = 0xffcd;
182 *(u_short *)BIOS_boot = 0xffcd;
183 *(u_short *)BIOS_comm_io = 0xffcd;
184 *(u_short *)BIOS_keyboard_io = 0xffcd;
185 *(u_short *)BIOS_keyboard_isr = 0xffcd;
186 *(u_short *)BIOS_fdisk_io = 0xffcd;
187 *(u_short *)BIOS_fdisk_isr = 0xffcd;
188 *(u_short *)BIOS_printer_io = 0xffcd;
189 *(u_short *)BIOS_video_io = 0xffcd;
190 *(u_short *)BIOS_cassette_io = 0xffcd;
191 *(u_short *)BIOS_time_of_day = 0xffcd;
192 *(u_short *)BIOS_timer_int = 0xffcd;
193 *(u_short *)BIOS_dummy_iret = 0xffcd;
194 *(u_short *)BIOS_print_screen = 0xffcd;
195 *(u_short *)BIOS_hard_reset = 0xffcd;
196 *(u_short *)BIOS_mem_size = 0xffcd;
197 *(u_short *)BIOS_equipment = 0xffcd;
198 *(u_short *)BIOS_vector = 0xffcd;
199 *(u_char *)0xffff2 = 0xcf; /* IRET */
202 *memcpy((u_char *)BIOS_video_parms, video_parms, sizeof(video_parms));
204 memcpy((u_char *)BIOS_disk_parms, disk_params, sizeof(disk_params));
205 memcpy((u_char *)BIOS_comm_table, comm_table, sizeof(comm_table));
207 *(u_short *)BIOS_video_font = 0xffcd;
209 jtab = (u_char *)BIOS_date_stamp;
220 *(u_char *)BIOS_hardware_id = 0xfe; /* Identify as a PC/XT */
221 *(u_char *)BIOS_hardware_id = 0xff; /* Identify as a PC */
223 *(u_char *)BIOS_hardware_id = 0xfc; /* Identify as a PC/AT */
227 * Interrupt revectors F000:0000 - F000:03ff
229 for (i = 0, j = 0, k = 0; i < 0x100; ++i) {
230 if ((i >= 0x60 && i < 0x68) ||
231 (i >= 0x78 && i < 0xe2))
233 if ((i >= 0x00 && i < 0x2f) ||
234 (i >= 0x30 && i < 0xfe)) {
235 ivec[i] = 0xF0300000L | (k * 1);
236 jtab = (u_char *)VECPTR(ivec[i]);
237 *jtab++ = 0xf4; /* HLT */
240 ivec[i] = 0xF0000000L | (j * 6);
241 jtab = (u_char *)VECPTR(ivec[i]);
242 *jtab++ = 0xcd; /* INT i */
244 *jtab++ = 0xca; /* RETF 2 */
252 * Misc variables from F000:0400 - F000:0fff
254 rom_config = 0xF0000400;
255 jtab = (u_char *)VECPTR(rom_config);
256 *jtab++ = 20; /* length of entry */
258 *jtab++ = *(u_char *)BIOS_hardware_id;
259 *jtab++ = 0x00; /* Sub model */
260 *jtab++ = 0x01; /* Bios Rev Enhanced kbd w/3.5" floppy */
261 *jtab++ = 0x20; /* real time clock present */
262 *jtab++ = 0; /* Reserved */
266 strcpy((char *)jtab, "BSDI BIOS");
275 *(u_short *)&BIOSDATA[0x10] =
276 (1 << 0) | /* Diskette avail for boot */
277 (1 << 1) | /* Math co-processor */
278 (nmice << 2) | /* No pointing device */
279 (2 << 4) | /* Initial video (80 x 25 C) */
280 (nfloppies - 1 << 6) | /* Number of floppies - 1 */
281 (nserial << 9) | /* Number of serial devices */
282 (nparallel << 14); /* Number of parallel devices */
285 *(u_short *)&BIOSDATA[0x13] = 640; /* Amount of memory */
286 BIOSDATA[0x75] = ndisks; /* number of fixed disks */
289 if (nfloppies >= 1) {
290 BIOSDATA[0x8F] |= 0x04;
291 BIOSDATA[0x90] = 0x40;
293 if (nfloppies >= 2) {
294 BIOSDATA[0x8F] |= 0x40;
295 BIOSDATA[0x91] = 0x40;
298 gettimeofday(&tv, &tz);
300 tm = *localtime(&tv_sec);
301 *(u_long *)&BIOSDATA[0x6c] =
302 (((tm.tm_hour * 60 + tm.tm_min) * 60) + tm.tm_sec) * 182 / 10;
304 vec = insert_softint_trampoline();
306 register_callback(vec, int11, "int 11");
308 vec = insert_softint_trampoline();
310 register_callback(vec, int12, "int 12");
312 vec = insert_softint_trampoline();
314 register_callback(vec, int14, "int 14");
316 vec = insert_softint_trampoline();
318 register_callback(vec, int15, "int 15");
320 vec = insert_softint_trampoline();
322 register_callback(vec, int16, "int 16");
324 vec = insert_softint_trampoline();
326 register_callback(vec, int17, "int 17");
328 vec = insert_softint_trampoline();
330 register_callback(vec, int1a, "int 1a");