diff options
| author | Michal Idziorek <m.i@gmx.at> | 2015-05-15 03:19:37 +0200 |
|---|---|---|
| committer | Michal Idziorek <m.i@gmx.at> | 2015-05-15 03:19:37 +0200 |
| commit | ba10657752ba869b1c46c861cbda689b535e8214 (patch) | |
| tree | 474e971ba555ca5ca0ad1c3acbf3c2d5610b1e02 /kernel/usermode.c | |
| parent | 9b152b773d40d40abf41a46be2ddae8905170fdf (diff) | |
started implementing usermode switch
Diffstat (limited to 'kernel/usermode.c')
| -rw-r--r-- | kernel/usermode.c | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/kernel/usermode.c b/kernel/usermode.c new file mode 100644 index 0000000..afad9df --- /dev/null +++ b/kernel/usermode.c @@ -0,0 +1,32 @@ +#include "usermode.h" + + +void install_tss(int cpu_no){ + // now fill each value + // set values necessary + sys_tss.ss0 = 0x10; + // now set the IO bitmap (not necessary, so set above limit) + sys_tss.iomap = ( unsigned short ) sizeof( tss_struct ); +} + +void switch_to_user_mode() { + // Set up a stack structure for switching to user mode. + asm volatile(" \ + cli; \ + mov $0x23, %ax; \ + mov %ax, %ds; \ + mov %ax, %es; \ + mov %ax, %fs; \ + mov %ax, %gs; \ + \ + mov %esp, %eax; \ + pushl $0x23; \ + pushl %eax; \ + pushf; \ + mov $0x200, %eax; \ + push %eax; \ + pushl $0x1B; \ + push $1f; \ + iret; \ 1: \ + "); +} |
