The Pedigree Project  0.1
kernel/core/processor/mips32/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_MIPS32_VIRTUALADDRESSSPACE_H
21 #define KERNEL_PROCESSOR_MIPS32_VIRTUALADDRESSSPACE_H
22 
23 #include "pedigree/kernel/machine/mips_common/types.h"
24 #include "pedigree/kernel/processor/VirtualAddressSpace.h"
25 #include "pedigree/kernel/processor/types.h"
26 
28 #ifndef PAGE_SIZE
29 #define PAGE_SIZE 0x1000
30 #endif
31 
33 #define MIPS32_PTE_GLOBAL 0x1 // If set, the TLB ignores the current ASID.
34 #define MIPS32_PTE_VALID 0x2 // If unset, the entry is invalid.
35 #define MIPS32_PTE_DIRTY \
36  0x4 // Actually, write-enable. 1 to allow writes, 0 for read-only.
37 #define MIPS32_PTE_UNCACHED 0x10 // No caching - field C = 0x2.
38 #define MIPS32_PTE_CACHED \
39  0x18 // Cache without multiprocessor signalling - field C = 0x3
40 
97 {
100  friend class Processor;
102 
103  public:
104  //
105  // VirtualAddressSpace Interface
106  //
107  virtual bool isAddressValid(void *virtualAddress);
108  virtual bool isMapped(void *virtualAddress);
109 
110  virtual bool
111  map(physical_uintptr_t physicalAddress, void *virtualAddress, size_t flags);
112  virtual void getMapping(
113  void *virtualAddress, physical_uintptr_t &physicalAddress,
114  size_t &flags);
115  virtual void setFlags(void *virtualAddress, size_t newFlags);
116  virtual void unmap(void *virtualAddress);
117  virtual void *allocateStack();
118  virtual void freeStack(void *pStack);
119 
122  uintptr_t getPageTableChunk(uintptr_t chunkIdx);
123 
124  protected:
126  virtual ~MIPS32VirtualAddressSpace();
127 
128  private:
137 
138  void setPageTableChunk(uintptr_t chunkIdx, uintptr_t chunkAddr);
139 
141  uintptr_t generateNullChunk();
142 
145  uintptr_t m_pKusegDirectory[1024];
147  static uintptr_t m_pKseg2Directory[512];
148 
151 };
152 
155 //
156 // Virtual address space layout
157 //
158 #define USERSPACE_VIRTUAL_HEAP static_cast<uintptr_t>(0x10000000)
159 #define VIRTUAL_PAGE_DIRECTORY static_cast<uintptr_t>(0xC0000000)
160 #define KERNEL_VIRTUAL_HEAP static_cast<uintptr_t>(0xC0800000)
161 
162 #endif
MIPS32VirtualAddressSpace & operator=(const MIPS32VirtualAddressSpace &)
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)
static EXPORTED_PUBLIC VirtualAddressSpace & getKernelAddressSpace()
virtual bool isAddressValid(void *virtualAddress)
uintptr_t physicalAddress(physical_uintptr_t address) PURE
Definition: utils.h:38
The exception was caused by a hardware task switch.
Definition: Processor.h:80
virtual bool isMapped(void *virtualAddress)
virtual void unmap(void *virtualAddress)
uintptr_t getPageTableChunk(uintptr_t chunkIdx)