Skip to content

Commit 3834f5d

Browse files
committedOct 17, 2012
Add support for page permission bits in BIOS
1 parent de964d4 commit 3834f5d

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed
 

Diff for: ‎software/include/hal/mmu.h

+2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@
3131
#define MAPPING_COPY_ON_WRITE (1 << 4)
3232
#define MAPPING_IS_VALID (1 << 5)
3333

34+
#define MAPPING_CAN_RW (MAPPING_CAN_READ | MAPPING_CAN_WRITE)
35+
3436
struct mmu_mapping {
3537

3638
unsigned int vaddr;

Diff for: ‎software/libbase/mmu.c

+9-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ unsigned int mmu_map(unsigned int vaddr, unsigned int paddr, char metadata) {
4747
{
4848
puts("Already mapped, updating metadata !");
4949
mappings[i].metadata |= metadata;
50+
// set the permission bits in lower bits of paddr to be written in the TLB
51+
paddr |= (metadata & MAPPING_CAN_RW);
52+
5053
if (mappings[i].metadata & ITLB_MAPPING)
5154
mmu_itlb_map(vaddr, paddr);
5255
if (mappings[i].metadata & DTLB_MAPPING)
@@ -57,6 +60,9 @@ unsigned int mmu_map(unsigned int vaddr, unsigned int paddr, char metadata) {
5760
printf("Vaddr already mapped to another Paddr (0x%08X), overwritting...\n", mappings[i].paddr);
5861
mappings[i].paddr = paddr;
5962
mappings[i].metadata = (metadata | MAPPING_IS_VALID);
63+
// set the permission bits in lower bits of paddr to be written in the TLB
64+
paddr |= (metadata & MAPPING_CAN_RW);
65+
6066
if (mappings[i].metadata & ITLB_MAPPING)
6167
mmu_itlb_map(vaddr, paddr);
6268
if (mappings[i].metadata & DTLB_MAPPING)
@@ -74,6 +80,8 @@ unsigned int mmu_map(unsigned int vaddr, unsigned int paddr, char metadata) {
7480
mappings[empty_slot].vaddr = vaddr;
7581
mappings[empty_slot].paddr = paddr;
7682
mappings[empty_slot].metadata = (metadata | MAPPING_IS_VALID);
83+
// set the permission bits in lower bits of paddr to be written in the TLB
84+
paddr |= (metadata & MAPPING_CAN_RW);
7785

7886
if (metadata & ITLB_MAPPING)
7987
mmu_itlb_map(vaddr, paddr);
@@ -92,7 +100,7 @@ unsigned int get_mmu_mapping_for(unsigned int vaddr) {
92100

93101
for (i = 0 ; i < MAX_MMU_SLOTS ; ++i)
94102
if ((mappings[i].metadata & MAPPING_IS_VALID) && (vaddr == mappings[i].vaddr))
95-
return mappings[i].paddr;
103+
return get_pfn(mappings[i].paddr);
96104

97105
return A_BAD_ADDR;
98106
}

0 commit comments

Comments
 (0)
Please sign in to comment.