blob: 7b74007279c5e5c1556a43947acf83d4ef368464 [file] [log] [blame]
Kevin O'Connorf13b0082008-08-17 11:26:42 -04001// Code to load disk image and start system boot.
Kevin O'Connorf076a3e2008-02-25 22:25:15 -05002//
3// Copyright (C) 2008 Kevin O'Connor <kevin@koconnor.net>
4// Copyright (C) 2002 MandrakeSoft S.A.
5//
Kevin O'Connorb1b7c2a2009-01-15 20:52:58 -05006// This file may be distributed under the terms of the GNU LGPLv3 license.
Kevin O'Connorf076a3e2008-02-25 22:25:15 -05007
Kevin O'Connorf076a3e2008-02-25 22:25:15 -05008#include "util.h" // irq_enable
Kevin O'Connor9521e262008-07-04 13:04:29 -04009#include "biosvar.h" // GET_EBDA
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -050010#include "config.h" // CONFIG_*
Kevin O'Connor180a9592008-03-04 22:50:53 -050011#include "disk.h" // cdrom_boot
Kevin O'Connor9521e262008-07-04 13:04:29 -040012#include "bregs.h" // struct bregs
Kevin O'Connorc659fde2008-12-28 23:43:20 -050013#include "boot.h" // struct ipl_s
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -050014#include "cmos.h" // inb_cmos
Kevin O'Connorc659fde2008-12-28 23:43:20 -050015
16struct ipl_s IPL;
Kevin O'Connorf076a3e2008-02-25 22:25:15 -050017
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -050018
19/****************************************************************
Kevin O'Connor0a924122009-02-08 19:43:47 -050020 * IPL and BCV handlers
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -050021 ****************************************************************/
22
23void
24boot_setup()
25{
26 if (! CONFIG_BOOT)
27 return;
28 dprintf(3, "init boot device ordering\n");
29
30 memset(&IPL, 0, sizeof(IPL));
31
32 // Floppy drive
Kevin O'Connor0a924122009-02-08 19:43:47 -050033 struct ipl_entry_s *ie = &IPL.bev[0];
Kevin O'Connor71f036d2009-02-08 16:57:22 -050034 ie->type = IPL_TYPE_FLOPPY;
35 ie->description = "Floppy";
36 ie++;
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -050037
38 // First HDD
Kevin O'Connor71f036d2009-02-08 16:57:22 -050039 ie->type = IPL_TYPE_HARDDISK;
40 ie->description = "Hard Disk";
41 ie++;
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -050042
43 // CDROM
44 if (CONFIG_CDROM_BOOT) {
Kevin O'Connor71f036d2009-02-08 16:57:22 -050045 ie->type = IPL_TYPE_CDROM;
46 ie->description = "CD-Rom";
47 ie++;
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -050048 }
49
Kevin O'Connor67823442009-04-13 14:14:51 -040050 if (CONFIG_COREBOOT_FLASH) {
51 ie->type = IPL_TYPE_CBFS;
52 ie->description = "CBFS";
53 ie++;
54 }
55
Kevin O'Connor0a924122009-02-08 19:43:47 -050056 IPL.bevcount = ie - IPL.bev;
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -050057 SET_EBDA(boot_sequence, 0xffff);
58 if (CONFIG_COREBOOT) {
59 // XXX - hardcode defaults for coreboot.
Kevin O'Connorff8c1412009-04-18 17:02:41 -040060 IPL.bootorder = 0x87654231;
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -050061 IPL.checkfloppysig = 1;
62 } else {
63 // On emulators, get boot order from nvram.
64 IPL.bootorder = (inb_cmos(CMOS_BIOS_BOOTFLAG2)
65 | ((inb_cmos(CMOS_BIOS_BOOTFLAG1) & 0xf0) << 4));
66 if (!(inb_cmos(CMOS_BIOS_BOOTFLAG1) & 1))
67 IPL.checkfloppysig = 1;
68 }
69}
70
71// Add a BEV vector for a given pnp compatible option rom.
72void
73add_bev(u16 seg, u16 bev, u16 desc)
74{
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -050075 if (! CONFIG_BOOT)
76 return;
Kevin O'Connor0a924122009-02-08 19:43:47 -050077 if (IPL.bevcount >= ARRAY_SIZE(IPL.bev))
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -050078 return;
79
Kevin O'Connor0a924122009-02-08 19:43:47 -050080 struct ipl_entry_s *ie = &IPL.bev[IPL.bevcount++];
Kevin O'Connor71f036d2009-02-08 16:57:22 -050081 ie->type = IPL_TYPE_BEV;
82 ie->vector = (seg << 16) | bev;
Kevin O'Connor0a924122009-02-08 19:43:47 -050083 const char *d = "Unknown";
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -050084 if (desc)
Kevin O'Connor0a924122009-02-08 19:43:47 -050085 d = MAKE_FLATPTR(seg, desc);
86 ie->description = d;
87}
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -050088
Kevin O'Connor0a924122009-02-08 19:43:47 -050089// Add a bcv entry for an expansion card harddrive or legacy option rom
90void
91add_bcv(u16 seg, u16 ip, u16 desc)
92{
93 if (! CONFIG_BOOT)
94 return;
95 if (IPL.bcvcount >= ARRAY_SIZE(IPL.bcv))
96 return;
97
98 struct ipl_entry_s *ie = &IPL.bcv[IPL.bcvcount++];
Kevin O'Connor51fd0a12009-09-12 13:20:14 -040099 ie->type = BCV_TYPE_EXTERNAL;
Kevin O'Connor0a924122009-02-08 19:43:47 -0500100 ie->vector = (seg << 16) | ip;
101 const char *d = "Legacy option rom";
102 if (desc)
103 d = MAKE_FLATPTR(seg, desc);
104 ie->description = d;
105}
106
Kevin O'Connor51fd0a12009-09-12 13:20:14 -0400107// Add a bcv entry for an internal harddrive
Kevin O'Connor0a924122009-02-08 19:43:47 -0500108void
Kevin O'Connor51fd0a12009-09-12 13:20:14 -0400109add_bcv_internal(int driveid)
Kevin O'Connor0a924122009-02-08 19:43:47 -0500110{
111 if (! CONFIG_BOOT)
112 return;
113 if (IPL.bcvcount >= ARRAY_SIZE(IPL.bcv))
114 return;
115
116 struct ipl_entry_s *ie = &IPL.bcv[IPL.bcvcount++];
Kevin O'Connor51fd0a12009-09-12 13:20:14 -0400117 ie->type = BCV_TYPE_INTERNAL;
Kevin O'Connor0a924122009-02-08 19:43:47 -0500118 ie->vector = driveid;
Kevin O'Connor51fd0a12009-09-12 13:20:14 -0400119 ie->description = "";
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500120}
121
122
123/****************************************************************
Kevin O'Connor0a924122009-02-08 19:43:47 -0500124 * Boot menu and BCV execution
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500125 ****************************************************************/
126
Kevin O'Connor0a924122009-02-08 19:43:47 -0500127// Show a generic menu item
128static int
129menu_show_default(struct ipl_entry_s *ie, int menupos)
130{
131 char desc[33];
132 printf("%d. %s\n", menupos
133 , strtcpy(desc, ie->description, ARRAY_SIZE(desc)));
134 return 1;
135}
136
137// Show floppy menu item - but only if there exists a floppy drive.
138static int
139menu_show_floppy(struct ipl_entry_s *ie, int menupos)
140{
Kevin O'Connorafd05202009-08-16 12:21:44 -0400141 int i;
142 for (i = 0; i < Drives.floppycount; i++) {
Kevin O'Connor51fd0a12009-09-12 13:20:14 -0400143 int driveid = Drives.idmap[EXTTYPE_FLOPPY][i];
144 printf("%d. Floppy [", menupos + i);
145 describe_drive(driveid);
146 printf("]\n");
Kevin O'Connorafd05202009-08-16 12:21:44 -0400147 }
148 return Drives.floppycount;
Kevin O'Connor0a924122009-02-08 19:43:47 -0500149}
150
151// Show menu items from BCV list.
152static int
153menu_show_harddisk(struct ipl_entry_s *ie, int menupos)
154{
155 int i;
156 for (i = 0; i < IPL.bcvcount; i++) {
157 struct ipl_entry_s *ie = &IPL.bcv[i];
158 switch (ie->type) {
Kevin O'Connor51fd0a12009-09-12 13:20:14 -0400159 case BCV_TYPE_INTERNAL:
160 printf("%d. ", menupos + i);
161 describe_drive(ie->vector);
162 printf("\n");
Kevin O'Connor0a924122009-02-08 19:43:47 -0500163 break;
164 default:
165 menu_show_default(ie, menupos+i);
166 break;
167 }
168 }
169 return IPL.bcvcount;
170}
171
172// Show cdrom menu item - but only if there exists a cdrom drive.
173static int
174menu_show_cdrom(struct ipl_entry_s *ie, int menupos)
175{
Kevin O'Connor7da1dcd2009-02-16 10:51:24 -0500176 int i;
Kevin O'Connorc892b132009-08-11 21:59:37 -0400177 for (i = 0; i < Drives.cdcount; i++) {
Kevin O'Connor0a0e42e2009-08-16 12:09:44 -0400178 int driveid = Drives.idmap[EXTTYPE_CD][i];
Kevin O'Connor51fd0a12009-09-12 13:20:14 -0400179 printf("%d. CD-Rom [", menupos + i);
180 describe_drive(driveid);
181 printf("]\n");
Kevin O'Connor7da1dcd2009-02-16 10:51:24 -0500182 }
Kevin O'Connorc892b132009-08-11 21:59:37 -0400183 return Drives.cdcount;
Kevin O'Connor0a924122009-02-08 19:43:47 -0500184}
185
Kevin O'Connor67823442009-04-13 14:14:51 -0400186// Show coreboot-fs menu item.
187static int
188menu_show_cbfs(struct ipl_entry_s *ie, int menupos)
189{
190 int count = 0;
Kevin O'Connor31ae6382009-09-20 15:42:39 -0400191 struct cbfs_file *file = NULL;
Kevin O'Connor67823442009-04-13 14:14:51 -0400192 for (;;) {
Kevin O'Connor1f836252009-08-16 20:17:35 -0400193 file = cbfs_findprefix("img/", file);
194 if (!file)
Kevin O'Connor67823442009-04-13 14:14:51 -0400195 break;
Kevin O'Connor1f836252009-08-16 20:17:35 -0400196 const char *filename = cbfs_filename(file);
Kevin O'Connor67823442009-04-13 14:14:51 -0400197 printf("%d. Payload [%s]\n", menupos + count, &filename[4]);
198 count++;
199 if (count > 8)
200 break;
201 }
202 return count;
203}
204
Kevin O'Connor0a924122009-02-08 19:43:47 -0500205// Show IPL option menu.
206static void
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500207interactive_bootmenu()
208{
209 if (! CONFIG_BOOTMENU)
210 return;
211
212 while (get_keystroke(0) >= 0)
213 ;
214
215 printf("Press F12 for boot menu.\n\n");
216
Kevin O'Connor217d3632009-04-29 22:00:21 -0400217 int scan_code = get_keystroke(CONFIG_BOOTMENU_WAIT);
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500218 if (scan_code != 0x86)
219 /* not F12 */
220 return;
221
222 while (get_keystroke(0) >= 0)
223 ;
224
225 printf("Select boot device:\n\n");
226
Kevin O'Connor0a924122009-02-08 19:43:47 -0500227 int subcount[ARRAY_SIZE(IPL.bev)];
228 int menupos = 1;
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500229 int i;
Kevin O'Connor0a924122009-02-08 19:43:47 -0500230 for (i = 0; i < IPL.bevcount; i++) {
231 struct ipl_entry_s *ie = &IPL.bev[i];
Kevin O'Connor31ae6382009-09-20 15:42:39 -0400232 int sc;
Kevin O'Connor0a924122009-02-08 19:43:47 -0500233 switch (ie->type) {
234 case IPL_TYPE_FLOPPY:
235 sc = menu_show_floppy(ie, menupos);
236 break;
237 case IPL_TYPE_HARDDISK:
238 sc = menu_show_harddisk(ie, menupos);
239 break;
240 case IPL_TYPE_CDROM:
241 sc = menu_show_cdrom(ie, menupos);
242 break;
Kevin O'Connor67823442009-04-13 14:14:51 -0400243 case IPL_TYPE_CBFS:
244 sc = menu_show_cbfs(ie, menupos);
245 break;
Kevin O'Connor0a924122009-02-08 19:43:47 -0500246 default:
247 sc = menu_show_default(ie, menupos);
248 break;
249 }
250 subcount[i] = sc;
251 menupos += sc;
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500252 }
253
254 for (;;) {
255 scan_code = get_keystroke(1000);
256 if (scan_code == 0x01)
257 // ESC
258 break;
Kevin O'Connor0a924122009-02-08 19:43:47 -0500259 if (scan_code < 1 || scan_code > menupos)
260 continue;
261 int choice = scan_code - 1;
262
263 // Find out which IPL this was for.
264 int bev = 0;
265 while (choice > subcount[bev]) {
266 choice -= subcount[bev];
267 bev++;
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500268 }
Kevin O'Connor67823442009-04-13 14:14:51 -0400269 IPL.bev[bev].subchoice = choice-1;
Kevin O'Connor0a924122009-02-08 19:43:47 -0500270
271 // Add user choice to the boot order.
272 IPL.bootorder = (IPL.bootorder << 4) | (bev+1);
273 break;
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500274 }
275 printf("\n");
276}
277
Kevin O'Connor0a924122009-02-08 19:43:47 -0500278// Run the specified bcv.
279static void
280run_bcv(struct ipl_entry_s *ie)
281{
282 switch (ie->type) {
Kevin O'Connor51fd0a12009-09-12 13:20:14 -0400283 case BCV_TYPE_INTERNAL:
Kevin O'Connorc892b132009-08-11 21:59:37 -0400284 map_hd_drive(ie->vector);
Kevin O'Connor0a924122009-02-08 19:43:47 -0500285 break;
Kevin O'Connor51fd0a12009-09-12 13:20:14 -0400286 case BCV_TYPE_EXTERNAL:
Kevin O'Connor0a924122009-02-08 19:43:47 -0500287 call_bcv(ie->vector >> 16, ie->vector & 0xffff);
288 break;
289 }
290}
291
292// Prepare for boot - show menu and run bcvs.
293void
294boot_prep()
295{
296 if (! CONFIG_BOOT)
297 return;
298
299 // Allow user to modify BCV/IPL order.
300 interactive_bootmenu();
301
Kevin O'Connorafd05202009-08-16 12:21:44 -0400302 // Setup floppy boot order
303 int override = IPL.bev[0].subchoice;
304 int tmp = Drives.idmap[EXTTYPE_FLOPPY][0];
305 Drives.idmap[EXTTYPE_FLOPPY][0] = Drives.idmap[EXTTYPE_FLOPPY][override];
306 Drives.idmap[EXTTYPE_FLOPPY][override] = tmp;
307
Kevin O'Connor0a924122009-02-08 19:43:47 -0500308 // Run BCVs
Kevin O'Connorafd05202009-08-16 12:21:44 -0400309 override = IPL.bev[1].subchoice;
Kevin O'Connor7da1dcd2009-02-16 10:51:24 -0500310 if (override < IPL.bcvcount)
Kevin O'Connor0a924122009-02-08 19:43:47 -0500311 run_bcv(&IPL.bcv[override]);
312 int i;
313 for (i=0; i<IPL.bcvcount; i++)
314 if (i != override)
315 run_bcv(&IPL.bcv[i]);
316}
317
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500318
319/****************************************************************
320 * Boot code (int 18/19)
321 ****************************************************************/
322
Kevin O'Connor0a924122009-02-08 19:43:47 -0500323// Jump to a bootup entry point.
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500324static void
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500325call_boot_entry(u16 bootseg, u16 bootip, u8 bootdrv)
326{
Kevin O'Connor91b53a72009-05-05 22:52:09 -0400327 dprintf(1, "Booting from %04x:%04x\n", bootseg, bootip);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500328
329 struct bregs br;
330 memset(&br, 0, sizeof(br));
Kevin O'Connorf8e800d2009-09-24 21:01:16 -0400331 br.flags = F_IF;
Kevin O'Connor9f985422009-09-09 11:34:39 -0400332 br.code = SEGOFF(bootseg, bootip);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500333 // Set the magic number in ax and the boot drive in dl.
334 br.dl = bootdrv;
335 br.ax = 0xaa55;
336 call16(&br);
337}
338
339// Boot from a disk (either floppy or harddrive)
340static void
341boot_disk(u8 bootdrv, int checksig)
342{
343 u16 bootseg = 0x07c0;
344
345 // Read sector
346 struct bregs br;
347 memset(&br, 0, sizeof(br));
Kevin O'Connorf8e800d2009-09-24 21:01:16 -0400348 br.flags = F_IF;
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500349 br.dl = bootdrv;
350 br.es = bootseg;
351 br.ah = 2;
352 br.al = 1;
353 br.cl = 1;
354 call16_int(0x13, &br);
355
356 if (br.flags & F_CF) {
357 printf("Boot failed: could not read the boot disk\n\n");
358 return;
359 }
360
361 if (checksig) {
362 struct mbr_s *mbr = (void*)0;
363 if (GET_FARVAR(bootseg, mbr->signature) != MBR_SIGNATURE) {
364 printf("Boot failed: not a bootable disk\n\n");
365 return;
366 }
367 }
368
369 /* Canonicalize bootseg:bootip */
370 u16 bootip = (bootseg & 0x0fff) << 4;
371 bootseg &= 0xf000;
372
373 call_boot_entry(bootseg, bootip, bootdrv);
374}
375
376// Boot from a CD-ROM
377static void
Kevin O'Connor67823442009-04-13 14:14:51 -0400378boot_cdrom(struct ipl_entry_s *ie)
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500379{
380 if (! CONFIG_CDROM_BOOT)
381 return;
Kevin O'Connor67823442009-04-13 14:14:51 -0400382 int status = cdrom_boot(ie->subchoice);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500383 if (status) {
384 printf("Boot failed: Could not read from CDROM (code %04x)\n", status);
385 return;
386 }
387
388 u16 ebda_seg = get_ebda_seg();
Kevin O'Connor669e6442009-08-11 22:36:30 -0400389 u8 bootdrv = GET_EBDA2(ebda_seg, cdemu.emulated_extdrive);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500390 u16 bootseg = GET_EBDA2(ebda_seg, cdemu.load_segment);
391 /* Canonicalize bootseg:bootip */
392 u16 bootip = (bootseg & 0x0fff) << 4;
393 bootseg &= 0xf000;
394
395 call_boot_entry(bootseg, bootip, bootdrv);
396}
397
Kevin O'Connore8f00ee2009-07-04 04:04:36 -0400398// Boot from a CBFS payload
Kevin O'Connor67823442009-04-13 14:14:51 -0400399static void
400boot_cbfs(struct ipl_entry_s *ie)
401{
402 if (! CONFIG_COREBOOT_FLASH)
403 return;
Kevin O'Connor1f836252009-08-16 20:17:35 -0400404 int count = ie->subchoice;
405 struct cbfs_file *file;
406 for (;;) {
407 file = cbfs_findprefix("img/", file);
408 if (!file)
409 return;
410 if (count--)
411 continue;
412 cbfs_run_payload(file);
413 }
Kevin O'Connor67823442009-04-13 14:14:51 -0400414}
415
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500416static void
417do_boot(u16 seq_nr)
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500418{
Kevin O'Connor40967022008-07-21 22:23:05 -0400419 if (! CONFIG_BOOT)
Kevin O'Connore07e18e2009-02-08 17:07:29 -0500420 panic("Boot support not compiled in.\n");
Kevin O'Connor40967022008-07-21 22:23:05 -0400421
Kevin O'Connorc659fde2008-12-28 23:43:20 -0500422 u32 bootdev = IPL.bootorder;
Kevin O'Connor840c5342008-03-29 14:04:34 -0400423 bootdev >>= 4 * seq_nr;
424 bootdev &= 0xf;
Kevin O'Connore0113c92008-04-05 15:51:12 -0400425
Kevin O'Connorabc75972008-05-18 00:20:53 -0400426 /* Translate bootdev to an IPL table offset by subtracting 1 */
Kevin O'Connor840c5342008-03-29 14:04:34 -0400427 bootdev -= 1;
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500428
Kevin O'Connor0a924122009-02-08 19:43:47 -0500429 if (bootdev >= IPL.bevcount) {
Kevin O'Connorff8c1412009-04-18 17:02:41 -0400430 printf("No bootable device.\n");
431 // Loop with irqs enabled - this allows ctrl+alt+delete to work.
432 for (;;)
433 usleep(1000000);
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500434 }
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500435
436 /* Do the loading, and set up vector as a far pointer to the boot
437 * address, and bootdrv as the boot drive */
Kevin O'Connor0a924122009-02-08 19:43:47 -0500438 struct ipl_entry_s *ie = &IPL.bev[bootdev];
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500439 char desc[33];
440 printf("Booting from %s...\n"
441 , strtcpy(desc, ie->description, ARRAY_SIZE(desc)));
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500442
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500443 switch(ie->type) {
Kevin O'Connorf13b0082008-08-17 11:26:42 -0400444 case IPL_TYPE_FLOPPY:
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500445 boot_disk(0x00, IPL.checkfloppysig);
446 break;
Kevin O'Connorf13b0082008-08-17 11:26:42 -0400447 case IPL_TYPE_HARDDISK:
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500448 boot_disk(0x80, 1);
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500449 break;
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500450 case IPL_TYPE_CDROM:
Kevin O'Connor67823442009-04-13 14:14:51 -0400451 boot_cdrom(ie);
452 break;
453 case IPL_TYPE_CBFS:
454 boot_cbfs(ie);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500455 break;
456 case IPL_TYPE_BEV:
457 call_boot_entry(ie->vector >> 16, ie->vector & 0xffff, 0);
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500458 break;
Kevin O'Connor180a9592008-03-04 22:50:53 -0500459 }
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500460
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500461 // Boot failed: invoke the boot recovery function
Kevin O'Connor7af49bf2008-03-09 13:46:13 -0400462 struct bregs br;
463 memset(&br, 0, sizeof(br));
Kevin O'Connorf8e800d2009-09-24 21:01:16 -0400464 br.flags = F_IF;
Kevin O'Connor7af49bf2008-03-09 13:46:13 -0400465 call16_int(0x18, &br);
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500466}
467
468// Boot Failure recovery: try the next device.
Kevin O'Connor44eeaf12008-07-06 10:14:49 -0400469void VISIBLE32
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500470handle_18()
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500471{
Kevin O'Connor61d6b062008-06-21 12:15:10 -0400472 debug_serial_setup();
Kevin O'Connor15c1f222008-06-12 22:59:43 -0400473 debug_enter(NULL, DEBUG_HDL_18);
Kevin O'Connor08815372008-12-29 21:16:31 -0500474 u16 ebda_seg = get_ebda_seg();
475 u16 seq = GET_EBDA2(ebda_seg, boot_sequence) + 1;
476 SET_EBDA2(ebda_seg, boot_sequence, seq);
Kevin O'Connor7af49bf2008-03-09 13:46:13 -0400477 do_boot(seq);
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500478}
479
480// INT 19h Boot Load Service Entry Point
Kevin O'Connor44eeaf12008-07-06 10:14:49 -0400481void VISIBLE32
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500482handle_19()
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500483{
Kevin O'Connor61d6b062008-06-21 12:15:10 -0400484 debug_serial_setup();
Kevin O'Connor15c1f222008-06-12 22:59:43 -0400485 debug_enter(NULL, DEBUG_HDL_19);
Kevin O'Connor08815372008-12-29 21:16:31 -0500486 SET_EBDA(boot_sequence, 0);
Kevin O'Connor7af49bf2008-03-09 13:46:13 -0400487 do_boot(0);
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500488}