1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

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 compilation
x64/boot.o: x64/boot.s x64/boot.o: x64/boot.s
as -32 $< -o $@ as -64 $< -o $@
sortix-x64.tmp: $(OBJS) x64/boot.o sortix-x64.tmp: $(OBJS) x64/boot.o
ld -N -melf_x86_64 -Ttext 110000 -o sortix-x64-internal.out $(OBJS) ld -N -melf_x86_64 -Ttext 100000 -o sortix-x64-internal.out x64/boot.o $(OBJS)
objcopy -O binary sortix-x64-internal.out sortix-x64-internal.tmp objcopy sortix-x64-internal.out -O elf32-i386 sortix-x64.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 $@
# x86 compilation # x86 compilation

View file

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

View file

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

View file

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