//
// This file may be distributed under the terms of the GNU LGPLv3 license.
-#include "util.h" // irq_enable
+#include "util.h" // dprintf
#include "biosvar.h" // GET_EBDA
#include "config.h" // CONFIG_*
#include "disk.h" // cdrom_boot
#include "bregs.h" // struct bregs
#include "boot.h" // struct ipl_s
#include "cmos.h" // inb_cmos
+#include "paravirt.h"
struct ipl_s IPL;
return;
struct ipl_entry_s *ie = &IPL.bcv[IPL.bcvcount++];
- ie->type = IPL_TYPE_BEV;
+ ie->type = BCV_TYPE_EXTERNAL;
ie->vector = (seg << 16) | ip;
const char *d = "Legacy option rom";
if (desc)
ie->description = d;
}
-// Add a bcv entry for an ata harddrive
+// Add a bcv entry for an internal harddrive
void
-add_bcv_hd(int driveid, const char *desc)
+add_bcv_internal(struct drive_s *drive_g)
{
if (! CONFIG_BOOT)
return;
return;
struct ipl_entry_s *ie = &IPL.bcv[IPL.bcvcount++];
- ie->type = IPL_TYPE_HARDDISK;
- ie->vector = driveid;
- ie->description = desc;
+ if (CONFIG_THREADS) {
+ // Add to bcv list with assured drive order.
+ struct ipl_entry_s *end = ie;
+ for (;;) {
+ struct ipl_entry_s *prev = ie - 1;
+ if (prev < IPL.bcv || prev->type != BCV_TYPE_INTERNAL)
+ break;
+ struct drive_s *prevdrive = (void*)prev->vector;
+ if (prevdrive->type < drive_g->type
+ || (prevdrive->type == drive_g->type
+ && prevdrive->cntl_id < drive_g->cntl_id))
+ break;
+ ie--;
+ }
+ if (ie != end)
+ memmove(ie+1, ie, (void*)end-(void*)ie);
+ }
+ ie->type = BCV_TYPE_INTERNAL;
+ ie->vector = (u32)drive_g;
+ ie->description = "";
}
{
int i;
for (i = 0; i < Drives.floppycount; i++) {
- printf("%d. floppy %d\n", menupos + i, i+1);
+ struct drive_s *drive_g = getDrive(EXTTYPE_FLOPPY, i);
+ printf("%d. Floppy [", menupos + i);
+ describe_drive(drive_g);
+ printf("]\n");
}
return Drives.floppycount;
}
for (i = 0; i < IPL.bcvcount; i++) {
struct ipl_entry_s *ie = &IPL.bcv[i];
switch (ie->type) {
- case IPL_TYPE_HARDDISK:
- printf("%d. ata%d-%d %s\n", menupos + i
- , ie->vector / 2, ie->vector % 2, ie->description);
+ case BCV_TYPE_INTERNAL:
+ printf("%d. ", menupos + i);
+ describe_drive((void*)ie->vector);
+ printf("\n");
break;
default:
menu_show_default(ie, menupos+i);
{
int i;
for (i = 0; i < Drives.cdcount; i++) {
- int driveid = Drives.idmap[EXTTYPE_CD][i];
- printf("%d. CD-Rom [ata%d-%d %s]\n", menupos + i
- , driveid / 2, driveid % 2, Drives.drives[driveid].model);
+ struct drive_s *drive_g = getDrive(EXTTYPE_CD, i);
+ printf("%d. CD-Rom [", menupos + i);
+ describe_drive(drive_g);
+ printf("]\n");
}
return Drives.cdcount;
}
menu_show_cbfs(struct ipl_entry_s *ie, int menupos)
{
int count = 0;
- struct cbfs_file *file;
+ struct cbfs_file *file = NULL;
for (;;) {
file = cbfs_findprefix("img/", file);
if (!file)
static void
interactive_bootmenu()
{
- if (! CONFIG_BOOTMENU)
+ if (! CONFIG_BOOTMENU || ! qemu_cfg_show_boot_menu())
return;
while (get_keystroke(0) >= 0)
int i;
for (i = 0; i < IPL.bevcount; i++) {
struct ipl_entry_s *ie = &IPL.bev[i];
- int sc = 1;
+ int sc;
switch (ie->type) {
case IPL_TYPE_FLOPPY:
sc = menu_show_floppy(ie, menupos);
run_bcv(struct ipl_entry_s *ie)
{
switch (ie->type) {
- case IPL_TYPE_HARDDISK:
- map_hd_drive(ie->vector);
+ case BCV_TYPE_INTERNAL:
+ map_hd_drive((void*)ie->vector);
break;
- case IPL_TYPE_BEV:
+ case BCV_TYPE_EXTERNAL:
call_bcv(ie->vector >> 16, ie->vector & 0xffff);
break;
}
if (! CONFIG_BOOT)
return;
+ // XXX - show available drives?
+
// Allow user to modify BCV/IPL order.
interactive_bootmenu();
struct bregs br;
memset(&br, 0, sizeof(br));
+ br.flags = F_IF;
br.code = SEGOFF(bootseg, bootip);
// Set the magic number in ax and the boot drive in dl.
br.dl = bootdrv;
// Read sector
struct bregs br;
memset(&br, 0, sizeof(br));
+ br.flags = F_IF;
br.dl = bootdrv;
br.es = bootseg;
br.ah = 2;
printf("No bootable device.\n");
// Loop with irqs enabled - this allows ctrl+alt+delete to work.
for (;;)
- usleep(1000000);
+ biosusleep(1000000);
}
/* Do the loading, and set up vector as a far pointer to the boot
// Boot failed: invoke the boot recovery function
struct bregs br;
memset(&br, 0, sizeof(br));
+ br.flags = F_IF;
call16_int(0x18, &br);
}