162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (C) 2008-2009 Michal Simek <monstr@monstr.eu> 462306a36Sopenharmony_ci * Copyright (C) 2008-2009 PetaLogix 562306a36Sopenharmony_ci * Copyright (C) 2006 Atmark Techno, Inc. 662306a36Sopenharmony_ci */ 762306a36Sopenharmony_ci 862306a36Sopenharmony_ci#ifndef _ASM_MICROBLAZE_MMU_H 962306a36Sopenharmony_ci#define _ASM_MICROBLAZE_MMU_H 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ci# ifdef __KERNEL__ 1262306a36Sopenharmony_ci# ifndef __ASSEMBLY__ 1362306a36Sopenharmony_ci 1462306a36Sopenharmony_ci/* Default "unsigned long" context */ 1562306a36Sopenharmony_citypedef unsigned long mm_context_t; 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci/* Hardware Page Table Entry */ 1862306a36Sopenharmony_citypedef struct _PTE { 1962306a36Sopenharmony_ci unsigned long v:1; /* Entry is valid */ 2062306a36Sopenharmony_ci unsigned long vsid:24; /* Virtual segment identifier */ 2162306a36Sopenharmony_ci unsigned long h:1; /* Hash algorithm indicator */ 2262306a36Sopenharmony_ci unsigned long api:6; /* Abbreviated page index */ 2362306a36Sopenharmony_ci unsigned long rpn:20; /* Real (physical) page number */ 2462306a36Sopenharmony_ci unsigned long :3; /* Unused */ 2562306a36Sopenharmony_ci unsigned long r:1; /* Referenced */ 2662306a36Sopenharmony_ci unsigned long c:1; /* Changed */ 2762306a36Sopenharmony_ci unsigned long w:1; /* Write-thru cache mode */ 2862306a36Sopenharmony_ci unsigned long i:1; /* Cache inhibited */ 2962306a36Sopenharmony_ci unsigned long m:1; /* Memory coherence */ 3062306a36Sopenharmony_ci unsigned long g:1; /* Guarded */ 3162306a36Sopenharmony_ci unsigned long :1; /* Unused */ 3262306a36Sopenharmony_ci unsigned long pp:2; /* Page protection */ 3362306a36Sopenharmony_ci} PTE; 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci/* Values for PP (assumes Ks=0, Kp=1) */ 3662306a36Sopenharmony_ci# define PP_RWXX 0 /* Supervisor read/write, User none */ 3762306a36Sopenharmony_ci# define PP_RWRX 1 /* Supervisor read/write, User read */ 3862306a36Sopenharmony_ci# define PP_RWRW 2 /* Supervisor read/write, User read/write */ 3962306a36Sopenharmony_ci# define PP_RXRX 3 /* Supervisor read, User read */ 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci/* Segment Register */ 4262306a36Sopenharmony_citypedef struct _SEGREG { 4362306a36Sopenharmony_ci unsigned long t:1; /* Normal or I/O type */ 4462306a36Sopenharmony_ci unsigned long ks:1; /* Supervisor 'key' (normally 0) */ 4562306a36Sopenharmony_ci unsigned long kp:1; /* User 'key' (normally 1) */ 4662306a36Sopenharmony_ci unsigned long n:1; /* No-execute */ 4762306a36Sopenharmony_ci unsigned long :4; /* Unused */ 4862306a36Sopenharmony_ci unsigned long vsid:24; /* Virtual Segment Identifier */ 4962306a36Sopenharmony_ci} SEGREG; 5062306a36Sopenharmony_ci 5162306a36Sopenharmony_ciextern void _tlbie(unsigned long va); /* invalidate a TLB entry */ 5262306a36Sopenharmony_ciextern void _tlbia(void); /* invalidate all TLB entries */ 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_ci/* 5562306a36Sopenharmony_ci * tlb_skip size stores actual number skipped TLBs from TLB0 - every directy TLB 5662306a36Sopenharmony_ci * mapping has to increase tlb_skip size. 5762306a36Sopenharmony_ci */ 5862306a36Sopenharmony_ciextern u32 tlb_skip; 5962306a36Sopenharmony_ci# endif /* __ASSEMBLY__ */ 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ci/* 6262306a36Sopenharmony_ci * The MicroBlaze processor has a TLB architecture identical to PPC-40x. The 6362306a36Sopenharmony_ci * instruction and data sides share a unified, 64-entry, semi-associative 6462306a36Sopenharmony_ci * TLB which is maintained totally under software control. In addition, the 6562306a36Sopenharmony_ci * instruction side has a hardware-managed, 2,4, or 8-entry, fully-associative 6662306a36Sopenharmony_ci * TLB which serves as a first level to the shared TLB. These two TLBs are 6762306a36Sopenharmony_ci * known as the UTLB and ITLB, respectively. 6862306a36Sopenharmony_ci */ 6962306a36Sopenharmony_ci 7062306a36Sopenharmony_ci# define MICROBLAZE_TLB_SIZE 64 7162306a36Sopenharmony_ci 7262306a36Sopenharmony_ci/* For cases when you want to skip some TLB entries */ 7362306a36Sopenharmony_ci# define MICROBLAZE_TLB_SKIP 0 7462306a36Sopenharmony_ci 7562306a36Sopenharmony_ci/* Use the last TLB for temporary access to LMB */ 7662306a36Sopenharmony_ci# define MICROBLAZE_LMB_TLB_ID 63 7762306a36Sopenharmony_ci 7862306a36Sopenharmony_ci/* 7962306a36Sopenharmony_ci * TLB entries are defined by a "high" tag portion and a "low" data 8062306a36Sopenharmony_ci * portion. The data portion is 32-bits. 8162306a36Sopenharmony_ci * 8262306a36Sopenharmony_ci * TLB entries are managed entirely under software control by reading, 8362306a36Sopenharmony_ci * writing, and searching using the MTS and MFS instructions. 8462306a36Sopenharmony_ci */ 8562306a36Sopenharmony_ci 8662306a36Sopenharmony_ci# define TLB_LO 1 8762306a36Sopenharmony_ci# define TLB_HI 0 8862306a36Sopenharmony_ci# define TLB_DATA TLB_LO 8962306a36Sopenharmony_ci# define TLB_TAG TLB_HI 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci/* Tag portion */ 9262306a36Sopenharmony_ci# define TLB_EPN_MASK 0xFFFFFC00 /* Effective Page Number */ 9362306a36Sopenharmony_ci# define TLB_PAGESZ_MASK 0x00000380 9462306a36Sopenharmony_ci# define TLB_PAGESZ(x) (((x) & 0x7) << 7) 9562306a36Sopenharmony_ci# define PAGESZ_1K 0 9662306a36Sopenharmony_ci# define PAGESZ_4K 1 9762306a36Sopenharmony_ci# define PAGESZ_16K 2 9862306a36Sopenharmony_ci# define PAGESZ_64K 3 9962306a36Sopenharmony_ci# define PAGESZ_256K 4 10062306a36Sopenharmony_ci# define PAGESZ_1M 5 10162306a36Sopenharmony_ci# define PAGESZ_4M 6 10262306a36Sopenharmony_ci# define PAGESZ_16M 7 10362306a36Sopenharmony_ci# define TLB_VALID 0x00000040 /* Entry is valid */ 10462306a36Sopenharmony_ci 10562306a36Sopenharmony_ci/* Data portion */ 10662306a36Sopenharmony_ci# define TLB_RPN_MASK 0xFFFFFC00 /* Real Page Number */ 10762306a36Sopenharmony_ci# define TLB_PERM_MASK 0x00000300 10862306a36Sopenharmony_ci# define TLB_EX 0x00000200 /* Instruction execution allowed */ 10962306a36Sopenharmony_ci# define TLB_WR 0x00000100 /* Writes permitted */ 11062306a36Sopenharmony_ci# define TLB_ZSEL_MASK 0x000000F0 11162306a36Sopenharmony_ci# define TLB_ZSEL(x) (((x) & 0xF) << 4) 11262306a36Sopenharmony_ci# define TLB_ATTR_MASK 0x0000000F 11362306a36Sopenharmony_ci# define TLB_W 0x00000008 /* Caching is write-through */ 11462306a36Sopenharmony_ci# define TLB_I 0x00000004 /* Caching is inhibited */ 11562306a36Sopenharmony_ci# define TLB_M 0x00000002 /* Memory is coherent */ 11662306a36Sopenharmony_ci# define TLB_G 0x00000001 /* Memory is guarded from prefetch */ 11762306a36Sopenharmony_ci 11862306a36Sopenharmony_ci# endif /* __KERNEL__ */ 11962306a36Sopenharmony_ci#endif /* _ASM_MICROBLAZE_MMU_H */ 120