The Pedigree Project  0.1
kernel/core/processor/arm_926e/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_ARM926E_VIRTUALADDRESSSPACE_H
21 #define KERNEL_PROCESSOR_ARM926E_VIRTUALADDRESSSPACE_H
22 
23 #include "pedigree/kernel/processor/VirtualAddressSpace.h"
24 #include "pedigree/kernel/processor/types.h"
25 
33 {
36  friend class Processor;
38 
39  public:
40  //
41  // VirtualAddressSpace Interface
42  //
43  virtual bool isAddressValid(void *virtualAddress);
44  virtual bool isMapped(void *virtualAddress);
45 
46  virtual bool
47  map(physical_uintptr_t physicalAddress, void *virtualAddress, size_t flags);
48  virtual void getMapping(
49  void *virtualAddress, physical_uintptr_t &physicalAddress,
50  size_t &flags);
51  virtual void setFlags(void *virtualAddress, size_t newFlags);
52  virtual void unmap(void *virtualAddress);
53  virtual void *allocateStack();
54  virtual void freeStack(void *pStack);
55 
56  //
57  // Needed for the PhysicalMemoryManager
58  //
68  bool mapPageStructures(
69  physical_uintptr_t physicalAddress, void *virtualAddress, size_t flags);
70 
74  {
75  return 0;
76  };
77 
81  virtual void revertToKernelAddressSpace(){};
82 
83  protected:
86 
87  private:
92  struct Translation
93  {
94  uint32_t entries[4096];
95  } PACKED;
96 
98  struct SectionTable
99  {
100  uint32_t entry;
101  } PACKED;
102 
104  struct CoarseTable
105  {
106  uint32_t entries[256];
107  } PACKED;
108 
110  struct FineTable
111  {
112  uint32_t entries[1024];
113  };
114 
115  // http://www.atmel.com/dyn/resources/prod_documents/ARM_926EJS_TRM.pdf
119  {
120  uint32_t data;
121  struct Desc
122  {
123  // bits indicate size and validity, outlined Table 3-3 in doc above
124  uint32_t size_validity_1 : 1;
125  uint32_t size_validity_2 : 1;
126  uint32_t
127  always0 : 30;
128  };
129  };
131  {
132  uint32_t data;
133  struct Desc
134  {
135  // bits indicate size and validity, outlined Table 3-3 in doc above
136  uint32_t size_validity_1 : 1;
137  uint32_t size_validity_2 : 1;
138  uint32_t always0_1 : 1;
139  uint32_t always0_2 : 2;
140  uint32_t always1 : 1;
141  uint32_t domainctl : 3;
142  uint32_t always0_3 : 1;
143  uint32_t coarse_table_addr : 21;
144  };
145  };
147  {
148  uint32_t data;
150  struct Desc
151  {
152  // bits indicate size and validity, outlined Table 3-3 in doc above
153  uint32_t size_validity_1 : 1;
154  uint32_t size_validity_2 : 1;
155  uint32_t cb : 2; // cache control
156  uint32_t always1 : 1;
157  uint32_t domainctl : 3;
158  uint32_t always0 : 1;
159  uint32_t perms : 2; // access permission bits
160  uint32_t always0_2 : 7;
161  uint32_t section_address : 11;
162  };
163  };
165  {
166  uint32_t data;
167  struct Desc
168  {
169  // bits indicate size and validity, outlined Table 3-3 in doc above
170  uint32_t size_validity_1 : 1;
171  uint32_t size_validity_2 : 1;
172  uint32_t always0_1 : 1;
173  uint32_t always0_2 : 2;
174  uint32_t always1 : 1;
175  uint32_t domainctl : 3;
176  uint32_t always0_3 : 3;
177  uint32_t coarse_table_addr : 19;
178  };
179  };
180 
187  void *Heap, physical_uintptr_t PhysicalPageDirectory,
188  void *VirtualPageDirectory, void *VirtualPageTables);
189 
199 
201  bool initialise();
202 
208  bool getPageTableEntry(void *virtualAddress, uint32_t *&pageTableEntry);
212  uint32_t toFlags(size_t flags);
216  size_t fromFlags(uint32_t Flags);
217 
219  physical_uintptr_t m_PhysicalPageDirectory;
224 
227 };
228 
231 #endif
Arm926EVirtualAddressSpace & operator=(const Arm926EVirtualAddressSpace &)
uint32_t toFlags(size_t flags)
virtual bool isAddressValid(void *virtualAddress)
static EXPORTED_PUBLIC VirtualAddressSpace & getKernelAddressSpace()
bool getPageTableEntry(void *virtualAddress, uint32_t *&pageTableEntry)
uintptr_t physicalAddress(physical_uintptr_t address) PURE
Definition: utils.h:38
virtual bool isMapped(void *virtualAddress)
The exception was caused by a hardware task switch.
Definition: Processor.h:80
virtual void setFlags(void *virtualAddress, size_t newFlags)
size_t fromFlags(uint32_t Flags)
bool mapPageStructures(physical_uintptr_t physicalAddress, void *virtualAddress, size_t flags)
virtual void getMapping(void *virtualAddress, physical_uintptr_t &physicalAddress, size_t &flags)
virtual void unmap(void *virtualAddress)
virtual bool map(physical_uintptr_t physicalAddress, void *virtualAddress, size_t flags)