Changeset 6c296a9 in mainline
- Timestamp:
- 2008-07-27T13:23:17Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0d387d2
- Parents:
- 4541ae4
- Location:
- kernel/arch/mips32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/mips32/include/mm/tlb.h
r4541ae4 r6c296a9 50 50 #define TLB_KSTACK_WIRED_INDEX 0 51 51 52 #define TLB_PAGE_MASK_16K (0x3 << 13) 52 #define TLB_PAGE_MASK_4K (0x000 << 13) 53 #define TLB_PAGE_MASK_16K (0x003 << 13) 54 #define TLB_PAGE_MASK_64K (0x00f << 13) 55 #define TLB_PAGE_MASK_256K (0x03f << 13) 56 #define TLB_PAGE_MASK_1M (0x0ff << 13) 57 #define TLB_PAGE_MASK_4M (0x3ff << 13) 58 #define TLB_PAGE_MASK_16M (0xfff << 13) 53 59 54 60 #define PAGE_UNCACHED 2 -
kernel/arch/mips32/src/mm/frame.c
r4541ae4 r6c296a9 36 36 #include <arch/mm/frame.h> 37 37 #include <arch/mm/tlb.h> 38 #include <interrupt.h> 38 39 #include <mm/frame.h> 39 40 #include <mm/asid.h> … … 42 43 #include <arch/drivers/serial.h> 43 44 #include <print.h> 44 #include <debug.h> 45 46 #define TLB_PAGE_MASK_1M (0xff << 13) 47 45 46 #define ZERO_PAGE_MASK TLB_PAGE_MASK_1M 48 47 #define ZERO_FRAMES 4096 49 48 #define ZERO_PAGE_WIDTH 20 /* 1M */ … … 53 52 #define ZERO_PAGE_ADDR 0 54 53 #define ZERO_PAGE_OFFSET (ZERO_PAGE_SIZE / sizeof(uint32_t) - 1) 55 #define ZERO_PAGE_VALUE ( *((volatile uint32_t *) ZERO_PAGE_ADDR + ZERO_PAGE_OFFSET))54 #define ZERO_PAGE_VALUE (((volatile uint32_t *) ZERO_PAGE_ADDR)[ZERO_PAGE_OFFSET]) 56 55 57 56 #define MAX_REGIONS 32 … … 132 131 /* Convert 1M frames to 16K frames */ 133 132 pfn_t first = ADDR2PFN(start_frame << ZERO_PAGE_WIDTH); 134 pfn_t count = ADDR2PFN((end_frame - start_frame - 1) << ZERO_PAGE_WIDTH);133 pfn_t count = ADDR2PFN((end_frame - start_frame) << ZERO_PAGE_WIDTH); 135 134 136 135 /* Interrupt vector frame is blacklisted */ … … 157 156 * memory and create zones. 158 157 * 158 * Note: It is assumed that the TLB is not yet being 159 * used in any way, thus there is no interference. 160 * 159 161 */ 160 162 void frame_arch_init(void) 161 163 { 162 cp0_index_write(ZERO_PAGE_TLBI); 163 tlbr(); 164 165 uint32_t orig_pagemask = cp0_pagemask_read(); 166 uint32_t orig_lo0 = cp0_entry_lo0_read(); 167 uint32_t orig_lo1 = cp0_entry_lo1_read(); 168 uint32_t orig_hi = cp0_entry_hi_read(); 164 ipl_t ipl = interrupts_disable(); 165 166 /* Clear and initialize TLB */ 167 cp0_pagemask_write(ZERO_PAGE_MASK); 168 cp0_entry_lo0_write(0); 169 cp0_entry_lo1_write(0); 170 cp0_entry_hi_write(0); 171 172 count_t i; 173 for (i = 0; i < TLB_ENTRY_COUNT; i++) { 174 cp0_index_write(i); 175 tlbwi(); 176 } 169 177 170 178 pfn_t start_frame = 0; … … 185 193 tlb_prepare_entry_hi(&hi, ZERO_PAGE_ASID, ZERO_PAGE_ADDR); 186 194 187 cp0_index_write(ZERO_PAGE_TLBI); 188 cp0_pagemask_write(TLB_PAGE_MASK_1M); 195 cp0_pagemask_write(ZERO_PAGE_MASK); 189 196 cp0_entry_lo0_write(lo0.value); 190 197 cp0_entry_lo1_write(lo1.value); 191 198 cp0_entry_hi_write(hi.value); 199 cp0_index_write(ZERO_PAGE_TLBI); 192 200 tlbwi(); 193 201 … … 212 220 frame_add_region(start_frame, frame); 213 221 214 /* Cleanup TLB */215 cp0_index_write(ZERO_PAGE_TLBI);216 cp0_pagemask_write(orig_pagemask);217 cp0_entry_lo0_write(orig_lo0);218 cp0_entry_lo1_write(orig_lo1);219 cp0_entry_hi_write(orig_hi);220 tlbwi();221 222 222 /* Blacklist interrupt vector frame */ 223 223 frame_mark_unavailable(0, 1); 224 225 /* Cleanup */ 226 cp0_pagemask_write(ZERO_PAGE_MASK); 227 cp0_entry_lo0_write(0); 228 cp0_entry_lo1_write(0); 229 cp0_entry_hi_write(0); 230 cp0_index_write(ZERO_PAGE_TLBI); 231 tlbwi(); 232 233 interrupts_restore(ipl); 224 234 } 225 235
Note:
See TracChangeset
for help on using the changeset viewer.