6.828: Operating System Engineering (31)
pmap.[ch] 見ながらなメモ。
ちょっとまだ basemem たら extmem とかが何かがワケワカ。
(gdb) p/x basemem $1 = 0xa0000 (gdb) p/x extmem $2 = 0x3fff000 (gdb) p/x maxpa $3 = 0x40ff000 (gdb) p/x npage $4 = 0x40ff (gdb)
ええと、extmem が 0 でなければ以下な処理になってますね。
// Calculate the maximum physical address based on whether // or not there is any extended memory. See comment in <inc/mmu.h>. if (extmem) maxpa = EXTPHYSMEM + extmem;
ええと、EXTPHYSMEM は inc/memlayout.h で定義されてて以下。
// At IOPHYSMEM (640K) there is a 384K hole for I/O. From the kernel, // IOPHYSMEM can be addressed at KERNBASE + IOPHYSMEM. The hole ends // at physical address EXTPHYSMEM. #define IOPHYSMEM 0x0A0000 #define EXTPHYSMEM 0x100000
えーと、inc/mmu.h のコメント見れとかあったな。てか、EXTPHYSMEM って Kernel のテキストセグメントがナニされる位置だな。ちょっとまだ色々なものがツナガッていないカンジがします。
とりあえず boot_alloc 手続きで何をしないといけないのかは理解できてると思うんですが、i386_vm_init 手続きがアレ。
VPT って何だば
inc/memlayout.h なアレが以下。
// Virtual page table. Entry PDX[VPT] in the PD contains a pointer to // the page directory itself, thereby turning the PD into a page table, // which maps all the PTEs containing the page mappings for the entire // virtual address space into that 4 Meg region starting at VPT. #define VPT (KERNBASE - PTSIZE) #define KSTACKTOP VPT
以下な初期設定をしてます。
// Permissions: kernel RW, user NONE pgdir[PDX(VPT)] = PADDR(pgdir)|PTE_W|PTE_P;
PDX て何でしょ。ってアレか。
// +--------10------+-------10-------+---------12----------+ // | Page Directory | Page Table | Offset within Page | // | Index | Index | | // +----------------+----------------+---------------------+ // \--- PDX(la) --/ \--- PTX(la) --/ \---- PGOFF(la) ----/ // \----------- PPN(la) -----------/
この時点での (?) pgdir は物理アドレスって思ってて良いのかどうか。あ、違うや。右辺で phy なナニに直してるじゃん。んーと、直上のコメントがアレ。
////////////////////////////////////////////////////////////////////// // Recursively insert PD in itself as a page table, to form // a virtual page table at virtual address VPT. // (For now, you don't have understand the greater purpose of the // following two lines.)
これ、どこで Page Directory を初期設定してるのかなぁ。俯瞰が必要なカンジ。どうも俯瞰ができてないな。ある意味絶不調。