/* SPDX-License-Identifier: GPL-2.0 */1/*2* Copyright (C) 2008-2009 Michal Simek <[email protected]>3* Copyright (C) 2008-2009 PetaLogix4* Copyright (C) 2006 Atmark Techno, Inc.5*/67#ifndef _ASM_MICROBLAZE_MMU_H8#define _ASM_MICROBLAZE_MMU_H910# ifdef __KERNEL__11# ifndef __ASSEMBLY__1213/* Default "unsigned long" context */14typedef unsigned long mm_context_t;1516/* Hardware Page Table Entry */17typedef struct _PTE {18unsigned long v:1; /* Entry is valid */19unsigned long vsid:24; /* Virtual segment identifier */20unsigned long h:1; /* Hash algorithm indicator */21unsigned long api:6; /* Abbreviated page index */22unsigned long rpn:20; /* Real (physical) page number */23unsigned long :3; /* Unused */24unsigned long r:1; /* Referenced */25unsigned long c:1; /* Changed */26unsigned long w:1; /* Write-thru cache mode */27unsigned long i:1; /* Cache inhibited */28unsigned long m:1; /* Memory coherence */29unsigned long g:1; /* Guarded */30unsigned long :1; /* Unused */31unsigned long pp:2; /* Page protection */32} PTE;3334/* Values for PP (assumes Ks=0, Kp=1) */35# define PP_RWXX 0 /* Supervisor read/write, User none */36# define PP_RWRX 1 /* Supervisor read/write, User read */37# define PP_RWRW 2 /* Supervisor read/write, User read/write */38# define PP_RXRX 3 /* Supervisor read, User read */3940/* Segment Register */41typedef struct _SEGREG {42unsigned long t:1; /* Normal or I/O type */43unsigned long ks:1; /* Supervisor 'key' (normally 0) */44unsigned long kp:1; /* User 'key' (normally 1) */45unsigned long n:1; /* No-execute */46unsigned long :4; /* Unused */47unsigned long vsid:24; /* Virtual Segment Identifier */48} SEGREG;4950extern void _tlbie(unsigned long va); /* invalidate a TLB entry */51extern void _tlbia(void); /* invalidate all TLB entries */5253/*54* tlb_skip size stores actual number skipped TLBs from TLB0 - every directy TLB55* mapping has to increase tlb_skip size.56*/57extern u32 tlb_skip;58# endif /* __ASSEMBLY__ */5960/*61* The MicroBlaze processor has a TLB architecture identical to PPC-40x. The62* instruction and data sides share a unified, 64-entry, semi-associative63* TLB which is maintained totally under software control. In addition, the64* instruction side has a hardware-managed, 2,4, or 8-entry, fully-associative65* TLB which serves as a first level to the shared TLB. These two TLBs are66* known as the UTLB and ITLB, respectively.67*/6869# define MICROBLAZE_TLB_SIZE 647071/* For cases when you want to skip some TLB entries */72# define MICROBLAZE_TLB_SKIP 07374/* Use the last TLB for temporary access to LMB */75# define MICROBLAZE_LMB_TLB_ID 637677/*78* TLB entries are defined by a "high" tag portion and a "low" data79* portion. The data portion is 32-bits.80*81* TLB entries are managed entirely under software control by reading,82* writing, and searching using the MTS and MFS instructions.83*/8485# define TLB_LO 186# define TLB_HI 087# define TLB_DATA TLB_LO88# define TLB_TAG TLB_HI8990/* Tag portion */91# define TLB_EPN_MASK 0xFFFFFC00 /* Effective Page Number */92# define TLB_PAGESZ_MASK 0x0000038093# define TLB_PAGESZ(x) (((x) & 0x7) << 7)94# define PAGESZ_1K 095# define PAGESZ_4K 196# define PAGESZ_16K 297# define PAGESZ_64K 398# define PAGESZ_256K 499# define PAGESZ_1M 5100# define PAGESZ_4M 6101# define PAGESZ_16M 7102# define TLB_VALID 0x00000040 /* Entry is valid */103104/* Data portion */105# define TLB_RPN_MASK 0xFFFFFC00 /* Real Page Number */106# define TLB_PERM_MASK 0x00000300107# define TLB_EX 0x00000200 /* Instruction execution allowed */108# define TLB_WR 0x00000100 /* Writes permitted */109# define TLB_ZSEL_MASK 0x000000F0110# define TLB_ZSEL(x) (((x) & 0xF) << 4)111# define TLB_ATTR_MASK 0x0000000F112# define TLB_W 0x00000008 /* Caching is write-through */113# define TLB_I 0x00000004 /* Caching is inhibited */114# define TLB_M 0x00000002 /* Memory is coherent */115# define TLB_G 0x00000001 /* Memory is guarded from prefetch */116117# endif /* __KERNEL__ */118#endif /* _ASM_MICROBLAZE_MMU_H */119120121