Changeset 29b2bbf in mainline for kernel/arch/sparc64/src/mm/as.c
- Timestamp:
- 2006-09-18T22:10:20Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 19dba2b
- Parents:
- 57da95c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc64/src/mm/as.c
r57da95c r29b2bbf 41 41 #ifdef CONFIG_TSB 42 42 #include <arch/mm/tsb.h> 43 #include <arch/memstr.h> 44 #include <synch/mutex.h> 45 #include <arch/asm.h> 46 #include <mm/frame.h> 47 #include <bitops.h> 48 #include <macros.h> 43 49 #endif 44 50 … … 48 54 as_operations = &as_ht_operations; 49 55 asid_fifo_init(); 56 } 57 58 int as_constructor_arch(as_t *as, int flags) 59 { 60 #ifdef CONFIG_TSB 61 int order = fnzb32(((ITSB_ENTRY_COUNT+DTSB_ENTRY_COUNT)*sizeof(tsb_entry_t))>>FRAME_WIDTH); 62 uintptr_t tsb = (uintptr_t) frame_alloc(order, flags); 63 64 if (!tsb) 65 return -1; 66 67 as->arch.itsb = (tsb_entry_t *) tsb; 68 as->arch.dtsb = (tsb_entry_t *) (tsb + ITSB_ENTRY_COUNT * sizeof(tsb_entry_t)); 69 #endif 70 return 0; 71 } 72 73 int as_destructor_arch(as_t *as) 74 { 75 #ifdef CONFIG_TSB 76 count_t cnt = ((ITSB_ENTRY_COUNT+DTSB_ENTRY_COUNT)*sizeof(tsb_entry_t))>>FRAME_WIDTH; 77 frame_free((uintptr_t) as->arch.itsb); 78 return cnt; 79 #else 80 return 0; 81 #endif 82 } 83 84 int as_create_arch(as_t *as, int flags) 85 { 86 #ifdef CONFIG_TSB 87 ipl_t ipl; 88 89 memsetb((uintptr_t) as->arch.itsb, (ITSB_ENTRY_COUNT+DTSB_ENTRY_COUNT)*sizeof(tsb_entry_t), 0); 90 ipl = interrupts_disable(); 91 mutex_lock_active(&as->lock); /* completely unnecessary, but polite */ 92 tsb_invalidate(as, 0, (count_t) -1); 93 mutex_unlock(&as->lock); 94 interrupts_restore(ipl); 95 #endif 96 return 0; 50 97 } 51 98 … … 79 126 80 127 #ifdef CONFIG_TSB 81 if (as != AS_KERNEL) { 82 uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH); 128 uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH); 83 129 84 130 ASSERT(as->arch.itsb && as->arch.dtsb); 85 131 86 uintptr_t tsb =as->arch.itsb;132 uintptr_t tsb = (uintptr_t) as->arch.itsb; 87 133 88 89 90 91 92 93 94 95 96 134 if (!overlaps(tsb, 8*PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) { 135 /* 136 * TSBs were allocated from memory not covered 137 * by the locked 4M kernel DTLB entry. We need 138 * to map both TSBs explicitly. 139 */ 140 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, tsb); 141 dtlb_insert_mapping(tsb, KA2PA(tsb), PAGESIZE_64K, true, true); 142 } 97 143 98 99 100 101 144 /* 145 * Setup TSB Base registers. 146 */ 147 tsb_base_reg_t tsb_base; 102 148 103 104 105 149 tsb_base.value = 0; 150 tsb_base.size = TSB_SIZE; 151 tsb_base.split = 0; 106 152 107 tsb_base.base = as->arch.itsb >> PAGE_WIDTH; 108 itsb_base_write(tsb_base.value); 109 tsb_base.base = as->arch.dtsb >> PAGE_WIDTH; 110 dtsb_base_write(tsb_base.value); 111 } 153 tsb_base.base = ((uintptr_t) as->arch.itsb) >> PAGE_WIDTH; 154 itsb_base_write(tsb_base.value); 155 tsb_base.base = ((uintptr_t) as->arch.dtsb) >> PAGE_WIDTH; 156 dtsb_base_write(tsb_base.value); 112 157 #endif 113 158 } … … 130 175 131 176 #ifdef CONFIG_TSB 132 if (as != AS_KERNEL) { 133 uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH); 177 uintptr_t base = ALIGN_DOWN(config.base, 1 << KERNEL_PAGE_WIDTH); 134 178 135 179 ASSERT(as->arch.itsb && as->arch.dtsb); 136 180 137 uintptr_t tsb =as->arch.itsb;181 uintptr_t tsb = (uintptr_t) as->arch.itsb; 138 182 139 if (!overlaps(tsb, 8*PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) { 140 /* 141 * TSBs were allocated from memory not covered 142 * by the locked 4M kernel DTLB entry. We need 143 * to demap the entry installed by as_install_arch(). 144 */ 145 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, tsb); 146 } 147 183 if (!overlaps(tsb, 8*PAGE_SIZE, base, 1 << KERNEL_PAGE_WIDTH)) { 184 /* 185 * TSBs were allocated from memory not covered 186 * by the locked 4M kernel DTLB entry. We need 187 * to demap the entry installed by as_install_arch(). 188 */ 189 dtlb_demap(TLB_DEMAP_PAGE, TLB_DEMAP_NUCLEUS, tsb); 148 190 } 149 191 #endif
Note:
See TracChangeset
for help on using the changeset viewer.