X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=Kernel%2Farch%2Fx86_64%2Fstart64.asm;h=04bac26918e35e35576286b5a622b1dcca5a91ce;hb=4bc68df387ca7de4a0616d779509e5ebc05d0de4;hp=30fc9717b12309e9bbeaffb5e8a79d5b585a0787;hpb=1810e1d377b996679ae090bfe57d1b5321ce190f;p=tpg%2Facess2.git diff --git a/Kernel/arch/x86_64/start64.asm b/Kernel/arch/x86_64/start64.asm index 30fc9717..04bac269 100644 --- a/Kernel/arch/x86_64/start64.asm +++ b/Kernel/arch/x86_64/start64.asm @@ -2,13 +2,46 @@ ; Acess2 x86_64 Port ; [bits 64] +KERNEL_BASE equ 0xFFFF800000000000 + +[extern kmain] + +[extern gMultibootPtr] +[extern gMultibootMagic] [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 + mov rsp, gInitialKernelStack + ; Call main - jmp $ + mov edi, [gMultibootMagic - KERNEL_BASE] + mov esi, [gMultibootPtr - KERNEL_BASE] + call kmain + + cli +.hlt: + hlt + jmp .hlt [global GetRIP] GetRIP: @@ -63,6 +96,26 @@ Proc_ReturnToUser: iret +; int CallWithArgArray(void *Ptr, int NArgs, Uint *Args) +; Call a function passing the array as arguments +[global CallWithArgArray] +CallWithArgArray: + push rbp + mov rbp, rsp + mov rcx, [rbp+3*8] ; Get NArgs + mov rdx, [rbp+4*8] + +.top: + mov rax, [rdx+rcx*8-8] + push rax + loop .top + + mov rax, [rbp+2*8] + call rax + lea rsp, [rbp] + pop rbp + ret + [section .usertext] User_Syscall_RetAndExit: mov rdi, rax @@ -74,6 +127,6 @@ User_Syscall_Exit: [section .bss] [global gInitialKernelStack] - resd 1024*1 ; 1 Page + resd 1024*4 ; 4 Pages gInitialKernelStack: