Page 1 of 1

SS Selector

Posted: Wed Jul 03, 2002 11:00 pm
by Brill
Hi, i've got a stack segment in the gdt, i think its right. I now need to make a segment selector for the stack in the ss register. So, i've done that but i still get tripple faults. So i want to make sure im making the selector properly.

Firstly, selector index of 1 will infact goto the second entry in the gdt. The first entry 0 is the empty descriptor?

and the rest of the index should be 0. So, 0...01 would be correct and consume 13 bits, 12 with zero and 1 with 1. The remaining three need to be 0 for the gdt reference and the rpl needs to be 00 to make the highest previledge.

Also, the esp needs to be the stack base + stack size right?

I just want to confirm with someone who knows a little more experience in pmode than me.
Thanks

Regards, Brill.

p.s. I think i killed my Pentium 75Mhz test machine making tripple faults from the stack. Is it possible to permenantly damage a machine from tripple faults?

R.I.P Pentium :*(.

RE:SS Selector

Posted: Wed Jul 03, 2002 11:00 pm
by carbonBased
A selector looks like this:
<pre>
| 15 - 3 | 2  | 1 0 |
|  Index | TI | RPL |
</pre>

Yes, an index of 1 represents the first GDT entry past the null descriptor, and yes, TI = 0 for the GDT, and RPL should be 0 for highest privelege.

With all that in mind, that yeilds 0x08 as your final selector.
The next index would yeild 0x10, and so on.

These are the numbers you should be putting in your segment register (ie, ss).  And yes, esp would contain (base + size), assuming your stack is an expand-up stack (as Intel defines it... to me, it's an expand down, but... whatever).

If your getting triple faults, it's possible your GDT isn't defined properly, or you haven't entered pmode correctly.

And no, you can't permenantly damage a machine through triple faults... although, you might wear down the boot sector of a physical disk, if you're using one.

Jeff