...
This commit is contained in:
@@ -39,20 +39,17 @@ section .data
|
||||
section .data
|
||||
align 8
|
||||
multiboot_info:
|
||||
dq 0
|
||||
dd 0
|
||||
multiboot_magic:
|
||||
dd 0
|
||||
|
||||
section .text
|
||||
bits 32
|
||||
_start:
|
||||
mov esp, stack_top
|
||||
|
||||
; Multiboot will place a magic value in eax
|
||||
; If this magic value is not present, then we might not have multiboot info in ebx,
|
||||
; therefore we throw an error
|
||||
cmp eax, 0x2BADB002
|
||||
jne error
|
||||
|
||||
; Save multiboot info pointer for later
|
||||
mov [multiboot_magic], eax
|
||||
mov [multiboot_info], ebx
|
||||
|
||||
; Check if cpuid is available by flipping bit 21
|
||||
@@ -150,7 +147,8 @@ section .text
|
||||
mov ss, ax
|
||||
|
||||
; Finally, we call in to c
|
||||
mov rdi, [multiboot_info]
|
||||
mov edi, [multiboot_magic]
|
||||
mov esi, [multiboot_info]
|
||||
call entry
|
||||
.hang:
|
||||
hlt
|
||||
|
||||
@@ -6,14 +6,27 @@
|
||||
#include "multiboot.h"
|
||||
#include "util.h"
|
||||
#include "vga.h"
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void entry(multiboot_info_t* mbd)
|
||||
void entry(uint32_t magic, multiboot_info_t* info)
|
||||
{
|
||||
if (magic != 0x2BADB002)
|
||||
{
|
||||
printf("Multiboot magic does not match");
|
||||
panic();
|
||||
}
|
||||
|
||||
if (info == NULL)
|
||||
{
|
||||
printf("Multiboot info is NULL");
|
||||
panic();
|
||||
}
|
||||
|
||||
vga_clear();
|
||||
idt_init();
|
||||
remap_pic();
|
||||
map_memory(mbd);
|
||||
map_memory(info);
|
||||
enable_interrupts();
|
||||
main();
|
||||
}
|
||||
@@ -9,9 +9,9 @@ memory_map_t memory_map;
|
||||
|
||||
static memory_region_t usable_regions[USABLE_REGION_SIZE];
|
||||
|
||||
void map_memory(multiboot_info_t* mbd)
|
||||
void map_memory(multiboot_info_t* info)
|
||||
{
|
||||
if (!(mbd->flags & (1 << 6)))
|
||||
if (!(info->flags & (1 << 6)))
|
||||
{
|
||||
printf("Invalid memory map given by bootloader\n");
|
||||
panic();
|
||||
@@ -20,9 +20,9 @@ void map_memory(multiboot_info_t* mbd)
|
||||
size_t num_regions = 0;
|
||||
|
||||
uint64_t offset = 0;
|
||||
while (offset < mbd->mmap_length)
|
||||
while (offset < info->mmap_length)
|
||||
{
|
||||
multiboot_memory_map_t* mmmt = (multiboot_memory_map_t*)(mbd->mmap_addr + offset);
|
||||
multiboot_memory_map_t* mmmt = (multiboot_memory_map_t*)(info->mmap_addr + offset);
|
||||
|
||||
if (mmmt->type == MULTIBOOT_MEMORY_AVAILABLE)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user