File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33
44#include <stdint.h>
55
6+ #define KERNEL_DATA_SEG 0x10
7+ #define USER_CODE_SEG 0x1B
8+ #define USER_DATA_SEG 0x23
9+ #define TSS_SEGMENT_SELECTOR (5 << 3)
10+
611struct tss_entry {
712 uint32_t prev_tss ; // The previous TSS - with hardware task switching this is used
813 uint32_t esp0 ; // The stack pointer to load when we change to kernel mode
Original file line number Diff line number Diff line change @@ -191,13 +191,13 @@ void user_init(void) {
191191 uint32_t esp0 = 0 ;
192192 asm volatile ("mov %%esp, %0" : "=r" (esp0 ));
193193 tss .esp0 = esp0 ;
194- tss .ss0 = 0x10 ;
195- tss .cs = 0x1B ;
196- tss .ds = 0x23 ;
197- tss .es = 0x23 ;
198- tss .fs = 0x23 ;
199- tss .gs = 0x23 ;
200- tss .ss = 0x23 ;
194+ tss .ss0 = KERNEL_DATA_SEG ;
195+ tss .cs = USER_CODE_SEG ;
196+ tss .ds = USER_DATA_SEG ;
197+ tss .es = USER_DATA_SEG ;
198+ tss .fs = USER_DATA_SEG ;
199+ tss .gs = USER_DATA_SEG ;
200+ tss .ss = USER_DATA_SEG ;
201201 asm volatile ("ltr %%ax" : : "a" (5 << 3 ));
202202
203203 jmp_ring3 (p1 .sp , p1 .ip );
You can’t perform that action at this time.
0 commit comments