Changeset c049309 in mainline for kernel/arch/xen32/src/mm/frame.c
- Timestamp:
- 2006-07-30T15:57:07Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b3e8c90
- Parents:
- 764c302
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/xen32/src/mm/frame.c
r764c302 rc049309 50 50 uintptr_t last_frame = 0; 51 51 52 #define L 1_PT_SHIFT 1053 #define L 2_PT_SHIFT 052 #define L0_PT_SHIFT 10 53 #define L3_PT_SHIFT 0 54 54 55 #define L 1_PT_ENTRIES 102456 #define L 2_PT_ENTRIES 102455 #define L0_PT_ENTRIES 1024 56 #define L3_PT_ENTRIES 1024 57 57 58 #define L 1_OFFSET_MASK (L1_PT_ENTRIES - 1)59 #define L 2_OFFSET_MASK (L2_PT_ENTRIES - 1)58 #define L0_INDEX_MASK (L0_PT_ENTRIES - 1) 59 #define L3_INDEX_MASK (L3_PT_ENTRIES - 1) 60 60 61 #define PFN2PTL 1_OFFSET(pfn) ((pfn >> L1_PT_SHIFT) & L1_OFFSET_MASK)62 #define PFN2PTL 2_OFFSET(pfn) ((pfn >> L2_PT_SHIFT) & L2_OFFSET_MASK)61 #define PFN2PTL0_INDEX(pfn) ((pfn >> L0_PT_SHIFT) & L0_INDEX_MASK) 62 #define PFN2PTL3_INDEX(pfn) ((pfn >> L3_PT_SHIFT) & L3_INDEX_MASK) 63 63 64 64 #define PAGE_MASK (~(PAGE_SIZE - 1)) 65 66 #define PTE2ADDR(pte) (pte & PAGE_MASK)67 65 68 66 #define _PAGE_PRESENT 0x001UL … … 77 75 #define _PAGE_GLOBAL 0x100UL 78 76 79 #define L 1_PROT (_PAGE_PRESENT | _PAGE_ACCESSED)80 #define L 2_PROT (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED)77 #define L0_PROT (_PAGE_PRESENT | _PAGE_ACCESSED) 78 #define L3_PROT (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED) 81 79 82 80 void frame_arch_init(void) … … 84 82 if (config.cpu_active == 1) { 85 83 /* The only memory zone starts just after page table */ 86 pfn_t start = ADDR2PFN(ALIGN_UP(KA2PA(start_info.pt _base), PAGE_SIZE)) + start_info.nr_pt_frames;87 size_t size = start_info. nr_pages - start;84 pfn_t start = ADDR2PFN(ALIGN_UP(KA2PA(start_info.ptl0), PAGE_SIZE)) + start_info.pt_frames; 85 size_t size = start_info.frames - start; 88 86 89 87 /* Create identity mapping */ … … 91 89 count_t count = 0; 92 90 for (phys = start; phys < start + size; phys++) { 93 mmu_update_t updates[L 2_PT_ENTRIES];91 mmu_update_t updates[L3_PT_ENTRIES]; 94 92 pfn_t virt = ADDR2PFN(PA2KA(PFN2ADDR(phys))); 95 93 96 size_t ptl 1_offset = PFN2PTL1_OFFSET(virt);97 size_t ptl 2_offset = PFN2PTL2_OFFSET(virt);94 size_t ptl0_index = PFN2PTL0_INDEX(virt); 95 size_t ptl3_index = PFN2PTL3_INDEX(virt); 98 96 99 unsigned long *ptl2_base = (unsigned long *) PTE2ADDR(start_info.pt_base[ptl1_offset]);97 pte_t *ptl3 = (pte_t *) PFN2ADDR(start_info.ptl0[ptl0_index].frame_address); 100 98 101 if (ptl 2_base== 0) {99 if (ptl3 == 0) { 102 100 mmuext_op_t mmu_ext; 103 101 … … 107 105 memsetb(PFN2ADDR(virt2), PAGE_SIZE, 0); 108 106 109 size_t ptl 1_offset2 = PFN2PTL1_OFFSET(virt2);110 size_t ptl 2_offset2 = PFN2PTL2_OFFSET(virt2);111 unsigned long *ptl2_base2 = (unsigned long *) PTE2ADDR(start_info.pt_base[ptl1_offset2]);107 size_t ptl0_index2 = PFN2PTL0_INDEX(virt2); 108 size_t ptl3_index2 = PFN2PTL3_INDEX(virt2); 109 pte_t *ptl3_2 = (pte_t *) PFN2ADDR(start_info.ptl0[ptl0_index2].frame_address); 112 110 113 if (ptl 2_base2 == 0)111 if (ptl3_2 == 0) 114 112 panic("Unable to find page table reference"); 115 113 116 updates[count].ptr = (uintptr_t) &ptl 2_base2[ptl2_offset2];117 updates[count].val = P FN2ADDR(start_info.mfn_list[start]) | L1_PROT;114 updates[count].ptr = (uintptr_t) &ptl3_2[ptl3_index2]; 115 updates[count].val = PA2MA(PFN2ADDR(start)) | L0_PROT; 118 116 if (xen_mmu_update(updates, count + 1, NULL, DOMID_SELF) < 0) 119 117 panic("Unable to map new page table"); … … 121 119 122 120 mmu_ext.cmd = MMUEXT_PIN_L1_TABLE; 123 mmu_ext.arg1.mfn = start_info.mfn_list[start];121 mmu_ext.arg1.mfn = ADDR2PFN(PA2MA(PFN2ADDR(start))); 124 122 if (xen_mmuext_op(&mmu_ext, 1, NULL, DOMID_SELF) < 0) 125 123 panic("Error pinning new page table"); 126 124 127 unsigned long *ptl0 = (unsigned long *) PFN2ADDR(start_info.mfn_list[ADDR2PFN(KA2PA(start_info.pt_base))]);125 pte_t *ptl0 = (pte_t *) PA2MA(KA2PA(start_info.ptl0)); 128 126 129 updates[count].ptr = (uintptr_t) &ptl0[ptl 1_offset];130 updates[count].val = P FN2ADDR(start_info.mfn_list[start]) | L2_PROT;127 updates[count].ptr = (uintptr_t) &ptl0[ptl0_index]; 128 updates[count].val = PA2MA(PFN2ADDR(start)) | L3_PROT; 131 129 if (xen_mmu_update(updates, count + 1, NULL, DOMID_SELF) < 0) 132 130 panic("Unable to update PTE for page table"); 133 131 count = 0; 134 132 135 ptl 2_base = (unsigned long *) PTE2ADDR(start_info.pt_base[ptl1_offset]);133 ptl3 = (pte_t *) PFN2ADDR(start_info.ptl0[ptl0_index].frame_address); 136 134 start++; 137 135 size--; 138 136 } 139 137 140 updates[count].ptr = (uintptr_t) &ptl 2_base[ptl2_offset];141 updates[count].val = P FN2ADDR(start_info.mfn_list[phys]) | L2_PROT;138 updates[count].ptr = (uintptr_t) &ptl3[ptl3_index]; 139 updates[count].val = PA2MA(PFN2ADDR(phys)) | L3_PROT; 142 140 count++; 143 141 144 if ((count == L 2_PT_ENTRIES) || (phys + 1 == start + size)) {142 if ((count == L3_PT_ENTRIES) || (phys + 1 == start + size)) { 145 143 if (xen_mmu_update(updates, count, NULL, DOMID_SELF) < 0) 146 144 panic("Unable to update PTE");
Note:
See TracChangeset
for help on using the changeset viewer.