Changeset 0d776cd2 in rtems
- Timestamp:
- 05/14/02 16:56:44 (22 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- 6fae458
- Parents:
- 78f8c91
- Location:
- c/src/lib/libcpu/powerpc
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libcpu/powerpc/ChangeLog
r78f8c91 r0d776cd2 1 2001-05-14 Till Straumann <strauman@slac.stanford.edu> 2 3 * rtems/powerpc/registers.h, rtems/score/ppc.h: Per PR213, add 4 the following: 5 - support for the MPC74000 (AKA G4); there is no 6 AltiVec support yet, however. 7 - the cache flushing assembly code uses hardware-flush on the G4. 8 Also, a couple of hardcoded numerical values were replaced 9 by more readable symbolic constants. 10 - extended interrupt-disabled code section so enclose the entire 11 cache flush/invalidate procedure (as recommended by the book). 12 This is not (latency) critical as it is only used by 13 init code but prevents possible corruption. 14 - Trivial page table support as been added. 15 (1:1 effective-virtual-physical address mapping which is only 16 useful only on CPUs which feature hardware TLB replacement, 17 e.g. >604. This allows for write-protecting memory regions, 18 e.g. text/ro-data which makes catching corruptors a lot easier. 19 It also frees one DBAT/IBAT and gives more flexibility 20 for setting up address maps :-) 21 - setdbat() allows changing BAT0 also (since the BSP may use 22 a page table, BAT0 could be available...). 23 - asm_setdbatX() violated the SVR ABI by using 24 r20 as a scratch register; changed for r0 25 - according to the book, a context synchronizing instruction is 26 necessary prior to and after changing a DBAT -> isync added 27 1 28 2002-04-30 Ralf Corsepius <corsepiu@faw.uni-ulm.de> 2 29 -
c/src/lib/libcpu/powerpc/configure.ac
r78f8c91 r0d776cd2 29 29 30 30 AM_CONDITIONAL(shared, test "$RTEMS_CPU_MODEL" = "mpc750" \ 31 || test "$RTEMS_CPU_MODEL" = "mpc7400" \ 31 32 || test "$RTEMS_CPU_MODEL" = "ppc603e" \ 32 33 || test "$RTEMS_CPU_MODEL" = "mpc604" \ … … 41 42 AM_CONDITIONAL(mpc6xx, test "$RTEMS_CPU_MODEL" = "mpc6xx" \ 42 43 || test "$RTEMS_CPU_MODEL" = "mpc604" \ 44 || test "$RTEMS_CPU_MODEL" = "mpc7400" \ 43 45 || test "$RTEMS_CPU_MODEL" = "mpc750" ) 44 46 AM_CONDITIONAL(mpc8xx, test "$RTEMS_CPU_MODEL" = "mpc8xx" \ -
c/src/lib/libcpu/powerpc/mpc6xx/exceptions/raw_exception.c
r78f8c91 r0d776cd2 114 114 { 115 115 switch (current_ppc_cpu) { 116 case PPC_7400: 116 117 case PPC_750: 117 118 if (!mpc750_vector_is_valid(vector)) { -
c/src/lib/libcpu/powerpc/mpc6xx/mmu/Makefile.am
r78f8c91 r0d776cd2 6 6 PGM = $(ARCH)/mmu.rel 7 7 8 C_FILES = bat.c 8 C_FILES = bat.c pte121.c 9 9 10 10 S_FILES = mmuAsm.S … … 12 12 include_libcpudir = $(includedir)/libcpu 13 13 14 include_libcpu_HEADERS = bat.h 14 include_libcpu_HEADERS = bat.h pte121.h 15 15 16 16 mmu_rel_OBJECTS = $(C_FILES:%.c=$(ARCH)/%.o) $(S_FILES:%.S=$(ARCH)/%.o) … … 39 39 .PRECIOUS: $(PGM) 40 40 41 EXTRA_DIST = bat.c bat.h mmuAsm.S 41 EXTRA_DIST = bat.c bat.h mmuAsm.S pte121.c pte121.h 42 42 43 43 include $(top_srcdir)/../../../../../automake/local.am -
c/src/lib/libcpu/powerpc/mpc6xx/mmu/bat.c
r78f8c91 r0d776cd2 56 56 bat_addrs[bat_index].phys = phys; 57 57 switch (bat_index) { 58 case 0 : asm_setdbat1(bat.word[0], bat.word[1]); break; 58 59 case 1 : asm_setdbat1(bat.word[0], bat.word[1]); break; 59 60 case 2 : asm_setdbat2(bat.word[0], bat.word[1]); break; -
c/src/lib/libcpu/powerpc/mpc6xx/mmu/mmuAsm.S
r78f8c91 r0d776cd2 13 13 * http://www.OARcorp.com/rtems/license.html. 14 14 * 15 * T. Straumann - 11/2001: added support for 7400 (no AltiVec yet) 15 16 */ 16 17 … … 18 19 #include <rtems/score/cpu.h> 19 20 #include <libcpu/io.h> 21 22 /* Unfortunately, the CPU types defined in cpu.h are 23 * an 'enum' type and hence not available :-( 24 */ 25 #define PPC_601 0x1 26 #define PPC_603 0x3 27 #define PPC_604 0x4 28 #define PPC_603e 0x6 29 #define PPC_603ev 0x7 30 #define PPC_750 0x8 31 #define PPC_604e 0x9 32 #define PPC_604r 0xA 33 #define PPC_7400 0xC 34 #define PPC_620 0x16 35 #define PPC_860 0x50 36 #define PPC_821 PPC_860 37 #define PPC_8260 0x81 38 39 /* ALTIVEC instructions (not recognized by off-the shelf gcc yet) */ 40 #define DSSALL .long 0x7e00066c /* DSSALL altivec instruction opcode */ 41 42 /* A couple of defines to make the code more readable */ 43 #define CACHE_LINE_SIZE 32 44 45 #ifndef MSSCR0 46 #define MSSCR0 1014 47 #else 48 #warning MSSCR0 seems to be known, update __FILE__ 49 #endif 50 51 #define DL1HWF (1<<(31-8)) 52 #define L2HWF (1<<(31-20)) 53 54 20 55 21 56 /* … … 25 60 */ 26 61 62 .globl asm_setdbat0 63 .type asm_setdbat0,@function 64 asm_setdbat0: 65 li r0,0 66 sync 67 isync 68 mtspr DBAT0U,r0 69 mtspr DBAT0L,r0 70 sync 71 isync 72 mtspr DBAT0L, r4 73 mtspr DBAT0U, r3 74 sync 75 isync 76 blr 77 27 78 .globl asm_setdbat1 28 79 .type asm_setdbat1,@function 29 80 asm_setdbat1: 30 li r20,0 31 SYNC 32 mtspr DBAT1U,r20 33 mtspr DBAT1L,r20 34 SYNC 81 li r0,0 82 sync 83 isync 84 mtspr DBAT1U,r0 85 mtspr DBAT1L,r0 86 sync 87 isync 35 88 mtspr DBAT1L, r4 36 89 mtspr DBAT1U, r3 37 SYNC 90 sync 91 isync 38 92 blr 39 93 … … 41 95 .type asm_setdbat2,@function 42 96 asm_setdbat2: 43 li r20,0 44 SYNC 45 mtspr DBAT2U,r20 46 mtspr DBAT2L,r20 47 SYNC 97 li r0,0 98 sync 99 isync 100 mtspr DBAT2U,r0 101 mtspr DBAT2L,r0 102 sync 103 isync 48 104 mtspr DBAT2L, r4 49 105 mtspr DBAT2U, r3 50 SYNC 106 sync 107 isync 51 108 blr 52 109 … … 54 111 .type asm_setdbat3,@function 55 112 asm_setdbat3: 56 li r20,0 57 SYNC 58 mtspr DBAT3U,r20 59 mtspr DBAT3L,r20 60 SYNC 113 li r0,0 114 sync 115 isync 116 mtspr DBAT3U,r0 117 mtspr DBAT3L,r0 118 sync 119 isync 61 120 mtspr DBAT3L, r4 62 121 mtspr DBAT3U, r3 63 SYNC 122 sync 123 isync 64 124 blr 65 125 … … 73 133 mfspr r9,PVR 74 134 rlwinm r9,r9,16,16,31 75 cmpi 0,r9, 1135 cmpi 0,r9,PPC_601 76 136 beq 4f /* not needed for 601 */ 77 137 mfspr r11,HID0 … … 88 148 sync 89 149 isync 90 cmpi 0,r9, 4/* check for 604 */91 cmpi 1,r9, 9/* or 604e */92 cmpi 2,r9, 10/* or mach5 */150 cmpi 0,r9,PPC_604 /* check for 604 */ 151 cmpi 1,r9,PPC_604e /* or 604e */ 152 cmpi 2,r9,PPC_604r /* or mach5 */ 93 153 cror 2,2,6 94 154 cror 2,2,10 155 cmpi 1,r9,PPC_750 /* or 750 */ 156 cror 2,2,6 157 cmpi 1,r9,PPC_7400 /* or 7400 */ 158 bne 3f 159 ori r11,r11,HID0_BTIC /* enable branch tgt cache on 7400 */ 160 3: cror 2,2,6 95 161 bne 4f 162 /* on 7400 SIED is actually SGE (store gathering enable) */ 96 163 ori r11,r11,HID0_SIED|HID0_BHTE /* for 604[e], enable */ 97 164 bne 2,5f … … 104 171 .type get_L2CR, @function 105 172 get_L2CR: 106 /* Make sure this is a 750 chip */173 /* Make sure this is a > 750 chip */ 107 174 mfspr r3,PVR 108 175 rlwinm r3,r3,16,16,31 109 cmplwi r3,0x0008 176 cmplwi r3,PPC_750 /* it's a 750 */ 177 beq 1f 178 cmplwi r3,PPC_7400 /* it's a 7400 */ 179 beq 1f 110 180 li r3,0 111 bnelr 112 181 blr 182 183 1: 113 184 /* Return the L2CR contents */ 114 185 mfspr r3,L2CR … … 147 218 */ 148 219 149 /* Make sure this is a 750 chip */ 150 mfspr r4,PVR 151 rlwinm r4,r4,16,16,31 152 cmplwi r4,0x0008 220 /* Make sure this is a > 750 chip */ 221 mfspr r0,PVR 222 rlwinm r0,r0,16,16,31 223 cmplwi r0,PPC_750 224 beq thisIs750 225 cmplwi r0,PPC_7400 153 226 beq thisIs750 154 227 li r3,-1 … … 162 235 /* See if we want to perform a global inval this time. */ 163 236 rlwinm r6,r3,0,10,10 /* r6 contains the new invalidate bit */ 164 rlwinm. r5,r3,0,0,0 /* r5 contains the new enable bit */237 rlwinm. r5,r3,0,0,0 /* r5 contains the new enable bit */ 165 238 rlwinm r3,r3,0,11,9 /* Turn off the invalidate bit */ 166 239 rlwinm r3,r3,0,1,31 /* Turn off the enable bit */ 167 or r3,r3,r4 /* Keep the enable bit the same as it was for now. */ 168 bne dontDisableCache /* Only disable the cache if L2CRApply has the enable bit off */ 240 or r3,r3,r4 /* Keep the enable bit the same as it was for now. */ 241 mfmsr r7 /* shut off interrupts around critical flush/invalidate sections */ 242 rlwinm r4,r7,0,17,15 /* Turn off EE bit - an external exception while we are flushing 243 the cache is fatal (comment this line and see!) */ 244 mtmsr r4 245 bne dontDisableCache /* Only disable the cache if L2CRApply has the enable bit off */ 246 247 cmplwi r0,PPC_7400 /* > 7400 ? */ 248 bne disableCache /* use traditional method */ 249 250 /* On the 7400, they recommend using the hardware flush feature */ 251 DSSALL /* stop all data streams */ 252 sync 253 /* we wouldn't have to flush L1, but for sake of consistency with the other code we do it anyway */ 254 mfspr r4, MSSCR0 255 oris r4, r4, DL1HWF@h 256 mtspr MSSCR0, r4 257 sync 258 /* L1 flushed */ 259 mfspr r4, L2CR 260 ori r4, r4, L2HWF 261 mtspr L2CR, r4 262 sync 263 /* L2 flushed */ 264 b flushDone 169 265 170 266 disableCache: 171 267 /* Disable the cache. First, we turn off data relocation. */ 172 mfmsr r7 173 rlwinm r4,r7,0,28,26 /* Turn off DR bit */ 174 rlwinm r4,r4,0,17,15 /* Turn off EE bit - an external exception while we are flushing 175 the cache is fatal (comment this line and see!) */ 176 sync 268 rlwinm r4,r4,0,28,26 /* Turn off DR bit */ 177 269 mtmsr r4 178 sync270 isync /* make sure memory accesses have completed */ 179 271 180 272 /* … … 183 275 the size of the L1 cache, but 2MB will cover everything just to be safe). 184 276 */ 185 lis r4,0x0001277 lis r4,0x0001 186 278 mtctr r4 187 li r4,0279 li r4,0 188 280 loadLoop: 189 281 lwzx r0,r0,r4 190 addi r4,r4, 0x0020/* Go to start of next cache line */282 addi r4,r4,CACHE_LINE_SIZE /* Go to start of next cache line */ 191 283 bdnz loadLoop 192 284 193 285 /* Now, flush the first 2MB of memory */ 194 lis r4,0x0001286 lis r4,0x0001 195 287 mtctr r4 196 li r4,0288 li r4,0 197 289 sync 198 290 flushLoop: 199 291 dcbf r0,r4 200 addi r4,r4, 0x0020/* Go to start of next cache line */292 addi r4,r4,CACHE_LINE_SIZE /* Go to start of next cache line */ 201 293 bdnz flushLoop 294 sync 295 296 rlwinm r4,r7,0,17,15 /* still mask EE but reenable data relocation */ 297 mtmsr r4 298 isync 299 300 flushDone: 202 301 203 302 /* Turn off the L2CR enable bit. */ 204 303 rlwinm r3,r3,0,1,31 205 304 206 /* Reenable data relocation. */207 sync208 mtmsr r7209 sync210 211 305 dontDisableCache: 212 306 /* Set up the L2CR configuration bits */ … … 220 314 oris r3,r3,0x0020 221 315 sync 222 mtspr 1017,r3223 sync 224 invalCompleteLoop: /* Wait for the invalidation to complete */225 mfspr r3, 1017316 mtspr L2CR,r3 317 sync 318 invalCompleteLoop: /* Wait for the invalidation to complete */ 319 mfspr r3,L2CR 226 320 rlwinm. r4,r3,0,31,31 227 321 bne invalCompleteLoop … … 233 327 234 328 noInval: 329 /* re-enable interrupts, i.e. restore original MSR */ 330 mtmsr r7 /* (no sync needed) */ 235 331 /* See if we need to enable the cache */ 236 332 cmplwi r5,0 -
c/src/lib/libcpu/powerpc/shared/include/cpuIdent.c
r78f8c91 r0d776cd2 27 27 ppc_cpu_revision_t current_ppc_revision = 0xff; 28 28 29 char *get_ppc_cpu_type_name(ppc_cpu_id_t cpu) 30 { 31 switch (cpu) { 32 case PPC_601: return "MPC601"; 33 case PPC_603: return "MPC603"; 34 case PPC_603ev: return "MPC603ev"; 35 case PPC_604: return "MPC604"; 36 case PPC_750: return "MPC750"; 37 case PPC_7400: return "MPC7400"; 38 case PPC_604e: return "MPC604e"; 39 case PPC_604r: return "MPC604r"; 40 case PPC_620: return "MPC620"; 41 case PPC_860: return "MPC860"; 42 case PPC_8260: return "MPC8260"; 43 default: 44 printk("Unknown CPU value of 0x%x. Please add it to <libcpu/powerpc/shared/cpu.h>\n", cpu ); 45 } 46 return "UNKNOWN"; 47 } 48 29 49 ppc_cpu_id_t get_ppc_cpu_type() 30 50 { 31 51 unsigned int pvr = (_read_PVR() >> 16); 32 33 52 current_ppc_cpu = (ppc_cpu_id_t) pvr; 34 53 switch (pvr) { … … 38 57 case PPC_604: 39 58 case PPC_750: 59 case PPC_7400: 40 60 case PPC_604e: 41 61 case PPC_604r: … … 43 63 case PPC_860: 44 64 case PPC_8260: 45 current_ppc_cpu = (ppc_cpu_id_t) pvr;46 65 return current_ppc_cpu; 47 66 default: … … 49 68 return PPC_UNKNOWN; 50 69 } 51 52 70 } 71 53 72 ppc_cpu_revision_t get_ppc_cpu_revision() 54 73 { -
c/src/lib/libcpu/powerpc/shared/include/cpuIdent.h
r78f8c91 r0d776cd2 28 28 PPC_604e = 0x9, 29 29 PPC_604r = 0xA, 30 PPC_7400 = 0xA, 30 31 PPC_620 = 0x16, 31 32 PPC_860 = 0x50, … … 39 40 extern ppc_cpu_id_t get_ppc_cpu_type (); 40 41 extern ppc_cpu_id_t current_ppc_cpu; 42 extern char *get_ppc_cpu_type_name(ppc_cpu_id_t cpu); 41 43 extern ppc_cpu_revision_t get_ppc_cpu_revision (); 42 44 extern ppc_cpu_revision_t current_ppc_revision;
Note: See TracChangeset
for help on using the changeset viewer.