内核全局描述符¶
Overview¶
- https://wiki.osdev.org/GDT
- https://github.com/LordNoteworthy/cpu-internals
在 64位 模式下已经不是很重要了,于是采用 平坦模式.
Structure¶
同 32 位,gdt的每个项都是 64bit 的.
至于为什么会这么乱呢,主要是历史遗留问题 (real mode).

AccessByte¶
A- Accessed bitRW- Readable / Writable bitDC- Direction bit/Conforming bit- Data
- 0 - 向上拓展
- 1 - 向下拓展
- Code
- 0 - 只能给此 DPL 执行
- 1 - 可以给此 DPL 及以下执行
EXE-

S- 0 - 系统段
- 1 - Code / Data 段
DPL- Descriptor privilege level 特权级 (0 ~ 3)P- 有效
Flags¶
AVL- 保留,友情赠送L- 长模式- 如果不是 64位模式(IA-32e) 或者不是代码段置 0
- 0 ->
D/B置0 D/B- 0 - 16-bit
- 1 - 32-bit
GGranularity 作 Limit 单位- 0 - 1 Byte
- 1 - 4 KB
Set up¶
The first entry in the GDT (Entry 0) should always be null and subsequent entries should be used instead.
将 Base 置0,Limit 置最大值.
lgdt¶

lgdt 使用一个 80bit 的操作数.