Page 1 of 1

Bits for DPL in GDT or IDT.

Posted: Sun Oct 26, 2014 9:34 am
by donggas90
You can see IDT structure here.

Code: Select all

•Bits 42...44: Descriptor Privedlge Level (DPL)
◦00: Ring 0
◦01: Ring 1
◦10: Ring 2
◦11: Ring 3
And you can download that tutorial's source here.

Now my question is this.
About bits of DPL field.
I already know that 0(00b) means Ring0 and 3(11b) means Ring3.

but How about Ring1 or Ring2?
In Ring1 case, 01b? 10b?
I thought and believe 01b is right because that is 1 in decimal.
However the source had been wrote 10b as Ring1.

Code: Select all

#define I86_IDT_DESC_RING1		0x40	//01000000
#define I86_IDT_DESC_RING2		0x20	//00100000
#define I86_IDT_DESC_RING3		0x60	//01100000
You can see this code at idt.h in Hal project.

I'm really confusing about that. The code is wrong? What is correct?

Re: Bits for DPL in GDT or IDT.

Posted: Sun Oct 26, 2014 9:42 am
by Brendan
Hi,
donggas90 wrote:I'm really concerning. The code is wrong? What is correct?
The source in the tutorial is wrong and has them around the wrong way. Nobody uses ring 1 or ring 2 (including the demo/tutorial), so nobody noticed.


Cheers,

Brendan

Re: Bits for DPL in GDT or IDT.

Posted: Sun Oct 26, 2014 10:11 am
by donggas90
Thanks Brendan.