7.5.4 Address Translation Macros
System code may need to translate between virtual and physical addresses, as well as
between kernel segment addresses. The macros are defined in sys/kmem.h
so the application code should #include <sys/kmem.h>
. Macros are
provided to make these translations easier and to determine the segment an address is
in.
KVA_TO_PA(v) |
Translate a kernel virtual address to a physical address. |
PA_TO_KVA0(pa) |
Translate a physical address to a KSEG0 virtual address. |
PA_TO_KVA1(pa) |
Translate a physical address to a KSEG1 virtual address. |
KVA0_TO_KVA1(v) |
Translate a KSEG0 virtual address to a KSEG1 virtual address. |
KVA1_TO_KVA0(v) |
Translate a KSEG1 virtual address to a KSEG0 virtual address. |
IS_KVA(v) |
Evaluates to 1 if the address is a kernel segment virtual address, zero otherwise. |
IS_KVA0(v) |
Evaluate to 1 if the address is a KSEG0 virtual address, zero otherwise. |
IS_KVA1(v) |
Evaluate to 1 if the address is a KSEG1 virtual address, zero otherwise. |
IS_KVA01(v) |
Evaluate to 1 if the address is either a KSEG0 or a KSEG1 virtual address, zero otherwise. |