From ed8e7b962b65a97630d125f8a5cac9661039e809 Mon Sep 17 00:00:00 2001 From: mintsuki Date: Wed, 13 May 2020 18:13:17 +0200 Subject: [PATCH] Add support for chainloading another bootsector --- CONFIG.md | 6 +++--- qloader2.bin | Bin 32768 -> 32768 bytes src/protos/chainload.c | 15 ++++++++++----- 3 files changed, 13 insertions(+), 8 deletions(-) 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 bea3051eabddac745e987afe6479a46348a122d1..332003e997f9306fffaff8fc5b83f64f109b6633 100644 GIT binary patch delta 4620 zcma)Adt6ji9=~Upk&)L7;UJ;N$W!nIzLBR2N?OYuMhApYbB)h!EVpzfYFA=%pbys( zGLMzpT8X2dWqaC=ChBer!iVvZhH0s#g=TedTtAqK=Iie7cke*$<{vws&zw2u`+Gmm z?_O{?R1Sw~N1!^i`y|ITgw~&d)zD3csGnT44G?=sX3Q4&)z$9gIL?`kT%0}9WU}f7 z&d71Bcm&6}5p{OxoA6iM-*!t~DH>iwtXo&<-iY8S@h9E3{pz-EwR;nu4V&pV>R7U# z-cyfA-VBH|8F9(3broFDecZtdj~)W;VKKlfJ0MQpMrUbel5YBv=2`Lry{j>kjnp(K zmi&!A1M6=33arQIN3b$_Y|vN10f#xxr!^Jx!UXzp;8wDbF4U$Hk=AM#2KIujwT2dY zK|3<11@pSx#qm!w!rN&^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vvIfEAZ3#4*AaMAEwv0R4qe5gGxI*wumBjuNO5J98c$l6jDn zX62NwWVv$uYxEKlbDo+oT!NMljOHJ)nvg@=lJIyEL2ah5riI8tRX}P|H=xOG}VZ=h0PD~(r&(?|i z0z)3c8*2c(^*sgOX!s8IEHsYvjpj3q(QXoMg_C zS31`cO2=7BJj2ZOzGM&mdDcW_3%pb;rZ;Bwp;Kp%^11daT{U|?{A1wa?B&XFaJ*WH iwWJ`Dt}h7d*ZpT7bc6I~q96R?UhvcxOo*XX#Q#5t5ZR*u 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