Changed the build system for 64-bit quite a bit.

The kernel is now compiled 100% as 64-bit code and converted to ELF32.
This commit is contained in:
Jonas 'Sortie' Termansen 2011-12-01 23:05:08 +01:00
parent 8e8bb15a1b
commit f8129a17b2
4 changed files with 12 additions and 22 deletions

View File

@ -102,17 +102,11 @@ sortix-x86-js.tmp: $(OBJS)
# x64 compilation
x64/boot.o: x64/boot.s
as -32 $< -o $@
as -64 $< -o $@
sortix-x64.tmp: $(OBJS) x64/boot.o
ld -N -melf_x86_64 -Ttext 110000 -o sortix-x64-internal.out $(OBJS)
objcopy -O binary sortix-x64-internal.out sortix-x64-internal.tmp
objcopy --add-section kernel64=sortix-x64-internal.tmp \
--set-section-flag kernel64=alloc,data,load,contents \
$(CPU)/boot.o
ld -melf_i386 -Ttext 100000 $(CPU)/boot.o -o $@
# move section to 0x11000
objcopy --change-section-address kernel64=1114112 $@
ld -N -melf_x86_64 -Ttext 100000 -o sortix-x64-internal.out x64/boot.o $(OBJS)
objcopy sortix-x64-internal.out -O elf32-i386 sortix-x64.tmp
# x86 compilation

View File

@ -56,8 +56,8 @@ using namespace Maxsi;
void* RunApplication(void* Parameter);
extern "C" size_t stack[4096] = {0};
extern "C" size_t stackend = 0;
extern "C" { size_t stack[64*1024] = {0}; }
extern "C" { size_t stackend = 0; }
namespace Sortix
{

View File

@ -28,12 +28,9 @@
.section .text
.text 0x110000
.type _beginkernel, @function
beginkernel:
_beginkernel:
start:
_start:
movw $0x736, 0xB83E8
movw $0x734, 0xB83EA
movw $0x753, 0xB83EE
@ -44,8 +41,7 @@ _start:
movw $0x758, 0xB83F8
# Initialize the stack pointer.
# TODO: This is very hacky!
movq $0x110000, %rsp
movq $stackend, %rsp
# Reset EFLAGS.
# pushl $0

View File

@ -77,14 +77,15 @@ multiboot_entry:
movl $0x3207, (%edi)
addl $0x1000, %edi
# Page-Directory
movl $0x4207, (%edi)
# Page-Directory (no user-space access here)
movl $0x4203, (%edi) # (First 2 MiB)
movl $0x5203, 8(%edi) # (Second 2 MiB)
addl $0x1000, %edi
# Page-Table
# Memory map the first 2 MiB.
# Memory map the first 4 MiB.
movl $0x3, %ebx
movl $512, %ecx
movl $1024, %ecx
SetEntry:
mov %ebx, (%edi)
@ -177,6 +178,5 @@ Main:
# Load the magic value.
mov 0x100004, %eax
# The linker is kindly asked to put the real 64-bit kernel at 0x110000.
jmp 0x110000
jmp beginkernel