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
24 : m_VirtualAddress(0),
25 m_PhysicalAddress(0),
26 m_Size(0),
27 m_pName(pName),
28 m_bNonRamMemory(false),
29 m_bForced(false),
30 m_bPageBacked(false),
31 m_bAnonymous(false) {}
32
36
37void MemoryRegion::free() {
39}
40
42 return m_VirtualAddress;
43}
44
45physical_uintptr_t MemoryRegion::physicalAddress() const {
46 return m_PhysicalAddress;
47}
48
49size_t MemoryRegion::size() const {
50 return m_Size;
51}
52
53const char* MemoryRegion::name() const {
54 return m_pName;
55}
56
57MemoryRegion::operator bool() const {
58 return (m_Size != 0);
59}
60
61bool MemoryRegion::physicalBoundsCheck(physical_uintptr_t address) {
62 if (address >= m_PhysicalAddress && address < (m_PhysicalAddress + m_Size))
63 return true;
64 return false;
65}
66
67void MemoryRegion::setNonRamMemory(bool b) {
68 m_bNonRamMemory = b;
69}
70
71bool MemoryRegion::getNonRamMemory() {
72 return m_bNonRamMemory;
73}
74
75void MemoryRegion::setForced(bool b) {
76 m_bForced = b;
77}
78
79bool MemoryRegion::getForced() {
80 return m_bForced;
81}
82
83void MemoryRegion::setAnonymous(bool b) {
84 m_bAnonymous = b;
85}
86
87bool MemoryRegion::getAnonymous() const {
88 return m_bAnonymous;
89}
void * m_VirtualAddress
const char * m_pName
const char * name() const
void * virtualAddress() const
virtual ~MemoryRegion()
MemoryRegion(const char *pName)
physical_uintptr_t physicalAddress() const
size_t size() const
physical_uintptr_t m_PhysicalAddress
static PhysicalMemoryManager & instance()
virtual void unmapRegion(MemoryRegion *pRegion)=0