From 724a2cd70d6bc514f3715497a29213e5081d2348 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Tue, 19 Jul 2016 23:19:14 +0200 Subject: [PATCH] some code cleanups, the current version is just proof of concept --- hermit/arch/x86/loader/entry.asm | 17 ++++------------- hermit/arch/x86/loader/main.c | 2 +- 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/hermit/arch/x86/loader/entry.asm b/hermit/arch/x86/loader/entry.asm index 7d6325808..538cabbb2 100644 --- a/hermit/arch/x86/loader/entry.asm +++ b/hermit/arch/x86/loader/entry.asm @@ -201,16 +201,17 @@ L1: ; Set CR3 mov eax, boot_pml4 + or eax, (1 << 0) ; set present bit mov cr3, eax ; Set CR4 mov eax, cr4 and eax, 0xfffbf9ff ; disable SSE - or eax, (1 << 4) ; enable PSE - or eax, (1 << 7) ; enabel PGE + or eax, (1 << 7) ; enable PGE + or eax, (1 << 20) ; enable SMEP mov cr4, eax - ; Set CR0 + ; Set CR0 (PM-bit is already set) mov eax, cr0 and eax, ~(1 << 2) ; disable FPU emulation or eax, (1 << 1) ; enable FPU montitoring @@ -218,7 +219,6 @@ L1: and eax, ~(1 << 29) ; disable write through caching and eax, ~(1 << 16) ; allow kernel write access to read-only pages or eax, (1 << 31) ; enable paging - or eax, (1 << 0) ; long mode also needs PM-bit set mov cr0, eax ret @@ -247,15 +247,6 @@ start64: call main jmp $ -;global gdt_flush -;extern gp - -; This will set up our new segment registers and is declared in -; C as 'extern void gdt_flush();' -;gdt_flush: -; lgdt [gp] -; ret - SECTION .data global mb_info: diff --git a/hermit/arch/x86/loader/main.c b/hermit/arch/x86/loader/main.c index 457a8d8b1..8a9dc799b 100644 --- a/hermit/arch/x86/loader/main.c +++ b/hermit/arch/x86/loader/main.c @@ -136,9 +136,9 @@ void main(void) *((uint64_t*) (viraddr + 0x08)) = phyaddr; // physical start address *((uint32_t*) (viraddr + 0x1C)) = 0; // apicid; *((uint32_t*) (viraddr + 0x24)) = 1; // number of used cpus + *((uint32_t*) (viraddr + 0x30)) = 0; // apicid *((uint64_t*) (viraddr + 0x38)) = prog_header->file_size; *((uint32_t*) (viraddr + 0x60)) = 1; // numa nodes - *((uint32_t*) (viraddr + 0x30)) = 0; // apicid } break; case ELF_PT_GNU_STACK: // Indicates stack executability => nothing todo