blob: d6b1fb77bad32f5cc1bbffaa388ba07900b98563 [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//
Kevin O'Connor0ac5e9e2013-09-14 13:09:27 -04003// Copyright (C) 2008-2013 Kevin O'Connor <kevin@koconnor.net>
Kevin O'Connorf076a3e2008-02-25 22:25:15 -05004// 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'Connor135f3f62013-09-14 23:57:26 -04008#include "block.h" // struct drive_s
Kevin O'Connor2d2fa312013-09-14 21:55:26 -04009#include "bregs.h" // struct bregs
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -050010#include "config.h" // CONFIG_*
Kevin O'Connorccee6e82013-09-02 21:25:21 -040011#include "fw/paravirt.h" // qemu_cfg_show_boot_menu
Kevin O'Connor5d369d82013-09-02 20:48:46 -040012#include "hw/pci.h" // pci_bdf_to_*
Kevin O'Connor8b7861c2013-09-15 02:29:06 -040013#include "hw/rtc.h" // rtc_read
Kevin O'Connor5d369d82013-09-02 20:48:46 -040014#include "hw/usb.h" // struct usbdevice_s
Kevin O'Connor446defb2013-06-08 21:50:53 -040015#include "list.h" // hlist_node
Kevin O'Connor9dea5902013-09-14 20:23:54 -040016#include "malloc.h" // free
Kevin O'Connor2d2fa312013-09-14 21:55:26 -040017#include "output.h" // dprintf
Kevin O'Connor41639f82013-09-14 19:37:36 -040018#include "romfile.h" // romfile_loadint
Kevin O'Connor135f3f62013-09-14 23:57:26 -040019#include "std/disk.h" // struct mbr_s
Kevin O'Connorfa9c66a2013-09-14 19:10:40 -040020#include "string.h" // memset
Kevin O'Connor2d2fa312013-09-14 21:55:26 -040021#include "util.h" // irqtimer_calc
Kevin O'Connorc659fde2008-12-28 23:43:20 -050022
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -050023
24/****************************************************************
Kevin O'Connor031ef552010-12-27 19:26:57 -050025 * Boot priority ordering
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -050026 ****************************************************************/
27
Kevin O'Connor70c94dd2013-03-08 19:39:49 -050028static char **Bootorder VARVERIFY32INIT;
Kevin O'Connor3da2c1c2010-12-29 11:37:41 -050029static int BootorderCount;
30
Kevin O'Connord1a17462010-12-24 11:17:03 -050031static void
32loadBootOrder(void)
33{
Kevin O'Connor49bf57b2011-05-10 22:08:30 -040034 if (!CONFIG_BOOTORDER)
35 return;
36
Kevin O'Connord1a17462010-12-24 11:17:03 -050037 char *f = romfile_loadfile("bootorder", NULL);
38 if (!f)
39 return;
40
Kevin O'Connor8bf55032011-01-01 11:00:42 -050041 int i = 0;
Kevin O'Connor3da2c1c2010-12-29 11:37:41 -050042 BootorderCount = 1;
Kevin O'Connord1a17462010-12-24 11:17:03 -050043 while (f[i]) {
44 if (f[i] == '\n')
Kevin O'Connor3da2c1c2010-12-29 11:37:41 -050045 BootorderCount++;
Kevin O'Connord1a17462010-12-24 11:17:03 -050046 i++;
47 }
Kevin O'Connor3da2c1c2010-12-29 11:37:41 -050048 Bootorder = malloc_tmphigh(BootorderCount*sizeof(char*));
49 if (!Bootorder) {
Kevin O'Connord1a17462010-12-24 11:17:03 -050050 warn_noalloc();
51 free(f);
Kevin O'Connor4d0c5922011-01-26 21:04:01 -050052 BootorderCount = 0;
Kevin O'Connord1a17462010-12-24 11:17:03 -050053 return;
54 }
55
Gerd Hoffmannf5beab42013-12-06 10:29:09 +010056 dprintf(1, "boot order:\n");
Kevin O'Connord1a17462010-12-24 11:17:03 -050057 i = 0;
58 do {
Kevin O'Connor3da2c1c2010-12-29 11:37:41 -050059 Bootorder[i] = f;
Kevin O'Connord1a17462010-12-24 11:17:03 -050060 f = strchr(f, '\n');
Kevin O'Connor8bf55032011-01-01 11:00:42 -050061 if (f)
62 *(f++) = '\0';
Kevin O'Connord15b0102014-01-31 19:38:36 -050063 Bootorder[i] = nullTrailingSpace(Bootorder[i]);
Gerd Hoffmannf5beab42013-12-06 10:29:09 +010064 dprintf(1, "%d: %s\n", i+1, Bootorder[i]);
Kevin O'Connor8bf55032011-01-01 11:00:42 -050065 i++;
66 } while (f);
67}
68
69// See if 'str' starts with 'glob' - if glob contains an '*' character
70// it will match any number of characters in str that aren't a '/' or
71// the next glob character.
72static char *
73glob_prefix(const char *glob, const char *str)
74{
75 for (;;) {
76 if (!*glob && (!*str || *str == '/'))
77 return (char*)str;
78 if (*glob == '*') {
79 if (!*str || *str == '/' || *str == glob[1])
80 glob++;
81 else
82 str++;
83 continue;
Kevin O'Connord1a17462010-12-24 11:17:03 -050084 }
Kevin O'Connor8bf55032011-01-01 11:00:42 -050085 if (*glob != *str)
86 return NULL;
87 glob++;
88 str++;
89 }
90}
91
92// Search the bootorder list for the given glob pattern.
93static int
94find_prio(const char *glob)
95{
96 dprintf(1, "Searching bootorder for: %s\n", glob);
97 int i;
98 for (i = 0; i < BootorderCount; i++)
99 if (glob_prefix(glob, Bootorder[i]))
100 return i+1;
101 return -1;
102}
103
104#define FW_PCI_DOMAIN "/pci@i0cf8"
105
Kevin O'Connor659c99d2011-06-20 23:29:15 -0400106static char *
107build_pci_path(char *buf, int max, const char *devname, struct pci_device *pci)
108{
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500109 // Build the string path of a bdf - for example: /pci@i0cf8/isa@1,2
110 char *p = buf;
Kevin O'Connor659c99d2011-06-20 23:29:15 -0400111 if (pci->parent) {
112 p = build_pci_path(p, max, "pci-bridge", pci->parent);
Kevin O'Connord08eb9c2011-01-10 00:48:45 -0500113 } else {
Kevin O'Connor659c99d2011-06-20 23:29:15 -0400114 if (pci->rootbus)
115 p += snprintf(p, max, "/pci-root@%x", pci->rootbus);
Kevin O'Connord08eb9c2011-01-10 00:48:45 -0500116 p += snprintf(p, buf+max-p, "%s", FW_PCI_DOMAIN);
117 }
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500118
Kevin O'Connor659c99d2011-06-20 23:29:15 -0400119 int dev = pci_bdf_to_dev(pci->bdf), fn = pci_bdf_to_fn(pci->bdf);
Kevin O'Connord08eb9c2011-01-10 00:48:45 -0500120 p += snprintf(p, buf+max-p, "/%s@%x", devname, dev);
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500121 if (fn)
122 p += snprintf(p, buf+max-p, ",%x", fn);
123 return p;
Kevin O'Connord1a17462010-12-24 11:17:03 -0500124}
125
Kevin O'Connordc3a7d62011-07-09 14:33:56 -0400126int bootprio_find_pci_device(struct pci_device *pci)
Kevin O'Connor031ef552010-12-27 19:26:57 -0500127{
David Woodhouse118469a2013-01-25 19:46:25 -0600128 if (CONFIG_CSM)
129 return csm_bootprio_pci(pci);
Kevin O'Connor49bf57b2011-05-10 22:08:30 -0400130 if (!CONFIG_BOOTORDER)
131 return -1;
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500132 // Find pci device - for example: /pci@i0cf8/ethernet@5
133 char desc[256];
Kevin O'Connordc3a7d62011-07-09 14:33:56 -0400134 build_pci_path(desc, sizeof(desc), "*", pci);
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500135 return find_prio(desc);
Kevin O'Connor031ef552010-12-27 19:26:57 -0500136}
137
Paolo Bonzinic5c488f2012-02-27 17:22:23 +0100138int bootprio_find_scsi_device(struct pci_device *pci, int target, int lun)
139{
140 if (!CONFIG_BOOTORDER)
141 return -1;
142 if (!pci)
143 // support only pci machine for now
144 return -1;
145 // Find scsi drive - for example: /pci@i0cf8/scsi@5/channel@0/disk@1,0
146 char desc[256], *p;
147 p = build_pci_path(desc, sizeof(desc), "*", pci);
Markus Armbruster275672e2014-08-15 08:58:17 +0200148 snprintf(p, desc+sizeof(desc)-p, "/*@0/*@%x,%x", target, lun);
Paolo Bonzinic5c488f2012-02-27 17:22:23 +0100149 return find_prio(desc);
150}
151
Kevin O'Connor95b2e0c2011-07-09 14:42:11 -0400152int bootprio_find_ata_device(struct pci_device *pci, int chanid, int slave)
Kevin O'Connor031ef552010-12-27 19:26:57 -0500153{
David Woodhouse118469a2013-01-25 19:46:25 -0600154 if (CONFIG_CSM)
155 return csm_bootprio_ata(pci, chanid, slave);
Kevin O'Connor49bf57b2011-05-10 22:08:30 -0400156 if (!CONFIG_BOOTORDER)
157 return -1;
Kevin O'Connor95b2e0c2011-07-09 14:42:11 -0400158 if (!pci)
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500159 // support only pci machine for now
160 return -1;
161 // Find ata drive - for example: /pci@i0cf8/ide@1,1/drive@1/disk@0
162 char desc[256], *p;
Kevin O'Connor95b2e0c2011-07-09 14:42:11 -0400163 p = build_pci_path(desc, sizeof(desc), "*", pci);
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500164 snprintf(p, desc+sizeof(desc)-p, "/drive@%x/disk@%x", chanid, slave);
165 return find_prio(desc);
Kevin O'Connor031ef552010-12-27 19:26:57 -0500166}
167
Kevin O'Connor03e589c2011-07-09 14:35:37 -0400168int bootprio_find_fdc_device(struct pci_device *pci, int port, int fdid)
Kevin O'Connor031ef552010-12-27 19:26:57 -0500169{
David Woodhouse118469a2013-01-25 19:46:25 -0600170 if (CONFIG_CSM)
171 return csm_bootprio_fdc(pci, port, fdid);
Kevin O'Connor49bf57b2011-05-10 22:08:30 -0400172 if (!CONFIG_BOOTORDER)
173 return -1;
Kevin O'Connor03e589c2011-07-09 14:35:37 -0400174 if (!pci)
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500175 // support only pci machine for now
176 return -1;
177 // Find floppy - for example: /pci@i0cf8/isa@1/fdc@03f1/floppy@0
178 char desc[256], *p;
Kevin O'Connor03e589c2011-07-09 14:35:37 -0400179 p = build_pci_path(desc, sizeof(desc), "isa", pci);
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500180 snprintf(p, desc+sizeof(desc)-p, "/fdc@%04x/floppy@%x", port, fdid);
181 return find_prio(desc);
Kevin O'Connor031ef552010-12-27 19:26:57 -0500182}
183
Kevin O'Connorfce91892011-07-09 14:47:47 -0400184int bootprio_find_pci_rom(struct pci_device *pci, int instance)
Kevin O'Connor031ef552010-12-27 19:26:57 -0500185{
Kevin O'Connor49bf57b2011-05-10 22:08:30 -0400186 if (!CONFIG_BOOTORDER)
187 return -1;
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500188 // Find pci rom - for example: /pci@i0cf8/scsi@3:rom2
189 char desc[256], *p;
Kevin O'Connorfce91892011-07-09 14:47:47 -0400190 p = build_pci_path(desc, sizeof(desc), "*", pci);
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500191 if (instance)
Kevin O'Connore7104472014-08-15 09:52:43 -0400192 snprintf(p, desc+sizeof(desc)-p, ":rom%x", instance);
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500193 return find_prio(desc);
Kevin O'Connor031ef552010-12-27 19:26:57 -0500194}
195
196int bootprio_find_named_rom(const char *name, int instance)
197{
Kevin O'Connor49bf57b2011-05-10 22:08:30 -0400198 if (!CONFIG_BOOTORDER)
199 return -1;
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500200 // Find named rom - for example: /rom@genroms/linuxboot.bin
201 char desc[256], *p;
202 p = desc + snprintf(desc, sizeof(desc), "/rom@%s", name);
203 if (instance)
Kevin O'Connore7104472014-08-15 09:52:43 -0400204 snprintf(p, desc+sizeof(desc)-p, ":rom%x", instance);
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500205 return find_prio(desc);
Kevin O'Connor031ef552010-12-27 19:26:57 -0500206}
207
Kevin O'Connorea274782012-03-08 07:49:09 -0500208static char *
209build_usb_path(char *buf, int max, struct usbhub_s *hub)
210{
211 if (!hub->usbdev)
212 // Root hub - nothing to add.
213 return buf;
214 char *p = build_usb_path(buf, max, hub->usbdev->hub);
215 p += snprintf(p, buf+max-p, "/hub@%x", hub->usbdev->port+1);
216 return p;
217}
218
Kevin O'Connor7fa31b52012-06-13 08:47:03 -0400219int bootprio_find_usb(struct usbdevice_s *usbdev, int lun)
Kevin O'Connorc2002a12010-12-31 14:38:10 -0500220{
Kevin O'Connor49bf57b2011-05-10 22:08:30 -0400221 if (!CONFIG_BOOTORDER)
222 return -1;
Kevin O'Connor7fa31b52012-06-13 08:47:03 -0400223 // Find usb - for example: /pci@i0cf8/usb@1,2/storage@1/channel@0/disk@0,0
Kevin O'Connorc2002a12010-12-31 14:38:10 -0500224 char desc[256], *p;
Kevin O'Connorea274782012-03-08 07:49:09 -0500225 p = build_pci_path(desc, sizeof(desc), "usb", usbdev->hub->cntl->pci);
226 p = build_usb_path(p, desc+sizeof(desc)-p, usbdev->hub);
Markus Armbruster275672e2014-08-15 08:58:17 +0200227 snprintf(p, desc+sizeof(desc)-p, "/storage@%x/*@0/*@0,%x"
Kevin O'Connor7fa31b52012-06-13 08:47:03 -0400228 , usbdev->port+1, lun);
229 int ret = find_prio(desc);
230 if (ret >= 0)
231 return ret;
232 // Try usb-host/redir - for example: /pci@i0cf8/usb@1,2/usb-host@1
233 snprintf(p, desc+sizeof(desc)-p, "/usb-*@%x", usbdev->port+1);
Kevin O'Connorc2002a12010-12-31 14:38:10 -0500234 return find_prio(desc);
235}
236
Kevin O'Connor031ef552010-12-27 19:26:57 -0500237
238/****************************************************************
239 * Boot setup
240 ****************************************************************/
241
Kevin O'Connor11a72342013-03-05 17:52:21 +0800242static int BootRetryTime;
Kevin O'Connorbaaadb62010-12-29 11:18:04 -0500243static int CheckFloppySig = 1;
244
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500245#define DEFAULT_PRIO 9999
246
247static int DefaultFloppyPrio = 101;
248static int DefaultCDPrio = 102;
249static int DefaultHDPrio = 103;
250static int DefaultBEVPrio = 104;
251
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500252void
Kevin O'Connord83c87b2013-01-21 01:14:12 -0500253boot_init(void)
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500254{
255 if (! CONFIG_BOOT)
256 return;
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500257
Kevin O'Connor897fb112013-02-07 23:32:48 -0500258 if (CONFIG_QEMU) {
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500259 // On emulators, get boot order from nvram.
Kevin O'Connor8b7861c2013-09-15 02:29:06 -0400260 if (rtc_read(CMOS_BIOS_BOOTFLAG1) & 1)
Kevin O'Connorbaaadb62010-12-29 11:18:04 -0500261 CheckFloppySig = 0;
Kevin O'Connor8b7861c2013-09-15 02:29:06 -0400262 u32 bootorder = (rtc_read(CMOS_BIOS_BOOTFLAG2)
263 | ((rtc_read(CMOS_BIOS_BOOTFLAG1) & 0xf0) << 4));
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500264 DefaultFloppyPrio = DefaultCDPrio = DefaultHDPrio
265 = DefaultBEVPrio = DEFAULT_PRIO;
266 int i;
267 for (i=101; i<104; i++) {
268 u32 val = bootorder & 0x0f;
269 bootorder >>= 4;
270 switch (val) {
271 case 1: DefaultFloppyPrio = i; break;
272 case 2: DefaultHDPrio = i; break;
273 case 3: DefaultCDPrio = i; break;
274 case 4: DefaultBEVPrio = i; break;
275 }
276 }
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500277 }
Gleb Natapovb9a75912010-12-23 11:29:38 +0200278
Kevin O'Connor11a72342013-03-05 17:52:21 +0800279 BootRetryTime = romfile_loadint("etc/boot-fail-wait", 60*1000);
280
Kevin O'Connord1a17462010-12-24 11:17:03 -0500281 loadBootOrder();
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500282}
283
Kevin O'Connord1a17462010-12-24 11:17:03 -0500284
285/****************************************************************
Kevin O'Connor031ef552010-12-27 19:26:57 -0500286 * BootList handling
Kevin O'Connord1a17462010-12-24 11:17:03 -0500287 ****************************************************************/
288
Kevin O'Connor031ef552010-12-27 19:26:57 -0500289struct bootentry_s {
290 int type;
291 union {
292 u32 data;
293 struct segoff_s vector;
294 struct drive_s *drive;
295 };
296 int priority;
297 const char *description;
Kevin O'Connor446defb2013-06-08 21:50:53 -0400298 struct hlist_node node;
Kevin O'Connor031ef552010-12-27 19:26:57 -0500299};
Kevin O'Connor446defb2013-06-08 21:50:53 -0400300static struct hlist_head BootList VARVERIFY32INIT;
Kevin O'Connor031ef552010-12-27 19:26:57 -0500301
Kevin O'Connor7bb15842010-12-29 11:25:14 -0500302#define IPL_TYPE_FLOPPY 0x01
303#define IPL_TYPE_HARDDISK 0x02
304#define IPL_TYPE_CDROM 0x03
305#define IPL_TYPE_CBFS 0x20
306#define IPL_TYPE_BEV 0x80
307#define IPL_TYPE_BCV 0x81
Kevin O'Connor54ae5432013-01-12 16:36:11 -0500308#define IPL_TYPE_HALT 0xf0
Kevin O'Connor7bb15842010-12-29 11:25:14 -0500309
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500310static void
311bootentry_add(int type, int prio, u32 data, const char *desc)
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500312{
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500313 if (! CONFIG_BOOT)
314 return;
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500315 struct bootentry_s *be = malloc_tmp(sizeof(*be));
316 if (!be) {
317 warn_noalloc();
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500318 return;
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500319 }
320 be->type = type;
321 be->priority = prio;
322 be->data = data;
Kevin O'Connorca2bc1c2010-12-29 21:41:19 -0500323 be->description = desc ?: "?";
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500324 dprintf(3, "Registering bootable: %s (type:%d prio:%d data:%x)\n"
325 , be->description, type, prio, data);
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500326
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500327 // Add entry in sorted order.
Kevin O'Connor446defb2013-06-08 21:50:53 -0400328 struct hlist_node **pprev;
329 struct bootentry_s *pos;
Kevin O'Connor030a58a2013-06-13 21:24:14 -0400330 hlist_for_each_entry_pprev(pos, pprev, &BootList, node) {
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500331 if (be->priority < pos->priority)
332 break;
333 if (be->priority > pos->priority)
334 continue;
335 if (be->type < pos->type)
336 break;
337 if (be->type > pos->type)
338 continue;
339 if (be->type <= IPL_TYPE_CDROM
340 && (be->drive->type < pos->drive->type
341 || (be->drive->type == pos->drive->type
342 && be->drive->cntl_id < pos->drive->cntl_id)))
343 break;
344 }
Kevin O'Connor446defb2013-06-08 21:50:53 -0400345 hlist_add(&be->node, pprev);
Kevin O'Connor0a924122009-02-08 19:43:47 -0500346}
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500347
Kevin O'Connor031ef552010-12-27 19:26:57 -0500348// Return the given priority if it's set - defaultprio otherwise.
349static inline int defPrio(int priority, int defaultprio) {
350 return (priority < 0) ? defaultprio : priority;
351}
352
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500353// Add a BEV vector for a given pnp compatible option rom.
Gleb Natapov4c90a202010-12-07 13:50:54 +0200354void
Kevin O'Connor031ef552010-12-27 19:26:57 -0500355boot_add_bev(u16 seg, u16 bev, u16 desc, int prio)
Gleb Natapov4c90a202010-12-07 13:50:54 +0200356{
Kevin O'Connor031ef552010-12-27 19:26:57 -0500357 bootentry_add(IPL_TYPE_BEV, defPrio(prio, DefaultBEVPrio)
358 , SEGOFF(seg, bev).segoff
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500359 , desc ? MAKE_FLATPTR(seg, desc) : "Unknown");
360 DefaultBEVPrio = DEFAULT_PRIO;
Gleb Natapov4c90a202010-12-07 13:50:54 +0200361}
362
Kevin O'Connor0a924122009-02-08 19:43:47 -0500363// Add a bcv entry for an expansion card harddrive or legacy option rom
364void
Kevin O'Connor031ef552010-12-27 19:26:57 -0500365boot_add_bcv(u16 seg, u16 ip, u16 desc, int prio)
Kevin O'Connor0a924122009-02-08 19:43:47 -0500366{
Kevin O'Connor88e745e2012-01-14 11:58:14 -0500367 bootentry_add(IPL_TYPE_BCV, defPrio(prio, DefaultHDPrio)
Kevin O'Connor031ef552010-12-27 19:26:57 -0500368 , SEGOFF(seg, ip).segoff
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500369 , desc ? MAKE_FLATPTR(seg, desc) : "Legacy option rom");
Kevin O'Connor0a924122009-02-08 19:43:47 -0500370}
371
Kevin O'Connor0a924122009-02-08 19:43:47 -0500372void
Kevin O'Connorca2bc1c2010-12-29 21:41:19 -0500373boot_add_floppy(struct drive_s *drive_g, const char *desc, int prio)
Kevin O'Connor0a924122009-02-08 19:43:47 -0500374{
Kevin O'Connor031ef552010-12-27 19:26:57 -0500375 bootentry_add(IPL_TYPE_FLOPPY, defPrio(prio, DefaultFloppyPrio)
Kevin O'Connorca2bc1c2010-12-29 21:41:19 -0500376 , (u32)drive_g, desc);
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500377}
Kevin O'Connor0a924122009-02-08 19:43:47 -0500378
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500379void
Kevin O'Connorca2bc1c2010-12-29 21:41:19 -0500380boot_add_hd(struct drive_s *drive_g, const char *desc, int prio)
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500381{
Kevin O'Connor031ef552010-12-27 19:26:57 -0500382 bootentry_add(IPL_TYPE_HARDDISK, defPrio(prio, DefaultHDPrio)
Kevin O'Connorca2bc1c2010-12-29 21:41:19 -0500383 , (u32)drive_g, desc);
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500384}
385
386void
Kevin O'Connorca2bc1c2010-12-29 21:41:19 -0500387boot_add_cd(struct drive_s *drive_g, const char *desc, int prio)
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500388{
Kevin O'Connor031ef552010-12-27 19:26:57 -0500389 bootentry_add(IPL_TYPE_CDROM, defPrio(prio, DefaultCDPrio)
Kevin O'Connorca2bc1c2010-12-29 21:41:19 -0500390 , (u32)drive_g, desc);
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500391}
392
393// Add a CBFS payload entry
394void
Kevin O'Connor031ef552010-12-27 19:26:57 -0500395boot_add_cbfs(void *data, const char *desc, int prio)
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500396{
Kevin O'Connor031ef552010-12-27 19:26:57 -0500397 bootentry_add(IPL_TYPE_CBFS, defPrio(prio, DEFAULT_PRIO), (u32)data, desc);
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500398}
399
400
401/****************************************************************
Kevin O'Connor0ac5e9e2013-09-14 13:09:27 -0400402 * Keyboard calls
403 ****************************************************************/
404
405// See if a keystroke is pending in the keyboard buffer.
406static int
407check_for_keystroke(void)
408{
409 struct bregs br;
410 memset(&br, 0, sizeof(br));
411 br.flags = F_IF|F_ZF;
412 br.ah = 1;
413 call16_int(0x16, &br);
414 return !(br.flags & F_ZF);
415}
416
417// Return a keystroke - waiting forever if necessary.
418static int
419get_raw_keystroke(void)
420{
421 struct bregs br;
422 memset(&br, 0, sizeof(br));
423 br.flags = F_IF;
424 call16_int(0x16, &br);
425 return br.ah;
426}
427
428// Read a keystroke - waiting up to 'msec' milliseconds.
429static int
430get_keystroke(int msec)
431{
432 u32 end = irqtimer_calc(msec);
433 for (;;) {
434 if (check_for_keystroke())
435 return get_raw_keystroke();
436 if (irqtimer_check(end))
437 return -1;
438 yield_toirq();
439 }
440}
441
442
443/****************************************************************
Kevin O'Connor0a924122009-02-08 19:43:47 -0500444 * Boot menu and BCV execution
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500445 ****************************************************************/
446
Kevin O'Connor73023002011-07-05 20:34:34 -0400447#define DEFAULT_BOOTMENU_WAIT 2500
448
Kevin O'Connor0a924122009-02-08 19:43:47 -0500449// Show IPL option menu.
Kevin O'Connor8a0a9722013-01-21 01:53:31 -0500450void
Kevin O'Connor1ca05b02010-01-03 17:43:37 -0500451interactive_bootmenu(void)
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500452{
Kevin O'Connor8a0a9722013-01-21 01:53:31 -0500453 // XXX - show available drives?
454
Kevin O'Connor56c50892013-02-09 19:25:51 -0500455 if (! CONFIG_BOOTMENU || !romfile_loadint("etc/show-boot-menu", 1))
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500456 return;
457
458 while (get_keystroke(0) >= 0)
459 ;
460
Kevin O'Connor129f11e2013-08-02 14:13:50 -0400461 char *bootmsg = romfile_loadfile("etc/boot-menu-message", NULL);
Paolo Bonzinia1ac8862015-03-12 18:12:24 +0100462 int menukey = romfile_loadint("etc/boot-menu-key", 1);
463 printf("%s", bootmsg ?: "\nPress ESC for boot menu.\n\n");
Kevin O'Connor129f11e2013-08-02 14:13:50 -0400464 free(bootmsg);
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500465
Kevin O'Connor73023002011-07-05 20:34:34 -0400466 u32 menutime = romfile_loadint("etc/boot-menu-wait", DEFAULT_BOOTMENU_WAIT);
Kevin O'Connor9a01a9c2010-08-25 21:07:48 -0400467 enable_bootsplash();
Kevin O'Connor73023002011-07-05 20:34:34 -0400468 int scan_code = get_keystroke(menutime);
Kevin O'Connor9a01a9c2010-08-25 21:07:48 -0400469 disable_bootsplash();
Kevin O'Connor129f11e2013-08-02 14:13:50 -0400470 if (scan_code != menukey)
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500471 return;
472
473 while (get_keystroke(0) >= 0)
474 ;
475
476 printf("Select boot device:\n\n");
Kevin O'Connore438b0c2010-05-01 12:20:33 -0400477 wait_threads();
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500478
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500479 // Show menu items
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500480 int maxmenu = 0;
Kevin O'Connor446defb2013-06-08 21:50:53 -0400481 struct bootentry_s *pos;
482 hlist_for_each_entry(pos, &BootList, node) {
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500483 char desc[60];
484 maxmenu++;
485 printf("%d. %s\n", maxmenu
486 , strtcpy(desc, pos->description, ARRAY_SIZE(desc)));
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500487 }
488
Paolo Bonzini80aae262015-03-12 18:12:23 +0100489 // Get key press. If the menu key is ESC, do not restart boot unless
490 // 1.5 seconds have passed. Otherwise users (trained by years of
491 // repeatedly hitting keys to enter the BIOS) will end up hitting ESC
492 // multiple times and immediately booting the primary boot device.
493 int esc_accepted_time = irqtimer_calc(menukey == 1 ? 1500 : 0);
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500494 for (;;) {
495 scan_code = get_keystroke(1000);
Paolo Bonzini80aae262015-03-12 18:12:23 +0100496 if (scan_code == 1 && !irqtimer_check(esc_accepted_time))
497 continue;
Kevin O'Connor551caa22010-12-29 13:25:18 -0500498 if (scan_code >= 1 && scan_code <= maxmenu+1)
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500499 break;
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500500 }
501 printf("\n");
Kevin O'Connor551caa22010-12-29 13:25:18 -0500502 if (scan_code == 0x01)
503 // ESC
504 return;
505
506 // Find entry and make top priority.
507 int choice = scan_code - 1;
Kevin O'Connor446defb2013-06-08 21:50:53 -0400508 hlist_for_each_entry(pos, &BootList, node) {
509 if (! --choice)
510 break;
511 }
512 hlist_del(&pos->node);
Kevin O'Connor551caa22010-12-29 13:25:18 -0500513 pos->priority = 0;
Kevin O'Connor446defb2013-06-08 21:50:53 -0400514 hlist_add_head(&pos->node, &BootList);
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500515}
516
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500517// BEV (Boot Execution Vector) list
Kevin O'Connor7bb15842010-12-29 11:25:14 -0500518struct bev_s {
519 int type;
520 u32 vector;
521};
522static struct bev_s BEV[20];
523static int BEVCount;
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500524static int HaveHDBoot, HaveFDBoot;
525
Kevin O'Connor0a924122009-02-08 19:43:47 -0500526static void
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500527add_bev(int type, u32 vector)
Kevin O'Connor0a924122009-02-08 19:43:47 -0500528{
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500529 if (type == IPL_TYPE_HARDDISK && HaveHDBoot++)
530 return;
531 if (type == IPL_TYPE_FLOPPY && HaveFDBoot++)
532 return;
Kevin O'Connor7bb15842010-12-29 11:25:14 -0500533 if (BEVCount >= ARRAY_SIZE(BEV))
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500534 return;
Kevin O'Connor7bb15842010-12-29 11:25:14 -0500535 struct bev_s *bev = &BEV[BEVCount++];
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500536 bev->type = type;
537 bev->vector = vector;
Kevin O'Connor0a924122009-02-08 19:43:47 -0500538}
539
540// Prepare for boot - show menu and run bcvs.
541void
Kevin O'Connor8a0a9722013-01-21 01:53:31 -0500542bcv_prepboot(void)
Kevin O'Connor0a924122009-02-08 19:43:47 -0500543{
Kevin O'Connor8a0a9722013-01-21 01:53:31 -0500544 if (! CONFIG_BOOT)
Kevin O'Connor0a924122009-02-08 19:43:47 -0500545 return;
Kevin O'Connor0a924122009-02-08 19:43:47 -0500546
Kevin O'Connor54ae5432013-01-12 16:36:11 -0500547 int haltprio = find_prio("HALT");
548 if (haltprio >= 0)
549 bootentry_add(IPL_TYPE_HALT, haltprio, 0, "HALT");
550
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500551 // Map drives and populate BEV list
Kevin O'Connor446defb2013-06-08 21:50:53 -0400552 struct bootentry_s *pos;
553 hlist_for_each_entry(pos, &BootList, node) {
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500554 switch (pos->type) {
555 case IPL_TYPE_BCV:
556 call_bcv(pos->vector.seg, pos->vector.offset);
557 add_bev(IPL_TYPE_HARDDISK, 0);
558 break;
559 case IPL_TYPE_FLOPPY:
560 map_floppy_drive(pos->drive);
561 add_bev(IPL_TYPE_FLOPPY, 0);
562 break;
563 case IPL_TYPE_HARDDISK:
564 map_hd_drive(pos->drive);
565 add_bev(IPL_TYPE_HARDDISK, 0);
566 break;
567 case IPL_TYPE_CDROM:
568 map_cd_drive(pos->drive);
569 // NO BREAK
570 default:
571 add_bev(pos->type, pos->data);
572 break;
573 }
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500574 }
Kevin O'Connorafd05202009-08-16 12:21:44 -0400575
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500576 // If nothing added a floppy/hd boot - add it manually.
577 add_bev(IPL_TYPE_FLOPPY, 0);
578 add_bev(IPL_TYPE_HARDDISK, 0);
Kevin O'Connor0a924122009-02-08 19:43:47 -0500579}
580
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500581
582/****************************************************************
583 * Boot code (int 18/19)
584 ****************************************************************/
585
Kevin O'Connor0a924122009-02-08 19:43:47 -0500586// Jump to a bootup entry point.
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500587static void
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500588call_boot_entry(struct segoff_s bootsegip, u8 bootdrv)
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500589{
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500590 dprintf(1, "Booting from %04x:%04x\n", bootsegip.seg, bootsegip.offset);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500591 struct bregs br;
592 memset(&br, 0, sizeof(br));
Kevin O'Connorf8e800d2009-09-24 21:01:16 -0400593 br.flags = F_IF;
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500594 br.code = bootsegip;
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500595 // Set the magic number in ax and the boot drive in dl.
596 br.dl = bootdrv;
597 br.ax = 0xaa55;
Kevin O'Connorc7ffbac2012-03-25 11:04:10 -0400598 farcall16(&br);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500599}
600
601// Boot from a disk (either floppy or harddrive)
602static void
603boot_disk(u8 bootdrv, int checksig)
604{
605 u16 bootseg = 0x07c0;
606
607 // Read sector
608 struct bregs br;
609 memset(&br, 0, sizeof(br));
Kevin O'Connorf8e800d2009-09-24 21:01:16 -0400610 br.flags = F_IF;
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500611 br.dl = bootdrv;
612 br.es = bootseg;
613 br.ah = 2;
614 br.al = 1;
615 br.cl = 1;
616 call16_int(0x13, &br);
617
618 if (br.flags & F_CF) {
619 printf("Boot failed: could not read the boot disk\n\n");
620 return;
621 }
622
623 if (checksig) {
624 struct mbr_s *mbr = (void*)0;
625 if (GET_FARVAR(bootseg, mbr->signature) != MBR_SIGNATURE) {
626 printf("Boot failed: not a bootable disk\n\n");
627 return;
628 }
629 }
630
631 /* Canonicalize bootseg:bootip */
632 u16 bootip = (bootseg & 0x0fff) << 4;
633 bootseg &= 0xf000;
634
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500635 call_boot_entry(SEGOFF(bootseg, bootip), bootdrv);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500636}
637
638// Boot from a CD-ROM
639static void
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500640boot_cdrom(struct drive_s *drive_g)
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500641{
642 if (! CONFIG_CDROM_BOOT)
643 return;
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500644 printf("Booting from DVD/CD...\n");
Gleb Natapov4c90a202010-12-07 13:50:54 +0200645
Gleb Natapov4c90a202010-12-07 13:50:54 +0200646 int status = cdrom_boot(drive_g);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500647 if (status) {
Kevin O'Connorecbcf772010-12-29 13:26:01 -0500648 printf("Boot failed: Could not read from CDROM (code %04x)\n", status);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500649 return;
650 }
651
Kevin O'Connor02f76762014-05-10 01:20:46 -0400652 u8 bootdrv = CDEmu.emulated_drive;
Kevin O'Connord3140832012-05-13 22:46:12 -0400653 u16 bootseg = CDEmu.load_segment;
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500654 /* Canonicalize bootseg:bootip */
655 u16 bootip = (bootseg & 0x0fff) << 4;
656 bootseg &= 0xf000;
657
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500658 call_boot_entry(SEGOFF(bootseg, bootip), bootdrv);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500659}
660
Kevin O'Connore8f00ee2009-07-04 04:04:36 -0400661// Boot from a CBFS payload
Kevin O'Connor67823442009-04-13 14:14:51 -0400662static void
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500663boot_cbfs(struct cbfs_file *file)
Kevin O'Connor67823442009-04-13 14:14:51 -0400664{
Kevin O'Connor897fb112013-02-07 23:32:48 -0500665 if (!CONFIG_COREBOOT_FLASH)
Kevin O'Connor67823442009-04-13 14:14:51 -0400666 return;
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500667 printf("Booting from CBFS...\n");
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500668 cbfs_run_payload(file);
Kevin O'Connor67823442009-04-13 14:14:51 -0400669}
670
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500671// Boot from a BEV entry on an optionrom.
672static void
673boot_rom(u32 vector)
674{
675 printf("Booting from ROM...\n");
676 struct segoff_s so;
677 so.segoff = vector;
678 call_boot_entry(so, 0);
679}
680
Kevin O'Connorb8fcf462012-05-12 22:12:22 -0400681// Unable to find bootable device - warn user and eventually retry.
682static void
683boot_fail(void)
684{
Kevin O'Connor11a72342013-03-05 17:52:21 +0800685 if (BootRetryTime == (u32)-1)
Kevin O'Connorb8fcf462012-05-12 22:12:22 -0400686 printf("No bootable device.\n");
687 else
Kevin O'Connor11a72342013-03-05 17:52:21 +0800688 printf("No bootable device. Retrying in %d seconds.\n"
689 , BootRetryTime/1000);
690 // Wait for 'BootRetryTime' milliseconds and then reboot.
Kevin O'Connor95ee3822013-07-20 18:07:50 -0400691 u32 end = irqtimer_calc(BootRetryTime);
Kevin O'Connorb8fcf462012-05-12 22:12:22 -0400692 for (;;) {
Kevin O'Connor95ee3822013-07-20 18:07:50 -0400693 if (BootRetryTime != (u32)-1 && irqtimer_check(end))
Kevin O'Connorb8fcf462012-05-12 22:12:22 -0400694 break;
Kevin O'Connor94c749c2012-05-28 11:44:02 -0400695 yield_toirq();
Kevin O'Connorb8fcf462012-05-12 22:12:22 -0400696 }
697 printf("Rebooting.\n");
Kevin O'Connor43197a22014-06-06 13:49:33 -0400698 reset();
Kevin O'Connorb8fcf462012-05-12 22:12:22 -0400699}
700
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500701// Determine next boot method and attempt a boot using it.
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500702static void
Kevin O'Connor9d8e0a62012-05-13 12:23:58 -0400703do_boot(int seq_nr)
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500704{
Kevin O'Connor40967022008-07-21 22:23:05 -0400705 if (! CONFIG_BOOT)
Kevin O'Connore07e18e2009-02-08 17:07:29 -0500706 panic("Boot support not compiled in.\n");
Kevin O'Connor40967022008-07-21 22:23:05 -0400707
Kevin O'Connorb8fcf462012-05-12 22:12:22 -0400708 if (seq_nr >= BEVCount)
709 boot_fail();
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500710
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500711 // Boot the given BEV type.
Kevin O'Connor7bb15842010-12-29 11:25:14 -0500712 struct bev_s *ie = &BEV[seq_nr];
Kevin O'Connorcadaf0e2010-07-26 23:47:26 -0400713 switch (ie->type) {
Kevin O'Connorf13b0082008-08-17 11:26:42 -0400714 case IPL_TYPE_FLOPPY:
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500715 printf("Booting from Floppy...\n");
Kevin O'Connorbaaadb62010-12-29 11:18:04 -0500716 boot_disk(0x00, CheckFloppySig);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500717 break;
Kevin O'Connorf13b0082008-08-17 11:26:42 -0400718 case IPL_TYPE_HARDDISK:
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500719 printf("Booting from Hard Disk...\n");
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500720 boot_disk(0x80, 1);
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500721 break;
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500722 case IPL_TYPE_CDROM:
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500723 boot_cdrom((void*)ie->vector);
Kevin O'Connor67823442009-04-13 14:14:51 -0400724 break;
725 case IPL_TYPE_CBFS:
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500726 boot_cbfs((void*)ie->vector);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500727 break;
728 case IPL_TYPE_BEV:
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500729 boot_rom(ie->vector);
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500730 break;
Kevin O'Connor54ae5432013-01-12 16:36:11 -0500731 case IPL_TYPE_HALT:
732 boot_fail();
733 break;
Kevin O'Connor180a9592008-03-04 22:50:53 -0500734 }
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500735
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500736 // Boot failed: invoke the boot recovery function
Kevin O'Connor7af49bf2008-03-09 13:46:13 -0400737 struct bregs br;
738 memset(&br, 0, sizeof(br));
Kevin O'Connorf8e800d2009-09-24 21:01:16 -0400739 br.flags = F_IF;
Kevin O'Connor7af49bf2008-03-09 13:46:13 -0400740 call16_int(0x18, &br);
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500741}
742
Kevin O'Connor9d8e0a62012-05-13 12:23:58 -0400743int BootSequence VARLOW = -1;
744
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500745// Boot Failure recovery: try the next device.
Kevin O'Connor52a300f2009-12-26 23:32:57 -0500746void VISIBLE32FLAT
Kevin O'Connor1ca05b02010-01-03 17:43:37 -0500747handle_18(void)
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500748{
Kevin O'Connor15c1f222008-06-12 22:59:43 -0400749 debug_enter(NULL, DEBUG_HDL_18);
Kevin O'Connor9d8e0a62012-05-13 12:23:58 -0400750 int seq = BootSequence + 1;
751 BootSequence = seq;
Kevin O'Connor7af49bf2008-03-09 13:46:13 -0400752 do_boot(seq);
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500753}
754
755// INT 19h Boot Load Service Entry Point
Kevin O'Connor52a300f2009-12-26 23:32:57 -0500756void VISIBLE32FLAT
Kevin O'Connor1ca05b02010-01-03 17:43:37 -0500757handle_19(void)
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500758{
Kevin O'Connor15c1f222008-06-12 22:59:43 -0400759 debug_enter(NULL, DEBUG_HDL_19);
Kevin O'Connor9d8e0a62012-05-13 12:23:58 -0400760 BootSequence = 0;
Kevin O'Connor7af49bf2008-03-09 13:46:13 -0400761 do_boot(0);
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500762}