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
Kernel - Reworked x86 physical memory allocation
[tpg/acess2.git]
/
Kernel
/
arch
/
x86
/
proc.asm
diff --git
a/Kernel/arch/x86/proc.asm
b/Kernel/arch/x86/proc.asm
index
fd372db
..
944b24d
100644
(file)
--- a/
Kernel/arch/x86/proc.asm
+++ b/
Kernel/arch/x86/proc.asm
@@
-74,6
+74,10
@@
SchedulerBase:
push fs
push gs
push fs
push gs
+ pushf
+ and BYTE [esp+1], 0xFE ; Clear Trap Flag
+ popf
+
mov eax, dr0
push eax ; Debug Register 0, Current Thread
mov eax, dr0
push eax ; Debug Register 0, Current Thread
@@
-92,8
+96,10
@@
SchedulerBase:
%endif
call Proc_Scheduler
%endif
call Proc_Scheduler
+[global scheduler_return]
+scheduler_return: ; Used by some hackery in Proc_DumpThreadCPUState
- add esp, 4 ; Remove
Argument
+ add esp, 4 ; Remove
CPU Number (thread is poped later)
%if USE_MP
test ebx, ebx
%if USE_MP
test ebx, ebx
@@
-119,7
+125,7
@@
SchedulerBase:
pop ds
popa
pop ds
popa
- add esp, 4
; CPU ID
+ add esp, 4
*2 ; CPU ID + Dummy error code
; No Error code / int num
iret
; No Error code / int num
iret
@@
-140,9
+146,10
@@
SpawnTask:
; In child, so now set up stack frame
mov ebx, [esp+4] ; Child Function
mov edx, [esp+8] ; Argument
; In child, so now set up stack frame
mov ebx, [esp+4] ; Child Function
mov edx, [esp+8] ; Argument
- ; Child
+ ; Child
Function
push edx ; Argument
call ebx ; Function
push edx ; Argument
call ebx ; Function
+ ; Kill thread once done
push eax ; Exit Code
push 0 ; Kill this thread
call Threads_Exit ; Kill Thread
push eax ; Exit Code
push 0 ; Kill this thread
call Threads_Exit ; Kill Thread
@@
-158,14
+165,16
@@
SpawnTask:
Proc_ReturnToUser:
push ebp
mov ebp, esp
Proc_ReturnToUser:
push ebp
mov ebp, esp
- ; [EBP+4]: handler to use
- ; [EBP+8]: parameter
+ ; [EBP+8]: handler to use
+ ; [EBP+12]: parameter
+ ; [EBP+16]: kernel stack top
- call Proc_GetCurThread
+
;
call Proc_GetCurThread
; EAX is the current thread
; EAX is the current thread
- mov ebx, eax
- mov eax, [ebx+12*4] ; Get Kernel Stack
+ ;mov ebx, eax
+ ;mov eax, [ebx+12*4] ; Get Kernel Stack
+ mov eax, [ebp+16] ; Get Kernel Stack
sub eax, KSTACK_USERSTATE_SIZE
;
sub eax, KSTACK_USERSTATE_SIZE
;
@@
-208,7
+217,7
@@
Proc_ReturnToUser:
; Get and alter User SP
mov edi, edx
; Get and alter User SP
mov edi, edx
- mov edx, [ebp+
8]
; Get parameter
+ mov edx, [ebp+
12]
; Get parameter
mov [edi+4], edx ; save to user stack
mov [edi], DWORD User_Syscall_RetAndExit ; Return Address
mov [edi+4], edx ; save to user stack
mov [edi], DWORD User_Syscall_RetAndExit ; Return Address
@@
-223,7
+232,7
@@
Proc_ReturnToUser:
push edi ; ESP
push 0x202 ; EFLAGS (IP and Rsvd)
push 0x1B ; CS
push edi ; ESP
push 0x202 ; EFLAGS (IP and Rsvd)
push 0x1B ; CS
- mov eax, [ebp+
4
] ; Method to call
+ mov eax, [ebp+
8
] ; Method to call
push eax ; EIP
iret
push eax ; EIP
iret
@@
-233,7
+242,7
@@
Proc_ReturnToUser:
.justKillIt:
xor eax, eax
xor ebx, ebx
.justKillIt:
xor eax, eax
xor ebx, ebx
- dec ebx
+ dec ebx
; EBX = -1
int 0xAC
[global GetCPUNum]
int 0xAC
[global GetCPUNum]
@@
-245,6
+254,15
@@
GetCPUNum: ; TODO: Store in debug registers
mov eax, dr1
ret
mov eax, dr1
ret
+[extern GetEIP]
+[global GetEIP_Sched]
+[global GetEIP_Sched_ret]
+GetEIP_Sched_ret equ GetEIP_Sched.ret
+GetEIP_Sched:
+ call GetEIP
+GetEIP_Sched.ret:
+ ret
+
; Usermode code exported by the kernel
[section .usertext]
; Export a place for the user to jump to to call a syscall
; Usermode code exported by the kernel
[section .usertext]
; Export a place for the user to jump to to call a syscall
UCC
git Repository :: git.ucc.asn.au