[bits 32]
extern kernel_main
%include "assym.asm"
start:
mov ax, 0x10
mov ss, ax
mov esp, 0x200000 ; this gives us 2MiB - kernel_size of stack
call kernel_main
.hang:
hlt
jmp .hang
%define USER_CS 0x1b
%define USER_DS 0x23
global proc_switch
proc_switch:
mov ebp, [esp + 4] ; struct proc*
mov eax, PROC_PD(ebp)
mov cr3, eax
mov ebp, PROC_PCB(ebp)
mov ax, USER_DS
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
push byte USER_DS ; SS
mov eax, PCB_ESP(ebp) ; ESP
push eax
mov eax, PCB_EFL(ebp) ; EFL
push eax
push byte USER_CS ; CS
mov eax, PCB_EIP(ebp) ; EIP
push eax
mov eax, PCB_EAX(ebp)
mov ebx, PCB_EBX(ebp)
mov ecx, PCB_ECX(ebp)
mov edx, PCB_EDX(ebp)
mov ebp, PCB_EBP(ebp)
iret