The Pedigree Project  0.1
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
ArmV7VirtualAddressSpace Class Reference

#include <VirtualAddressSpace.h>

+ Inheritance diagram for ArmV7VirtualAddressSpace:
+ Collaboration diagram for ArmV7VirtualAddressSpace:

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 VirtualAddressSpaceclone ()
 
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 VirtualAddressSpaceclone (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 &)
 
ArmV7VirtualAddressSpaceoperator= (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
 
VirtualAddressSpaceVirtualAddressSpace::create ()
 

Additional Inherited Members

- Static Public Member Functions inherited from VirtualAddressSpace
static EXPORTED_PUBLIC VirtualAddressSpacegetKernelAddressSpace ()
 
static VirtualAddressSpacecreate ()
 
- 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
 

Detailed Description

The ArmV7VirtualAddressSpace implements the VirtualAddressSpace class for the ARMv7 architecture.

Definition at line 68 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

Constructor & Destructor Documentation

ArmV7VirtualAddressSpace::~ArmV7VirtualAddressSpace ( )
protectedvirtual

The destructor does nothing

Definition at line 54 of file armv7/VirtualAddressSpace.cc.

Referenced by getKernelModulesEnd().

+ Here is the caller graph for this function:

ArmV7VirtualAddressSpace::ArmV7VirtualAddressSpace ( void *  Heap,
physical_uintptr_t  PhysicalPageDirectory,
void *  VirtualPageDirectory,
void *  VirtualPageTables,
void *  VirtualStack 
)
protected

The constructor for already present paging structures

Parameters
[in]Heapvirtual address of the beginning of the heap
[in]PhysicalPageDirectoryphysical address of the page directory
[in]VirtualPageDirectoryvirtual address of the page directory
[in]VirtualPageTablesvirtual address of the page tables
[in]VirtualStackvirtual address of the next stacks
Note
This constructor is only used to construct the kernel VirtualAddressSpace

Definition at line 642 of file armv7/VirtualAddressSpace.cc.

ArmV7VirtualAddressSpace::ArmV7VirtualAddressSpace ( void *  Heap,
physical_uintptr_t  PhysicalPageDirectory,
void *  VirtualPageDirectory,
void *  VirtualPageTables 
)
private

The constructor for already present paging structures

Parameters
[in]Heapvirtual address of the beginning of the heap
[in]PhysicalPageDirectoryphysical address of the page directory
[in]VirtualPageDirectoryvirtual address of the page directory
[in]VirtualPageTablesvirtual address of the page tables
ArmV7VirtualAddressSpace::ArmV7VirtualAddressSpace ( )
private

The default constructor

Note
NOT implemented

Definition at line 49 of file armv7/VirtualAddressSpace.cc.

Referenced by getKernelModulesEnd().

+ Here is the caller graph for this function:

ArmV7VirtualAddressSpace::ArmV7VirtualAddressSpace ( const ArmV7VirtualAddressSpace )
private

The copy-constructor

Note
NOT implemented

Member Function Documentation

void * ArmV7VirtualAddressSpace::allocateStack ( )
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().

+ Here is the caller graph for this function:

void * ArmV7VirtualAddressSpace::allocateStack ( size_t  stackSz)
virtual
virtual VirtualAddressSpace* ArmV7VirtualAddressSpace::clone ( )
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.

bool ArmV7VirtualAddressSpace::doMap ( physical_uintptr_t  physicalAddress,
void *  virtualAddress,
size_t  flags 
)
protected
Note
For later: when creating high-memory page table mappings, they should be in DOMAIN ONE - which holds all paging structures. This way they can be locked down appropriately.

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().

+ Here is the caller graph for this function:

size_t ArmV7VirtualAddressSpace::fromFlags ( uint32_t  Flags)
private

Convert processor's representation of the flags to the processor independant representation

Parameters
[in]Flagsthe processor specific flag representation
Returns
the proessor independant flag representation

Definition at line 91 of file armv7/VirtualAddressSpace.cc.

References VirtualAddressSpace::KernelMode, and VirtualAddressSpace::Write.

Referenced by doMap(), and getKernelModulesEnd().

+ Here is the caller graph for this function:

virtual uintptr_t ArmV7VirtualAddressSpace::getDynamicLinkerAddress ( ) const
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.

void * ArmV7VirtualAddressSpace::getEndOfHeap ( )
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().

+ Here is the caller graph for this function:

virtual uintptr_t ArmV7VirtualAddressSpace::getKernelCacheEnd ( ) const
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.

virtual uintptr_t ArmV7VirtualAddressSpace::getKernelCacheStart ( ) const
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.

virtual uintptr_t ArmV7VirtualAddressSpace::getKernelEventBlockStart ( ) const
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.

virtual uintptr_t ArmV7VirtualAddressSpace::getKernelHeapEnd ( ) const
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.

virtual uintptr_t ArmV7VirtualAddressSpace::getKernelHeapStart ( ) const
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.

virtual uintptr_t ArmV7VirtualAddressSpace::getKernelModulesEnd ( ) const
inlinevirtual
virtual uintptr_t ArmV7VirtualAddressSpace::getKernelModulesStart ( ) const
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.

virtual uintptr_t ArmV7VirtualAddressSpace::getKernelStart ( ) const
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.

void ArmV7VirtualAddressSpace::getMapping ( void *  virtualAddress,
physical_uintptr_t &  physicalAddress,
size_t &  flags 
)
virtual

Get the physical address and the flags associated with the specific virtual address.

Note
This function is only valid on memory that was mapped with VirtualAddressSpace::map() and that is still mapped or marked as swapped out.
Parameters
[in]virtualAddressthe address in the virtual address space
[out]flagsthe flags
[out]physicalAddressthe physical address

Implements VirtualAddressSpace.

Reimplemented in ArmV7KernelVirtualAddressSpace.

Definition at line 135 of file armv7/VirtualAddressSpace.cc.

bool ArmV7VirtualAddressSpace::getPageTableEntry ( void *  virtualAddress,
uint32_t *&  pageTableEntry 
)
private

Get the page table entry, if it exists and check whether a page is mapped or marked as swapped out.

Parameters
[in]virtualAddressthe virtual address
[out]pageTableEntrypointer to the page table entry
Returns
true, if the page table is present and the page mapped or marked swapped out, false otherwise

Referenced by getKernelModulesEnd().

+ Here is the caller graph for this function:

virtual uintptr_t ArmV7VirtualAddressSpace::getUserReservedStart ( ) const
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.

virtual uintptr_t ArmV7VirtualAddressSpace::getUserStart ( ) const
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.

bool ArmV7VirtualAddressSpace::initialise ( )
private

Initialises the kernel address space, called by Processor.

Definition at line 108 of file armv7/VirtualAddressSpace.cc.

Referenced by getKernelModulesEnd().

+ Here is the caller graph for this function:

bool ArmV7VirtualAddressSpace::isAddressValid ( void *  virtualAddress)
virtual

Is a particular virtual address valid?

Parameters
[in]virtualAddressthe virtual address to check
Returns
true, if the address is valid, false otherwise

Implements VirtualAddressSpace.

Definition at line 113 of file armv7/VirtualAddressSpace.cc.

bool ArmV7VirtualAddressSpace::isMapped ( void *  virtualAddress)
virtual

Checks whether a mapping the the specific virtual address exists. Pages marked as swapped out are not considered mapped.

Note
This function must be valid on all the valid addresses within the virtual address space.
Parameters
[in]virtualAddressthe virtual address
Returns
true, if a mapping exists, false otherwise

Implements VirtualAddressSpace.

Reimplemented in ArmV7KernelVirtualAddressSpace.

Definition at line 130 of file armv7/VirtualAddressSpace.cc.

bool ArmV7VirtualAddressSpace::map ( physical_uintptr_t  physicalAddress,
void *  virtualAddress,
size_t  flags 
)
virtual

Map a specific physical page (of size PhysicalMemoryManager::getPageSize()) at a specific location into the virtual address space.

Note
This function must also work on pages marked as swapped out.
Parameters
[in]physicalAddressthe address of the physical page that should be mapped into the virtual address space.
[in]virtualAddressthe virtual address at which the page apears within the virtual address space.
[in]flagsflags that describe which accesses should be allowed on the page.
Returns
true, if successfull, false otherwise

Implements VirtualAddressSpace.

Reimplemented in ArmV7KernelVirtualAddressSpace.

Definition at line 119 of file armv7/VirtualAddressSpace.cc.

References doMap().

Referenced by allocateStack(), and ArmV7PhysicalMemoryManager::PageStack::free().

+ Here is the caller graph for this function:

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

Note
This should only be used from the PhysicalMemoryManager
Parameters
[in]physicalAddressthe physical page that should be used as page table or page frame
[in]virtualAddressthe virtual address that should be checked for the existance of a page table and page frame
[in]flagsthe flags used for the mapping
Returns
true, if a page table/frame is already mapped for that address, false if the physicalAddress has been used as a page table or as a page frame.
bool ArmV7VirtualAddressSpace::memIsInHeap ( void *  pMem)
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().

ArmV7VirtualAddressSpace& ArmV7VirtualAddressSpace::operator= ( const ArmV7VirtualAddressSpace )
private

The copy-constructor

Note
Not implemented

Referenced by getKernelModulesEnd().

+ Here is the caller graph for this function:

virtual void ArmV7VirtualAddressSpace::revertToKernelAddressSpace ( )
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.

void ArmV7VirtualAddressSpace::setFlags ( void *  virtualAddress,
size_t  newFlags 
)
virtual

Set the flags of the page at a specific virtual address.

Note
The page must have been mapped with VirtualAddressSpace::map() and the page must still be mapped or marked as swapped out.
Parameters
[in]virtualAddressthe virtual address
[in]newFlagsthe flags

Implements VirtualAddressSpace.

Reimplemented in ArmV7KernelVirtualAddressSpace.

Definition at line 141 of file armv7/VirtualAddressSpace.cc.

References m_VirtualPageDirectory, and m_VirtualPageTables.

uint32_t ArmV7VirtualAddressSpace::toFlags ( size_t  flags)
private

Convert the processor independant flags to the processor's representation of the flags

Parameters
[in]flagsthe processor independant flag representation
Returns
the proessor specific flag representation

Definition at line 74 of file armv7/VirtualAddressSpace.cc.

References VirtualAddressSpace::KernelMode, and VirtualAddressSpace::Write.

Referenced by doMap(), and getKernelModulesEnd().

+ Here is the caller graph for this function:

void ArmV7VirtualAddressSpace::unmap ( void *  virtualAddress)
virtual

Remove the page at the specific virtual address from the virtual address space.

Note
This function is only valid on memory that was mapped with VirtualAddressSpace::map() and that is still mapped or marked as swapped out.
Parameters
[in]virtualAddressthe virtual address

Implements VirtualAddressSpace.

Reimplemented in ArmV7KernelVirtualAddressSpace.

Definition at line 125 of file armv7/VirtualAddressSpace.cc.

Friends And Related Function Documentation

friend class Processor
friend

Processor::switchAddressSpace() needs access to m_PhysicalPageDirectory

Definition at line 72 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

VirtualAddressSpace::create needs access to the constructor

Member Data Documentation

Vector<void *> ArmV7VirtualAddressSpace::m_freeStacks
private

List of free stacks

Definition at line 368 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

Referenced by allocateStack().

Spinlock ArmV7VirtualAddressSpace::m_Lock
private

Lock to guard against multiprocessor reentrancy.

Definition at line 371 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

Referenced by allocateStack(), and doMap().

physical_uintptr_t ArmV7VirtualAddressSpace::m_PhysicalPageDirectory
private

Physical address of the page directory

Definition at line 359 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

Referenced by ArmV7KernelVirtualAddressSpace::initialiseKernelAddressSpace().

void* ArmV7VirtualAddressSpace::m_pStackTop
private

Current top of the stacks

Definition at line 366 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

Referenced by allocateStack().

void* ArmV7VirtualAddressSpace::m_VirtualPageDirectory
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().

void* ArmV7VirtualAddressSpace::m_VirtualPageTables
private

Virtual address of the page tables

Definition at line 363 of file kernel/core/processor/armv7/VirtualAddressSpace.h.

Referenced by doMap(), and setFlags().


The documentation for this class was generated from the following files: