bluemoon wrote:unless by 32 you meant 0x32, it does match 0x20, the selector index of ss after trim the lower ring bits.
And it will be great if you post your GDT tables so we don't have to do wild guess.
thank for your patience.
the 32 is decimal.
the GDT tables are :
Code: Select all
/* GDT selectors.*/
#define SEL_NULL 0x0
#define SEL_KERNEL_CODE 0x8
#define SEL_KERNEL_DATA 0x10
#define SEL_USER_CODE 0x18
#define SEL_USER_DATA 0x20
and i set GDT as follows:
Code: Select all
set_segment(&gdt[SEG_KERNEL_CODE], 0,0xFFFFFFFF, 0x9A, 0xCF);// kernel Code segment
set_segment(&gdt[SEG_KERNEL_DATA], 0,0xFFFFFFFF, 0x92, 0xCF);// kernel Data segment
set_segment(&gdt[SEG_USER_CODE], 0, 0xFFFFFFFF, 0xFA, 0xCF);// User mode code segment
set_segment(&gdt[SEG_USER_DATA], 0, 0xFFFFFFFF, 0xFA, 0xCF);// User mode data segment
set_segment is a function,
Code: Select all
set_segment(struct SegmentDescriptor *ptr, uint_32 base, uint_32 limit, uint_8 access, uint_8 gran)
and the 0xFA of user mode data segment means type = 1010(exec and readable), p = 1,DPL = 11.