limine: Add support for base protocol revisions

This commit is contained in:
mintsuki 2023-11-01 18:35:14 +01:00
parent ee9405b04d
commit 01e9ba6755
2 changed files with 22 additions and 0 deletions

View File

@ -342,6 +342,25 @@ noreturn void limine_load(char *config, char *cmdline) {
kaslr = kaslr && is_reloc; kaslr = kaslr && is_reloc;
// Determine base revision
LIMINE_BASE_REVISION_1
int base_revision = 0;
for (size_t i = 0; i < ALIGN_DOWN(image_size_before_bss, 8); i += 8) {
void *p = (void *)(uintptr_t)physical_base + i;
int new_revision = 0;
if (memcmp(p, (void *)&limine_base_revision_1, 16) == 0) {
new_revision = 1;
}
if (new_revision != 0) {
if (base_revision != 0) {
panic(true, "limine: Duplicated base revision tag");
}
base_revision = new_revision;
}
}
// Load requests // Load requests
if (elf64_load_section(kernel, &requests, ".limine_reqs", 0, slide)) { if (elf64_load_section(kernel, &requests, ".limine_reqs", 0, slide)) {
for (size_t i = 0; ; i++) { for (size_t i = 0; ; i++) {

View File

@ -44,6 +44,9 @@ extern "C" {
# define LIMINE_DEPRECATED_IGNORE_END # define LIMINE_DEPRECATED_IGNORE_END
#endif #endif
#define LIMINE_BASE_REVISION_1 \
volatile uint64_t limine_base_revision_1[2] = { 0xf9562b2d5c95a6c8, 0x6a7b384944536bdc };
#define LIMINE_COMMON_MAGIC 0xc7b1dd30df4c8b88, 0x0a82e883a194f07b #define LIMINE_COMMON_MAGIC 0xc7b1dd30df4c8b88, 0x0a82e883a194f07b
struct limine_uuid { struct limine_uuid {