PKUOS - Pintos
Pintos source browser for PKU Operating System course
|
Go to the source code of this file.
Macros | |
#define | BITMASK(SHIFT, CNT) (((1ul << (CNT)) - 1) << (SHIFT)) |
Functions and macros for working with virtual addresses. More... | |
#define | PGSHIFT 0 |
Page offset (bits 0:12). More... | |
#define | PGBITS 12 |
Number of offset bits. More... | |
#define | PGSIZE (1 << PGBITS) |
Bytes in a page. More... | |
#define | PGMASK BITMASK(PGSHIFT, PGBITS) |
Page offset bits (0:12). More... | |
#define | PHYS_BASE ((void *) LOADER_PHYS_BASE) |
Base address of the 1:1 physical-to-virtual mapping. More... | |
Functions | |
static unsigned | pg_ofs (const void *va) |
Offset within a page. More... | |
static uintptr_t | pg_no (const void *va) |
Virtual page number. More... | |
static void * | pg_round_up (const void *va) |
Round up to nearest page boundary. More... | |
static void * | pg_round_down (const void *va) |
Round down to nearest page boundary. More... | |
static bool | is_user_vaddr (const void *vaddr) |
Returns true if VADDR is a user virtual address. More... | |
static bool | is_kernel_vaddr (const void *vaddr) |
Returns true if VADDR is a kernel virtual address. More... | |
static void * | ptov (uintptr_t paddr) |
Returns kernel virtual address at which physical address PADDR is mapped. More... | |
static uintptr_t | vtop (const void *vaddr) |
Returns physical address at which kernel virtual address VADDR is mapped. More... | |
#define BITMASK | ( | SHIFT, | |
CNT | |||
) | (((1ul << (CNT)) - 1) << (SHIFT)) |
#define PGSHIFT 0 |
#define PHYS_BASE ((void *) LOADER_PHYS_BASE) |
Base address of the 1:1 physical-to-virtual mapping.
Physical memory is mapped starting at this virtual address. Thus, physical address 0 is accessible at PHYS_BASE, physical address address 0x1234 at (uint8_t *) PHYS_BASE + 0x1234, and so on.
This address also marks the end of user programs' address space. Up to this point in memory, user programs are allowed to map whatever they like. At this point and above, the virtual address space belongs to the kernel.
|
inlinestatic |
|
inlinestatic |
Returns true if VADDR is a user virtual address.
Definition at line 57 of file vaddr.h.
References PHYS_BASE.
Referenced by lookup_page(), pagedir_clear_page(), pagedir_get_page(), pagedir_set_page(), and validate_segment().
|
inlinestatic |
Virtual page number.
Definition at line 29 of file vaddr.h.
References PGBITS.
Referenced by page_from_pool(), and palloc_free_multiple().
|
inlinestatic |
Offset within a page.
Definition at line 24 of file vaddr.h.
References PGMASK.
Referenced by block_size(), block_to_arena(), load_segment(), pagedir_clear_page(), pagedir_get_page(), pagedir_set_page(), palloc_free_multiple(), pde_create(), and pte_create_kernel().
|
inlinestatic |
Round down to nearest page boundary.
Definition at line 39 of file vaddr.h.
References PGMASK.
Referenced by block_to_arena(), and running_thread().
|
inlinestatic |
|
inlinestatic |
Returns kernel virtual address at which physical address PADDR is mapped.
Definition at line 72 of file vaddr.h.
References ASSERT, and PHYS_BASE.
Referenced by active_pd(), init(), paging_init(), palloc_init(), pde_get_pt(), pte_get_page(), and read_command_line().
|
inlinestatic |
Returns physical address at which kernel virtual address VADDR is mapped.
Definition at line 82 of file vaddr.h.
References ASSERT, is_kernel_vaddr(), and PHYS_BASE.
Referenced by pagedir_activate(), pagedir_set_page(), paging_init(), pde_create(), and pte_create_kernel().