![]() |
|
|||
File indexing completed on 2025-05-11 08:23:59
0001 #ifndef RTEMS_VIRTEX4_MMU_H 0002 #define RTEMS_VIRTEX4_MMU_H 0003 /** 0004 * @file 0005 * 0006 * @ingroup RTEMSBSPsPowerPCVirtex4MMU 0007 * 0008 * @brief Routines to manipulate the PPC 405 MMU. 0009 */ 0010 /* 0011 * Authorship 0012 * ---------- 0013 * This software was created by 0014 * Till Straumann <strauman@slac.stanford.edu>, 2005-2007, 0015 * Stanford Linear Accelerator Center, Stanford University. 0016 * and was transcribed for the PPC 405 by 0017 * R. Claus <claus@slac.stanford.edu>, 2012, 0018 * Stanford Linear Accelerator Center, Stanford University, 0019 * 0020 * Acknowledgement of sponsorship 0021 * ------------------------------ 0022 * This software was produced by 0023 * the Stanford Linear Accelerator Center, Stanford University, 0024 * under Contract DE-AC03-76SFO0515 with the Department of Energy. 0025 * 0026 * Government disclaimer of liability 0027 * ---------------------------------- 0028 * Neither the United States nor the United States Department of Energy, 0029 * nor any of their employees, makes any warranty, express or implied, or 0030 * assumes any legal liability or responsibility for the accuracy, 0031 * completeness, or usefulness of any data, apparatus, product, or process 0032 * disclosed, or represents that its use would not infringe privately owned 0033 * rights. 0034 * 0035 * Stanford disclaimer of liability 0036 * -------------------------------- 0037 * Stanford University makes no representations or warranties, express or 0038 * implied, nor assumes any liability for the use of this software. 0039 * 0040 * Stanford disclaimer of copyright 0041 * -------------------------------- 0042 * Stanford University, owner of the copyright, hereby disclaims its 0043 * copyright and all other rights in this software. Hence, anyone may 0044 * freely use it for any purpose without restriction. 0045 * 0046 * Maintenance of notices 0047 * ---------------------- 0048 * In the interest of clarity regarding the origin and status of this 0049 * SLAC software, this and all the preceding Stanford University notices 0050 * are to remain affixed to any copy or derivative of this software made 0051 * or distributed by the recipient and are to be affixed to any copy of 0052 * software made or distributed by the recipient that contains a copy or 0053 * derivative of this software. 0054 * 0055 * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03 0056 */ 0057 0058 #include <rtems.h> 0059 #include <inttypes.h> 0060 #include <stdio.h> 0061 0062 #ifdef __cplusplus 0063 extern "C" { 0064 #endif 0065 0066 /** 0067 * @defgroup Virtex4MMU Virtex 4 - MMU Support 0068 * 0069 * @ingroup RTEMSBSPsPowerPCVirtex4 0070 * 0071 * @brief MMU support. 0072 * 0073 * @{ 0074 */ 0075 0076 /* Some routines require or return a index 'key'. 0077 */ 0078 typedef int bsp_tlb_idx_t; 0079 0080 /* Cache the relevant TLB entries so that we can make sure the user cannot 0081 * create conflicting (overlapping) entries. Keep them public for informational 0082 * purposes. 0083 */ 0084 typedef struct { 0085 struct { 0086 uint32_t pad:24; 0087 uint32_t tid:8; /** Translation ID */ 0088 } id; 0089 struct { 0090 uint32_t epn:22; /** Effective page number */ 0091 uint32_t size:3; /** Page size */ 0092 uint32_t v:1; /** Valid */ 0093 uint32_t att:2; /** Little-endian, User-defined */ 0094 uint32_t pad:4; 0095 } hi; /** High word*/ 0096 struct { 0097 uint32_t rpn:22; /** Real page number */ 0098 uint32_t perm:6; /** Execute enable, Write-enable, Zone select */ 0099 uint32_t wimg:4; /** Write-through, Caching inhibited, Mem coherent, Guarded */ 0100 } lo; /** Low word */ 0101 } bsp_tlb_entry_t; 0102 0103 #define NTLBS 64 0104 0105 extern bsp_tlb_entry_t* bsp_mmu_cache; 0106 0107 0108 // These constants will have to be shifted right by 20 bits before 0109 // being inserted the high word of the TLB. 0110 0111 #define MMU_M_SIZE_1K (0x00000000U) 0112 #define MMU_M_SIZE_4K (0x08000000U) 0113 #define MMU_M_SIZE_16K (0x10000000U) 0114 #define MMU_M_SIZE_64K (0x18000000U) 0115 #define MMU_M_SIZE_256K (0x20000000U) 0116 #define MMU_M_SIZE_1M (0x28000000U) 0117 #define MMU_M_SIZE_4M (0x30000000U) 0118 #define MMU_M_SIZE_16M (0x38000000U) 0119 #define MMU_M_SIZE_MIN (MMU_M_SIZE_1K) 0120 #define MMU_M_SIZE_MAX (MMU_M_SIZE_16M) 0121 #define MMU_M_SIZE (0x38000000U) 0122 #define MMU_V_SIZE (27) 0123 0124 #define MMU_M_ATTR_LITTLE_ENDIAN (0x02000000U) 0125 #define MMU_M_ATTR_USER0 (0x01000000U) 0126 #define MMU_M_ATTR (0x03000000U) 0127 #define MMU_V_ATTR (24) 0128 0129 // These constants have the same bit positions they'll occupy 0130 // in low word of the TLB. 0131 0132 #define MMU_M_PERM_EXEC (0x00000200U) 0133 #define MMU_M_PERM_DATA_WRITE (0x00000100U) 0134 #define MMU_M_PERM_ZONE_SELECT (0x000000f0U) 0135 #define MMU_M_PERM (0x000003f0U) 0136 #define MMU_V_PERM (4) 0137 0138 #define MMU_M_PROP_WRITE_THROUGH (0x00000008U) 0139 #define MMU_M_PROP_UNCACHED (0x00000004U) 0140 #define MMU_M_PROP_MEM_COHERENT (0x00000002U) 0141 #define MMU_M_PROP_GUARDED (0x00000001U) 0142 #define MMU_M_PROP (0x0000000fU) 0143 #define MMU_V_PROP (0) 0144 0145 0146 /* 0147 * Dump (cleartext) content info from cached TLB entries 0148 * to a file (stdout if f==NULL). 0149 */ 0150 void 0151 bsp_mmu_dump_cache(FILE *f); 0152 0153 /* Read a TLB entry from the hardware and store the settings in the 0154 * bsp_mmu_cache[] structure. 0155 * 0156 * The routine can perform this operation quietly or 0157 * print information to a file. 0158 * 0159 * 'key': TLB entry index. 0160 * 'quiet': perform operation silently (no info printed) if nonzero. 0161 * 'f': open FILE where to print information. May be NULL, in 0162 * which case 'stdout' is used. 0163 * 0164 * RETURNS: 0165 * 0: success; TLB entry is VALID 0166 * +1: success but TLB entry is INVALID 0167 * < 0: error (-1: invalid argument) 0168 * (-2: driver not initialized) 0169 */ 0170 int 0171 bsp_mmu_update(bsp_tlb_idx_t key, bool quiet, FILE *f); 0172 0173 /* Initialize cache. Should be done only once although this is not enforced. 0174 * 0175 * RETURNS: zero on success, nonzero on error; in this case the driver will 0176 * refuse to change TLB entries (other than disabling them). 0177 */ 0178 int 0179 bsp_mmu_initialize(void); 0180 0181 /* Find first free TLB entry by examining all entries' valid bit. The first 0182 * entry without the valid bit set is returned. 0183 * 0184 * RETURNS: A free TLB entry number. -1 if no entry can be found. 0185 */ 0186 bsp_tlb_idx_t 0187 bsp_mmu_find_first_free(void); 0188 0189 /* Write a TLB entry (can also be used to disable an entry). 0190 * 0191 * The routine checks against the cached data in bsp_mmu_cache[] 0192 * to prevent the user from generating overlapping entries. 0193 * 0194 * 'idx': TLB entry # to manipulate 0195 * 'ea': Effective address (must be page aligned) 0196 * 'pa': Physical address (must be page aligned) 0197 * 'sz': Page size selector; page size is 1024 * 2^(2*sz) bytes. 0198 * 'sz' may also be one of the following: 0199 * - page size in bytes ( >= 1024 ); the selector 0200 * value is then computed by this routine. 0201 * However, 'sz' must be a valid page size 0202 * or -1 will be returned. 0203 * - a value < 0 to invalidate/disable the 0204 * TLB entry. 0205 * 'flgs': Page's little-endian & user-defined flags, permissions and attributes 0206 * 'tid': Translation ID 0207 * 0208 * RETURNS: 0 on success, nonzero on error: 0209 * 0210 * >0: requested mapping would overlap with 0211 * existing mapping in another entry. Return 0212 * value gives conflicting entry + 1; i.e., 0213 * if a value of 4 is returned then the request 0214 * conflicts with existing mapping in entry 3. 0215 * -1: invalid argument 0216 * -3: driver not initialized (or initialization failed). 0217 * <0: other error 0218 */ 0219 bsp_tlb_idx_t 0220 bsp_mmu_write(bsp_tlb_idx_t idx, uint32_t ea, uint32_t pa, uint sz, 0221 uint32_t flgs, uint32_t tid); 0222 0223 /* Check if a ea/tid/sz mapping overlaps with an existing entry. 0224 * 0225 * 'ea': The Effective Address to match against 0226 * 'sz': The 'logarithmic' size selector; the page size 0227 * is 1024*2^(2*sz). 0228 * 'tid': The TID to match against 0229 * 0230 * RETURNS: 0231 * >= 0: index of TLB entry that already provides a mapping 0232 * which overlaps within the ea range. 0233 * -1: SUCCESS (no conflicting entry found) 0234 * <=-2: ERROR (invalid input) 0235 */ 0236 bsp_tlb_idx_t 0237 bsp_mmu_match(uint32_t ea, int sz, uint32_t tid); 0238 0239 /* Find TLB index that maps 'ea/tid' combination 0240 * 0241 * 'ea': Effective address to match against 0242 * 'tid': The TID to match against 0243 * 0244 * RETURNS: index 'key'; i.e., the index number. 0245 * 0246 * On error (no mapping) -1 is returned. 0247 */ 0248 bsp_tlb_idx_t 0249 bsp_mmu_find(uint32_t ea, uint32_t tid); 0250 0251 /* Mark TLB entry as invalid ('disabled'). 0252 * 0253 * 'key': TLB entry index. 0254 * 0255 * RETURNS: zero on success, nonzero on error (TLB unchanged). 0256 * 0257 * NOTE: If a TLB entry is disabled the associated 0258 * entry in bsp_mmu_cache[] is also marked as disabled. 0259 */ 0260 int 0261 bsp_mmu_invalidate(bsp_tlb_idx_t key); 0262 0263 /** @} */ 0264 0265 #ifdef __cplusplus 0266 }; 0267 #endif 0268 0269 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |