I just began to work on my task switching code which resides in the time interrupt, and got stuck for quite a while...
Here is the code:
00004a6d: ( ): push ds ; 1e
00004a6e: ( ): push es ; 06
00004a6f: ( ): push fs ; 0fa0
00004a71: ( ): push gs ; 0fa8
00004a73: ( ): pop gs ; 0fa9
00004a75: ( ): pop fs ; 0fa1
00004a77: ( ): pop es ; 07
00004a78: ( ): pop ds ; 1f
00004a79: ( ): iretd ; cf
When execution comes to the red line, bochs says:
"00051416079e[CPU0 ] load_seg_reg(GS, 0x0017): invalid segment"
The value 0x17 was initialized in a piece of code which I copied from the Linux 0.11 kernel in order to jump to ring 3:
Code: Select all
__asm__ ("movl %%esp,%%eax\n\t" \
"pushl $0x17\n\t" \
"pushl %%eax\n\t" \
"pushfl \n\t" \
"pushl $0xf\n\t" \
"pushl $1f\n\t" \
"iret\n" \
"1:\tmovl $0x17,%%eax\n\t" \
"movw %%ax,%%ds\n\t" \
"movw %%ax,%%es\n\t" \
"movw %%ax,%%fs\n\t" \
"movw %%ax,%%gs" \
:::"ax");
Thanks.