Changeset c59dd1a2 in mainline
- Timestamp:
- 2006-07-25T00:47:29Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a0c12f5
- Parents:
- aecf79f
- Location:
- kernel/arch
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/ia32/include/types.h
raecf79f rc59dd1a2 62 62 /** @} 63 63 */ 64 -
kernel/arch/xen32/include/asm.h
raecf79f rc59dd1a2 155 155 static inline ipl_t interrupts_enable(void) 156 156 { 157 ipl_t v ;158 __asm__ volatile (157 ipl_t v = 0; 158 /* __asm__ volatile ( 159 159 "pushf\n\t" 160 160 "popl %0\n\t" 161 161 "sti\n" 162 162 : "=r" (v) 163 ); 163 );*/ 164 164 return v; 165 165 } … … 174 174 static inline ipl_t interrupts_disable(void) 175 175 { 176 ipl_t v ;177 __asm__ volatile (176 ipl_t v = 0; 177 /* __asm__ volatile ( 178 178 "pushf\n\t" 179 179 "popl %0\n\t" 180 180 "cli\n" 181 181 : "=r" (v) 182 ); 182 );*/ 183 183 return v; 184 184 } … … 192 192 static inline void interrupts_restore(ipl_t ipl) 193 193 { 194 __asm__ volatile (194 /* __asm__ volatile ( 195 195 "pushl %0\n\t" 196 196 "popf\n" 197 197 : : "r" (ipl) 198 ); 198 );*/ 199 199 } 200 200 … … 205 205 static inline ipl_t interrupts_read(void) 206 206 { 207 ipl_t v ;208 __asm__ volatile (207 ipl_t v = 0; 208 /* __asm__ volatile ( 209 209 "pushf\n\t" 210 210 "popl %0\n" 211 211 : "=r" (v) 212 ); 212 );*/ 213 213 return v; 214 214 } -
kernel/arch/xen32/include/boot/boot.h
raecf79f rc59dd1a2 47 47 char magic[32]; /**< "xen-<version>-<platform>" */ 48 48 unsigned long nr_pages; /**< Total pages allocated to this domain */ 49 unsigned long shared_info; /**< Physicaladdress of shared info struct */49 void *shared_info; /**< Machine address of shared info struct */ 50 50 uint32_t flags; /**< SIF_xxx flags */ 51 unsigned long store_mfn; /**< Physicalpage number of shared page */51 void *store_mfn; /**< Machine page number of shared page */ 52 52 uint32_t store_evtchn; /**< Event channel for store communication */ 53 unsigned long console_mfn; /**< Physicaladdress of console page */53 void *console_mfn; /**< Machine address of console page */ 54 54 uint32_t console_evtchn; /**< Event channel for console messages */ 55 unsigned long pt_base;/**< Virtual address of page directory */55 unsigned long *pt_base; /**< Virtual address of page directory */ 56 56 unsigned long nr_pt_frames; /**< Number of bootstrap p.t. frames */ 57 unsigned long mfn_list;/**< Virtual address of page-frame list */58 unsigned long mod_start;/**< Virtual address of pre-loaded module */57 unsigned long *mfn_list; /**< Virtual address of page-frame list */ 58 void *mod_start; /**< Virtual address of pre-loaded module */ 59 59 unsigned long mod_len; /**< Size (bytes) of pre-loaded module */ 60 60 int8_t cmd_line[GUEST_CMDLINE]; -
kernel/arch/xen32/include/hypercall.h
raecf79f rc59dd1a2 34 34 35 35 36 typedef uint16_t domid_t; 37 38 typedef struct { 39 uint64_t ptr; /**< Machine address of PTE */ 40 uint64_t val; /**< New contents of PTE */ 41 } mmu_update_t; 42 43 typedef struct { 44 unsigned int cmd; 45 union { 46 unsigned long mfn; 47 unsigned long linear_addr; 48 } arg1; 49 union { 50 unsigned int nr_ents; 51 void *vcpumask; 52 } arg2; 53 } mmuext_op_t; 54 55 56 #define XEN_MMU_UPDATE 1 36 57 #define XEN_CONSOLE_IO 18 58 #define XEN_MMUEXT_OP 26 37 59 38 60 … … 44 66 45 67 68 #define MMUEXT_PIN_L1_TABLE 0 69 #define MMUEXT_PIN_L2_TABLE 1 70 #define MMUEXT_PIN_L3_TABLE 2 71 #define MMUEXT_PIN_L4_TABLE 3 72 #define MMUEXT_UNPIN_TABLE 4 73 #define MMUEXT_NEW_BASEPTR 5 74 #define MMUEXT_TLB_FLUSH_LOCAL 6 75 #define MMUEXT_INVLPG_LOCAL 7 76 #define MMUEXT_TLB_FLUSH_MULTI 8 77 #define MMUEXT_INVLPG_MULTI 9 78 #define MMUEXT_TLB_FLUSH_ALL 10 79 #define MMUEXT_INVLPG_ALL 11 80 #define MMUEXT_FLUSH_CACHE 12 81 #define MMUEXT_SET_LDT 13 82 #define MMUEXT_NEW_USER_BASEPTR 15 83 84 85 #define DOMID_SELF (0x7FF0U) 86 #define DOMID_IO (0x7FF1U) 87 88 46 89 #define hypercall0(id) \ 47 90 ({ \ … … 142 185 143 186 144 static inline int xen_console_io(const int cmd, constint count, const char *str)187 static inline int xen_console_io(const unsigned int cmd, const unsigned int count, const char *str) 145 188 { 146 189 return hypercall3(XEN_CONSOLE_IO, cmd, count, str); 147 190 } 148 191 192 static inline int xen_mmu_update(const mmu_update_t *req, const unsigned int count, unsigned int *success_count, domid_t domid) 193 { 194 return hypercall4(XEN_MMU_UPDATE, req, count, success_count, domid); 195 } 196 197 static inline int xen_mmuext_op(const mmuext_op_t *op, const unsigned int count, unsigned int *success_count, domid_t domid) 198 { 199 return hypercall4(XEN_MMUEXT_OP, op, count, success_count, domid); 200 } 201 149 202 #endif -
kernel/arch/xen32/src/mm/frame.c
raecf79f rc59dd1a2 39 39 #include <config.h> 40 40 #include <arch/boot/boot.h> 41 #include <arch/hypercall.h> 41 42 #include <panic.h> 42 43 #include <debug.h> … … 44 45 #include <macros.h> 45 46 46 #include <print.h>47 47 #include <console/cmd.h> 48 48 #include <console/kconsole.h> … … 50 50 uintptr_t last_frame = 0; 51 51 52 #define L1_PT_SHIFT 10 53 #define L2_PT_SHIFT 0 54 55 #define L1_OFFSET_MASK 0x3ff 56 #define L2_OFFSET_MASK 0x3ff 57 58 #define PFN2PTL1_OFFSET(pfn) ((pfn >> L1_PT_SHIFT) & L1_OFFSET_MASK) 59 #define PFN2PTL2_OFFSET(pfn) ((pfn >> L2_PT_SHIFT) & L2_OFFSET_MASK) 60 61 #define PAGE_MASK (~(PAGE_SIZE - 1)) 62 63 #define PTE2ADDR(pte) (pte & PAGE_MASK) 64 65 #define _PAGE_PRESENT 0x001UL 66 #define _PAGE_RW 0x002UL 67 #define _PAGE_USER 0x004UL 68 #define _PAGE_PWT 0x008UL 69 #define _PAGE_PCD 0x010UL 70 #define _PAGE_ACCESSED 0x020UL 71 #define _PAGE_DIRTY 0x040UL 72 #define _PAGE_PAT 0x080UL 73 #define _PAGE_PSE 0x080UL 74 #define _PAGE_GLOBAL 0x100UL 75 76 #define L1_PROT (_PAGE_PRESENT | _PAGE_ACCESSED) 77 #define L2_PROT (_PAGE_PRESENT | _PAGE_RW | _PAGE_ACCESSED) 78 52 79 void frame_arch_init(void) 53 80 { 54 81 if (config.cpu_active == 1) { 82 /* The only memory zone starts just after page table */ 55 83 pfn_t start = ADDR2PFN(ALIGN_UP(KA2PA(start_info.pt_base), PAGE_SIZE)) + start_info.nr_pt_frames; 56 84 size_t size = start_info.nr_pages - start; 85 86 /* Create identity mapping */ 87 pfn_t phys; 88 for (phys = start; phys < start + size; phys++) { 89 mmu_update_t updates[1]; 90 pfn_t virt = ADDR2PFN(PA2KA(PFN2ADDR(phys))); 91 92 size_t ptl1_offset = PFN2PTL1_OFFSET(virt); 93 size_t ptl2_offset = PFN2PTL2_OFFSET(virt); 94 95 unsigned long *ptl2_base = (unsigned long *) PTE2ADDR(start_info.pt_base[ptl1_offset]); 96 97 if (ptl2_base == 0) { 98 mmuext_op_t mmu_ext; 99 100 pfn_t virt2 = ADDR2PFN(PA2KA(PFN2ADDR(start))); 101 102 /* New L1 page table entry needed */ 103 memsetb(PFN2ADDR(virt2), PAGE_SIZE, 0); 104 105 size_t ptl1_offset2 = PFN2PTL1_OFFSET(virt2); 106 size_t ptl2_offset2 = PFN2PTL2_OFFSET(virt2); 107 unsigned long *ptl2_base2 = (unsigned long *) PTE2ADDR(start_info.pt_base[ptl1_offset2]); 108 109 if (ptl2_base2 == 0) 110 panic("Unable to find page table reference"); 111 112 updates[0].ptr = (uintptr_t) &ptl2_base2[ptl2_offset2]; 113 updates[0].val = PFN2ADDR(start_info.mfn_list[start]) | L1_PROT; 114 if (xen_mmu_update(updates, 1, NULL, DOMID_SELF) < 0) 115 panic("Unable to map new page table"); 116 117 mmu_ext.cmd = MMUEXT_PIN_L1_TABLE; 118 mmu_ext.arg1.mfn = start_info.mfn_list[start]; 119 if (xen_mmuext_op(&mmu_ext, 1, NULL, DOMID_SELF) < 0) 120 panic("Error pinning new page table"); 121 122 unsigned long *ptl0 = (unsigned long *) PFN2ADDR(start_info.mfn_list[ADDR2PFN(KA2PA(start_info.pt_base))]); 123 124 updates[0].ptr = (uintptr_t) &ptl0[ptl1_offset]; 125 updates[0].val = PFN2ADDR(start_info.mfn_list[start]) | L2_PROT; 126 if (xen_mmu_update(updates, 1, NULL, DOMID_SELF) < 0) 127 panic("Unable to update PTE for page table"); 128 129 ptl2_base = (unsigned long *) PTE2ADDR(start_info.pt_base[ptl1_offset]); 130 start++; 131 size--; 132 } 133 134 updates[0].ptr = (uintptr_t) &ptl2_base[ptl2_offset]; 135 updates[0].val = PFN2ADDR(start_info.mfn_list[phys]) | L2_PROT; 136 if (xen_mmu_update(updates, 1, NULL, DOMID_SELF) < 0) 137 panic("Unable to update PTE"); 138 } 57 139 58 140 zone_create(start, size, start, 0); -
kernel/arch/xen32/src/mm/page.c
raecf79f rc59dd1a2 69 69 70 70 exc_register(14, "page_fault", (iroutine) page_fault); 71 write_cr3((uintptr_t) AS_KERNEL->page_table);71 // write_cr3((uintptr_t) AS_KERNEL->page_table); 72 72 } 73 73 else { 74 write_cr3((uintptr_t) AS_KERNEL->page_table);74 // write_cr3((uintptr_t) AS_KERNEL->page_table); 75 75 } 76 76 77 paging_on();77 // paging_on(); 78 78 } 79 79
Note:
See TracChangeset
for help on using the changeset viewer.