aboutsummaryrefslogtreecommitdiff
path: root/src/mem/vmm.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mem/vmm.c')
-rw-r--r--src/mem/vmm.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/mem/vmm.c b/src/mem/vmm.c
index f62eadf..a07dd72 100644
--- a/src/mem/vmm.c
+++ b/src/mem/vmm.c
@@ -16,15 +16,15 @@ to_vaddr(unsigned paddr)
unsigned int
vmm_map(unsigned int paddr, unsigned int vaddr)
{
- if (paddr & 0xfff || vaddr & 0xfff) return 0;
-
+ struct TableEntry *table;
const unsigned table_idx = vaddr >> 22; /* high 10 bits */
const unsigned entry_idx = (vaddr >> 12) & 0x3ff; /* low 10 bits */
- if (k_pagedir[table_idx].present == 0) return 0;
- struct TableEntry *table = (struct TableEntry *)to_vaddr(k_pagedir[table_idx].address << 12);
+ if (paddr & 0xfff || vaddr & 0xfff) return 0;
- table[entry_idx].address = paddr >> 12;
+ if (k_pagedir[table_idx].present == 0) return 0;
+ table = (struct TableEntry *)to_vaddr(k_pagedir[table_idx].address << 12);
+ table[entry_idx].address = (paddr >> 12) & 0xfffff;
table[entry_idx].present = 1;
table[entry_idx].writeable = 1;
@@ -34,10 +34,12 @@ vmm_map(unsigned int paddr, unsigned int vaddr)
void
alloc4M()
{
+ struct DirectoryEntry4MB *directory;
+
/* enable pse in cr4 */
__asm__("movl %cr4, %eax; orl $0x10, %eax; movl %eax, %cr4");
- struct DirectoryEntry4MB *directory = (struct DirectoryEntry4MB *)&k_pagedir[0x301];
+ directory = (struct DirectoryEntry4MB *)&k_pagedir[0x301];
directory->address_low = 0x1;
directory->present = 1;
directory->writeable = 1;