The Pedigree Project
0.1
|
#include <VirtualAddressSpace.h>
Classes | |
struct | ShadowPageTable |
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 | freeStack (void *pStack) |
virtual VirtualAddressSpace * | clone () |
virtual void | revertToKernelAddressSpace () |
PPC32VirtualAddressSpace () | |
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 Stack * | allocateStack (size_t stackSz) |
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 bool | memIsInHeap (void *pMem)=0 |
virtual void * | getEndOfHeap ()=0 |
virtual uintptr_t | getKernelStart () const =0 |
virtual uintptr_t | getUserStart () const =0 |
virtual uintptr_t | getUserReservedStart () const =0 |
virtual uintptr_t | getDynamicLinkerAddress () const =0 |
virtual uintptr_t | getKernelHeapStart () const =0 |
virtual uintptr_t | getKernelHeapEnd () const =0 |
virtual uintptr_t | getKernelCacheStart () const =0 |
virtual uintptr_t | getKernelCacheEnd () const =0 |
virtual uintptr_t | getKernelEventBlockStart () const =0 |
virtual uintptr_t | getKernelModulesStart () const =0 |
virtual uintptr_t | getKernelModulesEnd () const =0 |
virtual uintptr_t | getDynamicStart () const |
virtual uintptr_t | getDynamicEnd () const |
virtual uintptr_t | getGlobalInfoBlock () const |
Public Attributes | |
VsidManager::Vsid | m_Vsid |
Public Attributes inherited from VirtualAddressSpace | |
void * | m_Heap |
void * | m_HeapEnd |
Protected Member Functions | |
virtual | ~PPC32VirtualAddressSpace () |
Protected Member Functions inherited from VirtualAddressSpace | |
VirtualAddressSpace (void *Heap) | |
Private Member Functions | |
PPC32VirtualAddressSpace (const PPC32VirtualAddressSpace &) | |
PPC32VirtualAddressSpace & | operator= (const PPC32VirtualAddressSpace &) |
bool | initialise (Translations &translations) |
void | initialRoster (Translations &translations) |
Private Attributes | |
ShadowPageTable * | m_pPageDirectory [1024] |
Static Private Attributes | |
static PPC32VirtualAddressSpace | m_KernelSpace |
Friends | |
class | Processor |
VirtualAddressSpace & | VirtualAddressSpace::getKernelAddressSpace () |
Additional Inherited Members | |
Static Public Member Functions inherited from VirtualAddressSpace | |
static EXPORTED_PUBLIC VirtualAddressSpace & | getKernelAddressSpace () |
static VirtualAddressSpace * | create () |
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 |
In PPC we have to keep a shadow page table for all address spaces, as the hashed processor page table is finite in size and thus not all mappings may be able to fit.
We use an intel-style two level page table system. These page tables are never given verbatim to the processor, however, so we are able to take some shortcuts that aren't possible in the x86 architecture.
The lower X bytes of virtual address space are reserved for the kernel, and any map(), isMapped(), setFlags(), or unmap() calls get forwarded directly to the kernel address space.
Definition at line 50 of file kernel/core/processor/ppc32/VirtualAddressSpace.h.
|
protectedvirtual |
The destructor does nothing
Definition at line 64 of file ppc32/VirtualAddressSpace.cc.
References VsidManager::instance(), m_pPageDirectory, m_Vsid, and VsidManager::returnVsid().
PPC32VirtualAddressSpace::PPC32VirtualAddressSpace | ( | ) |
The constructor for already present paging structures
Definition at line 49 of file ppc32/VirtualAddressSpace.cc.
References VsidManager::instance(), m_KernelSpace, m_pPageDirectory, m_Vsid, and VsidManager::obtainVsid().
|
private |
The copy-constructor
|
virtual |
Allocates a single stack for a thread. Will use the default kernel thread size.
Implements VirtualAddressSpace.
Definition at line 293 of file ppc32/VirtualAddressSpace.cc.
|
virtual |
Definition at line 304 of file ppc32/VirtualAddressSpace.cc.
References PhysicalMemoryManager::allocatePage(), VirtualAddressSpace::create(), PhysicalMemoryManager::instance(), VirtualAddressSpace::KernelMode, m_pPageDirectory, map(), unmap(), and VirtualAddressSpace::Write.
|
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.
Definition at line 224 of file ppc32/VirtualAddressSpace.cc.
References getMapping(), m_KernelSpace, and m_pPageDirectory.
Referenced by getMapping().
|
private |
Initialises the kernel address space, called by Processor.
Definition at line 73 of file ppc32/VirtualAddressSpace.cc.
References Translations::addTranslation(), Translations::findFreePhysicalMemory(), OpenFirmware::instance(), m_pPageDirectory, and panic().
|
private |
Adds the given translations into the page table, called by HashedPageTable.
Definition at line 111 of file ppc32/VirtualAddressSpace.cc.
References VirtualAddressSpace::CacheDisable, Translations::getNumTranslations(), Translations::getTranslation(), m_KernelSpace, m_pPageDirectory, panic(), physicalAddress(), VirtualAddressSpace::Write, and VirtualAddressSpace::WriteThrough.
|
virtual |
Is a particular virtual address valid?
[in] | virtualAddress | the virtual address to check |
Implements VirtualAddressSpace.
Definition at line 155 of file ppc32/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.
Definition at line 160 of file ppc32/VirtualAddressSpace.cc.
References isMapped(), m_KernelSpace, and m_pPageDirectory.
Referenced by isMapped().
|
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.
Definition at line 186 of file ppc32/VirtualAddressSpace.cc.
References HashedPageTable::addMapping(), HashedPageTable::instance(), m_KernelSpace, m_pPageDirectory, m_Vsid, and map().
Referenced by clone(), and map().
|
private |
The copy-constructor
|
virtual |
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 350 of file ppc32/VirtualAddressSpace.cc.
References m_pPageDirectory, and unmap().
|
virtual |
Set the flags of the page at a specific virtual address.
[in] | virtualAddress | the virtual address |
[in] | newFlags | the flags |
Implements VirtualAddressSpace.
Definition at line 248 of file ppc32/VirtualAddressSpace.cc.
References m_KernelSpace, m_pPageDirectory, and setFlags().
Referenced by setFlags().
|
virtual |
Remove the page at the specific virtual address from the virtual address space.
[in] | virtualAddress | the virtual address |
Implements VirtualAddressSpace.
Definition at line 269 of file ppc32/VirtualAddressSpace.cc.
References HashedPageTable::instance(), m_KernelSpace, m_pPageDirectory, m_Vsid, HashedPageTable::removeMapping(), and unmap().
Referenced by clone(), revertToKernelAddressSpace(), and unmap().
|
friend |
Processor::switchAddressSpace() needs access to m_PhysicalPageDirectory
Definition at line 54 of file kernel/core/processor/ppc32/VirtualAddressSpace.h.
|
staticprivate |
The kernel virtual address space
Definition at line 108 of file kernel/core/processor/ppc32/VirtualAddressSpace.h.
Referenced by getMapping(), initialRoster(), isMapped(), map(), PPC32VirtualAddressSpace(), setFlags(), and unmap().
|
private |
The x86-style shadow page directory
Definition at line 111 of file kernel/core/processor/ppc32/VirtualAddressSpace.h.
Referenced by clone(), getMapping(), initialise(), initialRoster(), isMapped(), map(), PPC32VirtualAddressSpace(), revertToKernelAddressSpace(), setFlags(), unmap(), and ~PPC32VirtualAddressSpace().
VsidManager::Vsid PPC32VirtualAddressSpace::m_Vsid |
The VSIDs - Virtual segment identifiers
Definition at line 115 of file kernel/core/processor/ppc32/VirtualAddressSpace.h.
Referenced by map(), PPC32VirtualAddressSpace(), unmap(), and ~PPC32VirtualAddressSpace().