mirror of
https://github.com/limine-bootloader/limine
synced 2024-12-11 09:14:38 +03:00
Fix broken memory types in stivale
This commit is contained in:
parent
6296d27c11
commit
a002f05110
BIN
qloader2.bin
BIN
qloader2.bin
Binary file not shown.
@ -271,7 +271,7 @@ int elf32_load_section(struct file_handle *fd, void *buffer, const char *name, s
|
|||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
int elf64_load(struct file_handle *fd, uint64_t *entry_point, uint64_t *top, uint64_t slide) {
|
int elf64_load(struct file_handle *fd, uint64_t *entry_point, uint64_t *top, uint64_t slide, uint32_t alloc_type) {
|
||||||
struct elf64_hdr hdr;
|
struct elf64_hdr hdr;
|
||||||
fread(fd, &hdr, 0, sizeof(struct elf64_hdr));
|
fread(fd, &hdr, 0, sizeof(struct elf64_hdr));
|
||||||
|
|
||||||
@ -312,7 +312,7 @@ int elf64_load(struct file_handle *fd, uint64_t *entry_point, uint64_t *top, uin
|
|||||||
if (this_top > *top)
|
if (this_top > *top)
|
||||||
*top = this_top;
|
*top = this_top;
|
||||||
|
|
||||||
memmap_alloc_range((size_t)load_vaddr, (size_t)phdr.p_memsz);
|
memmap_alloc_range((size_t)load_vaddr, (size_t)phdr.p_memsz, alloc_type);
|
||||||
|
|
||||||
fread(fd, (void *)(uint32_t)load_vaddr, phdr.p_offset, phdr.p_filesz);
|
fread(fd, (void *)(uint32_t)load_vaddr, phdr.p_offset, phdr.p_filesz);
|
||||||
|
|
||||||
@ -335,7 +335,7 @@ int elf64_load(struct file_handle *fd, uint64_t *entry_point, uint64_t *top, uin
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int elf32_load(struct file_handle *fd, uint32_t *entry_point, uint32_t *top) {
|
int elf32_load(struct file_handle *fd, uint32_t *entry_point, uint32_t *top, uint32_t alloc_type) {
|
||||||
struct elf32_hdr hdr;
|
struct elf32_hdr hdr;
|
||||||
fread(fd, &hdr, 0, sizeof(struct elf32_hdr));
|
fread(fd, &hdr, 0, sizeof(struct elf32_hdr));
|
||||||
|
|
||||||
@ -368,7 +368,7 @@ int elf32_load(struct file_handle *fd, uint32_t *entry_point, uint32_t *top) {
|
|||||||
if (this_top > *top)
|
if (this_top > *top)
|
||||||
*top = this_top;
|
*top = this_top;
|
||||||
|
|
||||||
memmap_alloc_range((size_t)phdr.p_paddr, (size_t)phdr.p_memsz);
|
memmap_alloc_range((size_t)phdr.p_paddr, (size_t)phdr.p_memsz, alloc_type);
|
||||||
|
|
||||||
fread(fd, (void *)phdr.p_paddr, phdr.p_offset, phdr.p_filesz);
|
fread(fd, (void *)phdr.p_paddr, phdr.p_offset, phdr.p_filesz);
|
||||||
|
|
||||||
|
@ -8,10 +8,10 @@
|
|||||||
|
|
||||||
int elf_bits(struct file_handle *fd);
|
int elf_bits(struct file_handle *fd);
|
||||||
|
|
||||||
int elf64_load(struct file_handle *fd, uint64_t *entry_point, uint64_t *top, uint64_t slide);
|
int elf64_load(struct file_handle *fd, uint64_t *entry_point, uint64_t *top, uint64_t slide, uint32_t alloc_type);
|
||||||
int elf64_load_section(struct file_handle *fd, void *buffer, const char *name, size_t limit, uint64_t slide);
|
int elf64_load_section(struct file_handle *fd, void *buffer, const char *name, size_t limit, uint64_t slide);
|
||||||
|
|
||||||
int elf32_load(struct file_handle *fd, uint32_t *entry_point, uint32_t *top);
|
int elf32_load(struct file_handle *fd, uint32_t *entry_point, uint32_t *top, uint32_t alloc_type);
|
||||||
int elf32_load_section(struct file_handle *fd, void *buffer, const char *name, size_t limit);
|
int elf32_load_section(struct file_handle *fd, void *buffer, const char *name, size_t limit);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -165,7 +165,7 @@ void init_memmap(void) {
|
|||||||
sanitise_entries();
|
sanitise_entries();
|
||||||
}
|
}
|
||||||
|
|
||||||
void memmap_alloc_range(uint64_t base, uint64_t length) {
|
void memmap_alloc_range(uint64_t base, uint64_t length, uint32_t type) {
|
||||||
uint64_t top = base + length;
|
uint64_t top = base + length;
|
||||||
|
|
||||||
for (size_t i = 0; i < memmap_entries; i++) {
|
for (size_t i = 0; i < memmap_entries; i++) {
|
||||||
@ -206,7 +206,7 @@ void memmap_alloc_range(uint64_t base, uint64_t length) {
|
|||||||
}
|
}
|
||||||
target = &memmap[memmap_entries++];
|
target = &memmap[memmap_entries++];
|
||||||
|
|
||||||
target->type = MEMMAP_KERNEL_AND_MODULES;
|
target->type = type;
|
||||||
target->base = base;
|
target->base = base;
|
||||||
target->length = length;
|
target->length = length;
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
#include <lib/e820.h>
|
#include <lib/e820.h>
|
||||||
|
|
||||||
void init_memmap(void);
|
void init_memmap(void);
|
||||||
void memmap_alloc_range(uint64_t base, uint64_t length);
|
void memmap_alloc_range(uint64_t base, uint64_t length, uint32_t type);
|
||||||
struct e820_entry_t *get_memmap(size_t *entries);
|
struct e820_entry_t *get_memmap(size_t *entries);
|
||||||
void print_memmap(struct e820_entry_t *mm, size_t size);
|
void print_memmap(struct e820_entry_t *mm, size_t size);
|
||||||
|
|
||||||
|
@ -103,7 +103,7 @@ void linux_load(char *cmdline, int boot_drive) {
|
|||||||
|
|
||||||
// load kernel
|
// load kernel
|
||||||
print("Loading kernel...\n");
|
print("Loading kernel...\n");
|
||||||
memmap_alloc_range(KERNEL_LOAD_ADDR, fd->size - real_mode_code_size);
|
memmap_alloc_range(KERNEL_LOAD_ADDR, fd->size - real_mode_code_size, 0);
|
||||||
fread(fd, (void *)KERNEL_LOAD_ADDR, real_mode_code_size, fd->size - real_mode_code_size);
|
fread(fd, (void *)KERNEL_LOAD_ADDR, real_mode_code_size, fd->size - real_mode_code_size);
|
||||||
|
|
||||||
char initrd_path[64];
|
char initrd_path[64];
|
||||||
@ -125,7 +125,7 @@ void linux_load(char *cmdline, int boot_drive) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
print("Loading initrd...\n");
|
print("Loading initrd...\n");
|
||||||
memmap_alloc_range(INITRD_LOAD_ADDR, initrd.size);
|
memmap_alloc_range(INITRD_LOAD_ADDR, initrd.size, 0);
|
||||||
fread(&initrd, (void *)INITRD_LOAD_ADDR, 0, initrd.size);
|
fread(&initrd, (void *)INITRD_LOAD_ADDR, 0, initrd.size);
|
||||||
|
|
||||||
*((uint32_t *)(real_mode_code + 0x218)) = (uint32_t)INITRD_LOAD_ADDR;
|
*((uint32_t *)(real_mode_code + 0x218)) = (uint32_t)INITRD_LOAD_ADDR;
|
||||||
|
@ -145,10 +145,10 @@ void stivale_load(char *cmdline, int boot_drive) {
|
|||||||
|
|
||||||
switch (bits) {
|
switch (bits) {
|
||||||
case 64:
|
case 64:
|
||||||
elf64_load(fd, &entry_point, &top_used_addr, slide);
|
elf64_load(fd, &entry_point, &top_used_addr, slide, 10);
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
elf32_load(fd, (uint32_t *)&entry_point, (uint32_t *)&top_used_addr);
|
elf32_load(fd, (uint32_t *)&entry_point, (uint32_t *)&top_used_addr, 10);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -192,7 +192,7 @@ void stivale_load(char *cmdline, int boot_drive) {
|
|||||||
((uint32_t)top_used_addr & ~((uint32_t)0xfff)) + 0x1000 :
|
((uint32_t)top_used_addr & ~((uint32_t)0xfff)) + 0x1000 :
|
||||||
(uint32_t)top_used_addr);
|
(uint32_t)top_used_addr);
|
||||||
|
|
||||||
memmap_alloc_range((size_t)module_addr, f.size);
|
memmap_alloc_range((size_t)module_addr, f.size, 10);
|
||||||
fread(&f, module_addr, 0, f.size);
|
fread(&f, module_addr, 0, f.size);
|
||||||
|
|
||||||
m->begin = (uint64_t)(size_t)module_addr;
|
m->begin = (uint64_t)(size_t)module_addr;
|
||||||
|
@ -232,10 +232,10 @@ void stivale2_load(char *cmdline, int boot_drive) {
|
|||||||
|
|
||||||
switch (bits) {
|
switch (bits) {
|
||||||
case 64:
|
case 64:
|
||||||
elf64_load(fd, &entry_point, &top_used_addr, slide);
|
elf64_load(fd, &entry_point, &top_used_addr, slide, 0x1001);
|
||||||
break;
|
break;
|
||||||
case 32:
|
case 32:
|
||||||
elf32_load(fd, (uint32_t *)&entry_point, (uint32_t *)&top_used_addr);
|
elf32_load(fd, (uint32_t *)&entry_point, (uint32_t *)&top_used_addr, 0x1001);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -301,7 +301,7 @@ void stivale2_load(char *cmdline, int boot_drive) {
|
|||||||
((uint32_t)top_used_addr & ~((uint32_t)0xfff)) + 0x1000 :
|
((uint32_t)top_used_addr & ~((uint32_t)0xfff)) + 0x1000 :
|
||||||
(uint32_t)top_used_addr);
|
(uint32_t)top_used_addr);
|
||||||
|
|
||||||
memmap_alloc_range((size_t)module_addr, f.size);
|
memmap_alloc_range((size_t)module_addr, f.size, 0x1001);
|
||||||
fread(&f, module_addr, 0, f.size);
|
fread(&f, module_addr, 0, f.size);
|
||||||
|
|
||||||
m->begin = (uint64_t)(size_t)module_addr;
|
m->begin = (uint64_t)(size_t)module_addr;
|
||||||
@ -310,10 +310,10 @@ void stivale2_load(char *cmdline, int boot_drive) {
|
|||||||
top_used_addr = (uint64_t)(size_t)m->end;
|
top_used_addr = (uint64_t)(size_t)m->end;
|
||||||
|
|
||||||
print("stivale2: Requested module %u:\n", i);
|
print("stivale2: Requested module %u:\n", i);
|
||||||
print(" Path: %s\n", module_file);
|
print(" Path: %s\n", module_file);
|
||||||
print(" String: %s\n", m->string);
|
print(" String: %s\n", m->string);
|
||||||
print(" Begin: %X\n", m->begin);
|
print(" Begin: %X\n", m->begin);
|
||||||
print(" End: %X\n", m->end);
|
print(" End: %X\n", m->end);
|
||||||
}
|
}
|
||||||
|
|
||||||
append_tag(&stivale2_struct, (struct stivale2_tag *)tag);
|
append_tag(&stivale2_struct, (struct stivale2_tag *)tag);
|
||||||
|
Loading…
Reference in New Issue
Block a user