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

#include <VirtualAddressSpace.h>

+ Inheritance diagram for PPC32VirtualAddressSpace:
+ Collaboration diagram for PPC32VirtualAddressSpace:

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 VirtualAddressSpaceclone ()
 
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 StackallocateStack (size_t stackSz)
 
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 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 &)
 
PPC32VirtualAddressSpaceoperator= (const PPC32VirtualAddressSpace &)
 
bool initialise (Translations &translations)
 
void initialRoster (Translations &translations)
 

Private Attributes

ShadowPageTablem_pPageDirectory [1024]
 

Static Private Attributes

static PPC32VirtualAddressSpace m_KernelSpace
 

Friends

class Processor
 
VirtualAddressSpaceVirtualAddressSpace::getKernelAddressSpace ()
 

Additional Inherited Members

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

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.

Constructor & Destructor Documentation

PPC32VirtualAddressSpace::~PPC32VirtualAddressSpace ( )
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().

PPC32VirtualAddressSpace::PPC32VirtualAddressSpace ( const PPC32VirtualAddressSpace )
private

The copy-constructor

Note
NOT implemented

Member Function Documentation

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

VirtualAddressSpace * PPC32VirtualAddressSpace::clone ( )
virtual
void PPC32VirtualAddressSpace::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.

Definition at line 224 of file ppc32/VirtualAddressSpace.cc.

References getMapping(), m_KernelSpace, and m_pPageDirectory.

Referenced by getMapping().

+ Here is the caller graph for this function:

bool PPC32VirtualAddressSpace::initialise ( Translations translations)
private

Initialises the kernel address space, called by Processor.

Todo:
the 0x6a is temporary and wrong. Find a proper mode. (0x2 doesn't seem to work)
Todo:
Holy magic numbers, batman! the 0x100 is a bit hardcoded, isn't it?

Definition at line 73 of file ppc32/VirtualAddressSpace.cc.

References Translations::addTranslation(), Translations::findFreePhysicalMemory(), OpenFirmware::instance(), m_pPageDirectory, and panic().

void PPC32VirtualAddressSpace::initialRoster ( Translations translations)
private
bool PPC32VirtualAddressSpace::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 155 of file ppc32/VirtualAddressSpace.cc.

bool PPC32VirtualAddressSpace::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.

Definition at line 160 of file ppc32/VirtualAddressSpace.cc.

References isMapped(), m_KernelSpace, and m_pPageDirectory.

Referenced by isMapped().

+ Here is the caller graph for this function:

bool PPC32VirtualAddressSpace::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.

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

+ Here is the caller graph for this function:

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

The copy-constructor

Note
Not implemented
void PPC32VirtualAddressSpace::revertToKernelAddressSpace ( )
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().

void PPC32VirtualAddressSpace::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.

Definition at line 248 of file ppc32/VirtualAddressSpace.cc.

References m_KernelSpace, m_pPageDirectory, and setFlags().

Referenced by setFlags().

+ Here is the caller graph for this function:

void PPC32VirtualAddressSpace::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.

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

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend class Processor
friend

Processor::switchAddressSpace() needs access to m_PhysicalPageDirectory

Definition at line 54 of file kernel/core/processor/ppc32/VirtualAddressSpace.h.

Member Data Documentation

PPC32VirtualAddressSpace PPC32VirtualAddressSpace::m_KernelSpace
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().

ShadowPageTable* PPC32VirtualAddressSpace::m_pPageDirectory[1024]
private
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().


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