Add support for chainloading another bootsector

This commit is contained in:
mintsuki 2020-05-13 18:13:17 +02:00
parent 85a4106691
commit ed8e7b962b
3 changed files with 13 additions and 8 deletions

View File

@ -42,9 +42,9 @@ Some *local assignments* are shared between entries using any *protocol*, while
* `MODULE_PARTITION` - Partition index of a module. * `MODULE_PARTITION` - Partition index of a module.
* `MODULE_PATH` - The path to a module. * `MODULE_PATH` - The path to a module.
* `MODULE_STRING` - A string to be passed to a module. * `MODULE_STRING` - A string to be passed to a module.
* chainload protocol: * Chainload protocol:
* `DRIVE` - The drive to chainload. * `DRIVE` - The BIOS drive (in decimal) to chainload.
* `PARTITION` - The partition 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. 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 The entries will be matched in order. E.g.: the 1st partition entry will be matched

Binary file not shown.

View File

@ -11,9 +11,10 @@ void chainload(void) {
int part; { int part; {
char buf[32]; char buf[32];
if (!config_get_value(buf, 0, 32, "PARTITION")) { 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; { int drive; {
char buf[32]; char buf[32];
@ -25,10 +26,14 @@ void chainload(void) {
deinit_vga_textmode(); deinit_vga_textmode();
struct part p; if (part != -1) {
get_part(&p, drive, part); 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 ( asm volatile (
// Jump to real mode // Jump to real mode