mirror of
https://github.com/limine-bootloader/limine
synced 2024-11-23 09:02:11 +03:00
Add RSDP detection to stivale
This commit is contained in:
parent
0040b97fd1
commit
26bccc6308
20
src/lib/acpi.c
Normal file
20
src/lib/acpi.c
Normal file
@ -0,0 +1,20 @@
|
||||
#include <stddef.h>
|
||||
#include <lib/acpi.h>
|
||||
#include <lib/blib.h>
|
||||
#include <lib/libc.h>
|
||||
|
||||
void *get_rsdp(void) {
|
||||
for (size_t i = 0x80000; i < 0x100000; i += 16) {
|
||||
if (i == 0xa0000) {
|
||||
/* skip video mem and mapped hardware */
|
||||
i = 0xe0000 - 16;
|
||||
continue;
|
||||
}
|
||||
if (!strncmp((char *)i, "RSD PTR ", 8)) {
|
||||
print("acpi: Found RSDP at %x\n", i);
|
||||
return (void *)i;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
6
src/lib/acpi.h
Normal file
6
src/lib/acpi.h
Normal file
@ -0,0 +1,6 @@
|
||||
#ifndef __LIB__ACPI_H__
|
||||
#define __LIB__ACPI_H__
|
||||
|
||||
void *get_rsdp(void);
|
||||
|
||||
#endif
|
@ -3,6 +3,7 @@
|
||||
#include <protos/stivale.h>
|
||||
#include <lib/elf.h>
|
||||
#include <lib/blib.h>
|
||||
#include <lib/acpi.h>
|
||||
|
||||
struct stivale_header {
|
||||
uint64_t stack;
|
||||
@ -24,6 +25,7 @@ struct stivale_struct {
|
||||
uint16_t framebuffer_width;
|
||||
uint16_t framebuffer_height;
|
||||
uint16_t framebuffer_bpp;
|
||||
uint64_t rsdp;
|
||||
uint64_t module_count;
|
||||
struct stivale_module modules[];
|
||||
} __attribute__((packed));
|
||||
@ -54,6 +56,9 @@ void stivale_load(struct echfs_file_handle *fd) {
|
||||
|
||||
elf_load(fd, &entry_point);
|
||||
|
||||
stivale_struct.rsdp = (uint64_t)(size_t)get_rsdp();
|
||||
print("stivale: RSDP at %X\n", stivale_struct.rsdp);
|
||||
|
||||
volatile struct {
|
||||
uint64_t pml4[512];
|
||||
uint64_t pml3_lo[512];
|
||||
@ -103,9 +108,11 @@ void stivale_load(struct echfs_file_handle *fd) {
|
||||
"mov fs, ax\n\t"
|
||||
"mov gs, ax\n\t"
|
||||
"mov ss, ax\n\t"
|
||||
"mov rsp, [rsi]\n\t"
|
||||
"jmp [rbx]\n\t"
|
||||
".code32\n\t"
|
||||
:
|
||||
: "a" (pagemap), "b" (&entry_point), "S" (&stivale_struct)
|
||||
: "a" (pagemap), "b" (&entry_point),
|
||||
"D" (&stivale_struct), "S" (&stivale_hdr.stack)
|
||||
);
|
||||
}
|
||||
|
@ -3,19 +3,23 @@ ENTRY(_start)
|
||||
SECTIONS {
|
||||
. = 0xffffffff80100000;
|
||||
|
||||
.text : {
|
||||
.stivalehdr : ALIGN(4K) {
|
||||
*(.stivalehdr)
|
||||
}
|
||||
|
||||
.text : ALIGN(4K) {
|
||||
*(.text*)
|
||||
}
|
||||
|
||||
.rodata : {
|
||||
.rodata : ALIGN(4K) {
|
||||
*(.rodata*)
|
||||
}
|
||||
|
||||
.data : {
|
||||
.data : ALIGN(4K) {
|
||||
*(.data*)
|
||||
}
|
||||
|
||||
.bss : {
|
||||
.bss : ALIGN(4K) {
|
||||
*(.bss*)
|
||||
*(COMMON)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user