Plug in e820 driver
This commit is contained in:
parent
f537f64b89
commit
1cbd6fb2e9
@ -21,10 +21,11 @@ static const char *e820_type(uint32_t type) {
|
||||
}
|
||||
}
|
||||
|
||||
void init_e820(void) {
|
||||
int init_e820(void) {
|
||||
struct rm_regs r = {0};
|
||||
|
||||
for (size_t i = 0; i < E820_MAX_ENTRIES; i++) {
|
||||
int entry_count;
|
||||
for (int i = 0; i < E820_MAX_ENTRIES; i++) {
|
||||
r.eax = 0xe820;
|
||||
r.ecx = 24;
|
||||
r.edx = 0x534d4150;
|
||||
@ -32,24 +33,27 @@ void init_e820(void) {
|
||||
rm_int(0x15, &r, &r);
|
||||
|
||||
if (r.eflags & EFLAGS_CF) {
|
||||
e820_map[i].type = 0;
|
||||
entry_count = i;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (!r.ebx) {
|
||||
e820_map[i+1].type = 0;
|
||||
entry_count = ++i;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
print("e820: Too many entries!\n");
|
||||
for (;;);
|
||||
|
||||
done:
|
||||
for (size_t i = 0; e820_map[i].type; i++) {
|
||||
for (int i = 0; i < entry_count; i++) {
|
||||
print("e820: [%X -> %X] : %X <%s>\n",
|
||||
e820_map[i].base,
|
||||
e820_map[i].base + e820_map[i].length,
|
||||
e820_map[i].length,
|
||||
e820_type(e820_map[i].type));
|
||||
}
|
||||
|
||||
return entry_count;
|
||||
}
|
||||
|
@ -14,6 +14,6 @@ struct e820_entry_t {
|
||||
|
||||
extern struct e820_entry_t e820_map[E820_MAX_ENTRIES];
|
||||
|
||||
void init_e820(void);
|
||||
int init_e820(void);
|
||||
|
||||
#endif
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <lib/elf.h>
|
||||
#include <lib/blib.h>
|
||||
#include <lib/acpi.h>
|
||||
#include <lib/e820.h>
|
||||
#include <drivers/vbe.h>
|
||||
|
||||
struct stivale_header {
|
||||
@ -59,6 +60,9 @@ void stivale_load(struct echfs_file_handle *fd) {
|
||||
|
||||
elf_load(fd, &entry_point);
|
||||
|
||||
stivale_struct.memory_map_entries = (uint64_t)init_e820();
|
||||
stivale_struct.memory_map_addr = (uint64_t)(size_t)e820_map;
|
||||
|
||||
stivale_struct.rsdp = (uint64_t)(size_t)get_rsdp();
|
||||
print("stivale: RSDP at %X\n", stivale_struct.rsdp);
|
||||
|
||||
|
@ -24,7 +24,8 @@ _start:
|
||||
mov rax, 'h e l l '
|
||||
mov rbx, 'o w o '
|
||||
mov rcx, 'r l d '
|
||||
mov [0xb8000], rax
|
||||
mov [0xb8008], rbx
|
||||
mov [0xb8010], rcx
|
||||
mov rdx, [rdi+20]
|
||||
mov [rdx], rax
|
||||
mov [rdx+8], rbx
|
||||
mov [rdx+16], rcx
|
||||
jmp $
|
||||
|
Loading…
Reference in New Issue
Block a user