diff --git a/src/boot.c b/src/boot.c index 1effd80..2e6e356 100644 --- a/src/boot.c +++ b/src/boot.c @@ -802,7 +802,7 @@ static int HaveHDBoot, HaveFDBoot; static void add_bev(int type, u32 vector) {
- if (type == IPL_TYPE_HARDDISK && HaveHDBoot++)
- if (type == IPL_TYPE_HARDDISK && HaveHDBoot++ && !CONFIG_DYNAMIC_MAP_HD) return; if (type == IPL_TYPE_FLOPPY && HaveFDBoot++) return;
@@ -837,8 +837,14 @@ bcv_prepboot(void) add_bev(IPL_TYPE_FLOPPY, 0); break; case IPL_TYPE_HARDDISK:
map_hd_drive(pos->drive);
add_bev(IPL_TYPE_HARDDISK, 0);
if (CONFIG_DYNAMIC_MAP_HD) {
// Pass the drive_s pointer to bev_s struct so that
// we can do dynamic hard disk map in do_boot().
add_bev(IPL_TYPE_HARDDISK, (u32)pos->drive);
} else {
map_hd_drive(pos->drive);
add_bev(IPL_TYPE_HARDDISK, 0);
} break; case IPL_TYPE_CDROM: map_cd_drive(pos->drive);
@@ -998,6 +1004,8 @@ do_boot(int seq_nr) break; case IPL_TYPE_HARDDISK: printf("Booting from Hard Disk...\n");
if (CONFIG_DYNAMIC_MAP_HD)
map_hd_drive((struct drive_s *)ie->vector); boot_disk(0x80, 1);
This is not valid. Once we start the boot phase (via INT19), it's not valid to change the hard drive mappings. Once we invoke INT19, it's possible for external code to alter memory - including any temporary storage that SeaBIOS allocated during the post phase. Indeed, on normal QEMU the memory holding the active drives is marked as read-only after the POST phase. Also, external code can invoke the SeaBIOS int19 handler multiple times.
In accordance with the "BIOS Boot Specification", SeaBIOS does all its setup in the POST phase, and then just starts the boot process in the "BOOT phase".
Essentially the map_hd_drive() function only touches struct drive_s{} and its parent container, IDMap[], BEV[] and BDA. The first one is typically malloc_high()ed, the last three are static/BSS. So if external code alters memory it will not affect map_hd_drive(). With that said, the dynamic hd map and the original static hd map don't have any difference, except that dynamic map can support more hard drives. Also the new code is gated by a configuration option CONFIG_DYNAMIC_MAP_HD and it's disabled by default, so it won't break the BBS spec. Would you consider this as an experiment feature?
-Kevin