Open yfractal opened 3 years ago
The instructions are using virtual address, hardware will help us to do the virtual address to physical address translation.
For os, we need get the physical address, eg: read/write some physical address content.
That means os wants to use physical address but the hardware doesn't support that directly.
How could we achieve that?
xv6 maps some virtual address to physical address directly by:
kvmmap(kpgtbl, (uint64)etext, (uint64)etext, PHYSTOP-(uint64)etext, PTE_R | PTE_W);
the kvmmap
's signature is kvmmap(pagetable_t kpgtbl, uint64 va, uint64 pa, uint64 sz, int perm)
.
Yeah, that's how xv6 gets physical address, so fucking amazing !!!
Need explain:
For page table or virtual addressing may need write another blog.