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/arm7 - Fiddling with PCI etc
[tpg/acess2.git]
/
Kernel
/
arch
/
x86
/
proc.asm
diff --git
a/Kernel/arch/x86/proc.asm
b/Kernel/arch/x86/proc.asm
index
a07bdad
..
5a9ad0a
100644
(file)
--- a/
Kernel/arch/x86/proc.asm
+++ b/
Kernel/arch/x86/proc.asm
@@
-8,6
+8,26
@@
KERNEL_BASE equ 0xC0000000
KSTACK_USERSTATE_SIZE equ (4+8+1+5)*4 ; SRegs, GPRegs, CPU, IRET
[section .text]
KSTACK_USERSTATE_SIZE equ (4+8+1+5)*4 ; SRegs, GPRegs, CPU, IRET
[section .text]
+
+[global NewTaskHeader]
+NewTaskHeader:
+ mov eax, [esp]
+ mov dr0, eax
+ xchg bx, bx
+
+ sti
+ ; TODO: SMP
+ mov al, 0x20
+ out 0x20, al
+
+ mov eax, [esp+4]
+ add esp, 12 ; Thread, Function, Args
+ call eax
+
+ push eax ; Ret val
+ push 0 ; 0 = This Thread
+ call Threads_Exit
+
%if USE_MP
[extern giMP_TimerCount]
[extern gpMP_LocalAPIC]
%if USE_MP
[extern giMP_TimerCount]
[extern gpMP_LocalAPIC]
@@
-74,6
+94,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
+116,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
+145,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
@@
-129,7
+155,7
@@
SchedulerBase:
SpawnTask:
; Call Proc_Clone with Flags=0
xor eax, eax
SpawnTask:
; Call Proc_Clone with Flags=0
xor eax, eax
-
push eax
+
;
push eax
push eax
call Proc_Clone
add esp, 8 ; Remove arguments from stack
push eax
call Proc_Clone
add esp, 8 ; Remove arguments from stack
@@
-140,9
+166,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
@@
-179,14
+206,10
@@
Proc_ReturnToUser:
; Validate user ESP
; - Page Table
mov edx, [eax+KSTACK_USERSTATE_SIZE-12] ; User ESP is at top of kstack - 3*4
; Validate user ESP
; - Page Table
mov edx, [eax+KSTACK_USERSTATE_SIZE-12] ; User ESP is at top of kstack - 3*4
- %if USE_PAE
- %error PAE Support
- %else
mov ecx, edx
shr ecx, 22
test BYTE [0xFC3F0000+ecx*4], 1
jnz .justKillIt
mov ecx, edx
shr ecx, 22
test BYTE [0xFC3F0000+ecx*4], 1
jnz .justKillIt
- %endif
; - Page
mov ecx, edx
shr ecx, 12
; - Page
mov ecx, edx
shr ecx, 12
@@
-195,13
+218,10
@@
Proc_ReturnToUser:
; Adjust
sub edx, 8
; - Page Table
; Adjust
sub edx, 8
; - Page Table
- %if USE_PAE
- %else
mov ecx, edx
shr ecx, 22
test BYTE [0xFC3F0000+ecx*4], 1
jnz .justKillIt
mov ecx, edx
shr ecx, 22
test BYTE [0xFC3F0000+ecx*4], 1
jnz .justKillIt
- %endif
; - Page
mov ecx, edx
shr ecx, 12
; - Page
mov ecx, edx
shr ecx, 12
@@
-235,7
+255,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]
@@
-247,6
+267,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