#ifndef _SH_MMU_SH4_H_
#define _SH_MMU_SH4_H_
#include <sh/devreg.h>
#define SH4_PTEH 0xff000000
#define SH4_PTEH_VPN_MASK 0xfffffc00
#define SH4_PTEH_ASID_MASK 0x000000ff
#define SH4_PTEL 0xff000004
#define SH4_PTEL_WT 0x00000001
#define SH4_PTEL_SH 0x00000002
#define SH4_PTEL_D 0x00000004
#define SH4_PTEL_C 0x00000008
#define SH4_PTEL_PR_SHIFT 5
#define SH4_PTEL_PR_MASK 0x00000060
#define SH4_PTEL_SZ_MASK 0x00000090
#define SH4_PTEL_SZ_1K 0x00000000
#define SH4_PTEL_SZ_4K 0x00000010
#define SH4_PTEL_SZ_64K 0x00000080
#define SH4_PTEL_SZ_1M 0x00000090
#define SH4_PTEL_V 0x00000100
#define SH4_PTEL_HWBITS 0x1ffff1ff
#define SH4_PTEA 0xff000034
#define SH4_PTEA_SA_MASK 0x00000007
#define SH4_PTEA_SA_TC 0x00000008
#define SH4_TTB 0xff000008
#define SH4_TEA 0xff00000c
#define SH4_MMUCR 0xff000010
#define SH4_MMUCR_AT 0x00000001
#define SH4_MMUCR_TI 0x00000004
#define SH4_MMUCR_SV 0x00000100
#define SH4_MMUCR_SQMD 0x00000200
#define SH4_MMUCR_URC_SHIFT 10
#define SH4_MMUCR_URC_MASK 0x0000fc00
#define SH4_MMUCR_URB_SHIFT 18
#define SH4_MMUCR_URB_MASK 0x00fc0000
#define SH4_MMUCR_LRUI_SHIFT 26
#define SH4_MMUCR_LRUT_MASK 0xfc000000
#define SH4_MMUCR_MASK (SH4_MMUCR_LRUT_MASK | SH4_MMUCR_URB_MASK | \
SH4_MMUCR_URC_MASK | SH4_MMUCR_SQMD | SH4_MMUCR_SV | SH4_MMUCR_AT)
#define SH4_ITLB_ENTRY 4
#define SH4_UTLB_ENTRY 64
#define SH4_ITLB_AA 0xf2000000
#define SH4_ITLB_E_SHIFT 8
#define SH4_ITLB_E_MASK 0x00000300
#define SH4_ITLB_AA_ASID_MASK 0x000000ff
#define SH4_ITLB_AA_V 0x00000100
#define SH4_ITLB_AA_VPN_SHIFT 10
#define SH4_ITLB_AA_VPN_MASK 0xfffffc00
#define SH4_ITLB_DA1 0xf3000000
#define SH4_ITLB_DA1_SH 0x00000002
#define SH4_ITLB_DA1_C 0x00000008
#define SH4_ITLB_DA1_SZ_MASK 0x00000090
#define SH4_ITLB_DA1_SZ_1K 0x00000000
#define SH4_ITLB_DA1_SZ_4K 0x00000010
#define SH4_ITLB_DA1_SZ_64K 0x00000080
#define SH4_ITLB_DA1_SZ_1M 0x00000090
#define SH4_ITLB_DA1_PR 0x00000040
#define SH4_ITLB_DA1_V 0x00000100
#define SH4_ITLB_DA1_PPN_SHIFT 11
#define SH4_ITLB_DA1_PPN_MASK 0x1ffffc00
#define SH4_ITLB_DA2 0xf3800000
#define SH4_ITLB_DA2_SA_MASK 0x00000003
#define SH4_ITLB_DA2_TC 0x00000004
#define SH4_UTLB_AA 0xf6000000
#define SH4_UTLB_E_SHIFT 8
#define SH4_UTLB_E_MASK 0x00003f00
#define SH4_UTLB_A 0x00000080
#define SH4_UTLB_AA_VPN_MASK 0xfffffc00
#define SH4_UTLB_AA_D 0x00000200
#define SH4_UTLB_AA_V 0x00000100
#define SH4_UTLB_AA_ASID_MASK 0x000000ff
#define SH4_UTLB_DA1 0xf7000000
#define SH4_UTLB_DA1_WT 0x00000001
#define SH4_UTLB_DA1_SH 0x00000002
#define SH4_UTLB_DA1_D 0x00000004
#define SH4_UTLB_DA1_C 0x00000008
#define SH4_UTLB_DA1_SZ_MASK 0x00000090
#define SH4_UTLB_DA1_SZ_1K 0x00000000
#define SH4_UTLB_DA1_SZ_4K 0x00000010
#define SH4_UTLB_DA1_SZ_64K 0x00000080
#define SH4_UTLB_DA1_SZ_1M 0x00000090
#define SH4_UTLB_DA1_PR_SHIFT 5
#define SH4_UTLB_DA1_PR_MASK 0x00000060
#define SH4_UTLB_DA1_V 0x00000100
#define SH4_UTLB_DA1_PPN_SHIFT 11
#define SH4_UTLB_DA1_PPN_MASK 0x1ffffc00
#define SH4_UTLB_DA2 0xf7800000
#define SH4_UTLB_DA2_SA_MASK 0x00000003
#define SH4_UTLB_DA2_TC 0x00000004
#define SH4_TLB_DISABLE *(volatile uint32_t *)SH4_MMUCR = SH4_MMUCR_TI
#endif