Use URIs in the last few remaining places, update CONFIG.md
diff --git a/CONFIG.md b/CONFIG.md
index 8c7a1397..088cd3fb 100644
--- a/CONFIG.md
+++ b/CONFIG.md
@@ -28,8 +28,7 @@ Some keys take *URIs* as values; these are described in the next section.
* `THEME_BLACK`, `THEME_RED`, `THEME_GREEN`, `THEME_BROWN`, `THEME_BLUE`, `THEME_MAGENTA`, `THEME_CYAN`, `THEME_GREY` - Specifies the colors used by the terminal (RRGGBB). Ignored if `GRAPHICS` is not `yes`.
* `THEME_MARGIN` - Set the amount of margin around the terminal. Ignored if `GRAPHICS` is not `yes`.
* `THEME_MARGIN_GRADIENT` - Set the thickness in pixel for the gradient around the terminal. Ignored if `GRAPHICS` is not `yes`.
-* `BACKGROUND_DRIVE` - Drive where to find the background .BMP file. Assume boot drive if unspecified. Ignored if `GRAPHICS` is not `yes`.
-* `BACKGROUND_PATH` - Path where to find the background .BMP file. Ignored if `GRAPHICS` is not `yes`.
+* `BACKGROUND_PATH` - URI where to find the background .BMP file. Ignored if `GRAPHICS` is not `yes`.
*Locally assignable (non protocol specific)* keys are:
* `PROTOCOL` - The boot protocol that will be used to boot the kernel. Valid protocols are: `linux`, `stivale`, `stivale2`, `chainload`.
@@ -45,7 +44,8 @@ Some keys take *URIs* as values; these are described in the next section.
* `MODULE_PATH` - The URI path to a module.
* `MODULE_STRING` - A string to be passed to a module.
* Chainload protocol:
- * `DRIVE` - The URI to a drive to chainload.
+ * `DRIVE` - The 1-based BIOS drive to chainload.
+ * `PARTITION` - The 1-based BIOS partition to chainload, if omitted, chainload drive.
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
@@ -63,4 +63,4 @@ The format for `root` changes depending on the resource used.
A resource can be one of the following:
* `bios` - The `root` takes the form of `drive:partition`; for example: `bios://3:1/...` would use BIOS drive 3, partition 1. Partitions and BIOS drives are both 1-based. Omitting the drive is possible; for example: `bios://:2/...`. Omitting the drive makes Limine use the boot drive.
-* `guid` - The `root` takes the form of a GUID/UUID, such as `736b5698-5ae1-4dff-be2c-ef8f44a61c52`. It is a filesystem GUID and not a partition GUID.
+* `guid` - The `root` takes the form of a GUID/UUID, such as `guid://736b5698-5ae1-4dff-be2c-ef8f44a61c52/...`. It is a filesystem GUID and not a partition GUID.
diff --git a/limine.bin b/limine.bin
index 4ed50dc9..3d3503ed 100644
Binary files a/limine.bin and b/limine.bin differ
diff --git a/stage2/lib/blib.c b/stage2/lib/blib.c
index ea4b0eef..dde26e21 100644
--- a/stage2/lib/blib.c
+++ b/stage2/lib/blib.c
@@ -62,13 +62,12 @@ static bool uri_bios_dispatch(struct file_handle *fd, char *loc, char *path) {
static bool uri_guid_dispatch(struct file_handle *fd, char *guid_str, char *path) {
struct guid guid;
-
if (!string_to_guid(&guid, guid_str))
- panic("Invalid GUID format");
+ return false;
int drive, partition;
if (!part_get_by_guid(&drive, &partition, &guid))
- panic("No partition found for GUID: %s", guid_str);
+ return false;
if (fopen(fd, drive, partition, path))
return false;
diff --git a/stage2/lib/part.c b/stage2/lib/part.c
index 12070ee4..bb5aa82f 100644
--- a/stage2/lib/part.c
+++ b/stage2/lib/part.c
@@ -207,12 +207,6 @@ bool part_get_by_guid(int *drive, int *part, struct guid *guid) {
for (size_t i = 0; i < part_index_i; i++) {
if (!part_index[i].guid_valid)
continue;
- print("%X %X\n",
- ((uint64_t*)&part_index[i].guid)[0],
- ((uint64_t*)&part_index[i].guid)[1]);
- print("%X %X\n",
- ((uint64_t*)guid)[0],
- ((uint64_t*)guid)[1]);
if (!memcmp(&part_index[i].guid, guid, 16)) {
*drive = part_index[i].drive;
*part = part_index[i].partition;
diff --git a/stage2/main.c b/stage2/main.c
index 6a0107ef..1200e4fd 100644
--- a/stage2/main.c
+++ b/stage2/main.c
@@ -57,7 +57,7 @@ void entry(uint8_t _boot_drive) {
init_e820();
init_memmap();
- char *cmdline = menu(boot_drive);
+ char *cmdline = menu();
char proto[32];
if (!config_get_value(proto, 0, 32, "PROTOCOL")) {
diff --git a/stage2/menu.c b/stage2/menu.c
index 1952f7d5..76e486b8 100644
--- a/stage2/menu.c
+++ b/stage2/menu.c
@@ -17,7 +17,7 @@ static char *cmdline;
static char config_entry_name[1024];
-char *menu(int boot_drive) {
+char *menu(void) {
cmdline = conv_mem_alloc(CMDLINE_MAX);
char buf[16];
@@ -91,23 +91,11 @@ char *menu(int boot_drive) {
margin_gradient = (int)strtoui(buf);
}
- int bg_drive;
- if (!config_get_value(buf, 0, 16, "BACKGROUND_DRIVE")) {
- bg_drive = boot_drive;
- } else {
- bg_drive = (int)strtoui(buf);
- }
- int bg_part;
- if (!config_get_value(buf, 0, 16, "BACKGROUND_PARTITION")) {
- goto nobg;
- } else {
- bg_part = (int)strtoui(buf);
- }
if (!config_get_value(cmdline, 0, CMDLINE_MAX, "BACKGROUND_PATH"))
goto nobg;
struct file_handle *bg_file = conv_mem_alloc(sizeof(struct file_handle));
- if (fopen(bg_file, bg_drive, bg_part, cmdline))
+ if (!uri_open(bg_file, cmdline))
goto nobg;
struct image *bg = conv_mem_alloc(sizeof(struct image));
diff --git a/stage2/menu.h b/stage2/menu.h
index b6e8c901..8d04432f 100644
--- a/stage2/menu.h
+++ b/stage2/menu.h
@@ -1,6 +1,6 @@
#ifndef __MENU_H__
#define __MENU_H__
-char *menu(int boot_drive);
+char *menu(void);
#endif
diff --git a/stage2/protos/chainload.c b/stage2/protos/chainload.c
index a5018ede..14346456 100644
--- a/stage2/protos/chainload.c
+++ b/stage2/protos/chainload.c
@@ -52,6 +52,9 @@ void chainload(void) {
if (!config_get_value(buf, 0, 32, "PARTITION")) {
part = -1;
} else {
+ if (strtoui(buf) < 1 || strtoui(buf) > 256) {
+ panic("BIOS partition number outside range 1-256");
+ }
part = (int)strtoui(buf);
}
}
@@ -60,6 +63,9 @@ void chainload(void) {
if (!config_get_value(buf, 0, 32, "DRIVE")) {
panic("DRIVE not specified");
}
+ if (strtoui(buf) < 1 || strtoui(buf) > 16) {
+ panic("BIOS drive number outside range 1-16");
+ }
drive = (int)strtoui(buf);
}
diff --git a/test/limine.cfg b/test/limine.cfg
index 05ed74c4..71a5cb9b 100644
--- a/test/limine.cfg
+++ b/test/limine.cfg
@@ -14,8 +14,7 @@ THEME_GREY=aaaaaa
THEME_MARGIN=64
-BACKGROUND_PARTITION=0
-BACKGROUND_PATH=bg.bmp
+BACKGROUND_PATH=guid://@GUID@/bg.bmp
:Stivale Test
