git.ucc.asn.au
/
tpg
/
acess2.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Cleaning up and attempting to fix these darn heisenbugs
[tpg/acess2.git]
/
Kernel
/
arch
/
x86_64
/
start64.asm
diff --git
a/Kernel/arch/x86_64/start64.asm
b/Kernel/arch/x86_64/start64.asm
index
a2ffb19
..
7617d6a
100644
(file)
--- a/
Kernel/arch/x86_64/start64.asm
+++ b/
Kernel/arch/x86_64/start64.asm
@@
-2,13
+2,47
@@
; Acess2 x86_64 Port
;
[bits 64]
; Acess2 x86_64 Port
;
[bits 64]
+;KERNEL_BASE equ 0xFFFF800000000000
+KERNEL_BASE equ 0xFFFFFFFF80000000
+
+[extern kmain]
+
+[extern gMultibootPtr]
+[extern gMultibootMagic]
[section .text]
[global start64]
start64:
[section .text]
[global start64]
start64:
+ ; Load Registers
+ mov ax, 0x10
+ mov ds, ax
+ mov es, ax
+ mov fs, ax
+ mov gs, ax
+
+ ; Go to high memory
+ mov rax, start64.himem
+ jmp rax
+.himem:
+
+ ; Clear the screen
+ mov rax, 0x1F201F201F201F20 ; Set the screen to White on blue, space (4 characters)
+ mov edi, 0xB8000
+ mov ecx, 80*25*2/8
+ rep stosq
+
; Set kernel stack
; Set kernel stack
+ mov rsp, gInitialKernelStack
+
; Call main
; Call main
- jmp $
+ mov edi, [gMultibootMagic - KERNEL_BASE]
+ mov esi, [gMultibootPtr - KERNEL_BASE]
+ call kmain
+
+ cli
+.hlt:
+ hlt
+ jmp .hlt
[global GetRIP]
GetRIP:
[global GetRIP]
GetRIP:
@@
-17,10
+51,10
@@
GetRIP:
[global GetCPUNum]
GetCPUNum:
[global GetCPUNum]
GetCPUNum:
- str ax
- mov gs, ax
xor rax, rax
xor rax, rax
- mov al, [gs:104] ; End of TSS
+ str ax
+ sub ax, 0x38 ; TSS Base
+ shr ax, 4 ; One 16-byte TSS per CPU
ret
KSTACK_USERSTATE_SIZE equ (16+1+5)*8 ; GPRegs, CPU, IRET
ret
KSTACK_USERSTATE_SIZE equ (16+1+5)*8 ; GPRegs, CPU, IRET
@@
-94,6
+128,6
@@
User_Syscall_Exit:
[section .bss]
[global gInitialKernelStack]
[section .bss]
[global gInitialKernelStack]
- resd 1024*
1 ; 1 Page
+ resd 1024*
4 ; 4 Pages
gInitialKernelStack:
gInitialKernelStack:
UCC
git Repository :: git.ucc.asn.au