diff options
author | Kartik Agaram <vc@akkartik.com> | 2019-09-27 15:45:23 -0700 |
---|---|---|
committer | Kartik Agaram <vc@akkartik.com> | 2019-09-27 15:45:23 -0700 |
commit | 8ccd1cfbcfe7cca692caadf0803790e8322b2398 (patch) | |
tree | 449e7d0ae05b1511db308e176c542ac5c6ee96ba | |
parent | 6d367fd7642edafdaa81df9fabaa4a924b5e60f3 (diff) | |
download | mu-8ccd1cfbcfe7cca692caadf0803790e8322b2398.tar.gz |
5692 - attempt at never leaving kernel mode
Doesn't work. Kernel gets kicked back to the Grub prompt(!)
-rw-r--r-- | kernel.soso/process.c | 23 | ||||
-rw-r--r-- | kernel.soso/process.h | 3 |
2 files changed, 15 insertions, 11 deletions
diff --git a/kernel.soso/process.c b/kernel.soso/process.c index 7964467b..e1088bd8 100644 --- a/kernel.soso/process.c +++ b/kernel.soso/process.c @@ -547,7 +547,7 @@ BOOL isProcessValid(Process* process) { return FALSE; } -static void switchToTask(Thread* current); +static void switchToTask(Thread* current, int mode); static void updateMetrics(Thread* thread) { uint32 seconds = getUptimeSeconds(); @@ -657,10 +657,20 @@ void schedule(TimerInt_Registers* registers) { */ updateMetrics(current); - switchToTask(current); + + if (current->regs.cs != 0x08) { + switchToTask(current, USERMODE); + } + else { + switchToTask(current, KERNELMODE); + } } -static void switchToTask(Thread* current) { + + +//The mode indicates whether this process was in user mode or kernel mode +//When it was previously interrupted by the scheduler. +static void switchToTask(Thread* current, int mode) { uint32 kesp, eflags; uint16 kss, ss, cs; @@ -672,14 +682,11 @@ static void switchToTask(Thread* current) { cs = current->regs.cs; eflags = (current->regs.eflags | 0x200) & 0xFFFFBFFF; - int oldMode; - if (cs != 0x08) { - oldMode = USERMODE; + if (mode == USERMODE) { kss = current->kstack.ss0; kesp = current->kstack.esp0; } else { - oldMode = KERNELMODE; kss = current->regs.ss; kesp = current->regs.esp; } @@ -708,6 +715,6 @@ static void switchToTask(Thread* current) { "m"(current->regs.eip), \ "m"(current), \ [KMODE] "i"(KERNELMODE), \ - [mode] "g"(oldMode) + [mode] "g"(mode) ); } diff --git a/kernel.soso/process.h b/kernel.soso/process.h index a2979714..ab4e3615 100644 --- a/kernel.soso/process.h +++ b/kernel.soso/process.h @@ -1,9 +1,6 @@ #ifndef PROCESS_H #define PROCESS_H -#define KERNELMODE 0 -#define USERMODE 1 - #define MAX_OPENED_FILES 20 #include "common.h" |