Add support for chainloading another bootsector
diff --git a/CONFIG.md b/CONFIG.md
index 609dc6f9..d8b67969 100644
--- a/CONFIG.md
+++ b/CONFIG.md
@@ -42,9 +42,9 @@ Some *local assignments* are shared between entries using any *protocol*, while
* `MODULE_PARTITION` - Partition index of a module.
* `MODULE_PATH` - The path to a module.
* `MODULE_STRING` - A string to be passed to a module.
-* chainload protocol:
- * `DRIVE` - The drive to chainload.
- * `PARTITION` - The partition to chainload.
+* Chainload protocol:
+ * `DRIVE` - The BIOS drive (in decimal) to chainload.
+ * `PARTITION` - The partition index (in decimal) to chainload (if omitted, chainload the drive's bootsector).
Note that one can define these 3 variable multiple times to specify multiple modules.
The entries will be matched in order. E.g.: the 1st partition entry will be matched
diff --git a/qloader2.bin b/qloader2.bin
index bea3051e..332003e9 100644
Binary files a/qloader2.bin and b/qloader2.bin differ
diff --git a/src/protos/chainload.c b/src/protos/chainload.c
index fef3bf1e..09311c3a 100644
--- a/src/protos/chainload.c
+++ b/src/protos/chainload.c
@@ -11,9 +11,10 @@ void chainload(void) {
int part; {
char buf[32];
if (!config_get_value(buf, 0, 32, "PARTITION")) {
- panic("PARTITION not specified");
+ part = -1;
+ } else {
+ part = (int)strtoui(buf);
}
- part = (int)strtoui(buf);
}
int drive; {
char buf[32];
@@ -25,10 +26,14 @@ void chainload(void) {
deinit_vga_textmode();
- struct part p;
- get_part(&p, drive, part);
+ if (part != -1) {
+ struct part p;
+ get_part(&p, drive, part);
- read_partition(drive, &p, (void*)0x7c00, 0, 512);
+ read_partition(drive, &p, (void *)0x7c00, 0, 512);
+ } else {
+ read(drive, (void *)0x7c00, 0, 512);
+ }
asm volatile (
// Jump to real mode
