Add new option for targetting a coreboot payload.
When in coreboot mode, configure out those parts of the code that wont
work on real hardware.
Don't include cmos.h in files that don't need it.
static void
out_str(const char *str_cs)
{
+ if (CONFIG_COREBOOT) {
+ BX_INFO("APM request '%s'\n", str_cs);
+ return;
+ }
+
u8 *s = (u8*)str_cs;
for (;;) {
u8 c = GET_VAR(CS, *s);
static u8
get_translation(int driveid)
{
- u8 channel = driveid / 2;
- u8 translation = inb_cmos(CMOS_BIOS_DISKTRANSFLAG + channel/2);
- translation >>= 2 * (driveid % 4);
- translation &= 0x03;
- return translation;
+ if (! CONFIG_COREBOOT) {
+ // Emulators pass in the translation info via nvram.
+ u8 channel = driveid / 2;
+ u8 translation = inb_cmos(CMOS_BIOS_DISKTRANSFLAG + channel/2);
+ translation >>= 2 * (driveid % 4);
+ translation &= 0x03;
+ return translation;
+ }
+
+ // On COREBOOT, use a heuristic to determine translation type.
+ u16 heads = GET_EBDA(ata.devices[driveid].pchs.heads);
+ u16 cylinders = GET_EBDA(ata.devices[driveid].pchs.cylinders);
+ u16 spt = GET_EBDA(ata.devices[driveid].pchs.spt);
+
+ if (cylinders <= 1024 && heads <= 16 && spt <= 63)
+ return ATA_TRANSLATION_NONE;
+ if (cylinders * heads <= 131072)
+ return ATA_TRANSLATION_LARGE;
+ return ATA_TRANSLATION_LBA;
}
static void
#define CONFIG_APPNAME "Bochs"
#endif
+// Configure as a payload coreboot payload.
+#define CONFIG_COREBOOT 0
+
#define CONFIG_DEBUG_SERIAL 0
#define CONFIG_FLOPPY_SUPPORT 1
#include "disk.h" // floppy_13
#include "biosvar.h" // struct bregs
#include "config.h" // CONFIG_*
-#include "cmos.h" // inb_cmos
#include "util.h" // debug_enter
#include "ata.h" // ATA_*
static void
ram_probe(void)
{
- u32 rs = (inb_cmos(CMOS_MEM_EXTMEM2_LOW)
+ u32 rs;
+ if (CONFIG_COREBOOT) {
+ // XXX - just hardcode for now.
+ rs = 128*1024*1024;
+ } else {
+ // On emulators, get memory size from nvram.
+ rs = (inb_cmos(CMOS_MEM_EXTMEM2_LOW)
| (inb_cmos(CMOS_MEM_EXTMEM2_HIGH) << 8)) * 65536;
- if (rs)
- rs += 16 * 1024 * 1024;
- else
- rs = ((inb_cmos(CMOS_MEM_EXTMEM_LOW)
- | (inb_cmos(CMOS_MEM_EXTMEM_HIGH) << 8)) * 1024
- + 1 * 1024 * 1024);
+ if (rs)
+ rs += 16 * 1024 * 1024;
+ else
+ rs = ((inb_cmos(CMOS_MEM_EXTMEM_LOW)
+ | (inb_cmos(CMOS_MEM_EXTMEM_HIGH) << 8)) * 1024
+ + 1 * 1024 * 1024);
+ }
SET_EBDA(ram_size, rs);
BX_INFO("ram_size=0x%08x\n", rs);
ebda->ipl.count = ip - ebda->ipl.table;
ebda->ipl.sequence = 0xffff;
- ebda->ipl.bootorder = (inb_cmos(CMOS_BIOS_BOOTFLAG2)
- | ((inb_cmos(CMOS_BIOS_BOOTFLAG1) & 0xf0) << 4));
- if (!(inb_cmos(CMOS_BIOS_BOOTFLAG1) & 1))
+ if (CONFIG_COREBOOT) {
+ // XXX - hardcode defaults for coreboot.
+ ebda->ipl.bootorder = 0x00000231;
ebda->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));
+ if (!(inb_cmos(CMOS_BIOS_BOOTFLAG1) & 1))
+ ebda->ipl.checkfloppysig = 1;
+ }
}
static void
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
#include "util.h" // BX_INFO
-#include "cmos.h" // inb_cmos
#include "pci.h" // PCIDevice
#include "types.h" // u32
#include "config.h" // CONFIG_*
void rombios32_init(void)
{
+ if (CONFIG_COREBOOT)
+ // XXX - not supported on coreboot yet.
+ return;
+
BX_INFO("Starting rombios32\n");
#if (CONFIG_USE_EBDA_TABLES == 1)
#include "util.h" // irq_restore
#include "biosvar.h" // BIOS_CONFIG_TABLE
#include "ioport.h" // inb
-#include "cmos.h" // inb_cmos
#define E820_RAM 1
#define E820_RESERVED 2