【发布时间】:2018-07-16 01:43:22
【问题描述】:
MINIX 3 中的这段代码将引导监视器的(引导)GDT 复制到内核空间并切换它。但是我很难理解代码。在代码中,_gdt 是在 C 中声明的描述符表数组的地址 (gdt[GDT_SIZE])。
gdt的结构如下:
struct segdesc_s { /* segment descriptor for protected mode */
u16_t limit_low;
u16_t base_low;
u8_t base_middle;
u8_t access; /* |P|DL|1|X|E|R|A| */
u8_t granularity; /* |G|X|0|A|LIMT| */
u8_t base_high;
};
结构的大小为 8 个字节。宏 GDT_SELECTOR 的值为 8。
! Copy the monitor global descriptor table to the address space of kernel and
! switch over to it. Prot_init() can then update it with immediate effect.
sgdt (_gdt+GDT_SELECTOR) ! get the monitor gdtr
mov esi, (_gdt+GDT_SELECTOR+2) ! absolute address of GDT
mov ebx, _gdt ! address of kernel GDT
mov ecx, 8*8 ! copying eight descriptors
copygdt:
eseg movb al, (esi)
movb (ebx), al
inc esi
inc ebx
loop copygdt
最令人困惑的一行是movb (ebx), al。请帮忙。
【问题讨论】:
标签: assembly x86 operating-system minix