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.
97 mov edx, [eax+KSTACK_USERSTATE_SIZE-12] ; User ESP is at top of kstack - 3*4
103 test BYTE [0xFC3F0000+ecx*4], 1
109 test BYTE [0xFC000000+ecx*4], 1
118 test BYTE [0xFC3F0000+ecx*4], 1
124 test BYTE [0xFC000000+ecx*4], 1
127 ; Get and alter User SP
129 mov edx, [ebx+60] ; Get Signal Number from TCB
130 mov [ecx+4], edx ; Parameter (Signal/Error Number)
131 mov [ecx], DWORD User_Syscall_RetAndExit ; Return Address
133 ; Restore Segment Registers
142 push 0x202 ; EFLAGS (IP and Rsvd)
148 ; Just kill the bleeding thing
149 ; (I know it calls int 0xAC in kernel mode, but meh)
164 ; Usermode code exported by the kernel
166 User_Syscall_RetAndExit:
168 call User_Syscall_Exit