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
32 * $FreeBSD: src/usr.bin/doscmd/bios.c,v 1.5.2.1 2002/04/25 11:04:50 tg Exp $
33 * $DragonFly: src/usr.bin/doscmd/bios.c,v 1.2 2003/06/17 04:29:25 dillon Exp $
40 #define BIOS_copyright 0xfe000
41 #define BIOS_reset 0xfe05b
42 #define BIOS_nmi 0xfe2c3
43 #define BIOS_hdisk_table 0xfe401
44 #define BIOS_boot 0xfe6f2
45 #define BIOS_comm_table 0xfe729
46 #define BIOS_comm_io 0xfe739
47 #define BIOS_keyboard_io 0xfe82e
48 #define BIOS_keyboard_isr 0xfe987
49 #define BIOS_fdisk_io 0xfec59
50 #define BIOS_fdisk_isr 0xfef57
51 #define BIOS_disk_parms 0xfefc7
52 #define BIOS_printer_io 0xfefd2
53 #define BIOS_video_io 0xff065
54 #define BIOS_video_parms 0xff0a4
55 #define BIOS_mem_size 0xff841
56 #define BIOS_equipment 0xff84d
57 #define BIOS_cassette_io 0xff859
58 #define BIOS_video_font 0xffa6e
59 #define BIOS_time_of_day 0xffe6e
60 #define BIOS_timer_int 0xffea5
61 #define BIOS_vector 0xffef3
62 #define BIOS_dummy_iret 0xfff53
63 #define BIOS_print_screen 0xfff54
64 #define BIOS_hard_reset 0xffff0
65 #define BIOS_date_stamp 0xffff5
66 #define BIOS_hardware_id 0xffffe
68 static u_char disk_params[] = {
69 0xdf, 2, 0x25, 2, 0x0f, 0x1b, 0xff, 0x54, 0xf6, 0x0f, 8,
72 static u_short comm_table[] = {
73 1047, 768, 384, 192, 96, 48, 24, 12,
82 unsigned long rom_config;
85 ** BIOS equipment list
88 int11(regcontext_t *REGS)
91 (nfloppies ? 1:0) | /* do we have any floppydisks? */
92 (0x2 << 4) | /* 80x25 colour */
93 ((nfloppies-1) << 6) | /* how many floppies? */
94 (nserial << 9) | /* serial ports? */
95 (nparallel << 14); /* parallel ports? */
99 ** get installed memory
102 int12(regcontext_t *REGS)
111 int15(regcontext_t *REGS)
116 case 0x00: /* Get Cassette Status */
118 R_FLAGS |= PSL_C; /* We don't support a cassette */
120 case 0x04: /* Set ABIOS table */
121 R_FLAGS |= PSL_C; /* We don't support it */
123 case 0x4f: /* Keyboard intercept */
124 debug(D_TRAPS | 0x15, "BIOS: Keyboard intercept\n");
125 /* Don't translate scan code. */
128 get_raw_extmemory_info(REGS);
130 case 0xc0: /* Get configuration */
131 debug(D_TRAPS | 0x15, "BIOS: Get configuration\n");
132 PUTVEC(R_ES, R_BX, rom_config);
135 case 0xc1: /* Get extended BIOS data area */
138 case 0xc2: /* Pointing device */
139 debug(D_TRAPS | 0x15, "BIOS: Pointing device?\n");
141 R_AH = 5; /* No pointer */
144 unknown_int2(0x15, R_AX, REGS);
160 strcpy((char *)BIOS_copyright,
161 "Copyright (C) 1993 Krystal Technologies/BSDI");
163 *(u_short *)BIOS_reset = 0xffcd;
164 *(u_short *)BIOS_nmi = 0xffcd;
165 *(u_short *)BIOS_boot = 0xffcd;
166 *(u_short *)BIOS_comm_io = 0xffcd;
167 *(u_short *)BIOS_keyboard_io = 0xffcd;
168 *(u_short *)BIOS_keyboard_isr = 0xffcd;
169 *(u_short *)BIOS_fdisk_io = 0xffcd;
170 *(u_short *)BIOS_fdisk_isr = 0xffcd;
171 *(u_short *)BIOS_printer_io = 0xffcd;
172 *(u_short *)BIOS_video_io = 0xffcd;
173 *(u_short *)BIOS_cassette_io = 0xffcd;
174 *(u_short *)BIOS_time_of_day = 0xffcd;
175 *(u_short *)BIOS_timer_int = 0xffcd;
176 *(u_short *)BIOS_dummy_iret = 0xffcd;
177 *(u_short *)BIOS_print_screen = 0xffcd;
178 *(u_short *)BIOS_hard_reset = 0xffcd;
179 *(u_short *)BIOS_mem_size = 0xffcd;
180 *(u_short *)BIOS_equipment = 0xffcd;
181 *(u_short *)BIOS_vector = 0xffcd;
182 *(u_char *)0xffff2 = 0xcf; /* IRET */
184 memcpy((u_char *)BIOS_disk_parms, disk_params, sizeof(disk_params));
185 memcpy((u_char *)BIOS_comm_table, comm_table, sizeof(comm_table));
187 *(u_short *)BIOS_video_font = 0xffcd;
189 jtab = (u_char *)BIOS_date_stamp;
199 *(u_char *)BIOS_hardware_id = 0xfc; /* Identify as a PC/AT */
202 * Interrupt revectors F000:0000 - F000:03ff
204 for (i = 0, j = 0, k = 0; i < 0x100; ++i) {
205 if ((i >= 0x60 && i < 0x68) ||
206 (i >= 0x78 && i < 0xe2))
208 if ((i >= 0x00 && i < 0x2f) ||
209 (i >= 0x30 && i < 0xfe)) {
210 ivec[i] = 0xF0300000L | (k * 1);
211 jtab = (u_char *)VECPTR(ivec[i]);
212 *jtab++ = 0xf4; /* HLT */
215 ivec[i] = 0xF0000000L | (j * 6);
216 jtab = (u_char *)VECPTR(ivec[i]);
217 *jtab++ = 0xcd; /* INT i */
219 *jtab++ = 0xca; /* RETF 2 */
227 * Misc variables from F000:0400 - F000:0fff
229 rom_config = 0xF0000400;
230 jtab = (u_char *)VECPTR(rom_config);
231 *jtab++ = 20; /* length of entry */
233 *jtab++ = *(u_char *)BIOS_hardware_id;
234 *jtab++ = 0x00; /* Sub model */
235 *jtab++ = 0x01; /* Bios Rev Enhanced kbd w/3.5" floppy */
236 *jtab++ = 0x20; /* real time clock present */
237 *jtab++ = 0; /* Reserved */
241 strcpy((char *)jtab, "BSDI BIOS");
250 *(u_short *)&BIOSDATA[0x10] =
251 (1 << 0) | /* Diskette avail for boot */
252 (1 << 1) | /* Math co-processor */
253 (nmice << 2) | /* No pointing device */
254 (2 << 4) | /* Initial video (80 x 25 C) */
255 ((nfloppies - 1) << 6) | /* Number of floppies - 1 */
256 (nserial << 9) | /* Number of serial devices */
257 (nparallel << 14); /* Number of parallel devices */
260 *(u_short *)&BIOSDATA[0x13] = 640; /* Amount of memory */
261 BIOSDATA[0x75] = ndisks; /* number of fixed disks */
264 if (nfloppies >= 1) {
265 BIOSDATA[0x8F] |= 0x04;
266 BIOSDATA[0x90] = 0x40;
268 if (nfloppies >= 2) {
269 BIOSDATA[0x8F] |= 0x40;
270 BIOSDATA[0x91] = 0x40;
273 gettimeofday(&tv, &tz);
275 tm = *localtime(&tv_sec);
276 *(u_long *)&BIOSDATA[0x6c] =
277 (((tm.tm_hour * 60 + tm.tm_min) * 60) + tm.tm_sec) * 182 / 10;
279 vec = insert_softint_trampoline();
281 register_callback(vec, int11, "int 11");
283 vec = insert_softint_trampoline();
285 register_callback(vec, int12, "int 12");
287 vec = insert_softint_trampoline();
289 register_callback(vec, int14, "int 14");
291 vec = insert_softint_trampoline();
293 register_callback(vec, int15, "int 15");
295 vec = insert_softint_trampoline();
297 register_callback(vec, int16, "int 16");
299 vec = insert_softint_trampoline();
301 register_callback(vec, int17, "int 17");
303 vec = insert_softint_trampoline();
305 register_callback(vec, int1a, "int 1a");