#include "cmos.h" // CMOS_*
#include "util.h" // memset
#include "biosvar.h" // struct bios_data_area_s
-#include "ata.h"
-#include "kbd.h"
+#include "ata.h" // ata_detect
+#include "kbd.h" // kbd_setup
+#include "disk.h" // floppy_drive_setup
-#define bda ((struct bios_data_area_s *)0)
-#define ebda ((struct extended_bios_data_area_s *)(EBDA_SEG<<4))
-#define ipl ((struct ipl_s *)(IPL_SEG<<4))
-
-static u8
-checksum(u8 *p, u32 len)
-{
- u32 i;
- u8 sum = 0;
- for (i=0; i<len; i++)
- sum += p[i];
- return sum;
-}
+#define bda ((struct bios_data_area_s *)MAKE_FARPTR(SEG_BDA, 0))
+#define ebda ((struct extended_bios_data_area_s *)MAKE_FARPTR(SEG_EBDA, 0))
static void
init_bda()
SET_BDA(ivecs[0x74].offset, OFFSET_entry_74);
SET_BDA(ivecs[0x75].offset, OFFSET_entry_75);
SET_BDA(ivecs[0x10].offset, OFFSET_entry_10);
+
+ SET_BDA(ivecs[0x1E].offset, OFFSET_diskette_param_table2);
}
static void
{
memset(ebda, 0, sizeof(*ebda));
ebda->size = EBDA_SIZE;
- SET_BDA(ebda_seg, EBDA_SEG);
- SET_BDA(ivecs[0x41].seg, EBDA_SEG);
+ SET_BDA(ebda_seg, SEG_EBDA);
+ SET_BDA(ivecs[0x41].seg, SEG_EBDA);
SET_BDA(ivecs[0x41].offset
, offsetof(struct extended_bios_data_area_s, fdpt0));
- SET_BDA(ivecs[0x46].seg, EBDA_SEG);
+ SET_BDA(ivecs[0x46].seg, SEG_EBDA);
SET_BDA(ivecs[0x41].offset
, offsetof(struct extended_bios_data_area_s, fdpt1));
}
outb(0x9f, PORT_PIC2_DATA);
}
-static void
-floppy_drive_post()
-{
- u8 type = inb_cmos(CMOS_FLOPPY_DRIVE_TYPE);
- u8 out = 0;
- if (type & 0xf0)
- out |= 0x07;
- if (type & 0x0f)
- out |= 0x70;
- SET_BDA(floppy_harddisk_info, out);
- outb(0x02, PORT_DMA1_MASK_REG);
-
- SET_BDA(ivecs[0x1E].offset, OFFSET_diskette_param_table2);
-}
-
static void
ata_init()
{
}
info->cylinders = cyl;
info->heads = heads;
- info->checksum = ~checksum((u8*)info, sizeof(*info)-1) + 1;
+ info->checksum = -checksum((u8*)info, sizeof(*info)-1);
}
static void
hard_drive_post()
{
- outb(0x0a, 0x03f6); // 0000 1010 = reserved, disable IRQ 14
+ outb(0x0a, PORT_HD_DATA); // 0000 1010 = reserved, disable IRQ 14
SET_BDA(disk_count, 1);
SET_BDA(disk_control_byte, 0xc0);
if ((diskinfo & 0x0f) == 0x0f)
// XXX - bochs halts on any other type
// Fill EBDA table for hard disk 1.
- fill_hdinfo(&ebda->fdpt0, CMOS_DISK_DRIVE2_TYPE, CMOS_DISK_DRIVE2_CYL);
+ fill_hdinfo(&ebda->fdpt1, CMOS_DISK_DRIVE2_TYPE, CMOS_DISK_DRIVE2_CYL);
}
-
static void
init_boot_vectors()
{
- // Clear out the IPL table.
- memset(ipl, 0, sizeof(*ipl));
-
// Floppy drive
- struct ipl_entry_s *ip = &ipl->table[0];
+ struct ipl_entry_s *ip = &ebda->ipl.table[0];
ip->type = IPL_TYPE_FLOPPY;
ip++;
ip++;
}
- ipl->count = ip - ipl->table;
- ipl->sequence = 0xffff;
+ ebda->ipl.count = ip - ebda->ipl.table;
+ ebda->ipl.sequence = 0xffff;
+ ebda->ipl.bootfirst = 0xffff;
}
static void
if (checksum(rom, len) != 0)
continue;
p = (u8*)(((u32)p + len) / 2048 * 2048);
- callrom(PTR_TO_SEG(rom), PTR_TO_OFFSET(rom + 3));
+ callrom(FARPTR_TO_SEG(rom), FARPTR_TO_OFFSET(rom + 3));
// Look at the ROM's PnP Expansion header. Properly, we're supposed
// to init all the ROMs and then go back and build an IPL table of
// Found a device that thinks it can boot the system. Record
// its BEV and product name string.
- if (ipl->count >= ARRAY_SIZE(ipl->table))
+ if (ebda->ipl.count >= ARRAY_SIZE(ebda->ipl.table))
continue;
- struct ipl_entry_s *ip = &ipl->table[ipl->count];
+ struct ipl_entry_s *ip = &ebda->ipl.table[ebda->ipl.count];
ip->type = IPL_TYPE_BEV;
- ip->vector = (PTR_TO_SEG(rom) << 16) | entry;
+ ip->vector = (FARPTR_TO_SEG(rom) << 16) | entry;
u16 desc = *(u16*)&rom[0x1a+0x10];
if (desc)
- ip->description = (PTR_TO_SEG(rom) << 16) | desc;
+ ip->description = (u32)MAKE_FARPTR(FARPTR_TO_SEG(rom), desc);
- ipl->count++;
+ ebda->ipl.count++;
}
}
rombios32_init();
- init_boot_vectors();
-
- floppy_drive_post();
+ floppy_drive_setup();
hard_drive_post();
if (CONFIG_ATA) {
ata_init();
rom_scan(0xc8000, 0xe0000);
+ interactive_bootmenu();
+
// reset the memory (some boot loaders such as syslinux suppose
// that the memory is set to zero)
memset((void*)0x40000, 0, 0x40000); // XXX - shouldn't use globals