The Pedigree Project  0.1
Translation.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 TRANSLATION_H
21 #define TRANSLATION_H
22 
23 #include "pedigree/kernel/processor/types.h"
24 
25 #define NUM_TRANSLATIONS 256
26 
31 {
32  public:
33  struct Translation
34  {
35  uint32_t virt;
36  uint32_t size;
37  uint32_t phys;
38  uint32_t mode;
39  };
40 
41  Translations();
42  ~Translations();
43 
45  Translation getTranslation(size_t n);
46 
48  size_t getNumTranslations();
49 
51  void
52  addTranslation(uint32_t virt, uint32_t phys, uint32_t size, uint32_t mode);
53 
57  uint32_t findFreePhysicalMemory(uint32_t size, uint32_t align = 0x100000);
58 
61  void removeRange(uintptr_t start, uintptr_t end);
62 
63  private:
65  Translation m_pTranslations[NUM_TRANSLATIONS];
66 
69 };
70 #endif
void removeRange(uintptr_t start, uintptr_t end)
Definition: Translation.cc:122
Translation m_pTranslations[NUM_TRANSLATIONS]
Definition: Translation.h:65
Translation getTranslation(size_t n)
Definition: Translation.cc:57
size_t m_nTranslations
Definition: Translation.h:68
void addTranslation(uint32_t virt, uint32_t phys, uint32_t size, uint32_t mode)
Definition: Translation.cc:67
uint32_t findFreePhysicalMemory(uint32_t size, uint32_t align=0x100000)
Definition: Translation.cc:80
size_t getNumTranslations()
Definition: Translation.cc:62