Changeset 0b9ac3c in mainline for kernel/arch/sparc64/include/mm
- Timestamp:
- 2010-02-23T19:03:28Z (16 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c62d2e1
- Parents:
- 1ccafee (diff), 5e50394 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- kernel/arch/sparc64/include/mm
- Files:
-
- 14 added
- 6 edited
-
as.h (modified) (1 diff)
-
frame.h (modified) (1 diff)
-
mmu.h (modified) (1 diff)
-
pagesize.h (added)
-
sun4u/as.h (added)
-
sun4u/frame.h (added)
-
sun4u/mmu.h (added)
-
sun4u/tlb.h (added)
-
sun4u/tsb.h (added)
-
sun4u/tte.h (added)
-
sun4v/as.h (added)
-
sun4v/frame.h (added)
-
sun4v/mmu.h (added)
-
sun4v/page.h (added)
-
sun4v/tlb.h (added)
-
sun4v/tsb.h (added)
-
sun4v/tte.h (added)
-
tlb.h (modified) (1 diff)
-
tsb.h (modified) (1 diff)
-
tte.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
kernel/arch/sparc64/include/mm/as.h
r1ccafee r0b9ac3c 36 36 #define KERN_sparc64_AS_H_ 37 37 38 #include <arch/mm/tte.h> 39 40 #define KERNEL_ADDRESS_SPACE_SHADOWED_ARCH 1 41 42 #define KERNEL_ADDRESS_SPACE_START_ARCH (unsigned long) 0x0000000000000000 43 #define KERNEL_ADDRESS_SPACE_END_ARCH (unsigned long) 0xffffffffffffffff 44 #define USER_ADDRESS_SPACE_START_ARCH (unsigned long) 0x0000000000000000 45 #define USER_ADDRESS_SPACE_END_ARCH (unsigned long) 0xffffffffffffffff 46 47 #define USTACK_ADDRESS_ARCH (0xffffffffffffffffULL - (PAGE_SIZE - 1)) 48 49 #ifdef CONFIG_TSB 50 51 /** TSB Tag Target register. */ 52 typedef union tsb_tag_target { 53 uint64_t value; 54 struct { 55 unsigned invalid : 1; /**< Invalidated by software. */ 56 unsigned : 2; 57 unsigned context : 13; /**< Software ASID. */ 58 unsigned : 6; 59 uint64_t va_tag : 42; /**< Virtual address bits <63:22>. */ 60 } __attribute__ ((packed)); 61 } tsb_tag_target_t; 62 63 /** TSB entry. */ 64 typedef struct tsb_entry { 65 tsb_tag_target_t tag; 66 tte_data_t data; 67 } __attribute__ ((packed)) tsb_entry_t; 68 69 typedef struct { 70 tsb_entry_t *itsb; 71 tsb_entry_t *dtsb; 72 } as_arch_t; 73 74 #else 75 76 typedef struct { 77 } as_arch_t; 78 79 #endif /* CONFIG_TSB */ 80 81 #include <genarch/mm/as_ht.h> 82 83 #ifdef CONFIG_TSB 84 #include <arch/mm/tsb.h> 85 #define as_invalidate_translation_cache(as, page, cnt) \ 86 tsb_invalidate((as), (page), (cnt)) 87 #else 88 #define as_invalidate_translation_cache(as, page, cnt) 38 #if defined (SUN4U) 39 #include <arch/mm/sun4u/as.h> 40 #elif defined (SUN4V) 41 #include <arch/mm/sun4v/as.h> 89 42 #endif 90 91 extern void as_arch_init(void);92 43 93 44 #endif -
kernel/arch/sparc64/include/mm/frame.h
r1ccafee r0b9ac3c 36 36 #define KERN_sparc64_FRAME_H_ 37 37 38 /* 39 * Page size supported by the MMU. 40 * For 8K there is the nasty illegal virtual aliasing problem. 41 * Therefore, the kernel uses 8K only internally on the TLB and TSB levels. 42 */ 43 #define MMU_FRAME_WIDTH 13 /* 8K */ 44 #define MMU_FRAME_SIZE (1 << MMU_FRAME_WIDTH) 45 46 /* 47 * Page size exported to the generic memory management subsystems. 48 * This page size is not directly supported by the MMU, but we can emulate 49 * each 16K page with a pair of adjacent 8K pages. 50 */ 51 #define FRAME_WIDTH 14 /* 16K */ 52 #define FRAME_SIZE (1 << FRAME_WIDTH) 53 54 #ifdef KERNEL 55 #ifndef __ASM__ 56 57 #include <arch/types.h> 58 59 union frame_address { 60 uintptr_t address; 61 struct { 62 #if defined (US) 63 unsigned : 23; 64 uint64_t pfn : 28; /**< Physical Frame Number. */ 65 #elif defined (US3) 66 unsigned : 21; 67 uint64_t pfn : 30; /**< Physical Frame Number. */ 68 #endif 69 unsigned offset : 13; /**< Offset. */ 70 } __attribute__ ((packed)); 71 }; 72 73 typedef union frame_address frame_address_t; 74 75 extern uintptr_t last_frame; 76 extern uintptr_t end_of_identity; 77 78 extern void frame_arch_init(void); 79 #define physmem_print() 80 81 #endif 38 #if defined (SUN4U) 39 #include <arch/mm/sun4u/frame.h> 40 #elif defined (SUN4V) 41 #include <arch/mm/sun4v/frame.h> 82 42 #endif 83 43 -
kernel/arch/sparc64/include/mm/mmu.h
r1ccafee r0b9ac3c 36 36 #define KERN_sparc64_MMU_H_ 37 37 38 #if defined(US) 39 /* LSU Control Register ASI. */ 40 #define ASI_LSU_CONTROL_REG 0x45 /**< Load/Store Unit Control Register. */ 38 #if defined (SUN4U) 39 #include <arch/mm/sun4u/mmu.h> 40 #elif defined (SUN4V) 41 #include <arch/mm/sun4v/mmu.h> 41 42 #endif 42 43 43 /* I-MMU ASIs. */44 #define ASI_IMMU 0x5045 #define ASI_IMMU_TSB_8KB_PTR_REG 0x5146 #define ASI_IMMU_TSB_64KB_PTR_REG 0x5247 #define ASI_ITLB_DATA_IN_REG 0x5448 #define ASI_ITLB_DATA_ACCESS_REG 0x5549 #define ASI_ITLB_TAG_READ_REG 0x5650 #define ASI_IMMU_DEMAP 0x5751 52 /* Virtual Addresses within ASI_IMMU. */53 #define VA_IMMU_TSB_TAG_TARGET 0x0 /**< IMMU TSB tag target register. */54 #define VA_IMMU_SFSR 0x18 /**< IMMU sync fault status register. */55 #define VA_IMMU_TSB_BASE 0x28 /**< IMMU TSB base register. */56 #define VA_IMMU_TAG_ACCESS 0x30 /**< IMMU TLB tag access register. */57 #if defined (US3)58 #define VA_IMMU_PRIMARY_EXTENSION 0x48 /**< IMMU TSB primary extension register */59 #define VA_IMMU_NUCLEUS_EXTENSION 0x58 /**< IMMU TSB nucleus extension register */60 #endif61 62 63 /* D-MMU ASIs. */64 #define ASI_DMMU 0x5865 #define ASI_DMMU_TSB_8KB_PTR_REG 0x5966 #define ASI_DMMU_TSB_64KB_PTR_REG 0x5a67 #define ASI_DMMU_TSB_DIRECT_PTR_REG 0x5b68 #define ASI_DTLB_DATA_IN_REG 0x5c69 #define ASI_DTLB_DATA_ACCESS_REG 0x5d70 #define ASI_DTLB_TAG_READ_REG 0x5e71 #define ASI_DMMU_DEMAP 0x5f72 73 /* Virtual Addresses within ASI_DMMU. */74 #define VA_DMMU_TSB_TAG_TARGET 0x0 /**< DMMU TSB tag target register. */75 #define VA_PRIMARY_CONTEXT_REG 0x8 /**< DMMU primary context register. */76 #define VA_SECONDARY_CONTEXT_REG 0x10 /**< DMMU secondary context register. */77 #define VA_DMMU_SFSR 0x18 /**< DMMU sync fault status register. */78 #define VA_DMMU_SFAR 0x20 /**< DMMU sync fault address register. */79 #define VA_DMMU_TSB_BASE 0x28 /**< DMMU TSB base register. */80 #define VA_DMMU_TAG_ACCESS 0x30 /**< DMMU TLB tag access register. */81 #define VA_DMMU_VA_WATCHPOINT_REG 0x38 /**< DMMU VA data watchpoint register. */82 #define VA_DMMU_PA_WATCHPOINT_REG 0x40 /**< DMMU PA data watchpoint register. */83 #if defined (US3)84 #define VA_DMMU_PRIMARY_EXTENSION 0x48 /**< DMMU TSB primary extension register */85 #define VA_DMMU_SECONDARY_EXTENSION 0x50 /**< DMMU TSB secondary extension register */86 #define VA_DMMU_NUCLEUS_EXTENSION 0x58 /**< DMMU TSB nucleus extension register */87 #endif88 89 #ifndef __ASM__90 91 #include <arch/asm.h>92 #include <arch/barrier.h>93 #include <arch/types.h>94 95 #if defined(US)96 /** LSU Control Register. */97 typedef union {98 uint64_t value;99 struct {100 unsigned : 23;101 unsigned pm : 8;102 unsigned vm : 8;103 unsigned pr : 1;104 unsigned pw : 1;105 unsigned vr : 1;106 unsigned vw : 1;107 unsigned : 1;108 unsigned fm : 16;109 unsigned dm : 1; /**< D-MMU enable. */110 unsigned im : 1; /**< I-MMU enable. */111 unsigned dc : 1; /**< D-Cache enable. */112 unsigned ic : 1; /**< I-Cache enable. */113 114 } __attribute__ ((packed));115 } lsu_cr_reg_t;116 #endif /* US */117 118 #endif /* !def __ASM__ */119 44 120 45 #endif -
kernel/arch/sparc64/include/mm/tlb.h
r1ccafee r0b9ac3c 36 36 #define KERN_sparc64_TLB_H_ 37 37 38 #if defined (US) 39 #define ITLB_ENTRY_COUNT 64 40 #define DTLB_ENTRY_COUNT 64 41 #define DTLB_MAX_LOCKED_ENTRIES DTLB_ENTRY_COUNT 38 39 #if defined (SUN4U) 40 #include <arch/mm/sun4u/tlb.h> 41 #elif defined (SUN4V) 42 #include <arch/mm/sun4v/tlb.h> 42 43 #endif 43 44 /** TLB_DSMALL is the only of the three DMMUs that can hold locked entries. */45 #if defined (US3)46 #define DTLB_MAX_LOCKED_ENTRIES 1647 #endif48 49 #define MEM_CONTEXT_KERNEL 050 #define MEM_CONTEXT_TEMP 151 52 /** Page sizes. */53 #define PAGESIZE_8K 054 #define PAGESIZE_64K 155 #define PAGESIZE_512K 256 #define PAGESIZE_4M 357 58 /** Bit width of the TLB-locked portion of kernel address space. */59 #define KERNEL_PAGE_WIDTH 22 /* 4M */60 61 /* TLB Demap Operation types. */62 #define TLB_DEMAP_PAGE 063 #define TLB_DEMAP_CONTEXT 164 #if defined (US3)65 #define TLB_DEMAP_ALL 266 #endif67 68 #define TLB_DEMAP_TYPE_SHIFT 669 70 /* TLB Demap Operation Context register encodings. */71 #define TLB_DEMAP_PRIMARY 072 #define TLB_DEMAP_SECONDARY 173 #define TLB_DEMAP_NUCLEUS 274 75 /* There are more TLBs in one MMU in US3, their codes are defined here. */76 #if defined (US3)77 /* D-MMU: one small (16-entry) TLB and two big (512-entry) TLBs */78 #define TLB_DSMALL 079 #define TLB_DBIG_0 280 #define TLB_DBIG_1 381 82 /* I-MMU: one small (16-entry) TLB and one big TLB */83 #define TLB_ISMALL 084 #define TLB_IBIG 285 #endif86 87 #define TLB_DEMAP_CONTEXT_SHIFT 488 89 /* TLB Tag Access shifts */90 #define TLB_TAG_ACCESS_CONTEXT_SHIFT 091 #define TLB_TAG_ACCESS_CONTEXT_MASK ((1 << 13) - 1)92 #define TLB_TAG_ACCESS_VPN_SHIFT 1393 94 #ifndef __ASM__95 96 #include <arch/mm/tte.h>97 #include <arch/mm/mmu.h>98 #include <arch/mm/page.h>99 #include <arch/asm.h>100 #include <arch/barrier.h>101 #include <arch/types.h>102 #include <arch/register.h>103 #include <arch/cpu.h>104 105 union tlb_context_reg {106 uint64_t v;107 struct {108 unsigned long : 51;109 unsigned context : 13; /**< Context/ASID. */110 } __attribute__ ((packed));111 };112 typedef union tlb_context_reg tlb_context_reg_t;113 114 /** I-/D-TLB Data In/Access Register type. */115 typedef tte_data_t tlb_data_t;116 117 /** I-/D-TLB Data Access Address in Alternate Space. */118 119 #if defined (US)120 121 union tlb_data_access_addr {122 uint64_t value;123 struct {124 uint64_t : 55;125 unsigned tlb_entry : 6;126 unsigned : 3;127 } __attribute__ ((packed));128 };129 typedef union tlb_data_access_addr dtlb_data_access_addr_t;130 typedef union tlb_data_access_addr dtlb_tag_read_addr_t;131 typedef union tlb_data_access_addr itlb_data_access_addr_t;132 typedef union tlb_data_access_addr itlb_tag_read_addr_t;133 134 #elif defined (US3)135 136 /*137 * In US3, I-MMU and D-MMU have different formats of the data138 * access register virtual address. In the corresponding139 * structures the member variable for the entry number is140 * called "local_tlb_entry" - it contrasts with the "tlb_entry"141 * for the US data access register VA structure. The rationale142 * behind this is to prevent careless mistakes in the code143 * caused by setting only the entry number and not the TLB144 * number in the US3 code (when taking the code from US).145 */146 147 union dtlb_data_access_addr {148 uint64_t value;149 struct {150 uint64_t : 45;151 unsigned : 1;152 unsigned tlb_number : 2;153 unsigned : 4;154 unsigned local_tlb_entry : 9;155 unsigned : 3;156 } __attribute__ ((packed));157 };158 typedef union dtlb_data_access_addr dtlb_data_access_addr_t;159 typedef union dtlb_data_access_addr dtlb_tag_read_addr_t;160 161 union itlb_data_access_addr {162 uint64_t value;163 struct {164 uint64_t : 45;165 unsigned : 1;166 unsigned tlb_number : 2;167 unsigned : 6;168 unsigned local_tlb_entry : 7;169 unsigned : 3;170 } __attribute__ ((packed));171 };172 typedef union itlb_data_access_addr itlb_data_access_addr_t;173 typedef union itlb_data_access_addr itlb_tag_read_addr_t;174 175 #endif176 177 /** I-/D-TLB Tag Read Register. */178 union tlb_tag_read_reg {179 uint64_t value;180 struct {181 uint64_t vpn : 51; /**< Virtual Address bits 63:13. */182 unsigned context : 13; /**< Context identifier. */183 } __attribute__ ((packed));184 };185 typedef union tlb_tag_read_reg tlb_tag_read_reg_t;186 typedef union tlb_tag_read_reg tlb_tag_access_reg_t;187 188 189 /** TLB Demap Operation Address. */190 union tlb_demap_addr {191 uint64_t value;192 struct {193 uint64_t vpn: 51; /**< Virtual Address bits 63:13. */194 #if defined (US)195 unsigned : 6; /**< Ignored. */196 unsigned type : 1; /**< The type of demap operation. */197 #elif defined (US3)198 unsigned : 5; /**< Ignored. */199 unsigned type: 2; /**< The type of demap operation. */200 #endif201 unsigned context : 2; /**< Context register selection. */202 unsigned : 4; /**< Zero. */203 } __attribute__ ((packed));204 };205 typedef union tlb_demap_addr tlb_demap_addr_t;206 207 /** TLB Synchronous Fault Status Register. */208 union tlb_sfsr_reg {209 uint64_t value;210 struct {211 #if defined (US)212 unsigned long : 40; /**< Implementation dependent. */213 unsigned asi : 8; /**< ASI. */214 unsigned : 2;215 unsigned ft : 7; /**< Fault type. */216 #elif defined (US3)217 unsigned long : 39; /**< Implementation dependent. */218 unsigned nf : 1; /**< Non-faulting load. */219 unsigned asi : 8; /**< ASI. */220 unsigned tm : 1; /**< I-TLB miss. */221 unsigned : 3; /**< Reserved. */222 unsigned ft : 5; /**< Fault type. */223 #endif224 unsigned e : 1; /**< Side-effect bit. */225 unsigned ct : 2; /**< Context Register selection. */226 unsigned pr : 1; /**< Privilege bit. */227 unsigned w : 1; /**< Write bit. */228 unsigned ow : 1; /**< Overwrite bit. */229 unsigned fv : 1; /**< Fault Valid bit. */230 } __attribute__ ((packed));231 };232 typedef union tlb_sfsr_reg tlb_sfsr_reg_t;233 234 #if defined (US3)235 236 /*237 * Functions for determining the number of entries in TLBs. They either return238 * a constant value or a value based on the CPU autodetection.239 */240 241 /**242 * Determine the number of entries in the DMMU's small TLB.243 */244 static inline uint16_t tlb_dsmall_size(void)245 {246 return 16;247 }248 249 /**250 * Determine the number of entries in each DMMU's big TLB.251 */252 static inline uint16_t tlb_dbig_size(void)253 {254 return 512;255 }256 257 /**258 * Determine the number of entries in the IMMU's small TLB.259 */260 static inline uint16_t tlb_ismall_size(void)261 {262 return 16;263 }264 265 /**266 * Determine the number of entries in the IMMU's big TLB.267 */268 static inline uint16_t tlb_ibig_size(void)269 {270 if (((ver_reg_t) ver_read()).impl == IMPL_ULTRASPARCIV_PLUS)271 return 512;272 else273 return 128;274 }275 276 #endif277 278 /** Read MMU Primary Context Register.279 *280 * @return Current value of Primary Context Register.281 */282 static inline uint64_t mmu_primary_context_read(void)283 {284 return asi_u64_read(ASI_DMMU, VA_PRIMARY_CONTEXT_REG);285 }286 287 /** Write MMU Primary Context Register.288 *289 * @param v New value of Primary Context Register.290 */291 static inline void mmu_primary_context_write(uint64_t v)292 {293 asi_u64_write(ASI_DMMU, VA_PRIMARY_CONTEXT_REG, v);294 flush_pipeline();295 }296 297 /** Read MMU Secondary Context Register.298 *299 * @return Current value of Secondary Context Register.300 */301 static inline uint64_t mmu_secondary_context_read(void)302 {303 return asi_u64_read(ASI_DMMU, VA_SECONDARY_CONTEXT_REG);304 }305 306 /** Write MMU Primary Context Register.307 *308 * @param v New value of Primary Context Register.309 */310 static inline void mmu_secondary_context_write(uint64_t v)311 {312 asi_u64_write(ASI_DMMU, VA_SECONDARY_CONTEXT_REG, v);313 flush_pipeline();314 }315 316 #if defined (US)317 318 /** Read IMMU TLB Data Access Register.319 *320 * @param entry TLB Entry index.321 *322 * @return Current value of specified IMMU TLB Data Access323 * Register.324 */325 static inline uint64_t itlb_data_access_read(size_t entry)326 {327 itlb_data_access_addr_t reg;328 329 reg.value = 0;330 reg.tlb_entry = entry;331 return asi_u64_read(ASI_ITLB_DATA_ACCESS_REG, reg.value);332 }333 334 /** Write IMMU TLB Data Access Register.335 *336 * @param entry TLB Entry index.337 * @param value Value to be written.338 */339 static inline void itlb_data_access_write(size_t entry, uint64_t value)340 {341 itlb_data_access_addr_t reg;342 343 reg.value = 0;344 reg.tlb_entry = entry;345 asi_u64_write(ASI_ITLB_DATA_ACCESS_REG, reg.value, value);346 flush_pipeline();347 }348 349 /** Read DMMU TLB Data Access Register.350 *351 * @param entry TLB Entry index.352 *353 * @return Current value of specified DMMU TLB Data Access354 * Register.355 */356 static inline uint64_t dtlb_data_access_read(size_t entry)357 {358 dtlb_data_access_addr_t reg;359 360 reg.value = 0;361 reg.tlb_entry = entry;362 return asi_u64_read(ASI_DTLB_DATA_ACCESS_REG, reg.value);363 }364 365 /** Write DMMU TLB Data Access Register.366 *367 * @param entry TLB Entry index.368 * @param value Value to be written.369 */370 static inline void dtlb_data_access_write(size_t entry, uint64_t value)371 {372 dtlb_data_access_addr_t reg;373 374 reg.value = 0;375 reg.tlb_entry = entry;376 asi_u64_write(ASI_DTLB_DATA_ACCESS_REG, reg.value, value);377 membar();378 }379 380 /** Read IMMU TLB Tag Read Register.381 *382 * @param entry TLB Entry index.383 *384 * @return Current value of specified IMMU TLB Tag Read Register.385 */386 static inline uint64_t itlb_tag_read_read(size_t entry)387 {388 itlb_tag_read_addr_t tag;389 390 tag.value = 0;391 tag.tlb_entry = entry;392 return asi_u64_read(ASI_ITLB_TAG_READ_REG, tag.value);393 }394 395 /** Read DMMU TLB Tag Read Register.396 *397 * @param entry TLB Entry index.398 *399 * @return Current value of specified DMMU TLB Tag Read Register.400 */401 static inline uint64_t dtlb_tag_read_read(size_t entry)402 {403 dtlb_tag_read_addr_t tag;404 405 tag.value = 0;406 tag.tlb_entry = entry;407 return asi_u64_read(ASI_DTLB_TAG_READ_REG, tag.value);408 }409 410 #elif defined (US3)411 412 413 /** Read IMMU TLB Data Access Register.414 *415 * @param tlb TLB number (one of TLB_ISMALL or TLB_IBIG)416 * @param entry TLB Entry index.417 *418 * @return Current value of specified IMMU TLB Data Access419 * Register.420 */421 static inline uint64_t itlb_data_access_read(int tlb, size_t entry)422 {423 itlb_data_access_addr_t reg;424 425 reg.value = 0;426 reg.tlb_number = tlb;427 reg.local_tlb_entry = entry;428 return asi_u64_read(ASI_ITLB_DATA_ACCESS_REG, reg.value);429 }430 431 /** Write IMMU TLB Data Access Register.432 * @param tlb TLB number (one of TLB_ISMALL or TLB_IBIG)433 * @param entry TLB Entry index.434 * @param value Value to be written.435 */436 static inline void itlb_data_access_write(int tlb, size_t entry,437 uint64_t value)438 {439 itlb_data_access_addr_t reg;440 441 reg.value = 0;442 reg.tlb_number = tlb;443 reg.local_tlb_entry = entry;444 asi_u64_write(ASI_ITLB_DATA_ACCESS_REG, reg.value, value);445 flush_pipeline();446 }447 448 /** Read DMMU TLB Data Access Register.449 *450 * @param tlb TLB number (one of TLB_DSMALL, TLB_DBIG, TLB_DBIG)451 * @param entry TLB Entry index.452 *453 * @return Current value of specified DMMU TLB Data Access454 * Register.455 */456 static inline uint64_t dtlb_data_access_read(int tlb, size_t entry)457 {458 dtlb_data_access_addr_t reg;459 460 reg.value = 0;461 reg.tlb_number = tlb;462 reg.local_tlb_entry = entry;463 return asi_u64_read(ASI_DTLB_DATA_ACCESS_REG, reg.value);464 }465 466 /** Write DMMU TLB Data Access Register.467 *468 * @param tlb TLB number (one of TLB_DSMALL, TLB_DBIG_0, TLB_DBIG_1)469 * @param entry TLB Entry index.470 * @param value Value to be written.471 */472 static inline void dtlb_data_access_write(int tlb, size_t entry,473 uint64_t value)474 {475 dtlb_data_access_addr_t reg;476 477 reg.value = 0;478 reg.tlb_number = tlb;479 reg.local_tlb_entry = entry;480 asi_u64_write(ASI_DTLB_DATA_ACCESS_REG, reg.value, value);481 membar();482 }483 484 /** Read IMMU TLB Tag Read Register.485 *486 * @param tlb TLB number (one of TLB_ISMALL or TLB_IBIG)487 * @param entry TLB Entry index.488 *489 * @return Current value of specified IMMU TLB Tag Read Register.490 */491 static inline uint64_t itlb_tag_read_read(int tlb, size_t entry)492 {493 itlb_tag_read_addr_t tag;494 495 tag.value = 0;496 tag.tlb_number = tlb;497 tag.local_tlb_entry = entry;498 return asi_u64_read(ASI_ITLB_TAG_READ_REG, tag.value);499 }500 501 /** Read DMMU TLB Tag Read Register.502 *503 * @param tlb TLB number (one of TLB_DSMALL, TLB_DBIG_0, TLB_DBIG_1)504 * @param entry TLB Entry index.505 *506 * @return Current value of specified DMMU TLB Tag Read Register.507 */508 static inline uint64_t dtlb_tag_read_read(int tlb, size_t entry)509 {510 dtlb_tag_read_addr_t tag;511 512 tag.value = 0;513 tag.tlb_number = tlb;514 tag.local_tlb_entry = entry;515 return asi_u64_read(ASI_DTLB_TAG_READ_REG, tag.value);516 }517 518 #endif519 520 521 /** Write IMMU TLB Tag Access Register.522 *523 * @param v Value to be written.524 */525 static inline void itlb_tag_access_write(uint64_t v)526 {527 asi_u64_write(ASI_IMMU, VA_IMMU_TAG_ACCESS, v);528 flush_pipeline();529 }530 531 /** Read IMMU TLB Tag Access Register.532 *533 * @return Current value of IMMU TLB Tag Access Register.534 */535 static inline uint64_t itlb_tag_access_read(void)536 {537 return asi_u64_read(ASI_IMMU, VA_IMMU_TAG_ACCESS);538 }539 540 /** Write DMMU TLB Tag Access Register.541 *542 * @param v Value to be written.543 */544 static inline void dtlb_tag_access_write(uint64_t v)545 {546 asi_u64_write(ASI_DMMU, VA_DMMU_TAG_ACCESS, v);547 membar();548 }549 550 /** Read DMMU TLB Tag Access Register.551 *552 * @return Current value of DMMU TLB Tag Access Register.553 */554 static inline uint64_t dtlb_tag_access_read(void)555 {556 return asi_u64_read(ASI_DMMU, VA_DMMU_TAG_ACCESS);557 }558 559 560 /** Write IMMU TLB Data in Register.561 *562 * @param v Value to be written.563 */564 static inline void itlb_data_in_write(uint64_t v)565 {566 asi_u64_write(ASI_ITLB_DATA_IN_REG, 0, v);567 flush_pipeline();568 }569 570 /** Write DMMU TLB Data in Register.571 *572 * @param v Value to be written.573 */574 static inline void dtlb_data_in_write(uint64_t v)575 {576 asi_u64_write(ASI_DTLB_DATA_IN_REG, 0, v);577 membar();578 }579 580 /** Read ITLB Synchronous Fault Status Register.581 *582 * @return Current content of I-SFSR register.583 */584 static inline uint64_t itlb_sfsr_read(void)585 {586 return asi_u64_read(ASI_IMMU, VA_IMMU_SFSR);587 }588 589 /** Write ITLB Synchronous Fault Status Register.590 *591 * @param v New value of I-SFSR register.592 */593 static inline void itlb_sfsr_write(uint64_t v)594 {595 asi_u64_write(ASI_IMMU, VA_IMMU_SFSR, v);596 flush_pipeline();597 }598 599 /** Read DTLB Synchronous Fault Status Register.600 *601 * @return Current content of D-SFSR register.602 */603 static inline uint64_t dtlb_sfsr_read(void)604 {605 return asi_u64_read(ASI_DMMU, VA_DMMU_SFSR);606 }607 608 /** Write DTLB Synchronous Fault Status Register.609 *610 * @param v New value of D-SFSR register.611 */612 static inline void dtlb_sfsr_write(uint64_t v)613 {614 asi_u64_write(ASI_DMMU, VA_DMMU_SFSR, v);615 membar();616 }617 618 /** Read DTLB Synchronous Fault Address Register.619 *620 * @return Current content of D-SFAR register.621 */622 static inline uint64_t dtlb_sfar_read(void)623 {624 return asi_u64_read(ASI_DMMU, VA_DMMU_SFAR);625 }626 627 /** Perform IMMU TLB Demap Operation.628 *629 * @param type Selects between context and page demap (and entire MMU630 * demap on US3).631 * @param context_encoding Specifies which Context register has Context ID for632 * demap.633 * @param page Address which is on the page to be demapped.634 */635 static inline void itlb_demap(int type, int context_encoding, uintptr_t page)636 {637 tlb_demap_addr_t da;638 page_address_t pg;639 640 da.value = 0;641 pg.address = page;642 643 da.type = type;644 da.context = context_encoding;645 da.vpn = pg.vpn;646 647 /* da.value is the address within the ASI */648 asi_u64_write(ASI_IMMU_DEMAP, da.value, 0);649 650 flush_pipeline();651 }652 653 /** Perform DMMU TLB Demap Operation.654 *655 * @param type Selects between context and page demap (and entire MMU656 * demap on US3).657 * @param context_encoding Specifies which Context register has Context ID for658 * demap.659 * @param page Address which is on the page to be demapped.660 */661 static inline void dtlb_demap(int type, int context_encoding, uintptr_t page)662 {663 tlb_demap_addr_t da;664 page_address_t pg;665 666 da.value = 0;667 pg.address = page;668 669 da.type = type;670 da.context = context_encoding;671 da.vpn = pg.vpn;672 673 /* da.value is the address within the ASI */674 asi_u64_write(ASI_DMMU_DEMAP, da.value, 0);675 676 membar();677 }678 679 extern void fast_instruction_access_mmu_miss(unative_t, istate_t *);680 extern void fast_data_access_mmu_miss(tlb_tag_access_reg_t, istate_t *);681 extern void fast_data_access_protection(tlb_tag_access_reg_t , istate_t *);682 683 extern void dtlb_insert_mapping(uintptr_t, uintptr_t, int, bool, bool);684 685 extern void dump_sfsr_and_sfar(void);686 687 #endif /* !def __ASM__ */688 44 689 45 #endif -
kernel/arch/sparc64/include/mm/tsb.h
r1ccafee r0b9ac3c 36 36 #define KERN_sparc64_TSB_H_ 37 37 38 /* 39 * ITSB abd DTSB will claim 64K of memory, which 40 * is a nice number considered that it is one of 41 * the page sizes supported by hardware, which, 42 * again, is nice because TSBs need to be locked 43 * in TLBs - only one TLB entry will do. 44 */ 45 #define TSB_SIZE 2 /* when changing this, change 46 * as.c as well */ 47 #define ITSB_ENTRY_COUNT (512 * (1 << TSB_SIZE)) 48 #define DTSB_ENTRY_COUNT (512 * (1 << TSB_SIZE)) 49 50 #define TSB_TAG_TARGET_CONTEXT_SHIFT 48 51 52 #ifndef __ASM__ 53 54 #include <arch/mm/tte.h> 55 #include <arch/mm/mmu.h> 56 #include <arch/types.h> 57 58 /** TSB Base register. */ 59 typedef union tsb_base_reg { 60 uint64_t value; 61 struct { 62 uint64_t base : 51; /**< TSB base address, bits 63:13. */ 63 unsigned split : 1; /**< Split vs. common TSB for 8K and 64K 64 * pages. HelenOS uses only 8K pages 65 * for user mappings, so we always set 66 * this to 0. 67 */ 68 unsigned : 9; 69 unsigned size : 3; /**< TSB size. Number of entries is 70 * 512 * 2^size. */ 71 } __attribute__ ((packed)); 72 } tsb_base_reg_t; 73 74 /** Read ITSB Base register. 75 * 76 * @return Content of the ITSB Base register. 77 */ 78 static inline uint64_t itsb_base_read(void) 79 { 80 return asi_u64_read(ASI_IMMU, VA_IMMU_TSB_BASE); 81 } 82 83 /** Read DTSB Base register. 84 * 85 * @return Content of the DTSB Base register. 86 */ 87 static inline uint64_t dtsb_base_read(void) 88 { 89 return asi_u64_read(ASI_DMMU, VA_DMMU_TSB_BASE); 90 } 91 92 /** Write ITSB Base register. 93 * 94 * @param v New content of the ITSB Base register. 95 */ 96 static inline void itsb_base_write(uint64_t v) 97 { 98 asi_u64_write(ASI_IMMU, VA_IMMU_TSB_BASE, v); 99 } 100 101 /** Write DTSB Base register. 102 * 103 * @param v New content of the DTSB Base register. 104 */ 105 static inline void dtsb_base_write(uint64_t v) 106 { 107 asi_u64_write(ASI_DMMU, VA_DMMU_TSB_BASE, v); 108 } 109 110 #if defined (US3) 111 112 /** Write DTSB Primary Extension register. 113 * 114 * @param v New content of the DTSB Primary Extension register. 115 */ 116 static inline void dtsb_primary_extension_write(uint64_t v) 117 { 118 asi_u64_write(ASI_DMMU, VA_DMMU_PRIMARY_EXTENSION, v); 119 } 120 121 /** Write DTSB Secondary Extension register. 122 * 123 * @param v New content of the DTSB Secondary Extension register. 124 */ 125 static inline void dtsb_secondary_extension_write(uint64_t v) 126 { 127 asi_u64_write(ASI_DMMU, VA_DMMU_SECONDARY_EXTENSION, v); 128 } 129 130 /** Write DTSB Nucleus Extension register. 131 * 132 * @param v New content of the DTSB Nucleus Extension register. 133 */ 134 static inline void dtsb_nucleus_extension_write(uint64_t v) 135 { 136 asi_u64_write(ASI_DMMU, VA_DMMU_NUCLEUS_EXTENSION, v); 137 } 138 139 /** Write ITSB Primary Extension register. 140 * 141 * @param v New content of the ITSB Primary Extension register. 142 */ 143 static inline void itsb_primary_extension_write(uint64_t v) 144 { 145 asi_u64_write(ASI_IMMU, VA_IMMU_PRIMARY_EXTENSION, v); 146 } 147 148 /** Write ITSB Nucleus Extension register. 149 * 150 * @param v New content of the ITSB Nucleus Extension register. 151 */ 152 static inline void itsb_nucleus_extension_write(uint64_t v) 153 { 154 asi_u64_write(ASI_IMMU, VA_IMMU_NUCLEUS_EXTENSION, v); 155 } 156 38 #if defined (SUN4U) 39 #include <arch/mm/sun4u/tsb.h> 40 #elif defined (SUN4V) 41 #include <arch/mm/sun4v/tsb.h> 157 42 #endif 158 159 /* Forward declarations. */160 struct as;161 struct pte;162 163 extern void tsb_invalidate(struct as *as, uintptr_t page, size_t pages);164 extern void itsb_pte_copy(struct pte *t, size_t index);165 extern void dtsb_pte_copy(struct pte *t, size_t index, bool ro);166 167 #endif /* !def __ASM__ */168 43 169 44 #endif -
kernel/arch/sparc64/include/mm/tte.h
r1ccafee r0b9ac3c 36 36 #define KERN_sparc64_TTE_H_ 37 37 38 #define TTE_G (1 << 0) 39 #define TTE_W (1 << 1) 40 #define TTE_P (1 << 2) 41 #define TTE_E (1 << 3) 42 #define TTE_CV (1 << 4) 43 #define TTE_CP (1 << 5) 44 #define TTE_L (1 << 6) 45 46 #define TTE_V_SHIFT 63 47 #define TTE_SIZE_SHIFT 61 48 49 #ifndef __ASM__ 50 51 #include <arch/types.h> 52 53 /* TTE tag's VA_tag field contains bits <63:VA_TAG_PAGE_SHIFT> of the VA */ 54 #define VA_TAG_PAGE_SHIFT 22 55 56 /** Translation Table Entry - Tag. */ 57 union tte_tag { 58 uint64_t value; 59 struct { 60 unsigned g : 1; /**< Global. */ 61 unsigned : 2; /**< Reserved. */ 62 unsigned context : 13; /**< Context identifier. */ 63 unsigned : 6; /**< Reserved. */ 64 uint64_t va_tag : 42; /**< Virtual Address Tag, bits 63:22. */ 65 } __attribute__ ((packed)); 66 }; 67 68 typedef union tte_tag tte_tag_t; 69 70 /** Translation Table Entry - Data. */ 71 union tte_data { 72 uint64_t value; 73 struct { 74 unsigned v : 1; /**< Valid. */ 75 unsigned size : 2; /**< Page size of this entry. */ 76 unsigned nfo : 1; /**< No-Fault-Only. */ 77 unsigned ie : 1; /**< Invert Endianness. */ 78 unsigned soft2 : 9; /**< Software defined field. */ 79 #if defined (US) 80 unsigned diag : 9; /**< Diagnostic data. */ 81 unsigned pfn : 28; /**< Physical Address bits, bits 40:13. */ 82 #elif defined (US3) 83 unsigned : 7; /**< Reserved. */ 84 unsigned pfn : 30; /**< Physical Address bits, bits 42:13 */ 38 #if defined (SUN4U) 39 #include <arch/mm/sun4u/tte.h> 40 #elif defined (SUN4V) 41 #include <arch/mm/sun4v/tte.h> 85 42 #endif 86 unsigned soft : 6; /**< Software defined field. */87 unsigned l : 1; /**< Lock. */88 unsigned cp : 1; /**< Cacheable in physically indexed cache. */89 unsigned cv : 1; /**< Cacheable in virtually indexed cache. */90 unsigned e : 1; /**< Side-effect. */91 unsigned p : 1; /**< Privileged. */92 unsigned w : 1; /**< Writable. */93 unsigned g : 1; /**< Global. */94 } __attribute__ ((packed));95 };96 97 typedef union tte_data tte_data_t;98 99 #endif /* !def __ASM__ */100 43 101 44 #endif
Note:
See TracChangeset
for help on using the changeset viewer.
