Trying my best.

alentours-dev
q3k 2012-05-18 16:14:51 +02:00
parent 8e640f27ff
commit 085ae2df79
3 changed files with 20 additions and 14 deletions

View File

@ -1,7 +1,7 @@
OUTPUT_FORMAT(elf64-x86-64)
ENTRY(kmain)
KERNEL_VMA = 0x0000800000000000;
KERNEL_VMA = 0xffffffff80000000;
SECTIONS
{

View File

@ -33,7 +33,6 @@ extern u64 omg64;
extern u64 _end;
extern u64 _start;
u64 pJmpLoadAddres = 0;
void outb(u16 Port, u8 Data)
{
@ -316,6 +315,8 @@ u32 create_ia32e_paging(u64 KernelPhysicalStart, u64 KernelVirtualStart, u64 Ker
u64 g_multiboot_header;
T_LOAD_CONTEXT g_Context;
extern u64 GDT;
extern u32 ldrEntryLow;
extern u32 ldrEntryHigh;
u32 load(void *Multiboot, unsigned int Magic)
{
@ -446,11 +447,6 @@ u32 load(void *Multiboot, unsigned int Magic)
ContinuityTest = VirtualAddress + Sections[i].Size;
Size += Sections[i].Size;
// inline strcmp, fuck yeah!
if (Name[0] == '.' && Name[1] == 't' && Name[2] == 'e' && Name[3] == 'x' && Name[4] == 't' && Name[5] == 0)
{
pJmpLoadAddres += VirtualAddress;
}
puts("-> Section ");
puts(Name);
puts(", 0x");
@ -513,10 +509,8 @@ u32 load(void *Multiboot, unsigned int Magic)
g_Context.VGACurrentLine = stdio_current_line;
g_Context.VGACursorX = stdio_cur_x;
g_Context.VGACursorY = stdio_cur_y;
pJmpLoadAddres += Header->Entry;
puts("Will be jumping to 0x");
print_hex(pJmpLoadAddres);
puts(".\n");
for (;;) {}
ldrEntryLow = Header->Entry & 0xFFFFFFFF;
ldrEntryHigh = Header->Entry >> 32;
return 1;
}

View File

@ -1,9 +1,12 @@
extern load
extern puts
extern print_hex
extern g_Context;
global _loader
global omg64
global GDT
global ldrEntryLow
global ldrEntryHigh
; Multiboot-related constants
MODULEALIGN equ 1 << 0
@ -42,6 +45,11 @@ GDT:
db 0xFF, 0xFF, 0, 0, 0, 10011010b, 10101111b, 0x00 ; 64-bit code segment (0x18)
db 0xFF, 0xFF, 0, 0, 0, 10010010b, 10101111b, 0x00 ; 64-bit data segment (0x20)
ldrEntryLow:
dd 0
ldrEntryHigh:
dd 0
str_back_in_asm:
db "Back in assembler!", 0
@ -71,8 +79,12 @@ _loader_gdt:
test eax, eax
jz hang
push ecx
push ebx
mov eax, [ldrEntryHigh]
push eax
mov eax, [ldrEntryLow]
push eax
call print_hex
mov ax, 0x20
mov ds, ax