|
| enum | {
PRESENT = 1<<0
, RW = 1<<1
, USER = 1<<2
, ACCESS = 1<<5
,
DIRTY = 1<<6
} |
| | Page attributes. More...
|
|
| static bool | insert_mapping (mword virt, mword phys, mword attr) |
| | Inserts a 4 KB mapping into the page table.
|
| static mword | get_mapping (mword virt) |
| | Returns the page table entry for the virtual address virt, INCLUDING THE ATTRIBUTE BITS.
|
| static void * | remap (mword phys) |
| | Maps the passed physical address to the fixed virtual address REMAP_SADDR as a single 4MB page.
|
◆ anonymous enum
Page attributes.
15 {
16 PRESENT = 1<<0,
17 RW = 1<<1,
18 USER = 1<<2,
19 ACCESS = 1<<5,
20 DIRTY = 1<<6,
21 };
◆ get_mapping()
| mword Ptab::get_mapping |
( |
mword | virt | ) |
|
|
static |
Returns the page table entry for the virtual address virt, INCLUDING THE ATTRIBUTE BITS.
Get a page table entry corresponding to virtual address virt.
- Returns
- The requested page table entry.
53{
55 mword* ptab;
56
57 if ((pdir[virt >> 22] & PRESENT) == 0)
58 return 0;
59 else
61
62 return ptab[(virt >> PAGE_BITS) & 0x3ff];
63}
static void * phys2virt(mword)
Returns the virtual address that can be used to access memory with physical address phys.
Definition kalloc.cc:92
◆ insert_mapping()
| bool Ptab::insert_mapping |
( |
mword | virt, |
|
|
mword | phys, |
|
|
mword | attr ) |
|
static |
Inserts a 4 KB mapping into the page table.
Set a page table entry corresponding to virtual address virt to the combination of phys and attr.
- Parameters
-
| [in] | virt | Virtual address to be mapped. |
| [in] | phys | Physical address to map at virt. |
| [in] | attr | Page attributes such as PRESENT, RW, USER, ACCESS, DIRTY. |
- Returns
- true in case of success, false otherwise.
21{
22
24 mword* ptab;
25
26 if ((pdir[virt >> 22] & PRESENT) == 0) {
27
28 ptab =
static_cast<mword*
>(Kalloc::allocator.
alloc_page(1, Kalloc::FILL_0));
29 if (!ptab)
30 return false;
32
33 pdir[virt >> 22] = p | ACCESS | RW | PRESENT | USER;
34 } else {
35
37 }
38 assert ((phys & PAGE_MASK) == 0);
39
40 ptab[(virt >> PAGE_BITS) & 0x3ff] = (phys & ~PAGE_MASK) | (attr & PAGE_MASK);
41
42 Cpu::flush();
43 return true;
44}
static mword virt2phys(void *)
Return the physical address that is mapped from the virtual address virt (opposite of phys2virt).
Definition kalloc.cc:98
void * alloc_page(unsigned count, Fill fill=NOFILL)
Allocate count virtually contiguous pages and optionally fill them with 0x00 or 0xFF.
Definition kalloc.cc:46
◆ remap()
| void * Ptab::remap |
( |
mword | phys | ) |
|
|
static |
Maps the passed physical address to the fixed virtual address REMAP_SADDR as a single 4MB page.
This mapping is temporary, and is changed the next time this method is called.
This is useful for one-off reads from a given physical address. We cannot use Kalloc::phys2virt(), because the 1:1 mapping used by it may not cover the whole physical RAM.
66{
68
69
70 pdir[REMAP_SADDR >> 22] = 0;
71 Cpu::flush(REMAP_SADDR);
72
73
74 pdir[REMAP_SADDR >> 22] = (phys & 0xffc00000) + 0xe3;
75
76 return reinterpret_cast<void *>(REMAP_SADDR + (phys & 0x3fffff));
77}
The documentation for this class was generated from the following files: