#include <list.h>
#include <task.h>
#include <register.h>
Go to the source code of this file.
Data Structures | |
struct | MemoryRegion |
Defines | |
#define | VM_ADDRESS_KERNEL_HEAP 0x00000000 |
#define | VM_ADDRESS_KERNEL_HEAP_LIMIT 0x01000000 |
#define | VM_ADDRESS_USER_SPACE 0x01000000 |
#define | VM_ADDRESS_USER_SPACE_LIMIT 0xFE000000 |
#define | VM_ADDRESS_TEMPORARY_MAPPING_1 0xFF000000 |
#define | VM_ADDRESS_TEMPORARY_MAPPING_2 0xFF400000 |
#define | VM_ADDRESS_TEMPORARY_MAPPING_1_PT0 0xFF800000 |
#define | VM_ADDRESS_TEMPORARY_MAPPING_2_PT0 0xFF801000 |
#define | VM_ADDRESS_KERNEL_STACK 0xFF802000 |
#define | VM_ADDRESS_KERNEL_STACK_LIMIT 0x003FE000 |
#define | VM_ADDRESS_PAGE_TABLE 0xFFC00000 |
#define | VM_PROTECTION_READ (0 << 1) |
#define | VM_PROTECTION_WRITE (1 << 1) |
#define | VM_PROTECTION_SUPERVISOR (0 << 2) |
#define | VM_PROTECTION_USER (1 << 2) |
#define | VM_PROTECTION_MASK (3 << 1) |
#define | VM_PT0 ((PageTableEntry *) (VM_ADDRESS_PAGE_TABLE + ((VM_ADDRESS_PAGE_TABLE >> VM_PT0_SHIFT) << VM_PT1_SHIFT))) |
#define | VM_PT0_MASK 0xFFC00000 |
#define | VM_PT0_SHIFT 22 |
#define | VM_PT0_SIZE 1024 |
#define | VM_PT1(index) ((PageTableEntry *) (VM_ADDRESS_PAGE_TABLE + (index) * sizeof (PageTableEntry) * VM_PT1_SIZE)) |
#define | VM_PT1_MASK 0x003FF000 |
#define | VM_PT1_SHIFT 12 |
#define | VM_PT1_SIZE 1024 |
#define | VM_PTE(address) (VM_PT1((address) >> VM_PT0_SHIFT) [((address) & VM_PT1_MASK) >> VM_PT1_SHIFT]) |
#define | VM_PTE_PRESENT (1 << 0) |
#define | VM_PTE_GLOBAL (1 << 8) |
#define | VM_STACK_TOLERANCE (1 << VM_PT0_SHIFT) |
#define | VM_VALIDATE(ptr, type, elems) (vm_validate ((MemoryAddress) (ptr), (MemoryAddress) (ptr) + sizeof (type) * (elems) - 1, VM_PROTECTION_READ)) |
#define | VM_VALIDATE_WRITE(ptr, type, elems) (vm_validate ((MemoryAddress) (ptr), (MemoryAddress) (ptr) + sizeof (type) * (elems) - 1, VM_PROTECTION_READ | VM_PROTECTION_WRITE)) |
#define | VM_VALIDATE_STRING(ptr, type) (vm_validate_string ((MemoryAddress) (ptr), sizeof (type))) |
Typedefs | |
typedef unsigned int | PageTableEntry |
typedef unsigned long int | MemoryAddress |
typedef int(* | MemoryFaultHandler )(struct MemoryRegion *, MemoryAddress, Registers *) |
typedef MemoryRegion | MemoryRegion |
Functions | |
int | vm_initialize (Task *task) |
Initialize virtual memory. | |
int | vm_validate (MemoryAddress, MemoryAddress, unsigned int protection) |
Validates that a memory region is mapped. | |
int | vm_validate_string (MemoryAddress start, unsigned int size) |
Validates that a memory region is mapped. | |
void | vm_context_switch (Task *task) |
Context switch into a task's address space. | |
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_fork (Task *task) |
Forks a new task from the current task. | |
int | vm_copy (Task *task, MemoryAddress dst, char *src, unsigned int size) |
Copies data into a specified task's address space. | |
int | stack_fault_handler (MemoryRegion *, MemoryAddress, Registers *) |
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. | |
void | memory_region_destroy (MemoryRegion *region) |
Destroys a memory region. | |
MemoryRegion * | memory_region_find (Task *task, MemoryAddress address) |
Finds a memory region by address. |
Provides the interface for managing memory regions and the virtual address space.
|
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.
|
|
Destroys a memory region. Free frames associated with a memory region.
|
|
Finds a memory region by address. Find a memory region in a task by an address that falls within the region.
|
|
Context switch into a task's address space. Installs the page directory of the specified task as the current page directory.
|
|
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.
|
|
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.
|
|
Initialize virtual memory. Initializes the virtual memory system with the specified init task.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|