35#ifndef KERN_sparc64_TLB_sun4u_H_
36#define KERN_sparc64_TLB_sun4u_H_
39#define ITLB_ENTRY_COUNT 64
40#define DTLB_ENTRY_COUNT 64
41#define DTLB_MAX_LOCKED_ENTRIES DTLB_ENTRY_COUNT
46#define DTLB_MAX_LOCKED_ENTRIES 16
49#define MEM_CONTEXT_KERNEL 0
50#define MEM_CONTEXT_TEMP 1
55#define PAGESIZE_512K 2
59#define KERNEL_PAGE_WIDTH 22
62#define TLB_DEMAP_PAGE 0
63#define TLB_DEMAP_CONTEXT 1
65#define TLB_DEMAP_ALL 2
68#define TLB_DEMAP_TYPE_SHIFT 6
71#define TLB_DEMAP_PRIMARY 0
72#define TLB_DEMAP_SECONDARY 1
73#define TLB_DEMAP_NUCLEUS 2
87#define TLB_DEMAP_CONTEXT_SHIFT 4
90#define TLB_TAG_ACCESS_CONTEXT_SHIFT 0
91#define TLB_TAG_ACCESS_CONTEXT_MASK ((1 << 13) - 1)
92#define TLB_TAG_ACCESS_VPN_SHIFT 13
100#include <arch/barrier.h>
101#include <arch/types.h>
102#include <arch/register.h>
121union tlb_data_access_addr {
125 unsigned tlb_entry : 6;
129typedef union tlb_data_access_addr dtlb_data_access_addr_t;
130typedef union tlb_data_access_addr dtlb_tag_read_addr_t;
131typedef union tlb_data_access_addr itlb_data_access_addr_t;
132typedef union tlb_data_access_addr itlb_tag_read_addr_t;
147union dtlb_data_access_addr {
152 unsigned tlb_number : 2;
154 unsigned local_tlb_entry : 9;
158typedef union dtlb_data_access_addr dtlb_data_access_addr_t;
159typedef union dtlb_data_access_addr dtlb_tag_read_addr_t;
161union itlb_data_access_addr {
166 unsigned tlb_number : 2;
168 unsigned local_tlb_entry : 7;
172typedef union itlb_data_access_addr itlb_data_access_addr_t;
173typedef union itlb_data_access_addr itlb_tag_read_addr_t;
244static inline uint16_t tlb_dsmall_size(
void)
252static inline uint16_t tlb_dbig_size(
void)
260static inline uint16_t tlb_ismall_size(
void)
268static inline uint16_t tlb_ibig_size(
void)
270 if (((ver_reg_t) ver_read()).impl == IMPL_ULTRASPARCIV_PLUS)
282static inline uint64_t mmu_primary_context_read(
void)
291static inline void mmu_primary_context_write(uint64_t
v)
301static inline uint64_t mmu_secondary_context_read(
void)
310static inline void mmu_secondary_context_write(uint64_t
v)
325static inline uint64_t itlb_data_access_read(
size_t entry)
327 itlb_data_access_addr_t reg;
330 reg.tlb_entry =
entry;
331 return asi_u64_read(ASI_ITLB_DATA_ACCESS_REG, reg.value);
339static inline void itlb_data_access_write(
size_t entry, uint64_t value)
341 itlb_data_access_addr_t reg;
344 reg.tlb_entry =
entry;
345 asi_u64_write(ASI_ITLB_DATA_ACCESS_REG, reg.value, value);
356static inline uint64_t dtlb_data_access_read(
size_t entry)
358 dtlb_data_access_addr_t reg;
361 reg.tlb_entry =
entry;
362 return asi_u64_read(ASI_DTLB_DATA_ACCESS_REG, reg.value);
370static inline void dtlb_data_access_write(
size_t entry, uint64_t value)
372 dtlb_data_access_addr_t reg;
375 reg.tlb_entry =
entry;
376 asi_u64_write(ASI_DTLB_DATA_ACCESS_REG, reg.value, value);
386static inline uint64_t itlb_tag_read_read(
size_t entry)
388 itlb_tag_read_addr_t tag;
391 tag.tlb_entry =
entry;
392 return asi_u64_read(ASI_ITLB_TAG_READ_REG, tag.value);
401static inline uint64_t dtlb_tag_read_read(
size_t entry)
403 dtlb_tag_read_addr_t tag;
406 tag.tlb_entry =
entry;
407 return asi_u64_read(ASI_DTLB_TAG_READ_REG, tag.value);
421static inline uint64_t itlb_data_access_read(
int tlb,
size_t entry)
423 itlb_data_access_addr_t reg;
426 reg.tlb_number = tlb;
427 reg.local_tlb_entry =
entry;
428 return asi_u64_read(ASI_ITLB_DATA_ACCESS_REG, reg.value);
436static inline void itlb_data_access_write(
int tlb,
size_t entry,
439 itlb_data_access_addr_t reg;
442 reg.tlb_number = tlb;
443 reg.local_tlb_entry =
entry;
444 asi_u64_write(ASI_ITLB_DATA_ACCESS_REG, reg.value, value);
456static inline uint64_t dtlb_data_access_read(
int tlb,
size_t entry)
458 dtlb_data_access_addr_t reg;
461 reg.tlb_number = tlb;
462 reg.local_tlb_entry =
entry;
463 return asi_u64_read(ASI_DTLB_DATA_ACCESS_REG, reg.value);
472static inline void dtlb_data_access_write(
int tlb,
size_t entry,
475 dtlb_data_access_addr_t reg;
478 reg.tlb_number = tlb;
479 reg.local_tlb_entry =
entry;
480 asi_u64_write(ASI_DTLB_DATA_ACCESS_REG, reg.value, value);
491static inline uint64_t itlb_tag_read_read(
int tlb,
size_t entry)
493 itlb_tag_read_addr_t tag;
496 tag.tlb_number = tlb;
497 tag.local_tlb_entry =
entry;
498 return asi_u64_read(ASI_ITLB_TAG_READ_REG, tag.value);
508static inline uint64_t dtlb_tag_read_read(
int tlb,
size_t entry)
510 dtlb_tag_read_addr_t tag;
513 tag.tlb_number = tlb;
514 tag.local_tlb_entry =
entry;
515 return asi_u64_read(ASI_DTLB_TAG_READ_REG, tag.value);
525static inline void itlb_tag_access_write(uint64_t
v)
535static inline uint64_t itlb_tag_access_read(
void)
544static inline void dtlb_tag_access_write(uint64_t
v)
554static inline uint64_t dtlb_tag_access_read(
void)
564static inline void itlb_data_in_write(uint64_t
v)
566 asi_u64_write(ASI_ITLB_DATA_IN_REG, 0,
v);
574static inline void dtlb_data_in_write(uint64_t
v)
576 asi_u64_write(ASI_DTLB_DATA_IN_REG, 0,
v);
584static inline uint64_t itlb_sfsr_read(
void)
593static inline void itlb_sfsr_write(uint64_t
v)
603static inline uint64_t dtlb_sfsr_read(
void)
612static inline void dtlb_sfsr_write(uint64_t
v)
622static inline uint64_t dtlb_sfar_read(
void)
635static inline void itlb_demap(
int type,
int context_encoding, uintptr_t
page)
648 asi_u64_write(ASI_IMMU_DEMAP, da.value, 0);
661static inline void dtlb_demap(
int type,
int context_encoding, uintptr_t
page)
674 asi_u64_write(ASI_DMMU_DEMAP, da.value, 0);
679extern void fast_instruction_access_mmu_miss(unative_t, istate_t *);
683extern void dtlb_insert_mapping(uintptr_t, uintptr_t,
int,
bool,
bool);
685extern void dump_sfsr_and_sfar(
void);
686extern void describe_dmmu_fault(
void);
#define VA_SECONDARY_CONTEXT_REG
Definition: mmu.h:76
#define VA_DMMU_TAG_ACCESS
Definition: mmu.h:80
#define VA_IMMU_TAG_ACCESS
Definition: mmu.h:56
#define VA_PRIMARY_CONTEXT_REG
Definition: mmu.h:75
#define VA_DMMU_SFSR
Definition: mmu.h:77
tte_data_t tlb_data_t
Definition: tlb.h:115
#define VA_IMMU_SFSR
Definition: mmu.h:54
#define VA_DMMU_SFAR
Definition: mmu.h:78
unsigned short int uint16 __attribute__((__may_alias__))
Perform a 32-bit endian conversion.
Definition: mcf5282.h:37
Definition: xnandpsu_onfi.h:181
Definition: mmu-config.c:53
unsigned v
Definition: tte.h:0
unsigned context
Definition: tlb.h:109
unsigned context
Definition: tlb.h:201
uint64_t vpn
Definition: tlb.h:193
unsigned ow
Definition: tlb.h:228
unsigned w
Definition: tlb.h:227
unsigned e
Definition: tlb.h:224
unsigned fv
Definition: tlb.h:229
unsigned pr
Definition: tlb.h:226
unsigned ct
Definition: tlb.h:225
uint64_t vpn
Definition: tlb.h:181
unsigned context
Definition: tlb.h:182