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;
|
||||
}
|
||||
|
||||
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;
|
||||
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)
|
||||
*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);
|
||||
|
||||
@ -335,7 +335,7 @@ int elf64_load(struct file_handle *fd, uint64_t *entry_point, uint64_t *top, uin
|
||||
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;
|
||||
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)
|
||||
*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);
|
||||
|
||||
|
@ -8,10 +8,10 @@
|
||||
|
||||
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 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);
|
||||
|
||||
#endif
|
||||
|
@ -165,7 +165,7 @@ void init_memmap(void) {
|
||||
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;
|
||||
|
||||
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->type = MEMMAP_KERNEL_AND_MODULES;
|
||||
target->type = type;
|
||||
target->base = base;
|
||||
target->length = length;
|
||||
|
||||
|
@ -5,7 +5,7 @@
|
||||
#include <lib/e820.h>
|
||||
|
||||
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);
|
||||
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
|
||||
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);
|
||||
|
||||
char initrd_path[64];
|
||||
@ -125,7 +125,7 @@ void linux_load(char *cmdline, int boot_drive) {
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
*((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) {
|
||||
case 64:
|
||||
elf64_load(fd, &entry_point, &top_used_addr, slide);
|
||||
elf64_load(fd, &entry_point, &top_used_addr, slide, 10);
|
||||
break;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
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);
|
||||
|
||||
m->begin = (uint64_t)(size_t)module_addr;
|
||||
|
@ -232,10 +232,10 @@ void stivale2_load(char *cmdline, int boot_drive) {
|
||||
|
||||
switch (bits) {
|
||||
case 64:
|
||||
elf64_load(fd, &entry_point, &top_used_addr, slide);
|
||||
elf64_load(fd, &entry_point, &top_used_addr, slide, 0x1001);
|
||||
break;
|
||||
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;
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
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);
|
||||
|
||||
m->begin = (uint64_t)(size_t)module_addr;
|
||||
|
Loading…
Reference in New Issue
Block a user