From here you can consider that the address in gdt is line address.
<------------------------------------------------------------->
/*
* Set segments to known values.
*/
lgdt pa(boot_gdt_descr) //here, gdt address to pa address.
movl $(__BOOT_DS),%eax
movl %eax,%ds
movl %eax,%es
movl %eax,%fs
movl %eax,%gs
<------------------------------------------------------------->
and, for pgd, (pmd), pte, are set up after the segment set, bss clear, and bootup parameter to be copy out of the ram.
so, its init is back far from the gdt configurations.
实模式何须要GDT/LDT等内存管理/分页分段的产物。
但是,GDT(boot_GDT)的建立是在实模式阶段进行的。
当然,GDT register里面的是线性地址了。
当real mode to protected mode时候,需要设定PDBR(cr3)的值,加载gdt(线性地址)。
每个process有一个gdt的copy,then they everyone can seperately modify their copy gdt.
ldt is build up after gdt.
the following codes are the codes what the real mode to protected mode.
<------------------------------------------------------>
real_to_prot:
.code16
cli
/* load the GDT register *///*************************/
DATA32 ADDR32 lgdt gdtdesc //load line address
这个概念是不是搞错了?
GDT本身是用于把逻辑地址映射到线性地址空间的,真正把线性地址映射到这个跟Page_table。所以我不明白的是为什么进入保护模式前必须设置GDT呢?似乎只需要把Page_table设置好,就已经可以进入保护模式了,也就是分页机制已经启用。所以,似乎真正要设置成使得物理地址我线性地址等价的应该是Page_table的内容,而不是GDT。这个过程再Understanding Linux Kernel的第三版说明的比较详细,但似乎没有提到GDT的初始化时机。