Use URIs in the last few remaining places, update CONFIG.md

This commit is contained in:
mintsuki 2020-11-01 22:07:10 +01:00
parent bacef9fcce
commit 0319b51b4b
9 changed files with 17 additions and 31 deletions

View File

@ -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.

Binary file not shown.

View File

@ -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;

View File

@ -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;

View File

@ -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")) {

View File

@ -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));

View File

@ -1,6 +1,6 @@
#ifndef __MENU_H__
#define __MENU_H__
char *menu(int boot_drive);
char *menu(void);
#endif

View File

@ -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);
}

View File

@ -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