summaryrefslogtreecommitdiff
path: root/kernel/usermode.c
diff options
context:
space:
mode:
authorMiguel <m.i@gmx.at>2018-08-22 00:52:30 +0200
committerMiguel <m.i@gmx.at>2018-08-22 00:52:30 +0200
commit59038fc67c20a1f04e5d2fd5f9a444e707d1d3ea (patch)
tree1b0161c1b6d5caefe900f419fed31cc7d7ad6017 /kernel/usermode.c
parent72c6e9763ca61bc9d7de5f7080ee1c8a1c7c1562 (diff)
userspace and kernelspace taskswitching
Diffstat (limited to 'kernel/usermode.c')
-rw-r--r--kernel/usermode.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/kernel/usermode.c b/kernel/usermode.c
index 81dc5c1..bb614d0 100644
--- a/kernel/usermode.c
+++ b/kernel/usermode.c
@@ -15,6 +15,9 @@
//https://wiki.osdev.org/Task_State_Segment
tss_struct sys_tss; //Define the TSS as a global structure
+static volatile uint32_t c1;
+static volatile uint32_t c2;
+
void install_tss(int cpu_no){
// now fill each value
@@ -28,20 +31,28 @@ void install_tss(int cpu_no){
void userfunc()
{
+
// we need enable here again (since the pushed eflags have it disabled)!
x86_sti();
// if we are pid 0, replace ourselves with /bin/init TODO: switch to usermode before!
- if(task_get_current_pid()==0)syscall(SYSCALL_EXECVE,BIN_INIT,NULL,NULL);
+ if(task_get_current_pid()==0)
+ {
+ //usermode(&initfunc);
+ while(1)
+ {
+ c2++;
+ }
+ }
- // kernel worker thread
+ // kernel worker thread on pid1
if(task_get_current_pid()==1)
{
+ while(1)
+ {
+ c1++;
+ }
}
}
-void switch_to_user_mode()
-{
- usermode(&userfunc);
-}