Skip to content
This repository
Browse code

Add support for page permission bits in BIOS

  • Loading branch information...
commit 3834f5dd783f813a2bb4ce71de31c9591a505456 1 parent de964d4
Yann Sionneau authored October 17, 2012
2  software/include/hal/mmu.h
@@ -31,6 +31,8 @@
31 31
 #define MAPPING_COPY_ON_WRITE	(1 << 4)
32 32
 #define MAPPING_IS_VALID	(1 << 5)
33 33
 
  34
+#define MAPPING_CAN_RW		(MAPPING_CAN_READ | MAPPING_CAN_WRITE)
  35
+
34 36
 struct mmu_mapping {
35 37
 
36 38
 	unsigned int vaddr;
10  software/libbase/mmu.c
@@ -47,6 +47,9 @@ unsigned int mmu_map(unsigned int vaddr, unsigned int paddr, char metadata) {
47 47
 		{
48 48
 			puts("Already mapped, updating metadata !");
49 49
 			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
+
50 53
 			if (mappings[i].metadata & ITLB_MAPPING)
51 54
 				mmu_itlb_map(vaddr, paddr);
52 55
 			if (mappings[i].metadata & DTLB_MAPPING)
@@ -57,6 +60,9 @@ unsigned int mmu_map(unsigned int vaddr, unsigned int paddr, char metadata) {
57 60
 			printf("Vaddr already mapped to another Paddr (0x%08X), overwritting...\n", mappings[i].paddr);
58 61
 			mappings[i].paddr = paddr;
59 62
 			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
+
60 66
 			if (mappings[i].metadata & ITLB_MAPPING)
61 67
 				mmu_itlb_map(vaddr, paddr);
62 68
 			if (mappings[i].metadata & DTLB_MAPPING)
@@ -74,6 +80,8 @@ unsigned int mmu_map(unsigned int vaddr, unsigned int paddr, char metadata) {
74 80
 	mappings[empty_slot].vaddr = vaddr;
75 81
 	mappings[empty_slot].paddr = paddr;
76 82
 	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);
77 85
 
78 86
 	if (metadata & ITLB_MAPPING)
79 87
 		mmu_itlb_map(vaddr, paddr);
@@ -92,7 +100,7 @@ unsigned int get_mmu_mapping_for(unsigned int vaddr) {
92 100
 
93 101
 	for (i = 0 ; i < MAX_MMU_SLOTS ; ++i)
94 102
 		if ((mappings[i].metadata & MAPPING_IS_VALID) && (vaddr == mappings[i].vaddr))
95  
-			return mappings[i].paddr;
  103
+			return get_pfn(mappings[i].paddr);
96 104
 
97 105
 	return A_BAD_ADDR;
98 106
 }

0 notes on commit 3834f5d

Please sign in to comment.
Something went wrong with that request. Please try again.