The Pedigree Project  0.1
kernel/core/processor/armv7/PhysicalMemoryManager.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_ARMV7_PHYSICALMEMORYMANAGER_H
21 #define KERNEL_PROCESSOR_ARMV7_PHYSICALMEMORYMANAGER_H
22 
23 #include "pedigree/kernel/BootstrapInfo.h"
24 #include "pedigree/kernel/Spinlock.h"
25 #include "pedigree/kernel/processor/PhysicalMemoryManager.h"
26 #include "pedigree/kernel/utilities/RangeList.h"
27 
34 {
35  public:
39  {
40  return m_Instance;
41  }
42 
43  //
44  // PhysicalMemoryManager Interface
45  //
46  virtual physical_uintptr_t allocatePage();
47  virtual void freePage(physical_uintptr_t page);
49  virtual void pin(physical_uintptr_t page){};
50  virtual bool allocateRegion(
51  MemoryRegion &Region, size_t cPages, size_t pageConstraints,
52  size_t Flags, physical_uintptr_t start = -1);
53 
54  void initialise(const BootstrapStruct_t &info);
55 
56  protected:
61 
62  private:
69 
72  virtual void freePageUnlocked(physical_uintptr_t page);
73 
75  virtual void unmapRegion(MemoryRegion *pRegion);
76 
81  class PageStack
82  {
83  public:
89  physical_uintptr_t allocate(size_t constraints);
92  void free(physical_uintptr_t physicalAddress);
94  inline ~PageStack()
95  {
96  }
97 
98  private:
101  PageStack(const PageStack &);
104  PageStack &operator=(const PageStack &);
105 
107 #ifdef ARM_BEAGLE
108 // physical_uintptr_t m_Stack[0x10000000 / sizeof(physical_uintptr_t)]; // 256
109 // MB, one entry per address physical_uintptr_t m_Stack[1024];
110 #else
111  physical_uintptr_t m_Stack[1];
112 #endif
113  void *m_Stack;
115  size_t m_StackMax;
117  size_t m_StackSize;
118  };
119 
122 
125 
128 
131 
134 
136  Spinlock m_Lock, m_RegionLock;
137 };
138 
141 #endif
Bootstrap structure passed to the kernel entry point.
The Stack of pages (below4GB, below64GB, no constraint).
void free(physical_uintptr_t physicalAddress)
virtual physical_uintptr_t allocatePage()
virtual bool allocateRegion(MemoryRegion &Region, size_t cPages, size_t pageConstraints, size_t Flags, physical_uintptr_t start=-1)
uintptr_t physicalAddress(physical_uintptr_t address) PURE
Definition: utils.h:38
Special memory entity in the kernel's virtual address space.
Definition: MemoryRegion.h:35
ArmV7PhysicalMemoryManager & operator=(const ArmV7PhysicalMemoryManager &)
virtual void freePage(physical_uintptr_t page)
Implementation of the PhysicalMemoryManager for common arm.
virtual void unmapRegion(MemoryRegion *pRegion)
virtual void freePageUnlocked(physical_uintptr_t page)
physical_uintptr_t allocate(size_t constraints)
PageStack & operator=(const PageStack &)