The Pedigree Project
0.1
|
#include <VirtualAddressSpace.h>
Classes | |
struct | FirstLevelDescriptor |
struct | SecondLevelDescriptor |
Public Member Functions | |
virtual bool | isAddressValid (void *virtualAddress) |
virtual bool | isMapped (void *virtualAddress) |
virtual bool | map (physical_uintptr_t physicalAddress, void *virtualAddress, size_t flags) |
virtual void | getMapping (void *virtualAddress, physical_uintptr_t &physicalAddress, size_t &flags) |
virtual void | setFlags (void *virtualAddress, size_t newFlags) |
virtual void | unmap (void *virtualAddress) |
virtual void * | allocateStack () |
virtual void * | allocateStack (size_t stackSz) |
virtual void | freeStack (void *pStack) |
virtual bool | memIsInHeap (void *pMem) |
virtual void * | getEndOfHeap () |
bool | mapPageStructures (physical_uintptr_t physicalAddress, void *virtualAddress, size_t flags) |
virtual VirtualAddressSpace * | clone () |
virtual void | revertToKernelAddressSpace () |
virtual uintptr_t | getKernelStart () const |
virtual uintptr_t | getUserStart () const |
virtual uintptr_t | getUserReservedStart () const |
virtual uintptr_t | getDynamicLinkerAddress () const |
virtual uintptr_t | getKernelHeapStart () const |
virtual uintptr_t | getKernelHeapEnd () const |
virtual uintptr_t | getKernelCacheStart () const |
virtual uintptr_t | getKernelCacheEnd () const |
virtual uintptr_t | getKernelEventBlockStart () const |
virtual uintptr_t | getKernelModulesStart () const |
virtual uintptr_t | getKernelModulesEnd () const |
Public Member Functions inherited from VirtualAddressSpace | |
virtual void * | expandHeap (ssize_t incr, size_t flags) |
virtual bool | mapHuge (physical_uintptr_t physAddress, void *virtualAddress, size_t count, size_t flags) |
virtual void | freeStack (Stack *pStack)=0 |
virtual VirtualAddressSpace * | clone (bool copyOnWrite=true)=0 |
virtual | ~VirtualAddressSpace () |
void | setHeap (void *heap, void *heapEnd) |
virtual bool | memIsInKernelHeap (void *pMem)=0 |
virtual uintptr_t | getDynamicStart () const |
virtual uintptr_t | getDynamicEnd () const |
virtual uintptr_t | getGlobalInfoBlock () const |
Protected Member Functions | |
virtual | ~ArmV7VirtualAddressSpace () |
ArmV7VirtualAddressSpace (void *Heap, physical_uintptr_t PhysicalPageDirectory, void *VirtualPageDirectory, void *VirtualPageTables, void *VirtualStack) | |
bool | doIsMapped (void *virtualAddress) |
bool | doMap (physical_uintptr_t physicalAddress, void *virtualAddress, size_t flags) |
void | doGetMapping (void *virtualAddress, physical_uintptr_t &physicalAddress, size_t &flags) |
void | doSetFlags (void *virtualAddress, size_t newFlags) |
void | doUnmap (void *virtualAddress) |
void * | doAllocateStack (size_t sSize) |
Protected Member Functions inherited from VirtualAddressSpace | |
VirtualAddressSpace (void *Heap) | |
Private Member Functions | |
ArmV7VirtualAddressSpace (void *Heap, physical_uintptr_t PhysicalPageDirectory, void *VirtualPageDirectory, void *VirtualPageTables) | |
ArmV7VirtualAddressSpace () | |
ArmV7VirtualAddressSpace (const ArmV7VirtualAddressSpace &) | |
ArmV7VirtualAddressSpace & | operator= (const ArmV7VirtualAddressSpace &) |
bool | initialise () |
bool | getPageTableEntry (void *virtualAddress, uint32_t *&pageTableEntry) |
uint32_t | toFlags (size_t flags) |
size_t | fromFlags (uint32_t Flags) |
Private Attributes | |
struct ArmV7VirtualAddressSpace::FirstLevelDescriptor | PACKED |
struct ArmV7VirtualAddressSpace::SecondLevelDescriptor | PACKED |
physical_uintptr_t | m_PhysicalPageDirectory |
void * | m_VirtualPageDirectory |
void * | m_VirtualPageTables |
void * | m_pStackTop |
Vector< void * > | m_freeStacks |
Spinlock | m_Lock |
Friends | |
class | Processor |
class | ArmV7KernelVirtualAddressSpace |
VirtualAddressSpace * | VirtualAddressSpace::create () |
Additional Inherited Members | |
Static Public Member Functions inherited from VirtualAddressSpace | |
static EXPORTED_PUBLIC VirtualAddressSpace & | getKernelAddressSpace () |
static VirtualAddressSpace * | create () |
Public Attributes inherited from VirtualAddressSpace | |
void * | m_Heap |
void * | m_HeapEnd |
Static Public Attributes inherited from VirtualAddressSpace | |
static const size_t | KernelMode = 0x01 |
static const size_t | Write = 0x02 |
static const size_t | Execute = 0x04 |
static const size_t | WriteThrough = 0x08 |
static const size_t | CacheDisable = 0x10 |
static const size_t | CopyOnWrite = 0x20 |
static const size_t | Swapped = 0x40 |
static const size_t | MemoryCoherent = 0x80 |
static const size_t | Guarded = 0x100 |
static const size_t | Shared = 0x200 |
static const size_t | WriteCombine = 0x400 |
static const size_t | Accessed = 0x800 |
static const size_t | Dirty = 0x1000 |
static const size_t | ClearDirty = 0x2000 |
static physical_uintptr_t | m_ZeroPage = 0 |
The ArmV7VirtualAddressSpace implements the VirtualAddressSpace class for the ARMv7 architecture.
Definition at line 68 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
|
protectedvirtual |
The destructor does nothing
Definition at line 54 of file armv7/VirtualAddressSpace.cc.
Referenced by getKernelModulesEnd().
|
protected |
The constructor for already present paging structures
[in] | Heap | virtual address of the beginning of the heap |
[in] | PhysicalPageDirectory | physical address of the page directory |
[in] | VirtualPageDirectory | virtual address of the page directory |
[in] | VirtualPageTables | virtual address of the page tables |
[in] | VirtualStack | virtual address of the next stacks |
Definition at line 642 of file armv7/VirtualAddressSpace.cc.
|
private |
The constructor for already present paging structures
[in] | Heap | virtual address of the beginning of the heap |
[in] | PhysicalPageDirectory | physical address of the page directory |
[in] | VirtualPageDirectory | virtual address of the page directory |
[in] | VirtualPageTables | virtual address of the page tables |
|
private |
The default constructor
Definition at line 49 of file armv7/VirtualAddressSpace.cc.
Referenced by getKernelModulesEnd().
|
private |
The copy-constructor
|
virtual |
Allocates a single stack for a thread. Will use the default kernel thread size.
Implements VirtualAddressSpace.
Definition at line 432 of file armv7/VirtualAddressSpace.cc.
References VirtualAddressSpace::getKernelAddressSpace().
Referenced by allocateStack().
|
virtual |
Allocates a single stack of the given size for a thread.
Reimplemented from VirtualAddressSpace.
Definition at line 440 of file armv7/VirtualAddressSpace.cc.
References Spinlock::acquire(), PhysicalMemoryManager::allocatePage(), allocateStack(), Vector< T >::count(), VirtualAddressSpace::getKernelAddressSpace(), PhysicalMemoryManager::getPageSize(), PhysicalMemoryManager::instance(), VirtualAddressSpace::KernelMode, m_freeStacks, m_Lock, m_pStackTop, map(), Vector< T >::popBack(), Vector< T >::pushBack(), Spinlock::release(), WARNING, and VirtualAddressSpace::Write.
|
inlinevirtual |
Clone this VirtualAddressSpace. That means that we copy-on-write-map the application image.
Definition at line 115 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
|
protected |
Definition at line 173 of file armv7/VirtualAddressSpace.cc.
References PhysicalMemoryManager::allocatePage(), ArmV7VirtualAddressSpace::FirstLevelDescriptor::descriptor, ArmV7VirtualAddressSpace::SecondLevelDescriptor::descriptor, ERROR, FATAL, fromFlags(), Processor::id(), PhysicalMemoryManager::instance(), m_Lock, m_VirtualPageDirectory, m_VirtualPageTables, physicalAddress(), toFlags(), USERSPACE_PAGETABLES, and WARNING.
Referenced by getKernelModulesEnd(), map(), and ArmV7KernelVirtualAddressSpace::map().
|
private |
Convert processor's representation of the flags to the processor independant representation
[in] | Flags | the processor specific flag representation |
Definition at line 91 of file armv7/VirtualAddressSpace.cc.
References VirtualAddressSpace::KernelMode, and VirtualAddressSpace::Write.
Referenced by doMap(), and getKernelModulesEnd().
|
inlinevirtual |
Gets address of the dynamic linker in the address space.
Implements VirtualAddressSpace.
Definition at line 144 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
References USERSPACE_DYNAMIC_LINKER_LOCATION.
|
virtual |
Gets a pointer to the byte after the end of the heap.
Implements VirtualAddressSpace.
Definition at line 67 of file armv7/VirtualAddressSpace.cc.
Referenced by memIsInHeap().
|
inlinevirtual |
Gets address of the end of the kernel's cache region.
Implements VirtualAddressSpace.
Definition at line 169 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
|
inlinevirtual |
Gets address of the start of the kernel's cache region.
Implements VirtualAddressSpace.
Definition at line 163 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
|
inlinevirtual |
Gets address of the start of the kernel's event handling block.
Implements VirtualAddressSpace.
Definition at line 176 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
|
inlinevirtual |
Gets address of the end of the kernel's heap region.
Implements VirtualAddressSpace.
Definition at line 156 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
|
inlinevirtual |
Gets address of the start of the kernel's heap region.
Implements VirtualAddressSpace.
Definition at line 150 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
|
inlinevirtual |
Gets address of the end of the kernel's module region.
Implements VirtualAddressSpace.
Definition at line 188 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
References ArmV7VirtualAddressSpace(), doMap(), fromFlags(), getPageTableEntry(), initialise(), operator=(), physicalAddress(), toFlags(), and ~ArmV7VirtualAddressSpace().
|
inlinevirtual |
Gets address of the start of the kernel's module region.
Implements VirtualAddressSpace.
Definition at line 182 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
|
inlinevirtual |
Gets start address of the kernel in the address space.
Implements VirtualAddressSpace.
Definition at line 126 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
|
virtual |
Get the physical address and the flags associated with the specific virtual address.
[in] | virtualAddress | the address in the virtual address space |
[out] | flags | the flags |
[out] | physicalAddress | the physical address |
Implements VirtualAddressSpace.
Reimplemented in ArmV7KernelVirtualAddressSpace.
Definition at line 135 of file armv7/VirtualAddressSpace.cc.
|
private |
Get the page table entry, if it exists and check whether a page is mapped or marked as swapped out.
[in] | virtualAddress | the virtual address |
[out] | pageTableEntry | pointer to the page table entry |
Referenced by getKernelModulesEnd().
|
inlinevirtual |
Gets start address of reserved areas of the userpace address space.
Implements VirtualAddressSpace.
Definition at line 138 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
|
inlinevirtual |
Gets start address of the region usable and cloneable for userspace.
Implements VirtualAddressSpace.
Definition at line 132 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
|
private |
Initialises the kernel address space, called by Processor.
Definition at line 108 of file armv7/VirtualAddressSpace.cc.
Referenced by getKernelModulesEnd().
|
virtual |
Is a particular virtual address valid?
[in] | virtualAddress | the virtual address to check |
Implements VirtualAddressSpace.
Definition at line 113 of file armv7/VirtualAddressSpace.cc.
|
virtual |
Checks whether a mapping the the specific virtual address exists. Pages marked as swapped out are not considered mapped.
[in] | virtualAddress | the virtual address |
Implements VirtualAddressSpace.
Reimplemented in ArmV7KernelVirtualAddressSpace.
Definition at line 130 of file armv7/VirtualAddressSpace.cc.
|
virtual |
Map a specific physical page (of size PhysicalMemoryManager::getPageSize()) at a specific location into the virtual address space.
[in] | physicalAddress | the address of the physical page that should be mapped into the virtual address space. |
[in] | virtualAddress | the virtual address at which the page apears within the virtual address space. |
[in] | flags | flags that describe which accesses should be allowed on the page. |
Implements VirtualAddressSpace.
Reimplemented in ArmV7KernelVirtualAddressSpace.
Definition at line 119 of file armv7/VirtualAddressSpace.cc.
References doMap().
Referenced by allocateStack(), and ArmV7PhysicalMemoryManager::PageStack::free().
bool ArmV7VirtualAddressSpace::mapPageStructures | ( | physical_uintptr_t | physicalAddress, |
void * | virtualAddress, | ||
size_t | flags | ||
) |
Map the page table or the page frame if none is currently present
[in] | physicalAddress | the physical page that should be used as page table or page frame |
[in] | virtualAddress | the virtual address that should be checked for the existance of a page table and page frame |
[in] | flags | the flags used for the mapping |
|
virtual |
Determines if a given point is within the virtual address space region dedicated to the kernel heap.
Implements VirtualAddressSpace.
Definition at line 58 of file armv7/VirtualAddressSpace.cc.
References getEndOfHeap().
|
private |
The copy-constructor
Referenced by getKernelModulesEnd().
|
inlinevirtual |
Undo a clone() - this happens when an application is Exec()'d - we destroy all mappings not in the kernel address space so the space is 'clean'.
Implements VirtualAddressSpace.
Definition at line 123 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
|
virtual |
Set the flags of the page at a specific virtual address.
[in] | virtualAddress | the virtual address |
[in] | newFlags | the flags |
Implements VirtualAddressSpace.
Reimplemented in ArmV7KernelVirtualAddressSpace.
Definition at line 141 of file armv7/VirtualAddressSpace.cc.
References m_VirtualPageDirectory, and m_VirtualPageTables.
|
private |
Convert the processor independant flags to the processor's representation of the flags
[in] | flags | the processor independant flag representation |
Definition at line 74 of file armv7/VirtualAddressSpace.cc.
References VirtualAddressSpace::KernelMode, and VirtualAddressSpace::Write.
Referenced by doMap(), and getKernelModulesEnd().
|
virtual |
Remove the page at the specific virtual address from the virtual address space.
[in] | virtualAddress | the virtual address |
Implements VirtualAddressSpace.
Reimplemented in ArmV7KernelVirtualAddressSpace.
Definition at line 125 of file armv7/VirtualAddressSpace.cc.
|
friend |
Processor::switchAddressSpace() needs access to m_PhysicalPageDirectory
Definition at line 72 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
|
friend |
VirtualAddressSpace::create needs access to the constructor
|
private |
List of free stacks
Definition at line 368 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
Referenced by allocateStack().
|
private |
Lock to guard against multiprocessor reentrancy.
Definition at line 371 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
Referenced by allocateStack(), and doMap().
|
private |
Physical address of the page directory
Definition at line 359 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
Referenced by ArmV7KernelVirtualAddressSpace::initialiseKernelAddressSpace().
|
private |
Current top of the stacks
Definition at line 366 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
Referenced by allocateStack().
|
private |
Virtual address of the page directory
Definition at line 361 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
Referenced by doMap(), ArmV7KernelVirtualAddressSpace::initialiseKernelAddressSpace(), and setFlags().
|
private |
Virtual address of the page tables
Definition at line 363 of file kernel/core/processor/armv7/VirtualAddressSpace.h.
Referenced by doMap(), and setFlags().