summaryrefslogtreecommitdiff
path: root/kernel/usermode.c
blob: afad9df8952ddf07d971a2ba03f8a6929fd45cfe (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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: \
    "); 
}