1 ; AcessOS Microkernel Version
6 KERNEL_BASE equ 0xC0000000
8 KSTACK_USERSTATE_SIZE equ (4+8+1+5)*4 ; SRegs, GPRegs, CPU, IRET
14 [extern Proc_Scheduler]
15 [global SchedulerBase]
29 mov eax, [esp+12*4] ; CPU Number
30 push eax ; Pus as argument
34 add esp, 4 ; Remove Argument
46 ; No Error code / int num
53 ; Call Proc_Clone with Flags=0
58 add esp, 8 ; Remove arguments from stack
63 ; In child, so now set up stack frame
64 mov ebx, [esp+4] ; Child Function
65 mov edx, [esp+8] ; Argument
69 call Threads_Exit ; Kill Thread
75 ; Calls a user fault handler
77 [global Proc_ReturnToUser]
78 [extern Proc_GetCurThread]
80 ; EBP is the handler to use
82 call Proc_GetCurThread
84 ; EAX is the current thread
86 mov eax, [ebx+40] ; Get Kernel Stack
87 sub eax, KSTACK_USERSTATE_SIZE
90 ; NOTE: This can cause corruption if the signal happens while the user
91 ; has called a kernel operation.
92 ; Good thing this can only be called on a user fault.
95 ; Get and alter User SP
96 mov ecx, [eax+KSTACK_USERSTATE_SIZE-12]
97 mov edx, [ebx+60] ; Get Signal Number
99 mov [ecx-8], DWORD User_Syscall_RetAndExit
102 ; Restore Segment Registers
111 push 0x202 ; EFLAGS (IP and Rsvd)
119 User_Syscall_RetAndExit:
121 call User_Syscall_Exit