/* This is similar with the one in start.S. However the previous one * cannot be accessed in user process, because its virtual address is * below 0xC0000000, and is not in the user process' address space. */ void init_segment(void) { memset(gdt, 0, sizeof(gdt)); set_segment(&gdt[SEG_KERNEL_CODE], DPL_KERNEL, SEG_EXECUTABLE | SEG_READABLE); set_segment(&gdt[SEG_KERNEL_DATA], DPL_KERNEL, SEG_WRITABLE ); write_gdtr(gdt, sizeof(gdt)); }
void init_segment(void) { memset(gdt, 0, sizeof(gdt)); set_segment(&gdt[SEG_KERNEL_CODE], DPL_KERNEL, SEG_EXECUTABLE | SEG_READABLE); set_segment(&gdt[SEG_KERNEL_DATA], DPL_KERNEL, SEG_WRITABLE ); set_segment(&gdt[SEG_USER_CODE], DPL_USER, SEG_EXECUTABLE | SEG_READABLE); set_segment(&gdt[SEG_USER_DATA], DPL_USER, SEG_WRITABLE ); write_gdtr(gdt, sizeof(gdt)); set_tss(&gdt[SEG_TSS]); write_tr( SELECTOR_USER(SEG_TSS) ); }