1 /* 2 * PowerPC CPU initialization for qemu. 3 * 4 * Copyright (c) 2003-2007 Jocelyn Mayer 5 * Copyright 2011 Freescale Semiconductor, Inc. 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, see <http://www.gnu.org/licenses/>. 19 */ 20 21 #include "qemu/osdep.h" 22 #include "disas/dis-asm.h" 23 #include "gdbstub/helpers.h" 24 #include "kvm_ppc.h" 25 #include "sysemu/cpus.h" 26 #include "sysemu/hw_accel.h" 27 #include "sysemu/tcg.h" 28 #include "cpu-models.h" 29 #include "mmu-hash32.h" 30 #include "mmu-hash64.h" 31 #include "qemu/error-report.h" 32 #include "qemu/module.h" 33 #include "qemu/qemu-print.h" 34 #include "qapi/error.h" 35 #include "qapi/qmp/qnull.h" 36 #include "qapi/visitor.h" 37 #include "hw/qdev-properties.h" 38 #include "hw/ppc/ppc.h" 39 #include "mmu-book3s-v3.h" 40 #include "qemu/cutils.h" 41 #include "disas/capstone.h" 42 #include "fpu/softfloat.h" 43 44 #include "helper_regs.h" 45 #include "internal.h" 46 #include "spr_common.h" 47 #include "power8-pmu.h" 48 49 #ifndef CONFIG_USER_ONLY 50 #include "hw/boards.h" 51 #include "hw/intc/intc.h" 52 #endif 53 54 /* #define PPC_DEBUG_SPR */ 55 /* #define USE_APPLE_GDB */ 56 57 static inline void vscr_init(CPUPPCState *env, uint32_t val) 58 { 59 /* Altivec always uses round-to-nearest */ 60 set_float_rounding_mode(float_round_nearest_even, &env->vec_status); 61 ppc_store_vscr(env, val); 62 } 63 64 static void register_745_sprs(CPUPPCState *env) 65 { 66 /* SGPRs */ 67 spr_register(env, SPR_SPRG4, "SPRG4", 68 SPR_NOACCESS, SPR_NOACCESS, 69 &spr_read_generic, &spr_write_generic, 70 0x00000000); 71 spr_register(env, SPR_SPRG5, "SPRG5", 72 SPR_NOACCESS, SPR_NOACCESS, 73 &spr_read_generic, &spr_write_generic, 74 0x00000000); 75 spr_register(env, SPR_SPRG6, "SPRG6", 76 SPR_NOACCESS, SPR_NOACCESS, 77 &spr_read_generic, &spr_write_generic, 78 0x00000000); 79 spr_register(env, SPR_SPRG7, "SPRG7", 80 SPR_NOACCESS, SPR_NOACCESS, 81 &spr_read_generic, &spr_write_generic, 82 0x00000000); 83 84 /* Hardware implementation registers */ 85 spr_register(env, SPR_HID0, "HID0", 86 SPR_NOACCESS, SPR_NOACCESS, 87 &spr_read_generic, &spr_write_generic, 88 0x00000000); 89 90 spr_register(env, SPR_HID1, "HID1", 91 SPR_NOACCESS, SPR_NOACCESS, 92 &spr_read_generic, &spr_write_generic, 93 0x00000000); 94 95 spr_register(env, SPR_HID2, "HID2", 96 SPR_NOACCESS, SPR_NOACCESS, 97 &spr_read_generic, &spr_write_generic, 98 0x00000000); 99 } 100 101 static void register_755_sprs(CPUPPCState *env) 102 { 103 /* L2 cache control */ 104 spr_register(env, SPR_L2CR, "L2CR", 105 SPR_NOACCESS, SPR_NOACCESS, 106 &spr_read_generic, spr_access_nop, 107 0x00000000); 108 109 spr_register(env, SPR_L2PMCR, "L2PMCR", 110 SPR_NOACCESS, SPR_NOACCESS, 111 &spr_read_generic, &spr_write_generic, 112 0x00000000); 113 } 114 115 /* SPR common to all 7xx PowerPC implementations */ 116 static void register_7xx_sprs(CPUPPCState *env) 117 { 118 /* Breakpoints */ 119 spr_register_kvm(env, SPR_DABR, "DABR", 120 SPR_NOACCESS, SPR_NOACCESS, 121 &spr_read_generic, &spr_write_generic, 122 KVM_REG_PPC_DABR, 0x00000000); 123 124 spr_register(env, SPR_IABR, "IABR", 125 SPR_NOACCESS, SPR_NOACCESS, 126 &spr_read_generic, &spr_write_generic, 127 0x00000000); 128 /* Cache management */ 129 spr_register(env, SPR_ICTC, "ICTC", 130 SPR_NOACCESS, SPR_NOACCESS, 131 &spr_read_generic, &spr_write_generic, 132 0x00000000); 133 /* Performance monitors */ 134 spr_register(env, SPR_7XX_MMCR0, "MMCR0", 135 SPR_NOACCESS, SPR_NOACCESS, 136 &spr_read_generic, &spr_write_generic, 137 0x00000000); 138 139 spr_register(env, SPR_7XX_MMCR1, "MMCR1", 140 SPR_NOACCESS, SPR_NOACCESS, 141 &spr_read_generic, &spr_write_generic, 142 0x00000000); 143 144 spr_register(env, SPR_7XX_PMC1, "PMC1", 145 SPR_NOACCESS, SPR_NOACCESS, 146 &spr_read_generic, &spr_write_generic, 147 0x00000000); 148 149 spr_register(env, SPR_7XX_PMC2, "PMC2", 150 SPR_NOACCESS, SPR_NOACCESS, 151 &spr_read_generic, &spr_write_generic, 152 0x00000000); 153 154 spr_register(env, SPR_7XX_PMC3, "PMC3", 155 SPR_NOACCESS, SPR_NOACCESS, 156 &spr_read_generic, &spr_write_generic, 157 0x00000000); 158 159 spr_register(env, SPR_7XX_PMC4, "PMC4", 160 SPR_NOACCESS, SPR_NOACCESS, 161 &spr_read_generic, &spr_write_generic, 162 0x00000000); 163 164 spr_register(env, SPR_7XX_SIAR, "SIAR", 165 SPR_NOACCESS, SPR_NOACCESS, 166 &spr_read_generic, SPR_NOACCESS, 167 0x00000000); 168 169 spr_register(env, SPR_7XX_UMMCR0, "UMMCR0", 170 &spr_read_ureg, SPR_NOACCESS, 171 &spr_read_ureg, SPR_NOACCESS, 172 0x00000000); 173 174 spr_register(env, SPR_7XX_UMMCR1, "UMMCR1", 175 &spr_read_ureg, SPR_NOACCESS, 176 &spr_read_ureg, SPR_NOACCESS, 177 0x00000000); 178 179 spr_register(env, SPR_7XX_UPMC1, "UPMC1", 180 &spr_read_ureg, SPR_NOACCESS, 181 &spr_read_ureg, SPR_NOACCESS, 182 0x00000000); 183 184 spr_register(env, SPR_7XX_UPMC2, "UPMC2", 185 &spr_read_ureg, SPR_NOACCESS, 186 &spr_read_ureg, SPR_NOACCESS, 187 0x00000000); 188 189 spr_register(env, SPR_7XX_UPMC3, "UPMC3", 190 &spr_read_ureg, SPR_NOACCESS, 191 &spr_read_ureg, SPR_NOACCESS, 192 0x00000000); 193 194 spr_register(env, SPR_7XX_UPMC4, "UPMC4", 195 &spr_read_ureg, SPR_NOACCESS, 196 &spr_read_ureg, SPR_NOACCESS, 197 0x00000000); 198 199 spr_register(env, SPR_7XX_USIAR, "USIAR", 200 &spr_read_ureg, SPR_NOACCESS, 201 &spr_read_ureg, SPR_NOACCESS, 202 0x00000000); 203 /* External access control */ 204 spr_register(env, SPR_EAR, "EAR", 205 SPR_NOACCESS, SPR_NOACCESS, 206 &spr_read_generic, &spr_write_generic, 207 0x00000000); 208 209 /* Hardware implementation registers */ 210 spr_register(env, SPR_HID0, "HID0", 211 SPR_NOACCESS, SPR_NOACCESS, 212 &spr_read_generic, &spr_write_generic, 213 0x00000000); 214 215 spr_register(env, SPR_HID1, "HID1", 216 SPR_NOACCESS, SPR_NOACCESS, 217 &spr_read_generic, &spr_write_generic, 218 0x00000000); 219 } 220 221 #ifdef TARGET_PPC64 222 static void register_amr_sprs(CPUPPCState *env) 223 { 224 #ifndef CONFIG_USER_ONLY 225 /* 226 * Virtual Page Class Key protection 227 * 228 * The AMR is accessible either via SPR 13 or SPR 29. 13 is 229 * userspace accessible, 29 is privileged. So we only need to set 230 * the kvm ONE_REG id on one of them, we use 29 231 */ 232 spr_register(env, SPR_UAMR, "UAMR", 233 &spr_read_generic, &spr_write_amr, 234 &spr_read_generic, &spr_write_amr, 235 0); 236 spr_register_kvm_hv(env, SPR_AMR, "AMR", 237 SPR_NOACCESS, SPR_NOACCESS, 238 &spr_read_generic, &spr_write_amr, 239 &spr_read_generic, &spr_write_generic, 240 KVM_REG_PPC_AMR, 0); 241 spr_register_kvm_hv(env, SPR_UAMOR, "UAMOR", 242 SPR_NOACCESS, SPR_NOACCESS, 243 &spr_read_generic, &spr_write_uamor, 244 &spr_read_generic, &spr_write_generic, 245 KVM_REG_PPC_UAMOR, 0); 246 spr_register_hv(env, SPR_AMOR, "AMOR", 247 SPR_NOACCESS, SPR_NOACCESS, 248 SPR_NOACCESS, SPR_NOACCESS, 249 &spr_read_generic, &spr_write_generic, 250 0); 251 #endif /* !CONFIG_USER_ONLY */ 252 } 253 254 static void register_iamr_sprs(CPUPPCState *env) 255 { 256 #ifndef CONFIG_USER_ONLY 257 spr_register_kvm_hv(env, SPR_IAMR, "IAMR", 258 SPR_NOACCESS, SPR_NOACCESS, 259 &spr_read_generic, &spr_write_iamr, 260 &spr_read_generic, &spr_write_generic, 261 KVM_REG_PPC_IAMR, 0); 262 #endif /* !CONFIG_USER_ONLY */ 263 } 264 #endif /* TARGET_PPC64 */ 265 266 /* SPR specific to PowerPC 604 implementation */ 267 static void register_604_sprs(CPUPPCState *env) 268 { 269 /* Processor identification */ 270 spr_register(env, SPR_PIR, "PIR", 271 SPR_NOACCESS, SPR_NOACCESS, 272 &spr_read_generic, &spr_write_pir, 273 0x00000000); 274 /* Breakpoints */ 275 spr_register(env, SPR_IABR, "IABR", 276 SPR_NOACCESS, SPR_NOACCESS, 277 &spr_read_generic, &spr_write_generic, 278 0x00000000); 279 280 spr_register_kvm(env, SPR_DABR, "DABR", 281 SPR_NOACCESS, SPR_NOACCESS, 282 &spr_read_generic, &spr_write_generic, 283 KVM_REG_PPC_DABR, 0x00000000); 284 /* Performance counters */ 285 spr_register(env, SPR_7XX_MMCR0, "MMCR0", 286 SPR_NOACCESS, SPR_NOACCESS, 287 &spr_read_generic, &spr_write_generic, 288 0x00000000); 289 290 spr_register(env, SPR_7XX_PMC1, "PMC1", 291 SPR_NOACCESS, SPR_NOACCESS, 292 &spr_read_generic, &spr_write_generic, 293 0x00000000); 294 295 spr_register(env, SPR_7XX_PMC2, "PMC2", 296 SPR_NOACCESS, SPR_NOACCESS, 297 &spr_read_generic, &spr_write_generic, 298 0x00000000); 299 300 spr_register(env, SPR_7XX_SIAR, "SIAR", 301 SPR_NOACCESS, SPR_NOACCESS, 302 &spr_read_generic, SPR_NOACCESS, 303 0x00000000); 304 305 spr_register(env, SPR_SDA, "SDA", 306 SPR_NOACCESS, SPR_NOACCESS, 307 &spr_read_generic, SPR_NOACCESS, 308 0x00000000); 309 /* External access control */ 310 spr_register(env, SPR_EAR, "EAR", 311 SPR_NOACCESS, SPR_NOACCESS, 312 &spr_read_generic, &spr_write_generic, 313 0x00000000); 314 315 /* Hardware implementation registers */ 316 spr_register(env, SPR_HID0, "HID0", 317 SPR_NOACCESS, SPR_NOACCESS, 318 &spr_read_generic, &spr_write_generic, 319 0x00000000); 320 } 321 322 static void register_604e_sprs(CPUPPCState *env) 323 { 324 spr_register(env, SPR_7XX_MMCR1, "MMCR1", 325 SPR_NOACCESS, SPR_NOACCESS, 326 &spr_read_generic, &spr_write_generic, 327 0x00000000); 328 329 spr_register(env, SPR_7XX_PMC3, "PMC3", 330 SPR_NOACCESS, SPR_NOACCESS, 331 &spr_read_generic, &spr_write_generic, 332 0x00000000); 333 334 spr_register(env, SPR_7XX_PMC4, "PMC4", 335 SPR_NOACCESS, SPR_NOACCESS, 336 &spr_read_generic, &spr_write_generic, 337 0x00000000); 338 /* Hardware implementation registers */ 339 spr_register(env, SPR_HID1, "HID1", 340 SPR_NOACCESS, SPR_NOACCESS, 341 &spr_read_generic, &spr_write_generic, 342 0x00000000); 343 } 344 345 /* SPR specific to PowerPC 603 implementation */ 346 static void register_603_sprs(CPUPPCState *env) 347 { 348 /* External access control */ 349 spr_register(env, SPR_EAR, "EAR", 350 SPR_NOACCESS, SPR_NOACCESS, 351 &spr_read_generic, &spr_write_generic, 352 0x00000000); 353 /* Breakpoints */ 354 spr_register(env, SPR_IABR, "IABR", 355 SPR_NOACCESS, SPR_NOACCESS, 356 &spr_read_generic, &spr_write_generic, 357 0x00000000); 358 359 spr_register(env, SPR_HID0, "HID0", 360 SPR_NOACCESS, SPR_NOACCESS, 361 &spr_read_generic, &spr_write_generic, 362 0x00000000); 363 364 spr_register(env, SPR_HID1, "HID1", 365 SPR_NOACCESS, SPR_NOACCESS, 366 &spr_read_generic, &spr_write_generic, 367 0x00000000); 368 } 369 370 static void register_e300_sprs(CPUPPCState *env) 371 { 372 /* hardware implementation registers */ 373 spr_register(env, SPR_HID2, "HID2", 374 SPR_NOACCESS, SPR_NOACCESS, 375 &spr_read_generic, &spr_write_generic, 376 0x00000000); 377 /* Breakpoints */ 378 spr_register(env, SPR_DABR, "DABR", 379 SPR_NOACCESS, SPR_NOACCESS, 380 &spr_read_generic, &spr_write_generic, 381 0x00000000); 382 383 spr_register(env, SPR_DABR2, "DABR2", 384 SPR_NOACCESS, SPR_NOACCESS, 385 &spr_read_generic, &spr_write_generic, 386 0x00000000); 387 388 spr_register(env, SPR_IABR2, "IABR2", 389 SPR_NOACCESS, SPR_NOACCESS, 390 &spr_read_generic, &spr_write_generic, 391 0x00000000); 392 393 spr_register(env, SPR_IBCR, "IBCR", 394 SPR_NOACCESS, SPR_NOACCESS, 395 &spr_read_generic, &spr_write_generic, 396 0x00000000); 397 398 spr_register(env, SPR_DBCR, "DBCR", 399 SPR_NOACCESS, SPR_NOACCESS, 400 &spr_read_generic, &spr_write_generic, 401 0x00000000); 402 } 403 404 /* SPR specific to PowerPC G2 implementation */ 405 static void register_G2_sprs(CPUPPCState *env) 406 { 407 /* Memory base address */ 408 /* MBAR */ 409 spr_register(env, SPR_MBAR, "MBAR", 410 SPR_NOACCESS, SPR_NOACCESS, 411 &spr_read_generic, &spr_write_generic, 412 0x00000000); 413 /* Exception processing */ 414 spr_register(env, SPR_BOOKE_CSRR0, "CSRR0", 415 SPR_NOACCESS, SPR_NOACCESS, 416 &spr_read_generic, &spr_write_generic, 417 0x00000000); 418 spr_register(env, SPR_BOOKE_CSRR1, "CSRR1", 419 SPR_NOACCESS, SPR_NOACCESS, 420 &spr_read_generic, &spr_write_generic, 421 0x00000000); 422 /* Breakpoints */ 423 spr_register(env, SPR_DABR, "DABR", 424 SPR_NOACCESS, SPR_NOACCESS, 425 &spr_read_generic, &spr_write_generic, 426 0x00000000); 427 428 spr_register(env, SPR_DABR2, "DABR2", 429 SPR_NOACCESS, SPR_NOACCESS, 430 &spr_read_generic, &spr_write_generic, 431 0x00000000); 432 433 spr_register(env, SPR_IABR, "IABR", 434 SPR_NOACCESS, SPR_NOACCESS, 435 &spr_read_generic, &spr_write_generic, 436 0x00000000); 437 438 spr_register(env, SPR_IABR2, "IABR2", 439 SPR_NOACCESS, SPR_NOACCESS, 440 &spr_read_generic, &spr_write_generic, 441 0x00000000); 442 443 spr_register(env, SPR_IBCR, "IBCR", 444 SPR_NOACCESS, SPR_NOACCESS, 445 &spr_read_generic, &spr_write_generic, 446 0x00000000); 447 448 spr_register(env, SPR_DBCR, "DBCR", 449 SPR_NOACCESS, SPR_NOACCESS, 450 &spr_read_generic, &spr_write_generic, 451 0x00000000); 452 453 /* External access control */ 454 spr_register(env, SPR_EAR, "EAR", 455 SPR_NOACCESS, SPR_NOACCESS, 456 &spr_read_generic, &spr_write_generic, 457 0x00000000); 458 /* Hardware implementation register */ 459 spr_register(env, SPR_HID0, "HID0", 460 SPR_NOACCESS, SPR_NOACCESS, 461 &spr_read_generic, &spr_write_generic, 462 0x00000000); 463 464 spr_register(env, SPR_HID1, "HID1", 465 SPR_NOACCESS, SPR_NOACCESS, 466 &spr_read_generic, &spr_write_generic, 467 0x00000000); 468 469 spr_register(env, SPR_HID2, "HID2", 470 SPR_NOACCESS, SPR_NOACCESS, 471 &spr_read_generic, &spr_write_generic, 472 0x00000000); 473 474 /* SGPRs */ 475 spr_register(env, SPR_SPRG4, "SPRG4", 476 SPR_NOACCESS, SPR_NOACCESS, 477 &spr_read_generic, &spr_write_generic, 478 0x00000000); 479 spr_register(env, SPR_SPRG5, "SPRG5", 480 SPR_NOACCESS, SPR_NOACCESS, 481 &spr_read_generic, &spr_write_generic, 482 0x00000000); 483 spr_register(env, SPR_SPRG6, "SPRG6", 484 SPR_NOACCESS, SPR_NOACCESS, 485 &spr_read_generic, &spr_write_generic, 486 0x00000000); 487 spr_register(env, SPR_SPRG7, "SPRG7", 488 SPR_NOACCESS, SPR_NOACCESS, 489 &spr_read_generic, &spr_write_generic, 490 0x00000000); 491 } 492 493 static void register_74xx_sprs(CPUPPCState *env) 494 { 495 /* Breakpoints */ 496 spr_register_kvm(env, SPR_DABR, "DABR", 497 SPR_NOACCESS, SPR_NOACCESS, 498 &spr_read_generic, &spr_write_generic, 499 KVM_REG_PPC_DABR, 0x00000000); 500 501 spr_register(env, SPR_IABR, "IABR", 502 SPR_NOACCESS, SPR_NOACCESS, 503 &spr_read_generic, &spr_write_generic, 504 0x00000000); 505 /* Cache management */ 506 spr_register(env, SPR_ICTC, "ICTC", 507 SPR_NOACCESS, SPR_NOACCESS, 508 &spr_read_generic, &spr_write_generic, 509 0x00000000); 510 /* Performance monitors */ 511 spr_register(env, SPR_7XX_MMCR0, "MMCR0", 512 SPR_NOACCESS, SPR_NOACCESS, 513 &spr_read_generic, &spr_write_generic, 514 0x00000000); 515 516 spr_register(env, SPR_7XX_MMCR1, "MMCR1", 517 SPR_NOACCESS, SPR_NOACCESS, 518 &spr_read_generic, &spr_write_generic, 519 0x00000000); 520 521 spr_register(env, SPR_7XX_PMC1, "PMC1", 522 SPR_NOACCESS, SPR_NOACCESS, 523 &spr_read_generic, &spr_write_generic, 524 0x00000000); 525 526 spr_register(env, SPR_7XX_PMC2, "PMC2", 527 SPR_NOACCESS, SPR_NOACCESS, 528 &spr_read_generic, &spr_write_generic, 529 0x00000000); 530 531 spr_register(env, SPR_7XX_PMC3, "PMC3", 532 SPR_NOACCESS, SPR_NOACCESS, 533 &spr_read_generic, &spr_write_generic, 534 0x00000000); 535 536 spr_register(env, SPR_7XX_PMC4, "PMC4", 537 SPR_NOACCESS, SPR_NOACCESS, 538 &spr_read_generic, &spr_write_generic, 539 0x00000000); 540 541 spr_register(env, SPR_7XX_SIAR, "SIAR", 542 SPR_NOACCESS, SPR_NOACCESS, 543 &spr_read_generic, SPR_NOACCESS, 544 0x00000000); 545 546 spr_register(env, SPR_7XX_UMMCR0, "UMMCR0", 547 &spr_read_ureg, SPR_NOACCESS, 548 &spr_read_ureg, SPR_NOACCESS, 549 0x00000000); 550 551 spr_register(env, SPR_7XX_UMMCR1, "UMMCR1", 552 &spr_read_ureg, SPR_NOACCESS, 553 &spr_read_ureg, SPR_NOACCESS, 554 0x00000000); 555 556 spr_register(env, SPR_7XX_UPMC1, "UPMC1", 557 &spr_read_ureg, SPR_NOACCESS, 558 &spr_read_ureg, SPR_NOACCESS, 559 0x00000000); 560 561 spr_register(env, SPR_7XX_UPMC2, "UPMC2", 562 &spr_read_ureg, SPR_NOACCESS, 563 &spr_read_ureg, SPR_NOACCESS, 564 0x00000000); 565 566 spr_register(env, SPR_7XX_UPMC3, "UPMC3", 567 &spr_read_ureg, SPR_NOACCESS, 568 &spr_read_ureg, SPR_NOACCESS, 569 0x00000000); 570 571 spr_register(env, SPR_7XX_UPMC4, "UPMC4", 572 &spr_read_ureg, SPR_NOACCESS, 573 &spr_read_ureg, SPR_NOACCESS, 574 0x00000000); 575 576 spr_register(env, SPR_7XX_USIAR, "USIAR", 577 &spr_read_ureg, SPR_NOACCESS, 578 &spr_read_ureg, SPR_NOACCESS, 579 0x00000000); 580 /* External access control */ 581 spr_register(env, SPR_EAR, "EAR", 582 SPR_NOACCESS, SPR_NOACCESS, 583 &spr_read_generic, &spr_write_generic, 584 0x00000000); 585 586 /* Processor identification */ 587 spr_register(env, SPR_PIR, "PIR", 588 SPR_NOACCESS, SPR_NOACCESS, 589 &spr_read_generic, &spr_write_pir, 590 0x00000000); 591 592 spr_register(env, SPR_74XX_MMCR2, "MMCR2", 593 SPR_NOACCESS, SPR_NOACCESS, 594 &spr_read_generic, &spr_write_generic, 595 0x00000000); 596 597 spr_register(env, SPR_74XX_UMMCR2, "UMMCR2", 598 &spr_read_ureg, SPR_NOACCESS, 599 &spr_read_ureg, SPR_NOACCESS, 600 0x00000000); 601 602 spr_register(env, SPR_BAMR, "BAMR", 603 SPR_NOACCESS, SPR_NOACCESS, 604 &spr_read_generic, &spr_write_generic, 605 0x00000000); 606 607 spr_register(env, SPR_MSSCR0, "MSSCR0", 608 SPR_NOACCESS, SPR_NOACCESS, 609 &spr_read_generic, &spr_write_generic, 610 0x00000000); 611 /* Hardware implementation registers */ 612 spr_register(env, SPR_HID0, "HID0", 613 SPR_NOACCESS, SPR_NOACCESS, 614 &spr_read_generic, &spr_write_generic, 615 0x00000000); 616 617 spr_register(env, SPR_HID1, "HID1", 618 SPR_NOACCESS, SPR_NOACCESS, 619 &spr_read_generic, &spr_write_generic, 620 0x00000000); 621 /* Altivec */ 622 spr_register(env, SPR_VRSAVE, "VRSAVE", 623 &spr_read_generic, &spr_write_generic, 624 &spr_read_generic, &spr_write_generic, 625 0x00000000); 626 627 spr_register(env, SPR_L2CR, "L2CR", 628 SPR_NOACCESS, SPR_NOACCESS, 629 &spr_read_generic, spr_access_nop, 630 0x00000000); 631 } 632 633 static void register_l3_ctrl(CPUPPCState *env) 634 { 635 /* L3CR */ 636 spr_register(env, SPR_L3CR, "L3CR", 637 SPR_NOACCESS, SPR_NOACCESS, 638 &spr_read_generic, &spr_write_generic, 639 0x00000000); 640 /* L3ITCR0 */ 641 spr_register(env, SPR_L3ITCR0, "L3ITCR0", 642 SPR_NOACCESS, SPR_NOACCESS, 643 &spr_read_generic, &spr_write_generic, 644 0x00000000); 645 /* L3PM */ 646 spr_register(env, SPR_L3PM, "L3PM", 647 SPR_NOACCESS, SPR_NOACCESS, 648 &spr_read_generic, &spr_write_generic, 649 0x00000000); 650 } 651 652 /* PowerPC BookE SPR */ 653 static void register_BookE_sprs(CPUPPCState *env, uint64_t ivor_mask) 654 { 655 const char *ivor_names[64] = { 656 "IVOR0", "IVOR1", "IVOR2", "IVOR3", 657 "IVOR4", "IVOR5", "IVOR6", "IVOR7", 658 "IVOR8", "IVOR9", "IVOR10", "IVOR11", 659 "IVOR12", "IVOR13", "IVOR14", "IVOR15", 660 "IVOR16", "IVOR17", "IVOR18", "IVOR19", 661 "IVOR20", "IVOR21", "IVOR22", "IVOR23", 662 "IVOR24", "IVOR25", "IVOR26", "IVOR27", 663 "IVOR28", "IVOR29", "IVOR30", "IVOR31", 664 "IVOR32", "IVOR33", "IVOR34", "IVOR35", 665 "IVOR36", "IVOR37", "IVOR38", "IVOR39", 666 "IVOR40", "IVOR41", "IVOR42", "IVOR43", 667 "IVOR44", "IVOR45", "IVOR46", "IVOR47", 668 "IVOR48", "IVOR49", "IVOR50", "IVOR51", 669 "IVOR52", "IVOR53", "IVOR54", "IVOR55", 670 "IVOR56", "IVOR57", "IVOR58", "IVOR59", 671 "IVOR60", "IVOR61", "IVOR62", "IVOR63", 672 }; 673 #define SPR_BOOKE_IVORxx (-1) 674 int ivor_sprn[64] = { 675 SPR_BOOKE_IVOR0, SPR_BOOKE_IVOR1, SPR_BOOKE_IVOR2, SPR_BOOKE_IVOR3, 676 SPR_BOOKE_IVOR4, SPR_BOOKE_IVOR5, SPR_BOOKE_IVOR6, SPR_BOOKE_IVOR7, 677 SPR_BOOKE_IVOR8, SPR_BOOKE_IVOR9, SPR_BOOKE_IVOR10, SPR_BOOKE_IVOR11, 678 SPR_BOOKE_IVOR12, SPR_BOOKE_IVOR13, SPR_BOOKE_IVOR14, SPR_BOOKE_IVOR15, 679 SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, 680 SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, 681 SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, 682 SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, 683 SPR_BOOKE_IVOR32, SPR_BOOKE_IVOR33, SPR_BOOKE_IVOR34, SPR_BOOKE_IVOR35, 684 SPR_BOOKE_IVOR36, SPR_BOOKE_IVOR37, SPR_BOOKE_IVOR38, SPR_BOOKE_IVOR39, 685 SPR_BOOKE_IVOR40, SPR_BOOKE_IVOR41, SPR_BOOKE_IVOR42, SPR_BOOKE_IVORxx, 686 SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, 687 SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, 688 SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, 689 SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, 690 SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, SPR_BOOKE_IVORxx, 691 }; 692 int i; 693 694 /* Interrupt processing */ 695 spr_register(env, SPR_BOOKE_CSRR0, "CSRR0", 696 SPR_NOACCESS, SPR_NOACCESS, 697 &spr_read_generic, &spr_write_generic, 698 0x00000000); 699 spr_register(env, SPR_BOOKE_CSRR1, "CSRR1", 700 SPR_NOACCESS, SPR_NOACCESS, 701 &spr_read_generic, &spr_write_generic, 702 0x00000000); 703 /* Debug */ 704 spr_register(env, SPR_BOOKE_IAC1, "IAC1", 705 SPR_NOACCESS, SPR_NOACCESS, 706 &spr_read_generic, &spr_write_generic, 707 0x00000000); 708 709 spr_register(env, SPR_BOOKE_IAC2, "IAC2", 710 SPR_NOACCESS, SPR_NOACCESS, 711 &spr_read_generic, &spr_write_generic, 712 0x00000000); 713 714 spr_register(env, SPR_BOOKE_DAC1, "DAC1", 715 SPR_NOACCESS, SPR_NOACCESS, 716 &spr_read_generic, &spr_write_generic, 717 0x00000000); 718 719 spr_register(env, SPR_BOOKE_DAC2, "DAC2", 720 SPR_NOACCESS, SPR_NOACCESS, 721 &spr_read_generic, &spr_write_generic, 722 0x00000000); 723 724 spr_register(env, SPR_BOOKE_DBCR0, "DBCR0", 725 SPR_NOACCESS, SPR_NOACCESS, 726 &spr_read_generic, &spr_write_40x_dbcr0, 727 0x00000000); 728 729 spr_register(env, SPR_BOOKE_DBCR1, "DBCR1", 730 SPR_NOACCESS, SPR_NOACCESS, 731 &spr_read_generic, &spr_write_generic, 732 0x00000000); 733 734 spr_register(env, SPR_BOOKE_DBCR2, "DBCR2", 735 SPR_NOACCESS, SPR_NOACCESS, 736 &spr_read_generic, &spr_write_generic, 737 0x00000000); 738 spr_register(env, SPR_BOOKE_DSRR0, "DSRR0", 739 SPR_NOACCESS, SPR_NOACCESS, 740 &spr_read_generic, &spr_write_generic, 741 0x00000000); 742 spr_register(env, SPR_BOOKE_DSRR1, "DSRR1", 743 SPR_NOACCESS, SPR_NOACCESS, 744 &spr_read_generic, &spr_write_generic, 745 0x00000000); 746 747 spr_register(env, SPR_BOOKE_DBSR, "DBSR", 748 SPR_NOACCESS, SPR_NOACCESS, 749 &spr_read_generic, &spr_write_clear, 750 0x00000000); 751 spr_register(env, SPR_BOOKE_DEAR, "DEAR", 752 SPR_NOACCESS, SPR_NOACCESS, 753 &spr_read_generic, &spr_write_generic, 754 0x00000000); 755 spr_register(env, SPR_BOOKE_ESR, "ESR", 756 SPR_NOACCESS, SPR_NOACCESS, 757 &spr_read_generic, &spr_write_generic, 758 0x00000000); 759 spr_register(env, SPR_BOOKE_IVPR, "IVPR", 760 SPR_NOACCESS, SPR_NOACCESS, 761 &spr_read_generic, &spr_write_excp_prefix, 762 0x00000000); 763 /* Exception vectors */ 764 for (i = 0; i < 64; i++) { 765 if (ivor_mask & (1ULL << i)) { 766 if (ivor_sprn[i] == SPR_BOOKE_IVORxx) { 767 fprintf(stderr, "ERROR: IVOR %d SPR is not defined\n", i); 768 exit(1); 769 } 770 spr_register(env, ivor_sprn[i], ivor_names[i], 771 SPR_NOACCESS, SPR_NOACCESS, 772 &spr_read_generic, &spr_write_excp_vector, 773 0x00000000); 774 } 775 } 776 spr_register(env, SPR_BOOKE_PID, "PID", 777 SPR_NOACCESS, SPR_NOACCESS, 778 &spr_read_generic, &spr_write_booke_pid, 779 0x00000000); 780 spr_register(env, SPR_BOOKE_TCR, "TCR", 781 SPR_NOACCESS, SPR_NOACCESS, 782 &spr_read_generic, &spr_write_booke_tcr, 783 0x00000000); 784 spr_register(env, SPR_BOOKE_TSR, "TSR", 785 SPR_NOACCESS, SPR_NOACCESS, 786 &spr_read_generic, &spr_write_booke_tsr, 787 0x00000000); 788 /* Timer */ 789 spr_register(env, SPR_DECR, "DECR", 790 SPR_NOACCESS, SPR_NOACCESS, 791 &spr_read_decr, &spr_write_decr, 792 0x00000000); 793 spr_register(env, SPR_BOOKE_DECAR, "DECAR", 794 SPR_NOACCESS, SPR_NOACCESS, 795 SPR_NOACCESS, &spr_write_generic, 796 0x00000000); 797 /* SPRGs */ 798 spr_register(env, SPR_USPRG0, "USPRG0", 799 &spr_read_generic, &spr_write_generic, 800 &spr_read_generic, &spr_write_generic, 801 0x00000000); 802 spr_register(env, SPR_SPRG4, "SPRG4", 803 SPR_NOACCESS, SPR_NOACCESS, 804 &spr_read_generic, &spr_write_generic, 805 0x00000000); 806 spr_register(env, SPR_SPRG5, "SPRG5", 807 SPR_NOACCESS, SPR_NOACCESS, 808 &spr_read_generic, &spr_write_generic, 809 0x00000000); 810 spr_register(env, SPR_SPRG6, "SPRG6", 811 SPR_NOACCESS, SPR_NOACCESS, 812 &spr_read_generic, &spr_write_generic, 813 0x00000000); 814 spr_register(env, SPR_SPRG7, "SPRG7", 815 SPR_NOACCESS, SPR_NOACCESS, 816 &spr_read_generic, &spr_write_generic, 817 0x00000000); 818 spr_register(env, SPR_BOOKE_SPRG8, "SPRG8", 819 SPR_NOACCESS, SPR_NOACCESS, 820 &spr_read_generic, &spr_write_generic, 821 0x00000000); 822 spr_register(env, SPR_BOOKE_SPRG9, "SPRG9", 823 SPR_NOACCESS, SPR_NOACCESS, 824 &spr_read_generic, &spr_write_generic, 825 0x00000000); 826 } 827 828 #if !defined(CONFIG_USER_ONLY) 829 static inline uint32_t register_tlbncfg(uint32_t assoc, uint32_t minsize, 830 uint32_t maxsize, uint32_t flags, 831 uint32_t nentries) 832 { 833 return (assoc << TLBnCFG_ASSOC_SHIFT) | 834 (minsize << TLBnCFG_MINSIZE_SHIFT) | 835 (maxsize << TLBnCFG_MAXSIZE_SHIFT) | 836 flags | nentries; 837 } 838 #endif /* !CONFIG_USER_ONLY */ 839 840 /* BookE 2.06 storage control registers */ 841 static void register_BookE206_sprs(CPUPPCState *env, uint32_t mas_mask, 842 uint32_t *tlbncfg, uint32_t mmucfg) 843 { 844 #if !defined(CONFIG_USER_ONLY) 845 const char *mas_names[8] = { 846 "MAS0", "MAS1", "MAS2", "MAS3", "MAS4", "MAS5", "MAS6", "MAS7", 847 }; 848 int mas_sprn[8] = { 849 SPR_BOOKE_MAS0, SPR_BOOKE_MAS1, SPR_BOOKE_MAS2, SPR_BOOKE_MAS3, 850 SPR_BOOKE_MAS4, SPR_BOOKE_MAS5, SPR_BOOKE_MAS6, SPR_BOOKE_MAS7, 851 }; 852 int i; 853 854 /* TLB assist registers */ 855 for (i = 0; i < 8; i++) { 856 if (mas_mask & (1 << i)) { 857 spr_register(env, mas_sprn[i], mas_names[i], 858 SPR_NOACCESS, SPR_NOACCESS, 859 &spr_read_generic, 860 (i == 2 && (env->insns_flags & PPC_64B)) 861 ? &spr_write_generic : &spr_write_generic32, 862 0x00000000); 863 } 864 } 865 if (env->nb_pids > 1) { 866 spr_register(env, SPR_BOOKE_PID1, "PID1", 867 SPR_NOACCESS, SPR_NOACCESS, 868 &spr_read_generic, &spr_write_booke_pid, 869 0x00000000); 870 } 871 if (env->nb_pids > 2) { 872 spr_register(env, SPR_BOOKE_PID2, "PID2", 873 SPR_NOACCESS, SPR_NOACCESS, 874 &spr_read_generic, &spr_write_booke_pid, 875 0x00000000); 876 } 877 878 spr_register(env, SPR_BOOKE_EPLC, "EPLC", 879 SPR_NOACCESS, SPR_NOACCESS, 880 &spr_read_generic, &spr_write_eplc, 881 0x00000000); 882 spr_register(env, SPR_BOOKE_EPSC, "EPSC", 883 SPR_NOACCESS, SPR_NOACCESS, 884 &spr_read_generic, &spr_write_epsc, 885 0x00000000); 886 887 spr_register(env, SPR_MMUCFG, "MMUCFG", 888 SPR_NOACCESS, SPR_NOACCESS, 889 &spr_read_generic, SPR_NOACCESS, 890 mmucfg); 891 switch (env->nb_ways) { 892 case 4: 893 spr_register(env, SPR_BOOKE_TLB3CFG, "TLB3CFG", 894 SPR_NOACCESS, SPR_NOACCESS, 895 &spr_read_generic, SPR_NOACCESS, 896 tlbncfg[3]); 897 /* Fallthru */ 898 case 3: 899 spr_register(env, SPR_BOOKE_TLB2CFG, "TLB2CFG", 900 SPR_NOACCESS, SPR_NOACCESS, 901 &spr_read_generic, SPR_NOACCESS, 902 tlbncfg[2]); 903 /* Fallthru */ 904 case 2: 905 spr_register(env, SPR_BOOKE_TLB1CFG, "TLB1CFG", 906 SPR_NOACCESS, SPR_NOACCESS, 907 &spr_read_generic, SPR_NOACCESS, 908 tlbncfg[1]); 909 /* Fallthru */ 910 case 1: 911 spr_register(env, SPR_BOOKE_TLB0CFG, "TLB0CFG", 912 SPR_NOACCESS, SPR_NOACCESS, 913 &spr_read_generic, SPR_NOACCESS, 914 tlbncfg[0]); 915 /* Fallthru */ 916 case 0: 917 default: 918 break; 919 } 920 #endif 921 } 922 923 /* SPR specific to PowerPC 440 implementation */ 924 static void register_440_sprs(CPUPPCState *env) 925 { 926 /* Cache control */ 927 spr_register(env, SPR_440_DNV0, "DNV0", 928 SPR_NOACCESS, SPR_NOACCESS, 929 &spr_read_generic, &spr_write_generic, 930 0x00000000); 931 932 spr_register(env, SPR_440_DNV1, "DNV1", 933 SPR_NOACCESS, SPR_NOACCESS, 934 &spr_read_generic, &spr_write_generic, 935 0x00000000); 936 937 spr_register(env, SPR_440_DNV2, "DNV2", 938 SPR_NOACCESS, SPR_NOACCESS, 939 &spr_read_generic, &spr_write_generic, 940 0x00000000); 941 942 spr_register(env, SPR_440_DNV3, "DNV3", 943 SPR_NOACCESS, SPR_NOACCESS, 944 &spr_read_generic, &spr_write_generic, 945 0x00000000); 946 947 spr_register(env, SPR_440_DTV0, "DTV0", 948 SPR_NOACCESS, SPR_NOACCESS, 949 &spr_read_generic, &spr_write_generic, 950 0x00000000); 951 952 spr_register(env, SPR_440_DTV1, "DTV1", 953 SPR_NOACCESS, SPR_NOACCESS, 954 &spr_read_generic, &spr_write_generic, 955 0x00000000); 956 957 spr_register(env, SPR_440_DTV2, "DTV2", 958 SPR_NOACCESS, SPR_NOACCESS, 959 &spr_read_generic, &spr_write_generic, 960 0x00000000); 961 962 spr_register(env, SPR_440_DTV3, "DTV3", 963 SPR_NOACCESS, SPR_NOACCESS, 964 &spr_read_generic, &spr_write_generic, 965 0x00000000); 966 967 spr_register(env, SPR_440_DVLIM, "DVLIM", 968 SPR_NOACCESS, SPR_NOACCESS, 969 &spr_read_generic, &spr_write_generic, 970 0x00000000); 971 972 spr_register(env, SPR_440_INV0, "INV0", 973 SPR_NOACCESS, SPR_NOACCESS, 974 &spr_read_generic, &spr_write_generic, 975 0x00000000); 976 977 spr_register(env, SPR_440_INV1, "INV1", 978 SPR_NOACCESS, SPR_NOACCESS, 979 &spr_read_generic, &spr_write_generic, 980 0x00000000); 981 982 spr_register(env, SPR_440_INV2, "INV2", 983 SPR_NOACCESS, SPR_NOACCESS, 984 &spr_read_generic, &spr_write_generic, 985 0x00000000); 986 987 spr_register(env, SPR_440_INV3, "INV3", 988 SPR_NOACCESS, SPR_NOACCESS, 989 &spr_read_generic, &spr_write_generic, 990 0x00000000); 991 992 spr_register(env, SPR_440_ITV0, "ITV0", 993 SPR_NOACCESS, SPR_NOACCESS, 994 &spr_read_generic, &spr_write_generic, 995 0x00000000); 996 997 spr_register(env, SPR_440_ITV1, "ITV1", 998 SPR_NOACCESS, SPR_NOACCESS, 999 &spr_read_generic, &spr_write_generic, 1000 0x00000000); 1001 1002 spr_register(env, SPR_440_ITV2, "ITV2", 1003 SPR_NOACCESS, SPR_NOACCESS, 1004 &spr_read_generic, &spr_write_generic, 1005 0x00000000); 1006 1007 spr_register(env, SPR_440_ITV3, "ITV3", 1008 SPR_NOACCESS, SPR_NOACCESS, 1009 &spr_read_generic, &spr_write_generic, 1010 0x00000000); 1011 1012 spr_register(env, SPR_440_IVLIM, "IVLIM", 1013 SPR_NOACCESS, SPR_NOACCESS, 1014 &spr_read_generic, &spr_write_generic, 1015 0x00000000); 1016 /* Cache debug */ 1017 spr_register(env, SPR_BOOKE_DCDBTRH, "DCDBTRH", 1018 SPR_NOACCESS, SPR_NOACCESS, 1019 &spr_read_generic, SPR_NOACCESS, 1020 0x00000000); 1021 1022 spr_register(env, SPR_BOOKE_DCDBTRL, "DCDBTRL", 1023 SPR_NOACCESS, SPR_NOACCESS, 1024 &spr_read_generic, SPR_NOACCESS, 1025 0x00000000); 1026 1027 spr_register(env, SPR_BOOKE_ICDBDR, "ICDBDR", 1028 SPR_NOACCESS, SPR_NOACCESS, 1029 &spr_read_generic, SPR_NOACCESS, 1030 0x00000000); 1031 1032 spr_register(env, SPR_BOOKE_ICDBTRH, "ICDBTRH", 1033 SPR_NOACCESS, SPR_NOACCESS, 1034 &spr_read_generic, SPR_NOACCESS, 1035 0x00000000); 1036 1037 spr_register(env, SPR_BOOKE_ICDBTRL, "ICDBTRL", 1038 SPR_NOACCESS, SPR_NOACCESS, 1039 &spr_read_generic, SPR_NOACCESS, 1040 0x00000000); 1041 1042 spr_register(env, SPR_440_DBDR, "DBDR", 1043 SPR_NOACCESS, SPR_NOACCESS, 1044 &spr_read_generic, &spr_write_generic, 1045 0x00000000); 1046 /* Processor control */ 1047 spr_register(env, SPR_4xx_CCR0, "CCR0", 1048 SPR_NOACCESS, SPR_NOACCESS, 1049 &spr_read_generic, &spr_write_generic, 1050 0x00000000); 1051 spr_register(env, SPR_440_RSTCFG, "RSTCFG", 1052 SPR_NOACCESS, SPR_NOACCESS, 1053 &spr_read_generic, SPR_NOACCESS, 1054 0x00000000); 1055 /* Storage control */ 1056 spr_register(env, SPR_440_MMUCR, "MMUCR", 1057 SPR_NOACCESS, SPR_NOACCESS, 1058 &spr_read_generic, &spr_write_generic, 1059 0x00000000); 1060 1061 /* Processor identification */ 1062 spr_register(env, SPR_BOOKE_PIR, "PIR", 1063 SPR_NOACCESS, SPR_NOACCESS, 1064 &spr_read_generic, &spr_write_pir, 1065 0x00000000); 1066 1067 spr_register(env, SPR_BOOKE_IAC3, "IAC3", 1068 SPR_NOACCESS, SPR_NOACCESS, 1069 &spr_read_generic, &spr_write_generic, 1070 0x00000000); 1071 1072 spr_register(env, SPR_BOOKE_IAC4, "IAC4", 1073 SPR_NOACCESS, SPR_NOACCESS, 1074 &spr_read_generic, &spr_write_generic, 1075 0x00000000); 1076 1077 spr_register(env, SPR_BOOKE_DVC1, "DVC1", 1078 SPR_NOACCESS, SPR_NOACCESS, 1079 &spr_read_generic, &spr_write_generic, 1080 0x00000000); 1081 1082 spr_register(env, SPR_BOOKE_DVC2, "DVC2", 1083 SPR_NOACCESS, SPR_NOACCESS, 1084 &spr_read_generic, &spr_write_generic, 1085 0x00000000); 1086 } 1087 1088 /* SPR shared between PowerPC 40x implementations */ 1089 static void register_40x_sprs(CPUPPCState *env) 1090 { 1091 /* Cache */ 1092 /* not emulated, as QEMU do not emulate caches */ 1093 spr_register(env, SPR_40x_DCCR, "DCCR", 1094 SPR_NOACCESS, SPR_NOACCESS, 1095 &spr_read_generic, &spr_write_generic, 1096 0x00000000); 1097 /* not emulated, as QEMU do not emulate caches */ 1098 spr_register(env, SPR_40x_ICCR, "ICCR", 1099 SPR_NOACCESS, SPR_NOACCESS, 1100 &spr_read_generic, &spr_write_generic, 1101 0x00000000); 1102 /* not emulated, as QEMU do not emulate caches */ 1103 spr_register(env, SPR_BOOKE_ICDBDR, "ICDBDR", 1104 SPR_NOACCESS, SPR_NOACCESS, 1105 &spr_read_generic, SPR_NOACCESS, 1106 0x00000000); 1107 /* Exception */ 1108 spr_register(env, SPR_40x_DEAR, "DEAR", 1109 SPR_NOACCESS, SPR_NOACCESS, 1110 &spr_read_generic, &spr_write_generic, 1111 0x00000000); 1112 spr_register(env, SPR_40x_ESR, "ESR", 1113 SPR_NOACCESS, SPR_NOACCESS, 1114 &spr_read_generic, &spr_write_generic, 1115 0x00000000); 1116 spr_register(env, SPR_40x_EVPR, "EVPR", 1117 SPR_NOACCESS, SPR_NOACCESS, 1118 &spr_read_generic, &spr_write_excp_prefix, 1119 0x00000000); 1120 spr_register(env, SPR_40x_SRR2, "SRR2", 1121 &spr_read_generic, &spr_write_generic, 1122 &spr_read_generic, &spr_write_generic, 1123 0x00000000); 1124 spr_register(env, SPR_40x_SRR3, "SRR3", 1125 &spr_read_generic, &spr_write_generic, 1126 &spr_read_generic, &spr_write_generic, 1127 0x00000000); 1128 /* Timers */ 1129 spr_register(env, SPR_40x_PIT, "PIT", 1130 SPR_NOACCESS, SPR_NOACCESS, 1131 &spr_read_40x_pit, &spr_write_40x_pit, 1132 0x00000000); 1133 spr_register(env, SPR_40x_TCR, "TCR", 1134 SPR_NOACCESS, SPR_NOACCESS, 1135 &spr_read_generic, &spr_write_40x_tcr, 1136 0x00000000); 1137 spr_register(env, SPR_40x_TSR, "TSR", 1138 SPR_NOACCESS, SPR_NOACCESS, 1139 &spr_read_generic, &spr_write_40x_tsr, 1140 0x00000000); 1141 } 1142 1143 /* SPR specific to PowerPC 405 implementation */ 1144 static void register_405_sprs(CPUPPCState *env) 1145 { 1146 /* MMU */ 1147 spr_register(env, SPR_40x_PID, "PID", 1148 SPR_NOACCESS, SPR_NOACCESS, 1149 &spr_read_generic, &spr_write_40x_pid, 1150 0x00000000); 1151 spr_register(env, SPR_4xx_CCR0, "CCR0", 1152 SPR_NOACCESS, SPR_NOACCESS, 1153 &spr_read_generic, &spr_write_generic, 1154 0x00700000); 1155 /* Debug interface */ 1156 spr_register(env, SPR_40x_DBCR0, "DBCR0", 1157 SPR_NOACCESS, SPR_NOACCESS, 1158 &spr_read_generic, &spr_write_40x_dbcr0, 1159 0x00000000); 1160 1161 spr_register(env, SPR_405_DBCR1, "DBCR1", 1162 SPR_NOACCESS, SPR_NOACCESS, 1163 &spr_read_generic, &spr_write_generic, 1164 0x00000000); 1165 1166 spr_register(env, SPR_40x_DBSR, "DBSR", 1167 SPR_NOACCESS, SPR_NOACCESS, 1168 &spr_read_generic, &spr_write_clear, 1169 /* Last reset was system reset */ 1170 0x00000300); 1171 1172 spr_register(env, SPR_40x_DAC1, "DAC1", 1173 SPR_NOACCESS, SPR_NOACCESS, 1174 &spr_read_generic, &spr_write_generic, 1175 0x00000000); 1176 spr_register(env, SPR_40x_DAC2, "DAC2", 1177 SPR_NOACCESS, SPR_NOACCESS, 1178 &spr_read_generic, &spr_write_generic, 1179 0x00000000); 1180 1181 spr_register(env, SPR_405_DVC1, "DVC1", 1182 SPR_NOACCESS, SPR_NOACCESS, 1183 &spr_read_generic, &spr_write_generic, 1184 0x00000000); 1185 1186 spr_register(env, SPR_405_DVC2, "DVC2", 1187 SPR_NOACCESS, SPR_NOACCESS, 1188 &spr_read_generic, &spr_write_generic, 1189 0x00000000); 1190 1191 spr_register(env, SPR_40x_IAC1, "IAC1", 1192 SPR_NOACCESS, SPR_NOACCESS, 1193 &spr_read_generic, &spr_write_generic, 1194 0x00000000); 1195 spr_register(env, SPR_40x_IAC2, "IAC2", 1196 SPR_NOACCESS, SPR_NOACCESS, 1197 &spr_read_generic, &spr_write_generic, 1198 0x00000000); 1199 1200 spr_register(env, SPR_405_IAC3, "IAC3", 1201 SPR_NOACCESS, SPR_NOACCESS, 1202 &spr_read_generic, &spr_write_generic, 1203 0x00000000); 1204 1205 spr_register(env, SPR_405_IAC4, "IAC4", 1206 SPR_NOACCESS, SPR_NOACCESS, 1207 &spr_read_generic, &spr_write_generic, 1208 0x00000000); 1209 /* Storage control */ 1210 spr_register(env, SPR_405_SLER, "SLER", 1211 SPR_NOACCESS, SPR_NOACCESS, 1212 &spr_read_generic, &spr_write_40x_sler, 1213 0x00000000); 1214 spr_register(env, SPR_40x_ZPR, "ZPR", 1215 SPR_NOACCESS, SPR_NOACCESS, 1216 &spr_read_generic, &spr_write_generic, 1217 0x00000000); 1218 1219 spr_register(env, SPR_405_SU0R, "SU0R", 1220 SPR_NOACCESS, SPR_NOACCESS, 1221 &spr_read_generic, &spr_write_generic, 1222 0x00000000); 1223 /* SPRG */ 1224 spr_register(env, SPR_USPRG0, "USPRG0", 1225 &spr_read_ureg, SPR_NOACCESS, 1226 &spr_read_ureg, SPR_NOACCESS, 1227 0x00000000); 1228 spr_register(env, SPR_SPRG4, "SPRG4", 1229 SPR_NOACCESS, SPR_NOACCESS, 1230 &spr_read_generic, &spr_write_generic, 1231 0x00000000); 1232 spr_register(env, SPR_SPRG5, "SPRG5", 1233 SPR_NOACCESS, SPR_NOACCESS, 1234 spr_read_generic, &spr_write_generic, 1235 0x00000000); 1236 spr_register(env, SPR_SPRG6, "SPRG6", 1237 SPR_NOACCESS, SPR_NOACCESS, 1238 spr_read_generic, &spr_write_generic, 1239 0x00000000); 1240 spr_register(env, SPR_SPRG7, "SPRG7", 1241 SPR_NOACCESS, SPR_NOACCESS, 1242 spr_read_generic, &spr_write_generic, 1243 0x00000000); 1244 1245 /* Bus access control */ 1246 /* not emulated, as QEMU never does speculative access */ 1247 spr_register(env, SPR_40x_SGR, "SGR", 1248 SPR_NOACCESS, SPR_NOACCESS, 1249 &spr_read_generic, &spr_write_generic, 1250 0xFFFFFFFF); 1251 /* not emulated, as QEMU do not emulate caches */ 1252 spr_register(env, SPR_40x_DCWR, "DCWR", 1253 SPR_NOACCESS, SPR_NOACCESS, 1254 &spr_read_generic, &spr_write_generic, 1255 0x00000000); 1256 } 1257 1258 1259 static void register_5xx_8xx_sprs(CPUPPCState *env) 1260 { 1261 /* Exception processing */ 1262 spr_register_kvm(env, SPR_DSISR, "DSISR", 1263 SPR_NOACCESS, SPR_NOACCESS, 1264 &spr_read_generic, &spr_write_generic, 1265 KVM_REG_PPC_DSISR, 0x00000000); 1266 spr_register_kvm(env, SPR_DAR, "DAR", 1267 SPR_NOACCESS, SPR_NOACCESS, 1268 &spr_read_generic, &spr_write_generic, 1269 KVM_REG_PPC_DAR, 0x00000000); 1270 /* Timer */ 1271 spr_register(env, SPR_DECR, "DECR", 1272 SPR_NOACCESS, SPR_NOACCESS, 1273 &spr_read_decr, &spr_write_decr, 1274 0x00000000); 1275 1276 spr_register(env, SPR_MPC_EIE, "EIE", 1277 SPR_NOACCESS, SPR_NOACCESS, 1278 &spr_read_generic, &spr_write_generic, 1279 0x00000000); 1280 1281 spr_register(env, SPR_MPC_EID, "EID", 1282 SPR_NOACCESS, SPR_NOACCESS, 1283 &spr_read_generic, &spr_write_generic, 1284 0x00000000); 1285 1286 spr_register(env, SPR_MPC_NRI, "NRI", 1287 SPR_NOACCESS, SPR_NOACCESS, 1288 &spr_read_generic, &spr_write_generic, 1289 0x00000000); 1290 1291 spr_register(env, SPR_MPC_CMPA, "CMPA", 1292 SPR_NOACCESS, SPR_NOACCESS, 1293 &spr_read_generic, &spr_write_generic, 1294 0x00000000); 1295 1296 spr_register(env, SPR_MPC_CMPB, "CMPB", 1297 SPR_NOACCESS, SPR_NOACCESS, 1298 &spr_read_generic, &spr_write_generic, 1299 0x00000000); 1300 1301 spr_register(env, SPR_MPC_CMPC, "CMPC", 1302 SPR_NOACCESS, SPR_NOACCESS, 1303 &spr_read_generic, &spr_write_generic, 1304 0x00000000); 1305 1306 spr_register(env, SPR_MPC_CMPD, "CMPD", 1307 SPR_NOACCESS, SPR_NOACCESS, 1308 &spr_read_generic, &spr_write_generic, 1309 0x00000000); 1310 1311 spr_register(env, SPR_MPC_ECR, "ECR", 1312 SPR_NOACCESS, SPR_NOACCESS, 1313 &spr_read_generic, &spr_write_generic, 1314 0x00000000); 1315 1316 spr_register(env, SPR_MPC_DER, "DER", 1317 SPR_NOACCESS, SPR_NOACCESS, 1318 &spr_read_generic, &spr_write_generic, 1319 0x00000000); 1320 1321 spr_register(env, SPR_MPC_COUNTA, "COUNTA", 1322 SPR_NOACCESS, SPR_NOACCESS, 1323 &spr_read_generic, &spr_write_generic, 1324 0x00000000); 1325 1326 spr_register(env, SPR_MPC_COUNTB, "COUNTB", 1327 SPR_NOACCESS, SPR_NOACCESS, 1328 &spr_read_generic, &spr_write_generic, 1329 0x00000000); 1330 1331 spr_register(env, SPR_MPC_CMPE, "CMPE", 1332 SPR_NOACCESS, SPR_NOACCESS, 1333 &spr_read_generic, &spr_write_generic, 1334 0x00000000); 1335 1336 spr_register(env, SPR_MPC_CMPF, "CMPF", 1337 SPR_NOACCESS, SPR_NOACCESS, 1338 &spr_read_generic, &spr_write_generic, 1339 0x00000000); 1340 1341 spr_register(env, SPR_MPC_CMPG, "CMPG", 1342 SPR_NOACCESS, SPR_NOACCESS, 1343 &spr_read_generic, &spr_write_generic, 1344 0x00000000); 1345 1346 spr_register(env, SPR_MPC_CMPH, "CMPH", 1347 SPR_NOACCESS, SPR_NOACCESS, 1348 &spr_read_generic, &spr_write_generic, 1349 0x00000000); 1350 1351 spr_register(env, SPR_MPC_LCTRL1, "LCTRL1", 1352 SPR_NOACCESS, SPR_NOACCESS, 1353 &spr_read_generic, &spr_write_generic, 1354 0x00000000); 1355 1356 spr_register(env, SPR_MPC_LCTRL2, "LCTRL2", 1357 SPR_NOACCESS, SPR_NOACCESS, 1358 &spr_read_generic, &spr_write_generic, 1359 0x00000000); 1360 1361 spr_register(env, SPR_MPC_BAR, "BAR", 1362 SPR_NOACCESS, SPR_NOACCESS, 1363 &spr_read_generic, &spr_write_generic, 1364 0x00000000); 1365 1366 spr_register(env, SPR_MPC_DPDR, "DPDR", 1367 SPR_NOACCESS, SPR_NOACCESS, 1368 &spr_read_generic, &spr_write_generic, 1369 0x00000000); 1370 1371 spr_register(env, SPR_MPC_IMMR, "IMMR", 1372 SPR_NOACCESS, SPR_NOACCESS, 1373 &spr_read_generic, &spr_write_generic, 1374 0x00000000); 1375 } 1376 1377 static void register_5xx_sprs(CPUPPCState *env) 1378 { 1379 spr_register(env, SPR_RCPU_MI_GRA, "MI_GRA", 1380 SPR_NOACCESS, SPR_NOACCESS, 1381 &spr_read_generic, &spr_write_generic, 1382 0x00000000); 1383 1384 spr_register(env, SPR_RCPU_L2U_GRA, "L2U_GRA", 1385 SPR_NOACCESS, SPR_NOACCESS, 1386 &spr_read_generic, &spr_write_generic, 1387 0x00000000); 1388 1389 spr_register(env, SPR_RPCU_BBCMCR, "L2U_BBCMCR", 1390 SPR_NOACCESS, SPR_NOACCESS, 1391 &spr_read_generic, &spr_write_generic, 1392 0x00000000); 1393 1394 spr_register(env, SPR_RCPU_L2U_MCR, "L2U_MCR", 1395 SPR_NOACCESS, SPR_NOACCESS, 1396 &spr_read_generic, &spr_write_generic, 1397 0x00000000); 1398 1399 spr_register(env, SPR_RCPU_MI_RBA0, "MI_RBA0", 1400 SPR_NOACCESS, SPR_NOACCESS, 1401 &spr_read_generic, &spr_write_generic, 1402 0x00000000); 1403 1404 spr_register(env, SPR_RCPU_MI_RBA1, "MI_RBA1", 1405 SPR_NOACCESS, SPR_NOACCESS, 1406 &spr_read_generic, &spr_write_generic, 1407 0x00000000); 1408 1409 spr_register(env, SPR_RCPU_MI_RBA2, "MI_RBA2", 1410 SPR_NOACCESS, SPR_NOACCESS, 1411 &spr_read_generic, &spr_write_generic, 1412 0x00000000); 1413 1414 spr_register(env, SPR_RCPU_MI_RBA3, "MI_RBA3", 1415 SPR_NOACCESS, SPR_NOACCESS, 1416 &spr_read_generic, &spr_write_generic, 1417 0x00000000); 1418 1419 spr_register(env, SPR_RCPU_L2U_RBA0, "L2U_RBA0", 1420 SPR_NOACCESS, SPR_NOACCESS, 1421 &spr_read_generic, &spr_write_generic, 1422 0x00000000); 1423 1424 spr_register(env, SPR_RCPU_L2U_RBA1, "L2U_RBA1", 1425 SPR_NOACCESS, SPR_NOACCESS, 1426 &spr_read_generic, &spr_write_generic, 1427 0x00000000); 1428 1429 spr_register(env, SPR_RCPU_L2U_RBA2, "L2U_RBA2", 1430 SPR_NOACCESS, SPR_NOACCESS, 1431 &spr_read_generic, &spr_write_generic, 1432 0x00000000); 1433 1434 spr_register(env, SPR_RCPU_L2U_RBA3, "L2U_RBA3", 1435 SPR_NOACCESS, SPR_NOACCESS, 1436 &spr_read_generic, &spr_write_generic, 1437 0x00000000); 1438 1439 spr_register(env, SPR_RCPU_MI_RA0, "MI_RA0", 1440 SPR_NOACCESS, SPR_NOACCESS, 1441 &spr_read_generic, &spr_write_generic, 1442 0x00000000); 1443 1444 spr_register(env, SPR_RCPU_MI_RA1, "MI_RA1", 1445 SPR_NOACCESS, SPR_NOACCESS, 1446 &spr_read_generic, &spr_write_generic, 1447 0x00000000); 1448 1449 spr_register(env, SPR_RCPU_MI_RA2, "MI_RA2", 1450 SPR_NOACCESS, SPR_NOACCESS, 1451 &spr_read_generic, &spr_write_generic, 1452 0x00000000); 1453 1454 spr_register(env, SPR_RCPU_MI_RA3, "MI_RA3", 1455 SPR_NOACCESS, SPR_NOACCESS, 1456 &spr_read_generic, &spr_write_generic, 1457 0x00000000); 1458 1459 spr_register(env, SPR_RCPU_L2U_RA0, "L2U_RA0", 1460 SPR_NOACCESS, SPR_NOACCESS, 1461 &spr_read_generic, &spr_write_generic, 1462 0x00000000); 1463 1464 spr_register(env, SPR_RCPU_L2U_RA1, "L2U_RA1", 1465 SPR_NOACCESS, SPR_NOACCESS, 1466 &spr_read_generic, &spr_write_generic, 1467 0x00000000); 1468 1469 spr_register(env, SPR_RCPU_L2U_RA2, "L2U_RA2", 1470 SPR_NOACCESS, SPR_NOACCESS, 1471 &spr_read_generic, &spr_write_generic, 1472 0x00000000); 1473 1474 spr_register(env, SPR_RCPU_L2U_RA3, "L2U_RA3", 1475 SPR_NOACCESS, SPR_NOACCESS, 1476 &spr_read_generic, &spr_write_generic, 1477 0x00000000); 1478 1479 spr_register(env, SPR_RCPU_FPECR, "FPECR", 1480 SPR_NOACCESS, SPR_NOACCESS, 1481 &spr_read_generic, &spr_write_generic, 1482 0x00000000); 1483 } 1484 1485 static void register_8xx_sprs(CPUPPCState *env) 1486 { 1487 1488 spr_register(env, SPR_MPC_IC_CST, "IC_CST", 1489 SPR_NOACCESS, SPR_NOACCESS, 1490 &spr_read_generic, &spr_write_generic, 1491 0x00000000); 1492 1493 spr_register(env, SPR_MPC_IC_ADR, "IC_ADR", 1494 SPR_NOACCESS, SPR_NOACCESS, 1495 &spr_read_generic, &spr_write_generic, 1496 0x00000000); 1497 1498 spr_register(env, SPR_MPC_IC_DAT, "IC_DAT", 1499 SPR_NOACCESS, SPR_NOACCESS, 1500 &spr_read_generic, &spr_write_generic, 1501 0x00000000); 1502 1503 spr_register(env, SPR_MPC_DC_CST, "DC_CST", 1504 SPR_NOACCESS, SPR_NOACCESS, 1505 &spr_read_generic, &spr_write_generic, 1506 0x00000000); 1507 1508 spr_register(env, SPR_MPC_DC_ADR, "DC_ADR", 1509 SPR_NOACCESS, SPR_NOACCESS, 1510 &spr_read_generic, &spr_write_generic, 1511 0x00000000); 1512 1513 spr_register(env, SPR_MPC_DC_DAT, "DC_DAT", 1514 SPR_NOACCESS, SPR_NOACCESS, 1515 &spr_read_generic, &spr_write_generic, 1516 0x00000000); 1517 1518 spr_register(env, SPR_MPC_MI_CTR, "MI_CTR", 1519 SPR_NOACCESS, SPR_NOACCESS, 1520 &spr_read_generic, &spr_write_generic, 1521 0x00000000); 1522 1523 spr_register(env, SPR_MPC_MI_AP, "MI_AP", 1524 SPR_NOACCESS, SPR_NOACCESS, 1525 &spr_read_generic, &spr_write_generic, 1526 0x00000000); 1527 1528 spr_register(env, SPR_MPC_MI_EPN, "MI_EPN", 1529 SPR_NOACCESS, SPR_NOACCESS, 1530 &spr_read_generic, &spr_write_generic, 1531 0x00000000); 1532 1533 spr_register(env, SPR_MPC_MI_TWC, "MI_TWC", 1534 SPR_NOACCESS, SPR_NOACCESS, 1535 &spr_read_generic, &spr_write_generic, 1536 0x00000000); 1537 1538 spr_register(env, SPR_MPC_MI_RPN, "MI_RPN", 1539 SPR_NOACCESS, SPR_NOACCESS, 1540 &spr_read_generic, &spr_write_generic, 1541 0x00000000); 1542 1543 spr_register(env, SPR_MPC_MI_DBCAM, "MI_DBCAM", 1544 SPR_NOACCESS, SPR_NOACCESS, 1545 &spr_read_generic, &spr_write_generic, 1546 0x00000000); 1547 1548 spr_register(env, SPR_MPC_MI_DBRAM0, "MI_DBRAM0", 1549 SPR_NOACCESS, SPR_NOACCESS, 1550 &spr_read_generic, &spr_write_generic, 1551 0x00000000); 1552 1553 spr_register(env, SPR_MPC_MI_DBRAM1, "MI_DBRAM1", 1554 SPR_NOACCESS, SPR_NOACCESS, 1555 &spr_read_generic, &spr_write_generic, 1556 0x00000000); 1557 1558 spr_register(env, SPR_MPC_MD_CTR, "MD_CTR", 1559 SPR_NOACCESS, SPR_NOACCESS, 1560 &spr_read_generic, &spr_write_generic, 1561 0x00000000); 1562 1563 spr_register(env, SPR_MPC_MD_CASID, "MD_CASID", 1564 SPR_NOACCESS, SPR_NOACCESS, 1565 &spr_read_generic, &spr_write_generic, 1566 0x00000000); 1567 1568 spr_register(env, SPR_MPC_MD_AP, "MD_AP", 1569 SPR_NOACCESS, SPR_NOACCESS, 1570 &spr_read_generic, &spr_write_generic, 1571 0x00000000); 1572 1573 spr_register(env, SPR_MPC_MD_EPN, "MD_EPN", 1574 SPR_NOACCESS, SPR_NOACCESS, 1575 &spr_read_generic, &spr_write_generic, 1576 0x00000000); 1577 1578 spr_register(env, SPR_MPC_MD_TWB, "MD_TWB", 1579 SPR_NOACCESS, SPR_NOACCESS, 1580 &spr_read_generic, &spr_write_generic, 1581 0x00000000); 1582 1583 spr_register(env, SPR_MPC_MD_TWC, "MD_TWC", 1584 SPR_NOACCESS, SPR_NOACCESS, 1585 &spr_read_generic, &spr_write_generic, 1586 0x00000000); 1587 1588 spr_register(env, SPR_MPC_MD_RPN, "MD_RPN", 1589 SPR_NOACCESS, SPR_NOACCESS, 1590 &spr_read_generic, &spr_write_generic, 1591 0x00000000); 1592 1593 spr_register(env, SPR_MPC_MD_TW, "MD_TW", 1594 SPR_NOACCESS, SPR_NOACCESS, 1595 &spr_read_generic, &spr_write_generic, 1596 0x00000000); 1597 1598 spr_register(env, SPR_MPC_MD_DBCAM, "MD_DBCAM", 1599 SPR_NOACCESS, SPR_NOACCESS, 1600 &spr_read_generic, &spr_write_generic, 1601 0x00000000); 1602 1603 spr_register(env, SPR_MPC_MD_DBRAM0, "MD_DBRAM0", 1604 SPR_NOACCESS, SPR_NOACCESS, 1605 &spr_read_generic, &spr_write_generic, 1606 0x00000000); 1607 1608 spr_register(env, SPR_MPC_MD_DBRAM1, "MD_DBRAM1", 1609 SPR_NOACCESS, SPR_NOACCESS, 1610 &spr_read_generic, &spr_write_generic, 1611 0x00000000); 1612 } 1613 1614 /* 1615 * AMR => SPR 29 (Power 2.04) 1616 * CTRL => SPR 136 (Power 2.04) 1617 * CTRL => SPR 152 (Power 2.04) 1618 * SCOMC => SPR 276 (64 bits ?) 1619 * SCOMD => SPR 277 (64 bits ?) 1620 * TBU40 => SPR 286 (Power 2.04 hypv) 1621 * HSPRG0 => SPR 304 (Power 2.04 hypv) 1622 * HSPRG1 => SPR 305 (Power 2.04 hypv) 1623 * HDSISR => SPR 306 (Power 2.04 hypv) 1624 * HDAR => SPR 307 (Power 2.04 hypv) 1625 * PURR => SPR 309 (Power 2.04 hypv) 1626 * HDEC => SPR 310 (Power 2.04 hypv) 1627 * HIOR => SPR 311 (hypv) 1628 * RMOR => SPR 312 (970) 1629 * HRMOR => SPR 313 (Power 2.04 hypv) 1630 * HSRR0 => SPR 314 (Power 2.04 hypv) 1631 * HSRR1 => SPR 315 (Power 2.04 hypv) 1632 * LPIDR => SPR 317 (970) 1633 * HEIR => SPR 339 (Power 2.05 hypv) (64-bit reg from 3.1) 1634 * EPR => SPR 702 (Power 2.04 emb) 1635 * perf => 768-783 (Power 2.04) 1636 * perf => 784-799 (Power 2.04) 1637 * PPR => SPR 896 (Power 2.04) 1638 * DABRX => 1015 (Power 2.04 hypv) 1639 * FPECR => SPR 1022 (?) 1640 * ... and more (thermal management, performance counters, ...) 1641 */ 1642 1643 /*****************************************************************************/ 1644 /* Exception vectors models */ 1645 static void init_excp_4xx_softmmu(CPUPPCState *env) 1646 { 1647 #if !defined(CONFIG_USER_ONLY) 1648 env->excp_vectors[POWERPC_EXCP_CRITICAL] = 0x00000100; 1649 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1650 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1651 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1652 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1653 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1654 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1655 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1656 env->excp_vectors[POWERPC_EXCP_PIT] = 0x00001000; 1657 env->excp_vectors[POWERPC_EXCP_FIT] = 0x00001010; 1658 env->excp_vectors[POWERPC_EXCP_WDT] = 0x00001020; 1659 env->excp_vectors[POWERPC_EXCP_DTLB] = 0x00001100; 1660 env->excp_vectors[POWERPC_EXCP_ITLB] = 0x00001200; 1661 env->excp_vectors[POWERPC_EXCP_DEBUG] = 0x00002000; 1662 env->ivor_mask = 0x0000FFF0UL; 1663 env->ivpr_mask = 0xFFFF0000UL; 1664 /* Hardware reset vector */ 1665 env->hreset_vector = 0xFFFFFFFCUL; 1666 #endif 1667 } 1668 1669 static void init_excp_MPC5xx(CPUPPCState *env) 1670 { 1671 #if !defined(CONFIG_USER_ONLY) 1672 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1673 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1674 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1675 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1676 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1677 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1678 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1679 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1680 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1681 env->excp_vectors[POWERPC_EXCP_FPA] = 0x00000E00; 1682 env->excp_vectors[POWERPC_EXCP_EMUL] = 0x00001000; 1683 env->excp_vectors[POWERPC_EXCP_DABR] = 0x00001C00; 1684 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001C00; 1685 env->excp_vectors[POWERPC_EXCP_MEXTBR] = 0x00001E00; 1686 env->excp_vectors[POWERPC_EXCP_NMEXTBR] = 0x00001F00; 1687 env->ivor_mask = 0x0000FFF0UL; 1688 env->ivpr_mask = 0xFFFF0000UL; 1689 /* Hardware reset vector */ 1690 env->hreset_vector = 0x00000100UL; 1691 #endif 1692 } 1693 1694 static void init_excp_MPC8xx(CPUPPCState *env) 1695 { 1696 #if !defined(CONFIG_USER_ONLY) 1697 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1698 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1699 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1700 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1701 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1702 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1703 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1704 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1705 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1706 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1707 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1708 env->excp_vectors[POWERPC_EXCP_FPA] = 0x00000E00; 1709 env->excp_vectors[POWERPC_EXCP_EMUL] = 0x00001000; 1710 env->excp_vectors[POWERPC_EXCP_ITLB] = 0x00001100; 1711 env->excp_vectors[POWERPC_EXCP_DTLB] = 0x00001200; 1712 env->excp_vectors[POWERPC_EXCP_ITLBE] = 0x00001300; 1713 env->excp_vectors[POWERPC_EXCP_DTLBE] = 0x00001400; 1714 env->excp_vectors[POWERPC_EXCP_DABR] = 0x00001C00; 1715 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001C00; 1716 env->excp_vectors[POWERPC_EXCP_MEXTBR] = 0x00001E00; 1717 env->excp_vectors[POWERPC_EXCP_NMEXTBR] = 0x00001F00; 1718 env->ivor_mask = 0x0000FFF0UL; 1719 env->ivpr_mask = 0xFFFF0000UL; 1720 /* Hardware reset vector */ 1721 env->hreset_vector = 0x00000100UL; 1722 #endif 1723 } 1724 1725 static void init_excp_G2(CPUPPCState *env) 1726 { 1727 #if !defined(CONFIG_USER_ONLY) 1728 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1729 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1730 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1731 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1732 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1733 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1734 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1735 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1736 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1737 env->excp_vectors[POWERPC_EXCP_CRITICAL] = 0x00000A00; 1738 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1739 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1740 env->excp_vectors[POWERPC_EXCP_IFTLB] = 0x00001000; 1741 env->excp_vectors[POWERPC_EXCP_DLTLB] = 0x00001100; 1742 env->excp_vectors[POWERPC_EXCP_DSTLB] = 0x00001200; 1743 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; 1744 env->excp_vectors[POWERPC_EXCP_SMI] = 0x00001400; 1745 /* Hardware reset vector */ 1746 env->hreset_vector = 0x00000100UL; 1747 #endif 1748 } 1749 1750 static void init_excp_e200(CPUPPCState *env, target_ulong ivpr_mask) 1751 { 1752 #if !defined(CONFIG_USER_ONLY) 1753 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000FFC; 1754 env->excp_vectors[POWERPC_EXCP_CRITICAL] = 0x00000000; 1755 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000000; 1756 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000000; 1757 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000000; 1758 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000000; 1759 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000000; 1760 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000000; 1761 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000000; 1762 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000000; 1763 env->excp_vectors[POWERPC_EXCP_APU] = 0x00000000; 1764 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000000; 1765 env->excp_vectors[POWERPC_EXCP_FIT] = 0x00000000; 1766 env->excp_vectors[POWERPC_EXCP_WDT] = 0x00000000; 1767 env->excp_vectors[POWERPC_EXCP_DTLB] = 0x00000000; 1768 env->excp_vectors[POWERPC_EXCP_ITLB] = 0x00000000; 1769 env->excp_vectors[POWERPC_EXCP_DEBUG] = 0x00000000; 1770 /* 1771 * These two are the same IVOR as POWERPC_EXCP_VPU and 1772 * POWERPC_EXCP_VPUA. We deal with that when dispatching at 1773 * powerpc_excp(). 1774 */ 1775 env->excp_vectors[POWERPC_EXCP_SPEU] = 0x00000000; 1776 env->excp_vectors[POWERPC_EXCP_EFPDI] = 0x00000000; 1777 1778 env->excp_vectors[POWERPC_EXCP_EFPRI] = 0x00000000; 1779 env->ivor_mask = 0x0000FFF7UL; 1780 env->ivpr_mask = ivpr_mask; 1781 /* Hardware reset vector */ 1782 env->hreset_vector = 0xFFFFFFFCUL; 1783 #endif 1784 } 1785 1786 static void init_excp_BookE(CPUPPCState *env) 1787 { 1788 #if !defined(CONFIG_USER_ONLY) 1789 env->excp_vectors[POWERPC_EXCP_CRITICAL] = 0x00000000; 1790 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000000; 1791 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000000; 1792 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000000; 1793 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000000; 1794 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000000; 1795 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000000; 1796 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000000; 1797 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000000; 1798 env->excp_vectors[POWERPC_EXCP_APU] = 0x00000000; 1799 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000000; 1800 env->excp_vectors[POWERPC_EXCP_FIT] = 0x00000000; 1801 env->excp_vectors[POWERPC_EXCP_WDT] = 0x00000000; 1802 env->excp_vectors[POWERPC_EXCP_DTLB] = 0x00000000; 1803 env->excp_vectors[POWERPC_EXCP_ITLB] = 0x00000000; 1804 env->excp_vectors[POWERPC_EXCP_DEBUG] = 0x00000000; 1805 env->ivor_mask = 0x0000FFF0UL; 1806 env->ivpr_mask = 0xFFFF0000UL; 1807 /* Hardware reset vector */ 1808 env->hreset_vector = 0xFFFFFFFCUL; 1809 #endif 1810 } 1811 1812 static void init_excp_603(CPUPPCState *env) 1813 { 1814 #if !defined(CONFIG_USER_ONLY) 1815 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1816 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1817 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1818 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1819 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1820 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1821 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1822 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1823 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1824 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1825 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1826 env->excp_vectors[POWERPC_EXCP_IFTLB] = 0x00001000; 1827 env->excp_vectors[POWERPC_EXCP_DLTLB] = 0x00001100; 1828 env->excp_vectors[POWERPC_EXCP_DSTLB] = 0x00001200; 1829 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; 1830 env->excp_vectors[POWERPC_EXCP_SMI] = 0x00001400; 1831 /* Hardware reset vector */ 1832 env->hreset_vector = 0x00000100UL; 1833 #endif 1834 } 1835 1836 static void init_excp_604(CPUPPCState *env) 1837 { 1838 #if !defined(CONFIG_USER_ONLY) 1839 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1840 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1841 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1842 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1843 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1844 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1845 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1846 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1847 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1848 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1849 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1850 env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00; 1851 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; 1852 env->excp_vectors[POWERPC_EXCP_SMI] = 0x00001400; 1853 /* Hardware reset vector */ 1854 env->hreset_vector = 0x00000100UL; 1855 #endif 1856 } 1857 1858 static void init_excp_7x0(CPUPPCState *env) 1859 { 1860 #if !defined(CONFIG_USER_ONLY) 1861 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1862 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1863 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1864 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1865 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1866 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1867 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1868 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1869 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1870 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1871 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1872 env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00; 1873 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; 1874 env->excp_vectors[POWERPC_EXCP_SMI] = 0x00001400; 1875 env->excp_vectors[POWERPC_EXCP_THERM] = 0x00001700; 1876 /* Hardware reset vector */ 1877 env->hreset_vector = 0x00000100UL; 1878 #endif 1879 } 1880 1881 static void init_excp_750cl(CPUPPCState *env) 1882 { 1883 #if !defined(CONFIG_USER_ONLY) 1884 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1885 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1886 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1887 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1888 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1889 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1890 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1891 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1892 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1893 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1894 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1895 env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00; 1896 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; 1897 env->excp_vectors[POWERPC_EXCP_SMI] = 0x00001400; 1898 /* Hardware reset vector */ 1899 env->hreset_vector = 0x00000100UL; 1900 #endif 1901 } 1902 1903 static void init_excp_750cx(CPUPPCState *env) 1904 { 1905 #if !defined(CONFIG_USER_ONLY) 1906 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1907 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1908 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1909 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1910 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1911 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1912 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1913 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1914 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1915 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1916 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1917 env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00; 1918 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; 1919 env->excp_vectors[POWERPC_EXCP_THERM] = 0x00001700; 1920 /* Hardware reset vector */ 1921 env->hreset_vector = 0x00000100UL; 1922 #endif 1923 } 1924 1925 /* XXX: Check if this is correct */ 1926 static void init_excp_7x5(CPUPPCState *env) 1927 { 1928 #if !defined(CONFIG_USER_ONLY) 1929 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1930 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1931 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1932 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1933 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1934 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1935 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1936 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1937 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1938 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1939 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1940 env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00; 1941 env->excp_vectors[POWERPC_EXCP_IFTLB] = 0x00001000; 1942 env->excp_vectors[POWERPC_EXCP_DLTLB] = 0x00001100; 1943 env->excp_vectors[POWERPC_EXCP_DSTLB] = 0x00001200; 1944 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; 1945 env->excp_vectors[POWERPC_EXCP_SMI] = 0x00001400; 1946 env->excp_vectors[POWERPC_EXCP_THERM] = 0x00001700; 1947 /* Hardware reset vector */ 1948 env->hreset_vector = 0x00000100UL; 1949 #endif 1950 } 1951 1952 static void init_excp_7400(CPUPPCState *env) 1953 { 1954 #if !defined(CONFIG_USER_ONLY) 1955 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1956 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1957 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1958 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1959 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1960 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1961 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1962 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1963 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1964 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1965 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1966 env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00; 1967 env->excp_vectors[POWERPC_EXCP_VPU] = 0x00000F20; 1968 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; 1969 env->excp_vectors[POWERPC_EXCP_SMI] = 0x00001400; 1970 env->excp_vectors[POWERPC_EXCP_VPUA] = 0x00001600; 1971 env->excp_vectors[POWERPC_EXCP_THERM] = 0x00001700; 1972 /* Hardware reset vector */ 1973 env->hreset_vector = 0x00000100UL; 1974 #endif 1975 } 1976 1977 static void init_excp_7450(CPUPPCState *env) 1978 { 1979 #if !defined(CONFIG_USER_ONLY) 1980 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1981 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1982 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1983 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1984 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1985 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1986 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1987 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1988 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1989 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1990 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1991 env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00; 1992 env->excp_vectors[POWERPC_EXCP_VPU] = 0x00000F20; 1993 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; 1994 env->excp_vectors[POWERPC_EXCP_SMI] = 0x00001400; 1995 env->excp_vectors[POWERPC_EXCP_VPUA] = 0x00001600; 1996 /* Hardware reset vector */ 1997 env->hreset_vector = 0x00000100UL; 1998 #endif 1999 } 2000 2001 #if defined(TARGET_PPC64) 2002 static void init_excp_970(CPUPPCState *env) 2003 { 2004 #if !defined(CONFIG_USER_ONLY) 2005 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 2006 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 2007 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 2008 env->excp_vectors[POWERPC_EXCP_DSEG] = 0x00000380; 2009 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 2010 env->excp_vectors[POWERPC_EXCP_ISEG] = 0x00000480; 2011 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 2012 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 2013 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 2014 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 2015 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 2016 env->excp_vectors[POWERPC_EXCP_HDECR] = 0x00000980; 2017 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 2018 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 2019 env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00; 2020 env->excp_vectors[POWERPC_EXCP_VPU] = 0x00000F20; 2021 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; 2022 env->excp_vectors[POWERPC_EXCP_MAINT] = 0x00001600; 2023 env->excp_vectors[POWERPC_EXCP_VPUA] = 0x00001700; 2024 env->excp_vectors[POWERPC_EXCP_THERM] = 0x00001800; 2025 /* Hardware reset vector */ 2026 env->hreset_vector = 0x0000000000000100ULL; 2027 #endif 2028 } 2029 2030 static void init_excp_POWER7(CPUPPCState *env) 2031 { 2032 #if !defined(CONFIG_USER_ONLY) 2033 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 2034 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 2035 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 2036 env->excp_vectors[POWERPC_EXCP_DSEG] = 0x00000380; 2037 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 2038 env->excp_vectors[POWERPC_EXCP_ISEG] = 0x00000480; 2039 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 2040 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 2041 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 2042 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 2043 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 2044 env->excp_vectors[POWERPC_EXCP_HDECR] = 0x00000980; 2045 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 2046 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 2047 env->excp_vectors[POWERPC_EXCP_HDSI] = 0x00000E00; 2048 env->excp_vectors[POWERPC_EXCP_HISI] = 0x00000E20; 2049 env->excp_vectors[POWERPC_EXCP_HV_EMU] = 0x00000E40; 2050 env->excp_vectors[POWERPC_EXCP_HV_MAINT] = 0x00000E60; 2051 env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00; 2052 env->excp_vectors[POWERPC_EXCP_VPU] = 0x00000F20; 2053 env->excp_vectors[POWERPC_EXCP_VSXU] = 0x00000F40; 2054 /* Hardware reset vector */ 2055 env->hreset_vector = 0x0000000000000100ULL; 2056 #endif 2057 } 2058 2059 static void init_excp_POWER8(CPUPPCState *env) 2060 { 2061 init_excp_POWER7(env); 2062 2063 #if !defined(CONFIG_USER_ONLY) 2064 env->excp_vectors[POWERPC_EXCP_SDOOR] = 0x00000A00; 2065 env->excp_vectors[POWERPC_EXCP_FU] = 0x00000F60; 2066 env->excp_vectors[POWERPC_EXCP_HV_FU] = 0x00000F80; 2067 env->excp_vectors[POWERPC_EXCP_SDOOR_HV] = 0x00000E80; 2068 2069 /* Userland exceptions without vector value in PowerISA v3.1 */ 2070 env->excp_vectors[POWERPC_EXCP_PERFM_EBB] = 0x0; 2071 env->excp_vectors[POWERPC_EXCP_EXTERNAL_EBB] = 0x0; 2072 #endif 2073 } 2074 2075 static void init_excp_POWER9(CPUPPCState *env) 2076 { 2077 init_excp_POWER8(env); 2078 2079 #if !defined(CONFIG_USER_ONLY) 2080 env->excp_vectors[POWERPC_EXCP_HVIRT] = 0x00000EA0; 2081 env->excp_vectors[POWERPC_EXCP_SYSCALL_VECTORED] = 0x00017000; 2082 #endif 2083 } 2084 2085 static void init_excp_POWER10(CPUPPCState *env) 2086 { 2087 init_excp_POWER9(env); 2088 } 2089 2090 #endif 2091 2092 static int check_pow_hid0(CPUPPCState *env) 2093 { 2094 if (env->spr[SPR_HID0] & 0x00E00000) { 2095 return 1; 2096 } 2097 2098 return 0; 2099 } 2100 2101 static int check_pow_hid0_74xx(CPUPPCState *env) 2102 { 2103 if (env->spr[SPR_HID0] & 0x00600000) { 2104 return 1; 2105 } 2106 2107 return 0; 2108 } 2109 2110 static void init_proc_405(CPUPPCState *env) 2111 { 2112 register_40x_sprs(env); 2113 register_405_sprs(env); 2114 register_usprgh_sprs(env); 2115 2116 /* Memory management */ 2117 #if !defined(CONFIG_USER_ONLY) 2118 env->nb_tlb = 64; 2119 env->nb_ways = 1; 2120 env->id_tlbs = 0; 2121 env->tlb_type = TLB_EMB; 2122 #endif 2123 init_excp_4xx_softmmu(env); 2124 env->dcache_line_size = 32; 2125 env->icache_line_size = 32; 2126 /* Allocate hardware IRQ controller */ 2127 ppc40x_irq_init(env_archcpu(env)); 2128 2129 SET_FIT_PERIOD(8, 12, 16, 20); 2130 SET_WDT_PERIOD(16, 20, 24, 28); 2131 } 2132 2133 POWERPC_FAMILY(405)(ObjectClass *oc, void *data) 2134 { 2135 DeviceClass *dc = DEVICE_CLASS(oc); 2136 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2137 2138 dc->desc = "PowerPC 405"; 2139 pcc->init_proc = init_proc_405; 2140 pcc->check_pow = check_pow_nocheck; 2141 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 2142 PPC_DCR | PPC_WRTEE | 2143 PPC_CACHE | PPC_CACHE_ICBI | PPC_40x_ICBT | 2144 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 2145 PPC_MEM_SYNC | PPC_MEM_EIEIO | 2146 PPC_40x_TLB | PPC_MEM_TLBIA | PPC_MEM_TLBSYNC | 2147 PPC_4xx_COMMON | PPC_405_MAC | PPC_40x_EXCP; 2148 pcc->msr_mask = (1ull << MSR_WE) | 2149 (1ull << MSR_CE) | 2150 (1ull << MSR_EE) | 2151 (1ull << MSR_PR) | 2152 (1ull << MSR_FP) | 2153 (1ull << MSR_ME) | 2154 (1ull << MSR_DWE) | 2155 (1ull << MSR_DE) | 2156 (1ull << MSR_IR) | 2157 (1ull << MSR_DR); 2158 pcc->mmu_model = POWERPC_MMU_SOFT_4xx; 2159 pcc->excp_model = POWERPC_EXCP_40x; 2160 pcc->bus_model = PPC_FLAGS_INPUT_405; 2161 pcc->bfd_mach = bfd_mach_ppc_403; 2162 pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DWE | 2163 POWERPC_FLAG_DE | POWERPC_FLAG_BUS_CLK; 2164 } 2165 2166 static void init_proc_440EP(CPUPPCState *env) 2167 { 2168 register_BookE_sprs(env, 0x000000000000FFFFULL); 2169 register_440_sprs(env); 2170 register_usprgh_sprs(env); 2171 2172 spr_register(env, SPR_BOOKE_MCSR, "MCSR", 2173 SPR_NOACCESS, SPR_NOACCESS, 2174 &spr_read_generic, &spr_write_generic, 2175 0x00000000); 2176 spr_register(env, SPR_BOOKE_MCSRR0, "MCSRR0", 2177 SPR_NOACCESS, SPR_NOACCESS, 2178 &spr_read_generic, &spr_write_generic, 2179 0x00000000); 2180 spr_register(env, SPR_BOOKE_MCSRR1, "MCSRR1", 2181 SPR_NOACCESS, SPR_NOACCESS, 2182 &spr_read_generic, &spr_write_generic, 2183 0x00000000); 2184 2185 spr_register(env, SPR_440_CCR1, "CCR1", 2186 SPR_NOACCESS, SPR_NOACCESS, 2187 &spr_read_generic, &spr_write_generic, 2188 0x00000000); 2189 /* Memory management */ 2190 #if !defined(CONFIG_USER_ONLY) 2191 env->nb_tlb = 64; 2192 env->nb_ways = 1; 2193 env->id_tlbs = 0; 2194 env->tlb_type = TLB_EMB; 2195 #endif 2196 init_excp_BookE(env); 2197 env->dcache_line_size = 32; 2198 env->icache_line_size = 32; 2199 ppc40x_irq_init(env_archcpu(env)); 2200 2201 SET_FIT_PERIOD(12, 16, 20, 24); 2202 SET_WDT_PERIOD(20, 24, 28, 32); 2203 } 2204 2205 POWERPC_FAMILY(440EP)(ObjectClass *oc, void *data) 2206 { 2207 DeviceClass *dc = DEVICE_CLASS(oc); 2208 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2209 2210 dc->desc = "PowerPC 440 EP"; 2211 pcc->init_proc = init_proc_440EP; 2212 pcc->check_pow = check_pow_nocheck; 2213 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | 2214 PPC_FLOAT | PPC_FLOAT_FRES | PPC_FLOAT_FSEL | 2215 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 2216 PPC_FLOAT_STFIWX | 2217 PPC_DCR | PPC_WRTEE | PPC_RFMCI | 2218 PPC_CACHE | PPC_CACHE_ICBI | 2219 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 2220 PPC_MEM_TLBSYNC | PPC_MFTB | 2221 PPC_BOOKE | PPC_4xx_COMMON | PPC_405_MAC | 2222 PPC_440_SPEC; 2223 pcc->msr_mask = (1ull << MSR_POW) | 2224 (1ull << MSR_CE) | 2225 (1ull << MSR_EE) | 2226 (1ull << MSR_PR) | 2227 (1ull << MSR_FP) | 2228 (1ull << MSR_ME) | 2229 (1ull << MSR_FE0) | 2230 (1ull << MSR_DWE) | 2231 (1ull << MSR_DE) | 2232 (1ull << MSR_FE1) | 2233 (1ull << MSR_IR) | 2234 (1ull << MSR_DR); 2235 pcc->mmu_model = POWERPC_MMU_BOOKE; 2236 pcc->excp_model = POWERPC_EXCP_BOOKE; 2237 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 2238 pcc->bfd_mach = bfd_mach_ppc_403; 2239 pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DWE | 2240 POWERPC_FLAG_DE | POWERPC_FLAG_BUS_CLK; 2241 } 2242 2243 POWERPC_FAMILY(460EX)(ObjectClass *oc, void *data) 2244 { 2245 DeviceClass *dc = DEVICE_CLASS(oc); 2246 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2247 2248 dc->desc = "PowerPC 460 EX"; 2249 pcc->init_proc = init_proc_440EP; 2250 pcc->check_pow = check_pow_nocheck; 2251 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | 2252 PPC_FLOAT | PPC_FLOAT_FRES | PPC_FLOAT_FSEL | 2253 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 2254 PPC_FLOAT_STFIWX | 2255 PPC_DCR | PPC_DCRX | PPC_WRTEE | PPC_RFMCI | 2256 PPC_CACHE | PPC_CACHE_ICBI | 2257 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 2258 PPC_MEM_TLBSYNC | PPC_MFTB | 2259 PPC_BOOKE | PPC_4xx_COMMON | PPC_405_MAC | 2260 PPC_440_SPEC; 2261 pcc->msr_mask = (1ull << MSR_POW) | 2262 (1ull << MSR_CE) | 2263 (1ull << MSR_EE) | 2264 (1ull << MSR_PR) | 2265 (1ull << MSR_FP) | 2266 (1ull << MSR_ME) | 2267 (1ull << MSR_FE0) | 2268 (1ull << MSR_DWE) | 2269 (1ull << MSR_DE) | 2270 (1ull << MSR_FE1) | 2271 (1ull << MSR_IR) | 2272 (1ull << MSR_DR); 2273 pcc->mmu_model = POWERPC_MMU_BOOKE; 2274 pcc->excp_model = POWERPC_EXCP_BOOKE; 2275 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 2276 pcc->bfd_mach = bfd_mach_ppc_403; 2277 pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DWE | 2278 POWERPC_FLAG_DE | POWERPC_FLAG_BUS_CLK; 2279 } 2280 2281 static void init_proc_440GP(CPUPPCState *env) 2282 { 2283 register_BookE_sprs(env, 0x000000000000FFFFULL); 2284 register_440_sprs(env); 2285 register_usprgh_sprs(env); 2286 2287 /* Memory management */ 2288 #if !defined(CONFIG_USER_ONLY) 2289 env->nb_tlb = 64; 2290 env->nb_ways = 1; 2291 env->id_tlbs = 0; 2292 env->tlb_type = TLB_EMB; 2293 #endif 2294 init_excp_BookE(env); 2295 env->dcache_line_size = 32; 2296 env->icache_line_size = 32; 2297 /* XXX: TODO: allocate internal IRQ controller */ 2298 2299 SET_FIT_PERIOD(12, 16, 20, 24); 2300 SET_WDT_PERIOD(20, 24, 28, 32); 2301 } 2302 2303 POWERPC_FAMILY(440GP)(ObjectClass *oc, void *data) 2304 { 2305 DeviceClass *dc = DEVICE_CLASS(oc); 2306 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2307 2308 dc->desc = "PowerPC 440 GP"; 2309 pcc->init_proc = init_proc_440GP; 2310 pcc->check_pow = check_pow_nocheck; 2311 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | 2312 PPC_DCR | PPC_DCRX | PPC_WRTEE | PPC_MFAPIDI | 2313 PPC_CACHE | PPC_CACHE_ICBI | 2314 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 2315 PPC_MEM_TLBSYNC | PPC_TLBIVA | PPC_MFTB | 2316 PPC_BOOKE | PPC_4xx_COMMON | PPC_405_MAC | 2317 PPC_440_SPEC; 2318 pcc->msr_mask = (1ull << MSR_POW) | 2319 (1ull << MSR_CE) | 2320 (1ull << MSR_EE) | 2321 (1ull << MSR_PR) | 2322 (1ull << MSR_FP) | 2323 (1ull << MSR_ME) | 2324 (1ull << MSR_FE0) | 2325 (1ull << MSR_DWE) | 2326 (1ull << MSR_DE) | 2327 (1ull << MSR_FE1) | 2328 (1ull << MSR_IR) | 2329 (1ull << MSR_DR); 2330 pcc->mmu_model = POWERPC_MMU_BOOKE; 2331 pcc->excp_model = POWERPC_EXCP_BOOKE; 2332 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 2333 pcc->bfd_mach = bfd_mach_ppc_403; 2334 pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DWE | 2335 POWERPC_FLAG_DE | POWERPC_FLAG_BUS_CLK; 2336 } 2337 2338 static void init_proc_440x5(CPUPPCState *env) 2339 { 2340 register_BookE_sprs(env, 0x000000000000FFFFULL); 2341 register_440_sprs(env); 2342 register_usprgh_sprs(env); 2343 2344 spr_register(env, SPR_BOOKE_MCSR, "MCSR", 2345 SPR_NOACCESS, SPR_NOACCESS, 2346 &spr_read_generic, &spr_write_generic, 2347 0x00000000); 2348 spr_register(env, SPR_BOOKE_MCSRR0, "MCSRR0", 2349 SPR_NOACCESS, SPR_NOACCESS, 2350 &spr_read_generic, &spr_write_generic, 2351 0x00000000); 2352 spr_register(env, SPR_BOOKE_MCSRR1, "MCSRR1", 2353 SPR_NOACCESS, SPR_NOACCESS, 2354 &spr_read_generic, &spr_write_generic, 2355 0x00000000); 2356 2357 spr_register(env, SPR_440_CCR1, "CCR1", 2358 SPR_NOACCESS, SPR_NOACCESS, 2359 &spr_read_generic, &spr_write_generic, 2360 0x00000000); 2361 /* Memory management */ 2362 #if !defined(CONFIG_USER_ONLY) 2363 env->nb_tlb = 64; 2364 env->nb_ways = 1; 2365 env->id_tlbs = 0; 2366 env->tlb_type = TLB_EMB; 2367 #endif 2368 init_excp_BookE(env); 2369 env->dcache_line_size = 32; 2370 env->icache_line_size = 32; 2371 ppc40x_irq_init(env_archcpu(env)); 2372 2373 SET_FIT_PERIOD(12, 16, 20, 24); 2374 SET_WDT_PERIOD(20, 24, 28, 32); 2375 } 2376 2377 POWERPC_FAMILY(440x5)(ObjectClass *oc, void *data) 2378 { 2379 DeviceClass *dc = DEVICE_CLASS(oc); 2380 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2381 2382 dc->desc = "PowerPC 440x5"; 2383 pcc->init_proc = init_proc_440x5; 2384 pcc->check_pow = check_pow_nocheck; 2385 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | 2386 PPC_DCR | PPC_WRTEE | PPC_RFMCI | 2387 PPC_CACHE | PPC_CACHE_ICBI | 2388 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 2389 PPC_MEM_TLBSYNC | PPC_MFTB | 2390 PPC_BOOKE | PPC_4xx_COMMON | PPC_405_MAC | 2391 PPC_440_SPEC; 2392 pcc->msr_mask = (1ull << MSR_POW) | 2393 (1ull << MSR_CE) | 2394 (1ull << MSR_EE) | 2395 (1ull << MSR_PR) | 2396 (1ull << MSR_FP) | 2397 (1ull << MSR_ME) | 2398 (1ull << MSR_FE0) | 2399 (1ull << MSR_DWE) | 2400 (1ull << MSR_DE) | 2401 (1ull << MSR_FE1) | 2402 (1ull << MSR_IR) | 2403 (1ull << MSR_DR); 2404 pcc->mmu_model = POWERPC_MMU_BOOKE; 2405 pcc->excp_model = POWERPC_EXCP_BOOKE; 2406 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 2407 pcc->bfd_mach = bfd_mach_ppc_403; 2408 pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DWE | 2409 POWERPC_FLAG_DE | POWERPC_FLAG_BUS_CLK; 2410 } 2411 2412 POWERPC_FAMILY(440x5wDFPU)(ObjectClass *oc, void *data) 2413 { 2414 DeviceClass *dc = DEVICE_CLASS(oc); 2415 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2416 2417 dc->desc = "PowerPC 440x5 with double precision FPU"; 2418 pcc->init_proc = init_proc_440x5; 2419 pcc->check_pow = check_pow_nocheck; 2420 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | 2421 PPC_FLOAT | PPC_FLOAT_FSQRT | 2422 PPC_FLOAT_STFIWX | 2423 PPC_DCR | PPC_WRTEE | PPC_RFMCI | 2424 PPC_CACHE | PPC_CACHE_ICBI | 2425 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 2426 PPC_MEM_TLBSYNC | PPC_MFTB | 2427 PPC_BOOKE | PPC_4xx_COMMON | PPC_405_MAC | 2428 PPC_440_SPEC; 2429 pcc->insns_flags2 = PPC2_FP_CVT_S64; 2430 pcc->msr_mask = (1ull << MSR_POW) | 2431 (1ull << MSR_CE) | 2432 (1ull << MSR_EE) | 2433 (1ull << MSR_PR) | 2434 (1ull << MSR_FP) | 2435 (1ull << MSR_ME) | 2436 (1ull << MSR_FE0) | 2437 (1ull << MSR_DWE) | 2438 (1ull << MSR_DE) | 2439 (1ull << MSR_FE1) | 2440 (1ull << MSR_IR) | 2441 (1ull << MSR_DR); 2442 pcc->mmu_model = POWERPC_MMU_BOOKE; 2443 pcc->excp_model = POWERPC_EXCP_BOOKE; 2444 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 2445 pcc->bfd_mach = bfd_mach_ppc_403; 2446 pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DWE | 2447 POWERPC_FLAG_DE | POWERPC_FLAG_BUS_CLK; 2448 } 2449 2450 static void init_proc_MPC5xx(CPUPPCState *env) 2451 { 2452 register_5xx_8xx_sprs(env); 2453 register_5xx_sprs(env); 2454 init_excp_MPC5xx(env); 2455 env->dcache_line_size = 32; 2456 env->icache_line_size = 32; 2457 /* XXX: TODO: allocate internal IRQ controller */ 2458 } 2459 2460 POWERPC_FAMILY(MPC5xx)(ObjectClass *oc, void *data) 2461 { 2462 DeviceClass *dc = DEVICE_CLASS(oc); 2463 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2464 2465 dc->desc = "Freescale 5xx cores (aka RCPU)"; 2466 pcc->init_proc = init_proc_MPC5xx; 2467 pcc->check_pow = check_pow_none; 2468 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | 2469 PPC_MEM_EIEIO | PPC_MEM_SYNC | 2470 PPC_CACHE_ICBI | PPC_FLOAT | PPC_FLOAT_STFIWX | 2471 PPC_MFTB; 2472 pcc->msr_mask = (1ull << MSR_ILE) | 2473 (1ull << MSR_EE) | 2474 (1ull << MSR_PR) | 2475 (1ull << MSR_FP) | 2476 (1ull << MSR_ME) | 2477 (1ull << MSR_FE0) | 2478 (1ull << MSR_SE) | 2479 (1ull << MSR_DE) | 2480 (1ull << MSR_FE1) | 2481 (1ull << MSR_EP) | 2482 (1ull << MSR_RI) | 2483 (1ull << MSR_LE); 2484 pcc->mmu_model = POWERPC_MMU_REAL; 2485 pcc->excp_model = POWERPC_EXCP_6xx; 2486 pcc->bus_model = PPC_FLAGS_INPUT_RCPU; 2487 pcc->bfd_mach = bfd_mach_ppc_505; 2488 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 2489 POWERPC_FLAG_BUS_CLK; 2490 } 2491 2492 static void init_proc_MPC8xx(CPUPPCState *env) 2493 { 2494 register_5xx_8xx_sprs(env); 2495 register_8xx_sprs(env); 2496 init_excp_MPC8xx(env); 2497 env->dcache_line_size = 32; 2498 env->icache_line_size = 32; 2499 /* XXX: TODO: allocate internal IRQ controller */ 2500 } 2501 2502 POWERPC_FAMILY(MPC8xx)(ObjectClass *oc, void *data) 2503 { 2504 DeviceClass *dc = DEVICE_CLASS(oc); 2505 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2506 2507 dc->desc = "Freescale 8xx cores (aka PowerQUICC)"; 2508 pcc->init_proc = init_proc_MPC8xx; 2509 pcc->check_pow = check_pow_none; 2510 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | 2511 PPC_MEM_EIEIO | PPC_MEM_SYNC | 2512 PPC_CACHE_ICBI | PPC_MFTB; 2513 pcc->msr_mask = (1ull << MSR_ILE) | 2514 (1ull << MSR_EE) | 2515 (1ull << MSR_PR) | 2516 (1ull << MSR_FP) | 2517 (1ull << MSR_ME) | 2518 (1ull << MSR_SE) | 2519 (1ull << MSR_DE) | 2520 (1ull << MSR_EP) | 2521 (1ull << MSR_IR) | 2522 (1ull << MSR_DR) | 2523 (1ull << MSR_RI) | 2524 (1ull << MSR_LE); 2525 pcc->mmu_model = POWERPC_MMU_MPC8xx; 2526 pcc->excp_model = POWERPC_EXCP_6xx; 2527 pcc->bus_model = PPC_FLAGS_INPUT_RCPU; 2528 pcc->bfd_mach = bfd_mach_ppc_860; 2529 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 2530 POWERPC_FLAG_BUS_CLK; 2531 } 2532 2533 /* Freescale 82xx cores (aka PowerQUICC-II) */ 2534 2535 static void init_proc_G2(CPUPPCState *env) 2536 { 2537 register_non_embedded_sprs(env); 2538 register_sdr1_sprs(env); 2539 register_G2_sprs(env); 2540 2541 /* Memory management */ 2542 register_low_BATs(env); 2543 register_high_BATs(env); 2544 register_6xx_7xx_soft_tlb(env, 64, 2); 2545 init_excp_G2(env); 2546 env->dcache_line_size = 32; 2547 env->icache_line_size = 32; 2548 /* Allocate hardware IRQ controller */ 2549 ppc6xx_irq_init(env_archcpu(env)); 2550 } 2551 2552 POWERPC_FAMILY(G2)(ObjectClass *oc, void *data) 2553 { 2554 DeviceClass *dc = DEVICE_CLASS(oc); 2555 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2556 2557 dc->desc = "PowerPC G2"; 2558 pcc->init_proc = init_proc_G2; 2559 pcc->check_pow = check_pow_hid0; 2560 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 2561 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 2562 PPC_FLOAT_STFIWX | 2563 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 2564 PPC_MEM_SYNC | PPC_MEM_EIEIO | 2565 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_6xx_TLB | 2566 PPC_SEGMENT | PPC_EXTERN; 2567 pcc->msr_mask = (1ull << MSR_POW) | 2568 (1ull << MSR_TGPR) | 2569 (1ull << MSR_EE) | 2570 (1ull << MSR_PR) | 2571 (1ull << MSR_FP) | 2572 (1ull << MSR_ME) | 2573 (1ull << MSR_FE0) | 2574 (1ull << MSR_SE) | 2575 (1ull << MSR_DE) | 2576 (1ull << MSR_FE1) | 2577 (1ull << MSR_AL) | 2578 (1ull << MSR_EP) | 2579 (1ull << MSR_IR) | 2580 (1ull << MSR_DR) | 2581 (1ull << MSR_RI); 2582 pcc->mmu_model = POWERPC_MMU_SOFT_6xx; 2583 pcc->excp_model = POWERPC_EXCP_6xx; 2584 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 2585 pcc->bfd_mach = bfd_mach_ppc_ec603e; 2586 pcc->flags = POWERPC_FLAG_TGPR | POWERPC_FLAG_SE | 2587 POWERPC_FLAG_BE | POWERPC_FLAG_BUS_CLK; 2588 } 2589 2590 POWERPC_FAMILY(G2LE)(ObjectClass *oc, void *data) 2591 { 2592 DeviceClass *dc = DEVICE_CLASS(oc); 2593 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2594 2595 dc->desc = "PowerPC G2LE"; 2596 pcc->init_proc = init_proc_G2; 2597 pcc->check_pow = check_pow_hid0; 2598 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 2599 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 2600 PPC_FLOAT_STFIWX | 2601 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 2602 PPC_MEM_SYNC | PPC_MEM_EIEIO | 2603 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_6xx_TLB | 2604 PPC_SEGMENT | PPC_EXTERN; 2605 pcc->msr_mask = (1ull << MSR_POW) | 2606 (1ull << MSR_TGPR) | 2607 (1ull << MSR_ILE) | 2608 (1ull << MSR_EE) | 2609 (1ull << MSR_PR) | 2610 (1ull << MSR_FP) | 2611 (1ull << MSR_ME) | 2612 (1ull << MSR_FE0) | 2613 (1ull << MSR_SE) | 2614 (1ull << MSR_DE) | 2615 (1ull << MSR_FE1) | 2616 (1ull << MSR_AL) | 2617 (1ull << MSR_EP) | 2618 (1ull << MSR_IR) | 2619 (1ull << MSR_DR) | 2620 (1ull << MSR_RI) | 2621 (1ull << MSR_LE); 2622 pcc->mmu_model = POWERPC_MMU_SOFT_6xx; 2623 pcc->excp_model = POWERPC_EXCP_6xx; 2624 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 2625 pcc->bfd_mach = bfd_mach_ppc_ec603e; 2626 pcc->flags = POWERPC_FLAG_TGPR | POWERPC_FLAG_SE | 2627 POWERPC_FLAG_BE | POWERPC_FLAG_BUS_CLK; 2628 } 2629 2630 static void init_proc_e200(CPUPPCState *env) 2631 { 2632 register_BookE_sprs(env, 0x000000070000FFFFULL); 2633 2634 spr_register(env, SPR_BOOKE_SPEFSCR, "SPEFSCR", 2635 &spr_read_spefscr, &spr_write_spefscr, 2636 &spr_read_spefscr, &spr_write_spefscr, 2637 0x00000000); 2638 /* Memory management */ 2639 register_BookE206_sprs(env, 0x0000005D, NULL, 0); 2640 register_usprgh_sprs(env); 2641 2642 spr_register(env, SPR_HID0, "HID0", 2643 SPR_NOACCESS, SPR_NOACCESS, 2644 &spr_read_generic, &spr_write_generic, 2645 0x00000000); 2646 2647 spr_register(env, SPR_HID1, "HID1", 2648 SPR_NOACCESS, SPR_NOACCESS, 2649 &spr_read_generic, &spr_write_generic, 2650 0x00000000); 2651 2652 spr_register(env, SPR_Exxx_ALTCTXCR, "ALTCTXCR", 2653 SPR_NOACCESS, SPR_NOACCESS, 2654 &spr_read_generic, &spr_write_generic, 2655 0x00000000); 2656 2657 spr_register(env, SPR_Exxx_BUCSR, "BUCSR", 2658 SPR_NOACCESS, SPR_NOACCESS, 2659 &spr_read_generic, &spr_write_generic, 2660 0x00000000); 2661 2662 spr_register(env, SPR_Exxx_CTXCR, "CTXCR", 2663 SPR_NOACCESS, SPR_NOACCESS, 2664 &spr_read_generic, &spr_write_generic, 2665 0x00000000); 2666 2667 spr_register(env, SPR_Exxx_DBCNT, "DBCNT", 2668 SPR_NOACCESS, SPR_NOACCESS, 2669 &spr_read_generic, &spr_write_generic, 2670 0x00000000); 2671 2672 spr_register(env, SPR_Exxx_DBCR3, "DBCR3", 2673 SPR_NOACCESS, SPR_NOACCESS, 2674 &spr_read_generic, &spr_write_generic, 2675 0x00000000); 2676 2677 spr_register(env, SPR_Exxx_L1CFG0, "L1CFG0", 2678 &spr_read_generic, SPR_NOACCESS, 2679 &spr_read_generic, SPR_NOACCESS, 2680 0x00000000); 2681 2682 spr_register(env, SPR_Exxx_L1CSR0, "L1CSR0", 2683 SPR_NOACCESS, SPR_NOACCESS, 2684 &spr_read_generic, &spr_write_generic, 2685 0x00000000); 2686 2687 spr_register(env, SPR_Exxx_L1FINV0, "L1FINV0", 2688 SPR_NOACCESS, SPR_NOACCESS, 2689 &spr_read_generic, &spr_write_generic, 2690 0x00000000); 2691 2692 spr_register(env, SPR_BOOKE_TLB0CFG, "TLB0CFG", 2693 SPR_NOACCESS, SPR_NOACCESS, 2694 &spr_read_generic, &spr_write_generic, 2695 0x00000000); 2696 2697 spr_register(env, SPR_BOOKE_TLB1CFG, "TLB1CFG", 2698 SPR_NOACCESS, SPR_NOACCESS, 2699 &spr_read_generic, &spr_write_generic, 2700 0x00000000); 2701 2702 spr_register(env, SPR_BOOKE_IAC3, "IAC3", 2703 SPR_NOACCESS, SPR_NOACCESS, 2704 &spr_read_generic, &spr_write_generic, 2705 0x00000000); 2706 2707 spr_register(env, SPR_BOOKE_IAC4, "IAC4", 2708 SPR_NOACCESS, SPR_NOACCESS, 2709 &spr_read_generic, &spr_write_generic, 2710 0x00000000); 2711 2712 spr_register(env, SPR_MMUCSR0, "MMUCSR0", 2713 SPR_NOACCESS, SPR_NOACCESS, 2714 &spr_read_generic, &spr_write_generic, 2715 0x00000000); /* TOFIX */ 2716 spr_register(env, SPR_BOOKE_DSRR0, "DSRR0", 2717 SPR_NOACCESS, SPR_NOACCESS, 2718 &spr_read_generic, &spr_write_generic, 2719 0x00000000); 2720 spr_register(env, SPR_BOOKE_DSRR1, "DSRR1", 2721 SPR_NOACCESS, SPR_NOACCESS, 2722 &spr_read_generic, &spr_write_generic, 2723 0x00000000); 2724 #if !defined(CONFIG_USER_ONLY) 2725 env->nb_tlb = 64; 2726 env->nb_ways = 1; 2727 env->id_tlbs = 0; 2728 env->tlb_type = TLB_EMB; 2729 #endif 2730 init_excp_e200(env, 0xFFFF0000UL); 2731 env->dcache_line_size = 32; 2732 env->icache_line_size = 32; 2733 /* XXX: TODO: allocate internal IRQ controller */ 2734 } 2735 2736 POWERPC_FAMILY(e200)(ObjectClass *oc, void *data) 2737 { 2738 DeviceClass *dc = DEVICE_CLASS(oc); 2739 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2740 2741 dc->desc = "e200 core"; 2742 pcc->init_proc = init_proc_e200; 2743 pcc->check_pow = check_pow_hid0; 2744 /* 2745 * XXX: unimplemented instructions: 2746 * dcblc 2747 * dcbtlst 2748 * dcbtstls 2749 * icblc 2750 * icbtls 2751 * tlbivax 2752 * all SPE multiply-accumulate instructions 2753 */ 2754 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | 2755 PPC_SPE | PPC_SPE_SINGLE | 2756 PPC_WRTEE | PPC_RFDI | 2757 PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI | 2758 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 2759 PPC_MEM_TLBSYNC | PPC_TLBIVAX | 2760 PPC_BOOKE; 2761 pcc->msr_mask = (1ull << MSR_UCLE) | 2762 (1ull << MSR_SPE) | 2763 (1ull << MSR_POW) | 2764 (1ull << MSR_CE) | 2765 (1ull << MSR_EE) | 2766 (1ull << MSR_PR) | 2767 (1ull << MSR_FP) | 2768 (1ull << MSR_ME) | 2769 (1ull << MSR_FE0) | 2770 (1ull << MSR_DWE) | 2771 (1ull << MSR_DE) | 2772 (1ull << MSR_FE1) | 2773 (1ull << MSR_IR) | 2774 (1ull << MSR_DR); 2775 pcc->mmu_model = POWERPC_MMU_BOOKE206; 2776 pcc->excp_model = POWERPC_EXCP_BOOKE; 2777 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 2778 pcc->bfd_mach = bfd_mach_ppc_860; 2779 pcc->flags = POWERPC_FLAG_SPE | POWERPC_FLAG_CE | 2780 POWERPC_FLAG_UBLE | POWERPC_FLAG_DE | 2781 POWERPC_FLAG_BUS_CLK; 2782 } 2783 2784 enum fsl_e500_version { 2785 fsl_e500v1, 2786 fsl_e500v2, 2787 fsl_e500mc, 2788 fsl_e5500, 2789 fsl_e6500, 2790 }; 2791 2792 static void init_proc_e500(CPUPPCState *env, int version) 2793 { 2794 uint32_t tlbncfg[2]; 2795 uint64_t ivor_mask; 2796 uint64_t ivpr_mask = 0xFFFF0000ULL; 2797 uint32_t l1cfg0 = 0x3800 /* 8 ways */ 2798 | 0x0020; /* 32 kb */ 2799 uint32_t l1cfg1 = 0x3800 /* 8 ways */ 2800 | 0x0020; /* 32 kb */ 2801 uint32_t mmucfg = 0; 2802 #if !defined(CONFIG_USER_ONLY) 2803 int i; 2804 #endif 2805 2806 /* 2807 * XXX The e500 doesn't implement IVOR7 and IVOR9, but doesn't 2808 * complain when accessing them. 2809 * register_BookE_sprs(env, 0x0000000F0000FD7FULL); 2810 */ 2811 switch (version) { 2812 case fsl_e500v1: 2813 case fsl_e500v2: 2814 default: 2815 ivor_mask = 0x0000000F0000FFFFULL; 2816 break; 2817 case fsl_e500mc: 2818 case fsl_e5500: 2819 ivor_mask = 0x000003FE0000FFFFULL; 2820 break; 2821 case fsl_e6500: 2822 ivor_mask = 0x000003FF0000FFFFULL; 2823 break; 2824 } 2825 register_BookE_sprs(env, ivor_mask); 2826 2827 spr_register(env, SPR_USPRG3, "USPRG3", 2828 &spr_read_ureg, SPR_NOACCESS, 2829 &spr_read_ureg, SPR_NOACCESS, 2830 0x00000000); 2831 2832 /* Processor identification */ 2833 spr_register(env, SPR_BOOKE_PIR, "PIR", 2834 SPR_NOACCESS, SPR_NOACCESS, 2835 &spr_read_generic, &spr_write_pir, 2836 0x00000000); 2837 2838 spr_register(env, SPR_BOOKE_SPEFSCR, "SPEFSCR", 2839 &spr_read_spefscr, &spr_write_spefscr, 2840 &spr_read_spefscr, &spr_write_spefscr, 2841 0x00000000); 2842 #if !defined(CONFIG_USER_ONLY) 2843 /* Memory management */ 2844 env->nb_pids = 3; 2845 env->nb_ways = 2; 2846 env->id_tlbs = 0; 2847 switch (version) { 2848 case fsl_e500v1: 2849 tlbncfg[0] = register_tlbncfg(2, 1, 1, 0, 256); 2850 tlbncfg[1] = register_tlbncfg(16, 1, 9, TLBnCFG_AVAIL | TLBnCFG_IPROT, 16); 2851 break; 2852 case fsl_e500v2: 2853 tlbncfg[0] = register_tlbncfg(4, 1, 1, 0, 512); 2854 tlbncfg[1] = register_tlbncfg(16, 1, 12, TLBnCFG_AVAIL | TLBnCFG_IPROT, 16); 2855 break; 2856 case fsl_e500mc: 2857 case fsl_e5500: 2858 tlbncfg[0] = register_tlbncfg(4, 1, 1, 0, 512); 2859 tlbncfg[1] = register_tlbncfg(64, 1, 12, TLBnCFG_AVAIL | TLBnCFG_IPROT, 64); 2860 break; 2861 case fsl_e6500: 2862 mmucfg = 0x6510B45; 2863 env->nb_pids = 1; 2864 tlbncfg[0] = 0x08052400; 2865 tlbncfg[1] = 0x40028040; 2866 break; 2867 default: 2868 cpu_abort(env_cpu(env), "Unknown CPU: " TARGET_FMT_lx "\n", 2869 env->spr[SPR_PVR]); 2870 } 2871 #endif 2872 /* Cache sizes */ 2873 switch (version) { 2874 case fsl_e500v1: 2875 case fsl_e500v2: 2876 env->dcache_line_size = 32; 2877 env->icache_line_size = 32; 2878 break; 2879 case fsl_e500mc: 2880 case fsl_e5500: 2881 env->dcache_line_size = 64; 2882 env->icache_line_size = 64; 2883 l1cfg0 |= 0x1000000; /* 64 byte cache block size */ 2884 l1cfg1 |= 0x1000000; /* 64 byte cache block size */ 2885 break; 2886 case fsl_e6500: 2887 env->dcache_line_size = 32; 2888 env->icache_line_size = 32; 2889 l1cfg0 |= 0x0F83820; 2890 l1cfg1 |= 0x0B83820; 2891 break; 2892 default: 2893 cpu_abort(env_cpu(env), "Unknown CPU: " TARGET_FMT_lx "\n", 2894 env->spr[SPR_PVR]); 2895 } 2896 register_BookE206_sprs(env, 0x000000DF, tlbncfg, mmucfg); 2897 register_usprgh_sprs(env); 2898 2899 spr_register(env, SPR_HID0, "HID0", 2900 SPR_NOACCESS, SPR_NOACCESS, 2901 &spr_read_generic, &spr_write_generic, 2902 0x00000000); 2903 2904 spr_register(env, SPR_HID1, "HID1", 2905 SPR_NOACCESS, SPR_NOACCESS, 2906 &spr_read_generic, &spr_write_generic, 2907 0x00000000); 2908 2909 spr_register(env, SPR_Exxx_BBEAR, "BBEAR", 2910 SPR_NOACCESS, SPR_NOACCESS, 2911 &spr_read_generic, &spr_write_generic, 2912 0x00000000); 2913 2914 spr_register(env, SPR_Exxx_BBTAR, "BBTAR", 2915 SPR_NOACCESS, SPR_NOACCESS, 2916 &spr_read_generic, &spr_write_generic, 2917 0x00000000); 2918 2919 spr_register(env, SPR_Exxx_MCAR, "MCAR", 2920 SPR_NOACCESS, SPR_NOACCESS, 2921 &spr_read_generic, &spr_write_generic, 2922 0x00000000); 2923 2924 spr_register(env, SPR_BOOKE_MCSR, "MCSR", 2925 SPR_NOACCESS, SPR_NOACCESS, 2926 &spr_read_generic, &spr_write_generic, 2927 0x00000000); 2928 2929 spr_register(env, SPR_Exxx_NPIDR, "NPIDR", 2930 SPR_NOACCESS, SPR_NOACCESS, 2931 &spr_read_generic, &spr_write_generic, 2932 0x00000000); 2933 2934 spr_register(env, SPR_Exxx_BUCSR, "BUCSR", 2935 SPR_NOACCESS, SPR_NOACCESS, 2936 &spr_read_generic, &spr_write_generic, 2937 0x00000000); 2938 2939 spr_register(env, SPR_Exxx_L1CFG0, "L1CFG0", 2940 &spr_read_generic, SPR_NOACCESS, 2941 &spr_read_generic, SPR_NOACCESS, 2942 l1cfg0); 2943 spr_register(env, SPR_Exxx_L1CFG1, "L1CFG1", 2944 &spr_read_generic, SPR_NOACCESS, 2945 &spr_read_generic, SPR_NOACCESS, 2946 l1cfg1); 2947 spr_register(env, SPR_Exxx_L1CSR0, "L1CSR0", 2948 SPR_NOACCESS, SPR_NOACCESS, 2949 &spr_read_generic, &spr_write_e500_l1csr0, 2950 0x00000000); 2951 spr_register(env, SPR_Exxx_L1CSR1, "L1CSR1", 2952 SPR_NOACCESS, SPR_NOACCESS, 2953 &spr_read_generic, &spr_write_e500_l1csr1, 2954 0x00000000); 2955 if (version != fsl_e500v1 && version != fsl_e500v2) { 2956 spr_register(env, SPR_Exxx_L2CSR0, "L2CSR0", 2957 SPR_NOACCESS, SPR_NOACCESS, 2958 &spr_read_generic, &spr_write_e500_l2csr0, 2959 0x00000000); 2960 } 2961 spr_register(env, SPR_BOOKE_MCSRR0, "MCSRR0", 2962 SPR_NOACCESS, SPR_NOACCESS, 2963 &spr_read_generic, &spr_write_generic, 2964 0x00000000); 2965 spr_register(env, SPR_BOOKE_MCSRR1, "MCSRR1", 2966 SPR_NOACCESS, SPR_NOACCESS, 2967 &spr_read_generic, &spr_write_generic, 2968 0x00000000); 2969 spr_register(env, SPR_MMUCSR0, "MMUCSR0", 2970 SPR_NOACCESS, SPR_NOACCESS, 2971 &spr_read_generic, &spr_write_booke206_mmucsr0, 2972 0x00000000); 2973 spr_register(env, SPR_BOOKE_EPR, "EPR", 2974 SPR_NOACCESS, SPR_NOACCESS, 2975 &spr_read_generic, SPR_NOACCESS, 2976 0x00000000); 2977 /* XXX better abstract into Emb.xxx features */ 2978 if ((version == fsl_e5500) || (version == fsl_e6500)) { 2979 spr_register(env, SPR_BOOKE_EPCR, "EPCR", 2980 SPR_NOACCESS, SPR_NOACCESS, 2981 &spr_read_generic, &spr_write_generic, 2982 0x00000000); 2983 spr_register(env, SPR_BOOKE_MAS7_MAS3, "MAS7_MAS3", 2984 SPR_NOACCESS, SPR_NOACCESS, 2985 &spr_read_mas73, &spr_write_mas73, 2986 0x00000000); 2987 ivpr_mask = (target_ulong)~0xFFFFULL; 2988 } 2989 2990 if (version == fsl_e6500) { 2991 /* Thread identification */ 2992 spr_register(env, SPR_TIR, "TIR", 2993 SPR_NOACCESS, SPR_NOACCESS, 2994 &spr_read_generic, SPR_NOACCESS, 2995 0x00000000); 2996 spr_register(env, SPR_BOOKE_TLB0PS, "TLB0PS", 2997 SPR_NOACCESS, SPR_NOACCESS, 2998 &spr_read_generic, SPR_NOACCESS, 2999 0x00000004); 3000 spr_register(env, SPR_BOOKE_TLB1PS, "TLB1PS", 3001 SPR_NOACCESS, SPR_NOACCESS, 3002 &spr_read_generic, SPR_NOACCESS, 3003 0x7FFFFFFC); 3004 } 3005 3006 #if !defined(CONFIG_USER_ONLY) 3007 env->nb_tlb = 0; 3008 env->tlb_type = TLB_MAS; 3009 for (i = 0; i < BOOKE206_MAX_TLBN; i++) { 3010 env->nb_tlb += booke206_tlb_size(env, i); 3011 } 3012 #endif 3013 3014 init_excp_e200(env, ivpr_mask); 3015 /* Allocate hardware IRQ controller */ 3016 ppce500_irq_init(env_archcpu(env)); 3017 } 3018 3019 static void init_proc_e500v1(CPUPPCState *env) 3020 { 3021 init_proc_e500(env, fsl_e500v1); 3022 } 3023 3024 POWERPC_FAMILY(e500v1)(ObjectClass *oc, void *data) 3025 { 3026 DeviceClass *dc = DEVICE_CLASS(oc); 3027 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3028 3029 dc->desc = "e500v1 core"; 3030 pcc->init_proc = init_proc_e500v1; 3031 pcc->check_pow = check_pow_hid0; 3032 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | 3033 PPC_SPE | PPC_SPE_SINGLE | 3034 PPC_WRTEE | PPC_RFDI | 3035 PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI | 3036 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 3037 PPC_MEM_TLBSYNC | PPC_TLBIVAX | PPC_MEM_SYNC; 3038 pcc->insns_flags2 = PPC2_BOOKE206; 3039 pcc->msr_mask = (1ull << MSR_UCLE) | 3040 (1ull << MSR_SPE) | 3041 (1ull << MSR_POW) | 3042 (1ull << MSR_CE) | 3043 (1ull << MSR_EE) | 3044 (1ull << MSR_PR) | 3045 (1ull << MSR_FP) | 3046 (1ull << MSR_ME) | 3047 (1ull << MSR_FE0) | 3048 (1ull << MSR_DWE) | 3049 (1ull << MSR_DE) | 3050 (1ull << MSR_FE1) | 3051 (1ull << MSR_IR) | 3052 (1ull << MSR_DR); 3053 pcc->mmu_model = POWERPC_MMU_BOOKE206; 3054 pcc->excp_model = POWERPC_EXCP_BOOKE; 3055 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 3056 pcc->bfd_mach = bfd_mach_ppc_860; 3057 pcc->flags = POWERPC_FLAG_SPE | POWERPC_FLAG_CE | 3058 POWERPC_FLAG_UBLE | POWERPC_FLAG_DE | 3059 POWERPC_FLAG_BUS_CLK; 3060 } 3061 3062 static void init_proc_e500v2(CPUPPCState *env) 3063 { 3064 init_proc_e500(env, fsl_e500v2); 3065 } 3066 3067 POWERPC_FAMILY(e500v2)(ObjectClass *oc, void *data) 3068 { 3069 DeviceClass *dc = DEVICE_CLASS(oc); 3070 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3071 3072 dc->desc = "e500v2 core"; 3073 pcc->init_proc = init_proc_e500v2; 3074 pcc->check_pow = check_pow_hid0; 3075 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | 3076 PPC_SPE | PPC_SPE_SINGLE | PPC_SPE_DOUBLE | 3077 PPC_WRTEE | PPC_RFDI | 3078 PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI | 3079 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 3080 PPC_MEM_TLBSYNC | PPC_TLBIVAX | PPC_MEM_SYNC; 3081 pcc->insns_flags2 = PPC2_BOOKE206; 3082 pcc->msr_mask = (1ull << MSR_UCLE) | 3083 (1ull << MSR_SPE) | 3084 (1ull << MSR_POW) | 3085 (1ull << MSR_CE) | 3086 (1ull << MSR_EE) | 3087 (1ull << MSR_PR) | 3088 (1ull << MSR_FP) | 3089 (1ull << MSR_ME) | 3090 (1ull << MSR_FE0) | 3091 (1ull << MSR_DWE) | 3092 (1ull << MSR_DE) | 3093 (1ull << MSR_FE1) | 3094 (1ull << MSR_IR) | 3095 (1ull << MSR_DR); 3096 pcc->mmu_model = POWERPC_MMU_BOOKE206; 3097 pcc->excp_model = POWERPC_EXCP_BOOKE; 3098 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 3099 pcc->bfd_mach = bfd_mach_ppc_860; 3100 pcc->flags = POWERPC_FLAG_SPE | POWERPC_FLAG_CE | 3101 POWERPC_FLAG_UBLE | POWERPC_FLAG_DE | 3102 POWERPC_FLAG_BUS_CLK; 3103 } 3104 3105 static void init_proc_e500mc(CPUPPCState *env) 3106 { 3107 init_proc_e500(env, fsl_e500mc); 3108 } 3109 3110 POWERPC_FAMILY(e500mc)(ObjectClass *oc, void *data) 3111 { 3112 DeviceClass *dc = DEVICE_CLASS(oc); 3113 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3114 3115 dc->desc = "e500mc core"; 3116 pcc->init_proc = init_proc_e500mc; 3117 pcc->check_pow = check_pow_none; 3118 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_MFTB | 3119 PPC_WRTEE | PPC_RFDI | PPC_RFMCI | 3120 PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI | 3121 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 3122 PPC_FLOAT | PPC_FLOAT_FRES | 3123 PPC_FLOAT_FRSQRTE | PPC_FLOAT_FSEL | 3124 PPC_FLOAT_STFIWX | PPC_WAIT | 3125 PPC_MEM_TLBSYNC | PPC_TLBIVAX | PPC_MEM_SYNC; 3126 pcc->insns_flags2 = PPC2_BOOKE206 | PPC2_PRCNTL; 3127 pcc->msr_mask = (1ull << MSR_GS) | 3128 (1ull << MSR_UCLE) | 3129 (1ull << MSR_CE) | 3130 (1ull << MSR_EE) | 3131 (1ull << MSR_PR) | 3132 (1ull << MSR_FP) | 3133 (1ull << MSR_ME) | 3134 (1ull << MSR_FE0) | 3135 (1ull << MSR_DE) | 3136 (1ull << MSR_FE1) | 3137 (1ull << MSR_IR) | 3138 (1ull << MSR_DR) | 3139 (1ull << MSR_PX) | 3140 (1ull << MSR_RI); 3141 pcc->mmu_model = POWERPC_MMU_BOOKE206; 3142 pcc->excp_model = POWERPC_EXCP_BOOKE; 3143 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 3144 /* FIXME: figure out the correct flag for e500mc */ 3145 pcc->bfd_mach = bfd_mach_ppc_e500; 3146 pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DE | 3147 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 3148 } 3149 3150 #ifdef TARGET_PPC64 3151 static void init_proc_e5500(CPUPPCState *env) 3152 { 3153 init_proc_e500(env, fsl_e5500); 3154 } 3155 3156 POWERPC_FAMILY(e5500)(ObjectClass *oc, void *data) 3157 { 3158 DeviceClass *dc = DEVICE_CLASS(oc); 3159 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3160 3161 dc->desc = "e5500 core"; 3162 pcc->init_proc = init_proc_e5500; 3163 pcc->check_pow = check_pow_none; 3164 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_MFTB | 3165 PPC_WRTEE | PPC_RFDI | PPC_RFMCI | 3166 PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI | 3167 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 3168 PPC_FLOAT | PPC_FLOAT_FRES | 3169 PPC_FLOAT_FRSQRTE | PPC_FLOAT_FSEL | 3170 PPC_FLOAT_STFIWX | PPC_WAIT | 3171 PPC_MEM_TLBSYNC | PPC_TLBIVAX | PPC_MEM_SYNC | 3172 PPC_64B | PPC_POPCNTB | PPC_POPCNTWD; 3173 pcc->insns_flags2 = PPC2_BOOKE206 | PPC2_PRCNTL | PPC2_PERM_ISA206 | 3174 PPC2_FP_CVT_S64; 3175 pcc->msr_mask = (1ull << MSR_CM) | 3176 (1ull << MSR_GS) | 3177 (1ull << MSR_UCLE) | 3178 (1ull << MSR_CE) | 3179 (1ull << MSR_EE) | 3180 (1ull << MSR_PR) | 3181 (1ull << MSR_FP) | 3182 (1ull << MSR_ME) | 3183 (1ull << MSR_FE0) | 3184 (1ull << MSR_DE) | 3185 (1ull << MSR_FE1) | 3186 (1ull << MSR_IR) | 3187 (1ull << MSR_DR) | 3188 (1ull << MSR_PX) | 3189 (1ull << MSR_RI); 3190 pcc->mmu_model = POWERPC_MMU_BOOKE206; 3191 pcc->excp_model = POWERPC_EXCP_BOOKE; 3192 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 3193 /* FIXME: figure out the correct flag for e5500 */ 3194 pcc->bfd_mach = bfd_mach_ppc_e500; 3195 pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DE | 3196 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 3197 } 3198 3199 static void init_proc_e6500(CPUPPCState *env) 3200 { 3201 init_proc_e500(env, fsl_e6500); 3202 } 3203 3204 POWERPC_FAMILY(e6500)(ObjectClass *oc, void *data) 3205 { 3206 DeviceClass *dc = DEVICE_CLASS(oc); 3207 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3208 3209 dc->desc = "e6500 core"; 3210 pcc->init_proc = init_proc_e6500; 3211 pcc->check_pow = check_pow_none; 3212 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_MFTB | 3213 PPC_WRTEE | PPC_RFDI | PPC_RFMCI | 3214 PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI | 3215 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 3216 PPC_FLOAT | PPC_FLOAT_FRES | 3217 PPC_FLOAT_FRSQRTE | PPC_FLOAT_FSEL | 3218 PPC_FLOAT_STFIWX | PPC_WAIT | 3219 PPC_MEM_TLBSYNC | PPC_TLBIVAX | PPC_MEM_SYNC | 3220 PPC_64B | PPC_POPCNTB | PPC_POPCNTWD | PPC_ALTIVEC; 3221 pcc->insns_flags2 = PPC2_BOOKE206 | PPC2_PRCNTL | PPC2_PERM_ISA206 | 3222 PPC2_FP_CVT_S64 | PPC2_ATOMIC_ISA206; 3223 pcc->msr_mask = (1ull << MSR_CM) | 3224 (1ull << MSR_GS) | 3225 (1ull << MSR_UCLE) | 3226 (1ull << MSR_CE) | 3227 (1ull << MSR_EE) | 3228 (1ull << MSR_PR) | 3229 (1ull << MSR_FP) | 3230 (1ull << MSR_ME) | 3231 (1ull << MSR_FE0) | 3232 (1ull << MSR_DE) | 3233 (1ull << MSR_FE1) | 3234 (1ull << MSR_IS) | 3235 (1ull << MSR_DS) | 3236 (1ull << MSR_PX) | 3237 (1ull << MSR_RI) | 3238 (1ull << MSR_VR); 3239 pcc->mmu_model = POWERPC_MMU_BOOKE206; 3240 pcc->excp_model = POWERPC_EXCP_BOOKE; 3241 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 3242 pcc->bfd_mach = bfd_mach_ppc_e500; 3243 pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DE | 3244 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_VRE; 3245 } 3246 3247 #endif 3248 3249 /* Non-embedded PowerPC */ 3250 static void init_proc_603(CPUPPCState *env) 3251 { 3252 register_non_embedded_sprs(env); 3253 register_sdr1_sprs(env); 3254 register_603_sprs(env); 3255 3256 /* Memory management */ 3257 register_low_BATs(env); 3258 register_6xx_7xx_soft_tlb(env, 64, 2); 3259 init_excp_603(env); 3260 env->dcache_line_size = 32; 3261 env->icache_line_size = 32; 3262 /* Allocate hardware IRQ controller */ 3263 ppc6xx_irq_init(env_archcpu(env)); 3264 } 3265 3266 POWERPC_FAMILY(603)(ObjectClass *oc, void *data) 3267 { 3268 DeviceClass *dc = DEVICE_CLASS(oc); 3269 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3270 3271 dc->desc = "PowerPC 603"; 3272 pcc->init_proc = init_proc_603; 3273 pcc->check_pow = check_pow_hid0; 3274 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3275 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3276 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 3277 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3278 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3279 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_6xx_TLB | 3280 PPC_SEGMENT | PPC_EXTERN; 3281 pcc->msr_mask = (1ull << MSR_POW) | 3282 (1ull << MSR_TGPR) | 3283 (1ull << MSR_ILE) | 3284 (1ull << MSR_EE) | 3285 (1ull << MSR_PR) | 3286 (1ull << MSR_FP) | 3287 (1ull << MSR_ME) | 3288 (1ull << MSR_FE0) | 3289 (1ull << MSR_SE) | 3290 (1ull << MSR_DE) | 3291 (1ull << MSR_FE1) | 3292 (1ull << MSR_EP) | 3293 (1ull << MSR_IR) | 3294 (1ull << MSR_DR) | 3295 (1ull << MSR_RI) | 3296 (1ull << MSR_LE); 3297 pcc->mmu_model = POWERPC_MMU_SOFT_6xx; 3298 pcc->excp_model = POWERPC_EXCP_6xx; 3299 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 3300 pcc->bfd_mach = bfd_mach_ppc_603; 3301 pcc->flags = POWERPC_FLAG_TGPR | POWERPC_FLAG_SE | 3302 POWERPC_FLAG_BE | POWERPC_FLAG_BUS_CLK; 3303 } 3304 3305 POWERPC_FAMILY(603E)(ObjectClass *oc, void *data) 3306 { 3307 DeviceClass *dc = DEVICE_CLASS(oc); 3308 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3309 3310 dc->desc = "PowerPC 603e"; 3311 pcc->init_proc = init_proc_603; 3312 pcc->check_pow = check_pow_hid0; 3313 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3314 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3315 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 3316 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3317 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3318 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_6xx_TLB | 3319 PPC_SEGMENT | PPC_EXTERN; 3320 pcc->msr_mask = (1ull << MSR_POW) | 3321 (1ull << MSR_TGPR) | 3322 (1ull << MSR_ILE) | 3323 (1ull << MSR_EE) | 3324 (1ull << MSR_PR) | 3325 (1ull << MSR_FP) | 3326 (1ull << MSR_ME) | 3327 (1ull << MSR_FE0) | 3328 (1ull << MSR_SE) | 3329 (1ull << MSR_DE) | 3330 (1ull << MSR_FE1) | 3331 (1ull << MSR_EP) | 3332 (1ull << MSR_IR) | 3333 (1ull << MSR_DR) | 3334 (1ull << MSR_RI) | 3335 (1ull << MSR_LE); 3336 pcc->mmu_model = POWERPC_MMU_SOFT_6xx; 3337 pcc->excp_model = POWERPC_EXCP_6xx; 3338 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 3339 pcc->bfd_mach = bfd_mach_ppc_ec603e; 3340 pcc->flags = POWERPC_FLAG_TGPR | POWERPC_FLAG_SE | 3341 POWERPC_FLAG_BE | POWERPC_FLAG_BUS_CLK; 3342 } 3343 3344 static void init_proc_e300(CPUPPCState *env) 3345 { 3346 init_proc_603(env); 3347 register_e300_sprs(env); 3348 } 3349 3350 POWERPC_FAMILY(e300)(ObjectClass *oc, void *data) 3351 { 3352 DeviceClass *dc = DEVICE_CLASS(oc); 3353 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3354 3355 dc->desc = "e300 core"; 3356 pcc->init_proc = init_proc_e300; 3357 pcc->check_pow = check_pow_hid0; 3358 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3359 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3360 PPC_FLOAT_STFIWX | 3361 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3362 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3363 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_6xx_TLB | 3364 PPC_SEGMENT | PPC_EXTERN; 3365 pcc->msr_mask = (1ull << MSR_POW) | 3366 (1ull << MSR_TGPR) | 3367 (1ull << MSR_ILE) | 3368 (1ull << MSR_EE) | 3369 (1ull << MSR_PR) | 3370 (1ull << MSR_FP) | 3371 (1ull << MSR_ME) | 3372 (1ull << MSR_FE0) | 3373 (1ull << MSR_SE) | 3374 (1ull << MSR_DE) | 3375 (1ull << MSR_FE1) | 3376 (1ull << MSR_AL) | 3377 (1ull << MSR_EP) | 3378 (1ull << MSR_IR) | 3379 (1ull << MSR_DR) | 3380 (1ull << MSR_RI) | 3381 (1ull << MSR_LE); 3382 pcc->mmu_model = POWERPC_MMU_SOFT_6xx; 3383 pcc->excp_model = POWERPC_EXCP_6xx; 3384 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 3385 pcc->bfd_mach = bfd_mach_ppc_603; 3386 pcc->flags = POWERPC_FLAG_TGPR | POWERPC_FLAG_SE | 3387 POWERPC_FLAG_BE | POWERPC_FLAG_BUS_CLK; 3388 } 3389 3390 static void init_proc_604(CPUPPCState *env) 3391 { 3392 register_non_embedded_sprs(env); 3393 register_sdr1_sprs(env); 3394 register_604_sprs(env); 3395 3396 /* Memory management */ 3397 register_low_BATs(env); 3398 init_excp_604(env); 3399 env->dcache_line_size = 32; 3400 env->icache_line_size = 32; 3401 /* Allocate hardware IRQ controller */ 3402 ppc6xx_irq_init(env_archcpu(env)); 3403 } 3404 3405 POWERPC_FAMILY(604)(ObjectClass *oc, void *data) 3406 { 3407 DeviceClass *dc = DEVICE_CLASS(oc); 3408 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3409 3410 dc->desc = "PowerPC 604"; 3411 pcc->init_proc = init_proc_604; 3412 pcc->check_pow = check_pow_nocheck; 3413 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3414 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3415 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 3416 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3417 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3418 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 3419 PPC_SEGMENT | PPC_EXTERN; 3420 pcc->msr_mask = (1ull << MSR_POW) | 3421 (1ull << MSR_ILE) | 3422 (1ull << MSR_EE) | 3423 (1ull << MSR_PR) | 3424 (1ull << MSR_FP) | 3425 (1ull << MSR_ME) | 3426 (1ull << MSR_FE0) | 3427 (1ull << MSR_SE) | 3428 (1ull << MSR_DE) | 3429 (1ull << MSR_FE1) | 3430 (1ull << MSR_EP) | 3431 (1ull << MSR_IR) | 3432 (1ull << MSR_DR) | 3433 (1ull << MSR_PMM) | 3434 (1ull << MSR_RI) | 3435 (1ull << MSR_LE); 3436 pcc->mmu_model = POWERPC_MMU_32B; 3437 pcc->excp_model = POWERPC_EXCP_6xx; 3438 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 3439 pcc->bfd_mach = bfd_mach_ppc_604; 3440 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 3441 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 3442 } 3443 3444 static void init_proc_604E(CPUPPCState *env) 3445 { 3446 init_proc_604(env); 3447 register_604e_sprs(env); 3448 } 3449 3450 POWERPC_FAMILY(604E)(ObjectClass *oc, void *data) 3451 { 3452 DeviceClass *dc = DEVICE_CLASS(oc); 3453 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3454 3455 dc->desc = "PowerPC 604E"; 3456 pcc->init_proc = init_proc_604E; 3457 pcc->check_pow = check_pow_nocheck; 3458 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3459 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3460 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 3461 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3462 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3463 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 3464 PPC_SEGMENT | PPC_EXTERN; 3465 pcc->msr_mask = (1ull << MSR_POW) | 3466 (1ull << MSR_ILE) | 3467 (1ull << MSR_EE) | 3468 (1ull << MSR_PR) | 3469 (1ull << MSR_FP) | 3470 (1ull << MSR_ME) | 3471 (1ull << MSR_FE0) | 3472 (1ull << MSR_SE) | 3473 (1ull << MSR_DE) | 3474 (1ull << MSR_FE1) | 3475 (1ull << MSR_EP) | 3476 (1ull << MSR_IR) | 3477 (1ull << MSR_DR) | 3478 (1ull << MSR_PMM) | 3479 (1ull << MSR_RI) | 3480 (1ull << MSR_LE); 3481 pcc->mmu_model = POWERPC_MMU_32B; 3482 pcc->excp_model = POWERPC_EXCP_6xx; 3483 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 3484 pcc->bfd_mach = bfd_mach_ppc_604; 3485 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 3486 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 3487 } 3488 3489 static void init_proc_740(CPUPPCState *env) 3490 { 3491 register_non_embedded_sprs(env); 3492 register_sdr1_sprs(env); 3493 register_7xx_sprs(env); 3494 /* Thermal management */ 3495 register_thrm_sprs(env); 3496 3497 /* Memory management */ 3498 register_low_BATs(env); 3499 init_excp_7x0(env); 3500 env->dcache_line_size = 32; 3501 env->icache_line_size = 32; 3502 /* Allocate hardware IRQ controller */ 3503 ppc6xx_irq_init(env_archcpu(env)); 3504 } 3505 3506 POWERPC_FAMILY(740)(ObjectClass *oc, void *data) 3507 { 3508 DeviceClass *dc = DEVICE_CLASS(oc); 3509 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3510 3511 dc->desc = "PowerPC 740"; 3512 pcc->init_proc = init_proc_740; 3513 pcc->check_pow = check_pow_hid0; 3514 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3515 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3516 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 3517 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3518 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3519 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 3520 PPC_SEGMENT | PPC_EXTERN; 3521 pcc->msr_mask = (1ull << MSR_POW) | 3522 (1ull << MSR_ILE) | 3523 (1ull << MSR_EE) | 3524 (1ull << MSR_PR) | 3525 (1ull << MSR_FP) | 3526 (1ull << MSR_ME) | 3527 (1ull << MSR_FE0) | 3528 (1ull << MSR_SE) | 3529 (1ull << MSR_DE) | 3530 (1ull << MSR_FE1) | 3531 (1ull << MSR_EP) | 3532 (1ull << MSR_IR) | 3533 (1ull << MSR_DR) | 3534 (1ull << MSR_PMM) | 3535 (1ull << MSR_RI) | 3536 (1ull << MSR_LE); 3537 pcc->mmu_model = POWERPC_MMU_32B; 3538 pcc->excp_model = POWERPC_EXCP_7xx; 3539 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 3540 pcc->bfd_mach = bfd_mach_ppc_750; 3541 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 3542 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 3543 } 3544 3545 static void init_proc_750(CPUPPCState *env) 3546 { 3547 register_non_embedded_sprs(env); 3548 register_sdr1_sprs(env); 3549 register_7xx_sprs(env); 3550 3551 spr_register(env, SPR_L2CR, "L2CR", 3552 SPR_NOACCESS, SPR_NOACCESS, 3553 &spr_read_generic, spr_access_nop, 3554 0x00000000); 3555 /* Thermal management */ 3556 register_thrm_sprs(env); 3557 3558 /* Memory management */ 3559 register_low_BATs(env); 3560 /* 3561 * XXX: high BATs are also present but are known to be bugged on 3562 * die version 1.x 3563 */ 3564 init_excp_7x0(env); 3565 env->dcache_line_size = 32; 3566 env->icache_line_size = 32; 3567 /* Allocate hardware IRQ controller */ 3568 ppc6xx_irq_init(env_archcpu(env)); 3569 } 3570 3571 POWERPC_FAMILY(750)(ObjectClass *oc, void *data) 3572 { 3573 DeviceClass *dc = DEVICE_CLASS(oc); 3574 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3575 3576 dc->desc = "PowerPC 750"; 3577 pcc->init_proc = init_proc_750; 3578 pcc->check_pow = check_pow_hid0; 3579 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3580 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3581 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 3582 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3583 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3584 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 3585 PPC_SEGMENT | PPC_EXTERN; 3586 pcc->msr_mask = (1ull << MSR_POW) | 3587 (1ull << MSR_ILE) | 3588 (1ull << MSR_EE) | 3589 (1ull << MSR_PR) | 3590 (1ull << MSR_FP) | 3591 (1ull << MSR_ME) | 3592 (1ull << MSR_FE0) | 3593 (1ull << MSR_SE) | 3594 (1ull << MSR_DE) | 3595 (1ull << MSR_FE1) | 3596 (1ull << MSR_EP) | 3597 (1ull << MSR_IR) | 3598 (1ull << MSR_DR) | 3599 (1ull << MSR_PMM) | 3600 (1ull << MSR_RI) | 3601 (1ull << MSR_LE); 3602 pcc->mmu_model = POWERPC_MMU_32B; 3603 pcc->excp_model = POWERPC_EXCP_7xx; 3604 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 3605 pcc->bfd_mach = bfd_mach_ppc_750; 3606 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 3607 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 3608 } 3609 3610 static void init_proc_750cl(CPUPPCState *env) 3611 { 3612 register_non_embedded_sprs(env); 3613 register_sdr1_sprs(env); 3614 register_7xx_sprs(env); 3615 3616 spr_register(env, SPR_L2CR, "L2CR", 3617 SPR_NOACCESS, SPR_NOACCESS, 3618 &spr_read_generic, spr_access_nop, 3619 0x00000000); 3620 /* Thermal management */ 3621 /* Those registers are fake on 750CL */ 3622 spr_register(env, SPR_THRM1, "THRM1", 3623 SPR_NOACCESS, SPR_NOACCESS, 3624 &spr_read_generic, &spr_write_generic, 3625 0x00000000); 3626 spr_register(env, SPR_THRM2, "THRM2", 3627 SPR_NOACCESS, SPR_NOACCESS, 3628 &spr_read_generic, &spr_write_generic, 3629 0x00000000); 3630 spr_register(env, SPR_THRM3, "THRM3", 3631 SPR_NOACCESS, SPR_NOACCESS, 3632 &spr_read_generic, &spr_write_generic, 3633 0x00000000); 3634 3635 spr_register(env, SPR_750_TDCL, "TDCL", 3636 SPR_NOACCESS, SPR_NOACCESS, 3637 &spr_read_generic, &spr_write_generic, 3638 0x00000000); 3639 spr_register(env, SPR_750_TDCH, "TDCH", 3640 SPR_NOACCESS, SPR_NOACCESS, 3641 &spr_read_generic, &spr_write_generic, 3642 0x00000000); 3643 /* DMA */ 3644 spr_register(env, SPR_750_WPAR, "WPAR", 3645 SPR_NOACCESS, SPR_NOACCESS, 3646 &spr_read_generic, &spr_write_generic, 3647 0x00000000); 3648 spr_register(env, SPR_750_DMAL, "DMAL", 3649 SPR_NOACCESS, SPR_NOACCESS, 3650 &spr_read_generic, &spr_write_generic, 3651 0x00000000); 3652 spr_register(env, SPR_750_DMAU, "DMAU", 3653 SPR_NOACCESS, SPR_NOACCESS, 3654 &spr_read_generic, &spr_write_generic, 3655 0x00000000); 3656 /* Hardware implementation registers */ 3657 spr_register(env, SPR_750CL_HID2, "HID2", 3658 SPR_NOACCESS, SPR_NOACCESS, 3659 &spr_read_generic, &spr_write_generic, 3660 0x00000000); 3661 3662 spr_register(env, SPR_750CL_HID4, "HID4", 3663 SPR_NOACCESS, SPR_NOACCESS, 3664 &spr_read_generic, &spr_write_generic, 3665 0x00000000); 3666 /* Quantization registers */ 3667 spr_register(env, SPR_750_GQR0, "GQR0", 3668 SPR_NOACCESS, SPR_NOACCESS, 3669 &spr_read_generic, &spr_write_generic, 3670 0x00000000); 3671 3672 spr_register(env, SPR_750_GQR1, "GQR1", 3673 SPR_NOACCESS, SPR_NOACCESS, 3674 &spr_read_generic, &spr_write_generic, 3675 0x00000000); 3676 3677 spr_register(env, SPR_750_GQR2, "GQR2", 3678 SPR_NOACCESS, SPR_NOACCESS, 3679 &spr_read_generic, &spr_write_generic, 3680 0x00000000); 3681 3682 spr_register(env, SPR_750_GQR3, "GQR3", 3683 SPR_NOACCESS, SPR_NOACCESS, 3684 &spr_read_generic, &spr_write_generic, 3685 0x00000000); 3686 3687 spr_register(env, SPR_750_GQR4, "GQR4", 3688 SPR_NOACCESS, SPR_NOACCESS, 3689 &spr_read_generic, &spr_write_generic, 3690 0x00000000); 3691 3692 spr_register(env, SPR_750_GQR5, "GQR5", 3693 SPR_NOACCESS, SPR_NOACCESS, 3694 &spr_read_generic, &spr_write_generic, 3695 0x00000000); 3696 3697 spr_register(env, SPR_750_GQR6, "GQR6", 3698 SPR_NOACCESS, SPR_NOACCESS, 3699 &spr_read_generic, &spr_write_generic, 3700 0x00000000); 3701 3702 spr_register(env, SPR_750_GQR7, "GQR7", 3703 SPR_NOACCESS, SPR_NOACCESS, 3704 &spr_read_generic, &spr_write_generic, 3705 0x00000000); 3706 /* Memory management */ 3707 register_low_BATs(env); 3708 /* PowerPC 750cl has 8 DBATs and 8 IBATs */ 3709 register_high_BATs(env); 3710 init_excp_750cl(env); 3711 env->dcache_line_size = 32; 3712 env->icache_line_size = 32; 3713 /* Allocate hardware IRQ controller */ 3714 ppc6xx_irq_init(env_archcpu(env)); 3715 } 3716 3717 POWERPC_FAMILY(750cl)(ObjectClass *oc, void *data) 3718 { 3719 DeviceClass *dc = DEVICE_CLASS(oc); 3720 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3721 3722 dc->desc = "PowerPC 750 CL"; 3723 pcc->init_proc = init_proc_750cl; 3724 pcc->check_pow = check_pow_hid0; 3725 /* 3726 * XXX: not implemented: 3727 * cache lock instructions: 3728 * dcbz_l 3729 * floating point paired instructions 3730 * psq_lux 3731 * psq_lx 3732 * psq_stux 3733 * psq_stx 3734 * ps_abs 3735 * ps_add 3736 * ps_cmpo0 3737 * ps_cmpo1 3738 * ps_cmpu0 3739 * ps_cmpu1 3740 * ps_div 3741 * ps_madd 3742 * ps_madds0 3743 * ps_madds1 3744 * ps_merge00 3745 * ps_merge01 3746 * ps_merge10 3747 * ps_merge11 3748 * ps_mr 3749 * ps_msub 3750 * ps_mul 3751 * ps_muls0 3752 * ps_muls1 3753 * ps_nabs 3754 * ps_neg 3755 * ps_nmadd 3756 * ps_nmsub 3757 * ps_res 3758 * ps_rsqrte 3759 * ps_sel 3760 * ps_sub 3761 * ps_sum0 3762 * ps_sum1 3763 */ 3764 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3765 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3766 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 3767 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3768 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3769 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 3770 PPC_SEGMENT | PPC_EXTERN; 3771 pcc->msr_mask = (1ull << MSR_POW) | 3772 (1ull << MSR_ILE) | 3773 (1ull << MSR_EE) | 3774 (1ull << MSR_PR) | 3775 (1ull << MSR_FP) | 3776 (1ull << MSR_ME) | 3777 (1ull << MSR_FE0) | 3778 (1ull << MSR_SE) | 3779 (1ull << MSR_DE) | 3780 (1ull << MSR_FE1) | 3781 (1ull << MSR_EP) | 3782 (1ull << MSR_IR) | 3783 (1ull << MSR_DR) | 3784 (1ull << MSR_PMM) | 3785 (1ull << MSR_RI) | 3786 (1ull << MSR_LE); 3787 pcc->mmu_model = POWERPC_MMU_32B; 3788 pcc->excp_model = POWERPC_EXCP_7xx; 3789 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 3790 pcc->bfd_mach = bfd_mach_ppc_750; 3791 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 3792 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 3793 } 3794 3795 static void init_proc_750cx(CPUPPCState *env) 3796 { 3797 register_non_embedded_sprs(env); 3798 register_sdr1_sprs(env); 3799 register_7xx_sprs(env); 3800 3801 spr_register(env, SPR_L2CR, "L2CR", 3802 SPR_NOACCESS, SPR_NOACCESS, 3803 &spr_read_generic, spr_access_nop, 3804 0x00000000); 3805 /* Thermal management */ 3806 register_thrm_sprs(env); 3807 3808 spr_register(env, SPR_SDA, "SDA", 3809 SPR_NOACCESS, SPR_NOACCESS, 3810 &spr_read_generic, &spr_write_generic, 3811 0x00000000); 3812 3813 /* Memory management */ 3814 register_low_BATs(env); 3815 /* PowerPC 750cx has 8 DBATs and 8 IBATs */ 3816 register_high_BATs(env); 3817 init_excp_750cx(env); 3818 env->dcache_line_size = 32; 3819 env->icache_line_size = 32; 3820 /* Allocate hardware IRQ controller */ 3821 ppc6xx_irq_init(env_archcpu(env)); 3822 } 3823 3824 POWERPC_FAMILY(750cx)(ObjectClass *oc, void *data) 3825 { 3826 DeviceClass *dc = DEVICE_CLASS(oc); 3827 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3828 3829 dc->desc = "PowerPC 750CX"; 3830 pcc->init_proc = init_proc_750cx; 3831 pcc->check_pow = check_pow_hid0; 3832 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3833 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3834 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 3835 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3836 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3837 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 3838 PPC_SEGMENT | PPC_EXTERN; 3839 pcc->msr_mask = (1ull << MSR_POW) | 3840 (1ull << MSR_ILE) | 3841 (1ull << MSR_EE) | 3842 (1ull << MSR_PR) | 3843 (1ull << MSR_FP) | 3844 (1ull << MSR_ME) | 3845 (1ull << MSR_FE0) | 3846 (1ull << MSR_SE) | 3847 (1ull << MSR_DE) | 3848 (1ull << MSR_FE1) | 3849 (1ull << MSR_EP) | 3850 (1ull << MSR_IR) | 3851 (1ull << MSR_DR) | 3852 (1ull << MSR_PMM) | 3853 (1ull << MSR_RI) | 3854 (1ull << MSR_LE); 3855 pcc->mmu_model = POWERPC_MMU_32B; 3856 pcc->excp_model = POWERPC_EXCP_7xx; 3857 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 3858 pcc->bfd_mach = bfd_mach_ppc_750; 3859 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 3860 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 3861 } 3862 3863 static void init_proc_750fx(CPUPPCState *env) 3864 { 3865 register_non_embedded_sprs(env); 3866 register_sdr1_sprs(env); 3867 register_7xx_sprs(env); 3868 3869 spr_register(env, SPR_L2CR, "L2CR", 3870 SPR_NOACCESS, SPR_NOACCESS, 3871 &spr_read_generic, spr_access_nop, 3872 0x00000000); 3873 /* Thermal management */ 3874 register_thrm_sprs(env); 3875 3876 spr_register(env, SPR_750_THRM4, "THRM4", 3877 SPR_NOACCESS, SPR_NOACCESS, 3878 &spr_read_generic, &spr_write_generic, 3879 0x00000000); 3880 /* Hardware implementation registers */ 3881 spr_register(env, SPR_750FX_HID2, "HID2", 3882 SPR_NOACCESS, SPR_NOACCESS, 3883 &spr_read_generic, &spr_write_generic, 3884 0x00000000); 3885 /* Memory management */ 3886 register_low_BATs(env); 3887 /* PowerPC 750fx & 750gx has 8 DBATs and 8 IBATs */ 3888 register_high_BATs(env); 3889 init_excp_7x0(env); 3890 env->dcache_line_size = 32; 3891 env->icache_line_size = 32; 3892 /* Allocate hardware IRQ controller */ 3893 ppc6xx_irq_init(env_archcpu(env)); 3894 } 3895 3896 POWERPC_FAMILY(750fx)(ObjectClass *oc, void *data) 3897 { 3898 DeviceClass *dc = DEVICE_CLASS(oc); 3899 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3900 3901 dc->desc = "PowerPC 750FX"; 3902 pcc->init_proc = init_proc_750fx; 3903 pcc->check_pow = check_pow_hid0; 3904 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3905 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3906 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 3907 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3908 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3909 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 3910 PPC_SEGMENT | PPC_EXTERN; 3911 pcc->msr_mask = (1ull << MSR_POW) | 3912 (1ull << MSR_ILE) | 3913 (1ull << MSR_EE) | 3914 (1ull << MSR_PR) | 3915 (1ull << MSR_FP) | 3916 (1ull << MSR_ME) | 3917 (1ull << MSR_FE0) | 3918 (1ull << MSR_SE) | 3919 (1ull << MSR_DE) | 3920 (1ull << MSR_FE1) | 3921 (1ull << MSR_EP) | 3922 (1ull << MSR_IR) | 3923 (1ull << MSR_DR) | 3924 (1ull << MSR_PMM) | 3925 (1ull << MSR_RI) | 3926 (1ull << MSR_LE); 3927 pcc->mmu_model = POWERPC_MMU_32B; 3928 pcc->excp_model = POWERPC_EXCP_7xx; 3929 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 3930 pcc->bfd_mach = bfd_mach_ppc_750; 3931 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 3932 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 3933 } 3934 3935 static void init_proc_750gx(CPUPPCState *env) 3936 { 3937 register_non_embedded_sprs(env); 3938 register_sdr1_sprs(env); 3939 register_7xx_sprs(env); 3940 3941 spr_register(env, SPR_L2CR, "L2CR", 3942 SPR_NOACCESS, SPR_NOACCESS, 3943 &spr_read_generic, spr_access_nop, 3944 0x00000000); 3945 /* Thermal management */ 3946 register_thrm_sprs(env); 3947 3948 spr_register(env, SPR_750_THRM4, "THRM4", 3949 SPR_NOACCESS, SPR_NOACCESS, 3950 &spr_read_generic, &spr_write_generic, 3951 0x00000000); 3952 /* Hardware implementation registers */ 3953 spr_register(env, SPR_750FX_HID2, "HID2", 3954 SPR_NOACCESS, SPR_NOACCESS, 3955 &spr_read_generic, &spr_write_generic, 3956 0x00000000); 3957 /* Memory management */ 3958 register_low_BATs(env); 3959 /* PowerPC 750fx & 750gx has 8 DBATs and 8 IBATs */ 3960 register_high_BATs(env); 3961 init_excp_7x0(env); 3962 env->dcache_line_size = 32; 3963 env->icache_line_size = 32; 3964 /* Allocate hardware IRQ controller */ 3965 ppc6xx_irq_init(env_archcpu(env)); 3966 } 3967 3968 POWERPC_FAMILY(750gx)(ObjectClass *oc, void *data) 3969 { 3970 DeviceClass *dc = DEVICE_CLASS(oc); 3971 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3972 3973 dc->desc = "PowerPC 750GX"; 3974 pcc->init_proc = init_proc_750gx; 3975 pcc->check_pow = check_pow_hid0; 3976 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3977 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3978 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 3979 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3980 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3981 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 3982 PPC_SEGMENT | PPC_EXTERN; 3983 pcc->msr_mask = (1ull << MSR_POW) | 3984 (1ull << MSR_ILE) | 3985 (1ull << MSR_EE) | 3986 (1ull << MSR_PR) | 3987 (1ull << MSR_FP) | 3988 (1ull << MSR_ME) | 3989 (1ull << MSR_FE0) | 3990 (1ull << MSR_SE) | 3991 (1ull << MSR_DE) | 3992 (1ull << MSR_FE1) | 3993 (1ull << MSR_EP) | 3994 (1ull << MSR_IR) | 3995 (1ull << MSR_DR) | 3996 (1ull << MSR_PMM) | 3997 (1ull << MSR_RI) | 3998 (1ull << MSR_LE); 3999 pcc->mmu_model = POWERPC_MMU_32B; 4000 pcc->excp_model = POWERPC_EXCP_7xx; 4001 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 4002 pcc->bfd_mach = bfd_mach_ppc_750; 4003 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 4004 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 4005 } 4006 4007 static void init_proc_745(CPUPPCState *env) 4008 { 4009 register_non_embedded_sprs(env); 4010 register_sdr1_sprs(env); 4011 register_7xx_sprs(env); 4012 register_745_sprs(env); 4013 /* Thermal management */ 4014 register_thrm_sprs(env); 4015 4016 /* Memory management */ 4017 register_low_BATs(env); 4018 register_high_BATs(env); 4019 register_6xx_7xx_soft_tlb(env, 64, 2); 4020 init_excp_7x5(env); 4021 env->dcache_line_size = 32; 4022 env->icache_line_size = 32; 4023 /* Allocate hardware IRQ controller */ 4024 ppc6xx_irq_init(env_archcpu(env)); 4025 } 4026 4027 POWERPC_FAMILY(745)(ObjectClass *oc, void *data) 4028 { 4029 DeviceClass *dc = DEVICE_CLASS(oc); 4030 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 4031 4032 dc->desc = "PowerPC 745"; 4033 pcc->init_proc = init_proc_745; 4034 pcc->check_pow = check_pow_hid0; 4035 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 4036 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 4037 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 4038 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 4039 PPC_MEM_SYNC | PPC_MEM_EIEIO | 4040 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_6xx_TLB | 4041 PPC_SEGMENT | PPC_EXTERN; 4042 pcc->msr_mask = (1ull << MSR_POW) | 4043 (1ull << MSR_ILE) | 4044 (1ull << MSR_EE) | 4045 (1ull << MSR_PR) | 4046 (1ull << MSR_FP) | 4047 (1ull << MSR_ME) | 4048 (1ull << MSR_FE0) | 4049 (1ull << MSR_SE) | 4050 (1ull << MSR_DE) | 4051 (1ull << MSR_FE1) | 4052 (1ull << MSR_EP) | 4053 (1ull << MSR_IR) | 4054 (1ull << MSR_DR) | 4055 (1ull << MSR_PMM) | 4056 (1ull << MSR_RI) | 4057 (1ull << MSR_LE); 4058 pcc->mmu_model = POWERPC_MMU_SOFT_6xx; 4059 pcc->excp_model = POWERPC_EXCP_7xx; 4060 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 4061 pcc->bfd_mach = bfd_mach_ppc_750; 4062 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 4063 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 4064 } 4065 4066 static void init_proc_755(CPUPPCState *env) 4067 { 4068 init_proc_745(env); 4069 register_755_sprs(env); 4070 } 4071 4072 POWERPC_FAMILY(755)(ObjectClass *oc, void *data) 4073 { 4074 DeviceClass *dc = DEVICE_CLASS(oc); 4075 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 4076 4077 dc->desc = "PowerPC 755"; 4078 pcc->init_proc = init_proc_755; 4079 pcc->check_pow = check_pow_hid0; 4080 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 4081 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 4082 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 4083 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 4084 PPC_MEM_SYNC | PPC_MEM_EIEIO | 4085 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_6xx_TLB | 4086 PPC_SEGMENT | PPC_EXTERN; 4087 pcc->msr_mask = (1ull << MSR_POW) | 4088 (1ull << MSR_ILE) | 4089 (1ull << MSR_EE) | 4090 (1ull << MSR_PR) | 4091 (1ull << MSR_FP) | 4092 (1ull << MSR_ME) | 4093 (1ull << MSR_FE0) | 4094 (1ull << MSR_SE) | 4095 (1ull << MSR_DE) | 4096 (1ull << MSR_FE1) | 4097 (1ull << MSR_EP) | 4098 (1ull << MSR_IR) | 4099 (1ull << MSR_DR) | 4100 (1ull << MSR_PMM) | 4101 (1ull << MSR_RI) | 4102 (1ull << MSR_LE); 4103 pcc->mmu_model = POWERPC_MMU_SOFT_6xx; 4104 pcc->excp_model = POWERPC_EXCP_7xx; 4105 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 4106 pcc->bfd_mach = bfd_mach_ppc_750; 4107 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 4108 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 4109 } 4110 4111 static void init_proc_7400(CPUPPCState *env) 4112 { 4113 register_non_embedded_sprs(env); 4114 register_sdr1_sprs(env); 4115 register_74xx_sprs(env); 4116 vscr_init(env, 0x00010000); 4117 4118 spr_register(env, SPR_UBAMR, "UBAMR", 4119 &spr_read_ureg, SPR_NOACCESS, 4120 &spr_read_ureg, SPR_NOACCESS, 4121 0x00000000); 4122 4123 spr_register(env, SPR_MSSCR1, "MSSCR1", 4124 SPR_NOACCESS, SPR_NOACCESS, 4125 &spr_read_generic, &spr_write_generic, 4126 0x00000000); 4127 /* Thermal management */ 4128 register_thrm_sprs(env); 4129 /* Memory management */ 4130 register_low_BATs(env); 4131 init_excp_7400(env); 4132 env->dcache_line_size = 32; 4133 env->icache_line_size = 32; 4134 /* Allocate hardware IRQ controller */ 4135 ppc6xx_irq_init(env_archcpu(env)); 4136 } 4137 4138 POWERPC_FAMILY(7400)(ObjectClass *oc, void *data) 4139 { 4140 DeviceClass *dc = DEVICE_CLASS(oc); 4141 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 4142 4143 dc->desc = "PowerPC 7400 (aka G4)"; 4144 pcc->init_proc = init_proc_7400; 4145 pcc->check_pow = check_pow_hid0; 4146 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 4147 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 4148 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 4149 PPC_FLOAT_STFIWX | 4150 PPC_CACHE | PPC_CACHE_ICBI | 4151 PPC_CACHE_DCBA | PPC_CACHE_DCBZ | 4152 PPC_MEM_SYNC | PPC_MEM_EIEIO | 4153 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 4154 PPC_MEM_TLBIA | 4155 PPC_SEGMENT | PPC_EXTERN | 4156 PPC_ALTIVEC; 4157 pcc->msr_mask = (1ull << MSR_VR) | 4158 (1ull << MSR_POW) | 4159 (1ull << MSR_ILE) | 4160 (1ull << MSR_EE) | 4161 (1ull << MSR_PR) | 4162 (1ull << MSR_FP) | 4163 (1ull << MSR_ME) | 4164 (1ull << MSR_FE0) | 4165 (1ull << MSR_SE) | 4166 (1ull << MSR_DE) | 4167 (1ull << MSR_FE1) | 4168 (1ull << MSR_EP) | 4169 (1ull << MSR_IR) | 4170 (1ull << MSR_DR) | 4171 (1ull << MSR_PMM) | 4172 (1ull << MSR_RI) | 4173 (1ull << MSR_LE); 4174 pcc->mmu_model = POWERPC_MMU_32B; 4175 pcc->excp_model = POWERPC_EXCP_74xx; 4176 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 4177 pcc->bfd_mach = bfd_mach_ppc_7400; 4178 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 4179 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 4180 POWERPC_FLAG_BUS_CLK; 4181 } 4182 4183 static void init_proc_7410(CPUPPCState *env) 4184 { 4185 register_non_embedded_sprs(env); 4186 register_sdr1_sprs(env); 4187 register_74xx_sprs(env); 4188 vscr_init(env, 0x00010000); 4189 4190 spr_register(env, SPR_UBAMR, "UBAMR", 4191 &spr_read_ureg, SPR_NOACCESS, 4192 &spr_read_ureg, SPR_NOACCESS, 4193 0x00000000); 4194 /* Thermal management */ 4195 register_thrm_sprs(env); 4196 /* L2PMCR */ 4197 4198 spr_register(env, SPR_L2PMCR, "L2PMCR", 4199 SPR_NOACCESS, SPR_NOACCESS, 4200 &spr_read_generic, &spr_write_generic, 4201 0x00000000); 4202 /* LDSTDB */ 4203 4204 spr_register(env, SPR_LDSTDB, "LDSTDB", 4205 SPR_NOACCESS, SPR_NOACCESS, 4206 &spr_read_generic, &spr_write_generic, 4207 0x00000000); 4208 /* Memory management */ 4209 register_low_BATs(env); 4210 init_excp_7400(env); 4211 env->dcache_line_size = 32; 4212 env->icache_line_size = 32; 4213 /* Allocate hardware IRQ controller */ 4214 ppc6xx_irq_init(env_archcpu(env)); 4215 } 4216 4217 POWERPC_FAMILY(7410)(ObjectClass *oc, void *data) 4218 { 4219 DeviceClass *dc = DEVICE_CLASS(oc); 4220 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 4221 4222 dc->desc = "PowerPC 7410 (aka G4)"; 4223 pcc->init_proc = init_proc_7410; 4224 pcc->check_pow = check_pow_hid0; 4225 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 4226 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 4227 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 4228 PPC_FLOAT_STFIWX | 4229 PPC_CACHE | PPC_CACHE_ICBI | 4230 PPC_CACHE_DCBA | PPC_CACHE_DCBZ | 4231 PPC_MEM_SYNC | PPC_MEM_EIEIO | 4232 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 4233 PPC_MEM_TLBIA | 4234 PPC_SEGMENT | PPC_EXTERN | 4235 PPC_ALTIVEC; 4236 pcc->msr_mask = (1ull << MSR_VR) | 4237 (1ull << MSR_POW) | 4238 (1ull << MSR_ILE) | 4239 (1ull << MSR_EE) | 4240 (1ull << MSR_PR) | 4241 (1ull << MSR_FP) | 4242 (1ull << MSR_ME) | 4243 (1ull << MSR_FE0) | 4244 (1ull << MSR_SE) | 4245 (1ull << MSR_DE) | 4246 (1ull << MSR_FE1) | 4247 (1ull << MSR_EP) | 4248 (1ull << MSR_IR) | 4249 (1ull << MSR_DR) | 4250 (1ull << MSR_PMM) | 4251 (1ull << MSR_RI) | 4252 (1ull << MSR_LE); 4253 pcc->mmu_model = POWERPC_MMU_32B; 4254 pcc->excp_model = POWERPC_EXCP_74xx; 4255 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 4256 pcc->bfd_mach = bfd_mach_ppc_7400; 4257 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 4258 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 4259 POWERPC_FLAG_BUS_CLK; 4260 } 4261 4262 static void init_proc_7440(CPUPPCState *env) 4263 { 4264 register_non_embedded_sprs(env); 4265 register_sdr1_sprs(env); 4266 register_74xx_sprs(env); 4267 vscr_init(env, 0x00010000); 4268 4269 spr_register(env, SPR_UBAMR, "UBAMR", 4270 &spr_read_ureg, SPR_NOACCESS, 4271 &spr_read_ureg, SPR_NOACCESS, 4272 0x00000000); 4273 /* LDSTCR */ 4274 spr_register(env, SPR_LDSTCR, "LDSTCR", 4275 SPR_NOACCESS, SPR_NOACCESS, 4276 &spr_read_generic, &spr_write_generic, 4277 0x00000000); 4278 /* ICTRL */ 4279 spr_register(env, SPR_ICTRL, "ICTRL", 4280 SPR_NOACCESS, SPR_NOACCESS, 4281 &spr_read_generic, &spr_write_generic, 4282 0x00000000); 4283 /* MSSSR0 */ 4284 spr_register(env, SPR_MSSSR0, "MSSSR0", 4285 SPR_NOACCESS, SPR_NOACCESS, 4286 &spr_read_generic, &spr_write_generic, 4287 0x00000000); 4288 /* PMC */ 4289 spr_register(env, SPR_7XX_PMC5, "PMC5", 4290 SPR_NOACCESS, SPR_NOACCESS, 4291 &spr_read_generic, &spr_write_generic, 4292 0x00000000); 4293 4294 spr_register(env, SPR_7XX_UPMC5, "UPMC5", 4295 &spr_read_ureg, SPR_NOACCESS, 4296 &spr_read_ureg, SPR_NOACCESS, 4297 0x00000000); 4298 4299 spr_register(env, SPR_7XX_PMC6, "PMC6", 4300 SPR_NOACCESS, SPR_NOACCESS, 4301 &spr_read_generic, &spr_write_generic, 4302 0x00000000); 4303 4304 spr_register(env, SPR_7XX_UPMC6, "UPMC6", 4305 &spr_read_ureg, SPR_NOACCESS, 4306 &spr_read_ureg, SPR_NOACCESS, 4307 0x00000000); 4308 /* Memory management */ 4309 register_low_BATs(env); 4310 init_excp_7450(env); 4311 env->dcache_line_size = 32; 4312 env->icache_line_size = 32; 4313 /* Allocate hardware IRQ controller */ 4314 ppc6xx_irq_init(env_archcpu(env)); 4315 } 4316 4317 POWERPC_FAMILY(7440)(ObjectClass *oc, void *data) 4318 { 4319 DeviceClass *dc = DEVICE_CLASS(oc); 4320 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 4321 4322 dc->desc = "PowerPC 7440 (aka G4)"; 4323 pcc->init_proc = init_proc_7440; 4324 pcc->check_pow = check_pow_hid0_74xx; 4325 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 4326 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 4327 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 4328 PPC_FLOAT_STFIWX | 4329 PPC_CACHE | PPC_CACHE_ICBI | 4330 PPC_CACHE_DCBA | PPC_CACHE_DCBZ | 4331 PPC_MEM_SYNC | PPC_MEM_EIEIO | 4332 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 4333 PPC_MEM_TLBIA | 4334 PPC_SEGMENT | PPC_EXTERN | 4335 PPC_ALTIVEC; 4336 pcc->msr_mask = (1ull << MSR_VR) | 4337 (1ull << MSR_POW) | 4338 (1ull << MSR_ILE) | 4339 (1ull << MSR_EE) | 4340 (1ull << MSR_PR) | 4341 (1ull << MSR_FP) | 4342 (1ull << MSR_ME) | 4343 (1ull << MSR_FE0) | 4344 (1ull << MSR_SE) | 4345 (1ull << MSR_DE) | 4346 (1ull << MSR_FE1) | 4347 (1ull << MSR_EP) | 4348 (1ull << MSR_IR) | 4349 (1ull << MSR_DR) | 4350 (1ull << MSR_PMM) | 4351 (1ull << MSR_RI) | 4352 (1ull << MSR_LE); 4353 pcc->mmu_model = POWERPC_MMU_32B; 4354 pcc->excp_model = POWERPC_EXCP_74xx; 4355 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 4356 pcc->bfd_mach = bfd_mach_ppc_7400; 4357 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 4358 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 4359 POWERPC_FLAG_BUS_CLK; 4360 } 4361 4362 static void init_proc_7450(CPUPPCState *env) 4363 { 4364 register_non_embedded_sprs(env); 4365 register_sdr1_sprs(env); 4366 register_74xx_sprs(env); 4367 vscr_init(env, 0x00010000); 4368 /* Level 3 cache control */ 4369 register_l3_ctrl(env); 4370 /* L3ITCR1 */ 4371 spr_register(env, SPR_L3ITCR1, "L3ITCR1", 4372 SPR_NOACCESS, SPR_NOACCESS, 4373 &spr_read_generic, &spr_write_generic, 4374 0x00000000); 4375 /* L3ITCR2 */ 4376 spr_register(env, SPR_L3ITCR2, "L3ITCR2", 4377 SPR_NOACCESS, SPR_NOACCESS, 4378 &spr_read_generic, &spr_write_generic, 4379 0x00000000); 4380 /* L3ITCR3 */ 4381 spr_register(env, SPR_L3ITCR3, "L3ITCR3", 4382 SPR_NOACCESS, SPR_NOACCESS, 4383 &spr_read_generic, &spr_write_generic, 4384 0x00000000); 4385 /* L3OHCR */ 4386 spr_register(env, SPR_L3OHCR, "L3OHCR", 4387 SPR_NOACCESS, SPR_NOACCESS, 4388 &spr_read_generic, &spr_write_generic, 4389 0x00000000); 4390 4391 spr_register(env, SPR_UBAMR, "UBAMR", 4392 &spr_read_ureg, SPR_NOACCESS, 4393 &spr_read_ureg, SPR_NOACCESS, 4394 0x00000000); 4395 /* LDSTCR */ 4396 spr_register(env, SPR_LDSTCR, "LDSTCR", 4397 SPR_NOACCESS, SPR_NOACCESS, 4398 &spr_read_generic, &spr_write_generic, 4399 0x00000000); 4400 /* ICTRL */ 4401 spr_register(env, SPR_ICTRL, "ICTRL", 4402 SPR_NOACCESS, SPR_NOACCESS, 4403 &spr_read_generic, &spr_write_generic, 4404 0x00000000); 4405 /* MSSSR0 */ 4406 spr_register(env, SPR_MSSSR0, "MSSSR0", 4407 SPR_NOACCESS, SPR_NOACCESS, 4408 &spr_read_generic, &spr_write_generic, 4409 0x00000000); 4410 /* PMC */ 4411 spr_register(env, SPR_7XX_PMC5, "PMC5", 4412 SPR_NOACCESS, SPR_NOACCESS, 4413 &spr_read_generic, &spr_write_generic, 4414 0x00000000); 4415 4416 spr_register(env, SPR_7XX_UPMC5, "UPMC5", 4417 &spr_read_ureg, SPR_NOACCESS, 4418 &spr_read_ureg, SPR_NOACCESS, 4419 0x00000000); 4420 4421 spr_register(env, SPR_7XX_PMC6, "PMC6", 4422 SPR_NOACCESS, SPR_NOACCESS, 4423 &spr_read_generic, &spr_write_generic, 4424 0x00000000); 4425 4426 spr_register(env, SPR_7XX_UPMC6, "UPMC6", 4427 &spr_read_ureg, SPR_NOACCESS, 4428 &spr_read_ureg, SPR_NOACCESS, 4429 0x00000000); 4430 /* Memory management */ 4431 register_low_BATs(env); 4432 init_excp_7450(env); 4433 env->dcache_line_size = 32; 4434 env->icache_line_size = 32; 4435 /* Allocate hardware IRQ controller */ 4436 ppc6xx_irq_init(env_archcpu(env)); 4437 } 4438 4439 POWERPC_FAMILY(7450)(ObjectClass *oc, void *data) 4440 { 4441 DeviceClass *dc = DEVICE_CLASS(oc); 4442 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 4443 4444 dc->desc = "PowerPC 7450 (aka G4)"; 4445 pcc->init_proc = init_proc_7450; 4446 pcc->check_pow = check_pow_hid0_74xx; 4447 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 4448 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 4449 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 4450 PPC_FLOAT_STFIWX | 4451 PPC_CACHE | PPC_CACHE_ICBI | 4452 PPC_CACHE_DCBA | PPC_CACHE_DCBZ | 4453 PPC_MEM_SYNC | PPC_MEM_EIEIO | 4454 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 4455 PPC_MEM_TLBIA | 4456 PPC_SEGMENT | PPC_EXTERN | 4457 PPC_ALTIVEC; 4458 pcc->msr_mask = (1ull << MSR_VR) | 4459 (1ull << MSR_POW) | 4460 (1ull << MSR_ILE) | 4461 (1ull << MSR_EE) | 4462 (1ull << MSR_PR) | 4463 (1ull << MSR_FP) | 4464 (1ull << MSR_ME) | 4465 (1ull << MSR_FE0) | 4466 (1ull << MSR_SE) | 4467 (1ull << MSR_DE) | 4468 (1ull << MSR_FE1) | 4469 (1ull << MSR_EP) | 4470 (1ull << MSR_IR) | 4471 (1ull << MSR_DR) | 4472 (1ull << MSR_PMM) | 4473 (1ull << MSR_RI) | 4474 (1ull << MSR_LE); 4475 pcc->mmu_model = POWERPC_MMU_32B; 4476 pcc->excp_model = POWERPC_EXCP_74xx; 4477 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 4478 pcc->bfd_mach = bfd_mach_ppc_7400; 4479 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 4480 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 4481 POWERPC_FLAG_BUS_CLK; 4482 } 4483 4484 static void init_proc_7445(CPUPPCState *env) 4485 { 4486 register_non_embedded_sprs(env); 4487 register_sdr1_sprs(env); 4488 register_74xx_sprs(env); 4489 vscr_init(env, 0x00010000); 4490 /* LDSTCR */ 4491 spr_register(env, SPR_LDSTCR, "LDSTCR", 4492 SPR_NOACCESS, SPR_NOACCESS, 4493 &spr_read_generic, &spr_write_generic, 4494 0x00000000); 4495 /* ICTRL */ 4496 spr_register(env, SPR_ICTRL, "ICTRL", 4497 SPR_NOACCESS, SPR_NOACCESS, 4498 &spr_read_generic, &spr_write_generic, 4499 0x00000000); 4500 /* MSSSR0 */ 4501 spr_register(env, SPR_MSSSR0, "MSSSR0", 4502 SPR_NOACCESS, SPR_NOACCESS, 4503 &spr_read_generic, &spr_write_generic, 4504 0x00000000); 4505 /* PMC */ 4506 spr_register(env, SPR_7XX_PMC5, "PMC5", 4507 SPR_NOACCESS, SPR_NOACCESS, 4508 &spr_read_generic, &spr_write_generic, 4509 0x00000000); 4510 4511 spr_register(env, SPR_7XX_UPMC5, "UPMC5", 4512 &spr_read_ureg, SPR_NOACCESS, 4513 &spr_read_ureg, SPR_NOACCESS, 4514 0x00000000); 4515 4516 spr_register(env, SPR_7XX_PMC6, "PMC6", 4517 SPR_NOACCESS, SPR_NOACCESS, 4518 &spr_read_generic, &spr_write_generic, 4519 0x00000000); 4520 4521 spr_register(env, SPR_7XX_UPMC6, "UPMC6", 4522 &spr_read_ureg, SPR_NOACCESS, 4523 &spr_read_ureg, SPR_NOACCESS, 4524 0x00000000); 4525 /* SPRGs */ 4526 spr_register(env, SPR_SPRG4, "SPRG4", 4527 SPR_NOACCESS, SPR_NOACCESS, 4528 &spr_read_generic, &spr_write_generic, 4529 0x00000000); 4530 spr_register(env, SPR_USPRG4, "USPRG4", 4531 &spr_read_ureg, SPR_NOACCESS, 4532 &spr_read_ureg, SPR_NOACCESS, 4533 0x00000000); 4534 spr_register(env, SPR_SPRG5, "SPRG5", 4535 SPR_NOACCESS, SPR_NOACCESS, 4536 &spr_read_generic, &spr_write_generic, 4537 0x00000000); 4538 spr_register(env, SPR_USPRG5, "USPRG5", 4539 &spr_read_ureg, SPR_NOACCESS, 4540 &spr_read_ureg, SPR_NOACCESS, 4541 0x00000000); 4542 spr_register(env, SPR_SPRG6, "SPRG6", 4543 SPR_NOACCESS, SPR_NOACCESS, 4544 &spr_read_generic, &spr_write_generic, 4545 0x00000000); 4546 spr_register(env, SPR_USPRG6, "USPRG6", 4547 &spr_read_ureg, SPR_NOACCESS, 4548 &spr_read_ureg, SPR_NOACCESS, 4549 0x00000000); 4550 spr_register(env, SPR_SPRG7, "SPRG7", 4551 SPR_NOACCESS, SPR_NOACCESS, 4552 &spr_read_generic, &spr_write_generic, 4553 0x00000000); 4554 spr_register(env, SPR_USPRG7, "USPRG7", 4555 &spr_read_ureg, SPR_NOACCESS, 4556 &spr_read_ureg, SPR_NOACCESS, 4557 0x00000000); 4558 /* Memory management */ 4559 register_low_BATs(env); 4560 register_high_BATs(env); 4561 init_excp_7450(env); 4562 env->dcache_line_size = 32; 4563 env->icache_line_size = 32; 4564 /* Allocate hardware IRQ controller */ 4565 ppc6xx_irq_init(env_archcpu(env)); 4566 } 4567 4568 POWERPC_FAMILY(7445)(ObjectClass *oc, void *data) 4569 { 4570 DeviceClass *dc = DEVICE_CLASS(oc); 4571 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 4572 4573 dc->desc = "PowerPC 7445 (aka G4)"; 4574 pcc->init_proc = init_proc_7445; 4575 pcc->check_pow = check_pow_hid0_74xx; 4576 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 4577 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 4578 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 4579 PPC_FLOAT_STFIWX | 4580 PPC_CACHE | PPC_CACHE_ICBI | 4581 PPC_CACHE_DCBA | PPC_CACHE_DCBZ | 4582 PPC_MEM_SYNC | PPC_MEM_EIEIO | 4583 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 4584 PPC_MEM_TLBIA | 4585 PPC_SEGMENT | PPC_EXTERN | 4586 PPC_ALTIVEC; 4587 pcc->msr_mask = (1ull << MSR_VR) | 4588 (1ull << MSR_POW) | 4589 (1ull << MSR_ILE) | 4590 (1ull << MSR_EE) | 4591 (1ull << MSR_PR) | 4592 (1ull << MSR_FP) | 4593 (1ull << MSR_ME) | 4594 (1ull << MSR_FE0) | 4595 (1ull << MSR_SE) | 4596 (1ull << MSR_DE) | 4597 (1ull << MSR_FE1) | 4598 (1ull << MSR_EP) | 4599 (1ull << MSR_IR) | 4600 (1ull << MSR_DR) | 4601 (1ull << MSR_PMM) | 4602 (1ull << MSR_RI) | 4603 (1ull << MSR_LE); 4604 pcc->mmu_model = POWERPC_MMU_32B; 4605 pcc->excp_model = POWERPC_EXCP_74xx; 4606 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 4607 pcc->bfd_mach = bfd_mach_ppc_7400; 4608 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 4609 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 4610 POWERPC_FLAG_BUS_CLK; 4611 } 4612 4613 static void init_proc_7455(CPUPPCState *env) 4614 { 4615 register_non_embedded_sprs(env); 4616 register_sdr1_sprs(env); 4617 register_74xx_sprs(env); 4618 vscr_init(env, 0x00010000); 4619 /* Level 3 cache control */ 4620 register_l3_ctrl(env); 4621 /* LDSTCR */ 4622 spr_register(env, SPR_LDSTCR, "LDSTCR", 4623 SPR_NOACCESS, SPR_NOACCESS, 4624 &spr_read_generic, &spr_write_generic, 4625 0x00000000); 4626 /* ICTRL */ 4627 spr_register(env, SPR_ICTRL, "ICTRL", 4628 SPR_NOACCESS, SPR_NOACCESS, 4629 &spr_read_generic, &spr_write_generic, 4630 0x00000000); 4631 /* MSSSR0 */ 4632 spr_register(env, SPR_MSSSR0, "MSSSR0", 4633 SPR_NOACCESS, SPR_NOACCESS, 4634 &spr_read_generic, &spr_write_generic, 4635 0x00000000); 4636 /* PMC */ 4637 spr_register(env, SPR_7XX_PMC5, "PMC5", 4638 SPR_NOACCESS, SPR_NOACCESS, 4639 &spr_read_generic, &spr_write_generic, 4640 0x00000000); 4641 4642 spr_register(env, SPR_7XX_UPMC5, "UPMC5", 4643 &spr_read_ureg, SPR_NOACCESS, 4644 &spr_read_ureg, SPR_NOACCESS, 4645 0x00000000); 4646 4647 spr_register(env, SPR_7XX_PMC6, "PMC6", 4648 SPR_NOACCESS, SPR_NOACCESS, 4649 &spr_read_generic, &spr_write_generic, 4650 0x00000000); 4651 4652 spr_register(env, SPR_7XX_UPMC6, "UPMC6", 4653 &spr_read_ureg, SPR_NOACCESS, 4654 &spr_read_ureg, SPR_NOACCESS, 4655 0x00000000); 4656 /* SPRGs */ 4657 spr_register(env, SPR_SPRG4, "SPRG4", 4658 SPR_NOACCESS, SPR_NOACCESS, 4659 &spr_read_generic, &spr_write_generic, 4660 0x00000000); 4661 spr_register(env, SPR_USPRG4, "USPRG4", 4662 &spr_read_ureg, SPR_NOACCESS, 4663 &spr_read_ureg, SPR_NOACCESS, 4664 0x00000000); 4665 spr_register(env, SPR_SPRG5, "SPRG5", 4666 SPR_NOACCESS, SPR_NOACCESS, 4667 &spr_read_generic, &spr_write_generic, 4668 0x00000000); 4669 spr_register(env, SPR_USPRG5, "USPRG5", 4670 &spr_read_ureg, SPR_NOACCESS, 4671 &spr_read_ureg, SPR_NOACCESS, 4672 0x00000000); 4673 spr_register(env, SPR_SPRG6, "SPRG6", 4674 SPR_NOACCESS, SPR_NOACCESS, 4675 &spr_read_generic, &spr_write_generic, 4676 0x00000000); 4677 spr_register(env, SPR_USPRG6, "USPRG6", 4678 &spr_read_ureg, SPR_NOACCESS, 4679 &spr_read_ureg, SPR_NOACCESS, 4680 0x00000000); 4681 spr_register(env, SPR_SPRG7, "SPRG7", 4682 SPR_NOACCESS, SPR_NOACCESS, 4683 &spr_read_generic, &spr_write_generic, 4684 0x00000000); 4685 spr_register(env, SPR_USPRG7, "USPRG7", 4686 &spr_read_ureg, SPR_NOACCESS, 4687 &spr_read_ureg, SPR_NOACCESS, 4688 0x00000000); 4689 /* Memory management */ 4690 register_low_BATs(env); 4691 register_high_BATs(env); 4692 init_excp_7450(env); 4693 env->dcache_line_size = 32; 4694 env->icache_line_size = 32; 4695 /* Allocate hardware IRQ controller */ 4696 ppc6xx_irq_init(env_archcpu(env)); 4697 } 4698 4699 POWERPC_FAMILY(7455)(ObjectClass *oc, void *data) 4700 { 4701 DeviceClass *dc = DEVICE_CLASS(oc); 4702 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 4703 4704 dc->desc = "PowerPC 7455 (aka G4)"; 4705 pcc->init_proc = init_proc_7455; 4706 pcc->check_pow = check_pow_hid0_74xx; 4707 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 4708 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 4709 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 4710 PPC_FLOAT_STFIWX | 4711 PPC_CACHE | PPC_CACHE_ICBI | 4712 PPC_CACHE_DCBA | PPC_CACHE_DCBZ | 4713 PPC_MEM_SYNC | PPC_MEM_EIEIO | 4714 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 4715 PPC_MEM_TLBIA | 4716 PPC_SEGMENT | PPC_EXTERN | 4717 PPC_ALTIVEC; 4718 pcc->msr_mask = (1ull << MSR_VR) | 4719 (1ull << MSR_POW) | 4720 (1ull << MSR_ILE) | 4721 (1ull << MSR_EE) | 4722 (1ull << MSR_PR) | 4723 (1ull << MSR_FP) | 4724 (1ull << MSR_ME) | 4725 (1ull << MSR_FE0) | 4726 (1ull << MSR_SE) | 4727 (1ull << MSR_DE) | 4728 (1ull << MSR_FE1) | 4729 (1ull << MSR_EP) | 4730 (1ull << MSR_IR) | 4731 (1ull << MSR_DR) | 4732 (1ull << MSR_PMM) | 4733 (1ull << MSR_RI) | 4734 (1ull << MSR_LE); 4735 pcc->mmu_model = POWERPC_MMU_32B; 4736 pcc->excp_model = POWERPC_EXCP_74xx; 4737 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 4738 pcc->bfd_mach = bfd_mach_ppc_7400; 4739 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 4740 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 4741 POWERPC_FLAG_BUS_CLK; 4742 } 4743 4744 static void init_proc_7457(CPUPPCState *env) 4745 { 4746 register_non_embedded_sprs(env); 4747 register_sdr1_sprs(env); 4748 register_74xx_sprs(env); 4749 vscr_init(env, 0x00010000); 4750 /* Level 3 cache control */ 4751 register_l3_ctrl(env); 4752 /* L3ITCR1 */ 4753 spr_register(env, SPR_L3ITCR1, "L3ITCR1", 4754 SPR_NOACCESS, SPR_NOACCESS, 4755 &spr_read_generic, &spr_write_generic, 4756 0x00000000); 4757 /* L3ITCR2 */ 4758 spr_register(env, SPR_L3ITCR2, "L3ITCR2", 4759 SPR_NOACCESS, SPR_NOACCESS, 4760 &spr_read_generic, &spr_write_generic, 4761 0x00000000); 4762 /* L3ITCR3 */ 4763 spr_register(env, SPR_L3ITCR3, "L3ITCR3", 4764 SPR_NOACCESS, SPR_NOACCESS, 4765 &spr_read_generic, &spr_write_generic, 4766 0x00000000); 4767 /* L3OHCR */ 4768 spr_register(env, SPR_L3OHCR, "L3OHCR", 4769 SPR_NOACCESS, SPR_NOACCESS, 4770 &spr_read_generic, &spr_write_generic, 4771 0x00000000); 4772 /* LDSTCR */ 4773 spr_register(env, SPR_LDSTCR, "LDSTCR", 4774 SPR_NOACCESS, SPR_NOACCESS, 4775 &spr_read_generic, &spr_write_generic, 4776 0x00000000); 4777 /* ICTRL */ 4778 spr_register(env, SPR_ICTRL, "ICTRL", 4779 SPR_NOACCESS, SPR_NOACCESS, 4780 &spr_read_generic, &spr_write_generic, 4781 0x00000000); 4782 /* MSSSR0 */ 4783 spr_register(env, SPR_MSSSR0, "MSSSR0", 4784 SPR_NOACCESS, SPR_NOACCESS, 4785 &spr_read_generic, &spr_write_generic, 4786 0x00000000); 4787 /* PMC */ 4788 spr_register(env, SPR_7XX_PMC5, "PMC5", 4789 SPR_NOACCESS, SPR_NOACCESS, 4790 &spr_read_generic, &spr_write_generic, 4791 0x00000000); 4792 4793 spr_register(env, SPR_7XX_UPMC5, "UPMC5", 4794 &spr_read_ureg, SPR_NOACCESS, 4795 &spr_read_ureg, SPR_NOACCESS, 4796 0x00000000); 4797 4798 spr_register(env, SPR_7XX_PMC6, "PMC6", 4799 SPR_NOACCESS, SPR_NOACCESS, 4800 &spr_read_generic, &spr_write_generic, 4801 0x00000000); 4802 4803 spr_register(env, SPR_7XX_UPMC6, "UPMC6", 4804 &spr_read_ureg, SPR_NOACCESS, 4805 &spr_read_ureg, SPR_NOACCESS, 4806 0x00000000); 4807 /* SPRGs */ 4808 spr_register(env, SPR_SPRG4, "SPRG4", 4809 SPR_NOACCESS, SPR_NOACCESS, 4810 &spr_read_generic, &spr_write_generic, 4811 0x00000000); 4812 spr_register(env, SPR_USPRG4, "USPRG4", 4813 &spr_read_ureg, SPR_NOACCESS, 4814 &spr_read_ureg, SPR_NOACCESS, 4815 0x00000000); 4816 spr_register(env, SPR_SPRG5, "SPRG5", 4817 SPR_NOACCESS, SPR_NOACCESS, 4818 &spr_read_generic, &spr_write_generic, 4819 0x00000000); 4820 spr_register(env, SPR_USPRG5, "USPRG5", 4821 &spr_read_ureg, SPR_NOACCESS, 4822 &spr_read_ureg, SPR_NOACCESS, 4823 0x00000000); 4824 spr_register(env, SPR_SPRG6, "SPRG6", 4825 SPR_NOACCESS, SPR_NOACCESS, 4826 &spr_read_generic, &spr_write_generic, 4827 0x00000000); 4828 spr_register(env, SPR_USPRG6, "USPRG6", 4829 &spr_read_ureg, SPR_NOACCESS, 4830 &spr_read_ureg, SPR_NOACCESS, 4831 0x00000000); 4832 spr_register(env, SPR_SPRG7, "SPRG7", 4833 SPR_NOACCESS, SPR_NOACCESS, 4834 &spr_read_generic, &spr_write_generic, 4835 0x00000000); 4836 spr_register(env, SPR_USPRG7, "USPRG7", 4837 &spr_read_ureg, SPR_NOACCESS, 4838 &spr_read_ureg, SPR_NOACCESS, 4839 0x00000000); 4840 /* Memory management */ 4841 register_low_BATs(env); 4842 register_high_BATs(env); 4843 init_excp_7450(env); 4844 env->dcache_line_size = 32; 4845 env->icache_line_size = 32; 4846 /* Allocate hardware IRQ controller */ 4847 ppc6xx_irq_init(env_archcpu(env)); 4848 } 4849 4850 POWERPC_FAMILY(7457)(ObjectClass *oc, void *data) 4851 { 4852 DeviceClass *dc = DEVICE_CLASS(oc); 4853 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 4854 4855 dc->desc = "PowerPC 7457 (aka G4)"; 4856 pcc->init_proc = init_proc_7457; 4857 pcc->check_pow = check_pow_hid0_74xx; 4858 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 4859 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 4860 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 4861 PPC_FLOAT_STFIWX | 4862 PPC_CACHE | PPC_CACHE_ICBI | 4863 PPC_CACHE_DCBA | PPC_CACHE_DCBZ | 4864 PPC_MEM_SYNC | PPC_MEM_EIEIO | 4865 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 4866 PPC_MEM_TLBIA | 4867 PPC_SEGMENT | PPC_EXTERN | 4868 PPC_ALTIVEC; 4869 pcc->msr_mask = (1ull << MSR_VR) | 4870 (1ull << MSR_POW) | 4871 (1ull << MSR_ILE) | 4872 (1ull << MSR_EE) | 4873 (1ull << MSR_PR) | 4874 (1ull << MSR_FP) | 4875 (1ull << MSR_ME) | 4876 (1ull << MSR_FE0) | 4877 (1ull << MSR_SE) | 4878 (1ull << MSR_DE) | 4879 (1ull << MSR_FE1) | 4880 (1ull << MSR_EP) | 4881 (1ull << MSR_IR) | 4882 (1ull << MSR_DR) | 4883 (1ull << MSR_PMM) | 4884 (1ull << MSR_RI) | 4885 (1ull << MSR_LE); 4886 pcc->mmu_model = POWERPC_MMU_32B; 4887 pcc->excp_model = POWERPC_EXCP_74xx; 4888 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 4889 pcc->bfd_mach = bfd_mach_ppc_7400; 4890 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 4891 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 4892 POWERPC_FLAG_BUS_CLK; 4893 } 4894 4895 static void init_proc_e600(CPUPPCState *env) 4896 { 4897 register_non_embedded_sprs(env); 4898 register_sdr1_sprs(env); 4899 register_74xx_sprs(env); 4900 vscr_init(env, 0x00010000); 4901 4902 spr_register(env, SPR_UBAMR, "UBAMR", 4903 &spr_read_ureg, SPR_NOACCESS, 4904 &spr_read_ureg, SPR_NOACCESS, 4905 0x00000000); 4906 4907 spr_register(env, SPR_LDSTCR, "LDSTCR", 4908 SPR_NOACCESS, SPR_NOACCESS, 4909 &spr_read_generic, &spr_write_generic, 4910 0x00000000); 4911 4912 spr_register(env, SPR_ICTRL, "ICTRL", 4913 SPR_NOACCESS, SPR_NOACCESS, 4914 &spr_read_generic, &spr_write_generic, 4915 0x00000000); 4916 4917 spr_register(env, SPR_MSSSR0, "MSSSR0", 4918 SPR_NOACCESS, SPR_NOACCESS, 4919 &spr_read_generic, &spr_write_generic, 4920 0x00000000); 4921 4922 spr_register(env, SPR_7XX_PMC5, "PMC5", 4923 SPR_NOACCESS, SPR_NOACCESS, 4924 &spr_read_generic, &spr_write_generic, 4925 0x00000000); 4926 4927 spr_register(env, SPR_7XX_UPMC5, "UPMC5", 4928 &spr_read_ureg, SPR_NOACCESS, 4929 &spr_read_ureg, SPR_NOACCESS, 4930 0x00000000); 4931 4932 spr_register(env, SPR_7XX_PMC6, "PMC6", 4933 SPR_NOACCESS, SPR_NOACCESS, 4934 &spr_read_generic, &spr_write_generic, 4935 0x00000000); 4936 4937 spr_register(env, SPR_7XX_UPMC6, "UPMC6", 4938 &spr_read_ureg, SPR_NOACCESS, 4939 &spr_read_ureg, SPR_NOACCESS, 4940 0x00000000); 4941 /* SPRGs */ 4942 spr_register(env, SPR_SPRG4, "SPRG4", 4943 SPR_NOACCESS, SPR_NOACCESS, 4944 &spr_read_generic, &spr_write_generic, 4945 0x00000000); 4946 spr_register(env, SPR_USPRG4, "USPRG4", 4947 &spr_read_ureg, SPR_NOACCESS, 4948 &spr_read_ureg, SPR_NOACCESS, 4949 0x00000000); 4950 spr_register(env, SPR_SPRG5, "SPRG5", 4951 SPR_NOACCESS, SPR_NOACCESS, 4952 &spr_read_generic, &spr_write_generic, 4953 0x00000000); 4954 spr_register(env, SPR_USPRG5, "USPRG5", 4955 &spr_read_ureg, SPR_NOACCESS, 4956 &spr_read_ureg, SPR_NOACCESS, 4957 0x00000000); 4958 spr_register(env, SPR_SPRG6, "SPRG6", 4959 SPR_NOACCESS, SPR_NOACCESS, 4960 &spr_read_generic, &spr_write_generic, 4961 0x00000000); 4962 spr_register(env, SPR_USPRG6, "USPRG6", 4963 &spr_read_ureg, SPR_NOACCESS, 4964 &spr_read_ureg, SPR_NOACCESS, 4965 0x00000000); 4966 spr_register(env, SPR_SPRG7, "SPRG7", 4967 SPR_NOACCESS, SPR_NOACCESS, 4968 &spr_read_generic, &spr_write_generic, 4969 0x00000000); 4970 spr_register(env, SPR_USPRG7, "USPRG7", 4971 &spr_read_ureg, SPR_NOACCESS, 4972 &spr_read_ureg, SPR_NOACCESS, 4973 0x00000000); 4974 /* Memory management */ 4975 register_low_BATs(env); 4976 register_high_BATs(env); 4977 init_excp_7450(env); 4978 env->dcache_line_size = 32; 4979 env->icache_line_size = 32; 4980 /* Allocate hardware IRQ controller */ 4981 ppc6xx_irq_init(env_archcpu(env)); 4982 } 4983 4984 POWERPC_FAMILY(e600)(ObjectClass *oc, void *data) 4985 { 4986 DeviceClass *dc = DEVICE_CLASS(oc); 4987 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 4988 4989 dc->desc = "PowerPC e600"; 4990 pcc->init_proc = init_proc_e600; 4991 pcc->check_pow = check_pow_hid0_74xx; 4992 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 4993 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 4994 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 4995 PPC_FLOAT_STFIWX | 4996 PPC_CACHE | PPC_CACHE_ICBI | 4997 PPC_CACHE_DCBA | PPC_CACHE_DCBZ | 4998 PPC_MEM_SYNC | PPC_MEM_EIEIO | 4999 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 5000 PPC_MEM_TLBIA | 5001 PPC_SEGMENT | PPC_EXTERN | 5002 PPC_ALTIVEC; 5003 pcc->insns_flags2 = PPC_NONE; 5004 pcc->msr_mask = (1ull << MSR_VR) | 5005 (1ull << MSR_POW) | 5006 (1ull << MSR_ILE) | 5007 (1ull << MSR_EE) | 5008 (1ull << MSR_PR) | 5009 (1ull << MSR_FP) | 5010 (1ull << MSR_ME) | 5011 (1ull << MSR_FE0) | 5012 (1ull << MSR_SE) | 5013 (1ull << MSR_DE) | 5014 (1ull << MSR_FE1) | 5015 (1ull << MSR_EP) | 5016 (1ull << MSR_IR) | 5017 (1ull << MSR_DR) | 5018 (1ull << MSR_PMM) | 5019 (1ull << MSR_RI) | 5020 (1ull << MSR_LE); 5021 pcc->mmu_model = POWERPC_MMU_32B; 5022 pcc->excp_model = POWERPC_EXCP_74xx; 5023 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 5024 pcc->bfd_mach = bfd_mach_ppc_7400; 5025 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 5026 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 5027 POWERPC_FLAG_BUS_CLK; 5028 } 5029 5030 #if defined(TARGET_PPC64) 5031 #if defined(CONFIG_USER_ONLY) 5032 #define POWERPC970_HID5_INIT 0x00000080 5033 #else 5034 #define POWERPC970_HID5_INIT 0x00000000 5035 #endif 5036 5037 static int check_pow_970(CPUPPCState *env) 5038 { 5039 if (env->spr[SPR_HID0] & (HID0_DEEPNAP | HID0_DOZE | HID0_NAP)) { 5040 return 1; 5041 } 5042 5043 return 0; 5044 } 5045 5046 static void register_970_hid_sprs(CPUPPCState *env) 5047 { 5048 /* Hardware implementation registers */ 5049 spr_register(env, SPR_HID0, "HID0", 5050 SPR_NOACCESS, SPR_NOACCESS, 5051 &spr_read_generic, &spr_write_clear, 5052 0x60000000); 5053 spr_register(env, SPR_HID1, "HID1", 5054 SPR_NOACCESS, SPR_NOACCESS, 5055 &spr_read_generic, &spr_write_generic, 5056 0x00000000); 5057 spr_register(env, SPR_970_HID5, "HID5", 5058 SPR_NOACCESS, SPR_NOACCESS, 5059 &spr_read_generic, &spr_write_generic, 5060 POWERPC970_HID5_INIT); 5061 } 5062 5063 static void register_970_hior_sprs(CPUPPCState *env) 5064 { 5065 spr_register(env, SPR_HIOR, "SPR_HIOR", 5066 SPR_NOACCESS, SPR_NOACCESS, 5067 &spr_read_hior, &spr_write_hior, 5068 0x00000000); 5069 } 5070 5071 static void register_book3s_ctrl_sprs(CPUPPCState *env) 5072 { 5073 spr_register(env, SPR_CTRL, "SPR_CTRL", 5074 SPR_NOACCESS, SPR_NOACCESS, 5075 SPR_NOACCESS, &spr_write_CTRL, 5076 0x00000000); 5077 spr_register(env, SPR_UCTRL, "SPR_UCTRL", 5078 &spr_read_ureg, SPR_NOACCESS, 5079 &spr_read_ureg, SPR_NOACCESS, 5080 0x00000000); 5081 } 5082 5083 static void register_book3s_altivec_sprs(CPUPPCState *env) 5084 { 5085 if (!(env->insns_flags & PPC_ALTIVEC)) { 5086 return; 5087 } 5088 5089 spr_register_kvm(env, SPR_VRSAVE, "VRSAVE", 5090 &spr_read_generic, &spr_write_generic32, 5091 &spr_read_generic, &spr_write_generic32, 5092 KVM_REG_PPC_VRSAVE, 0x00000000); 5093 5094 } 5095 5096 static void register_book3s_dbg_sprs(CPUPPCState *env) 5097 { 5098 /* 5099 * TODO: different specs define different scopes for these, 5100 * will have to address this: 5101 * 970: super/write and super/read 5102 * powerisa 2.03..2.04: hypv/write and super/read. 5103 * powerisa 2.05 and newer: hypv/write and hypv/read. 5104 */ 5105 spr_register_kvm(env, SPR_DABR, "DABR", 5106 SPR_NOACCESS, SPR_NOACCESS, 5107 &spr_read_generic, &spr_write_generic, 5108 KVM_REG_PPC_DABR, 0x00000000); 5109 spr_register_kvm(env, SPR_DABRX, "DABRX", 5110 SPR_NOACCESS, SPR_NOACCESS, 5111 &spr_read_generic, &spr_write_generic, 5112 KVM_REG_PPC_DABRX, 0x00000000); 5113 } 5114 5115 static void register_book3s_207_dbg_sprs(CPUPPCState *env) 5116 { 5117 spr_register_kvm_hv(env, SPR_DAWR0, "DAWR0", 5118 SPR_NOACCESS, SPR_NOACCESS, 5119 SPR_NOACCESS, SPR_NOACCESS, 5120 &spr_read_generic, &spr_write_generic, 5121 KVM_REG_PPC_DAWR, 0x00000000); 5122 spr_register_kvm_hv(env, SPR_DAWRX0, "DAWRX0", 5123 SPR_NOACCESS, SPR_NOACCESS, 5124 SPR_NOACCESS, SPR_NOACCESS, 5125 &spr_read_generic, &spr_write_generic32, 5126 KVM_REG_PPC_DAWRX, 0x00000000); 5127 spr_register_kvm_hv(env, SPR_CIABR, "CIABR", 5128 SPR_NOACCESS, SPR_NOACCESS, 5129 SPR_NOACCESS, SPR_NOACCESS, 5130 &spr_read_generic, &spr_write_generic, 5131 KVM_REG_PPC_CIABR, 0x00000000); 5132 } 5133 5134 static void register_970_dbg_sprs(CPUPPCState *env) 5135 { 5136 /* Breakpoints */ 5137 spr_register(env, SPR_IABR, "IABR", 5138 SPR_NOACCESS, SPR_NOACCESS, 5139 &spr_read_generic, &spr_write_generic, 5140 0x00000000); 5141 } 5142 5143 static void register_book3s_pmu_sup_sprs(CPUPPCState *env) 5144 { 5145 spr_register_kvm(env, SPR_POWER_MMCR0, "MMCR0", 5146 SPR_NOACCESS, SPR_NOACCESS, 5147 &spr_read_generic, &spr_write_MMCR0, 5148 KVM_REG_PPC_MMCR0, 0x80000000); 5149 spr_register_kvm(env, SPR_POWER_MMCR1, "MMCR1", 5150 SPR_NOACCESS, SPR_NOACCESS, 5151 &spr_read_generic, &spr_write_MMCR1, 5152 KVM_REG_PPC_MMCR1, 0x00000000); 5153 spr_register_kvm(env, SPR_POWER_MMCRA, "MMCRA", 5154 SPR_NOACCESS, SPR_NOACCESS, 5155 &spr_read_generic, &spr_write_generic, 5156 KVM_REG_PPC_MMCRA, 0x00000000); 5157 spr_register_kvm(env, SPR_POWER_PMC1, "PMC1", 5158 SPR_NOACCESS, SPR_NOACCESS, 5159 &spr_read_PMC, &spr_write_PMC, 5160 KVM_REG_PPC_PMC1, 0x00000000); 5161 spr_register_kvm(env, SPR_POWER_PMC2, "PMC2", 5162 SPR_NOACCESS, SPR_NOACCESS, 5163 &spr_read_PMC, &spr_write_PMC, 5164 KVM_REG_PPC_PMC2, 0x00000000); 5165 spr_register_kvm(env, SPR_POWER_PMC3, "PMC3", 5166 SPR_NOACCESS, SPR_NOACCESS, 5167 &spr_read_PMC, &spr_write_PMC, 5168 KVM_REG_PPC_PMC3, 0x00000000); 5169 spr_register_kvm(env, SPR_POWER_PMC4, "PMC4", 5170 SPR_NOACCESS, SPR_NOACCESS, 5171 &spr_read_PMC, &spr_write_PMC, 5172 KVM_REG_PPC_PMC4, 0x00000000); 5173 spr_register_kvm(env, SPR_POWER_PMC5, "PMC5", 5174 SPR_NOACCESS, SPR_NOACCESS, 5175 &spr_read_PMC, &spr_write_PMC, 5176 KVM_REG_PPC_PMC5, 0x00000000); 5177 spr_register_kvm(env, SPR_POWER_PMC6, "PMC6", 5178 SPR_NOACCESS, SPR_NOACCESS, 5179 &spr_read_PMC, &spr_write_PMC, 5180 KVM_REG_PPC_PMC6, 0x00000000); 5181 spr_register_kvm(env, SPR_POWER_SIAR, "SIAR", 5182 SPR_NOACCESS, SPR_NOACCESS, 5183 &spr_read_generic, &spr_write_generic, 5184 KVM_REG_PPC_SIAR, 0x00000000); 5185 spr_register_kvm(env, SPR_POWER_SDAR, "SDAR", 5186 SPR_NOACCESS, SPR_NOACCESS, 5187 &spr_read_generic, &spr_write_generic, 5188 KVM_REG_PPC_SDAR, 0x00000000); 5189 } 5190 5191 static void register_book3s_pmu_user_sprs(CPUPPCState *env) 5192 { 5193 spr_register(env, SPR_POWER_UMMCR0, "UMMCR0", 5194 &spr_read_MMCR0_ureg, &spr_write_MMCR0_ureg, 5195 &spr_read_ureg, &spr_write_ureg, 5196 0x80000000); 5197 spr_register(env, SPR_POWER_UMMCR1, "UMMCR1", 5198 &spr_read_ureg, SPR_NOACCESS, 5199 &spr_read_ureg, &spr_write_ureg, 5200 0x00000000); 5201 spr_register(env, SPR_POWER_UMMCRA, "UMMCRA", 5202 &spr_read_ureg, SPR_NOACCESS, 5203 &spr_read_ureg, &spr_write_ureg, 5204 0x00000000); 5205 spr_register(env, SPR_POWER_UPMC1, "UPMC1", 5206 &spr_read_PMC14_ureg, &spr_write_PMC14_ureg, 5207 &spr_read_ureg, &spr_write_ureg, 5208 0x00000000); 5209 spr_register(env, SPR_POWER_UPMC2, "UPMC2", 5210 &spr_read_PMC14_ureg, &spr_write_PMC14_ureg, 5211 &spr_read_ureg, &spr_write_ureg, 5212 0x00000000); 5213 spr_register(env, SPR_POWER_UPMC3, "UPMC3", 5214 &spr_read_PMC14_ureg, &spr_write_PMC14_ureg, 5215 &spr_read_ureg, &spr_write_ureg, 5216 0x00000000); 5217 spr_register(env, SPR_POWER_UPMC4, "UPMC4", 5218 &spr_read_PMC14_ureg, &spr_write_PMC14_ureg, 5219 &spr_read_ureg, &spr_write_ureg, 5220 0x00000000); 5221 spr_register(env, SPR_POWER_UPMC5, "UPMC5", 5222 &spr_read_PMC56_ureg, &spr_write_PMC56_ureg, 5223 &spr_read_ureg, &spr_write_ureg, 5224 0x00000000); 5225 spr_register(env, SPR_POWER_UPMC6, "UPMC6", 5226 &spr_read_PMC56_ureg, &spr_write_PMC56_ureg, 5227 &spr_read_ureg, &spr_write_ureg, 5228 0x00000000); 5229 spr_register(env, SPR_POWER_USIAR, "USIAR", 5230 &spr_read_ureg, SPR_NOACCESS, 5231 &spr_read_ureg, &spr_write_ureg, 5232 0x00000000); 5233 spr_register(env, SPR_POWER_USDAR, "USDAR", 5234 &spr_read_ureg, SPR_NOACCESS, 5235 &spr_read_ureg, &spr_write_ureg, 5236 0x00000000); 5237 } 5238 5239 static void register_970_pmu_sup_sprs(CPUPPCState *env) 5240 { 5241 spr_register_kvm(env, SPR_970_PMC7, "PMC7", 5242 SPR_NOACCESS, SPR_NOACCESS, 5243 &spr_read_generic, &spr_write_generic, 5244 KVM_REG_PPC_PMC7, 0x00000000); 5245 spr_register_kvm(env, SPR_970_PMC8, "PMC8", 5246 SPR_NOACCESS, SPR_NOACCESS, 5247 &spr_read_generic, &spr_write_generic, 5248 KVM_REG_PPC_PMC8, 0x00000000); 5249 } 5250 5251 static void register_970_pmu_user_sprs(CPUPPCState *env) 5252 { 5253 spr_register(env, SPR_970_UPMC7, "UPMC7", 5254 &spr_read_ureg, SPR_NOACCESS, 5255 &spr_read_ureg, &spr_write_ureg, 5256 0x00000000); 5257 spr_register(env, SPR_970_UPMC8, "UPMC8", 5258 &spr_read_ureg, SPR_NOACCESS, 5259 &spr_read_ureg, &spr_write_ureg, 5260 0x00000000); 5261 } 5262 5263 static void register_power8_pmu_sup_sprs(CPUPPCState *env) 5264 { 5265 spr_register_kvm(env, SPR_POWER_MMCR2, "MMCR2", 5266 SPR_NOACCESS, SPR_NOACCESS, 5267 &spr_read_generic, &spr_write_generic, 5268 KVM_REG_PPC_MMCR2, 0x00000000); 5269 spr_register_kvm(env, SPR_POWER_MMCRS, "MMCRS", 5270 SPR_NOACCESS, SPR_NOACCESS, 5271 &spr_read_generic, &spr_write_generic, 5272 KVM_REG_PPC_MMCRS, 0x00000000); 5273 spr_register_kvm(env, SPR_POWER_SIER, "SIER", 5274 SPR_NOACCESS, SPR_NOACCESS, 5275 &spr_read_generic, &spr_write_generic, 5276 KVM_REG_PPC_SIER, 0x00000000); 5277 spr_register_kvm(env, SPR_POWER_SPMC1, "SPMC1", 5278 SPR_NOACCESS, SPR_NOACCESS, 5279 &spr_read_generic, &spr_write_generic, 5280 KVM_REG_PPC_SPMC1, 0x00000000); 5281 spr_register_kvm(env, SPR_POWER_SPMC2, "SPMC2", 5282 SPR_NOACCESS, SPR_NOACCESS, 5283 &spr_read_generic, &spr_write_generic, 5284 KVM_REG_PPC_SPMC2, 0x00000000); 5285 spr_register_kvm(env, SPR_TACR, "TACR", 5286 SPR_NOACCESS, SPR_NOACCESS, 5287 &spr_read_generic, &spr_write_generic, 5288 KVM_REG_PPC_TACR, 0x00000000); 5289 spr_register_kvm(env, SPR_TCSCR, "TCSCR", 5290 SPR_NOACCESS, SPR_NOACCESS, 5291 &spr_read_generic, &spr_write_generic, 5292 KVM_REG_PPC_TCSCR, 0x00000000); 5293 spr_register_kvm(env, SPR_CSIGR, "CSIGR", 5294 SPR_NOACCESS, SPR_NOACCESS, 5295 &spr_read_generic, &spr_write_generic, 5296 KVM_REG_PPC_CSIGR, 0x00000000); 5297 } 5298 5299 static void register_power8_pmu_user_sprs(CPUPPCState *env) 5300 { 5301 spr_register(env, SPR_POWER_UMMCR2, "UMMCR2", 5302 &spr_read_MMCR2_ureg, &spr_write_MMCR2_ureg, 5303 &spr_read_ureg, &spr_write_ureg, 5304 0x00000000); 5305 spr_register(env, SPR_POWER_USIER, "USIER", 5306 &spr_read_generic, SPR_NOACCESS, 5307 &spr_read_generic, &spr_write_generic, 5308 0x00000000); 5309 } 5310 5311 static void register_power5p_ear_sprs(CPUPPCState *env) 5312 { 5313 /* External access control */ 5314 spr_register(env, SPR_EAR, "EAR", 5315 SPR_NOACCESS, SPR_NOACCESS, 5316 &spr_read_generic, &spr_write_generic, 5317 0x00000000); 5318 } 5319 5320 static void register_power5p_tb_sprs(CPUPPCState *env) 5321 { 5322 /* TBU40 (High 40 bits of the Timebase register */ 5323 spr_register_hv(env, SPR_TBU40, "TBU40", 5324 SPR_NOACCESS, SPR_NOACCESS, 5325 SPR_NOACCESS, SPR_NOACCESS, 5326 SPR_NOACCESS, &spr_write_tbu40, 5327 0x00000000); 5328 } 5329 5330 static void register_970_lpar_sprs(CPUPPCState *env) 5331 { 5332 #if !defined(CONFIG_USER_ONLY) 5333 /* 5334 * PPC970: HID4 covers things later controlled by the LPCR and 5335 * RMOR in later CPUs, but with a different encoding. We only 5336 * support the 970 in "Apple mode" which has all hypervisor 5337 * facilities disabled by strapping, so we can basically just 5338 * ignore it 5339 */ 5340 spr_register(env, SPR_970_HID4, "HID4", 5341 SPR_NOACCESS, SPR_NOACCESS, 5342 &spr_read_generic, &spr_write_generic, 5343 0x00000000); 5344 #endif 5345 } 5346 5347 static void register_power5p_lpar_sprs(CPUPPCState *env) 5348 { 5349 #if !defined(CONFIG_USER_ONLY) 5350 /* Logical partitionning */ 5351 spr_register_kvm_hv(env, SPR_LPCR, "LPCR", 5352 SPR_NOACCESS, SPR_NOACCESS, 5353 SPR_NOACCESS, SPR_NOACCESS, 5354 &spr_read_generic, &spr_write_lpcr, 5355 KVM_REG_PPC_LPCR, LPCR_LPES0 | LPCR_LPES1); 5356 spr_register_hv(env, SPR_HDEC, "HDEC", 5357 SPR_NOACCESS, SPR_NOACCESS, 5358 SPR_NOACCESS, SPR_NOACCESS, 5359 &spr_read_hdecr, &spr_write_hdecr, 0); 5360 #endif 5361 } 5362 5363 static void register_book3s_ids_sprs(CPUPPCState *env) 5364 { 5365 /* FIXME: Will need to deal with thread vs core only SPRs */ 5366 5367 /* Processor identification */ 5368 spr_register_hv(env, SPR_PIR, "PIR", 5369 SPR_NOACCESS, SPR_NOACCESS, 5370 &spr_read_generic, SPR_NOACCESS, 5371 &spr_read_generic, NULL, 5372 0x00000000); 5373 spr_register_hv(env, SPR_HID0, "HID0", 5374 SPR_NOACCESS, SPR_NOACCESS, 5375 SPR_NOACCESS, SPR_NOACCESS, 5376 &spr_read_generic, &spr_write_generic, 5377 0x00000000); 5378 spr_register_hv(env, SPR_TSCR, "TSCR", 5379 SPR_NOACCESS, SPR_NOACCESS, 5380 SPR_NOACCESS, SPR_NOACCESS, 5381 &spr_read_generic, &spr_write_generic32, 5382 0x00000000); 5383 spr_register_hv(env, SPR_HMER, "HMER", 5384 SPR_NOACCESS, SPR_NOACCESS, 5385 SPR_NOACCESS, SPR_NOACCESS, 5386 &spr_read_generic, &spr_write_hmer, 5387 0x00000000); 5388 spr_register_hv(env, SPR_HMEER, "HMEER", 5389 SPR_NOACCESS, SPR_NOACCESS, 5390 SPR_NOACCESS, SPR_NOACCESS, 5391 &spr_read_generic, &spr_write_generic, 5392 0x00000000); 5393 spr_register_hv(env, SPR_TFMR, "TFMR", 5394 SPR_NOACCESS, SPR_NOACCESS, 5395 SPR_NOACCESS, SPR_NOACCESS, 5396 &spr_read_generic, &spr_write_generic, 5397 0x00000000); 5398 spr_register_hv(env, SPR_LPIDR, "LPIDR", 5399 SPR_NOACCESS, SPR_NOACCESS, 5400 SPR_NOACCESS, SPR_NOACCESS, 5401 &spr_read_generic, &spr_write_lpidr, 5402 0x00000000); 5403 spr_register_hv(env, SPR_HFSCR, "HFSCR", 5404 SPR_NOACCESS, SPR_NOACCESS, 5405 SPR_NOACCESS, SPR_NOACCESS, 5406 &spr_read_generic, &spr_write_generic, 5407 0x00000000); 5408 spr_register_hv(env, SPR_MMCRC, "MMCRC", 5409 SPR_NOACCESS, SPR_NOACCESS, 5410 SPR_NOACCESS, SPR_NOACCESS, 5411 &spr_read_generic, &spr_write_generic32, 5412 0x00000000); 5413 spr_register_hv(env, SPR_MMCRH, "MMCRH", 5414 SPR_NOACCESS, SPR_NOACCESS, 5415 SPR_NOACCESS, SPR_NOACCESS, 5416 &spr_read_generic, &spr_write_generic, 5417 0x00000000); 5418 spr_register_hv(env, SPR_HSPRG0, "HSPRG0", 5419 SPR_NOACCESS, SPR_NOACCESS, 5420 SPR_NOACCESS, SPR_NOACCESS, 5421 &spr_read_generic, &spr_write_generic, 5422 0x00000000); 5423 spr_register_hv(env, SPR_HSPRG1, "HSPRG1", 5424 SPR_NOACCESS, SPR_NOACCESS, 5425 SPR_NOACCESS, SPR_NOACCESS, 5426 &spr_read_generic, &spr_write_generic, 5427 0x00000000); 5428 spr_register_hv(env, SPR_HSRR0, "HSRR0", 5429 SPR_NOACCESS, SPR_NOACCESS, 5430 SPR_NOACCESS, SPR_NOACCESS, 5431 &spr_read_generic, &spr_write_generic, 5432 0x00000000); 5433 spr_register_hv(env, SPR_HSRR1, "HSRR1", 5434 SPR_NOACCESS, SPR_NOACCESS, 5435 SPR_NOACCESS, SPR_NOACCESS, 5436 &spr_read_generic, &spr_write_generic, 5437 0x00000000); 5438 spr_register_hv(env, SPR_HDAR, "HDAR", 5439 SPR_NOACCESS, SPR_NOACCESS, 5440 SPR_NOACCESS, SPR_NOACCESS, 5441 &spr_read_generic, &spr_write_generic, 5442 0x00000000); 5443 spr_register_hv(env, SPR_HDSISR, "HDSISR", 5444 SPR_NOACCESS, SPR_NOACCESS, 5445 SPR_NOACCESS, SPR_NOACCESS, 5446 &spr_read_generic, &spr_write_generic32, 5447 0x00000000); 5448 spr_register_hv(env, SPR_HRMOR, "HRMOR", 5449 SPR_NOACCESS, SPR_NOACCESS, 5450 SPR_NOACCESS, SPR_NOACCESS, 5451 &spr_read_generic, &spr_write_generic, 5452 0x00000000); 5453 } 5454 5455 static void register_rmor_sprs(CPUPPCState *env) 5456 { 5457 spr_register_hv(env, SPR_RMOR, "RMOR", 5458 SPR_NOACCESS, SPR_NOACCESS, 5459 SPR_NOACCESS, SPR_NOACCESS, 5460 &spr_read_generic, &spr_write_generic, 5461 0x00000000); 5462 } 5463 5464 static void register_power8_ids_sprs(CPUPPCState *env) 5465 { 5466 /* Thread identification */ 5467 spr_register(env, SPR_TIR, "TIR", 5468 SPR_NOACCESS, SPR_NOACCESS, 5469 &spr_read_generic, SPR_NOACCESS, 5470 0x00000000); 5471 } 5472 5473 static void register_book3s_purr_sprs(CPUPPCState *env) 5474 { 5475 #if !defined(CONFIG_USER_ONLY) 5476 /* PURR & SPURR: Hack - treat these as aliases for the TB for now */ 5477 spr_register_kvm_hv(env, SPR_PURR, "PURR", 5478 &spr_read_purr, SPR_NOACCESS, 5479 &spr_read_purr, SPR_NOACCESS, 5480 &spr_read_purr, &spr_write_purr, 5481 KVM_REG_PPC_PURR, 0x00000000); 5482 spr_register_kvm_hv(env, SPR_SPURR, "SPURR", 5483 &spr_read_purr, SPR_NOACCESS, 5484 &spr_read_purr, SPR_NOACCESS, 5485 &spr_read_purr, &spr_write_purr, 5486 KVM_REG_PPC_SPURR, 0x00000000); 5487 #endif 5488 } 5489 5490 static void register_power6_dbg_sprs(CPUPPCState *env) 5491 { 5492 #if !defined(CONFIG_USER_ONLY) 5493 spr_register(env, SPR_CFAR, "SPR_CFAR", 5494 SPR_NOACCESS, SPR_NOACCESS, 5495 &spr_read_cfar, &spr_write_cfar, 5496 0x00000000); 5497 #endif 5498 } 5499 5500 static void register_power5p_common_sprs(CPUPPCState *env) 5501 { 5502 spr_register_kvm(env, SPR_PPR, "PPR", 5503 &spr_read_generic, &spr_write_generic, 5504 &spr_read_generic, &spr_write_generic, 5505 KVM_REG_PPC_PPR, 0x00000000); 5506 } 5507 5508 static void register_power6_common_sprs(CPUPPCState *env) 5509 { 5510 #if !defined(CONFIG_USER_ONLY) 5511 spr_register_kvm(env, SPR_DSCR, "SPR_DSCR", 5512 SPR_NOACCESS, SPR_NOACCESS, 5513 &spr_read_generic, &spr_write_generic, 5514 KVM_REG_PPC_DSCR, 0x00000000); 5515 #endif 5516 /* 5517 * Register PCR to report POWERPC_EXCP_PRIV_REG instead of 5518 * POWERPC_EXCP_INVAL_SPR in userspace. Permit hypervisor access. 5519 */ 5520 spr_register_hv(env, SPR_PCR, "PCR", 5521 SPR_NOACCESS, SPR_NOACCESS, 5522 SPR_NOACCESS, SPR_NOACCESS, 5523 &spr_read_generic, &spr_write_pcr, 5524 0x00000000); 5525 } 5526 5527 static void register_HEIR32_spr(CPUPPCState *env) 5528 { 5529 spr_register_hv(env, SPR_HEIR, "HEIR", 5530 SPR_NOACCESS, SPR_NOACCESS, 5531 SPR_NOACCESS, SPR_NOACCESS, 5532 &spr_read_generic, &spr_write_generic32, 5533 0x00000000); 5534 } 5535 5536 static void register_HEIR64_spr(CPUPPCState *env) 5537 { 5538 spr_register_hv(env, SPR_HEIR, "HEIR", 5539 SPR_NOACCESS, SPR_NOACCESS, 5540 SPR_NOACCESS, SPR_NOACCESS, 5541 &spr_read_generic, &spr_write_generic, 5542 0x00000000); 5543 } 5544 5545 static void register_power8_tce_address_control_sprs(CPUPPCState *env) 5546 { 5547 spr_register_kvm(env, SPR_TAR, "TAR", 5548 &spr_read_tar, &spr_write_tar, 5549 &spr_read_generic, &spr_write_generic, 5550 KVM_REG_PPC_TAR, 0x00000000); 5551 } 5552 5553 static void register_power8_tm_sprs(CPUPPCState *env) 5554 { 5555 spr_register_kvm(env, SPR_TFHAR, "TFHAR", 5556 &spr_read_tm, &spr_write_tm, 5557 &spr_read_tm, &spr_write_tm, 5558 KVM_REG_PPC_TFHAR, 0x00000000); 5559 spr_register_kvm(env, SPR_TFIAR, "TFIAR", 5560 &spr_read_tm, &spr_write_tm, 5561 &spr_read_tm, &spr_write_tm, 5562 KVM_REG_PPC_TFIAR, 0x00000000); 5563 spr_register_kvm(env, SPR_TEXASR, "TEXASR", 5564 &spr_read_tm, &spr_write_tm, 5565 &spr_read_tm, &spr_write_tm, 5566 KVM_REG_PPC_TEXASR, 0x00000000); 5567 spr_register(env, SPR_TEXASRU, "TEXASRU", 5568 &spr_read_tm_upper32, &spr_write_tm_upper32, 5569 &spr_read_tm_upper32, &spr_write_tm_upper32, 5570 0x00000000); 5571 } 5572 5573 static void register_power8_ebb_sprs(CPUPPCState *env) 5574 { 5575 spr_register(env, SPR_BESCRS, "BESCRS", 5576 &spr_read_ebb, &spr_write_ebb, 5577 &spr_read_generic, &spr_write_generic, 5578 0x00000000); 5579 spr_register(env, SPR_BESCRSU, "BESCRSU", 5580 &spr_read_ebb_upper32, &spr_write_ebb_upper32, 5581 &spr_read_prev_upper32, &spr_write_prev_upper32, 5582 0x00000000); 5583 spr_register(env, SPR_BESCRR, "BESCRR", 5584 &spr_read_ebb, &spr_write_ebb, 5585 &spr_read_generic, &spr_write_generic, 5586 0x00000000); 5587 spr_register(env, SPR_BESCRRU, "BESCRRU", 5588 &spr_read_ebb_upper32, &spr_write_ebb_upper32, 5589 &spr_read_prev_upper32, &spr_write_prev_upper32, 5590 0x00000000); 5591 spr_register_kvm(env, SPR_EBBHR, "EBBHR", 5592 &spr_read_ebb, &spr_write_ebb, 5593 &spr_read_generic, &spr_write_generic, 5594 KVM_REG_PPC_EBBHR, 0x00000000); 5595 spr_register_kvm(env, SPR_EBBRR, "EBBRR", 5596 &spr_read_ebb, &spr_write_ebb, 5597 &spr_read_generic, &spr_write_generic, 5598 KVM_REG_PPC_EBBRR, 0x00000000); 5599 spr_register_kvm(env, SPR_BESCR, "BESCR", 5600 &spr_read_ebb, &spr_write_ebb, 5601 &spr_read_generic, &spr_write_generic, 5602 KVM_REG_PPC_BESCR, 0x00000000); 5603 } 5604 5605 /* Virtual Time Base */ 5606 static void register_vtb_sprs(CPUPPCState *env) 5607 { 5608 spr_register_kvm_hv(env, SPR_VTB, "VTB", 5609 SPR_NOACCESS, SPR_NOACCESS, 5610 &spr_read_vtb, SPR_NOACCESS, 5611 &spr_read_vtb, &spr_write_vtb, 5612 KVM_REG_PPC_VTB, 0x00000000); 5613 } 5614 5615 static void register_power8_fscr_sprs(CPUPPCState *env) 5616 { 5617 #if defined(CONFIG_USER_ONLY) 5618 target_ulong initval = 1ULL << FSCR_TAR; 5619 #else 5620 target_ulong initval = 0; 5621 #endif 5622 spr_register_kvm(env, SPR_FSCR, "FSCR", 5623 SPR_NOACCESS, SPR_NOACCESS, 5624 &spr_read_generic, &spr_write_generic, 5625 KVM_REG_PPC_FSCR, initval); 5626 } 5627 5628 static void register_power8_pspb_sprs(CPUPPCState *env) 5629 { 5630 spr_register_kvm(env, SPR_PSPB, "PSPB", 5631 SPR_NOACCESS, SPR_NOACCESS, 5632 &spr_read_generic, &spr_write_generic32, 5633 KVM_REG_PPC_PSPB, 0); 5634 } 5635 5636 static void register_power8_dpdes_sprs(CPUPPCState *env) 5637 { 5638 #if !defined(CONFIG_USER_ONLY) 5639 /* Directed Privileged Door-bell Exception State, used for IPI */ 5640 spr_register_kvm_hv(env, SPR_DPDES, "DPDES", 5641 SPR_NOACCESS, SPR_NOACCESS, 5642 &spr_read_dpdes, SPR_NOACCESS, 5643 &spr_read_dpdes, &spr_write_dpdes, 5644 KVM_REG_PPC_DPDES, 0x00000000); 5645 #endif 5646 } 5647 5648 static void register_power8_ic_sprs(CPUPPCState *env) 5649 { 5650 #if !defined(CONFIG_USER_ONLY) 5651 spr_register_hv(env, SPR_IC, "IC", 5652 SPR_NOACCESS, SPR_NOACCESS, 5653 &spr_read_generic, SPR_NOACCESS, 5654 &spr_read_generic, &spr_write_generic, 5655 0); 5656 #endif 5657 } 5658 5659 static void register_power8_book4_sprs(CPUPPCState *env) 5660 { 5661 /* Add a number of P8 book4 registers */ 5662 #if !defined(CONFIG_USER_ONLY) 5663 spr_register_kvm(env, SPR_ACOP, "ACOP", 5664 SPR_NOACCESS, SPR_NOACCESS, 5665 &spr_read_generic, &spr_write_generic, 5666 KVM_REG_PPC_ACOP, 0); 5667 spr_register_kvm(env, SPR_BOOKS_PID, "PID", 5668 SPR_NOACCESS, SPR_NOACCESS, 5669 &spr_read_generic, &spr_write_pidr, 5670 KVM_REG_PPC_PID, 0); 5671 spr_register_kvm(env, SPR_WORT, "WORT", 5672 SPR_NOACCESS, SPR_NOACCESS, 5673 &spr_read_generic, &spr_write_generic, 5674 KVM_REG_PPC_WORT, 0); 5675 #endif 5676 } 5677 5678 static void register_power7_book4_sprs(CPUPPCState *env) 5679 { 5680 /* Add a number of P7 book4 registers */ 5681 #if !defined(CONFIG_USER_ONLY) 5682 spr_register_kvm(env, SPR_ACOP, "ACOP", 5683 SPR_NOACCESS, SPR_NOACCESS, 5684 &spr_read_generic, &spr_write_generic, 5685 KVM_REG_PPC_ACOP, 0); 5686 spr_register_kvm(env, SPR_BOOKS_PID, "PID", 5687 SPR_NOACCESS, SPR_NOACCESS, 5688 &spr_read_generic, &spr_write_generic32, 5689 KVM_REG_PPC_PID, 0); 5690 #endif 5691 } 5692 5693 static void register_power8_rpr_sprs(CPUPPCState *env) 5694 { 5695 #if !defined(CONFIG_USER_ONLY) 5696 spr_register_hv(env, SPR_RPR, "RPR", 5697 SPR_NOACCESS, SPR_NOACCESS, 5698 SPR_NOACCESS, SPR_NOACCESS, 5699 &spr_read_generic, &spr_write_generic, 5700 0x00000103070F1F3F); 5701 #endif 5702 } 5703 5704 static void register_power9_mmu_sprs(CPUPPCState *env) 5705 { 5706 #if !defined(CONFIG_USER_ONLY) 5707 /* Partition Table Control */ 5708 spr_register_kvm_hv(env, SPR_PTCR, "PTCR", 5709 SPR_NOACCESS, SPR_NOACCESS, 5710 SPR_NOACCESS, SPR_NOACCESS, 5711 &spr_read_generic, &spr_write_ptcr, 5712 KVM_REG_PPC_PTCR, 0x00000000); 5713 /* Address Segment Descriptor Register */ 5714 spr_register_hv(env, SPR_ASDR, "ASDR", 5715 SPR_NOACCESS, SPR_NOACCESS, 5716 SPR_NOACCESS, SPR_NOACCESS, 5717 &spr_read_generic, &spr_write_generic, 5718 0x0000000000000000); 5719 #endif 5720 } 5721 5722 static void register_power10_hash_sprs(CPUPPCState *env) 5723 { 5724 /* 5725 * it's the OS responsability to generate a random value for the registers 5726 * in each process' context. So, initialize it with 0 here. 5727 */ 5728 uint64_t hashkeyr_initial_value = 0, hashpkeyr_initial_value = 0; 5729 #if defined(CONFIG_USER_ONLY) 5730 /* in linux-user, setup the hash register with a random value */ 5731 GRand *rand = g_rand_new(); 5732 hashkeyr_initial_value = 5733 ((uint64_t)g_rand_int(rand) << 32) | (uint64_t)g_rand_int(rand); 5734 hashpkeyr_initial_value = 5735 ((uint64_t)g_rand_int(rand) << 32) | (uint64_t)g_rand_int(rand); 5736 g_rand_free(rand); 5737 #endif 5738 spr_register(env, SPR_HASHKEYR, "HASHKEYR", 5739 SPR_NOACCESS, SPR_NOACCESS, 5740 &spr_read_generic, &spr_write_generic, 5741 hashkeyr_initial_value); 5742 spr_register_hv(env, SPR_HASHPKEYR, "HASHPKEYR", 5743 SPR_NOACCESS, SPR_NOACCESS, 5744 SPR_NOACCESS, SPR_NOACCESS, 5745 &spr_read_generic, &spr_write_generic, 5746 hashpkeyr_initial_value); 5747 } 5748 5749 static void register_power10_dexcr_sprs(CPUPPCState *env) 5750 { 5751 spr_register(env, SPR_DEXCR, "DEXCR", 5752 SPR_NOACCESS, SPR_NOACCESS, 5753 &spr_read_generic, &spr_write_generic32, 5754 0); 5755 5756 spr_register(env, SPR_UDEXCR, "DEXCR", 5757 &spr_read_dexcr_ureg, SPR_NOACCESS, 5758 &spr_read_dexcr_ureg, SPR_NOACCESS, 5759 0); 5760 5761 spr_register_hv(env, SPR_HDEXCR, "HDEXCR", 5762 SPR_NOACCESS, SPR_NOACCESS, 5763 SPR_NOACCESS, SPR_NOACCESS, 5764 &spr_read_generic, &spr_write_generic32, 5765 0); 5766 5767 spr_register(env, SPR_UHDEXCR, "HDEXCR", 5768 &spr_read_dexcr_ureg, SPR_NOACCESS, 5769 &spr_read_dexcr_ureg, SPR_NOACCESS, 5770 0); 5771 } 5772 5773 /* 5774 * Initialize PMU counter overflow timers for Power8 and 5775 * newer Power chips when using TCG. 5776 */ 5777 static void init_tcg_pmu_power8(CPUPPCState *env) 5778 { 5779 /* Init PMU overflow timers */ 5780 if (tcg_enabled()) { 5781 cpu_ppc_pmu_init(env); 5782 } 5783 } 5784 5785 static void init_proc_book3s_common(CPUPPCState *env) 5786 { 5787 register_non_embedded_sprs(env); 5788 register_book3s_altivec_sprs(env); 5789 register_book3s_pmu_sup_sprs(env); 5790 register_book3s_pmu_user_sprs(env); 5791 register_book3s_ctrl_sprs(env); 5792 /* 5793 * Can't find information on what this should be on reset. This 5794 * value is the one used by 74xx processors. 5795 */ 5796 vscr_init(env, 0x00010000); 5797 5798 spr_register(env, SPR_USPRG3, "USPRG3", 5799 &spr_read_ureg, SPR_NOACCESS, 5800 &spr_read_ureg, SPR_NOACCESS, 5801 0x00000000); 5802 } 5803 5804 static void init_proc_970(CPUPPCState *env) 5805 { 5806 /* Common Registers */ 5807 init_proc_book3s_common(env); 5808 register_sdr1_sprs(env); 5809 register_book3s_dbg_sprs(env); 5810 5811 /* 970 Specific Registers */ 5812 register_970_hid_sprs(env); 5813 register_970_hior_sprs(env); 5814 register_low_BATs(env); 5815 register_970_pmu_sup_sprs(env); 5816 register_970_pmu_user_sprs(env); 5817 register_970_lpar_sprs(env); 5818 register_970_dbg_sprs(env); 5819 5820 /* env variables */ 5821 env->dcache_line_size = 128; 5822 env->icache_line_size = 128; 5823 5824 /* Allocate hardware IRQ controller */ 5825 init_excp_970(env); 5826 ppc970_irq_init(env_archcpu(env)); 5827 } 5828 5829 POWERPC_FAMILY(970)(ObjectClass *oc, void *data) 5830 { 5831 DeviceClass *dc = DEVICE_CLASS(oc); 5832 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 5833 5834 dc->desc = "PowerPC 970"; 5835 pcc->init_proc = init_proc_970; 5836 pcc->check_pow = check_pow_970; 5837 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 5838 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 5839 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 5840 PPC_FLOAT_STFIWX | 5841 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 5842 PPC_MEM_SYNC | PPC_MEM_EIEIO | 5843 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 5844 PPC_64B | PPC_ALTIVEC | 5845 PPC_SEGMENT_64B | PPC_SLBI; 5846 pcc->insns_flags2 = PPC2_FP_CVT_S64 | PPC2_MEM_LWSYNC; 5847 pcc->msr_mask = (1ull << MSR_SF) | 5848 (1ull << MSR_VR) | 5849 (1ull << MSR_POW) | 5850 (1ull << MSR_EE) | 5851 (1ull << MSR_PR) | 5852 (1ull << MSR_FP) | 5853 (1ull << MSR_ME) | 5854 (1ull << MSR_FE0) | 5855 (1ull << MSR_SE) | 5856 (1ull << MSR_DE) | 5857 (1ull << MSR_FE1) | 5858 (1ull << MSR_IR) | 5859 (1ull << MSR_DR) | 5860 (1ull << MSR_PMM) | 5861 (1ull << MSR_RI); 5862 pcc->mmu_model = POWERPC_MMU_64B; 5863 #if !defined(CONFIG_USER_ONLY) 5864 pcc->hash64_opts = &ppc_hash64_opts_basic; 5865 #endif 5866 pcc->excp_model = POWERPC_EXCP_970; 5867 pcc->bus_model = PPC_FLAGS_INPUT_970; 5868 pcc->bfd_mach = bfd_mach_ppc64; 5869 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 5870 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 5871 POWERPC_FLAG_BUS_CLK; 5872 pcc->l1_dcache_size = 0x8000; 5873 pcc->l1_icache_size = 0x10000; 5874 } 5875 5876 static void init_proc_power5plus(CPUPPCState *env) 5877 { 5878 /* Common Registers */ 5879 init_proc_book3s_common(env); 5880 register_sdr1_sprs(env); 5881 register_book3s_dbg_sprs(env); 5882 5883 /* POWER5+ Specific Registers */ 5884 register_970_hid_sprs(env); 5885 register_970_hior_sprs(env); 5886 register_low_BATs(env); 5887 register_970_pmu_sup_sprs(env); 5888 register_970_pmu_user_sprs(env); 5889 register_power5p_common_sprs(env); 5890 register_power5p_lpar_sprs(env); 5891 register_power5p_ear_sprs(env); 5892 register_power5p_tb_sprs(env); 5893 5894 /* env variables */ 5895 env->dcache_line_size = 128; 5896 env->icache_line_size = 128; 5897 5898 /* Allocate hardware IRQ controller */ 5899 init_excp_970(env); 5900 ppc970_irq_init(env_archcpu(env)); 5901 } 5902 5903 POWERPC_FAMILY(POWER5P)(ObjectClass *oc, void *data) 5904 { 5905 DeviceClass *dc = DEVICE_CLASS(oc); 5906 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 5907 5908 dc->fw_name = "PowerPC,POWER5"; 5909 dc->desc = "POWER5+"; 5910 pcc->init_proc = init_proc_power5plus; 5911 pcc->check_pow = check_pow_970; 5912 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 5913 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 5914 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 5915 PPC_FLOAT_STFIWX | 5916 PPC_FLOAT_EXT | 5917 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 5918 PPC_MEM_SYNC | PPC_MEM_EIEIO | 5919 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 5920 PPC_64B | 5921 PPC_POPCNTB | 5922 PPC_SEGMENT_64B | PPC_SLBI; 5923 pcc->insns_flags2 = PPC2_FP_CVT_S64 | PPC2_MEM_LWSYNC; 5924 pcc->msr_mask = (1ull << MSR_SF) | 5925 (1ull << MSR_VR) | 5926 (1ull << MSR_POW) | 5927 (1ull << MSR_EE) | 5928 (1ull << MSR_PR) | 5929 (1ull << MSR_FP) | 5930 (1ull << MSR_ME) | 5931 (1ull << MSR_FE0) | 5932 (1ull << MSR_SE) | 5933 (1ull << MSR_DE) | 5934 (1ull << MSR_FE1) | 5935 (1ull << MSR_IR) | 5936 (1ull << MSR_DR) | 5937 (1ull << MSR_PMM) | 5938 (1ull << MSR_RI); 5939 pcc->lpcr_mask = LPCR_RMLS | LPCR_ILE | LPCR_LPES0 | LPCR_LPES1 | 5940 LPCR_RMI | LPCR_HDICE; 5941 pcc->mmu_model = POWERPC_MMU_2_03; 5942 #if !defined(CONFIG_USER_ONLY) 5943 pcc->hash64_opts = &ppc_hash64_opts_basic; 5944 pcc->lrg_decr_bits = 32; 5945 #endif 5946 pcc->excp_model = POWERPC_EXCP_970; 5947 pcc->bus_model = PPC_FLAGS_INPUT_970; 5948 pcc->bfd_mach = bfd_mach_ppc64; 5949 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 5950 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 5951 POWERPC_FLAG_BUS_CLK; 5952 pcc->l1_dcache_size = 0x8000; 5953 pcc->l1_icache_size = 0x10000; 5954 } 5955 5956 static void init_proc_POWER7(CPUPPCState *env) 5957 { 5958 /* Common Registers */ 5959 init_proc_book3s_common(env); 5960 register_sdr1_sprs(env); 5961 register_book3s_dbg_sprs(env); 5962 5963 /* POWER7 Specific Registers */ 5964 register_book3s_ids_sprs(env); 5965 register_rmor_sprs(env); 5966 register_amr_sprs(env); 5967 register_book3s_purr_sprs(env); 5968 register_power5p_common_sprs(env); 5969 register_power5p_lpar_sprs(env); 5970 register_power5p_ear_sprs(env); 5971 register_power5p_tb_sprs(env); 5972 register_power6_common_sprs(env); 5973 register_HEIR32_spr(env); 5974 register_power6_dbg_sprs(env); 5975 register_power7_book4_sprs(env); 5976 5977 /* env variables */ 5978 env->dcache_line_size = 128; 5979 env->icache_line_size = 128; 5980 5981 /* Allocate hardware IRQ controller */ 5982 init_excp_POWER7(env); 5983 ppcPOWER7_irq_init(env_archcpu(env)); 5984 } 5985 5986 static bool ppc_pvr_match_power7(PowerPCCPUClass *pcc, uint32_t pvr, bool best) 5987 { 5988 uint32_t base = pvr & CPU_POWERPC_POWER_SERVER_MASK; 5989 uint32_t pcc_base = pcc->pvr & CPU_POWERPC_POWER_SERVER_MASK; 5990 5991 if (!best) { 5992 if (base == CPU_POWERPC_POWER7_BASE) { 5993 return true; 5994 } 5995 if (base == CPU_POWERPC_POWER7P_BASE) { 5996 return true; 5997 } 5998 } 5999 6000 if (base != pcc_base) { 6001 return false; 6002 } 6003 6004 return true; 6005 } 6006 6007 POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data) 6008 { 6009 DeviceClass *dc = DEVICE_CLASS(oc); 6010 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 6011 6012 dc->fw_name = "PowerPC,POWER7"; 6013 dc->desc = "POWER7"; 6014 pcc->pvr_match = ppc_pvr_match_power7; 6015 pcc->pcr_mask = PCR_VEC_DIS | PCR_VSX_DIS | PCR_COMPAT_2_05; 6016 pcc->pcr_supported = PCR_COMPAT_2_06 | PCR_COMPAT_2_05; 6017 pcc->init_proc = init_proc_POWER7; 6018 pcc->check_pow = check_pow_nocheck; 6019 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB | 6020 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 6021 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 6022 PPC_FLOAT_FRSQRTES | 6023 PPC_FLOAT_STFIWX | 6024 PPC_FLOAT_EXT | 6025 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 6026 PPC_MEM_SYNC | PPC_MEM_EIEIO | 6027 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 6028 PPC_64B | PPC_64H | PPC_64BX | PPC_ALTIVEC | 6029 PPC_SEGMENT_64B | PPC_SLBI | 6030 PPC_POPCNTB | PPC_POPCNTWD | 6031 PPC_CILDST; 6032 pcc->insns_flags2 = PPC2_VSX | PPC2_DFP | PPC2_DBRX | PPC2_ISA205 | 6033 PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | 6034 PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 | 6035 PPC2_FP_TST_ISA206 | PPC2_FP_CVT_S64 | 6036 PPC2_PM_ISA206 | PPC2_MEM_LWSYNC | PPC2_BCDA_ISA206; 6037 pcc->msr_mask = (1ull << MSR_SF) | 6038 (1ull << MSR_VR) | 6039 (1ull << MSR_VSX) | 6040 (1ull << MSR_EE) | 6041 (1ull << MSR_PR) | 6042 (1ull << MSR_FP) | 6043 (1ull << MSR_ME) | 6044 (1ull << MSR_FE0) | 6045 (1ull << MSR_SE) | 6046 (1ull << MSR_DE) | 6047 (1ull << MSR_FE1) | 6048 (1ull << MSR_IR) | 6049 (1ull << MSR_DR) | 6050 (1ull << MSR_PMM) | 6051 (1ull << MSR_RI) | 6052 (1ull << MSR_LE); 6053 pcc->lpcr_mask = LPCR_VPM0 | LPCR_VPM1 | LPCR_ISL | LPCR_DPFD | 6054 LPCR_VRMASD | LPCR_RMLS | LPCR_ILE | 6055 LPCR_P7_PECE0 | LPCR_P7_PECE1 | LPCR_P7_PECE2 | 6056 LPCR_MER | LPCR_TC | 6057 LPCR_LPES0 | LPCR_LPES1 | LPCR_HDICE; 6058 pcc->lpcr_pm = LPCR_P7_PECE0 | LPCR_P7_PECE1 | LPCR_P7_PECE2; 6059 pcc->mmu_model = POWERPC_MMU_2_06; 6060 #if !defined(CONFIG_USER_ONLY) 6061 pcc->hash64_opts = &ppc_hash64_opts_POWER7; 6062 pcc->lrg_decr_bits = 32; 6063 #endif 6064 pcc->excp_model = POWERPC_EXCP_POWER7; 6065 pcc->bus_model = PPC_FLAGS_INPUT_POWER7; 6066 pcc->bfd_mach = bfd_mach_ppc64; 6067 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 6068 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 6069 POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR | 6070 POWERPC_FLAG_VSX; 6071 pcc->l1_dcache_size = 0x8000; 6072 pcc->l1_icache_size = 0x8000; 6073 } 6074 6075 static void init_proc_POWER8(CPUPPCState *env) 6076 { 6077 /* Common Registers */ 6078 init_proc_book3s_common(env); 6079 register_sdr1_sprs(env); 6080 register_book3s_207_dbg_sprs(env); 6081 6082 /* Common TCG PMU */ 6083 init_tcg_pmu_power8(env); 6084 6085 /* POWER8 Specific Registers */ 6086 register_book3s_ids_sprs(env); 6087 register_rmor_sprs(env); 6088 register_amr_sprs(env); 6089 register_iamr_sprs(env); 6090 register_book3s_purr_sprs(env); 6091 register_power5p_common_sprs(env); 6092 register_power5p_lpar_sprs(env); 6093 register_power5p_ear_sprs(env); 6094 register_power5p_tb_sprs(env); 6095 register_power6_common_sprs(env); 6096 register_HEIR32_spr(env); 6097 register_power6_dbg_sprs(env); 6098 register_power8_tce_address_control_sprs(env); 6099 register_power8_ids_sprs(env); 6100 register_power8_ebb_sprs(env); 6101 register_power8_fscr_sprs(env); 6102 register_power8_pmu_sup_sprs(env); 6103 register_power8_pmu_user_sprs(env); 6104 register_power8_tm_sprs(env); 6105 register_power8_pspb_sprs(env); 6106 register_power8_dpdes_sprs(env); 6107 register_vtb_sprs(env); 6108 register_power8_ic_sprs(env); 6109 register_power8_book4_sprs(env); 6110 register_power8_rpr_sprs(env); 6111 6112 /* env variables */ 6113 env->dcache_line_size = 128; 6114 env->icache_line_size = 128; 6115 6116 /* Allocate hardware IRQ controller */ 6117 init_excp_POWER8(env); 6118 ppcPOWER7_irq_init(env_archcpu(env)); 6119 } 6120 6121 static bool ppc_pvr_match_power8(PowerPCCPUClass *pcc, uint32_t pvr, bool best) 6122 { 6123 uint32_t base = pvr & CPU_POWERPC_POWER_SERVER_MASK; 6124 uint32_t pcc_base = pcc->pvr & CPU_POWERPC_POWER_SERVER_MASK; 6125 6126 if (!best) { 6127 if (base == CPU_POWERPC_POWER8_BASE) { 6128 return true; 6129 } 6130 if (base == CPU_POWERPC_POWER8E_BASE) { 6131 return true; 6132 } 6133 if (base == CPU_POWERPC_POWER8NVL_BASE) { 6134 return true; 6135 } 6136 } 6137 if (base != pcc_base) { 6138 return false; 6139 } 6140 6141 return true; 6142 } 6143 6144 POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data) 6145 { 6146 DeviceClass *dc = DEVICE_CLASS(oc); 6147 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 6148 6149 dc->fw_name = "PowerPC,POWER8"; 6150 dc->desc = "POWER8"; 6151 pcc->pvr_match = ppc_pvr_match_power8; 6152 pcc->pcr_mask = PCR_TM_DIS | PCR_COMPAT_2_06 | PCR_COMPAT_2_05; 6153 pcc->pcr_supported = PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_COMPAT_2_05; 6154 pcc->init_proc = init_proc_POWER8; 6155 pcc->check_pow = check_pow_nocheck; 6156 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB | 6157 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 6158 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 6159 PPC_FLOAT_FRSQRTES | 6160 PPC_FLOAT_STFIWX | 6161 PPC_FLOAT_EXT | 6162 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 6163 PPC_MEM_SYNC | PPC_MEM_EIEIO | 6164 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 6165 PPC_64B | PPC_64H | PPC_64BX | PPC_ALTIVEC | 6166 PPC_SEGMENT_64B | PPC_SLBI | 6167 PPC_POPCNTB | PPC_POPCNTWD | 6168 PPC_CILDST; 6169 pcc->insns_flags2 = PPC2_VSX | PPC2_VSX207 | PPC2_DFP | PPC2_DBRX | 6170 PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | 6171 PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 | 6172 PPC2_FP_TST_ISA206 | PPC2_BCTAR_ISA207 | 6173 PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 | 6174 PPC2_ISA205 | PPC2_ISA207S | PPC2_FP_CVT_S64 | 6175 PPC2_TM | PPC2_PM_ISA206 | PPC2_MEM_LWSYNC | 6176 PPC2_BCDA_ISA206; 6177 pcc->msr_mask = (1ull << MSR_SF) | 6178 (1ull << MSR_HV) | 6179 (1ull << MSR_TM) | 6180 (1ull << MSR_VR) | 6181 (1ull << MSR_VSX) | 6182 (1ull << MSR_EE) | 6183 (1ull << MSR_PR) | 6184 (1ull << MSR_FP) | 6185 (1ull << MSR_ME) | 6186 (1ull << MSR_FE0) | 6187 (1ull << MSR_SE) | 6188 (1ull << MSR_DE) | 6189 (1ull << MSR_FE1) | 6190 (1ull << MSR_IR) | 6191 (1ull << MSR_DR) | 6192 (1ull << MSR_PMM) | 6193 (1ull << MSR_RI) | 6194 (1ull << MSR_TS0) | 6195 (1ull << MSR_TS1) | 6196 (1ull << MSR_LE); 6197 pcc->lpcr_mask = LPCR_VPM0 | LPCR_VPM1 | LPCR_ISL | LPCR_KBV | 6198 LPCR_DPFD | LPCR_VRMASD | LPCR_RMLS | LPCR_ILE | 6199 LPCR_AIL | LPCR_ONL | LPCR_P8_PECE0 | LPCR_P8_PECE1 | 6200 LPCR_P8_PECE2 | LPCR_P8_PECE3 | LPCR_P8_PECE4 | 6201 LPCR_MER | LPCR_TC | LPCR_LPES0 | LPCR_HDICE; 6202 pcc->lpcr_pm = LPCR_P8_PECE0 | LPCR_P8_PECE1 | LPCR_P8_PECE2 | 6203 LPCR_P8_PECE3 | LPCR_P8_PECE4; 6204 pcc->mmu_model = POWERPC_MMU_2_07; 6205 #if !defined(CONFIG_USER_ONLY) 6206 pcc->hash64_opts = &ppc_hash64_opts_POWER7; 6207 pcc->lrg_decr_bits = 32; 6208 pcc->n_host_threads = 8; 6209 #endif 6210 pcc->excp_model = POWERPC_EXCP_POWER8; 6211 pcc->bus_model = PPC_FLAGS_INPUT_POWER7; 6212 pcc->bfd_mach = bfd_mach_ppc64; 6213 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 6214 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 6215 POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR | 6216 POWERPC_FLAG_VSX | POWERPC_FLAG_TM; 6217 pcc->l1_dcache_size = 0x8000; 6218 pcc->l1_icache_size = 0x8000; 6219 } 6220 6221 #ifndef CONFIG_USER_ONLY 6222 /* 6223 * Radix pg sizes and AP encodings for dt node ibm,processor-radix-AP-encodings 6224 * Encoded as array of int_32s in the form: 6225 * 0bxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 6226 * x -> AP encoding 6227 * y -> radix mode supported page size (encoded as a shift) 6228 */ 6229 static struct ppc_radix_page_info POWER9_radix_page_info = { 6230 .count = 4, 6231 .entries = { 6232 0x0000000c, /* 4K - enc: 0x0 */ 6233 0xa0000010, /* 64K - enc: 0x5 */ 6234 0x20000015, /* 2M - enc: 0x1 */ 6235 0x4000001e /* 1G - enc: 0x2 */ 6236 } 6237 }; 6238 #endif /* CONFIG_USER_ONLY */ 6239 6240 static void init_proc_POWER9(CPUPPCState *env) 6241 { 6242 /* Common Registers */ 6243 init_proc_book3s_common(env); 6244 register_book3s_207_dbg_sprs(env); 6245 6246 /* Common TCG PMU */ 6247 init_tcg_pmu_power8(env); 6248 6249 /* POWER8 Specific Registers */ 6250 register_book3s_ids_sprs(env); 6251 register_amr_sprs(env); 6252 register_iamr_sprs(env); 6253 register_book3s_purr_sprs(env); 6254 register_power5p_common_sprs(env); 6255 register_power5p_lpar_sprs(env); 6256 register_power5p_ear_sprs(env); 6257 register_power5p_tb_sprs(env); 6258 register_power6_common_sprs(env); 6259 register_HEIR32_spr(env); 6260 register_power6_dbg_sprs(env); 6261 register_power8_tce_address_control_sprs(env); 6262 register_power8_ids_sprs(env); 6263 register_power8_ebb_sprs(env); 6264 register_power8_fscr_sprs(env); 6265 register_power8_pmu_sup_sprs(env); 6266 register_power8_pmu_user_sprs(env); 6267 register_power8_tm_sprs(env); 6268 register_power8_pspb_sprs(env); 6269 register_power8_dpdes_sprs(env); 6270 register_vtb_sprs(env); 6271 register_power8_ic_sprs(env); 6272 register_power8_book4_sprs(env); 6273 register_power8_rpr_sprs(env); 6274 register_power9_mmu_sprs(env); 6275 6276 /* POWER9 Specific registers */ 6277 spr_register_kvm(env, SPR_TIDR, "TIDR", NULL, NULL, 6278 spr_read_generic, spr_write_generic, 6279 KVM_REG_PPC_TIDR, 0); 6280 6281 /* FIXME: Filter fields properly based on privilege level */ 6282 spr_register_kvm_hv(env, SPR_PSSCR, "PSSCR", NULL, NULL, NULL, NULL, 6283 spr_read_generic, spr_write_generic, 6284 KVM_REG_PPC_PSSCR, 0); 6285 6286 /* env variables */ 6287 env->dcache_line_size = 128; 6288 env->icache_line_size = 128; 6289 6290 /* Allocate hardware IRQ controller */ 6291 init_excp_POWER9(env); 6292 ppcPOWER9_irq_init(env_archcpu(env)); 6293 } 6294 6295 static bool ppc_pvr_match_power9(PowerPCCPUClass *pcc, uint32_t pvr, bool best) 6296 { 6297 uint32_t base = pvr & CPU_POWERPC_POWER_SERVER_MASK; 6298 uint32_t pcc_base = pcc->pvr & CPU_POWERPC_POWER_SERVER_MASK; 6299 6300 if (!best) { 6301 if (base == CPU_POWERPC_POWER9_BASE) { 6302 return true; 6303 } 6304 } 6305 6306 if (base != pcc_base) { 6307 return false; 6308 } 6309 6310 if ((pvr & 0x0f00) != (pcc->pvr & 0x0f00)) { 6311 /* Major DD version does not match */ 6312 return false; 6313 } 6314 6315 if ((pvr & 0x0f00) == 0x100) { 6316 /* DD1.x always matches power9_v1.0 */ 6317 return true; 6318 } else if ((pvr & 0x0f00) == 0x200) { 6319 if ((pvr & 0xf) < 2) { 6320 /* DD2.0, DD2.1 match power9_v2.0 */ 6321 if ((pcc->pvr & 0xf) == 0) { 6322 return true; 6323 } 6324 } else { 6325 /* DD2.2, DD2.3 match power9_v2.2 */ 6326 if ((pcc->pvr & 0xf) == 2) { 6327 return true; 6328 } 6329 } 6330 } 6331 6332 return false; 6333 } 6334 6335 POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data) 6336 { 6337 DeviceClass *dc = DEVICE_CLASS(oc); 6338 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 6339 6340 dc->fw_name = "PowerPC,POWER9"; 6341 dc->desc = "POWER9"; 6342 pcc->pvr_match = ppc_pvr_match_power9; 6343 pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06 | PCR_COMPAT_2_07; 6344 pcc->pcr_supported = PCR_COMPAT_3_00 | PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | 6345 PCR_COMPAT_2_05; 6346 pcc->init_proc = init_proc_POWER9; 6347 pcc->check_pow = check_pow_nocheck; 6348 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB | 6349 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 6350 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 6351 PPC_FLOAT_FRSQRTES | 6352 PPC_FLOAT_STFIWX | 6353 PPC_FLOAT_EXT | 6354 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 6355 PPC_MEM_SYNC | PPC_MEM_EIEIO | 6356 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 6357 PPC_64B | PPC_64H | PPC_64BX | PPC_ALTIVEC | 6358 PPC_SEGMENT_64B | PPC_SLBI | 6359 PPC_POPCNTB | PPC_POPCNTWD | 6360 PPC_CILDST; 6361 pcc->insns_flags2 = PPC2_VSX | PPC2_VSX207 | PPC2_DFP | PPC2_DBRX | 6362 PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | 6363 PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 | 6364 PPC2_FP_TST_ISA206 | PPC2_BCTAR_ISA207 | 6365 PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 | 6366 PPC2_ISA205 | PPC2_ISA207S | PPC2_FP_CVT_S64 | 6367 PPC2_TM | PPC2_ISA300 | PPC2_PRCNTL | PPC2_MEM_LWSYNC | 6368 PPC2_BCDA_ISA206; 6369 pcc->msr_mask = (1ull << MSR_SF) | 6370 (1ull << MSR_HV) | 6371 (1ull << MSR_TM) | 6372 (1ull << MSR_VR) | 6373 (1ull << MSR_VSX) | 6374 (1ull << MSR_EE) | 6375 (1ull << MSR_PR) | 6376 (1ull << MSR_FP) | 6377 (1ull << MSR_ME) | 6378 (1ull << MSR_FE0) | 6379 (1ull << MSR_SE) | 6380 (1ull << MSR_DE) | 6381 (1ull << MSR_FE1) | 6382 (1ull << MSR_IR) | 6383 (1ull << MSR_DR) | 6384 (1ull << MSR_PMM) | 6385 (1ull << MSR_RI) | 6386 (1ull << MSR_LE); 6387 pcc->lpcr_mask = LPCR_VPM1 | LPCR_ISL | LPCR_KBV | LPCR_DPFD | 6388 (LPCR_PECE_U_MASK & LPCR_HVEE) | LPCR_ILE | LPCR_AIL | 6389 LPCR_UPRT | LPCR_EVIRT | LPCR_ONL | LPCR_HR | LPCR_LD | 6390 (LPCR_PECE_L_MASK & (LPCR_PDEE | LPCR_HDEE | LPCR_EEE | 6391 LPCR_DEE | LPCR_OEE)) 6392 | LPCR_MER | LPCR_GTSE | LPCR_TC | 6393 LPCR_HEIC | LPCR_LPES0 | LPCR_HVICE | LPCR_HDICE; 6394 pcc->lpcr_pm = LPCR_PDEE | LPCR_HDEE | LPCR_EEE | LPCR_DEE | LPCR_OEE; 6395 pcc->mmu_model = POWERPC_MMU_3_00; 6396 #if !defined(CONFIG_USER_ONLY) 6397 /* segment page size remain the same */ 6398 pcc->hash64_opts = &ppc_hash64_opts_POWER7; 6399 pcc->radix_page_info = &POWER9_radix_page_info; 6400 pcc->lrg_decr_bits = 56; 6401 pcc->n_host_threads = 4; 6402 #endif 6403 pcc->excp_model = POWERPC_EXCP_POWER9; 6404 pcc->bus_model = PPC_FLAGS_INPUT_POWER9; 6405 pcc->bfd_mach = bfd_mach_ppc64; 6406 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 6407 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 6408 POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR | 6409 POWERPC_FLAG_VSX | POWERPC_FLAG_TM | POWERPC_FLAG_SCV; 6410 pcc->l1_dcache_size = 0x8000; 6411 pcc->l1_icache_size = 0x8000; 6412 } 6413 6414 #ifndef CONFIG_USER_ONLY 6415 /* 6416 * Radix pg sizes and AP encodings for dt node ibm,processor-radix-AP-encodings 6417 * Encoded as array of int_32s in the form: 6418 * 0bxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 6419 * x -> AP encoding 6420 * y -> radix mode supported page size (encoded as a shift) 6421 */ 6422 static struct ppc_radix_page_info POWER10_radix_page_info = { 6423 .count = 4, 6424 .entries = { 6425 0x0000000c, /* 4K - enc: 0x0 */ 6426 0xa0000010, /* 64K - enc: 0x5 */ 6427 0x20000015, /* 2M - enc: 0x1 */ 6428 0x4000001e /* 1G - enc: 0x2 */ 6429 } 6430 }; 6431 #endif /* !CONFIG_USER_ONLY */ 6432 6433 static void init_proc_POWER10(CPUPPCState *env) 6434 { 6435 /* Common Registers */ 6436 init_proc_book3s_common(env); 6437 register_book3s_207_dbg_sprs(env); 6438 6439 /* Common TCG PMU */ 6440 init_tcg_pmu_power8(env); 6441 6442 /* POWER8 Specific Registers */ 6443 register_book3s_ids_sprs(env); 6444 register_amr_sprs(env); 6445 register_iamr_sprs(env); 6446 register_book3s_purr_sprs(env); 6447 register_power5p_common_sprs(env); 6448 register_power5p_lpar_sprs(env); 6449 register_power5p_ear_sprs(env); 6450 register_power5p_tb_sprs(env); 6451 register_power6_common_sprs(env); 6452 register_HEIR64_spr(env); 6453 register_power6_dbg_sprs(env); 6454 register_power8_tce_address_control_sprs(env); 6455 register_power8_ids_sprs(env); 6456 register_power8_ebb_sprs(env); 6457 register_power8_fscr_sprs(env); 6458 register_power8_pmu_sup_sprs(env); 6459 register_power8_pmu_user_sprs(env); 6460 register_power8_tm_sprs(env); 6461 register_power8_pspb_sprs(env); 6462 register_power8_dpdes_sprs(env); 6463 register_vtb_sprs(env); 6464 register_power8_ic_sprs(env); 6465 register_power8_book4_sprs(env); 6466 register_power8_rpr_sprs(env); 6467 register_power9_mmu_sprs(env); 6468 register_power10_hash_sprs(env); 6469 register_power10_dexcr_sprs(env); 6470 6471 /* FIXME: Filter fields properly based on privilege level */ 6472 spr_register_kvm_hv(env, SPR_PSSCR, "PSSCR", NULL, NULL, NULL, NULL, 6473 spr_read_generic, spr_write_generic, 6474 KVM_REG_PPC_PSSCR, 0); 6475 6476 /* env variables */ 6477 env->dcache_line_size = 128; 6478 env->icache_line_size = 128; 6479 6480 /* Allocate hardware IRQ controller */ 6481 init_excp_POWER10(env); 6482 ppcPOWER9_irq_init(env_archcpu(env)); 6483 } 6484 6485 static bool ppc_pvr_match_power10(PowerPCCPUClass *pcc, uint32_t pvr, bool best) 6486 { 6487 uint32_t base = pvr & CPU_POWERPC_POWER_SERVER_MASK; 6488 uint32_t pcc_base = pcc->pvr & CPU_POWERPC_POWER_SERVER_MASK; 6489 6490 if (!best) { 6491 if (base == CPU_POWERPC_POWER10_BASE) { 6492 return true; 6493 } 6494 } 6495 6496 if (base != pcc_base) { 6497 return false; 6498 } 6499 6500 if ((pvr & 0x0f00) == (pcc->pvr & 0x0f00)) { 6501 /* Major DD version matches to power10_v1.0 and power10_v2.0 */ 6502 return true; 6503 } 6504 6505 return false; 6506 } 6507 6508 POWERPC_FAMILY(POWER10)(ObjectClass *oc, void *data) 6509 { 6510 DeviceClass *dc = DEVICE_CLASS(oc); 6511 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 6512 6513 dc->fw_name = "PowerPC,POWER10"; 6514 dc->desc = "POWER10"; 6515 pcc->pvr_match = ppc_pvr_match_power10; 6516 pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06 | PCR_COMPAT_2_07 | 6517 PCR_COMPAT_3_00; 6518 pcc->pcr_supported = PCR_COMPAT_3_10 | PCR_COMPAT_3_00 | PCR_COMPAT_2_07 | 6519 PCR_COMPAT_2_06 | PCR_COMPAT_2_05; 6520 pcc->init_proc = init_proc_POWER10; 6521 pcc->check_pow = check_pow_nocheck; 6522 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB | 6523 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 6524 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 6525 PPC_FLOAT_FRSQRTES | 6526 PPC_FLOAT_STFIWX | 6527 PPC_FLOAT_EXT | 6528 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 6529 PPC_MEM_SYNC | PPC_MEM_EIEIO | 6530 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 6531 PPC_64B | PPC_64H | PPC_64BX | PPC_ALTIVEC | 6532 PPC_SEGMENT_64B | PPC_SLBI | 6533 PPC_POPCNTB | PPC_POPCNTWD | 6534 PPC_CILDST; 6535 pcc->insns_flags2 = PPC2_VSX | PPC2_VSX207 | PPC2_DFP | PPC2_DBRX | 6536 PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | 6537 PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 | 6538 PPC2_FP_TST_ISA206 | PPC2_BCTAR_ISA207 | 6539 PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 | 6540 PPC2_ISA205 | PPC2_ISA207S | PPC2_FP_CVT_S64 | 6541 PPC2_TM | PPC2_ISA300 | PPC2_PRCNTL | PPC2_ISA310 | 6542 PPC2_MEM_LWSYNC | PPC2_BCDA_ISA206; 6543 pcc->msr_mask = (1ull << MSR_SF) | 6544 (1ull << MSR_HV) | 6545 (1ull << MSR_TM) | 6546 (1ull << MSR_VR) | 6547 (1ull << MSR_VSX) | 6548 (1ull << MSR_EE) | 6549 (1ull << MSR_PR) | 6550 (1ull << MSR_FP) | 6551 (1ull << MSR_ME) | 6552 (1ull << MSR_FE0) | 6553 (1ull << MSR_SE) | 6554 (1ull << MSR_DE) | 6555 (1ull << MSR_FE1) | 6556 (1ull << MSR_IR) | 6557 (1ull << MSR_DR) | 6558 (1ull << MSR_PMM) | 6559 (1ull << MSR_RI) | 6560 (1ull << MSR_LE); 6561 pcc->lpcr_mask = LPCR_VPM1 | LPCR_ISL | LPCR_KBV | LPCR_DPFD | 6562 (LPCR_PECE_U_MASK & LPCR_HVEE) | LPCR_ILE | LPCR_AIL | 6563 LPCR_UPRT | LPCR_EVIRT | LPCR_ONL | LPCR_HR | LPCR_LD | 6564 (LPCR_PECE_L_MASK & (LPCR_PDEE | LPCR_HDEE | LPCR_EEE | 6565 LPCR_DEE | LPCR_OEE)) 6566 | LPCR_MER | LPCR_GTSE | LPCR_TC | 6567 LPCR_HEIC | LPCR_LPES0 | LPCR_HVICE | LPCR_HDICE; 6568 /* DD2 adds an extra HAIL bit */ 6569 pcc->lpcr_mask |= LPCR_HAIL; 6570 6571 pcc->lpcr_pm = LPCR_PDEE | LPCR_HDEE | LPCR_EEE | LPCR_DEE | LPCR_OEE; 6572 pcc->mmu_model = POWERPC_MMU_3_00; 6573 #if !defined(CONFIG_USER_ONLY) 6574 /* segment page size remain the same */ 6575 pcc->hash64_opts = &ppc_hash64_opts_POWER7; 6576 pcc->radix_page_info = &POWER10_radix_page_info; 6577 pcc->lrg_decr_bits = 56; 6578 #endif 6579 pcc->excp_model = POWERPC_EXCP_POWER10; 6580 pcc->bus_model = PPC_FLAGS_INPUT_POWER9; 6581 pcc->bfd_mach = bfd_mach_ppc64; 6582 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 6583 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 6584 POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR | 6585 POWERPC_FLAG_VSX | POWERPC_FLAG_TM | POWERPC_FLAG_SCV; 6586 pcc->l1_dcache_size = 0x8000; 6587 pcc->l1_icache_size = 0x8000; 6588 } 6589 6590 #if !defined(CONFIG_USER_ONLY) 6591 void cpu_ppc_set_vhyp(PowerPCCPU *cpu, PPCVirtualHypervisor *vhyp) 6592 { 6593 CPUPPCState *env = &cpu->env; 6594 6595 cpu->vhyp = vhyp; 6596 6597 /* 6598 * With a virtual hypervisor mode we never allow the CPU to go 6599 * hypervisor mode itself 6600 */ 6601 env->msr_mask &= ~MSR_HVB; 6602 } 6603 6604 #endif /* !defined(CONFIG_USER_ONLY) */ 6605 6606 #endif /* defined(TARGET_PPC64) */ 6607 6608 /*****************************************************************************/ 6609 /* Generic CPU instantiation routine */ 6610 static void init_ppc_proc(PowerPCCPU *cpu) 6611 { 6612 PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); 6613 CPUPPCState *env = &cpu->env; 6614 #if !defined(CONFIG_USER_ONLY) 6615 int i; 6616 6617 /* Set all exception vectors to an invalid address */ 6618 for (i = 0; i < POWERPC_EXCP_NB; i++) { 6619 env->excp_vectors[i] = (target_ulong)(-1ULL); 6620 } 6621 env->ivor_mask = 0x00000000; 6622 env->ivpr_mask = 0x00000000; 6623 /* Default MMU definitions */ 6624 env->nb_BATs = 0; 6625 env->nb_tlb = 0; 6626 env->nb_ways = 0; 6627 env->tlb_type = TLB_NONE; 6628 #endif 6629 /* Register SPR common to all PowerPC implementations */ 6630 register_generic_sprs(cpu); 6631 6632 /* PowerPC implementation specific initialisations (SPRs, timers, ...) */ 6633 (*pcc->init_proc)(env); 6634 6635 #if !defined(CONFIG_USER_ONLY) 6636 ppc_gdb_gen_spr_xml(cpu); 6637 #endif 6638 6639 /* MSR bits & flags consistency checks */ 6640 if (env->msr_mask & (1 << 25)) { 6641 switch (env->flags & (POWERPC_FLAG_SPE | POWERPC_FLAG_VRE)) { 6642 case POWERPC_FLAG_SPE: 6643 case POWERPC_FLAG_VRE: 6644 break; 6645 default: 6646 fprintf(stderr, "PowerPC MSR definition inconsistency\n" 6647 "Should define POWERPC_FLAG_SPE or POWERPC_FLAG_VRE\n"); 6648 exit(1); 6649 } 6650 } else if (env->flags & (POWERPC_FLAG_SPE | POWERPC_FLAG_VRE)) { 6651 fprintf(stderr, "PowerPC MSR definition inconsistency\n" 6652 "Should not define POWERPC_FLAG_SPE nor POWERPC_FLAG_VRE\n"); 6653 exit(1); 6654 } 6655 if (env->msr_mask & (1 << 17)) { 6656 switch (env->flags & (POWERPC_FLAG_TGPR | POWERPC_FLAG_CE)) { 6657 case POWERPC_FLAG_TGPR: 6658 case POWERPC_FLAG_CE: 6659 break; 6660 default: 6661 fprintf(stderr, "PowerPC MSR definition inconsistency\n" 6662 "Should define POWERPC_FLAG_TGPR or POWERPC_FLAG_CE\n"); 6663 exit(1); 6664 } 6665 } else if (env->flags & (POWERPC_FLAG_TGPR | POWERPC_FLAG_CE)) { 6666 fprintf(stderr, "PowerPC MSR definition inconsistency\n" 6667 "Should not define POWERPC_FLAG_TGPR nor POWERPC_FLAG_CE\n"); 6668 exit(1); 6669 } 6670 if (env->msr_mask & (1 << 10)) { 6671 switch (env->flags & (POWERPC_FLAG_SE | POWERPC_FLAG_DWE | 6672 POWERPC_FLAG_UBLE)) { 6673 case POWERPC_FLAG_SE: 6674 case POWERPC_FLAG_DWE: 6675 case POWERPC_FLAG_UBLE: 6676 break; 6677 default: 6678 fprintf(stderr, "PowerPC MSR definition inconsistency\n" 6679 "Should define POWERPC_FLAG_SE or POWERPC_FLAG_DWE or " 6680 "POWERPC_FLAG_UBLE\n"); 6681 exit(1); 6682 } 6683 } else if (env->flags & (POWERPC_FLAG_SE | POWERPC_FLAG_DWE | 6684 POWERPC_FLAG_UBLE)) { 6685 fprintf(stderr, "PowerPC MSR definition inconsistency\n" 6686 "Should not define POWERPC_FLAG_SE nor POWERPC_FLAG_DWE nor " 6687 "POWERPC_FLAG_UBLE\n"); 6688 exit(1); 6689 } 6690 if (env->msr_mask & (1 << 9)) { 6691 switch (env->flags & (POWERPC_FLAG_BE | POWERPC_FLAG_DE)) { 6692 case POWERPC_FLAG_BE: 6693 case POWERPC_FLAG_DE: 6694 break; 6695 default: 6696 fprintf(stderr, "PowerPC MSR definition inconsistency\n" 6697 "Should define POWERPC_FLAG_BE or POWERPC_FLAG_DE\n"); 6698 exit(1); 6699 } 6700 } else if (env->flags & (POWERPC_FLAG_BE | POWERPC_FLAG_DE)) { 6701 fprintf(stderr, "PowerPC MSR definition inconsistency\n" 6702 "Should not define POWERPC_FLAG_BE nor POWERPC_FLAG_DE\n"); 6703 exit(1); 6704 } 6705 if (env->msr_mask & (1 << 2)) { 6706 switch (env->flags & (POWERPC_FLAG_PX | POWERPC_FLAG_PMM)) { 6707 case POWERPC_FLAG_PX: 6708 case POWERPC_FLAG_PMM: 6709 break; 6710 default: 6711 fprintf(stderr, "PowerPC MSR definition inconsistency\n" 6712 "Should define POWERPC_FLAG_PX or POWERPC_FLAG_PMM\n"); 6713 exit(1); 6714 } 6715 } else if (env->flags & (POWERPC_FLAG_PX | POWERPC_FLAG_PMM)) { 6716 fprintf(stderr, "PowerPC MSR definition inconsistency\n" 6717 "Should not define POWERPC_FLAG_PX nor POWERPC_FLAG_PMM\n"); 6718 exit(1); 6719 } 6720 if ((env->flags & POWERPC_FLAG_BUS_CLK) == 0) { 6721 fprintf(stderr, "PowerPC flags inconsistency\n" 6722 "Should define the time-base and decrementer clock source\n"); 6723 exit(1); 6724 } 6725 /* Allocate TLBs buffer when needed */ 6726 #if !defined(CONFIG_USER_ONLY) 6727 if (env->nb_tlb != 0) { 6728 int nb_tlb = env->nb_tlb; 6729 if (env->id_tlbs != 0) { 6730 nb_tlb *= 2; 6731 } 6732 switch (env->tlb_type) { 6733 case TLB_6XX: 6734 env->tlb.tlb6 = g_new0(ppc6xx_tlb_t, nb_tlb); 6735 break; 6736 case TLB_EMB: 6737 env->tlb.tlbe = g_new0(ppcemb_tlb_t, nb_tlb); 6738 break; 6739 case TLB_MAS: 6740 env->tlb.tlbm = g_new0(ppcmas_tlb_t, nb_tlb); 6741 break; 6742 } 6743 /* Pre-compute some useful values */ 6744 env->tlb_per_way = env->nb_tlb / env->nb_ways; 6745 } 6746 #endif 6747 if (env->check_pow == NULL) { 6748 warn_report("no power management check handler registered." 6749 " Attempt QEMU to crash very soon !"); 6750 } 6751 } 6752 6753 6754 static void ppc_cpu_realize(DeviceState *dev, Error **errp) 6755 { 6756 CPUState *cs = CPU(dev); 6757 PowerPCCPU *cpu = POWERPC_CPU(dev); 6758 CPUPPCState *env = &cpu->env; 6759 PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); 6760 Error *local_err = NULL; 6761 6762 cpu_exec_realizefn(cs, &local_err); 6763 if (local_err != NULL) { 6764 error_propagate(errp, local_err); 6765 return; 6766 } 6767 if (cpu->vcpu_id == UNASSIGNED_CPU_INDEX) { 6768 cpu->vcpu_id = cs->cpu_index; 6769 } 6770 6771 if (tcg_enabled()) { 6772 if (ppc_fixup_cpu(cpu) != 0) { 6773 error_setg(errp, "Unable to emulate selected CPU with TCG"); 6774 goto unrealize; 6775 } 6776 } 6777 6778 create_ppc_opcodes(cpu, &local_err); 6779 if (local_err != NULL) { 6780 error_propagate(errp, local_err); 6781 goto unrealize; 6782 } 6783 init_ppc_proc(cpu); 6784 6785 ppc_gdb_init(cs, pcc); 6786 qemu_init_vcpu(cs); 6787 6788 pcc->parent_realize(dev, errp); 6789 6790 if (env_cpu(env)->nr_threads > 1) { 6791 env->flags |= POWERPC_FLAG_SMT; 6792 } 6793 6794 return; 6795 6796 unrealize: 6797 cpu_exec_unrealizefn(cs); 6798 } 6799 6800 static void ppc_cpu_unrealize(DeviceState *dev) 6801 { 6802 PowerPCCPU *cpu = POWERPC_CPU(dev); 6803 PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); 6804 6805 pcc->parent_unrealize(dev); 6806 6807 cpu_remove_sync(CPU(cpu)); 6808 6809 destroy_ppc_opcodes(cpu); 6810 } 6811 6812 static gint ppc_cpu_compare_class_pvr(gconstpointer a, gconstpointer b) 6813 { 6814 ObjectClass *oc = (ObjectClass *)a; 6815 uint32_t pvr = *(uint32_t *)b; 6816 PowerPCCPUClass *pcc = (PowerPCCPUClass *)a; 6817 6818 /* -cpu host does a PVR lookup during construction */ 6819 if (unlikely(strcmp(object_class_get_name(oc), 6820 TYPE_HOST_POWERPC_CPU) == 0)) { 6821 return -1; 6822 } 6823 6824 return pcc->pvr == pvr ? 0 : -1; 6825 } 6826 6827 PowerPCCPUClass *ppc_cpu_class_by_pvr(uint32_t pvr) 6828 { 6829 GSList *list, *item; 6830 PowerPCCPUClass *pcc = NULL; 6831 6832 list = object_class_get_list(TYPE_POWERPC_CPU, false); 6833 item = g_slist_find_custom(list, &pvr, ppc_cpu_compare_class_pvr); 6834 if (item != NULL) { 6835 pcc = POWERPC_CPU_CLASS(item->data); 6836 } 6837 g_slist_free(list); 6838 6839 return pcc; 6840 } 6841 6842 static gint ppc_cpu_compare_class_pvr_mask(gconstpointer a, gconstpointer b) 6843 { 6844 ObjectClass *oc = (ObjectClass *)a; 6845 uint32_t pvr = *(uint32_t *)b; 6846 PowerPCCPUClass *pcc = (PowerPCCPUClass *)a; 6847 6848 /* -cpu host does a PVR lookup during construction */ 6849 if (unlikely(strcmp(object_class_get_name(oc), 6850 TYPE_HOST_POWERPC_CPU) == 0)) { 6851 return -1; 6852 } 6853 6854 if (pcc->pvr_match(pcc, pvr, true)) { 6855 return 0; 6856 } 6857 6858 return -1; 6859 } 6860 6861 PowerPCCPUClass *ppc_cpu_class_by_pvr_mask(uint32_t pvr) 6862 { 6863 GSList *list, *item; 6864 PowerPCCPUClass *pcc = NULL; 6865 6866 list = object_class_get_list(TYPE_POWERPC_CPU, true); 6867 item = g_slist_find_custom(list, &pvr, ppc_cpu_compare_class_pvr_mask); 6868 if (item != NULL) { 6869 pcc = POWERPC_CPU_CLASS(item->data); 6870 } 6871 g_slist_free(list); 6872 6873 return pcc; 6874 } 6875 6876 static const char *ppc_cpu_lookup_alias(const char *alias) 6877 { 6878 int ai; 6879 6880 for (ai = 0; ppc_cpu_aliases[ai].alias != NULL; ai++) { 6881 if (strcmp(ppc_cpu_aliases[ai].alias, alias) == 0) { 6882 return ppc_cpu_aliases[ai].model; 6883 } 6884 } 6885 6886 return NULL; 6887 } 6888 6889 ObjectClass *ppc_cpu_class_by_name(const char *name) 6890 { 6891 char *cpu_model, *typename; 6892 ObjectClass *oc; 6893 const char *p; 6894 unsigned long pvr; 6895 6896 /* 6897 * Lookup by PVR if cpu_model is valid 8 digit hex number (excl: 6898 * 0x prefix if present) 6899 */ 6900 if (!qemu_strtoul(name, &p, 16, &pvr)) { 6901 int len = p - name; 6902 len = (len == 10) && (name[1] == 'x') ? len - 2 : len; 6903 if ((len == 8) && (*p == '\0')) { 6904 return OBJECT_CLASS(ppc_cpu_class_by_pvr(pvr)); 6905 } 6906 } 6907 6908 /* 6909 * All ppc CPUs represent hardware that exists in the real world, i.e.: we 6910 * do not have a "max" CPU with all possible emulated features enabled. 6911 * Return the default CPU type for the machine because that has greater 6912 * chance of being useful as the "max" CPU. 6913 */ 6914 #if !defined(CONFIG_USER_ONLY) 6915 if (strcmp(name, "max") == 0) { 6916 MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine()); 6917 if (mc) { 6918 return object_class_by_name(mc->default_cpu_type); 6919 } 6920 } 6921 #endif 6922 6923 cpu_model = g_ascii_strdown(name, -1); 6924 p = ppc_cpu_lookup_alias(cpu_model); 6925 if (p) { 6926 g_free(cpu_model); 6927 cpu_model = g_strdup(p); 6928 } 6929 6930 typename = g_strdup_printf("%s" POWERPC_CPU_TYPE_SUFFIX, cpu_model); 6931 oc = object_class_by_name(typename); 6932 g_free(typename); 6933 g_free(cpu_model); 6934 6935 return oc; 6936 } 6937 6938 PowerPCCPUClass *ppc_cpu_get_family_class(PowerPCCPUClass *pcc) 6939 { 6940 ObjectClass *oc = OBJECT_CLASS(pcc); 6941 6942 while (oc && !object_class_is_abstract(oc)) { 6943 oc = object_class_get_parent(oc); 6944 } 6945 assert(oc); 6946 6947 return POWERPC_CPU_CLASS(oc); 6948 } 6949 6950 /* Sort by PVR, ordering special case "host" last. */ 6951 static gint ppc_cpu_list_compare(gconstpointer a, gconstpointer b) 6952 { 6953 ObjectClass *oc_a = (ObjectClass *)a; 6954 ObjectClass *oc_b = (ObjectClass *)b; 6955 PowerPCCPUClass *pcc_a = POWERPC_CPU_CLASS(oc_a); 6956 PowerPCCPUClass *pcc_b = POWERPC_CPU_CLASS(oc_b); 6957 const char *name_a = object_class_get_name(oc_a); 6958 const char *name_b = object_class_get_name(oc_b); 6959 6960 if (strcmp(name_a, TYPE_HOST_POWERPC_CPU) == 0) { 6961 return 1; 6962 } else if (strcmp(name_b, TYPE_HOST_POWERPC_CPU) == 0) { 6963 return -1; 6964 } else { 6965 /* Avoid an integer overflow during subtraction */ 6966 if (pcc_a->pvr < pcc_b->pvr) { 6967 return -1; 6968 } else if (pcc_a->pvr > pcc_b->pvr) { 6969 return 1; 6970 } else { 6971 return 0; 6972 } 6973 } 6974 } 6975 6976 static void ppc_cpu_list_entry(gpointer data, gpointer user_data) 6977 { 6978 ObjectClass *oc = data; 6979 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 6980 DeviceClass *family = DEVICE_CLASS(ppc_cpu_get_family_class(pcc)); 6981 const char *typename = object_class_get_name(oc); 6982 char *name; 6983 int i; 6984 6985 if (unlikely(strcmp(typename, TYPE_HOST_POWERPC_CPU) == 0)) { 6986 return; 6987 } 6988 6989 name = g_strndup(typename, 6990 strlen(typename) - strlen(POWERPC_CPU_TYPE_SUFFIX)); 6991 qemu_printf("PowerPC %-16s PVR %08x\n", name, pcc->pvr); 6992 for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) { 6993 PowerPCCPUAlias *alias = &ppc_cpu_aliases[i]; 6994 ObjectClass *alias_oc = ppc_cpu_class_by_name(alias->model); 6995 6996 if (alias_oc != oc) { 6997 continue; 6998 } 6999 /* 7000 * If running with KVM, we might update the family alias later, so 7001 * avoid printing the wrong alias here and use "preferred" instead 7002 */ 7003 if (strcmp(alias->alias, family->desc) == 0) { 7004 qemu_printf("PowerPC %-16s (alias for preferred %s CPU)\n", 7005 alias->alias, family->desc); 7006 } else { 7007 qemu_printf("PowerPC %-16s (alias for %s)\n", 7008 alias->alias, name); 7009 } 7010 } 7011 g_free(name); 7012 } 7013 7014 void ppc_cpu_list(void) 7015 { 7016 GSList *list; 7017 7018 list = object_class_get_list(TYPE_POWERPC_CPU, false); 7019 list = g_slist_sort(list, ppc_cpu_list_compare); 7020 g_slist_foreach(list, ppc_cpu_list_entry, NULL); 7021 g_slist_free(list); 7022 7023 #ifdef CONFIG_KVM 7024 qemu_printf("\n"); 7025 qemu_printf("PowerPC %s\n", "host"); 7026 #endif 7027 } 7028 7029 static void ppc_cpu_set_pc(CPUState *cs, vaddr value) 7030 { 7031 PowerPCCPU *cpu = POWERPC_CPU(cs); 7032 7033 cpu->env.nip = value; 7034 } 7035 7036 static vaddr ppc_cpu_get_pc(CPUState *cs) 7037 { 7038 PowerPCCPU *cpu = POWERPC_CPU(cs); 7039 7040 return cpu->env.nip; 7041 } 7042 7043 #ifdef CONFIG_TCG 7044 static void ppc_restore_state_to_opc(CPUState *cs, 7045 const TranslationBlock *tb, 7046 const uint64_t *data) 7047 { 7048 PowerPCCPU *cpu = POWERPC_CPU(cs); 7049 7050 cpu->env.nip = data[0]; 7051 } 7052 #endif /* CONFIG_TCG */ 7053 7054 static bool ppc_cpu_has_work(CPUState *cs) 7055 { 7056 return cs->interrupt_request & CPU_INTERRUPT_HARD; 7057 } 7058 7059 static void ppc_cpu_reset_hold(Object *obj) 7060 { 7061 CPUState *s = CPU(obj); 7062 PowerPCCPU *cpu = POWERPC_CPU(s); 7063 PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); 7064 CPUPPCState *env = &cpu->env; 7065 target_ulong msr; 7066 int i; 7067 7068 if (pcc->parent_phases.hold) { 7069 pcc->parent_phases.hold(obj); 7070 } 7071 7072 msr = (target_ulong)0; 7073 msr |= (target_ulong)MSR_HVB; 7074 msr |= (target_ulong)1 << MSR_EP; 7075 #if defined(DO_SINGLE_STEP) && 0 7076 /* Single step trace mode */ 7077 msr |= (target_ulong)1 << MSR_SE; 7078 msr |= (target_ulong)1 << MSR_BE; 7079 #endif 7080 #if defined(CONFIG_USER_ONLY) 7081 msr |= (target_ulong)1 << MSR_FP; /* Allow floating point usage */ 7082 msr |= (target_ulong)1 << MSR_FE0; /* Allow floating point exceptions */ 7083 msr |= (target_ulong)1 << MSR_FE1; 7084 msr |= (target_ulong)1 << MSR_VR; /* Allow altivec usage */ 7085 msr |= (target_ulong)1 << MSR_VSX; /* Allow VSX usage */ 7086 msr |= (target_ulong)1 << MSR_SPE; /* Allow SPE usage */ 7087 msr |= (target_ulong)1 << MSR_PR; 7088 #if defined(TARGET_PPC64) 7089 msr |= (target_ulong)1 << MSR_TM; /* Transactional memory */ 7090 #endif 7091 #if !TARGET_BIG_ENDIAN 7092 msr |= (target_ulong)1 << MSR_LE; /* Little-endian user mode */ 7093 if (!((env->msr_mask >> MSR_LE) & 1)) { 7094 fprintf(stderr, "Selected CPU does not support little-endian.\n"); 7095 exit(1); 7096 } 7097 #endif 7098 #endif 7099 7100 #if defined(TARGET_PPC64) 7101 if (mmu_is_64bit(env->mmu_model)) { 7102 msr |= (1ULL << MSR_SF); 7103 } 7104 #endif 7105 7106 hreg_store_msr(env, msr, 1); 7107 7108 #if !defined(CONFIG_USER_ONLY) 7109 env->nip = env->hreset_vector | env->excp_prefix; 7110 7111 if (tcg_enabled()) { 7112 if (env->mmu_model != POWERPC_MMU_REAL) { 7113 ppc_tlb_invalidate_all(env); 7114 } 7115 pmu_mmcr01_updated(env); 7116 } 7117 7118 /* clean any pending stop state */ 7119 env->resume_as_sreset = 0; 7120 #endif 7121 hreg_compute_hflags(env); 7122 env->reserve_addr = (target_ulong)-1ULL; 7123 /* Be sure no exception or interrupt is pending */ 7124 env->pending_interrupts = 0; 7125 s->exception_index = POWERPC_EXCP_NONE; 7126 env->error_code = 0; 7127 ppc_irq_reset(cpu); 7128 7129 /* tininess for underflow is detected before rounding */ 7130 set_float_detect_tininess(float_tininess_before_rounding, 7131 &env->fp_status); 7132 7133 for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) { 7134 ppc_spr_t *spr = &env->spr_cb[i]; 7135 7136 if (!spr->name) { 7137 continue; 7138 } 7139 env->spr[i] = spr->default_value; 7140 } 7141 } 7142 7143 #ifndef CONFIG_USER_ONLY 7144 7145 static bool ppc_cpu_is_big_endian(CPUState *cs) 7146 { 7147 PowerPCCPU *cpu = POWERPC_CPU(cs); 7148 CPUPPCState *env = &cpu->env; 7149 7150 cpu_synchronize_state(cs); 7151 7152 return !FIELD_EX64(env->msr, MSR, LE); 7153 } 7154 7155 static bool ppc_get_irq_stats(InterruptStatsProvider *obj, 7156 uint64_t **irq_counts, unsigned int *nb_irqs) 7157 { 7158 CPUPPCState *env = &POWERPC_CPU(obj)->env; 7159 7160 *irq_counts = env->excp_stats; 7161 *nb_irqs = ARRAY_SIZE(env->excp_stats); 7162 return true; 7163 } 7164 7165 #ifdef CONFIG_TCG 7166 static void ppc_cpu_exec_enter(CPUState *cs) 7167 { 7168 PowerPCCPU *cpu = POWERPC_CPU(cs); 7169 7170 if (cpu->vhyp) { 7171 PPCVirtualHypervisorClass *vhc = 7172 PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp); 7173 vhc->cpu_exec_enter(cpu->vhyp, cpu); 7174 } 7175 } 7176 7177 static void ppc_cpu_exec_exit(CPUState *cs) 7178 { 7179 PowerPCCPU *cpu = POWERPC_CPU(cs); 7180 7181 if (cpu->vhyp) { 7182 PPCVirtualHypervisorClass *vhc = 7183 PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp); 7184 vhc->cpu_exec_exit(cpu->vhyp, cpu); 7185 } 7186 } 7187 #endif /* CONFIG_TCG */ 7188 7189 #endif /* !CONFIG_USER_ONLY */ 7190 7191 static void ppc_cpu_instance_init(Object *obj) 7192 { 7193 PowerPCCPU *cpu = POWERPC_CPU(obj); 7194 PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); 7195 CPUPPCState *env = &cpu->env; 7196 7197 cpu_set_cpustate_pointers(cpu); 7198 cpu->vcpu_id = UNASSIGNED_CPU_INDEX; 7199 7200 env->msr_mask = pcc->msr_mask; 7201 env->mmu_model = pcc->mmu_model; 7202 env->excp_model = pcc->excp_model; 7203 env->bus_model = pcc->bus_model; 7204 env->insns_flags = pcc->insns_flags; 7205 env->insns_flags2 = pcc->insns_flags2; 7206 env->flags = pcc->flags; 7207 env->bfd_mach = pcc->bfd_mach; 7208 env->check_pow = pcc->check_pow; 7209 7210 /* 7211 * Mark HV mode as supported if the CPU has an MSR_HV bit in the 7212 * msr_mask. The mask can later be cleared by PAPR mode but the hv 7213 * mode support will remain, thus enforcing that we cannot use 7214 * priv. instructions in guest in PAPR mode. For 970 we currently 7215 * simply don't set HV in msr_mask thus simulating an "Apple mode" 7216 * 970. If we ever want to support 970 HV mode, we'll have to add 7217 * a processor attribute of some sort. 7218 */ 7219 #if !defined(CONFIG_USER_ONLY) 7220 env->has_hv_mode = !!(env->msr_mask & MSR_HVB); 7221 #endif 7222 7223 ppc_hash64_init(cpu); 7224 } 7225 7226 static void ppc_cpu_instance_finalize(Object *obj) 7227 { 7228 PowerPCCPU *cpu = POWERPC_CPU(obj); 7229 7230 ppc_hash64_finalize(cpu); 7231 } 7232 7233 static bool ppc_pvr_match_default(PowerPCCPUClass *pcc, uint32_t pvr, bool best) 7234 { 7235 return pcc->pvr == pvr; 7236 } 7237 7238 static void ppc_disas_set_info(CPUState *cs, disassemble_info *info) 7239 { 7240 PowerPCCPU *cpu = POWERPC_CPU(cs); 7241 CPUPPCState *env = &cpu->env; 7242 7243 if ((env->hflags >> MSR_LE) & 1) { 7244 info->endian = BFD_ENDIAN_LITTLE; 7245 } 7246 info->mach = env->bfd_mach; 7247 if (!env->bfd_mach) { 7248 #ifdef TARGET_PPC64 7249 info->mach = bfd_mach_ppc64; 7250 #else 7251 info->mach = bfd_mach_ppc; 7252 #endif 7253 } 7254 7255 info->cap_arch = CS_ARCH_PPC; 7256 #ifdef TARGET_PPC64 7257 info->cap_mode = CS_MODE_64; 7258 #endif 7259 } 7260 7261 static Property ppc_cpu_properties[] = { 7262 DEFINE_PROP_BOOL("pre-2.8-migration", PowerPCCPU, pre_2_8_migration, false), 7263 DEFINE_PROP_BOOL("pre-2.10-migration", PowerPCCPU, pre_2_10_migration, 7264 false), 7265 DEFINE_PROP_BOOL("pre-3.0-migration", PowerPCCPU, pre_3_0_migration, 7266 false), 7267 DEFINE_PROP_END_OF_LIST(), 7268 }; 7269 7270 #ifndef CONFIG_USER_ONLY 7271 #include "hw/core/sysemu-cpu-ops.h" 7272 7273 static const struct SysemuCPUOps ppc_sysemu_ops = { 7274 .get_phys_page_debug = ppc_cpu_get_phys_page_debug, 7275 .write_elf32_note = ppc32_cpu_write_elf32_note, 7276 .write_elf64_note = ppc64_cpu_write_elf64_note, 7277 .virtio_is_big_endian = ppc_cpu_is_big_endian, 7278 .legacy_vmsd = &vmstate_ppc_cpu, 7279 }; 7280 #endif 7281 7282 #ifdef CONFIG_TCG 7283 #include "hw/core/tcg-cpu-ops.h" 7284 7285 static const struct TCGCPUOps ppc_tcg_ops = { 7286 .initialize = ppc_translate_init, 7287 .restore_state_to_opc = ppc_restore_state_to_opc, 7288 7289 #ifdef CONFIG_USER_ONLY 7290 .record_sigsegv = ppc_cpu_record_sigsegv, 7291 #else 7292 .tlb_fill = ppc_cpu_tlb_fill, 7293 .cpu_exec_interrupt = ppc_cpu_exec_interrupt, 7294 .do_interrupt = ppc_cpu_do_interrupt, 7295 .cpu_exec_enter = ppc_cpu_exec_enter, 7296 .cpu_exec_exit = ppc_cpu_exec_exit, 7297 .do_unaligned_access = ppc_cpu_do_unaligned_access, 7298 #endif /* !CONFIG_USER_ONLY */ 7299 }; 7300 #endif /* CONFIG_TCG */ 7301 7302 static void ppc_cpu_class_init(ObjectClass *oc, void *data) 7303 { 7304 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 7305 CPUClass *cc = CPU_CLASS(oc); 7306 DeviceClass *dc = DEVICE_CLASS(oc); 7307 ResettableClass *rc = RESETTABLE_CLASS(oc); 7308 7309 device_class_set_parent_realize(dc, ppc_cpu_realize, 7310 &pcc->parent_realize); 7311 device_class_set_parent_unrealize(dc, ppc_cpu_unrealize, 7312 &pcc->parent_unrealize); 7313 pcc->pvr_match = ppc_pvr_match_default; 7314 device_class_set_props(dc, ppc_cpu_properties); 7315 7316 resettable_class_set_parent_phases(rc, NULL, ppc_cpu_reset_hold, NULL, 7317 &pcc->parent_phases); 7318 7319 cc->class_by_name = ppc_cpu_class_by_name; 7320 cc->has_work = ppc_cpu_has_work; 7321 cc->dump_state = ppc_cpu_dump_state; 7322 cc->set_pc = ppc_cpu_set_pc; 7323 cc->get_pc = ppc_cpu_get_pc; 7324 cc->gdb_read_register = ppc_cpu_gdb_read_register; 7325 cc->gdb_write_register = ppc_cpu_gdb_write_register; 7326 #ifndef CONFIG_USER_ONLY 7327 cc->sysemu_ops = &ppc_sysemu_ops; 7328 INTERRUPT_STATS_PROVIDER_CLASS(oc)->get_statistics = ppc_get_irq_stats; 7329 #endif 7330 7331 cc->gdb_num_core_regs = 71; 7332 #ifndef CONFIG_USER_ONLY 7333 cc->gdb_get_dynamic_xml = ppc_gdb_get_dynamic_xml; 7334 #endif 7335 #ifdef USE_APPLE_GDB 7336 cc->gdb_read_register = ppc_cpu_gdb_read_register_apple; 7337 cc->gdb_write_register = ppc_cpu_gdb_write_register_apple; 7338 cc->gdb_num_core_regs = 71 + 32; 7339 #endif 7340 7341 cc->gdb_arch_name = ppc_gdb_arch_name; 7342 #if defined(TARGET_PPC64) 7343 cc->gdb_core_xml_file = "power64-core.xml"; 7344 #else 7345 cc->gdb_core_xml_file = "power-core.xml"; 7346 #endif 7347 cc->disas_set_info = ppc_disas_set_info; 7348 7349 dc->fw_name = "PowerPC,UNKNOWN"; 7350 7351 #ifdef CONFIG_TCG 7352 cc->tcg_ops = &ppc_tcg_ops; 7353 #endif /* CONFIG_TCG */ 7354 } 7355 7356 static const TypeInfo ppc_cpu_type_info = { 7357 .name = TYPE_POWERPC_CPU, 7358 .parent = TYPE_CPU, 7359 .instance_size = sizeof(PowerPCCPU), 7360 .instance_align = __alignof__(PowerPCCPU), 7361 .instance_init = ppc_cpu_instance_init, 7362 .instance_finalize = ppc_cpu_instance_finalize, 7363 .abstract = true, 7364 .class_size = sizeof(PowerPCCPUClass), 7365 .class_init = ppc_cpu_class_init, 7366 #ifndef CONFIG_USER_ONLY 7367 .interfaces = (InterfaceInfo[]) { 7368 { TYPE_INTERRUPT_STATS_PROVIDER }, 7369 { } 7370 }, 7371 #endif 7372 }; 7373 7374 #ifndef CONFIG_USER_ONLY 7375 static const TypeInfo ppc_vhyp_type_info = { 7376 .name = TYPE_PPC_VIRTUAL_HYPERVISOR, 7377 .parent = TYPE_INTERFACE, 7378 .class_size = sizeof(PPCVirtualHypervisorClass), 7379 }; 7380 #endif 7381 7382 static void ppc_cpu_register_types(void) 7383 { 7384 type_register_static(&ppc_cpu_type_info); 7385 #ifndef CONFIG_USER_ONLY 7386 type_register_static(&ppc_vhyp_type_info); 7387 #endif 7388 } 7389 7390 void ppc_cpu_dump_state(CPUState *cs, FILE *f, int flags) 7391 { 7392 #define RGPL 4 7393 #define RFPL 4 7394 7395 PowerPCCPU *cpu = POWERPC_CPU(cs); 7396 CPUPPCState *env = &cpu->env; 7397 int i; 7398 7399 qemu_fprintf(f, "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " CTR " 7400 TARGET_FMT_lx " XER " TARGET_FMT_lx " CPU#%d\n", 7401 env->nip, env->lr, env->ctr, cpu_read_xer(env), 7402 cs->cpu_index); 7403 qemu_fprintf(f, "MSR " TARGET_FMT_lx " HID0 " TARGET_FMT_lx " HF " 7404 "%08x iidx %d didx %d\n", 7405 env->msr, env->spr[SPR_HID0], env->hflags, 7406 cpu_mmu_index(env, true), cpu_mmu_index(env, false)); 7407 #if !defined(CONFIG_USER_ONLY) 7408 if (env->tb_env) { 7409 qemu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64 7410 " DECR " TARGET_FMT_lu "\n", cpu_ppc_load_tbu(env), 7411 cpu_ppc_load_tbl(env), cpu_ppc_load_decr(env)); 7412 } 7413 #else 7414 qemu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64 "\n", cpu_ppc_load_tbu(env), 7415 cpu_ppc_load_tbl(env)); 7416 #endif 7417 for (i = 0; i < 32; i++) { 7418 if ((i & (RGPL - 1)) == 0) { 7419 qemu_fprintf(f, "GPR%02d", i); 7420 } 7421 qemu_fprintf(f, " %016" PRIx64, ppc_dump_gpr(env, i)); 7422 if ((i & (RGPL - 1)) == (RGPL - 1)) { 7423 qemu_fprintf(f, "\n"); 7424 } 7425 } 7426 qemu_fprintf(f, "CR "); 7427 for (i = 0; i < 8; i++) 7428 qemu_fprintf(f, "%01x", env->crf[i]); 7429 qemu_fprintf(f, " ["); 7430 for (i = 0; i < 8; i++) { 7431 char a = '-'; 7432 if (env->crf[i] & 0x08) { 7433 a = 'L'; 7434 } else if (env->crf[i] & 0x04) { 7435 a = 'G'; 7436 } else if (env->crf[i] & 0x02) { 7437 a = 'E'; 7438 } 7439 qemu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' '); 7440 } 7441 qemu_fprintf(f, " ] RES %03x@" TARGET_FMT_lx "\n", 7442 (int)env->reserve_length, env->reserve_addr); 7443 7444 if (flags & CPU_DUMP_FPU) { 7445 for (i = 0; i < 32; i++) { 7446 if ((i & (RFPL - 1)) == 0) { 7447 qemu_fprintf(f, "FPR%02d", i); 7448 } 7449 qemu_fprintf(f, " %016" PRIx64, *cpu_fpr_ptr(env, i)); 7450 if ((i & (RFPL - 1)) == (RFPL - 1)) { 7451 qemu_fprintf(f, "\n"); 7452 } 7453 } 7454 qemu_fprintf(f, "FPSCR " TARGET_FMT_lx "\n", env->fpscr); 7455 } 7456 7457 #if !defined(CONFIG_USER_ONLY) 7458 qemu_fprintf(f, " SRR0 " TARGET_FMT_lx " SRR1 " TARGET_FMT_lx 7459 " PVR " TARGET_FMT_lx " VRSAVE " TARGET_FMT_lx "\n", 7460 env->spr[SPR_SRR0], env->spr[SPR_SRR1], 7461 env->spr[SPR_PVR], env->spr[SPR_VRSAVE]); 7462 7463 qemu_fprintf(f, "SPRG0 " TARGET_FMT_lx " SPRG1 " TARGET_FMT_lx 7464 " SPRG2 " TARGET_FMT_lx " SPRG3 " TARGET_FMT_lx "\n", 7465 env->spr[SPR_SPRG0], env->spr[SPR_SPRG1], 7466 env->spr[SPR_SPRG2], env->spr[SPR_SPRG3]); 7467 7468 qemu_fprintf(f, "SPRG4 " TARGET_FMT_lx " SPRG5 " TARGET_FMT_lx 7469 " SPRG6 " TARGET_FMT_lx " SPRG7 " TARGET_FMT_lx "\n", 7470 env->spr[SPR_SPRG4], env->spr[SPR_SPRG5], 7471 env->spr[SPR_SPRG6], env->spr[SPR_SPRG7]); 7472 7473 switch (env->excp_model) { 7474 #if defined(TARGET_PPC64) 7475 case POWERPC_EXCP_POWER7: 7476 case POWERPC_EXCP_POWER8: 7477 case POWERPC_EXCP_POWER9: 7478 case POWERPC_EXCP_POWER10: 7479 qemu_fprintf(f, "HSRR0 " TARGET_FMT_lx " HSRR1 " TARGET_FMT_lx "\n", 7480 env->spr[SPR_HSRR0], env->spr[SPR_HSRR1]); 7481 break; 7482 #endif 7483 case POWERPC_EXCP_BOOKE: 7484 qemu_fprintf(f, "CSRR0 " TARGET_FMT_lx " CSRR1 " TARGET_FMT_lx 7485 " MCSRR0 " TARGET_FMT_lx " MCSRR1 " TARGET_FMT_lx "\n", 7486 env->spr[SPR_BOOKE_CSRR0], env->spr[SPR_BOOKE_CSRR1], 7487 env->spr[SPR_BOOKE_MCSRR0], env->spr[SPR_BOOKE_MCSRR1]); 7488 7489 qemu_fprintf(f, " TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx 7490 " ESR " TARGET_FMT_lx " DEAR " TARGET_FMT_lx "\n", 7491 env->spr[SPR_BOOKE_TCR], env->spr[SPR_BOOKE_TSR], 7492 env->spr[SPR_BOOKE_ESR], env->spr[SPR_BOOKE_DEAR]); 7493 7494 qemu_fprintf(f, " PIR " TARGET_FMT_lx " DECAR " TARGET_FMT_lx 7495 " IVPR " TARGET_FMT_lx " EPCR " TARGET_FMT_lx "\n", 7496 env->spr[SPR_BOOKE_PIR], env->spr[SPR_BOOKE_DECAR], 7497 env->spr[SPR_BOOKE_IVPR], env->spr[SPR_BOOKE_EPCR]); 7498 7499 qemu_fprintf(f, " MCSR " TARGET_FMT_lx " SPRG8 " TARGET_FMT_lx 7500 " EPR " TARGET_FMT_lx "\n", 7501 env->spr[SPR_BOOKE_MCSR], env->spr[SPR_BOOKE_SPRG8], 7502 env->spr[SPR_BOOKE_EPR]); 7503 7504 /* FSL-specific */ 7505 qemu_fprintf(f, " MCAR " TARGET_FMT_lx " PID1 " TARGET_FMT_lx 7506 " PID2 " TARGET_FMT_lx " SVR " TARGET_FMT_lx "\n", 7507 env->spr[SPR_Exxx_MCAR], env->spr[SPR_BOOKE_PID1], 7508 env->spr[SPR_BOOKE_PID2], env->spr[SPR_E500_SVR]); 7509 7510 /* 7511 * IVORs are left out as they are large and do not change often -- 7512 * they can be read with "p $ivor0", "p $ivor1", etc. 7513 */ 7514 break; 7515 case POWERPC_EXCP_40x: 7516 qemu_fprintf(f, " TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx 7517 " ESR " TARGET_FMT_lx " DEAR " TARGET_FMT_lx "\n", 7518 env->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR], 7519 env->spr[SPR_40x_ESR], env->spr[SPR_40x_DEAR]); 7520 7521 qemu_fprintf(f, " EVPR " TARGET_FMT_lx " SRR2 " TARGET_FMT_lx 7522 " SRR3 " TARGET_FMT_lx " PID " TARGET_FMT_lx "\n", 7523 env->spr[SPR_40x_EVPR], env->spr[SPR_40x_SRR2], 7524 env->spr[SPR_40x_SRR3], env->spr[SPR_40x_PID]); 7525 break; 7526 default: 7527 break; 7528 } 7529 7530 #if defined(TARGET_PPC64) 7531 if (env->flags & POWERPC_FLAG_CFAR) { 7532 qemu_fprintf(f, " CFAR " TARGET_FMT_lx"\n", env->cfar); 7533 } 7534 #endif 7535 7536 if (env->spr_cb[SPR_LPCR].name) { 7537 qemu_fprintf(f, " LPCR " TARGET_FMT_lx "\n", env->spr[SPR_LPCR]); 7538 } 7539 7540 switch (env->mmu_model) { 7541 case POWERPC_MMU_32B: 7542 case POWERPC_MMU_SOFT_6xx: 7543 #if defined(TARGET_PPC64) 7544 case POWERPC_MMU_64B: 7545 case POWERPC_MMU_2_03: 7546 case POWERPC_MMU_2_06: 7547 case POWERPC_MMU_2_07: 7548 case POWERPC_MMU_3_00: 7549 #endif 7550 if (env->spr_cb[SPR_SDR1].name) { /* SDR1 Exists */ 7551 qemu_fprintf(f, " SDR1 " TARGET_FMT_lx " ", env->spr[SPR_SDR1]); 7552 } 7553 if (env->spr_cb[SPR_PTCR].name) { /* PTCR Exists */ 7554 qemu_fprintf(f, " PTCR " TARGET_FMT_lx " ", env->spr[SPR_PTCR]); 7555 } 7556 qemu_fprintf(f, " DAR " TARGET_FMT_lx " DSISR " TARGET_FMT_lx "\n", 7557 env->spr[SPR_DAR], env->spr[SPR_DSISR]); 7558 break; 7559 case POWERPC_MMU_BOOKE206: 7560 qemu_fprintf(f, " MAS0 " TARGET_FMT_lx " MAS1 " TARGET_FMT_lx 7561 " MAS2 " TARGET_FMT_lx " MAS3 " TARGET_FMT_lx "\n", 7562 env->spr[SPR_BOOKE_MAS0], env->spr[SPR_BOOKE_MAS1], 7563 env->spr[SPR_BOOKE_MAS2], env->spr[SPR_BOOKE_MAS3]); 7564 7565 qemu_fprintf(f, " MAS4 " TARGET_FMT_lx " MAS6 " TARGET_FMT_lx 7566 " MAS7 " TARGET_FMT_lx " PID " TARGET_FMT_lx "\n", 7567 env->spr[SPR_BOOKE_MAS4], env->spr[SPR_BOOKE_MAS6], 7568 env->spr[SPR_BOOKE_MAS7], env->spr[SPR_BOOKE_PID]); 7569 7570 qemu_fprintf(f, "MMUCFG " TARGET_FMT_lx " TLB0CFG " TARGET_FMT_lx 7571 " TLB1CFG " TARGET_FMT_lx "\n", 7572 env->spr[SPR_MMUCFG], env->spr[SPR_BOOKE_TLB0CFG], 7573 env->spr[SPR_BOOKE_TLB1CFG]); 7574 break; 7575 default: 7576 break; 7577 } 7578 #endif 7579 7580 #undef RGPL 7581 #undef RFPL 7582 } 7583 type_init(ppc_cpu_register_types) 7584