blob: 70888e264b907c9941a514708210ba8950a26601 [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'Connor2d2fa312013-09-14 21:55:26 -04008#include "boot.h" // boot_init
Kevin O'Connor135f3f62013-09-14 23:57:26 -04009#include "block.h" // struct drive_s
Kevin O'Connor2d2fa312013-09-14 21:55:26 -040010#include "bregs.h" // struct bregs
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -050011#include "config.h" // CONFIG_*
Kevin O'Connorccee6e82013-09-02 21:25:21 -040012#include "fw/paravirt.h" // qemu_cfg_show_boot_menu
Kevin O'Connor2d2fa312013-09-14 21:55:26 -040013#include "hw/cmos.h" // inb_cmos
Kevin O'Connor5d369d82013-09-02 20:48:46 -040014#include "hw/pci.h" // pci_bdf_to_*
15#include "hw/usb.h" // struct usbdevice_s
Kevin O'Connor446defb2013-06-08 21:50:53 -040016#include "list.h" // hlist_node
Kevin O'Connor9dea5902013-09-14 20:23:54 -040017#include "malloc.h" // free
Kevin O'Connor2d2fa312013-09-14 21:55:26 -040018#include "output.h" // dprintf
Kevin O'Connor41639f82013-09-14 19:37:36 -040019#include "romfile.h" // romfile_loadint
Kevin O'Connor135f3f62013-09-14 23:57:26 -040020#include "std/disk.h" // struct mbr_s
Kevin O'Connorfa9c66a2013-09-14 19:10:40 -040021#include "string.h" // memset
Kevin O'Connor2d2fa312013-09-14 21:55:26 -040022#include "util.h" // irqtimer_calc
Kevin O'Connorc659fde2008-12-28 23:43:20 -050023
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -050024
25/****************************************************************
Kevin O'Connor031ef552010-12-27 19:26:57 -050026 * Boot priority ordering
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -050027 ****************************************************************/
28
Kevin O'Connor70c94dd2013-03-08 19:39:49 -050029static char **Bootorder VARVERIFY32INIT;
Kevin O'Connor3da2c1c2010-12-29 11:37:41 -050030static int BootorderCount;
31
Kevin O'Connord1a17462010-12-24 11:17:03 -050032static void
33loadBootOrder(void)
34{
Kevin O'Connor49bf57b2011-05-10 22:08:30 -040035 if (!CONFIG_BOOTORDER)
36 return;
37
Kevin O'Connord1a17462010-12-24 11:17:03 -050038 char *f = romfile_loadfile("bootorder", NULL);
39 if (!f)
40 return;
41
Kevin O'Connor8bf55032011-01-01 11:00:42 -050042 int i = 0;
Kevin O'Connor3da2c1c2010-12-29 11:37:41 -050043 BootorderCount = 1;
Kevin O'Connord1a17462010-12-24 11:17:03 -050044 while (f[i]) {
45 if (f[i] == '\n')
Kevin O'Connor3da2c1c2010-12-29 11:37:41 -050046 BootorderCount++;
Kevin O'Connord1a17462010-12-24 11:17:03 -050047 i++;
48 }
Kevin O'Connor3da2c1c2010-12-29 11:37:41 -050049 Bootorder = malloc_tmphigh(BootorderCount*sizeof(char*));
50 if (!Bootorder) {
Kevin O'Connord1a17462010-12-24 11:17:03 -050051 warn_noalloc();
52 free(f);
Kevin O'Connor4d0c5922011-01-26 21:04:01 -050053 BootorderCount = 0;
Kevin O'Connord1a17462010-12-24 11:17:03 -050054 return;
55 }
56
57 dprintf(3, "boot order:\n");
58 i = 0;
59 do {
Kevin O'Connor3da2c1c2010-12-29 11:37:41 -050060 Bootorder[i] = f;
Kevin O'Connord1a17462010-12-24 11:17:03 -050061 f = strchr(f, '\n');
Kevin O'Connor8bf55032011-01-01 11:00:42 -050062 if (f)
63 *(f++) = '\0';
Kevin O'Connor9e881a32011-01-08 12:06:54 -050064 nullTrailingSpace(Bootorder[i]);
Kevin O'Connor8bf55032011-01-01 11:00:42 -050065 dprintf(3, "%d: %s\n", i+1, Bootorder[i]);
66 i++;
67 } while (f);
68}
69
70// See if 'str' starts with 'glob' - if glob contains an '*' character
71// it will match any number of characters in str that aren't a '/' or
72// the next glob character.
73static char *
74glob_prefix(const char *glob, const char *str)
75{
76 for (;;) {
77 if (!*glob && (!*str || *str == '/'))
78 return (char*)str;
79 if (*glob == '*') {
80 if (!*str || *str == '/' || *str == glob[1])
81 glob++;
82 else
83 str++;
84 continue;
Kevin O'Connord1a17462010-12-24 11:17:03 -050085 }
Kevin O'Connor8bf55032011-01-01 11:00:42 -050086 if (*glob != *str)
87 return NULL;
88 glob++;
89 str++;
90 }
91}
92
93// Search the bootorder list for the given glob pattern.
94static int
95find_prio(const char *glob)
96{
97 dprintf(1, "Searching bootorder for: %s\n", glob);
98 int i;
99 for (i = 0; i < BootorderCount; i++)
100 if (glob_prefix(glob, Bootorder[i]))
101 return i+1;
102 return -1;
103}
104
105#define FW_PCI_DOMAIN "/pci@i0cf8"
106
Kevin O'Connor659c99d2011-06-20 23:29:15 -0400107static char *
108build_pci_path(char *buf, int max, const char *devname, struct pci_device *pci)
109{
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500110 // Build the string path of a bdf - for example: /pci@i0cf8/isa@1,2
111 char *p = buf;
Kevin O'Connor659c99d2011-06-20 23:29:15 -0400112 if (pci->parent) {
113 p = build_pci_path(p, max, "pci-bridge", pci->parent);
Kevin O'Connord08eb9c2011-01-10 00:48:45 -0500114 } else {
Kevin O'Connor659c99d2011-06-20 23:29:15 -0400115 if (pci->rootbus)
116 p += snprintf(p, max, "/pci-root@%x", pci->rootbus);
Kevin O'Connord08eb9c2011-01-10 00:48:45 -0500117 p += snprintf(p, buf+max-p, "%s", FW_PCI_DOMAIN);
118 }
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500119
Kevin O'Connor659c99d2011-06-20 23:29:15 -0400120 int dev = pci_bdf_to_dev(pci->bdf), fn = pci_bdf_to_fn(pci->bdf);
Kevin O'Connord08eb9c2011-01-10 00:48:45 -0500121 p += snprintf(p, buf+max-p, "/%s@%x", devname, dev);
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500122 if (fn)
123 p += snprintf(p, buf+max-p, ",%x", fn);
124 return p;
Kevin O'Connord1a17462010-12-24 11:17:03 -0500125}
126
Kevin O'Connordc3a7d62011-07-09 14:33:56 -0400127int bootprio_find_pci_device(struct pci_device *pci)
Kevin O'Connor031ef552010-12-27 19:26:57 -0500128{
David Woodhouse118469a2013-01-25 19:46:25 -0600129 if (CONFIG_CSM)
130 return csm_bootprio_pci(pci);
Kevin O'Connor49bf57b2011-05-10 22:08:30 -0400131 if (!CONFIG_BOOTORDER)
132 return -1;
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500133 // Find pci device - for example: /pci@i0cf8/ethernet@5
134 char desc[256];
Kevin O'Connordc3a7d62011-07-09 14:33:56 -0400135 build_pci_path(desc, sizeof(desc), "*", pci);
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500136 return find_prio(desc);
Kevin O'Connor031ef552010-12-27 19:26:57 -0500137}
138
Paolo Bonzinic5c488f2012-02-27 17:22:23 +0100139int bootprio_find_scsi_device(struct pci_device *pci, int target, int lun)
140{
141 if (!CONFIG_BOOTORDER)
142 return -1;
143 if (!pci)
144 // support only pci machine for now
145 return -1;
146 // Find scsi drive - for example: /pci@i0cf8/scsi@5/channel@0/disk@1,0
147 char desc[256], *p;
148 p = build_pci_path(desc, sizeof(desc), "*", pci);
149 snprintf(p, desc+sizeof(desc)-p, "/*@0/*@%d,%d", target, lun);
150 return find_prio(desc);
151}
152
Kevin O'Connor95b2e0c2011-07-09 14:42:11 -0400153int bootprio_find_ata_device(struct pci_device *pci, int chanid, int slave)
Kevin O'Connor031ef552010-12-27 19:26:57 -0500154{
David Woodhouse118469a2013-01-25 19:46:25 -0600155 if (CONFIG_CSM)
156 return csm_bootprio_ata(pci, chanid, slave);
Kevin O'Connor49bf57b2011-05-10 22:08:30 -0400157 if (!CONFIG_BOOTORDER)
158 return -1;
Kevin O'Connor95b2e0c2011-07-09 14:42:11 -0400159 if (!pci)
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500160 // support only pci machine for now
161 return -1;
162 // Find ata drive - for example: /pci@i0cf8/ide@1,1/drive@1/disk@0
163 char desc[256], *p;
Kevin O'Connor95b2e0c2011-07-09 14:42:11 -0400164 p = build_pci_path(desc, sizeof(desc), "*", pci);
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500165 snprintf(p, desc+sizeof(desc)-p, "/drive@%x/disk@%x", chanid, slave);
166 return find_prio(desc);
Kevin O'Connor031ef552010-12-27 19:26:57 -0500167}
168
Kevin O'Connor03e589c2011-07-09 14:35:37 -0400169int bootprio_find_fdc_device(struct pci_device *pci, int port, int fdid)
Kevin O'Connor031ef552010-12-27 19:26:57 -0500170{
David Woodhouse118469a2013-01-25 19:46:25 -0600171 if (CONFIG_CSM)
172 return csm_bootprio_fdc(pci, port, fdid);
Kevin O'Connor49bf57b2011-05-10 22:08:30 -0400173 if (!CONFIG_BOOTORDER)
174 return -1;
Kevin O'Connor03e589c2011-07-09 14:35:37 -0400175 if (!pci)
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500176 // support only pci machine for now
177 return -1;
178 // Find floppy - for example: /pci@i0cf8/isa@1/fdc@03f1/floppy@0
179 char desc[256], *p;
Kevin O'Connor03e589c2011-07-09 14:35:37 -0400180 p = build_pci_path(desc, sizeof(desc), "isa", pci);
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500181 snprintf(p, desc+sizeof(desc)-p, "/fdc@%04x/floppy@%x", port, fdid);
182 return find_prio(desc);
Kevin O'Connor031ef552010-12-27 19:26:57 -0500183}
184
Kevin O'Connorfce91892011-07-09 14:47:47 -0400185int bootprio_find_pci_rom(struct pci_device *pci, int instance)
Kevin O'Connor031ef552010-12-27 19:26:57 -0500186{
Kevin O'Connor49bf57b2011-05-10 22:08:30 -0400187 if (!CONFIG_BOOTORDER)
188 return -1;
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500189 // Find pci rom - for example: /pci@i0cf8/scsi@3:rom2
190 char desc[256], *p;
Kevin O'Connorfce91892011-07-09 14:47:47 -0400191 p = build_pci_path(desc, sizeof(desc), "*", pci);
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500192 if (instance)
193 snprintf(p, desc+sizeof(desc)-p, ":rom%d", instance);
194 return find_prio(desc);
Kevin O'Connor031ef552010-12-27 19:26:57 -0500195}
196
197int bootprio_find_named_rom(const char *name, int instance)
198{
Kevin O'Connor49bf57b2011-05-10 22:08:30 -0400199 if (!CONFIG_BOOTORDER)
200 return -1;
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500201 // Find named rom - for example: /rom@genroms/linuxboot.bin
202 char desc[256], *p;
203 p = desc + snprintf(desc, sizeof(desc), "/rom@%s", name);
204 if (instance)
205 snprintf(p, desc+sizeof(desc)-p, ":rom%d", instance);
206 return find_prio(desc);
Kevin O'Connor031ef552010-12-27 19:26:57 -0500207}
208
Kevin O'Connorea274782012-03-08 07:49:09 -0500209static char *
210build_usb_path(char *buf, int max, struct usbhub_s *hub)
211{
212 if (!hub->usbdev)
213 // Root hub - nothing to add.
214 return buf;
215 char *p = build_usb_path(buf, max, hub->usbdev->hub);
216 p += snprintf(p, buf+max-p, "/hub@%x", hub->usbdev->port+1);
217 return p;
218}
219
Kevin O'Connor7fa31b52012-06-13 08:47:03 -0400220int bootprio_find_usb(struct usbdevice_s *usbdev, int lun)
Kevin O'Connorc2002a12010-12-31 14:38:10 -0500221{
Kevin O'Connor49bf57b2011-05-10 22:08:30 -0400222 if (!CONFIG_BOOTORDER)
223 return -1;
Kevin O'Connor7fa31b52012-06-13 08:47:03 -0400224 // Find usb - for example: /pci@i0cf8/usb@1,2/storage@1/channel@0/disk@0,0
Kevin O'Connorc2002a12010-12-31 14:38:10 -0500225 char desc[256], *p;
Kevin O'Connorea274782012-03-08 07:49:09 -0500226 p = build_pci_path(desc, sizeof(desc), "usb", usbdev->hub->cntl->pci);
227 p = build_usb_path(p, desc+sizeof(desc)-p, usbdev->hub);
Kevin O'Connor7fa31b52012-06-13 08:47:03 -0400228 snprintf(p, desc+sizeof(desc)-p, "/storage@%x/*@0/*@0,%d"
229 , usbdev->port+1, lun);
230 int ret = find_prio(desc);
231 if (ret >= 0)
232 return ret;
233 // Try usb-host/redir - for example: /pci@i0cf8/usb@1,2/usb-host@1
234 snprintf(p, desc+sizeof(desc)-p, "/usb-*@%x", usbdev->port+1);
Kevin O'Connorc2002a12010-12-31 14:38:10 -0500235 return find_prio(desc);
236}
237
Kevin O'Connor031ef552010-12-27 19:26:57 -0500238
239/****************************************************************
240 * Boot setup
241 ****************************************************************/
242
Kevin O'Connor11a72342013-03-05 17:52:21 +0800243static int BootRetryTime;
Kevin O'Connorbaaadb62010-12-29 11:18:04 -0500244static int CheckFloppySig = 1;
245
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500246#define DEFAULT_PRIO 9999
247
248static int DefaultFloppyPrio = 101;
249static int DefaultCDPrio = 102;
250static int DefaultHDPrio = 103;
251static int DefaultBEVPrio = 104;
252
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500253void
Kevin O'Connord83c87b2013-01-21 01:14:12 -0500254boot_init(void)
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500255{
256 if (! CONFIG_BOOT)
257 return;
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500258
Kevin O'Connor897fb112013-02-07 23:32:48 -0500259 if (CONFIG_QEMU) {
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500260 // On emulators, get boot order from nvram.
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500261 if (inb_cmos(CMOS_BIOS_BOOTFLAG1) & 1)
Kevin O'Connorbaaadb62010-12-29 11:18:04 -0500262 CheckFloppySig = 0;
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500263 u32 bootorder = (inb_cmos(CMOS_BIOS_BOOTFLAG2)
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500264 | ((inb_cmos(CMOS_BIOS_BOOTFLAG1) & 0xf0) << 4));
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500265 DefaultFloppyPrio = DefaultCDPrio = DefaultHDPrio
266 = DefaultBEVPrio = DEFAULT_PRIO;
267 int i;
268 for (i=101; i<104; i++) {
269 u32 val = bootorder & 0x0f;
270 bootorder >>= 4;
271 switch (val) {
272 case 1: DefaultFloppyPrio = i; break;
273 case 2: DefaultHDPrio = i; break;
274 case 3: DefaultCDPrio = i; break;
275 case 4: DefaultBEVPrio = i; break;
276 }
277 }
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500278 }
Gleb Natapovb9a75912010-12-23 11:29:38 +0200279
Kevin O'Connor11a72342013-03-05 17:52:21 +0800280 BootRetryTime = romfile_loadint("etc/boot-fail-wait", 60*1000);
281
Kevin O'Connord1a17462010-12-24 11:17:03 -0500282 loadBootOrder();
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500283}
284
Kevin O'Connord1a17462010-12-24 11:17:03 -0500285
286/****************************************************************
Kevin O'Connor031ef552010-12-27 19:26:57 -0500287 * BootList handling
Kevin O'Connord1a17462010-12-24 11:17:03 -0500288 ****************************************************************/
289
Kevin O'Connor031ef552010-12-27 19:26:57 -0500290struct bootentry_s {
291 int type;
292 union {
293 u32 data;
294 struct segoff_s vector;
295 struct drive_s *drive;
296 };
297 int priority;
298 const char *description;
Kevin O'Connor446defb2013-06-08 21:50:53 -0400299 struct hlist_node node;
Kevin O'Connor031ef552010-12-27 19:26:57 -0500300};
Kevin O'Connor446defb2013-06-08 21:50:53 -0400301static struct hlist_head BootList VARVERIFY32INIT;
Kevin O'Connor031ef552010-12-27 19:26:57 -0500302
Kevin O'Connor7bb15842010-12-29 11:25:14 -0500303#define IPL_TYPE_FLOPPY 0x01
304#define IPL_TYPE_HARDDISK 0x02
305#define IPL_TYPE_CDROM 0x03
306#define IPL_TYPE_CBFS 0x20
307#define IPL_TYPE_BEV 0x80
308#define IPL_TYPE_BCV 0x81
Kevin O'Connor54ae5432013-01-12 16:36:11 -0500309#define IPL_TYPE_HALT 0xf0
Kevin O'Connor7bb15842010-12-29 11:25:14 -0500310
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500311static void
312bootentry_add(int type, int prio, u32 data, const char *desc)
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500313{
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500314 if (! CONFIG_BOOT)
315 return;
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500316 struct bootentry_s *be = malloc_tmp(sizeof(*be));
317 if (!be) {
318 warn_noalloc();
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500319 return;
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500320 }
321 be->type = type;
322 be->priority = prio;
323 be->data = data;
Kevin O'Connorca2bc1c2010-12-29 21:41:19 -0500324 be->description = desc ?: "?";
Kevin O'Connor8bf55032011-01-01 11:00:42 -0500325 dprintf(3, "Registering bootable: %s (type:%d prio:%d data:%x)\n"
326 , be->description, type, prio, data);
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500327
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500328 // Add entry in sorted order.
Kevin O'Connor446defb2013-06-08 21:50:53 -0400329 struct hlist_node **pprev;
330 struct bootentry_s *pos;
Kevin O'Connor030a58a2013-06-13 21:24:14 -0400331 hlist_for_each_entry_pprev(pos, pprev, &BootList, node) {
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500332 if (be->priority < pos->priority)
333 break;
334 if (be->priority > pos->priority)
335 continue;
336 if (be->type < pos->type)
337 break;
338 if (be->type > pos->type)
339 continue;
340 if (be->type <= IPL_TYPE_CDROM
341 && (be->drive->type < pos->drive->type
342 || (be->drive->type == pos->drive->type
343 && be->drive->cntl_id < pos->drive->cntl_id)))
344 break;
345 }
Kevin O'Connor446defb2013-06-08 21:50:53 -0400346 hlist_add(&be->node, pprev);
Kevin O'Connor0a924122009-02-08 19:43:47 -0500347}
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500348
Kevin O'Connor031ef552010-12-27 19:26:57 -0500349// Return the given priority if it's set - defaultprio otherwise.
350static inline int defPrio(int priority, int defaultprio) {
351 return (priority < 0) ? defaultprio : priority;
352}
353
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500354// Add a BEV vector for a given pnp compatible option rom.
Gleb Natapov4c90a202010-12-07 13:50:54 +0200355void
Kevin O'Connor031ef552010-12-27 19:26:57 -0500356boot_add_bev(u16 seg, u16 bev, u16 desc, int prio)
Gleb Natapov4c90a202010-12-07 13:50:54 +0200357{
Kevin O'Connor031ef552010-12-27 19:26:57 -0500358 bootentry_add(IPL_TYPE_BEV, defPrio(prio, DefaultBEVPrio)
359 , SEGOFF(seg, bev).segoff
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500360 , desc ? MAKE_FLATPTR(seg, desc) : "Unknown");
361 DefaultBEVPrio = DEFAULT_PRIO;
Gleb Natapov4c90a202010-12-07 13:50:54 +0200362}
363
Kevin O'Connor0a924122009-02-08 19:43:47 -0500364// Add a bcv entry for an expansion card harddrive or legacy option rom
365void
Kevin O'Connor031ef552010-12-27 19:26:57 -0500366boot_add_bcv(u16 seg, u16 ip, u16 desc, int prio)
Kevin O'Connor0a924122009-02-08 19:43:47 -0500367{
Kevin O'Connor88e745e2012-01-14 11:58:14 -0500368 bootentry_add(IPL_TYPE_BCV, defPrio(prio, DefaultHDPrio)
Kevin O'Connor031ef552010-12-27 19:26:57 -0500369 , SEGOFF(seg, ip).segoff
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500370 , desc ? MAKE_FLATPTR(seg, desc) : "Legacy option rom");
Kevin O'Connor0a924122009-02-08 19:43:47 -0500371}
372
Kevin O'Connor0a924122009-02-08 19:43:47 -0500373void
Kevin O'Connorca2bc1c2010-12-29 21:41:19 -0500374boot_add_floppy(struct drive_s *drive_g, const char *desc, int prio)
Kevin O'Connor0a924122009-02-08 19:43:47 -0500375{
Kevin O'Connor031ef552010-12-27 19:26:57 -0500376 bootentry_add(IPL_TYPE_FLOPPY, defPrio(prio, DefaultFloppyPrio)
Kevin O'Connorca2bc1c2010-12-29 21:41:19 -0500377 , (u32)drive_g, desc);
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500378}
Kevin O'Connor0a924122009-02-08 19:43:47 -0500379
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500380void
Kevin O'Connorca2bc1c2010-12-29 21:41:19 -0500381boot_add_hd(struct drive_s *drive_g, const char *desc, int prio)
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500382{
Kevin O'Connor031ef552010-12-27 19:26:57 -0500383 bootentry_add(IPL_TYPE_HARDDISK, defPrio(prio, DefaultHDPrio)
Kevin O'Connorca2bc1c2010-12-29 21:41:19 -0500384 , (u32)drive_g, desc);
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500385}
386
387void
Kevin O'Connorca2bc1c2010-12-29 21:41:19 -0500388boot_add_cd(struct drive_s *drive_g, const char *desc, int prio)
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500389{
Kevin O'Connor031ef552010-12-27 19:26:57 -0500390 bootentry_add(IPL_TYPE_CDROM, defPrio(prio, DefaultCDPrio)
Kevin O'Connorca2bc1c2010-12-29 21:41:19 -0500391 , (u32)drive_g, desc);
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500392}
393
394// Add a CBFS payload entry
395void
Kevin O'Connor031ef552010-12-27 19:26:57 -0500396boot_add_cbfs(void *data, const char *desc, int prio)
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500397{
Kevin O'Connor031ef552010-12-27 19:26:57 -0500398 bootentry_add(IPL_TYPE_CBFS, defPrio(prio, DEFAULT_PRIO), (u32)data, desc);
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500399}
400
401
402/****************************************************************
Kevin O'Connor0ac5e9e2013-09-14 13:09:27 -0400403 * Keyboard calls
404 ****************************************************************/
405
406// See if a keystroke is pending in the keyboard buffer.
407static int
408check_for_keystroke(void)
409{
410 struct bregs br;
411 memset(&br, 0, sizeof(br));
412 br.flags = F_IF|F_ZF;
413 br.ah = 1;
414 call16_int(0x16, &br);
415 return !(br.flags & F_ZF);
416}
417
418// Return a keystroke - waiting forever if necessary.
419static int
420get_raw_keystroke(void)
421{
422 struct bregs br;
423 memset(&br, 0, sizeof(br));
424 br.flags = F_IF;
425 call16_int(0x16, &br);
426 return br.ah;
427}
428
429// Read a keystroke - waiting up to 'msec' milliseconds.
430static int
431get_keystroke(int msec)
432{
433 u32 end = irqtimer_calc(msec);
434 for (;;) {
435 if (check_for_keystroke())
436 return get_raw_keystroke();
437 if (irqtimer_check(end))
438 return -1;
439 yield_toirq();
440 }
441}
442
443
444/****************************************************************
Kevin O'Connor0a924122009-02-08 19:43:47 -0500445 * Boot menu and BCV execution
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500446 ****************************************************************/
447
Kevin O'Connor73023002011-07-05 20:34:34 -0400448#define DEFAULT_BOOTMENU_WAIT 2500
449
Kevin O'Connor0a924122009-02-08 19:43:47 -0500450// Show IPL option menu.
Kevin O'Connor8a0a9722013-01-21 01:53:31 -0500451void
Kevin O'Connor1ca05b02010-01-03 17:43:37 -0500452interactive_bootmenu(void)
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500453{
Kevin O'Connor8a0a9722013-01-21 01:53:31 -0500454 // XXX - show available drives?
455
Kevin O'Connor56c50892013-02-09 19:25:51 -0500456 if (! CONFIG_BOOTMENU || !romfile_loadint("etc/show-boot-menu", 1))
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500457 return;
458
459 while (get_keystroke(0) >= 0)
460 ;
461
Kevin O'Connor129f11e2013-08-02 14:13:50 -0400462 char *bootmsg = romfile_loadfile("etc/boot-menu-message", NULL);
463 int menukey = romfile_loadint("etc/boot-menu-key", 0x86);
464 printf("%s", bootmsg ?: "\nPress F12 for boot menu.\n\n");
465 free(bootmsg);
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500466
Kevin O'Connor73023002011-07-05 20:34:34 -0400467 u32 menutime = romfile_loadint("etc/boot-menu-wait", DEFAULT_BOOTMENU_WAIT);
Kevin O'Connor9a01a9c2010-08-25 21:07:48 -0400468 enable_bootsplash();
Kevin O'Connor73023002011-07-05 20:34:34 -0400469 int scan_code = get_keystroke(menutime);
Kevin O'Connor9a01a9c2010-08-25 21:07:48 -0400470 disable_bootsplash();
Kevin O'Connor129f11e2013-08-02 14:13:50 -0400471 if (scan_code != menukey)
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500472 return;
473
474 while (get_keystroke(0) >= 0)
475 ;
476
477 printf("Select boot device:\n\n");
Kevin O'Connore438b0c2010-05-01 12:20:33 -0400478 wait_threads();
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500479
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500480 // Show menu items
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500481 int maxmenu = 0;
Kevin O'Connor446defb2013-06-08 21:50:53 -0400482 struct bootentry_s *pos;
483 hlist_for_each_entry(pos, &BootList, node) {
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500484 char desc[60];
485 maxmenu++;
486 printf("%d. %s\n", maxmenu
487 , strtcpy(desc, pos->description, ARRAY_SIZE(desc)));
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500488 }
489
Kevin O'Connor551caa22010-12-29 13:25:18 -0500490 // Get key press
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500491 for (;;) {
492 scan_code = get_keystroke(1000);
Kevin O'Connor551caa22010-12-29 13:25:18 -0500493 if (scan_code >= 1 && scan_code <= maxmenu+1)
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500494 break;
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500495 }
496 printf("\n");
Kevin O'Connor551caa22010-12-29 13:25:18 -0500497 if (scan_code == 0x01)
498 // ESC
499 return;
500
501 // Find entry and make top priority.
502 int choice = scan_code - 1;
Kevin O'Connor446defb2013-06-08 21:50:53 -0400503 hlist_for_each_entry(pos, &BootList, node) {
504 if (! --choice)
505 break;
506 }
507 hlist_del(&pos->node);
Kevin O'Connor551caa22010-12-29 13:25:18 -0500508 pos->priority = 0;
Kevin O'Connor446defb2013-06-08 21:50:53 -0400509 hlist_add_head(&pos->node, &BootList);
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500510}
511
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500512// BEV (Boot Execution Vector) list
Kevin O'Connor7bb15842010-12-29 11:25:14 -0500513struct bev_s {
514 int type;
515 u32 vector;
516};
517static struct bev_s BEV[20];
518static int BEVCount;
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500519static int HaveHDBoot, HaveFDBoot;
520
Kevin O'Connor0a924122009-02-08 19:43:47 -0500521static void
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500522add_bev(int type, u32 vector)
Kevin O'Connor0a924122009-02-08 19:43:47 -0500523{
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500524 if (type == IPL_TYPE_HARDDISK && HaveHDBoot++)
525 return;
526 if (type == IPL_TYPE_FLOPPY && HaveFDBoot++)
527 return;
Kevin O'Connor7bb15842010-12-29 11:25:14 -0500528 if (BEVCount >= ARRAY_SIZE(BEV))
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500529 return;
Kevin O'Connor7bb15842010-12-29 11:25:14 -0500530 struct bev_s *bev = &BEV[BEVCount++];
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500531 bev->type = type;
532 bev->vector = vector;
Kevin O'Connor0a924122009-02-08 19:43:47 -0500533}
534
535// Prepare for boot - show menu and run bcvs.
536void
Kevin O'Connor8a0a9722013-01-21 01:53:31 -0500537bcv_prepboot(void)
Kevin O'Connor0a924122009-02-08 19:43:47 -0500538{
Kevin O'Connor8a0a9722013-01-21 01:53:31 -0500539 if (! CONFIG_BOOT)
Kevin O'Connor0a924122009-02-08 19:43:47 -0500540 return;
Kevin O'Connor0a924122009-02-08 19:43:47 -0500541
Kevin O'Connor54ae5432013-01-12 16:36:11 -0500542 int haltprio = find_prio("HALT");
543 if (haltprio >= 0)
544 bootentry_add(IPL_TYPE_HALT, haltprio, 0, "HALT");
545
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500546 // Map drives and populate BEV list
Kevin O'Connor446defb2013-06-08 21:50:53 -0400547 struct bootentry_s *pos;
548 hlist_for_each_entry(pos, &BootList, node) {
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500549 switch (pos->type) {
550 case IPL_TYPE_BCV:
551 call_bcv(pos->vector.seg, pos->vector.offset);
552 add_bev(IPL_TYPE_HARDDISK, 0);
553 break;
554 case IPL_TYPE_FLOPPY:
555 map_floppy_drive(pos->drive);
556 add_bev(IPL_TYPE_FLOPPY, 0);
557 break;
558 case IPL_TYPE_HARDDISK:
559 map_hd_drive(pos->drive);
560 add_bev(IPL_TYPE_HARDDISK, 0);
561 break;
562 case IPL_TYPE_CDROM:
563 map_cd_drive(pos->drive);
564 // NO BREAK
565 default:
566 add_bev(pos->type, pos->data);
567 break;
568 }
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500569 }
Kevin O'Connorafd05202009-08-16 12:21:44 -0400570
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500571 // If nothing added a floppy/hd boot - add it manually.
572 add_bev(IPL_TYPE_FLOPPY, 0);
573 add_bev(IPL_TYPE_HARDDISK, 0);
Kevin O'Connor0a924122009-02-08 19:43:47 -0500574}
575
Kevin O'Connor9f4e1d92009-02-08 15:44:08 -0500576
577/****************************************************************
578 * Boot code (int 18/19)
579 ****************************************************************/
580
Kevin O'Connor0a924122009-02-08 19:43:47 -0500581// Jump to a bootup entry point.
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500582static void
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500583call_boot_entry(struct segoff_s bootsegip, u8 bootdrv)
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500584{
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500585 dprintf(1, "Booting from %04x:%04x\n", bootsegip.seg, bootsegip.offset);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500586 struct bregs br;
587 memset(&br, 0, sizeof(br));
Kevin O'Connorf8e800d2009-09-24 21:01:16 -0400588 br.flags = F_IF;
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500589 br.code = bootsegip;
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500590 // Set the magic number in ax and the boot drive in dl.
591 br.dl = bootdrv;
592 br.ax = 0xaa55;
Kevin O'Connorc7ffbac2012-03-25 11:04:10 -0400593 farcall16(&br);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500594}
595
596// Boot from a disk (either floppy or harddrive)
597static void
598boot_disk(u8 bootdrv, int checksig)
599{
600 u16 bootseg = 0x07c0;
601
602 // Read sector
603 struct bregs br;
604 memset(&br, 0, sizeof(br));
Kevin O'Connorf8e800d2009-09-24 21:01:16 -0400605 br.flags = F_IF;
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500606 br.dl = bootdrv;
607 br.es = bootseg;
608 br.ah = 2;
609 br.al = 1;
610 br.cl = 1;
611 call16_int(0x13, &br);
612
613 if (br.flags & F_CF) {
614 printf("Boot failed: could not read the boot disk\n\n");
615 return;
616 }
617
618 if (checksig) {
619 struct mbr_s *mbr = (void*)0;
620 if (GET_FARVAR(bootseg, mbr->signature) != MBR_SIGNATURE) {
621 printf("Boot failed: not a bootable disk\n\n");
622 return;
623 }
624 }
625
626 /* Canonicalize bootseg:bootip */
627 u16 bootip = (bootseg & 0x0fff) << 4;
628 bootseg &= 0xf000;
629
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500630 call_boot_entry(SEGOFF(bootseg, bootip), bootdrv);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500631}
632
633// Boot from a CD-ROM
634static void
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500635boot_cdrom(struct drive_s *drive_g)
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500636{
637 if (! CONFIG_CDROM_BOOT)
638 return;
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500639 printf("Booting from DVD/CD...\n");
Gleb Natapov4c90a202010-12-07 13:50:54 +0200640
Gleb Natapov4c90a202010-12-07 13:50:54 +0200641 int status = cdrom_boot(drive_g);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500642 if (status) {
Kevin O'Connorecbcf772010-12-29 13:26:01 -0500643 printf("Boot failed: Could not read from CDROM (code %04x)\n", status);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500644 return;
645 }
646
Kevin O'Connord3140832012-05-13 22:46:12 -0400647 u8 bootdrv = CDEmu.emulated_extdrive;
648 u16 bootseg = CDEmu.load_segment;
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500649 /* Canonicalize bootseg:bootip */
650 u16 bootip = (bootseg & 0x0fff) << 4;
651 bootseg &= 0xf000;
652
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500653 call_boot_entry(SEGOFF(bootseg, bootip), bootdrv);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500654}
655
Kevin O'Connore8f00ee2009-07-04 04:04:36 -0400656// Boot from a CBFS payload
Kevin O'Connor67823442009-04-13 14:14:51 -0400657static void
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500658boot_cbfs(struct cbfs_file *file)
Kevin O'Connor67823442009-04-13 14:14:51 -0400659{
Kevin O'Connor897fb112013-02-07 23:32:48 -0500660 if (!CONFIG_COREBOOT_FLASH)
Kevin O'Connor67823442009-04-13 14:14:51 -0400661 return;
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500662 printf("Booting from CBFS...\n");
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500663 cbfs_run_payload(file);
Kevin O'Connor67823442009-04-13 14:14:51 -0400664}
665
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500666// Boot from a BEV entry on an optionrom.
667static void
668boot_rom(u32 vector)
669{
670 printf("Booting from ROM...\n");
671 struct segoff_s so;
672 so.segoff = vector;
673 call_boot_entry(so, 0);
674}
675
Kevin O'Connorb8fcf462012-05-12 22:12:22 -0400676// Unable to find bootable device - warn user and eventually retry.
677static void
678boot_fail(void)
679{
Kevin O'Connor11a72342013-03-05 17:52:21 +0800680 if (BootRetryTime == (u32)-1)
Kevin O'Connorb8fcf462012-05-12 22:12:22 -0400681 printf("No bootable device.\n");
682 else
Kevin O'Connor11a72342013-03-05 17:52:21 +0800683 printf("No bootable device. Retrying in %d seconds.\n"
684 , BootRetryTime/1000);
685 // Wait for 'BootRetryTime' milliseconds and then reboot.
Kevin O'Connor95ee3822013-07-20 18:07:50 -0400686 u32 end = irqtimer_calc(BootRetryTime);
Kevin O'Connorb8fcf462012-05-12 22:12:22 -0400687 for (;;) {
Kevin O'Connor95ee3822013-07-20 18:07:50 -0400688 if (BootRetryTime != (u32)-1 && irqtimer_check(end))
Kevin O'Connorb8fcf462012-05-12 22:12:22 -0400689 break;
Kevin O'Connor94c749c2012-05-28 11:44:02 -0400690 yield_toirq();
Kevin O'Connorb8fcf462012-05-12 22:12:22 -0400691 }
692 printf("Rebooting.\n");
693 struct bregs br;
694 memset(&br, 0, sizeof(br));
695 br.code = SEGOFF(SEG_BIOS, (u32)reset_vector);
Kevin O'Connorc7ffbac2012-03-25 11:04:10 -0400696 farcall16big(&br);
Kevin O'Connorb8fcf462012-05-12 22:12:22 -0400697}
698
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500699// Determine next boot method and attempt a boot using it.
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500700static void
Kevin O'Connor9d8e0a62012-05-13 12:23:58 -0400701do_boot(int seq_nr)
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500702{
Kevin O'Connor40967022008-07-21 22:23:05 -0400703 if (! CONFIG_BOOT)
Kevin O'Connore07e18e2009-02-08 17:07:29 -0500704 panic("Boot support not compiled in.\n");
Kevin O'Connor40967022008-07-21 22:23:05 -0400705
Kevin O'Connorb8fcf462012-05-12 22:12:22 -0400706 if (seq_nr >= BEVCount)
707 boot_fail();
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500708
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500709 // Boot the given BEV type.
Kevin O'Connor7bb15842010-12-29 11:25:14 -0500710 struct bev_s *ie = &BEV[seq_nr];
Kevin O'Connorcadaf0e2010-07-26 23:47:26 -0400711 switch (ie->type) {
Kevin O'Connorf13b0082008-08-17 11:26:42 -0400712 case IPL_TYPE_FLOPPY:
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500713 printf("Booting from Floppy...\n");
Kevin O'Connorbaaadb62010-12-29 11:18:04 -0500714 boot_disk(0x00, CheckFloppySig);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500715 break;
Kevin O'Connorf13b0082008-08-17 11:26:42 -0400716 case IPL_TYPE_HARDDISK:
Kevin O'Connor72eee3e2010-12-27 19:07:49 -0500717 printf("Booting from Hard Disk...\n");
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500718 boot_disk(0x80, 1);
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500719 break;
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500720 case IPL_TYPE_CDROM:
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500721 boot_cdrom((void*)ie->vector);
Kevin O'Connor67823442009-04-13 14:14:51 -0400722 break;
723 case IPL_TYPE_CBFS:
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500724 boot_cbfs((void*)ie->vector);
Kevin O'Connor71f036d2009-02-08 16:57:22 -0500725 break;
726 case IPL_TYPE_BEV:
Kevin O'Connorf13a1802010-12-29 11:52:33 -0500727 boot_rom(ie->vector);
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500728 break;
Kevin O'Connor54ae5432013-01-12 16:36:11 -0500729 case IPL_TYPE_HALT:
730 boot_fail();
731 break;
Kevin O'Connor180a9592008-03-04 22:50:53 -0500732 }
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500733
Kevin O'Connor38fcbfe2008-02-25 22:30:47 -0500734 // Boot failed: invoke the boot recovery function
Kevin O'Connor7af49bf2008-03-09 13:46:13 -0400735 struct bregs br;
736 memset(&br, 0, sizeof(br));
Kevin O'Connorf8e800d2009-09-24 21:01:16 -0400737 br.flags = F_IF;
Kevin O'Connor7af49bf2008-03-09 13:46:13 -0400738 call16_int(0x18, &br);
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500739}
740
Kevin O'Connor9d8e0a62012-05-13 12:23:58 -0400741int BootSequence VARLOW = -1;
742
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500743// Boot Failure recovery: try the next device.
Kevin O'Connor52a300f2009-12-26 23:32:57 -0500744void VISIBLE32FLAT
Kevin O'Connor1ca05b02010-01-03 17:43:37 -0500745handle_18(void)
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500746{
Kevin O'Connord83c87b2013-01-21 01:14:12 -0500747 debug_serial_preinit();
Kevin O'Connor15c1f222008-06-12 22:59:43 -0400748 debug_enter(NULL, DEBUG_HDL_18);
Kevin O'Connor9d8e0a62012-05-13 12:23:58 -0400749 int seq = BootSequence + 1;
750 BootSequence = seq;
Kevin O'Connor7af49bf2008-03-09 13:46:13 -0400751 do_boot(seq);
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500752}
753
754// INT 19h Boot Load Service Entry Point
Kevin O'Connor52a300f2009-12-26 23:32:57 -0500755void VISIBLE32FLAT
Kevin O'Connor1ca05b02010-01-03 17:43:37 -0500756handle_19(void)
Kevin O'Connorf076a3e2008-02-25 22:25:15 -0500757{
Kevin O'Connord83c87b2013-01-21 01:14:12 -0500758 debug_serial_preinit();
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}