我知道虚拟地址如何变成物理地址有一种映射机制。
就像下面这样,一个线性地址包含三个部分
这是插图:
现在,当我在 memorylayout.h 中查看 Xv6 的源代码时
#define V2P(a) (((uint) (a)) - KERNBASE)
#define P2V(a) (((void *) (a)) + KERNBASE)
#define V2P_WO(x) ((x) - KERNBASE) // same as V2P, but without casts
#define P2V_WO(x) ((x) + KERNBASE) // same as P2V, but without casts
Run Code Online (Sandbox Code Playgroud)
V2P或P2V如何在不做地址转换过程的情况下正常工作?