misc: Change config location detection mechanism slightly
This commit is contained in:
parent
92814b4728
commit
e3519a6cfa
14
CONFIG.md
14
CONFIG.md
|
@ -1,5 +1,19 @@
|
|||
# Limine configuration file
|
||||
|
||||
## Location of the config file
|
||||
|
||||
Limine scans for a config file on *the boot drive*. Every partition on the boot drive
|
||||
is scanned sequentially (first partition first, last partition last) for the presence
|
||||
of either a `/limine.cfg` or a `/boot/limine.cfg` file, in that order.
|
||||
|
||||
Once the file is located, Limine will use it as its config file. Other possible
|
||||
candidates in subsequent partitions or directories are ignored.
|
||||
|
||||
It is thus imperative that the intended config file is placed in a location that will
|
||||
not be shadowed by another potentially candidate config file.
|
||||
|
||||
## Structure of the config file
|
||||
|
||||
The Limine configuration file is comprised of *assignments* and *entries*.
|
||||
|
||||
*Entries* describe boot *entries* which the user can select in the *boot menu*.
|
||||
|
|
12
README.md
12
README.md
|
@ -94,9 +94,12 @@ number (in decimal).
|
|||
|
||||
```bash
|
||||
fdisk <device> # Create bootloader partition using your favourite method
|
||||
limine-install <bootloader image> <path to device/image> <start sector of boot partition>
|
||||
limine-install <bootloader image> <path to device/image> <start sector of boot partition> <sector size>
|
||||
```
|
||||
|
||||
The `<sector size>` argument is optional. Use it to specify the sector size in bytes
|
||||
if it is not Limine's expected default of 512 bytes.
|
||||
|
||||
### Configuration
|
||||
Then make sure the device/image contains at least 1 partition formatted in
|
||||
a supported filesystem containing a `/limine.cfg` or `/boot/limine.cfg` file
|
||||
|
@ -123,14 +126,13 @@ echfs-utils -m -p0 test.img import path/to/kernel.elf kernel.elf
|
|||
echfs-utils -m -p0 test.img import <path to file> <path in image>
|
||||
...
|
||||
limine-install test.img
|
||||
|
||||
```
|
||||
|
||||
One can get `echfs-utils` by installing https://github.com/qword-os/echfs.
|
||||
|
||||
## Acknowledgments
|
||||
Limine uses a stripped-down version of https://github.com/jibsen/tinf
|
||||
Limine uses a stripped-down version of [tinf](https://github.com/jibsen/tinf).
|
||||
|
||||
## Discord server
|
||||
We have a Discord server if you need support, info, or you just want to
|
||||
hang out: https://discord.gg/QEeZMz4
|
||||
We have a [Discord server](https://discord.gg/QEeZMz4) if you need support, info, or
|
||||
you just want to hang out with us.
|
||||
|
|
BIN
limine-pxe.bin
BIN
limine-pxe.bin
Binary file not shown.
BIN
limine.bin
BIN
limine.bin
Binary file not shown.
|
@ -9,10 +9,6 @@
|
|||
#include <mm/pmm.h>
|
||||
#include <fs/file.h>
|
||||
|
||||
#define NO_PARTITION (-1)
|
||||
#define INVALID_TABLE (-2)
|
||||
#define END_OF_TABLE (-3)
|
||||
|
||||
struct gpt_table_header {
|
||||
// the head
|
||||
char signature[8];
|
||||
|
@ -155,7 +151,7 @@ int part_get(struct part *part, int drive, int partition) {
|
|||
if (ret != INVALID_TABLE)
|
||||
return ret;
|
||||
|
||||
return -1;
|
||||
return INVALID_TABLE;
|
||||
}
|
||||
|
||||
static struct part *part_index = NULL;
|
||||
|
|
|
@ -5,6 +5,10 @@
|
|||
#include <stdbool.h>
|
||||
#include <lib/guid.h>
|
||||
|
||||
#define NO_PARTITION (-1)
|
||||
#define INVALID_TABLE (-2)
|
||||
#define END_OF_TABLE (-3)
|
||||
|
||||
struct part {
|
||||
int drive;
|
||||
int partition;
|
||||
|
|
|
@ -46,21 +46,23 @@ void entry(uint8_t _boot_drive, int pxe_boot) {
|
|||
print("Boot drive: %x\n", boot_drive);
|
||||
// Look for config file.
|
||||
print("Searching for config file...\n");
|
||||
struct part parts[4];
|
||||
for (int i = 0; ; i++) {
|
||||
if (i == 4) {
|
||||
panic("Config file not found.");
|
||||
}
|
||||
struct part part;
|
||||
print("Checking partition %d...\n", i);
|
||||
int ret = part_get(&parts[i], boot_drive, i);
|
||||
if (ret) {
|
||||
print("Partition not found.\n");
|
||||
} else {
|
||||
print("Partition found.\n");
|
||||
if (!init_config_disk(&parts[i])) {
|
||||
print("Config file found and loaded.\n");
|
||||
break;
|
||||
}
|
||||
int ret = part_get(&part, boot_drive, i);
|
||||
switch (ret) {
|
||||
case INVALID_TABLE:
|
||||
panic("Partition table of boot drive is invalid.");
|
||||
case END_OF_TABLE:
|
||||
panic("Config file not found.");
|
||||
case NO_PARTITION:
|
||||
print("Partition not found.\n");
|
||||
continue;
|
||||
}
|
||||
print("Partition found.\n");
|
||||
if (!init_config_disk(&part)) {
|
||||
print("Config file found and loaded.\n");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue