CS318 - Pintos
Pintos source browser for JHU CS318 course
Functions
pagedir.h File Reference
#include <stdbool.h>
#include <stdint.h>
Include dependency graph for pagedir.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

uint32_tpagedir_create (void)
 Creates a new page directory that has mappings for kernel virtual addresses, but none for user virtual addresses. More...
 
void pagedir_destroy (uint32_t *pd)
 Destroys page directory PD, freeing all the pages it references. More...
 
bool pagedir_set_page (uint32_t *pd, void *upage, void *kpage, bool rw)
 Adds a mapping in page directory PD from user virtual page UPAGE to the physical frame identified by kernel virtual address KPAGE. More...
 
void * pagedir_get_page (uint32_t *pd, const void *upage)
 Looks up the physical address that corresponds to user virtual address UADDR in PD. More...
 
void pagedir_clear_page (uint32_t *pd, void *upage)
 Marks user virtual page UPAGE "not present" in page directory PD. More...
 
bool pagedir_is_dirty (uint32_t *pd, const void *upage)
 Returns true if the PTE for virtual page VPAGE in PD is dirty, that is, if the page has been modified since the PTE was installed. More...
 
void pagedir_set_dirty (uint32_t *pd, const void *upage, bool dirty)
 Set the dirty bit to DIRTY in the PTE for virtual page VPAGE in PD. More...
 
bool pagedir_is_accessed (uint32_t *pd, const void *upage)
 Returns true if the PTE for virtual page VPAGE in PD has been accessed recently, that is, between the time the PTE was installed and the last time it was cleared. More...
 
void pagedir_set_accessed (uint32_t *pd, const void *upage, bool accessed)
 Sets the accessed bit to ACCESSED in the PTE for virtual page VPAGE in PD. More...
 
void pagedir_activate (uint32_t *pd)
 userprog/pagedir.h More...
 

Function Documentation

◆ pagedir_activate()

void pagedir_activate ( uint32_t pd)

userprog/pagedir.h

userprog/pagedir.h

Definition at line 220 of file pagedir.c.

References init_page_dir, NULL, and vtop().

Referenced by invalidate_pagedir(), process_activate(), and process_exit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pagedir_clear_page()

void pagedir_clear_page ( uint32_t pd,
void *  upage 
)

Marks user virtual page UPAGE "not present" in page directory PD.

Later accesses to the page will fault. Other bits in the page table entry are preserved. UPAGE need not be mapped.

Definition at line 144 of file pagedir.c.

References ASSERT, invalidate_pagedir(), is_user_vaddr(), lookup_page(), NULL, pg_ofs(), and PTE_P.

Here is the call graph for this function:

◆ pagedir_create()

uint32_t* pagedir_create ( void  )

Creates a new page directory that has mappings for kernel virtual addresses, but none for user virtual addresses.

Returns the new page directory, or a null pointer if memory allocation fails.

Definition at line 17 of file pagedir.c.

References init_page_dir, memcpy(), NULL, palloc_get_page(), and PGSIZE.

Referenced by load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pagedir_destroy()

void pagedir_destroy ( uint32_t pd)

Destroys page directory PD, freeing all the pages it references.

Definition at line 28 of file pagedir.c.

References ASSERT, init_page_dir, NULL, palloc_free_page(), pd_no(), pde_get_pt(), PGSIZE, PHYS_BASE, pte_get_page(), and PTE_P.

Referenced by process_exit().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pagedir_get_page()

void* pagedir_get_page ( uint32_t pd,
const void *  uaddr 
)

Looks up the physical address that corresponds to user virtual address UADDR in PD.

Returns the kernel virtual address corresponding to that physical address, or a null pointer if UADDR is unmapped.

Definition at line 126 of file pagedir.c.

References ASSERT, is_user_vaddr(), lookup_page(), NULL, pg_ofs(), pte_get_page(), and PTE_P.

Referenced by install_page().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ pagedir_is_accessed()

bool pagedir_is_accessed ( uint32_t pd,
const void *  vpage 
)

Returns true if the PTE for virtual page VPAGE in PD has been accessed recently, that is, between the time the PTE was installed and the last time it was cleared.

Returns false if PD contains no PTE for VPAGE.

Definition at line 193 of file pagedir.c.

References lookup_page(), NULL, and PTE_A.

Here is the call graph for this function:

◆ pagedir_is_dirty()

bool pagedir_is_dirty ( uint32_t pd,
const void *  vpage 
)

Returns true if the PTE for virtual page VPAGE in PD is dirty, that is, if the page has been modified since the PTE was installed.

Returns false if PD contains no PTE for VPAGE.

Definition at line 164 of file pagedir.c.

References lookup_page(), NULL, and PTE_D.

Here is the call graph for this function:

◆ pagedir_set_accessed()

void pagedir_set_accessed ( uint32_t pd,
const void *  upage,
bool  accessed 
)

Sets the accessed bit to ACCESSED in the PTE for virtual page VPAGE in PD.

Definition at line 202 of file pagedir.c.

References invalidate_pagedir(), lookup_page(), NULL, and PTE_A.

Here is the call graph for this function:

◆ pagedir_set_dirty()

void pagedir_set_dirty ( uint32_t pd,
const void *  upage,
bool  dirty 
)

Set the dirty bit to DIRTY in the PTE for virtual page VPAGE in PD.

Definition at line 173 of file pagedir.c.

References invalidate_pagedir(), lookup_page(), NULL, and PTE_D.

Here is the call graph for this function:

◆ pagedir_set_page()

bool pagedir_set_page ( uint32_t pd,
void *  upage,
void *  kpage,
bool  writable 
)

Adds a mapping in page directory PD from user virtual page UPAGE to the physical frame identified by kernel virtual address KPAGE.

UPAGE must not already be mapped. KPAGE should probably be a page obtained from the user pool with palloc_get_page(). If WRITABLE is true, the new page is read/write; otherwise it is read-only. Returns true if successful, false if memory allocation failed.

Definition at line 99 of file pagedir.c.

References ASSERT, init_page_dir, init_ram_pages, is_user_vaddr(), lookup_page(), NULL, pg_ofs(), pte_create_user(), PTE_P, PTSHIFT, and vtop().

Referenced by install_page().

Here is the call graph for this function:
Here is the caller graph for this function: