The Pedigree Project  0.1
kernel/core/processor/ppc32/VirtualAddressSpace.h
1 /*
2  * Copyright (c) 2008-2014, Pedigree Developers
3  *
4  * Please see the CONTRIB file in the root of the source tree for a full
5  * list of contributors.
6  *
7  * Permission to use, copy, modify, and distribute this software for any
8  * purpose with or without fee is hereby granted, provided that the above
9  * copyright notice and this permission notice appear in all copies.
10  *
11  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
12  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
13  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
14  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
15  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
16  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
17  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18  */
19 
20 #ifndef KERNEL_PROCESSOR_PPC32_VIRTUALADDRESSSPACE_H
21 #define KERNEL_PROCESSOR_PPC32_VIRTUALADDRESSSPACE_H
22 
23 #include "../ppc_common/VsidManager.h"
24 #include "Translation.h"
25 #include "pedigree/kernel/machine/ppc_common/types.h"
26 #include "pedigree/kernel/processor/VirtualAddressSpace.h"
27 #include "pedigree/kernel/processor/types.h"
28 
30 #ifndef PAGE_SIZE
31 #define PAGE_SIZE 0x1000
32 #endif
33 
51 {
54  friend class Processor;
56 
57  public:
58  //
59  // VirtualAddressSpace Interface
60  //
61  virtual bool isAddressValid(void *virtualAddress);
62  virtual bool isMapped(void *virtualAddress);
63 
64  virtual bool
65  map(physical_uintptr_t physicalAddress, void *virtualAddress, size_t flags);
66  virtual void getMapping(
67  void *virtualAddress, physical_uintptr_t &physicalAddress,
68  size_t &flags);
69  virtual void setFlags(void *virtualAddress, size_t newFlags);
70  virtual void unmap(void *virtualAddress);
71  virtual void *allocateStack();
72  virtual void freeStack(void *pStack);
73 
74  virtual VirtualAddressSpace *clone();
75  virtual void revertToKernelAddressSpace();
76 
77  protected:
79  virtual ~PPC32VirtualAddressSpace();
80 
81  private:
84  {
85  uint32_t entries[1024];
86  };
87 
88  public:
91 
92  private:
99 
101  bool initialise(Translations &translations);
102 
105  void initialRoster(Translations &translations);
106 
109 
112 
113  public:
116 };
117 
120 //
121 // Virtual address space layout
122 //
123 #define KERNEL_INITIAL_PAGE_TABLES static_cast<uintptr_t>(0xC0000000)
124 #define KERNEL_SPACE_START static_cast<uintptr_t>(0x80000000)
125 #define USERSPACE_VIRTUAL_HEAP static_cast<uintptr_t>(0x60000000)
126 #define KERNEL_VIRTUAL_HEAP static_cast<uintptr_t>(0xD0000000)
127 #define KERNEL_VIRTUAL_MEMORYREGION_ADDRESS static_cast<uintptr_t>(0xA0000000)
128 #define KERNEL_VIRTUAL_MEMORYREGION_SIZE static_cast<uintptr_t>(0x20000000)
129 #define KERNEL_VIRTUAL_TEMP1 reinterpret_cast<void *>(0xEFFFF000)
130 
131 #endif
virtual void setFlags(void *virtualAddress, size_t newFlags)
static EXPORTED_PUBLIC VirtualAddressSpace & getKernelAddressSpace()
virtual bool isAddressValid(void *virtualAddress)
uintptr_t physicalAddress(physical_uintptr_t address) PURE
Definition: utils.h:38
virtual VirtualAddressSpace * clone()
bool initialise(Translations &translations)
virtual void unmap(void *virtualAddress)
The exception was caused by a hardware task switch.
Definition: Processor.h:80
virtual void getMapping(void *virtualAddress, physical_uintptr_t &physicalAddress, size_t &flags)
virtual bool isMapped(void *virtualAddress)
uint32_t Vsid
Definition: VsidManager.h:45
virtual bool map(physical_uintptr_t physicalAddress, void *virtualAddress, size_t flags)
void initialRoster(Translations &translations)
PPC32VirtualAddressSpace & operator=(const PPC32VirtualAddressSpace &)