HelenOS sources
This source file includes following definitions.
- tlb_dsmall_size
- tlb_dbig_size
- tlb_ismall_size
- tlb_ibig_size
- mmu_primary_context_read
- mmu_primary_context_write
- mmu_secondary_context_read
- mmu_secondary_context_write
- itlb_data_access_read
- itlb_data_access_write
- dtlb_data_access_read
- dtlb_data_access_write
- itlb_tag_read_read
- dtlb_tag_read_read
- itlb_data_access_read
- itlb_data_access_write
- dtlb_data_access_read
- dtlb_data_access_write
- itlb_tag_read_read
- dtlb_tag_read_read
- itlb_tag_access_write
- itlb_tag_access_read
- dtlb_tag_access_write
- dtlb_tag_access_read
- itlb_data_in_write
- dtlb_data_in_write
- itlb_sfsr_read
- itlb_sfsr_write
- dtlb_sfsr_read
- dtlb_sfsr_write
- dtlb_sfar_read
- itlb_demap
- dtlb_demap
#ifndef KERN_sparc64_TLB_sun4u_H_
#define KERN_sparc64_TLB_sun4u_H_
#if defined (US)
#define ITLB_ENTRY_COUNT 64
#define DTLB_ENTRY_COUNT 64
#define DTLB_MAX_LOCKED_ENTRIES DTLB_ENTRY_COUNT
#endif
#if defined (US3)
#define DTLB_MAX_LOCKED_ENTRIES 16
#endif
#define MEM_CONTEXT_KERNEL 0
#define MEM_CONTEXT_TEMP 1
#define PAGESIZE_8K 0
#define PAGESIZE_64K 1
#define PAGESIZE_512K 2
#define PAGESIZE_4M 3
#define KERNEL_PAGE_WIDTH 22
#define TLB_DEMAP_PAGE 0
#define TLB_DEMAP_CONTEXT 1
#if defined (US3)
#define TLB_DEMAP_ALL 2
#endif
#define TLB_DEMAP_TYPE_SHIFT 6
#define TLB_DEMAP_PRIMARY 0
#define TLB_DEMAP_SECONDARY 1
#define TLB_DEMAP_NUCLEUS 2
#if defined (US3)
#define TLB_DSMALL 0
#define TLB_DBIG_0 2
#define TLB_DBIG_1 3
#define TLB_ISMALL 0
#define TLB_IBIG 2
#endif
#define TLB_DEMAP_CONTEXT_SHIFT 4
#define TLB_TAG_ACCESS_CONTEXT_SHIFT 0
#define TLB_TAG_ACCESS_CONTEXT_MASK ((1 << 13) - 1)
#define TLB_TAG_ACCESS_VPN_SHIFT 13
#ifndef __ASSEMBLER__
#include <arch/mm/tte.h>
#include <arch/mm/mmu.h>
#include <arch/mm/page.h>
#include <arch/asm.h>
#include <arch/barrier.h>
#include <barrier.h>
#include <typedefs.h>
#include <trace.h>
#include <arch/register.h>
#include <arch/cpu.h>
union tlb_context_reg {
uint64_t v;
struct {
unsigned long : 51;
unsigned context : 13;
} __attribute__((packed));
};
typedef union tlb_context_reg tlb_context_reg_t;
typedef tte_data_t tlb_data_t;
#if defined (US)
union tlb_data_access_addr {
uint64_t value;
struct {
uint64_t : 55;
unsigned tlb_entry : 6;
unsigned : 3;
} __attribute__((packed));
};
typedef union tlb_data_access_addr dtlb_data_access_addr_t;
typedef union tlb_data_access_addr dtlb_tag_read_addr_t;
typedef union tlb_data_access_addr itlb_data_access_addr_t;
typedef union tlb_data_access_addr itlb_tag_read_addr_t;
#elif defined (US3)
union dtlb_data_access_addr {
uint64_t value;
struct {
uint64_t : 45;
unsigned : 1;
unsigned tlb_number : 2;
unsigned : 4;
unsigned local_tlb_entry : 9;
unsigned : 3;
} __attribute__((packed));
};
typedef union dtlb_data_access_addr dtlb_data_access_addr_t;
typedef union dtlb_data_access_addr dtlb_tag_read_addr_t;
union itlb_data_access_addr {
uint64_t value;
struct {
uint64_t : 45;
unsigned : 1;
unsigned tlb_number : 2;
unsigned : 6;
unsigned local_tlb_entry : 7;
unsigned : 3;
} __attribute__((packed));
};
typedef union itlb_data_access_addr itlb_data_access_addr_t;
typedef union itlb_data_access_addr itlb_tag_read_addr_t;
#endif
union tlb_tag_read_reg {
uint64_t value;
struct {
uint64_t vpn : 51;
unsigned context : 13;
} __attribute__((packed));
};
typedef union tlb_tag_read_reg tlb_tag_read_reg_t;
typedef union tlb_tag_read_reg tlb_tag_access_reg_t;
union tlb_demap_addr {
uint64_t value;
struct {
uint64_t vpn : 51;
#if defined (US)
unsigned : 6;
unsigned type : 1;
#elif defined (US3)
unsigned : 5;
unsigned type : 2;
#endif
unsigned context : 2;
unsigned : 4;
} __attribute__((packed));
};
typedef union tlb_demap_addr tlb_demap_addr_t;
union tlb_sfsr_reg {
uint64_t value;
struct {
#if defined (US)
unsigned long : 40;
unsigned asi : 8;
unsigned : 2;
unsigned ft : 7;
#elif defined (US3)
unsigned long : 39;
unsigned nf : 1;
unsigned asi : 8;
unsigned tm : 1;
unsigned : 3;
unsigned ft : 5;
#endif
unsigned e : 1;
unsigned ct : 2;
unsigned pr : 1;
unsigned w : 1;
unsigned ow : 1;
unsigned fv : 1;
} __attribute__((packed));
};
typedef union tlb_sfsr_reg tlb_sfsr_reg_t;
#if defined (US3)
_NO_TRACE static inline uint16_t tlb_dsmall_size(void)
{
return 16;
}
_NO_TRACE static inline uint16_t tlb_dbig_size(void)
{
return 512;
}
_NO_TRACE static inline uint16_t tlb_ismall_size(void)
{
return 16;
}
_NO_TRACE static inline uint16_t tlb_ibig_size(void)
{
if (((ver_reg_t) ver_read()).impl == IMPL_ULTRASPARCIV_PLUS)
return 512;
else
return 128;
}
#endif
_NO_TRACE static inline uint64_t mmu_primary_context_read(void)
{
return asi_u64_read(ASI_DMMU, VA_PRIMARY_CONTEXT_REG);
}
_NO_TRACE static inline void mmu_primary_context_write(uint64_t v)
{
asi_u64_write(ASI_DMMU, VA_PRIMARY_CONTEXT_REG, v);
flush_pipeline();
}
_NO_TRACE static inline uint64_t mmu_secondary_context_read(void)
{
return asi_u64_read(ASI_DMMU, VA_SECONDARY_CONTEXT_REG);
}
_NO_TRACE static inline void mmu_secondary_context_write(uint64_t v)
{
asi_u64_write(ASI_DMMU, VA_SECONDARY_CONTEXT_REG, v);
flush_pipeline();
}
#if defined (US)
_NO_TRACE static inline uint64_t itlb_data_access_read(size_t entry)
{
itlb_data_access_addr_t reg;
reg.value = 0;
reg.tlb_entry = entry;
return asi_u64_read(ASI_ITLB_DATA_ACCESS_REG, reg.value);
}
_NO_TRACE static inline void itlb_data_access_write(size_t entry, uint64_t value)
{
itlb_data_access_addr_t reg;
reg.value = 0;
reg.tlb_entry = entry;
asi_u64_write(ASI_ITLB_DATA_ACCESS_REG, reg.value, value);
flush_pipeline();
}
_NO_TRACE static inline uint64_t dtlb_data_access_read(size_t entry)
{
dtlb_data_access_addr_t reg;
reg.value = 0;
reg.tlb_entry = entry;
return asi_u64_read(ASI_DTLB_DATA_ACCESS_REG, reg.value);
}
_NO_TRACE static inline void dtlb_data_access_write(size_t entry, uint64_t value)
{
dtlb_data_access_addr_t reg;
reg.value = 0;
reg.tlb_entry = entry;
asi_u64_write(ASI_DTLB_DATA_ACCESS_REG, reg.value, value);
membar();
}
_NO_TRACE static inline uint64_t itlb_tag_read_read(size_t entry)
{
itlb_tag_read_addr_t tag;
tag.value = 0;
tag.tlb_entry = entry;
return asi_u64_read(ASI_ITLB_TAG_READ_REG, tag.value);
}
_NO_TRACE static inline uint64_t dtlb_tag_read_read(size_t entry)
{
dtlb_tag_read_addr_t tag;
tag.value = 0;
tag.tlb_entry = entry;
return asi_u64_read(ASI_DTLB_TAG_READ_REG, tag.value);
}
#elif defined (US3)
_NO_TRACE static inline uint64_t itlb_data_access_read(int tlb, size_t entry)
{
itlb_data_access_addr_t reg;
reg.value = 0;
reg.tlb_number = tlb;
reg.local_tlb_entry = entry;
return asi_u64_read(ASI_ITLB_DATA_ACCESS_REG, reg.value);
}
_NO_TRACE static inline void itlb_data_access_write(int tlb, size_t entry,
uint64_t value)
{
itlb_data_access_addr_t reg;
reg.value = 0;
reg.tlb_number = tlb;
reg.local_tlb_entry = entry;
asi_u64_write(ASI_ITLB_DATA_ACCESS_REG, reg.value, value);
flush_pipeline();
}
_NO_TRACE static inline uint64_t dtlb_data_access_read(int tlb, size_t entry)
{
dtlb_data_access_addr_t reg;
reg.value = 0;
reg.tlb_number = tlb;
reg.local_tlb_entry = entry;
return asi_u64_read(ASI_DTLB_DATA_ACCESS_REG, reg.value);
}
_NO_TRACE static inline void dtlb_data_access_write(int tlb, size_t entry,
uint64_t value)
{
dtlb_data_access_addr_t reg;
reg.value = 0;
reg.tlb_number = tlb;
reg.local_tlb_entry = entry;
asi_u64_write(ASI_DTLB_DATA_ACCESS_REG, reg.value, value);
membar();
}
_NO_TRACE static inline uint64_t itlb_tag_read_read(int tlb, size_t entry)
{
itlb_tag_read_addr_t tag;
tag.value = 0;
tag.tlb_number = tlb;
tag.local_tlb_entry = entry;
return asi_u64_read(ASI_ITLB_TAG_READ_REG, tag.value);
}
_NO_TRACE static inline uint64_t dtlb_tag_read_read(int tlb, size_t entry)
{
dtlb_tag_read_addr_t tag;
tag.value = 0;
tag.tlb_number = tlb;
tag.local_tlb_entry = entry;
return asi_u64_read(ASI_DTLB_TAG_READ_REG, tag.value);
}
#endif
_NO_TRACE static inline void itlb_tag_access_write(uint64_t v)
{
asi_u64_write(ASI_IMMU, VA_IMMU_TAG_ACCESS, v);
flush_pipeline();
}
_NO_TRACE static inline uint64_t itlb_tag_access_read(void)
{
return asi_u64_read(ASI_IMMU, VA_IMMU_TAG_ACCESS);
}
_NO_TRACE static inline void dtlb_tag_access_write(uint64_t v)
{
asi_u64_write(ASI_DMMU, VA_DMMU_TAG_ACCESS, v);
membar();
}
_NO_TRACE static inline uint64_t dtlb_tag_access_read(void)
{
return asi_u64_read(ASI_DMMU, VA_DMMU_TAG_ACCESS);
}
_NO_TRACE static inline void itlb_data_in_write(uint64_t v)
{
asi_u64_write(ASI_ITLB_DATA_IN_REG, 0, v);
flush_pipeline();
}
_NO_TRACE static inline void dtlb_data_in_write(uint64_t v)
{
asi_u64_write(ASI_DTLB_DATA_IN_REG, 0, v);
membar();
}
_NO_TRACE static inline uint64_t itlb_sfsr_read(void)
{
return asi_u64_read(ASI_IMMU, VA_IMMU_SFSR);
}
_NO_TRACE static inline void itlb_sfsr_write(uint64_t v)
{
asi_u64_write(ASI_IMMU, VA_IMMU_SFSR, v);
flush_pipeline();
}
_NO_TRACE static inline uint64_t dtlb_sfsr_read(void)
{
return asi_u64_read(ASI_DMMU, VA_DMMU_SFSR);
}
_NO_TRACE static inline void dtlb_sfsr_write(uint64_t v)
{
asi_u64_write(ASI_DMMU, VA_DMMU_SFSR, v);
membar();
}
_NO_TRACE static inline uint64_t dtlb_sfar_read(void)
{
return asi_u64_read(ASI_DMMU, VA_DMMU_SFAR);
}
_NO_TRACE static inline void itlb_demap(int type, int context_encoding, uintptr_t page)
{
tlb_demap_addr_t da;
page_address_t pg;
da.value = 0;
pg.address = page;
da.type = type;
da.context = context_encoding;
da.vpn = pg.vpn;
asi_u64_write(ASI_IMMU_DEMAP, da.value, 0);
flush_pipeline();
}
_NO_TRACE static inline void dtlb_demap(int type, int context_encoding, uintptr_t page)
{
tlb_demap_addr_t da;
page_address_t pg;
da.value = 0;
pg.address = page;
da.type = type;
da.context = context_encoding;
da.vpn = pg.vpn;
asi_u64_write(ASI_DMMU_DEMAP, da.value, 0);
membar();
}
extern void fast_instruction_access_mmu_miss(unsigned int, istate_t *);
extern void fast_data_access_mmu_miss(unsigned int, istate_t *);
extern void fast_data_access_protection(unsigned int, istate_t *);
extern void dtlb_insert_mapping(uintptr_t, uintptr_t, int, bool, bool);
extern void dump_sfsr_and_sfar(void);
extern void describe_dmmu_fault(void);
#endif
#endif
HelenOS homepage, sources at GitHub