Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
It depends. If you are going to have user mode (PL=3) programs, you need at least a user mode code segment and a user mode data segment. The 6 entries you read about probably refer to long mode OSes, which need user segments for 32-bit and 64-bit operation. Another thing to consider when writing your GDT is SYSENTER/SYSLEAVE fast system call instructions and their AMD counterparts, SYSCALL/SYSRET. These instructions require your GDT to be structured in a specific way; look at the Intel manuals (I think they're in 2B) for info on them.
I apologize, but from what i see on the wiki it only lists 2 entries, and the null entry.
As for the manuals, I have gone through them, and other articles, which have all led me to the 6 entries for the table.
If I do not know as much on development as you do, I apologize, as frankly I am new to it. I have tried it in the past and failed, so I took a break to understand theory.
I asked a question, and there was no need for "RTFM!".
For most OS's, 6 GDT entries probably works out to:
NULL entry
CPL=0 code segment
CPL=0 stack/data segment
CPL=3 code segment
CPL=3 stack/data segment
System TSS (needed for CPL=0 -> CPL=3 -> CPL=0 context switches, not for task switches)
Extra entries might (optionally) be used for a kernel API call gate, and because GDT entries need to be in a different order for SYSENTER and SYSCALL (if an OS supports both then you can expect a few redundant entries).
Cheers,
Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.