From: Kevin O'Connor Date: Mon, 29 Dec 2008 04:43:20 +0000 (-0500) Subject: Move IPL definitions from ebda to global variables. X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=seabios.git;a=commitdiff_plain;h=c659fdedadce1566308675d0c44537ade0eb12a2 Move IPL definitions from ebda to global variables. The boot sequence variable remains in ebda. Move boot specific definitions to a new header (boot.h) --- diff --git a/src/biosvar.h b/src/biosvar.h index dc70802..1a6da34 100644 --- a/src/biosvar.h +++ b/src/biosvar.h @@ -128,31 +128,6 @@ struct bios_data_area_s { } while (0) -/**************************************************************** - * Initial Program Load (IPL) - ****************************************************************/ - -struct ipl_entry_s { - u16 type; - u16 flags; - u32 vector; - char *description; -}; - -struct ipl_s { - struct ipl_entry_s table[8]; - u16 count; - u16 sequence; - u32 bootorder; - u8 checkfloppysig; -}; - -#define IPL_TYPE_FLOPPY 0x01 -#define IPL_TYPE_HARDDISK 0x02 -#define IPL_TYPE_CDROM 0x03 -#define IPL_TYPE_BEV 0x80 - - /**************************************************************** * Extended Bios Data Area (EBDA) ****************************************************************/ @@ -218,8 +193,7 @@ struct extended_bios_data_area_s { // Locks for removable devices u8 cdrom_locks[CONFIG_MAX_ATA_DEVICES]; - // Initial program load - struct ipl_s ipl; + u16 boot_sequence; // Resume stack u8 resume_stack[128] __aligned(8); diff --git a/src/boot.c b/src/boot.c index ca1b980..b8104a5 100644 --- a/src/boot.c +++ b/src/boot.c @@ -11,6 +11,9 @@ #include "ata.h" // ata_detect #include "disk.h" // cdrom_boot #include "bregs.h" // struct bregs +#include "boot.h" // struct ipl_s + +struct ipl_s IPL; //-------------------------------------------------------------------------- // print_boot_device @@ -24,7 +27,7 @@ static const char drivetypes[][10]={ void printf_bootdev(u16 bootdev) { - u16 type = GET_EBDA(ipl.table[bootdev].type); + u16 type = IPL.table[bootdev].type; /* NIC appears as type 0x80 */ if (type == IPL_TYPE_BEV) @@ -34,7 +37,7 @@ printf_bootdev(u16 bootdev) printf("%s", drivetypes[type]); /* print product string if BEV */ - char *far_description = GET_EBDA(ipl.table[bootdev].description); + char *far_description = IPL.table[bootdev].description; if (type == 4 && far_description != 0) { char description[33]; /* first 32 bytes are significant */ @@ -80,9 +83,9 @@ try_boot(u16 seq_nr) if (! CONFIG_BOOT) BX_PANIC("Boot support not compiled in.\n"); - SET_EBDA(ipl.sequence, seq_nr); + SET_EBDA(boot_sequence, seq_nr); - u32 bootdev = GET_EBDA(ipl.bootorder); + u32 bootdev = IPL.bootorder; bootdev >>= 4 * seq_nr; bootdev &= 0xf; @@ -92,7 +95,7 @@ try_boot(u16 seq_nr) /* Translate bootdev to an IPL table offset by subtracting 1 */ bootdev -= 1; - if (bootdev >= GET_EBDA(ipl.count)) { + if (bootdev >= IPL.count) { dprintf(1, "Invalid boot device (0x%x)\n", bootdev); return; } @@ -101,7 +104,7 @@ try_boot(u16 seq_nr) * address, and bootdrv as the boot drive */ print_boot_device(bootdev); - u16 type = GET_EBDA(ipl.table[bootdev].type); + u16 type = IPL.table[bootdev].type; u16 bootseg, bootip; u8 bootdrv = 0; @@ -129,7 +132,7 @@ try_boot(u16 seq_nr) /* Always check the signature on a HDD boot sector; on FDD, * only do the check if configured for it */ - if (type != IPL_TYPE_FLOPPY || GET_EBDA(ipl.checkfloppysig)) { + if (type != IPL_TYPE_FLOPPY || IPL.checkfloppysig) { if (GET_FARVAR(bootseg, *(u16*)0x1fe) != 0xaa55) { print_boot_failure(type, 0); return; @@ -161,7 +164,7 @@ try_boot(u16 seq_nr) case IPL_TYPE_BEV: { /* Expansion ROM with a Bootstrap Entry Vector (a far * pointer) */ - u32 vector = GET_EBDA(ipl.table[bootdev].vector); + u32 vector = IPL.table[bootdev].vector; bootseg = vector >> 16; bootip = vector & 0xffff; break; @@ -199,7 +202,7 @@ handle_18() { debug_serial_setup(); debug_enter(NULL, DEBUG_HDL_18); - u16 seq = GET_EBDA(ipl.sequence) + 1; + u16 seq = GET_EBDA(boot_sequence) + 1; do_boot(seq); } diff --git a/src/boot.h b/src/boot.h new file mode 100644 index 0000000..a5fe08e --- /dev/null +++ b/src/boot.h @@ -0,0 +1,41 @@ +// Storage for boot definitions. +#ifndef __BOOT_H +#define __BOOT_H + + +/**************************************************************** + * Initial Program Load (IPL) + ****************************************************************/ + +struct ipl_entry_s { + u16 type; + u16 flags; + u32 vector; + char *description; +}; + +struct ipl_s { + struct ipl_entry_s table[8]; + u16 count; + u32 bootorder; + u8 checkfloppysig; +}; + +#define IPL_TYPE_FLOPPY 0x01 +#define IPL_TYPE_HARDDISK 0x02 +#define IPL_TYPE_CDROM 0x03 +#define IPL_TYPE_BEV 0x80 + + +/**************************************************************** + * Function defs + ****************************************************************/ + +// boot.c +extern struct ipl_s IPL; +void printf_bootdev(u16 bootdev); + +// post_menu.c +void interactive_bootmenu(); + +#endif // __BOOT_H diff --git a/src/optionroms.c b/src/optionroms.c index b7bc110..44001ee 100644 --- a/src/optionroms.c +++ b/src/optionroms.c @@ -6,11 +6,13 @@ // This file may be distributed under the terms of the GNU GPLv3 license. #include "bregs.h" // struct bregs -#include "biosvar.h" // struct ipl_entry_s +#include "farptr.h" // FARPTR_TO_SEG +#include "config.h" // CONFIG_* #include "util.h" // dprintf #include "pci.h" // pci_find_class #include "pci_regs.h" // PCI_ROM_ADDRESS #include "pci_ids.h" // PCI_CLASS_DISPLAY_VGA +#include "boot.h" // IPL /**************************************************************** @@ -156,11 +158,10 @@ add_ipl(struct rom_header *rom, struct pnp_data *pnp) if (! CONFIG_BOOT) return; - struct extended_bios_data_area_s *ebda = get_ebda_ptr(); - if (ebda->ipl.count >= ARRAY_SIZE(ebda->ipl.table)) + if (IPL.count >= ARRAY_SIZE(IPL.table)) return; - struct ipl_entry_s *ip = &ebda->ipl.table[ebda->ipl.count]; + struct ipl_entry_s *ip = &IPL.table[IPL.count]; ip->type = IPL_TYPE_BEV; ip->vector = (FARPTR_TO_SEG(rom) << 16) | pnp->bev; @@ -168,7 +169,7 @@ add_ipl(struct rom_header *rom, struct pnp_data *pnp) if (desc) ip->description = MAKE_FARPTR(FARPTR_TO_SEG(rom), desc); - ebda->ipl.count++; + IPL.count++; } // Copy a rom to its permanent location below 1MiB diff --git a/src/post.c b/src/post.c index ec55ab2..cc86abf 100644 --- a/src/post.c +++ b/src/post.c @@ -17,6 +17,7 @@ #include "pci.h" // create_pirtable #include "acpi.h" // acpi_bios_init #include "bregs.h" // struct bregs +#include "boot.h" // IPL #define bda ((struct bios_data_area_s *)MAKE_FARPTR(SEG_BDA, 0)) @@ -156,8 +157,7 @@ init_boot_vectors() dprintf(3, "init boot device ordering\n"); // Floppy drive - struct extended_bios_data_area_s *ebda = get_ebda_ptr(); - struct ipl_entry_s *ip = &ebda->ipl.table[0]; + struct ipl_entry_s *ip = &IPL.table[0]; ip->type = IPL_TYPE_FLOPPY; ip++; @@ -171,18 +171,18 @@ init_boot_vectors() ip++; } - ebda->ipl.count = ip - ebda->ipl.table; - ebda->ipl.sequence = 0xffff; + IPL.count = ip - IPL.table; + SET_EBDA(boot_sequence, 0xffff); if (CONFIG_COREBOOT) { // XXX - hardcode defaults for coreboot. - ebda->ipl.bootorder = 0x00000231; - ebda->ipl.checkfloppysig = 1; + IPL.bootorder = 0x00000231; + IPL.checkfloppysig = 1; } else { // On emulators, get boot order from nvram. - ebda->ipl.bootorder = (inb_cmos(CMOS_BIOS_BOOTFLAG2) - | ((inb_cmos(CMOS_BIOS_BOOTFLAG1) & 0xf0) << 4)); + IPL.bootorder = (inb_cmos(CMOS_BIOS_BOOTFLAG2) + | ((inb_cmos(CMOS_BIOS_BOOTFLAG1) & 0xf0) << 4)); if (!(inb_cmos(CMOS_BIOS_BOOTFLAG1) & 1)) - ebda->ipl.checkfloppysig = 1; + IPL.checkfloppysig = 1; } } diff --git a/src/post_menu.c b/src/post_menu.c index f714668..8b6e58a 100644 --- a/src/post_menu.c +++ b/src/post_menu.c @@ -8,6 +8,7 @@ #include "biosvar.h" // GET_EBDA #include "util.h" // mdelay #include "bregs.h" // struct bregs +#include "boot.h" // IPL static int check_for_keystroke() @@ -74,7 +75,7 @@ interactive_bootmenu() printf("Select boot device:\n\n"); - int count = GET_EBDA(ipl.count); + int count = IPL.count; int i; for (i = 0; i < count; i++) { printf("%d. ", i+1); @@ -90,8 +91,8 @@ interactive_bootmenu() if (scan_code <= count + 1) { // Add user choice to the boot order. u16 choice = scan_code - 1; - u32 bootorder = GET_EBDA(ipl.bootorder); - SET_EBDA(ipl.bootorder, (bootorder << 4) | choice); + u32 bootorder = IPL.bootorder; + IPL.bootorder = (bootorder << 4) | choice; break; } } diff --git a/src/util.h b/src/util.h index 89f049a..b3d6a49 100644 --- a/src/util.h +++ b/src/util.h @@ -160,12 +160,6 @@ void mptable_init(void); // smbios.c void smbios_init(void); -// boot.c -void printf_bootdev(u16 bootdev); - -// post_menu.c -void interactive_bootmenu(); - // coreboot.c void coreboot_fill_map();