mirror of
https://github.com/Fennix-Project/Kernel.git
synced 2025-05-25 22:14:37 +00:00
todo MB2MemoryMapper.cpp
This commit is contained in:
parent
b6f9a644a7
commit
fea5485958
@ -16,7 +16,7 @@ DetectCPUID:
|
||||
jz .NoCPUID
|
||||
ret
|
||||
.NoCPUID:
|
||||
mov word [0xb8F00], 0xF00F ; .
|
||||
; mov word [0xb8F00], 0xF00F ; .
|
||||
.Loop:
|
||||
cli
|
||||
hlt
|
||||
@ -34,7 +34,7 @@ Detect64Bit:
|
||||
jz .NoLongMode
|
||||
ret
|
||||
.NoLongMode:
|
||||
mov word [0xb8F00], 0xF00A ; .
|
||||
; mov word [0xb8F00], 0xF00A ; .
|
||||
.Loop:
|
||||
cli
|
||||
hlt
|
||||
|
@ -29,7 +29,7 @@ MB2_HeaderInfo:
|
||||
section .bootstrap.text
|
||||
MB2_start:
|
||||
cli
|
||||
mov word [0xb8F00], 0x072E ; .
|
||||
; mov word [0xb8F00], 0x072E ; .
|
||||
mov [MB2_HeaderMagic], eax
|
||||
mov [MB2_HeaderInfo], ebx
|
||||
|
||||
@ -37,7 +37,7 @@ MB2_start:
|
||||
call DetectCPUID
|
||||
call Detect64Bit
|
||||
|
||||
mov word [0xb8F02], 0x072E ; .
|
||||
; mov word [0xb8F02], 0x072E ; .
|
||||
|
||||
mov ecx, cr0
|
||||
and ecx, 0x7fffffff ; Clear PG
|
||||
@ -56,7 +56,7 @@ MB2_start:
|
||||
mov edi, BootPageTable
|
||||
mov cr3, edi
|
||||
|
||||
mov word [0xb8F04], 0x072E ; .
|
||||
; mov word [0xb8F04], 0x072E ; .
|
||||
|
||||
; Enable long mode
|
||||
mov ecx, 0xC0000080 ; EFER
|
||||
@ -84,7 +84,7 @@ MB2_start:
|
||||
[bits 64]
|
||||
HigherHalfStart:
|
||||
cli
|
||||
mov word [0xb8F06], 0x072E ; .
|
||||
; mov word [0xb8F06], 0x072E ; .
|
||||
call UpdatePageTable64
|
||||
|
||||
; Load the new page table
|
||||
@ -98,7 +98,7 @@ HigherHalfStart:
|
||||
mov gs, ax
|
||||
mov ss, ax
|
||||
|
||||
mov word [0xb8F08], 0x072E ; .
|
||||
; mov word [0xb8F08], 0x072E ; .
|
||||
mov rsp, (KernelStack + KERNEL_STACK_SIZE)
|
||||
mov rbp, (KernelStack + KERNEL_STACK_SIZE)
|
||||
|
||||
|
@ -1,3 +1,5 @@
|
||||
extern MB2_start
|
||||
|
||||
[bits 32]
|
||||
section .multiboot2
|
||||
align 4096
|
||||
@ -34,6 +36,22 @@ MB2_INFO_REQUEST_TAG_START:
|
||||
dd 21 ; Load Base Address
|
||||
MB2_INFO_REQUEST_TAG_END:
|
||||
align 8
|
||||
MB2_ENTRY_TAG:
|
||||
dw 3
|
||||
dw 0
|
||||
dd MB2_ENTRY_TAG_END - MB2_ENTRY_TAG
|
||||
dd MB2_start
|
||||
MB2_ENTRY_TAG_END:
|
||||
align 8
|
||||
MB2_FRAMEBUFFER_TAG_START:
|
||||
dw 5
|
||||
dw 1
|
||||
dd MB2_FRAMEBUFFER_TAG_END - MB2_FRAMEBUFFER_TAG_START
|
||||
dd 1280 ; Width
|
||||
dd 720 ; Height
|
||||
dd 32 ; Depth
|
||||
MB2_FRAMEBUFFER_TAG_END:
|
||||
align 8
|
||||
MB2_TAG_START:
|
||||
dw 0
|
||||
dw 0
|
||||
|
@ -259,6 +259,10 @@ __always_inline inline SafeFunction NIF void Map(void *VirtualAddress, void *Phy
|
||||
|
||||
EXTERNC __attribute__((section(".bootstrap.text"))) SafeFunction NIF __attribute__((section(".bootstrap.text"))) void UpdatePageTable64()
|
||||
{
|
||||
/*
|
||||
TODO: this code corrupts the page table
|
||||
*/
|
||||
|
||||
BPTable = (PageTable4 *)BootPageTable;
|
||||
|
||||
// for (size_t i = 0; i < 0x10000000; i += 0x1000)
|
||||
|
@ -1,7 +1,7 @@
|
||||
PAGE_TABLE_SIZE equ 0x4 ; 1GB
|
||||
PAGE_TABLE_SIZE equ 0x8 ; 2GB
|
||||
[bits 32]
|
||||
|
||||
section .bootstrap.data
|
||||
section .bootstrap.bss
|
||||
align 0x1000
|
||||
global BootPageTable
|
||||
BootPageTable:
|
||||
|
@ -4,7 +4,7 @@ OUTPUT_ARCH(i386:x86-64)
|
||||
KERNEL_LMA = 16M;
|
||||
KERNEL_VMA = 0xFFFFFFFF80000000;
|
||||
|
||||
ENTRY(MB2_start)
|
||||
ENTRY(_start)
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
|
@ -7,6 +7,8 @@
|
||||
|
||||
#include "../../kernel.h"
|
||||
|
||||
extern "C" char BootPageTable[]; // 0x10000 in length
|
||||
|
||||
namespace Memory
|
||||
{
|
||||
uint64_t Physical::GetTotalMemory()
|
||||
@ -371,8 +373,10 @@ namespace Memory
|
||||
for (uint64_t i = 0; i < Info->Memory.Entries; i++)
|
||||
if (Info->Memory.Entry[i].Type != Usable)
|
||||
this->ReservePages((void *)Info->Memory.Entry[i].BaseAddress, Info->Memory.Entry[i].Length / PAGE_SIZE + 1);
|
||||
trace("Locking bitmap pages...");
|
||||
|
||||
this->ReservePages(0, 0x100);
|
||||
this->ReservePages(BootPageTable, TO_PAGES(0x10000));
|
||||
trace("Locking bitmap pages...");
|
||||
this->LockPages(PageBitmap.Buffer, PageBitmap.Size / PAGE_SIZE + 1);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user