The Pedigree Project  0.1
MemoryRegion.cc
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 #include "pedigree/kernel/processor/MemoryRegion.h"
21 #include "pedigree/kernel/processor/PhysicalMemoryManager.h"
22 
23 MemoryRegion::MemoryRegion(const char *pName)
24  : m_VirtualAddress(0), m_PhysicalAddress(0), m_Size(0), m_pName(pName),
25  m_bNonRamMemory(false), m_bForced(false)
26 {
27 }
28 
30 {
32 }
33 
34 void MemoryRegion::free()
35 {
37 }
38 
40 {
41  return m_VirtualAddress;
42 }
43 
44 physical_uintptr_t MemoryRegion::physicalAddress() const
45 {
46  return m_PhysicalAddress;
47 }
48 
49 size_t MemoryRegion::size() const
50 {
51  return m_Size;
52 }
53 
54 const char *MemoryRegion::name() const
55 {
56  return m_pName;
57 }
58 
59 MemoryRegion::operator bool() const
60 {
61  return (m_Size != 0);
62 }
63 
64 bool MemoryRegion::physicalBoundsCheck(physical_uintptr_t address)
65 {
66  if (address >= m_PhysicalAddress && address < (m_PhysicalAddress + m_Size))
67  return true;
68  return false;
69 }
70 
71 void MemoryRegion::setNonRamMemory(bool b)
72 {
73  m_bNonRamMemory = b;
74 }
75 
76 bool MemoryRegion::getNonRamMemory()
77 {
78  return m_bNonRamMemory;
79 }
80 
81 void MemoryRegion::setForced(bool b)
82 {
83  m_bForced = b;
84 }
85 
86 bool MemoryRegion::getForced()
87 {
88  return m_bForced;
89 }
static PhysicalMemoryManager & instance()
virtual ~MemoryRegion()
Definition: MemoryRegion.cc:29
void * m_VirtualAddress
Definition: MemoryRegion.h:91
physical_uintptr_t m_PhysicalAddress
Definition: MemoryRegion.h:94
size_t m_Size
Definition: MemoryRegion.h:96
MemoryRegion(const char *pName)
Definition: MemoryRegion.cc:23
const char * m_pName
Definition: MemoryRegion.h:98
size_t size() const
Definition: MemoryRegion.cc:49
physical_uintptr_t physicalAddress() const
Definition: MemoryRegion.cc:44
virtual void unmapRegion(MemoryRegion *pRegion)=0
const char * name() const
Definition: MemoryRegion.cc:54
void * virtualAddress() const
Definition: MemoryRegion.cc:39