Main Page | Data Structures | File List | Globals | Related Pages

vm.c File Reference

Provides the implementantion of virtual memory management. More...

#include <x86/proc_reg.h>
#include <console.h>
#include <interrupt.h>
#include <malloc.h>
#include <string.h>
#include <stdio.h>
#include <frame.h>
#include <thread.h>
#include <task.h>
#include <vm.h>

Functions

void page_fault_handler (ExceptionVector vector, ExceptionData data, Registers *registers)
int vm_initialize (Task *task)
 Initialize virtual memory.

unsigned int unmapped_pt0_entries (PageTableEntry *pt0, MemoryAddress address, MemoryAddress end)
void flush_tlb (void)
void vm_context_switch (Task *task)
 Context switch into a task's address space.

int map_memory_region (Task *task, PageTableEntry *pt0, PageTableEntry *pt1, MemoryRegion *region, MemoryAddress start, MemoryAddress end)
void unmap_memory_region (PageTableEntry *pt0, PageTableEntry *pt1, MemoryRegion *region)
int vm_map (Task *task, MemoryRegion *region)
 Map a memory region into a task's address space.

int vm_unmap (Task *task, MemoryRegion *region)
 Unmap a memory region from a task's address space.

int vm_validate (MemoryAddress address, MemoryAddress end, unsigned int protection)
 Validates that a memory region is mapped.

int vm_validate_string (MemoryAddress address, unsigned int type)
 Validates that a memory region is mapped.

MemoryRegion * memory_region_find (Task *task, MemoryAddress address)
 Finds a memory region by address.

MemoryRegion * memory_region_create (Task *task, unsigned int protection, MemoryAddress address, MemoryAddress end, MemoryFaultHandler faultHandler)
 Creates a new memory region in a task's address space.

void memory_region_destroy (MemoryRegion *region)
 Destroys a memory region.

int fork_memory_regions (Task *dst, Task *src)
void initialize_pt0 (PageTableEntry *pt0, Frame *frame)
void copy_user_space (PageTableEntry *pt0)
int vm_fork (Task *task)
 Forks a new task from the current task.

int vm_copy (Task *task, MemoryAddress dst, char *src, unsigned int len)
 Copies data into a specified task's address space.

int stack_fault_handler (MemoryRegion *region, MemoryAddress address, Registers *registers)


Detailed Description

Provides the implementantion of virtual memory management.

Author:
Lee Salzman (lsalzman)

Hassaan Moin Khan (hkhan)

Bug:
No known bugs.

Function Documentation

MemoryRegion* memory_region_create Task *  task,
unsigned int  protection,
MemoryAddress  start,
MemoryAddress  end,
MemoryFaultHandler  handler
 

Creates a new memory region in a task's address space.

Creates a new memory region in the tasks address space, for a given protection and fault behavior.

Parameters:
task the task to create in
protection the mapping protection of the region
start the address of the first frame of the region
end the address of the last frame of the region
handler the page fault handler for the region
Returns:
the memory region on success NULL on failure

void memory_region_destroy MemoryRegion *  region  ) 
 

Destroys a memory region.

Free frames associated with a memory region.

Parameters:
region the region to destroy
Returns:
Void

MemoryRegion* memory_region_find Task *  task,
MemoryAddress  address
 

Finds a memory region by address.

Find a memory region in a task by an address that falls within the region.

Parameters:
task the task to find the memory region in
address the address falling within a region to search for
Returns:
the region containing the address on success NULL on failure

void vm_context_switch Task *  task  ) 
 

Context switch into a task's address space.

Installs the page directory of the specified task as the current page directory.

Parameters:
task the task to context switch into
Returns:
Void

int vm_copy Task *  task,
MemoryAddress  dst,
char *  src,
unsigned int  size
 

Copies data into a specified task's address space.

Copies data from the current address space into a target address space by utilizing the temporary mapping space.

Parameters:
task the task to copy data into
dst the memory address in the target task's address space to copy into
src the data from the current address space to copy
size the amount of data to copy
Returns:
0 on success -1 on failure

int vm_fork Task *  task  ) 
 

Forks a new task from the current task.

Forks a new address space that is a copy of the current task into the specified task.

Parameters:
task the task to fork the address space into
Returns:
0 on success -1 on failure

int vm_initialize Task *  task  ) 
 

Initialize virtual memory.

Initializes the virtual memory system with the specified init task.

Parameters:
task the init task
Returns:
0 on success -1 on failure

int vm_map Task *  task,
MemoryRegion *  region
 

Map a memory region into a task's address space.

Map a memory region into a task's address space, allocating page tables as necessary.

Parameters:
task the task to map into
region the memory region to map
Returns:
0 on success -1 on failure

int vm_unmap Task *  task,
MemoryRegion *  region
 

Unmap a memory region from a task's address space.

Unset all the page table entries associated with a memory region in the task's address space.

Parameters:
task the task to unmap from
region the region to unmap
Returns:
0 on success -1 on failure

int vm_validate MemoryAddress  ,
MemoryAddress  ,
unsigned int  protection
 

Validates that a memory region is mapped.

Checks if the specified region of the current task's address space is mapped as user memory with the specified protection.

Parameters:
start the address of beginning of the region
end the address of the last frame of the region
protection the protection flags to check for
Returns:
0 on success -1 on failure

int vm_validate_string MemoryAddress  start,
unsigned int  size
 

Validates that a memory region is mapped.

Checks if the specified region of the current task's address space is mapped as user readable, where the memory region is a string containing elements of a specified size with an unknown extent, ending at a 0 element.

Parameters:
start the address of beginning of the region
size the element size of the string memory region
Returns:
the length of the string 0 on success -1 on failure


Generated on Fri Apr 9 21:59:16 2004 for 15-410 Project 3 by doxygen 1.3.2