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 "exec/gdbstub.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 #include "qapi/qapi-commands-machine-target.h" 44 45 #include "helper_regs.h" 46 #include "internal.h" 47 #include "spr_common.h" 48 #include "power8-pmu.h" 49 50 #ifndef CONFIG_USER_ONLY 51 #include "hw/boards.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 * EPR => SPR 702 (Power 2.04 emb) 1634 * perf => 768-783 (Power 2.04) 1635 * perf => 784-799 (Power 2.04) 1636 * PPR => SPR 896 (Power 2.04) 1637 * DABRX => 1015 (Power 2.04 hypv) 1638 * FPECR => SPR 1022 (?) 1639 * ... and more (thermal management, performance counters, ...) 1640 */ 1641 1642 /*****************************************************************************/ 1643 /* Exception vectors models */ 1644 static void init_excp_4xx_softmmu(CPUPPCState *env) 1645 { 1646 #if !defined(CONFIG_USER_ONLY) 1647 env->excp_vectors[POWERPC_EXCP_CRITICAL] = 0x00000100; 1648 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1649 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1650 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1651 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1652 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1653 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1654 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1655 env->excp_vectors[POWERPC_EXCP_PIT] = 0x00001000; 1656 env->excp_vectors[POWERPC_EXCP_FIT] = 0x00001010; 1657 env->excp_vectors[POWERPC_EXCP_WDT] = 0x00001020; 1658 env->excp_vectors[POWERPC_EXCP_DTLB] = 0x00001100; 1659 env->excp_vectors[POWERPC_EXCP_ITLB] = 0x00001200; 1660 env->excp_vectors[POWERPC_EXCP_DEBUG] = 0x00002000; 1661 env->ivor_mask = 0x0000FFF0UL; 1662 env->ivpr_mask = 0xFFFF0000UL; 1663 /* Hardware reset vector */ 1664 env->hreset_vector = 0xFFFFFFFCUL; 1665 #endif 1666 } 1667 1668 static void init_excp_MPC5xx(CPUPPCState *env) 1669 { 1670 #if !defined(CONFIG_USER_ONLY) 1671 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1672 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1673 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1674 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1675 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1676 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1677 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1678 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1679 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1680 env->excp_vectors[POWERPC_EXCP_FPA] = 0x00000E00; 1681 env->excp_vectors[POWERPC_EXCP_EMUL] = 0x00001000; 1682 env->excp_vectors[POWERPC_EXCP_DABR] = 0x00001C00; 1683 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001C00; 1684 env->excp_vectors[POWERPC_EXCP_MEXTBR] = 0x00001E00; 1685 env->excp_vectors[POWERPC_EXCP_NMEXTBR] = 0x00001F00; 1686 env->ivor_mask = 0x0000FFF0UL; 1687 env->ivpr_mask = 0xFFFF0000UL; 1688 /* Hardware reset vector */ 1689 env->hreset_vector = 0x00000100UL; 1690 #endif 1691 } 1692 1693 static void init_excp_MPC8xx(CPUPPCState *env) 1694 { 1695 #if !defined(CONFIG_USER_ONLY) 1696 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1697 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1698 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1699 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1700 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1701 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1702 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1703 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1704 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1705 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1706 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1707 env->excp_vectors[POWERPC_EXCP_FPA] = 0x00000E00; 1708 env->excp_vectors[POWERPC_EXCP_EMUL] = 0x00001000; 1709 env->excp_vectors[POWERPC_EXCP_ITLB] = 0x00001100; 1710 env->excp_vectors[POWERPC_EXCP_DTLB] = 0x00001200; 1711 env->excp_vectors[POWERPC_EXCP_ITLBE] = 0x00001300; 1712 env->excp_vectors[POWERPC_EXCP_DTLBE] = 0x00001400; 1713 env->excp_vectors[POWERPC_EXCP_DABR] = 0x00001C00; 1714 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001C00; 1715 env->excp_vectors[POWERPC_EXCP_MEXTBR] = 0x00001E00; 1716 env->excp_vectors[POWERPC_EXCP_NMEXTBR] = 0x00001F00; 1717 env->ivor_mask = 0x0000FFF0UL; 1718 env->ivpr_mask = 0xFFFF0000UL; 1719 /* Hardware reset vector */ 1720 env->hreset_vector = 0x00000100UL; 1721 #endif 1722 } 1723 1724 static void init_excp_G2(CPUPPCState *env) 1725 { 1726 #if !defined(CONFIG_USER_ONLY) 1727 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1728 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1729 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1730 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1731 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1732 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1733 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1734 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1735 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1736 env->excp_vectors[POWERPC_EXCP_CRITICAL] = 0x00000A00; 1737 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1738 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1739 env->excp_vectors[POWERPC_EXCP_IFTLB] = 0x00001000; 1740 env->excp_vectors[POWERPC_EXCP_DLTLB] = 0x00001100; 1741 env->excp_vectors[POWERPC_EXCP_DSTLB] = 0x00001200; 1742 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; 1743 env->excp_vectors[POWERPC_EXCP_SMI] = 0x00001400; 1744 /* Hardware reset vector */ 1745 env->hreset_vector = 0x00000100UL; 1746 #endif 1747 } 1748 1749 static void init_excp_e200(CPUPPCState *env, target_ulong ivpr_mask) 1750 { 1751 #if !defined(CONFIG_USER_ONLY) 1752 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000FFC; 1753 env->excp_vectors[POWERPC_EXCP_CRITICAL] = 0x00000000; 1754 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000000; 1755 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000000; 1756 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000000; 1757 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000000; 1758 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000000; 1759 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000000; 1760 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000000; 1761 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000000; 1762 env->excp_vectors[POWERPC_EXCP_APU] = 0x00000000; 1763 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000000; 1764 env->excp_vectors[POWERPC_EXCP_FIT] = 0x00000000; 1765 env->excp_vectors[POWERPC_EXCP_WDT] = 0x00000000; 1766 env->excp_vectors[POWERPC_EXCP_DTLB] = 0x00000000; 1767 env->excp_vectors[POWERPC_EXCP_ITLB] = 0x00000000; 1768 env->excp_vectors[POWERPC_EXCP_DEBUG] = 0x00000000; 1769 /* 1770 * These two are the same IVOR as POWERPC_EXCP_VPU and 1771 * POWERPC_EXCP_VPUA. We deal with that when dispatching at 1772 * powerpc_excp(). 1773 */ 1774 env->excp_vectors[POWERPC_EXCP_SPEU] = 0x00000000; 1775 env->excp_vectors[POWERPC_EXCP_EFPDI] = 0x00000000; 1776 1777 env->excp_vectors[POWERPC_EXCP_EFPRI] = 0x00000000; 1778 env->ivor_mask = 0x0000FFF7UL; 1779 env->ivpr_mask = ivpr_mask; 1780 /* Hardware reset vector */ 1781 env->hreset_vector = 0xFFFFFFFCUL; 1782 #endif 1783 } 1784 1785 static void init_excp_BookE(CPUPPCState *env) 1786 { 1787 #if !defined(CONFIG_USER_ONLY) 1788 env->excp_vectors[POWERPC_EXCP_CRITICAL] = 0x00000000; 1789 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000000; 1790 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000000; 1791 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000000; 1792 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000000; 1793 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000000; 1794 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000000; 1795 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000000; 1796 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000000; 1797 env->excp_vectors[POWERPC_EXCP_APU] = 0x00000000; 1798 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000000; 1799 env->excp_vectors[POWERPC_EXCP_FIT] = 0x00000000; 1800 env->excp_vectors[POWERPC_EXCP_WDT] = 0x00000000; 1801 env->excp_vectors[POWERPC_EXCP_DTLB] = 0x00000000; 1802 env->excp_vectors[POWERPC_EXCP_ITLB] = 0x00000000; 1803 env->excp_vectors[POWERPC_EXCP_DEBUG] = 0x00000000; 1804 env->ivor_mask = 0x0000FFF0UL; 1805 env->ivpr_mask = 0xFFFF0000UL; 1806 /* Hardware reset vector */ 1807 env->hreset_vector = 0xFFFFFFFCUL; 1808 #endif 1809 } 1810 1811 static void init_excp_603(CPUPPCState *env) 1812 { 1813 #if !defined(CONFIG_USER_ONLY) 1814 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1815 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1816 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1817 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1818 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1819 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1820 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1821 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1822 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1823 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1824 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1825 env->excp_vectors[POWERPC_EXCP_IFTLB] = 0x00001000; 1826 env->excp_vectors[POWERPC_EXCP_DLTLB] = 0x00001100; 1827 env->excp_vectors[POWERPC_EXCP_DSTLB] = 0x00001200; 1828 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; 1829 env->excp_vectors[POWERPC_EXCP_SMI] = 0x00001400; 1830 /* Hardware reset vector */ 1831 env->hreset_vector = 0x00000100UL; 1832 #endif 1833 } 1834 1835 static void init_excp_604(CPUPPCState *env) 1836 { 1837 #if !defined(CONFIG_USER_ONLY) 1838 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1839 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1840 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1841 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1842 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1843 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1844 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1845 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1846 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1847 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1848 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1849 env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00; 1850 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; 1851 env->excp_vectors[POWERPC_EXCP_SMI] = 0x00001400; 1852 /* Hardware reset vector */ 1853 env->hreset_vector = 0x00000100UL; 1854 #endif 1855 } 1856 1857 static void init_excp_7x0(CPUPPCState *env) 1858 { 1859 #if !defined(CONFIG_USER_ONLY) 1860 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1861 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1862 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1863 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1864 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1865 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1866 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1867 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1868 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1869 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1870 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1871 env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00; 1872 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; 1873 env->excp_vectors[POWERPC_EXCP_SMI] = 0x00001400; 1874 env->excp_vectors[POWERPC_EXCP_THERM] = 0x00001700; 1875 /* Hardware reset vector */ 1876 env->hreset_vector = 0x00000100UL; 1877 #endif 1878 } 1879 1880 static void init_excp_750cl(CPUPPCState *env) 1881 { 1882 #if !defined(CONFIG_USER_ONLY) 1883 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1884 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1885 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1886 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1887 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1888 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1889 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1890 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1891 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1892 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1893 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1894 env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00; 1895 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; 1896 env->excp_vectors[POWERPC_EXCP_SMI] = 0x00001400; 1897 /* Hardware reset vector */ 1898 env->hreset_vector = 0x00000100UL; 1899 #endif 1900 } 1901 1902 static void init_excp_750cx(CPUPPCState *env) 1903 { 1904 #if !defined(CONFIG_USER_ONLY) 1905 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1906 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1907 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1908 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1909 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1910 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1911 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1912 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1913 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1914 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1915 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1916 env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00; 1917 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; 1918 env->excp_vectors[POWERPC_EXCP_THERM] = 0x00001700; 1919 /* Hardware reset vector */ 1920 env->hreset_vector = 0x00000100UL; 1921 #endif 1922 } 1923 1924 /* XXX: Check if this is correct */ 1925 static void init_excp_7x5(CPUPPCState *env) 1926 { 1927 #if !defined(CONFIG_USER_ONLY) 1928 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1929 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1930 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1931 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1932 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1933 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1934 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1935 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1936 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1937 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1938 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1939 env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00; 1940 env->excp_vectors[POWERPC_EXCP_IFTLB] = 0x00001000; 1941 env->excp_vectors[POWERPC_EXCP_DLTLB] = 0x00001100; 1942 env->excp_vectors[POWERPC_EXCP_DSTLB] = 0x00001200; 1943 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; 1944 env->excp_vectors[POWERPC_EXCP_SMI] = 0x00001400; 1945 env->excp_vectors[POWERPC_EXCP_THERM] = 0x00001700; 1946 /* Hardware reset vector */ 1947 env->hreset_vector = 0x00000100UL; 1948 #endif 1949 } 1950 1951 static void init_excp_7400(CPUPPCState *env) 1952 { 1953 #if !defined(CONFIG_USER_ONLY) 1954 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1955 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1956 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1957 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1958 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1959 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1960 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1961 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1962 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1963 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1964 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1965 env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00; 1966 env->excp_vectors[POWERPC_EXCP_VPU] = 0x00000F20; 1967 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; 1968 env->excp_vectors[POWERPC_EXCP_SMI] = 0x00001400; 1969 env->excp_vectors[POWERPC_EXCP_VPUA] = 0x00001600; 1970 env->excp_vectors[POWERPC_EXCP_THERM] = 0x00001700; 1971 /* Hardware reset vector */ 1972 env->hreset_vector = 0x00000100UL; 1973 #endif 1974 } 1975 1976 static void init_excp_7450(CPUPPCState *env) 1977 { 1978 #if !defined(CONFIG_USER_ONLY) 1979 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 1980 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 1981 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 1982 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 1983 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 1984 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 1985 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 1986 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 1987 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 1988 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 1989 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 1990 env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00; 1991 env->excp_vectors[POWERPC_EXCP_VPU] = 0x00000F20; 1992 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; 1993 env->excp_vectors[POWERPC_EXCP_SMI] = 0x00001400; 1994 env->excp_vectors[POWERPC_EXCP_VPUA] = 0x00001600; 1995 /* Hardware reset vector */ 1996 env->hreset_vector = 0x00000100UL; 1997 #endif 1998 } 1999 2000 #if defined(TARGET_PPC64) 2001 static void init_excp_970(CPUPPCState *env) 2002 { 2003 #if !defined(CONFIG_USER_ONLY) 2004 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 2005 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 2006 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 2007 env->excp_vectors[POWERPC_EXCP_DSEG] = 0x00000380; 2008 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 2009 env->excp_vectors[POWERPC_EXCP_ISEG] = 0x00000480; 2010 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 2011 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 2012 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 2013 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 2014 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 2015 env->excp_vectors[POWERPC_EXCP_HDECR] = 0x00000980; 2016 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 2017 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 2018 env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00; 2019 env->excp_vectors[POWERPC_EXCP_VPU] = 0x00000F20; 2020 env->excp_vectors[POWERPC_EXCP_IABR] = 0x00001300; 2021 env->excp_vectors[POWERPC_EXCP_MAINT] = 0x00001600; 2022 env->excp_vectors[POWERPC_EXCP_VPUA] = 0x00001700; 2023 env->excp_vectors[POWERPC_EXCP_THERM] = 0x00001800; 2024 /* Hardware reset vector */ 2025 env->hreset_vector = 0x0000000000000100ULL; 2026 #endif 2027 } 2028 2029 static void init_excp_POWER7(CPUPPCState *env) 2030 { 2031 #if !defined(CONFIG_USER_ONLY) 2032 env->excp_vectors[POWERPC_EXCP_RESET] = 0x00000100; 2033 env->excp_vectors[POWERPC_EXCP_MCHECK] = 0x00000200; 2034 env->excp_vectors[POWERPC_EXCP_DSI] = 0x00000300; 2035 env->excp_vectors[POWERPC_EXCP_DSEG] = 0x00000380; 2036 env->excp_vectors[POWERPC_EXCP_ISI] = 0x00000400; 2037 env->excp_vectors[POWERPC_EXCP_ISEG] = 0x00000480; 2038 env->excp_vectors[POWERPC_EXCP_EXTERNAL] = 0x00000500; 2039 env->excp_vectors[POWERPC_EXCP_ALIGN] = 0x00000600; 2040 env->excp_vectors[POWERPC_EXCP_PROGRAM] = 0x00000700; 2041 env->excp_vectors[POWERPC_EXCP_FPU] = 0x00000800; 2042 env->excp_vectors[POWERPC_EXCP_DECR] = 0x00000900; 2043 env->excp_vectors[POWERPC_EXCP_HDECR] = 0x00000980; 2044 env->excp_vectors[POWERPC_EXCP_SYSCALL] = 0x00000C00; 2045 env->excp_vectors[POWERPC_EXCP_TRACE] = 0x00000D00; 2046 env->excp_vectors[POWERPC_EXCP_HDSI] = 0x00000E00; 2047 env->excp_vectors[POWERPC_EXCP_HISI] = 0x00000E20; 2048 env->excp_vectors[POWERPC_EXCP_HV_EMU] = 0x00000E40; 2049 env->excp_vectors[POWERPC_EXCP_HV_MAINT] = 0x00000E60; 2050 env->excp_vectors[POWERPC_EXCP_PERFM] = 0x00000F00; 2051 env->excp_vectors[POWERPC_EXCP_VPU] = 0x00000F20; 2052 env->excp_vectors[POWERPC_EXCP_VSXU] = 0x00000F40; 2053 /* Hardware reset vector */ 2054 env->hreset_vector = 0x0000000000000100ULL; 2055 #endif 2056 } 2057 2058 static void init_excp_POWER8(CPUPPCState *env) 2059 { 2060 init_excp_POWER7(env); 2061 2062 #if !defined(CONFIG_USER_ONLY) 2063 env->excp_vectors[POWERPC_EXCP_SDOOR] = 0x00000A00; 2064 env->excp_vectors[POWERPC_EXCP_FU] = 0x00000F60; 2065 env->excp_vectors[POWERPC_EXCP_HV_FU] = 0x00000F80; 2066 env->excp_vectors[POWERPC_EXCP_SDOOR_HV] = 0x00000E80; 2067 2068 /* Userland exceptions without vector value in PowerISA v3.1 */ 2069 env->excp_vectors[POWERPC_EXCP_PERFM_EBB] = 0x0; 2070 env->excp_vectors[POWERPC_EXCP_EXTERNAL_EBB] = 0x0; 2071 #endif 2072 } 2073 2074 static void init_excp_POWER9(CPUPPCState *env) 2075 { 2076 init_excp_POWER8(env); 2077 2078 #if !defined(CONFIG_USER_ONLY) 2079 env->excp_vectors[POWERPC_EXCP_HVIRT] = 0x00000EA0; 2080 env->excp_vectors[POWERPC_EXCP_SYSCALL_VECTORED] = 0x00017000; 2081 #endif 2082 } 2083 2084 static void init_excp_POWER10(CPUPPCState *env) 2085 { 2086 init_excp_POWER9(env); 2087 } 2088 2089 #endif 2090 2091 static int check_pow_hid0(CPUPPCState *env) 2092 { 2093 if (env->spr[SPR_HID0] & 0x00E00000) { 2094 return 1; 2095 } 2096 2097 return 0; 2098 } 2099 2100 static int check_pow_hid0_74xx(CPUPPCState *env) 2101 { 2102 if (env->spr[SPR_HID0] & 0x00600000) { 2103 return 1; 2104 } 2105 2106 return 0; 2107 } 2108 2109 static void init_proc_405(CPUPPCState *env) 2110 { 2111 register_40x_sprs(env); 2112 register_405_sprs(env); 2113 register_usprgh_sprs(env); 2114 2115 /* Memory management */ 2116 #if !defined(CONFIG_USER_ONLY) 2117 env->nb_tlb = 64; 2118 env->nb_ways = 1; 2119 env->id_tlbs = 0; 2120 env->tlb_type = TLB_EMB; 2121 #endif 2122 init_excp_4xx_softmmu(env); 2123 env->dcache_line_size = 32; 2124 env->icache_line_size = 32; 2125 /* Allocate hardware IRQ controller */ 2126 ppc40x_irq_init(env_archcpu(env)); 2127 2128 SET_FIT_PERIOD(8, 12, 16, 20); 2129 SET_WDT_PERIOD(16, 20, 24, 28); 2130 } 2131 2132 POWERPC_FAMILY(405)(ObjectClass *oc, void *data) 2133 { 2134 DeviceClass *dc = DEVICE_CLASS(oc); 2135 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2136 2137 dc->desc = "PowerPC 405"; 2138 pcc->init_proc = init_proc_405; 2139 pcc->check_pow = check_pow_nocheck; 2140 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 2141 PPC_DCR | PPC_WRTEE | 2142 PPC_CACHE | PPC_CACHE_ICBI | PPC_40x_ICBT | 2143 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 2144 PPC_MEM_SYNC | PPC_MEM_EIEIO | 2145 PPC_40x_TLB | PPC_MEM_TLBIA | PPC_MEM_TLBSYNC | 2146 PPC_4xx_COMMON | PPC_405_MAC | PPC_40x_EXCP; 2147 pcc->msr_mask = (1ull << MSR_WE) | 2148 (1ull << MSR_CE) | 2149 (1ull << MSR_EE) | 2150 (1ull << MSR_PR) | 2151 (1ull << MSR_FP) | 2152 (1ull << MSR_ME) | 2153 (1ull << MSR_DWE) | 2154 (1ull << MSR_DE) | 2155 (1ull << MSR_IR) | 2156 (1ull << MSR_DR); 2157 pcc->mmu_model = POWERPC_MMU_SOFT_4xx; 2158 pcc->excp_model = POWERPC_EXCP_40x; 2159 pcc->bus_model = PPC_FLAGS_INPUT_405; 2160 pcc->bfd_mach = bfd_mach_ppc_403; 2161 pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DWE | 2162 POWERPC_FLAG_DE | POWERPC_FLAG_BUS_CLK; 2163 } 2164 2165 static void init_proc_440EP(CPUPPCState *env) 2166 { 2167 register_BookE_sprs(env, 0x000000000000FFFFULL); 2168 register_440_sprs(env); 2169 register_usprgh_sprs(env); 2170 2171 spr_register(env, SPR_BOOKE_MCSR, "MCSR", 2172 SPR_NOACCESS, SPR_NOACCESS, 2173 &spr_read_generic, &spr_write_generic, 2174 0x00000000); 2175 spr_register(env, SPR_BOOKE_MCSRR0, "MCSRR0", 2176 SPR_NOACCESS, SPR_NOACCESS, 2177 &spr_read_generic, &spr_write_generic, 2178 0x00000000); 2179 spr_register(env, SPR_BOOKE_MCSRR1, "MCSRR1", 2180 SPR_NOACCESS, SPR_NOACCESS, 2181 &spr_read_generic, &spr_write_generic, 2182 0x00000000); 2183 2184 spr_register(env, SPR_440_CCR1, "CCR1", 2185 SPR_NOACCESS, SPR_NOACCESS, 2186 &spr_read_generic, &spr_write_generic, 2187 0x00000000); 2188 /* Memory management */ 2189 #if !defined(CONFIG_USER_ONLY) 2190 env->nb_tlb = 64; 2191 env->nb_ways = 1; 2192 env->id_tlbs = 0; 2193 env->tlb_type = TLB_EMB; 2194 #endif 2195 init_excp_BookE(env); 2196 env->dcache_line_size = 32; 2197 env->icache_line_size = 32; 2198 ppc40x_irq_init(env_archcpu(env)); 2199 2200 SET_FIT_PERIOD(12, 16, 20, 24); 2201 SET_WDT_PERIOD(20, 24, 28, 32); 2202 } 2203 2204 POWERPC_FAMILY(440EP)(ObjectClass *oc, void *data) 2205 { 2206 DeviceClass *dc = DEVICE_CLASS(oc); 2207 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2208 2209 dc->desc = "PowerPC 440 EP"; 2210 pcc->init_proc = init_proc_440EP; 2211 pcc->check_pow = check_pow_nocheck; 2212 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | 2213 PPC_FLOAT | PPC_FLOAT_FRES | PPC_FLOAT_FSEL | 2214 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 2215 PPC_FLOAT_STFIWX | 2216 PPC_DCR | PPC_WRTEE | PPC_RFMCI | 2217 PPC_CACHE | PPC_CACHE_ICBI | 2218 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 2219 PPC_MEM_TLBSYNC | PPC_MFTB | 2220 PPC_BOOKE | PPC_4xx_COMMON | PPC_405_MAC | 2221 PPC_440_SPEC; 2222 pcc->msr_mask = (1ull << MSR_POW) | 2223 (1ull << MSR_CE) | 2224 (1ull << MSR_EE) | 2225 (1ull << MSR_PR) | 2226 (1ull << MSR_FP) | 2227 (1ull << MSR_ME) | 2228 (1ull << MSR_FE0) | 2229 (1ull << MSR_DWE) | 2230 (1ull << MSR_DE) | 2231 (1ull << MSR_FE1) | 2232 (1ull << MSR_IR) | 2233 (1ull << MSR_DR); 2234 pcc->mmu_model = POWERPC_MMU_BOOKE; 2235 pcc->excp_model = POWERPC_EXCP_BOOKE; 2236 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 2237 pcc->bfd_mach = bfd_mach_ppc_403; 2238 pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DWE | 2239 POWERPC_FLAG_DE | POWERPC_FLAG_BUS_CLK; 2240 } 2241 2242 POWERPC_FAMILY(460EX)(ObjectClass *oc, void *data) 2243 { 2244 DeviceClass *dc = DEVICE_CLASS(oc); 2245 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2246 2247 dc->desc = "PowerPC 460 EX"; 2248 pcc->init_proc = init_proc_440EP; 2249 pcc->check_pow = check_pow_nocheck; 2250 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | 2251 PPC_FLOAT | PPC_FLOAT_FRES | PPC_FLOAT_FSEL | 2252 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 2253 PPC_FLOAT_STFIWX | 2254 PPC_DCR | PPC_DCRX | PPC_WRTEE | PPC_RFMCI | 2255 PPC_CACHE | PPC_CACHE_ICBI | 2256 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 2257 PPC_MEM_TLBSYNC | PPC_MFTB | 2258 PPC_BOOKE | PPC_4xx_COMMON | PPC_405_MAC | 2259 PPC_440_SPEC; 2260 pcc->msr_mask = (1ull << MSR_POW) | 2261 (1ull << MSR_CE) | 2262 (1ull << MSR_EE) | 2263 (1ull << MSR_PR) | 2264 (1ull << MSR_FP) | 2265 (1ull << MSR_ME) | 2266 (1ull << MSR_FE0) | 2267 (1ull << MSR_DWE) | 2268 (1ull << MSR_DE) | 2269 (1ull << MSR_FE1) | 2270 (1ull << MSR_IR) | 2271 (1ull << MSR_DR); 2272 pcc->mmu_model = POWERPC_MMU_BOOKE; 2273 pcc->excp_model = POWERPC_EXCP_BOOKE; 2274 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 2275 pcc->bfd_mach = bfd_mach_ppc_403; 2276 pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DWE | 2277 POWERPC_FLAG_DE | POWERPC_FLAG_BUS_CLK; 2278 } 2279 2280 static void init_proc_440GP(CPUPPCState *env) 2281 { 2282 register_BookE_sprs(env, 0x000000000000FFFFULL); 2283 register_440_sprs(env); 2284 register_usprgh_sprs(env); 2285 2286 /* Memory management */ 2287 #if !defined(CONFIG_USER_ONLY) 2288 env->nb_tlb = 64; 2289 env->nb_ways = 1; 2290 env->id_tlbs = 0; 2291 env->tlb_type = TLB_EMB; 2292 #endif 2293 init_excp_BookE(env); 2294 env->dcache_line_size = 32; 2295 env->icache_line_size = 32; 2296 /* XXX: TODO: allocate internal IRQ controller */ 2297 2298 SET_FIT_PERIOD(12, 16, 20, 24); 2299 SET_WDT_PERIOD(20, 24, 28, 32); 2300 } 2301 2302 POWERPC_FAMILY(440GP)(ObjectClass *oc, void *data) 2303 { 2304 DeviceClass *dc = DEVICE_CLASS(oc); 2305 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2306 2307 dc->desc = "PowerPC 440 GP"; 2308 pcc->init_proc = init_proc_440GP; 2309 pcc->check_pow = check_pow_nocheck; 2310 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | 2311 PPC_DCR | PPC_DCRX | PPC_WRTEE | PPC_MFAPIDI | 2312 PPC_CACHE | PPC_CACHE_ICBI | 2313 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 2314 PPC_MEM_TLBSYNC | PPC_TLBIVA | PPC_MFTB | 2315 PPC_BOOKE | PPC_4xx_COMMON | PPC_405_MAC | 2316 PPC_440_SPEC; 2317 pcc->msr_mask = (1ull << MSR_POW) | 2318 (1ull << MSR_CE) | 2319 (1ull << MSR_EE) | 2320 (1ull << MSR_PR) | 2321 (1ull << MSR_FP) | 2322 (1ull << MSR_ME) | 2323 (1ull << MSR_FE0) | 2324 (1ull << MSR_DWE) | 2325 (1ull << MSR_DE) | 2326 (1ull << MSR_FE1) | 2327 (1ull << MSR_IR) | 2328 (1ull << MSR_DR); 2329 pcc->mmu_model = POWERPC_MMU_BOOKE; 2330 pcc->excp_model = POWERPC_EXCP_BOOKE; 2331 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 2332 pcc->bfd_mach = bfd_mach_ppc_403; 2333 pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DWE | 2334 POWERPC_FLAG_DE | POWERPC_FLAG_BUS_CLK; 2335 } 2336 2337 static void init_proc_440x5(CPUPPCState *env) 2338 { 2339 register_BookE_sprs(env, 0x000000000000FFFFULL); 2340 register_440_sprs(env); 2341 register_usprgh_sprs(env); 2342 2343 spr_register(env, SPR_BOOKE_MCSR, "MCSR", 2344 SPR_NOACCESS, SPR_NOACCESS, 2345 &spr_read_generic, &spr_write_generic, 2346 0x00000000); 2347 spr_register(env, SPR_BOOKE_MCSRR0, "MCSRR0", 2348 SPR_NOACCESS, SPR_NOACCESS, 2349 &spr_read_generic, &spr_write_generic, 2350 0x00000000); 2351 spr_register(env, SPR_BOOKE_MCSRR1, "MCSRR1", 2352 SPR_NOACCESS, SPR_NOACCESS, 2353 &spr_read_generic, &spr_write_generic, 2354 0x00000000); 2355 2356 spr_register(env, SPR_440_CCR1, "CCR1", 2357 SPR_NOACCESS, SPR_NOACCESS, 2358 &spr_read_generic, &spr_write_generic, 2359 0x00000000); 2360 /* Memory management */ 2361 #if !defined(CONFIG_USER_ONLY) 2362 env->nb_tlb = 64; 2363 env->nb_ways = 1; 2364 env->id_tlbs = 0; 2365 env->tlb_type = TLB_EMB; 2366 #endif 2367 init_excp_BookE(env); 2368 env->dcache_line_size = 32; 2369 env->icache_line_size = 32; 2370 ppc40x_irq_init(env_archcpu(env)); 2371 2372 SET_FIT_PERIOD(12, 16, 20, 24); 2373 SET_WDT_PERIOD(20, 24, 28, 32); 2374 } 2375 2376 POWERPC_FAMILY(440x5)(ObjectClass *oc, void *data) 2377 { 2378 DeviceClass *dc = DEVICE_CLASS(oc); 2379 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2380 2381 dc->desc = "PowerPC 440x5"; 2382 pcc->init_proc = init_proc_440x5; 2383 pcc->check_pow = check_pow_nocheck; 2384 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | 2385 PPC_DCR | PPC_WRTEE | PPC_RFMCI | 2386 PPC_CACHE | PPC_CACHE_ICBI | 2387 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 2388 PPC_MEM_TLBSYNC | PPC_MFTB | 2389 PPC_BOOKE | PPC_4xx_COMMON | PPC_405_MAC | 2390 PPC_440_SPEC; 2391 pcc->msr_mask = (1ull << MSR_POW) | 2392 (1ull << MSR_CE) | 2393 (1ull << MSR_EE) | 2394 (1ull << MSR_PR) | 2395 (1ull << MSR_FP) | 2396 (1ull << MSR_ME) | 2397 (1ull << MSR_FE0) | 2398 (1ull << MSR_DWE) | 2399 (1ull << MSR_DE) | 2400 (1ull << MSR_FE1) | 2401 (1ull << MSR_IR) | 2402 (1ull << MSR_DR); 2403 pcc->mmu_model = POWERPC_MMU_BOOKE; 2404 pcc->excp_model = POWERPC_EXCP_BOOKE; 2405 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 2406 pcc->bfd_mach = bfd_mach_ppc_403; 2407 pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DWE | 2408 POWERPC_FLAG_DE | POWERPC_FLAG_BUS_CLK; 2409 } 2410 2411 POWERPC_FAMILY(440x5wDFPU)(ObjectClass *oc, void *data) 2412 { 2413 DeviceClass *dc = DEVICE_CLASS(oc); 2414 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2415 2416 dc->desc = "PowerPC 440x5 with double precision FPU"; 2417 pcc->init_proc = init_proc_440x5; 2418 pcc->check_pow = check_pow_nocheck; 2419 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | 2420 PPC_FLOAT | PPC_FLOAT_FSQRT | 2421 PPC_FLOAT_STFIWX | 2422 PPC_DCR | PPC_WRTEE | PPC_RFMCI | 2423 PPC_CACHE | PPC_CACHE_ICBI | 2424 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 2425 PPC_MEM_TLBSYNC | PPC_MFTB | 2426 PPC_BOOKE | PPC_4xx_COMMON | PPC_405_MAC | 2427 PPC_440_SPEC; 2428 pcc->insns_flags2 = PPC2_FP_CVT_S64; 2429 pcc->msr_mask = (1ull << MSR_POW) | 2430 (1ull << MSR_CE) | 2431 (1ull << MSR_EE) | 2432 (1ull << MSR_PR) | 2433 (1ull << MSR_FP) | 2434 (1ull << MSR_ME) | 2435 (1ull << MSR_FE0) | 2436 (1ull << MSR_DWE) | 2437 (1ull << MSR_DE) | 2438 (1ull << MSR_FE1) | 2439 (1ull << MSR_IR) | 2440 (1ull << MSR_DR); 2441 pcc->mmu_model = POWERPC_MMU_BOOKE; 2442 pcc->excp_model = POWERPC_EXCP_BOOKE; 2443 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 2444 pcc->bfd_mach = bfd_mach_ppc_403; 2445 pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DWE | 2446 POWERPC_FLAG_DE | POWERPC_FLAG_BUS_CLK; 2447 } 2448 2449 static void init_proc_MPC5xx(CPUPPCState *env) 2450 { 2451 register_5xx_8xx_sprs(env); 2452 register_5xx_sprs(env); 2453 init_excp_MPC5xx(env); 2454 env->dcache_line_size = 32; 2455 env->icache_line_size = 32; 2456 /* XXX: TODO: allocate internal IRQ controller */ 2457 } 2458 2459 POWERPC_FAMILY(MPC5xx)(ObjectClass *oc, void *data) 2460 { 2461 DeviceClass *dc = DEVICE_CLASS(oc); 2462 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2463 2464 dc->desc = "Freescale 5xx cores (aka RCPU)"; 2465 pcc->init_proc = init_proc_MPC5xx; 2466 pcc->check_pow = check_pow_none; 2467 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | 2468 PPC_MEM_EIEIO | PPC_MEM_SYNC | 2469 PPC_CACHE_ICBI | PPC_FLOAT | PPC_FLOAT_STFIWX | 2470 PPC_MFTB; 2471 pcc->msr_mask = (1ull << MSR_ILE) | 2472 (1ull << MSR_EE) | 2473 (1ull << MSR_PR) | 2474 (1ull << MSR_FP) | 2475 (1ull << MSR_ME) | 2476 (1ull << MSR_FE0) | 2477 (1ull << MSR_SE) | 2478 (1ull << MSR_DE) | 2479 (1ull << MSR_FE1) | 2480 (1ull << MSR_EP) | 2481 (1ull << MSR_RI) | 2482 (1ull << MSR_LE); 2483 pcc->mmu_model = POWERPC_MMU_REAL; 2484 pcc->excp_model = POWERPC_EXCP_6xx; 2485 pcc->bus_model = PPC_FLAGS_INPUT_RCPU; 2486 pcc->bfd_mach = bfd_mach_ppc_505; 2487 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 2488 POWERPC_FLAG_BUS_CLK; 2489 } 2490 2491 static void init_proc_MPC8xx(CPUPPCState *env) 2492 { 2493 register_5xx_8xx_sprs(env); 2494 register_8xx_sprs(env); 2495 init_excp_MPC8xx(env); 2496 env->dcache_line_size = 32; 2497 env->icache_line_size = 32; 2498 /* XXX: TODO: allocate internal IRQ controller */ 2499 } 2500 2501 POWERPC_FAMILY(MPC8xx)(ObjectClass *oc, void *data) 2502 { 2503 DeviceClass *dc = DEVICE_CLASS(oc); 2504 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2505 2506 dc->desc = "Freescale 8xx cores (aka PowerQUICC)"; 2507 pcc->init_proc = init_proc_MPC8xx; 2508 pcc->check_pow = check_pow_none; 2509 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | 2510 PPC_MEM_EIEIO | PPC_MEM_SYNC | 2511 PPC_CACHE_ICBI | PPC_MFTB; 2512 pcc->msr_mask = (1ull << MSR_ILE) | 2513 (1ull << MSR_EE) | 2514 (1ull << MSR_PR) | 2515 (1ull << MSR_FP) | 2516 (1ull << MSR_ME) | 2517 (1ull << MSR_SE) | 2518 (1ull << MSR_DE) | 2519 (1ull << MSR_EP) | 2520 (1ull << MSR_IR) | 2521 (1ull << MSR_DR) | 2522 (1ull << MSR_RI) | 2523 (1ull << MSR_LE); 2524 pcc->mmu_model = POWERPC_MMU_MPC8xx; 2525 pcc->excp_model = POWERPC_EXCP_6xx; 2526 pcc->bus_model = PPC_FLAGS_INPUT_RCPU; 2527 pcc->bfd_mach = bfd_mach_ppc_860; 2528 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 2529 POWERPC_FLAG_BUS_CLK; 2530 } 2531 2532 /* Freescale 82xx cores (aka PowerQUICC-II) */ 2533 2534 static void init_proc_G2(CPUPPCState *env) 2535 { 2536 register_non_embedded_sprs(env); 2537 register_sdr1_sprs(env); 2538 register_G2_sprs(env); 2539 2540 /* Memory management */ 2541 register_low_BATs(env); 2542 register_high_BATs(env); 2543 register_6xx_7xx_soft_tlb(env, 64, 2); 2544 init_excp_G2(env); 2545 env->dcache_line_size = 32; 2546 env->icache_line_size = 32; 2547 /* Allocate hardware IRQ controller */ 2548 ppc6xx_irq_init(env_archcpu(env)); 2549 } 2550 2551 POWERPC_FAMILY(G2)(ObjectClass *oc, void *data) 2552 { 2553 DeviceClass *dc = DEVICE_CLASS(oc); 2554 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2555 2556 dc->desc = "PowerPC G2"; 2557 pcc->init_proc = init_proc_G2; 2558 pcc->check_pow = check_pow_hid0; 2559 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 2560 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 2561 PPC_FLOAT_STFIWX | 2562 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 2563 PPC_MEM_SYNC | PPC_MEM_EIEIO | 2564 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_6xx_TLB | 2565 PPC_SEGMENT | PPC_EXTERN; 2566 pcc->msr_mask = (1ull << MSR_POW) | 2567 (1ull << MSR_TGPR) | 2568 (1ull << MSR_EE) | 2569 (1ull << MSR_PR) | 2570 (1ull << MSR_FP) | 2571 (1ull << MSR_ME) | 2572 (1ull << MSR_FE0) | 2573 (1ull << MSR_SE) | 2574 (1ull << MSR_DE) | 2575 (1ull << MSR_FE1) | 2576 (1ull << MSR_AL) | 2577 (1ull << MSR_EP) | 2578 (1ull << MSR_IR) | 2579 (1ull << MSR_DR) | 2580 (1ull << MSR_RI); 2581 pcc->mmu_model = POWERPC_MMU_SOFT_6xx; 2582 pcc->excp_model = POWERPC_EXCP_6xx; 2583 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 2584 pcc->bfd_mach = bfd_mach_ppc_ec603e; 2585 pcc->flags = POWERPC_FLAG_TGPR | POWERPC_FLAG_SE | 2586 POWERPC_FLAG_BE | POWERPC_FLAG_BUS_CLK; 2587 } 2588 2589 POWERPC_FAMILY(G2LE)(ObjectClass *oc, void *data) 2590 { 2591 DeviceClass *dc = DEVICE_CLASS(oc); 2592 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2593 2594 dc->desc = "PowerPC G2LE"; 2595 pcc->init_proc = init_proc_G2; 2596 pcc->check_pow = check_pow_hid0; 2597 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 2598 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 2599 PPC_FLOAT_STFIWX | 2600 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 2601 PPC_MEM_SYNC | PPC_MEM_EIEIO | 2602 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_6xx_TLB | 2603 PPC_SEGMENT | PPC_EXTERN; 2604 pcc->msr_mask = (1ull << MSR_POW) | 2605 (1ull << MSR_TGPR) | 2606 (1ull << MSR_ILE) | 2607 (1ull << MSR_EE) | 2608 (1ull << MSR_PR) | 2609 (1ull << MSR_FP) | 2610 (1ull << MSR_ME) | 2611 (1ull << MSR_FE0) | 2612 (1ull << MSR_SE) | 2613 (1ull << MSR_DE) | 2614 (1ull << MSR_FE1) | 2615 (1ull << MSR_AL) | 2616 (1ull << MSR_EP) | 2617 (1ull << MSR_IR) | 2618 (1ull << MSR_DR) | 2619 (1ull << MSR_RI) | 2620 (1ull << MSR_LE); 2621 pcc->mmu_model = POWERPC_MMU_SOFT_6xx; 2622 pcc->excp_model = POWERPC_EXCP_6xx; 2623 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 2624 pcc->bfd_mach = bfd_mach_ppc_ec603e; 2625 pcc->flags = POWERPC_FLAG_TGPR | POWERPC_FLAG_SE | 2626 POWERPC_FLAG_BE | POWERPC_FLAG_BUS_CLK; 2627 } 2628 2629 static void init_proc_e200(CPUPPCState *env) 2630 { 2631 register_BookE_sprs(env, 0x000000070000FFFFULL); 2632 2633 spr_register(env, SPR_BOOKE_SPEFSCR, "SPEFSCR", 2634 &spr_read_spefscr, &spr_write_spefscr, 2635 &spr_read_spefscr, &spr_write_spefscr, 2636 0x00000000); 2637 /* Memory management */ 2638 register_BookE206_sprs(env, 0x0000005D, NULL, 0); 2639 register_usprgh_sprs(env); 2640 2641 spr_register(env, SPR_HID0, "HID0", 2642 SPR_NOACCESS, SPR_NOACCESS, 2643 &spr_read_generic, &spr_write_generic, 2644 0x00000000); 2645 2646 spr_register(env, SPR_HID1, "HID1", 2647 SPR_NOACCESS, SPR_NOACCESS, 2648 &spr_read_generic, &spr_write_generic, 2649 0x00000000); 2650 2651 spr_register(env, SPR_Exxx_ALTCTXCR, "ALTCTXCR", 2652 SPR_NOACCESS, SPR_NOACCESS, 2653 &spr_read_generic, &spr_write_generic, 2654 0x00000000); 2655 2656 spr_register(env, SPR_Exxx_BUCSR, "BUCSR", 2657 SPR_NOACCESS, SPR_NOACCESS, 2658 &spr_read_generic, &spr_write_generic, 2659 0x00000000); 2660 2661 spr_register(env, SPR_Exxx_CTXCR, "CTXCR", 2662 SPR_NOACCESS, SPR_NOACCESS, 2663 &spr_read_generic, &spr_write_generic, 2664 0x00000000); 2665 2666 spr_register(env, SPR_Exxx_DBCNT, "DBCNT", 2667 SPR_NOACCESS, SPR_NOACCESS, 2668 &spr_read_generic, &spr_write_generic, 2669 0x00000000); 2670 2671 spr_register(env, SPR_Exxx_DBCR3, "DBCR3", 2672 SPR_NOACCESS, SPR_NOACCESS, 2673 &spr_read_generic, &spr_write_generic, 2674 0x00000000); 2675 2676 spr_register(env, SPR_Exxx_L1CFG0, "L1CFG0", 2677 &spr_read_generic, SPR_NOACCESS, 2678 &spr_read_generic, SPR_NOACCESS, 2679 0x00000000); 2680 2681 spr_register(env, SPR_Exxx_L1CSR0, "L1CSR0", 2682 SPR_NOACCESS, SPR_NOACCESS, 2683 &spr_read_generic, &spr_write_generic, 2684 0x00000000); 2685 2686 spr_register(env, SPR_Exxx_L1FINV0, "L1FINV0", 2687 SPR_NOACCESS, SPR_NOACCESS, 2688 &spr_read_generic, &spr_write_generic, 2689 0x00000000); 2690 2691 spr_register(env, SPR_BOOKE_TLB0CFG, "TLB0CFG", 2692 SPR_NOACCESS, SPR_NOACCESS, 2693 &spr_read_generic, &spr_write_generic, 2694 0x00000000); 2695 2696 spr_register(env, SPR_BOOKE_TLB1CFG, "TLB1CFG", 2697 SPR_NOACCESS, SPR_NOACCESS, 2698 &spr_read_generic, &spr_write_generic, 2699 0x00000000); 2700 2701 spr_register(env, SPR_BOOKE_IAC3, "IAC3", 2702 SPR_NOACCESS, SPR_NOACCESS, 2703 &spr_read_generic, &spr_write_generic, 2704 0x00000000); 2705 2706 spr_register(env, SPR_BOOKE_IAC4, "IAC4", 2707 SPR_NOACCESS, SPR_NOACCESS, 2708 &spr_read_generic, &spr_write_generic, 2709 0x00000000); 2710 2711 spr_register(env, SPR_MMUCSR0, "MMUCSR0", 2712 SPR_NOACCESS, SPR_NOACCESS, 2713 &spr_read_generic, &spr_write_generic, 2714 0x00000000); /* TOFIX */ 2715 spr_register(env, SPR_BOOKE_DSRR0, "DSRR0", 2716 SPR_NOACCESS, SPR_NOACCESS, 2717 &spr_read_generic, &spr_write_generic, 2718 0x00000000); 2719 spr_register(env, SPR_BOOKE_DSRR1, "DSRR1", 2720 SPR_NOACCESS, SPR_NOACCESS, 2721 &spr_read_generic, &spr_write_generic, 2722 0x00000000); 2723 #if !defined(CONFIG_USER_ONLY) 2724 env->nb_tlb = 64; 2725 env->nb_ways = 1; 2726 env->id_tlbs = 0; 2727 env->tlb_type = TLB_EMB; 2728 #endif 2729 init_excp_e200(env, 0xFFFF0000UL); 2730 env->dcache_line_size = 32; 2731 env->icache_line_size = 32; 2732 /* XXX: TODO: allocate internal IRQ controller */ 2733 } 2734 2735 POWERPC_FAMILY(e200)(ObjectClass *oc, void *data) 2736 { 2737 DeviceClass *dc = DEVICE_CLASS(oc); 2738 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 2739 2740 dc->desc = "e200 core"; 2741 pcc->init_proc = init_proc_e200; 2742 pcc->check_pow = check_pow_hid0; 2743 /* 2744 * XXX: unimplemented instructions: 2745 * dcblc 2746 * dcbtlst 2747 * dcbtstls 2748 * icblc 2749 * icbtls 2750 * tlbivax 2751 * all SPE multiply-accumulate instructions 2752 */ 2753 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | 2754 PPC_SPE | PPC_SPE_SINGLE | 2755 PPC_WRTEE | PPC_RFDI | 2756 PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI | 2757 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 2758 PPC_MEM_TLBSYNC | PPC_TLBIVAX | 2759 PPC_BOOKE; 2760 pcc->msr_mask = (1ull << MSR_UCLE) | 2761 (1ull << MSR_SPE) | 2762 (1ull << MSR_POW) | 2763 (1ull << MSR_CE) | 2764 (1ull << MSR_EE) | 2765 (1ull << MSR_PR) | 2766 (1ull << MSR_FP) | 2767 (1ull << MSR_ME) | 2768 (1ull << MSR_FE0) | 2769 (1ull << MSR_DWE) | 2770 (1ull << MSR_DE) | 2771 (1ull << MSR_FE1) | 2772 (1ull << MSR_IR) | 2773 (1ull << MSR_DR); 2774 pcc->mmu_model = POWERPC_MMU_BOOKE206; 2775 pcc->excp_model = POWERPC_EXCP_BOOKE; 2776 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 2777 pcc->bfd_mach = bfd_mach_ppc_860; 2778 pcc->flags = POWERPC_FLAG_SPE | POWERPC_FLAG_CE | 2779 POWERPC_FLAG_UBLE | POWERPC_FLAG_DE | 2780 POWERPC_FLAG_BUS_CLK; 2781 } 2782 2783 enum fsl_e500_version { 2784 fsl_e500v1, 2785 fsl_e500v2, 2786 fsl_e500mc, 2787 fsl_e5500, 2788 fsl_e6500, 2789 }; 2790 2791 static void init_proc_e500(CPUPPCState *env, int version) 2792 { 2793 uint32_t tlbncfg[2]; 2794 uint64_t ivor_mask; 2795 uint64_t ivpr_mask = 0xFFFF0000ULL; 2796 uint32_t l1cfg0 = 0x3800 /* 8 ways */ 2797 | 0x0020; /* 32 kb */ 2798 uint32_t l1cfg1 = 0x3800 /* 8 ways */ 2799 | 0x0020; /* 32 kb */ 2800 uint32_t mmucfg = 0; 2801 #if !defined(CONFIG_USER_ONLY) 2802 int i; 2803 #endif 2804 2805 /* 2806 * XXX The e500 doesn't implement IVOR7 and IVOR9, but doesn't 2807 * complain when accessing them. 2808 * register_BookE_sprs(env, 0x0000000F0000FD7FULL); 2809 */ 2810 switch (version) { 2811 case fsl_e500v1: 2812 case fsl_e500v2: 2813 default: 2814 ivor_mask = 0x0000000F0000FFFFULL; 2815 break; 2816 case fsl_e500mc: 2817 case fsl_e5500: 2818 ivor_mask = 0x000003FE0000FFFFULL; 2819 break; 2820 case fsl_e6500: 2821 ivor_mask = 0x000003FF0000FFFFULL; 2822 break; 2823 } 2824 register_BookE_sprs(env, ivor_mask); 2825 2826 spr_register(env, SPR_USPRG3, "USPRG3", 2827 &spr_read_ureg, SPR_NOACCESS, 2828 &spr_read_ureg, SPR_NOACCESS, 2829 0x00000000); 2830 2831 /* Processor identification */ 2832 spr_register(env, SPR_BOOKE_PIR, "PIR", 2833 SPR_NOACCESS, SPR_NOACCESS, 2834 &spr_read_generic, &spr_write_pir, 2835 0x00000000); 2836 2837 spr_register(env, SPR_BOOKE_SPEFSCR, "SPEFSCR", 2838 &spr_read_spefscr, &spr_write_spefscr, 2839 &spr_read_spefscr, &spr_write_spefscr, 2840 0x00000000); 2841 #if !defined(CONFIG_USER_ONLY) 2842 /* Memory management */ 2843 env->nb_pids = 3; 2844 env->nb_ways = 2; 2845 env->id_tlbs = 0; 2846 switch (version) { 2847 case fsl_e500v1: 2848 tlbncfg[0] = register_tlbncfg(2, 1, 1, 0, 256); 2849 tlbncfg[1] = register_tlbncfg(16, 1, 9, TLBnCFG_AVAIL | TLBnCFG_IPROT, 16); 2850 break; 2851 case fsl_e500v2: 2852 tlbncfg[0] = register_tlbncfg(4, 1, 1, 0, 512); 2853 tlbncfg[1] = register_tlbncfg(16, 1, 12, TLBnCFG_AVAIL | TLBnCFG_IPROT, 16); 2854 break; 2855 case fsl_e500mc: 2856 case fsl_e5500: 2857 tlbncfg[0] = register_tlbncfg(4, 1, 1, 0, 512); 2858 tlbncfg[1] = register_tlbncfg(64, 1, 12, TLBnCFG_AVAIL | TLBnCFG_IPROT, 64); 2859 break; 2860 case fsl_e6500: 2861 mmucfg = 0x6510B45; 2862 env->nb_pids = 1; 2863 tlbncfg[0] = 0x08052400; 2864 tlbncfg[1] = 0x40028040; 2865 break; 2866 default: 2867 cpu_abort(env_cpu(env), "Unknown CPU: " TARGET_FMT_lx "\n", 2868 env->spr[SPR_PVR]); 2869 } 2870 #endif 2871 /* Cache sizes */ 2872 switch (version) { 2873 case fsl_e500v1: 2874 case fsl_e500v2: 2875 env->dcache_line_size = 32; 2876 env->icache_line_size = 32; 2877 break; 2878 case fsl_e500mc: 2879 case fsl_e5500: 2880 env->dcache_line_size = 64; 2881 env->icache_line_size = 64; 2882 l1cfg0 |= 0x1000000; /* 64 byte cache block size */ 2883 l1cfg1 |= 0x1000000; /* 64 byte cache block size */ 2884 break; 2885 case fsl_e6500: 2886 env->dcache_line_size = 32; 2887 env->icache_line_size = 32; 2888 l1cfg0 |= 0x0F83820; 2889 l1cfg1 |= 0x0B83820; 2890 break; 2891 default: 2892 cpu_abort(env_cpu(env), "Unknown CPU: " TARGET_FMT_lx "\n", 2893 env->spr[SPR_PVR]); 2894 } 2895 register_BookE206_sprs(env, 0x000000DF, tlbncfg, mmucfg); 2896 register_usprgh_sprs(env); 2897 2898 spr_register(env, SPR_HID0, "HID0", 2899 SPR_NOACCESS, SPR_NOACCESS, 2900 &spr_read_generic, &spr_write_generic, 2901 0x00000000); 2902 2903 spr_register(env, SPR_HID1, "HID1", 2904 SPR_NOACCESS, SPR_NOACCESS, 2905 &spr_read_generic, &spr_write_generic, 2906 0x00000000); 2907 2908 spr_register(env, SPR_Exxx_BBEAR, "BBEAR", 2909 SPR_NOACCESS, SPR_NOACCESS, 2910 &spr_read_generic, &spr_write_generic, 2911 0x00000000); 2912 2913 spr_register(env, SPR_Exxx_BBTAR, "BBTAR", 2914 SPR_NOACCESS, SPR_NOACCESS, 2915 &spr_read_generic, &spr_write_generic, 2916 0x00000000); 2917 2918 spr_register(env, SPR_Exxx_MCAR, "MCAR", 2919 SPR_NOACCESS, SPR_NOACCESS, 2920 &spr_read_generic, &spr_write_generic, 2921 0x00000000); 2922 2923 spr_register(env, SPR_BOOKE_MCSR, "MCSR", 2924 SPR_NOACCESS, SPR_NOACCESS, 2925 &spr_read_generic, &spr_write_generic, 2926 0x00000000); 2927 2928 spr_register(env, SPR_Exxx_NPIDR, "NPIDR", 2929 SPR_NOACCESS, SPR_NOACCESS, 2930 &spr_read_generic, &spr_write_generic, 2931 0x00000000); 2932 2933 spr_register(env, SPR_Exxx_BUCSR, "BUCSR", 2934 SPR_NOACCESS, SPR_NOACCESS, 2935 &spr_read_generic, &spr_write_generic, 2936 0x00000000); 2937 2938 spr_register(env, SPR_Exxx_L1CFG0, "L1CFG0", 2939 &spr_read_generic, SPR_NOACCESS, 2940 &spr_read_generic, SPR_NOACCESS, 2941 l1cfg0); 2942 spr_register(env, SPR_Exxx_L1CFG1, "L1CFG1", 2943 &spr_read_generic, SPR_NOACCESS, 2944 &spr_read_generic, SPR_NOACCESS, 2945 l1cfg1); 2946 spr_register(env, SPR_Exxx_L1CSR0, "L1CSR0", 2947 SPR_NOACCESS, SPR_NOACCESS, 2948 &spr_read_generic, &spr_write_e500_l1csr0, 2949 0x00000000); 2950 spr_register(env, SPR_Exxx_L1CSR1, "L1CSR1", 2951 SPR_NOACCESS, SPR_NOACCESS, 2952 &spr_read_generic, &spr_write_e500_l1csr1, 2953 0x00000000); 2954 if (version != fsl_e500v1 && version != fsl_e500v2) { 2955 spr_register(env, SPR_Exxx_L2CSR0, "L2CSR0", 2956 SPR_NOACCESS, SPR_NOACCESS, 2957 &spr_read_generic, &spr_write_e500_l2csr0, 2958 0x00000000); 2959 } 2960 spr_register(env, SPR_BOOKE_MCSRR0, "MCSRR0", 2961 SPR_NOACCESS, SPR_NOACCESS, 2962 &spr_read_generic, &spr_write_generic, 2963 0x00000000); 2964 spr_register(env, SPR_BOOKE_MCSRR1, "MCSRR1", 2965 SPR_NOACCESS, SPR_NOACCESS, 2966 &spr_read_generic, &spr_write_generic, 2967 0x00000000); 2968 spr_register(env, SPR_MMUCSR0, "MMUCSR0", 2969 SPR_NOACCESS, SPR_NOACCESS, 2970 &spr_read_generic, &spr_write_booke206_mmucsr0, 2971 0x00000000); 2972 spr_register(env, SPR_BOOKE_EPR, "EPR", 2973 SPR_NOACCESS, SPR_NOACCESS, 2974 &spr_read_generic, SPR_NOACCESS, 2975 0x00000000); 2976 /* XXX better abstract into Emb.xxx features */ 2977 if ((version == fsl_e5500) || (version == fsl_e6500)) { 2978 spr_register(env, SPR_BOOKE_EPCR, "EPCR", 2979 SPR_NOACCESS, SPR_NOACCESS, 2980 &spr_read_generic, &spr_write_generic, 2981 0x00000000); 2982 spr_register(env, SPR_BOOKE_MAS7_MAS3, "MAS7_MAS3", 2983 SPR_NOACCESS, SPR_NOACCESS, 2984 &spr_read_mas73, &spr_write_mas73, 2985 0x00000000); 2986 ivpr_mask = (target_ulong)~0xFFFFULL; 2987 } 2988 2989 if (version == fsl_e6500) { 2990 /* Thread identification */ 2991 spr_register(env, SPR_TIR, "TIR", 2992 SPR_NOACCESS, SPR_NOACCESS, 2993 &spr_read_generic, SPR_NOACCESS, 2994 0x00000000); 2995 spr_register(env, SPR_BOOKE_TLB0PS, "TLB0PS", 2996 SPR_NOACCESS, SPR_NOACCESS, 2997 &spr_read_generic, SPR_NOACCESS, 2998 0x00000004); 2999 spr_register(env, SPR_BOOKE_TLB1PS, "TLB1PS", 3000 SPR_NOACCESS, SPR_NOACCESS, 3001 &spr_read_generic, SPR_NOACCESS, 3002 0x7FFFFFFC); 3003 } 3004 3005 #if !defined(CONFIG_USER_ONLY) 3006 env->nb_tlb = 0; 3007 env->tlb_type = TLB_MAS; 3008 for (i = 0; i < BOOKE206_MAX_TLBN; i++) { 3009 env->nb_tlb += booke206_tlb_size(env, i); 3010 } 3011 #endif 3012 3013 init_excp_e200(env, ivpr_mask); 3014 /* Allocate hardware IRQ controller */ 3015 ppce500_irq_init(env_archcpu(env)); 3016 } 3017 3018 static void init_proc_e500v1(CPUPPCState *env) 3019 { 3020 init_proc_e500(env, fsl_e500v1); 3021 } 3022 3023 POWERPC_FAMILY(e500v1)(ObjectClass *oc, void *data) 3024 { 3025 DeviceClass *dc = DEVICE_CLASS(oc); 3026 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3027 3028 dc->desc = "e500v1 core"; 3029 pcc->init_proc = init_proc_e500v1; 3030 pcc->check_pow = check_pow_hid0; 3031 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | 3032 PPC_SPE | PPC_SPE_SINGLE | 3033 PPC_WRTEE | PPC_RFDI | 3034 PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI | 3035 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 3036 PPC_MEM_TLBSYNC | PPC_TLBIVAX | PPC_MEM_SYNC; 3037 pcc->insns_flags2 = PPC2_BOOKE206; 3038 pcc->msr_mask = (1ull << MSR_UCLE) | 3039 (1ull << MSR_SPE) | 3040 (1ull << MSR_POW) | 3041 (1ull << MSR_CE) | 3042 (1ull << MSR_EE) | 3043 (1ull << MSR_PR) | 3044 (1ull << MSR_FP) | 3045 (1ull << MSR_ME) | 3046 (1ull << MSR_FE0) | 3047 (1ull << MSR_DWE) | 3048 (1ull << MSR_DE) | 3049 (1ull << MSR_FE1) | 3050 (1ull << MSR_IR) | 3051 (1ull << MSR_DR); 3052 pcc->mmu_model = POWERPC_MMU_BOOKE206; 3053 pcc->excp_model = POWERPC_EXCP_BOOKE; 3054 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 3055 pcc->bfd_mach = bfd_mach_ppc_860; 3056 pcc->flags = POWERPC_FLAG_SPE | POWERPC_FLAG_CE | 3057 POWERPC_FLAG_UBLE | POWERPC_FLAG_DE | 3058 POWERPC_FLAG_BUS_CLK; 3059 } 3060 3061 static void init_proc_e500v2(CPUPPCState *env) 3062 { 3063 init_proc_e500(env, fsl_e500v2); 3064 } 3065 3066 POWERPC_FAMILY(e500v2)(ObjectClass *oc, void *data) 3067 { 3068 DeviceClass *dc = DEVICE_CLASS(oc); 3069 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3070 3071 dc->desc = "e500v2 core"; 3072 pcc->init_proc = init_proc_e500v2; 3073 pcc->check_pow = check_pow_hid0; 3074 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | 3075 PPC_SPE | PPC_SPE_SINGLE | PPC_SPE_DOUBLE | 3076 PPC_WRTEE | PPC_RFDI | 3077 PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI | 3078 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 3079 PPC_MEM_TLBSYNC | PPC_TLBIVAX | PPC_MEM_SYNC; 3080 pcc->insns_flags2 = PPC2_BOOKE206; 3081 pcc->msr_mask = (1ull << MSR_UCLE) | 3082 (1ull << MSR_SPE) | 3083 (1ull << MSR_POW) | 3084 (1ull << MSR_CE) | 3085 (1ull << MSR_EE) | 3086 (1ull << MSR_PR) | 3087 (1ull << MSR_FP) | 3088 (1ull << MSR_ME) | 3089 (1ull << MSR_FE0) | 3090 (1ull << MSR_DWE) | 3091 (1ull << MSR_DE) | 3092 (1ull << MSR_FE1) | 3093 (1ull << MSR_IR) | 3094 (1ull << MSR_DR); 3095 pcc->mmu_model = POWERPC_MMU_BOOKE206; 3096 pcc->excp_model = POWERPC_EXCP_BOOKE; 3097 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 3098 pcc->bfd_mach = bfd_mach_ppc_860; 3099 pcc->flags = POWERPC_FLAG_SPE | POWERPC_FLAG_CE | 3100 POWERPC_FLAG_UBLE | POWERPC_FLAG_DE | 3101 POWERPC_FLAG_BUS_CLK; 3102 } 3103 3104 static void init_proc_e500mc(CPUPPCState *env) 3105 { 3106 init_proc_e500(env, fsl_e500mc); 3107 } 3108 3109 POWERPC_FAMILY(e500mc)(ObjectClass *oc, void *data) 3110 { 3111 DeviceClass *dc = DEVICE_CLASS(oc); 3112 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3113 3114 dc->desc = "e500mc core"; 3115 pcc->init_proc = init_proc_e500mc; 3116 pcc->check_pow = check_pow_none; 3117 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_MFTB | 3118 PPC_WRTEE | PPC_RFDI | PPC_RFMCI | 3119 PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI | 3120 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 3121 PPC_FLOAT | PPC_FLOAT_FRES | 3122 PPC_FLOAT_FRSQRTE | PPC_FLOAT_FSEL | 3123 PPC_FLOAT_STFIWX | PPC_WAIT | 3124 PPC_MEM_TLBSYNC | PPC_TLBIVAX | PPC_MEM_SYNC; 3125 pcc->insns_flags2 = PPC2_BOOKE206 | PPC2_PRCNTL; 3126 pcc->msr_mask = (1ull << MSR_GS) | 3127 (1ull << MSR_UCLE) | 3128 (1ull << MSR_CE) | 3129 (1ull << MSR_EE) | 3130 (1ull << MSR_PR) | 3131 (1ull << MSR_FP) | 3132 (1ull << MSR_ME) | 3133 (1ull << MSR_FE0) | 3134 (1ull << MSR_DE) | 3135 (1ull << MSR_FE1) | 3136 (1ull << MSR_IR) | 3137 (1ull << MSR_DR) | 3138 (1ull << MSR_PX) | 3139 (1ull << MSR_RI); 3140 pcc->mmu_model = POWERPC_MMU_BOOKE206; 3141 pcc->excp_model = POWERPC_EXCP_BOOKE; 3142 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 3143 /* FIXME: figure out the correct flag for e500mc */ 3144 pcc->bfd_mach = bfd_mach_ppc_e500; 3145 pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DE | 3146 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 3147 } 3148 3149 #ifdef TARGET_PPC64 3150 static void init_proc_e5500(CPUPPCState *env) 3151 { 3152 init_proc_e500(env, fsl_e5500); 3153 } 3154 3155 POWERPC_FAMILY(e5500)(ObjectClass *oc, void *data) 3156 { 3157 DeviceClass *dc = DEVICE_CLASS(oc); 3158 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3159 3160 dc->desc = "e5500 core"; 3161 pcc->init_proc = init_proc_e5500; 3162 pcc->check_pow = check_pow_none; 3163 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_MFTB | 3164 PPC_WRTEE | PPC_RFDI | PPC_RFMCI | 3165 PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI | 3166 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 3167 PPC_FLOAT | PPC_FLOAT_FRES | 3168 PPC_FLOAT_FRSQRTE | PPC_FLOAT_FSEL | 3169 PPC_FLOAT_STFIWX | PPC_WAIT | 3170 PPC_MEM_TLBSYNC | PPC_TLBIVAX | PPC_MEM_SYNC | 3171 PPC_64B | PPC_POPCNTB | PPC_POPCNTWD; 3172 pcc->insns_flags2 = PPC2_BOOKE206 | PPC2_PRCNTL | PPC2_PERM_ISA206 | 3173 PPC2_FP_CVT_S64; 3174 pcc->msr_mask = (1ull << MSR_CM) | 3175 (1ull << MSR_GS) | 3176 (1ull << MSR_UCLE) | 3177 (1ull << MSR_CE) | 3178 (1ull << MSR_EE) | 3179 (1ull << MSR_PR) | 3180 (1ull << MSR_FP) | 3181 (1ull << MSR_ME) | 3182 (1ull << MSR_FE0) | 3183 (1ull << MSR_DE) | 3184 (1ull << MSR_FE1) | 3185 (1ull << MSR_IR) | 3186 (1ull << MSR_DR) | 3187 (1ull << MSR_PX) | 3188 (1ull << MSR_RI); 3189 pcc->mmu_model = POWERPC_MMU_BOOKE206; 3190 pcc->excp_model = POWERPC_EXCP_BOOKE; 3191 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 3192 /* FIXME: figure out the correct flag for e5500 */ 3193 pcc->bfd_mach = bfd_mach_ppc_e500; 3194 pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DE | 3195 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 3196 } 3197 3198 static void init_proc_e6500(CPUPPCState *env) 3199 { 3200 init_proc_e500(env, fsl_e6500); 3201 } 3202 3203 POWERPC_FAMILY(e6500)(ObjectClass *oc, void *data) 3204 { 3205 DeviceClass *dc = DEVICE_CLASS(oc); 3206 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3207 3208 dc->desc = "e6500 core"; 3209 pcc->init_proc = init_proc_e6500; 3210 pcc->check_pow = check_pow_none; 3211 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_MFTB | 3212 PPC_WRTEE | PPC_RFDI | PPC_RFMCI | 3213 PPC_CACHE | PPC_CACHE_LOCK | PPC_CACHE_ICBI | 3214 PPC_CACHE_DCBZ | PPC_CACHE_DCBA | 3215 PPC_FLOAT | PPC_FLOAT_FRES | 3216 PPC_FLOAT_FRSQRTE | PPC_FLOAT_FSEL | 3217 PPC_FLOAT_STFIWX | PPC_WAIT | 3218 PPC_MEM_TLBSYNC | PPC_TLBIVAX | PPC_MEM_SYNC | 3219 PPC_64B | PPC_POPCNTB | PPC_POPCNTWD | PPC_ALTIVEC; 3220 pcc->insns_flags2 = PPC2_BOOKE206 | PPC2_PRCNTL | PPC2_PERM_ISA206 | 3221 PPC2_FP_CVT_S64 | PPC2_ATOMIC_ISA206; 3222 pcc->msr_mask = (1ull << MSR_CM) | 3223 (1ull << MSR_GS) | 3224 (1ull << MSR_UCLE) | 3225 (1ull << MSR_CE) | 3226 (1ull << MSR_EE) | 3227 (1ull << MSR_PR) | 3228 (1ull << MSR_FP) | 3229 (1ull << MSR_ME) | 3230 (1ull << MSR_FE0) | 3231 (1ull << MSR_DE) | 3232 (1ull << MSR_FE1) | 3233 (1ull << MSR_IS) | 3234 (1ull << MSR_DS) | 3235 (1ull << MSR_PX) | 3236 (1ull << MSR_RI) | 3237 (1ull << MSR_VR); 3238 pcc->mmu_model = POWERPC_MMU_BOOKE206; 3239 pcc->excp_model = POWERPC_EXCP_BOOKE; 3240 pcc->bus_model = PPC_FLAGS_INPUT_BookE; 3241 pcc->bfd_mach = bfd_mach_ppc_e500; 3242 pcc->flags = POWERPC_FLAG_CE | POWERPC_FLAG_DE | 3243 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_VRE; 3244 } 3245 3246 #endif 3247 3248 /* Non-embedded PowerPC */ 3249 static void init_proc_603(CPUPPCState *env) 3250 { 3251 register_non_embedded_sprs(env); 3252 register_sdr1_sprs(env); 3253 register_603_sprs(env); 3254 3255 /* Memory management */ 3256 register_low_BATs(env); 3257 register_6xx_7xx_soft_tlb(env, 64, 2); 3258 init_excp_603(env); 3259 env->dcache_line_size = 32; 3260 env->icache_line_size = 32; 3261 /* Allocate hardware IRQ controller */ 3262 ppc6xx_irq_init(env_archcpu(env)); 3263 } 3264 3265 POWERPC_FAMILY(603)(ObjectClass *oc, void *data) 3266 { 3267 DeviceClass *dc = DEVICE_CLASS(oc); 3268 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3269 3270 dc->desc = "PowerPC 603"; 3271 pcc->init_proc = init_proc_603; 3272 pcc->check_pow = check_pow_hid0; 3273 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3274 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3275 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 3276 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3277 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3278 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_6xx_TLB | 3279 PPC_SEGMENT | PPC_EXTERN; 3280 pcc->msr_mask = (1ull << MSR_POW) | 3281 (1ull << MSR_TGPR) | 3282 (1ull << MSR_ILE) | 3283 (1ull << MSR_EE) | 3284 (1ull << MSR_PR) | 3285 (1ull << MSR_FP) | 3286 (1ull << MSR_ME) | 3287 (1ull << MSR_FE0) | 3288 (1ull << MSR_SE) | 3289 (1ull << MSR_DE) | 3290 (1ull << MSR_FE1) | 3291 (1ull << MSR_EP) | 3292 (1ull << MSR_IR) | 3293 (1ull << MSR_DR) | 3294 (1ull << MSR_RI) | 3295 (1ull << MSR_LE); 3296 pcc->mmu_model = POWERPC_MMU_SOFT_6xx; 3297 pcc->excp_model = POWERPC_EXCP_6xx; 3298 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 3299 pcc->bfd_mach = bfd_mach_ppc_603; 3300 pcc->flags = POWERPC_FLAG_TGPR | POWERPC_FLAG_SE | 3301 POWERPC_FLAG_BE | POWERPC_FLAG_BUS_CLK; 3302 } 3303 3304 POWERPC_FAMILY(603E)(ObjectClass *oc, void *data) 3305 { 3306 DeviceClass *dc = DEVICE_CLASS(oc); 3307 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3308 3309 dc->desc = "PowerPC 603e"; 3310 pcc->init_proc = init_proc_603; 3311 pcc->check_pow = check_pow_hid0; 3312 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3313 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3314 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 3315 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3316 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3317 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_6xx_TLB | 3318 PPC_SEGMENT | PPC_EXTERN; 3319 pcc->msr_mask = (1ull << MSR_POW) | 3320 (1ull << MSR_TGPR) | 3321 (1ull << MSR_ILE) | 3322 (1ull << MSR_EE) | 3323 (1ull << MSR_PR) | 3324 (1ull << MSR_FP) | 3325 (1ull << MSR_ME) | 3326 (1ull << MSR_FE0) | 3327 (1ull << MSR_SE) | 3328 (1ull << MSR_DE) | 3329 (1ull << MSR_FE1) | 3330 (1ull << MSR_EP) | 3331 (1ull << MSR_IR) | 3332 (1ull << MSR_DR) | 3333 (1ull << MSR_RI) | 3334 (1ull << MSR_LE); 3335 pcc->mmu_model = POWERPC_MMU_SOFT_6xx; 3336 pcc->excp_model = POWERPC_EXCP_6xx; 3337 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 3338 pcc->bfd_mach = bfd_mach_ppc_ec603e; 3339 pcc->flags = POWERPC_FLAG_TGPR | POWERPC_FLAG_SE | 3340 POWERPC_FLAG_BE | POWERPC_FLAG_BUS_CLK; 3341 } 3342 3343 static void init_proc_e300(CPUPPCState *env) 3344 { 3345 init_proc_603(env); 3346 register_e300_sprs(env); 3347 } 3348 3349 POWERPC_FAMILY(e300)(ObjectClass *oc, void *data) 3350 { 3351 DeviceClass *dc = DEVICE_CLASS(oc); 3352 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3353 3354 dc->desc = "e300 core"; 3355 pcc->init_proc = init_proc_e300; 3356 pcc->check_pow = check_pow_hid0; 3357 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3358 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3359 PPC_FLOAT_STFIWX | 3360 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3361 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3362 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_6xx_TLB | 3363 PPC_SEGMENT | PPC_EXTERN; 3364 pcc->msr_mask = (1ull << MSR_POW) | 3365 (1ull << MSR_TGPR) | 3366 (1ull << MSR_ILE) | 3367 (1ull << MSR_EE) | 3368 (1ull << MSR_PR) | 3369 (1ull << MSR_FP) | 3370 (1ull << MSR_ME) | 3371 (1ull << MSR_FE0) | 3372 (1ull << MSR_SE) | 3373 (1ull << MSR_DE) | 3374 (1ull << MSR_FE1) | 3375 (1ull << MSR_AL) | 3376 (1ull << MSR_EP) | 3377 (1ull << MSR_IR) | 3378 (1ull << MSR_DR) | 3379 (1ull << MSR_RI) | 3380 (1ull << MSR_LE); 3381 pcc->mmu_model = POWERPC_MMU_SOFT_6xx; 3382 pcc->excp_model = POWERPC_EXCP_6xx; 3383 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 3384 pcc->bfd_mach = bfd_mach_ppc_603; 3385 pcc->flags = POWERPC_FLAG_TGPR | POWERPC_FLAG_SE | 3386 POWERPC_FLAG_BE | POWERPC_FLAG_BUS_CLK; 3387 } 3388 3389 static void init_proc_604(CPUPPCState *env) 3390 { 3391 register_non_embedded_sprs(env); 3392 register_sdr1_sprs(env); 3393 register_604_sprs(env); 3394 3395 /* Memory management */ 3396 register_low_BATs(env); 3397 init_excp_604(env); 3398 env->dcache_line_size = 32; 3399 env->icache_line_size = 32; 3400 /* Allocate hardware IRQ controller */ 3401 ppc6xx_irq_init(env_archcpu(env)); 3402 } 3403 3404 POWERPC_FAMILY(604)(ObjectClass *oc, void *data) 3405 { 3406 DeviceClass *dc = DEVICE_CLASS(oc); 3407 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3408 3409 dc->desc = "PowerPC 604"; 3410 pcc->init_proc = init_proc_604; 3411 pcc->check_pow = check_pow_nocheck; 3412 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3413 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3414 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 3415 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3416 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3417 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 3418 PPC_SEGMENT | PPC_EXTERN; 3419 pcc->msr_mask = (1ull << MSR_POW) | 3420 (1ull << MSR_ILE) | 3421 (1ull << MSR_EE) | 3422 (1ull << MSR_PR) | 3423 (1ull << MSR_FP) | 3424 (1ull << MSR_ME) | 3425 (1ull << MSR_FE0) | 3426 (1ull << MSR_SE) | 3427 (1ull << MSR_DE) | 3428 (1ull << MSR_FE1) | 3429 (1ull << MSR_EP) | 3430 (1ull << MSR_IR) | 3431 (1ull << MSR_DR) | 3432 (1ull << MSR_PMM) | 3433 (1ull << MSR_RI) | 3434 (1ull << MSR_LE); 3435 pcc->mmu_model = POWERPC_MMU_32B; 3436 pcc->excp_model = POWERPC_EXCP_6xx; 3437 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 3438 pcc->bfd_mach = bfd_mach_ppc_604; 3439 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 3440 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 3441 } 3442 3443 static void init_proc_604E(CPUPPCState *env) 3444 { 3445 init_proc_604(env); 3446 register_604e_sprs(env); 3447 } 3448 3449 POWERPC_FAMILY(604E)(ObjectClass *oc, void *data) 3450 { 3451 DeviceClass *dc = DEVICE_CLASS(oc); 3452 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3453 3454 dc->desc = "PowerPC 604E"; 3455 pcc->init_proc = init_proc_604E; 3456 pcc->check_pow = check_pow_nocheck; 3457 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3458 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3459 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 3460 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3461 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3462 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 3463 PPC_SEGMENT | PPC_EXTERN; 3464 pcc->msr_mask = (1ull << MSR_POW) | 3465 (1ull << MSR_ILE) | 3466 (1ull << MSR_EE) | 3467 (1ull << MSR_PR) | 3468 (1ull << MSR_FP) | 3469 (1ull << MSR_ME) | 3470 (1ull << MSR_FE0) | 3471 (1ull << MSR_SE) | 3472 (1ull << MSR_DE) | 3473 (1ull << MSR_FE1) | 3474 (1ull << MSR_EP) | 3475 (1ull << MSR_IR) | 3476 (1ull << MSR_DR) | 3477 (1ull << MSR_PMM) | 3478 (1ull << MSR_RI) | 3479 (1ull << MSR_LE); 3480 pcc->mmu_model = POWERPC_MMU_32B; 3481 pcc->excp_model = POWERPC_EXCP_6xx; 3482 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 3483 pcc->bfd_mach = bfd_mach_ppc_604; 3484 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 3485 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 3486 } 3487 3488 static void init_proc_740(CPUPPCState *env) 3489 { 3490 register_non_embedded_sprs(env); 3491 register_sdr1_sprs(env); 3492 register_7xx_sprs(env); 3493 /* Thermal management */ 3494 register_thrm_sprs(env); 3495 3496 /* Memory management */ 3497 register_low_BATs(env); 3498 init_excp_7x0(env); 3499 env->dcache_line_size = 32; 3500 env->icache_line_size = 32; 3501 /* Allocate hardware IRQ controller */ 3502 ppc6xx_irq_init(env_archcpu(env)); 3503 } 3504 3505 POWERPC_FAMILY(740)(ObjectClass *oc, void *data) 3506 { 3507 DeviceClass *dc = DEVICE_CLASS(oc); 3508 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3509 3510 dc->desc = "PowerPC 740"; 3511 pcc->init_proc = init_proc_740; 3512 pcc->check_pow = check_pow_hid0; 3513 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3514 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3515 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 3516 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3517 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3518 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 3519 PPC_SEGMENT | PPC_EXTERN; 3520 pcc->msr_mask = (1ull << MSR_POW) | 3521 (1ull << MSR_ILE) | 3522 (1ull << MSR_EE) | 3523 (1ull << MSR_PR) | 3524 (1ull << MSR_FP) | 3525 (1ull << MSR_ME) | 3526 (1ull << MSR_FE0) | 3527 (1ull << MSR_SE) | 3528 (1ull << MSR_DE) | 3529 (1ull << MSR_FE1) | 3530 (1ull << MSR_EP) | 3531 (1ull << MSR_IR) | 3532 (1ull << MSR_DR) | 3533 (1ull << MSR_PMM) | 3534 (1ull << MSR_RI) | 3535 (1ull << MSR_LE); 3536 pcc->mmu_model = POWERPC_MMU_32B; 3537 pcc->excp_model = POWERPC_EXCP_7xx; 3538 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 3539 pcc->bfd_mach = bfd_mach_ppc_750; 3540 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 3541 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 3542 } 3543 3544 static void init_proc_750(CPUPPCState *env) 3545 { 3546 register_non_embedded_sprs(env); 3547 register_sdr1_sprs(env); 3548 register_7xx_sprs(env); 3549 3550 spr_register(env, SPR_L2CR, "L2CR", 3551 SPR_NOACCESS, SPR_NOACCESS, 3552 &spr_read_generic, spr_access_nop, 3553 0x00000000); 3554 /* Thermal management */ 3555 register_thrm_sprs(env); 3556 3557 /* Memory management */ 3558 register_low_BATs(env); 3559 /* 3560 * XXX: high BATs are also present but are known to be bugged on 3561 * die version 1.x 3562 */ 3563 init_excp_7x0(env); 3564 env->dcache_line_size = 32; 3565 env->icache_line_size = 32; 3566 /* Allocate hardware IRQ controller */ 3567 ppc6xx_irq_init(env_archcpu(env)); 3568 } 3569 3570 POWERPC_FAMILY(750)(ObjectClass *oc, void *data) 3571 { 3572 DeviceClass *dc = DEVICE_CLASS(oc); 3573 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3574 3575 dc->desc = "PowerPC 750"; 3576 pcc->init_proc = init_proc_750; 3577 pcc->check_pow = check_pow_hid0; 3578 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3579 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3580 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 3581 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3582 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3583 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 3584 PPC_SEGMENT | PPC_EXTERN; 3585 pcc->msr_mask = (1ull << MSR_POW) | 3586 (1ull << MSR_ILE) | 3587 (1ull << MSR_EE) | 3588 (1ull << MSR_PR) | 3589 (1ull << MSR_FP) | 3590 (1ull << MSR_ME) | 3591 (1ull << MSR_FE0) | 3592 (1ull << MSR_SE) | 3593 (1ull << MSR_DE) | 3594 (1ull << MSR_FE1) | 3595 (1ull << MSR_EP) | 3596 (1ull << MSR_IR) | 3597 (1ull << MSR_DR) | 3598 (1ull << MSR_PMM) | 3599 (1ull << MSR_RI) | 3600 (1ull << MSR_LE); 3601 pcc->mmu_model = POWERPC_MMU_32B; 3602 pcc->excp_model = POWERPC_EXCP_7xx; 3603 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 3604 pcc->bfd_mach = bfd_mach_ppc_750; 3605 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 3606 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 3607 } 3608 3609 static void init_proc_750cl(CPUPPCState *env) 3610 { 3611 register_non_embedded_sprs(env); 3612 register_sdr1_sprs(env); 3613 register_7xx_sprs(env); 3614 3615 spr_register(env, SPR_L2CR, "L2CR", 3616 SPR_NOACCESS, SPR_NOACCESS, 3617 &spr_read_generic, spr_access_nop, 3618 0x00000000); 3619 /* Thermal management */ 3620 /* Those registers are fake on 750CL */ 3621 spr_register(env, SPR_THRM1, "THRM1", 3622 SPR_NOACCESS, SPR_NOACCESS, 3623 &spr_read_generic, &spr_write_generic, 3624 0x00000000); 3625 spr_register(env, SPR_THRM2, "THRM2", 3626 SPR_NOACCESS, SPR_NOACCESS, 3627 &spr_read_generic, &spr_write_generic, 3628 0x00000000); 3629 spr_register(env, SPR_THRM3, "THRM3", 3630 SPR_NOACCESS, SPR_NOACCESS, 3631 &spr_read_generic, &spr_write_generic, 3632 0x00000000); 3633 3634 spr_register(env, SPR_750_TDCL, "TDCL", 3635 SPR_NOACCESS, SPR_NOACCESS, 3636 &spr_read_generic, &spr_write_generic, 3637 0x00000000); 3638 spr_register(env, SPR_750_TDCH, "TDCH", 3639 SPR_NOACCESS, SPR_NOACCESS, 3640 &spr_read_generic, &spr_write_generic, 3641 0x00000000); 3642 /* DMA */ 3643 spr_register(env, SPR_750_WPAR, "WPAR", 3644 SPR_NOACCESS, SPR_NOACCESS, 3645 &spr_read_generic, &spr_write_generic, 3646 0x00000000); 3647 spr_register(env, SPR_750_DMAL, "DMAL", 3648 SPR_NOACCESS, SPR_NOACCESS, 3649 &spr_read_generic, &spr_write_generic, 3650 0x00000000); 3651 spr_register(env, SPR_750_DMAU, "DMAU", 3652 SPR_NOACCESS, SPR_NOACCESS, 3653 &spr_read_generic, &spr_write_generic, 3654 0x00000000); 3655 /* Hardware implementation registers */ 3656 spr_register(env, SPR_750CL_HID2, "HID2", 3657 SPR_NOACCESS, SPR_NOACCESS, 3658 &spr_read_generic, &spr_write_generic, 3659 0x00000000); 3660 3661 spr_register(env, SPR_750CL_HID4, "HID4", 3662 SPR_NOACCESS, SPR_NOACCESS, 3663 &spr_read_generic, &spr_write_generic, 3664 0x00000000); 3665 /* Quantization registers */ 3666 spr_register(env, SPR_750_GQR0, "GQR0", 3667 SPR_NOACCESS, SPR_NOACCESS, 3668 &spr_read_generic, &spr_write_generic, 3669 0x00000000); 3670 3671 spr_register(env, SPR_750_GQR1, "GQR1", 3672 SPR_NOACCESS, SPR_NOACCESS, 3673 &spr_read_generic, &spr_write_generic, 3674 0x00000000); 3675 3676 spr_register(env, SPR_750_GQR2, "GQR2", 3677 SPR_NOACCESS, SPR_NOACCESS, 3678 &spr_read_generic, &spr_write_generic, 3679 0x00000000); 3680 3681 spr_register(env, SPR_750_GQR3, "GQR3", 3682 SPR_NOACCESS, SPR_NOACCESS, 3683 &spr_read_generic, &spr_write_generic, 3684 0x00000000); 3685 3686 spr_register(env, SPR_750_GQR4, "GQR4", 3687 SPR_NOACCESS, SPR_NOACCESS, 3688 &spr_read_generic, &spr_write_generic, 3689 0x00000000); 3690 3691 spr_register(env, SPR_750_GQR5, "GQR5", 3692 SPR_NOACCESS, SPR_NOACCESS, 3693 &spr_read_generic, &spr_write_generic, 3694 0x00000000); 3695 3696 spr_register(env, SPR_750_GQR6, "GQR6", 3697 SPR_NOACCESS, SPR_NOACCESS, 3698 &spr_read_generic, &spr_write_generic, 3699 0x00000000); 3700 3701 spr_register(env, SPR_750_GQR7, "GQR7", 3702 SPR_NOACCESS, SPR_NOACCESS, 3703 &spr_read_generic, &spr_write_generic, 3704 0x00000000); 3705 /* Memory management */ 3706 register_low_BATs(env); 3707 /* PowerPC 750cl has 8 DBATs and 8 IBATs */ 3708 register_high_BATs(env); 3709 init_excp_750cl(env); 3710 env->dcache_line_size = 32; 3711 env->icache_line_size = 32; 3712 /* Allocate hardware IRQ controller */ 3713 ppc6xx_irq_init(env_archcpu(env)); 3714 } 3715 3716 POWERPC_FAMILY(750cl)(ObjectClass *oc, void *data) 3717 { 3718 DeviceClass *dc = DEVICE_CLASS(oc); 3719 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3720 3721 dc->desc = "PowerPC 750 CL"; 3722 pcc->init_proc = init_proc_750cl; 3723 pcc->check_pow = check_pow_hid0; 3724 /* 3725 * XXX: not implemented: 3726 * cache lock instructions: 3727 * dcbz_l 3728 * floating point paired instructions 3729 * psq_lux 3730 * psq_lx 3731 * psq_stux 3732 * psq_stx 3733 * ps_abs 3734 * ps_add 3735 * ps_cmpo0 3736 * ps_cmpo1 3737 * ps_cmpu0 3738 * ps_cmpu1 3739 * ps_div 3740 * ps_madd 3741 * ps_madds0 3742 * ps_madds1 3743 * ps_merge00 3744 * ps_merge01 3745 * ps_merge10 3746 * ps_merge11 3747 * ps_mr 3748 * ps_msub 3749 * ps_mul 3750 * ps_muls0 3751 * ps_muls1 3752 * ps_nabs 3753 * ps_neg 3754 * ps_nmadd 3755 * ps_nmsub 3756 * ps_res 3757 * ps_rsqrte 3758 * ps_sel 3759 * ps_sub 3760 * ps_sum0 3761 * ps_sum1 3762 */ 3763 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3764 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3765 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 3766 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3767 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3768 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 3769 PPC_SEGMENT | PPC_EXTERN; 3770 pcc->msr_mask = (1ull << MSR_POW) | 3771 (1ull << MSR_ILE) | 3772 (1ull << MSR_EE) | 3773 (1ull << MSR_PR) | 3774 (1ull << MSR_FP) | 3775 (1ull << MSR_ME) | 3776 (1ull << MSR_FE0) | 3777 (1ull << MSR_SE) | 3778 (1ull << MSR_DE) | 3779 (1ull << MSR_FE1) | 3780 (1ull << MSR_EP) | 3781 (1ull << MSR_IR) | 3782 (1ull << MSR_DR) | 3783 (1ull << MSR_PMM) | 3784 (1ull << MSR_RI) | 3785 (1ull << MSR_LE); 3786 pcc->mmu_model = POWERPC_MMU_32B; 3787 pcc->excp_model = POWERPC_EXCP_7xx; 3788 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 3789 pcc->bfd_mach = bfd_mach_ppc_750; 3790 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 3791 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 3792 } 3793 3794 static void init_proc_750cx(CPUPPCState *env) 3795 { 3796 register_non_embedded_sprs(env); 3797 register_sdr1_sprs(env); 3798 register_7xx_sprs(env); 3799 3800 spr_register(env, SPR_L2CR, "L2CR", 3801 SPR_NOACCESS, SPR_NOACCESS, 3802 &spr_read_generic, spr_access_nop, 3803 0x00000000); 3804 /* Thermal management */ 3805 register_thrm_sprs(env); 3806 3807 spr_register(env, SPR_SDA, "SDA", 3808 SPR_NOACCESS, SPR_NOACCESS, 3809 &spr_read_generic, &spr_write_generic, 3810 0x00000000); 3811 3812 /* Memory management */ 3813 register_low_BATs(env); 3814 /* PowerPC 750cx has 8 DBATs and 8 IBATs */ 3815 register_high_BATs(env); 3816 init_excp_750cx(env); 3817 env->dcache_line_size = 32; 3818 env->icache_line_size = 32; 3819 /* Allocate hardware IRQ controller */ 3820 ppc6xx_irq_init(env_archcpu(env)); 3821 } 3822 3823 POWERPC_FAMILY(750cx)(ObjectClass *oc, void *data) 3824 { 3825 DeviceClass *dc = DEVICE_CLASS(oc); 3826 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3827 3828 dc->desc = "PowerPC 750CX"; 3829 pcc->init_proc = init_proc_750cx; 3830 pcc->check_pow = check_pow_hid0; 3831 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3832 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3833 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 3834 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3835 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3836 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 3837 PPC_SEGMENT | PPC_EXTERN; 3838 pcc->msr_mask = (1ull << MSR_POW) | 3839 (1ull << MSR_ILE) | 3840 (1ull << MSR_EE) | 3841 (1ull << MSR_PR) | 3842 (1ull << MSR_FP) | 3843 (1ull << MSR_ME) | 3844 (1ull << MSR_FE0) | 3845 (1ull << MSR_SE) | 3846 (1ull << MSR_DE) | 3847 (1ull << MSR_FE1) | 3848 (1ull << MSR_EP) | 3849 (1ull << MSR_IR) | 3850 (1ull << MSR_DR) | 3851 (1ull << MSR_PMM) | 3852 (1ull << MSR_RI) | 3853 (1ull << MSR_LE); 3854 pcc->mmu_model = POWERPC_MMU_32B; 3855 pcc->excp_model = POWERPC_EXCP_7xx; 3856 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 3857 pcc->bfd_mach = bfd_mach_ppc_750; 3858 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 3859 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 3860 } 3861 3862 static void init_proc_750fx(CPUPPCState *env) 3863 { 3864 register_non_embedded_sprs(env); 3865 register_sdr1_sprs(env); 3866 register_7xx_sprs(env); 3867 3868 spr_register(env, SPR_L2CR, "L2CR", 3869 SPR_NOACCESS, SPR_NOACCESS, 3870 &spr_read_generic, spr_access_nop, 3871 0x00000000); 3872 /* Thermal management */ 3873 register_thrm_sprs(env); 3874 3875 spr_register(env, SPR_750_THRM4, "THRM4", 3876 SPR_NOACCESS, SPR_NOACCESS, 3877 &spr_read_generic, &spr_write_generic, 3878 0x00000000); 3879 /* Hardware implementation registers */ 3880 spr_register(env, SPR_750FX_HID2, "HID2", 3881 SPR_NOACCESS, SPR_NOACCESS, 3882 &spr_read_generic, &spr_write_generic, 3883 0x00000000); 3884 /* Memory management */ 3885 register_low_BATs(env); 3886 /* PowerPC 750fx & 750gx has 8 DBATs and 8 IBATs */ 3887 register_high_BATs(env); 3888 init_excp_7x0(env); 3889 env->dcache_line_size = 32; 3890 env->icache_line_size = 32; 3891 /* Allocate hardware IRQ controller */ 3892 ppc6xx_irq_init(env_archcpu(env)); 3893 } 3894 3895 POWERPC_FAMILY(750fx)(ObjectClass *oc, void *data) 3896 { 3897 DeviceClass *dc = DEVICE_CLASS(oc); 3898 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3899 3900 dc->desc = "PowerPC 750FX"; 3901 pcc->init_proc = init_proc_750fx; 3902 pcc->check_pow = check_pow_hid0; 3903 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3904 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3905 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 3906 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3907 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3908 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 3909 PPC_SEGMENT | PPC_EXTERN; 3910 pcc->msr_mask = (1ull << MSR_POW) | 3911 (1ull << MSR_ILE) | 3912 (1ull << MSR_EE) | 3913 (1ull << MSR_PR) | 3914 (1ull << MSR_FP) | 3915 (1ull << MSR_ME) | 3916 (1ull << MSR_FE0) | 3917 (1ull << MSR_SE) | 3918 (1ull << MSR_DE) | 3919 (1ull << MSR_FE1) | 3920 (1ull << MSR_EP) | 3921 (1ull << MSR_IR) | 3922 (1ull << MSR_DR) | 3923 (1ull << MSR_PMM) | 3924 (1ull << MSR_RI) | 3925 (1ull << MSR_LE); 3926 pcc->mmu_model = POWERPC_MMU_32B; 3927 pcc->excp_model = POWERPC_EXCP_7xx; 3928 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 3929 pcc->bfd_mach = bfd_mach_ppc_750; 3930 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 3931 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 3932 } 3933 3934 static void init_proc_750gx(CPUPPCState *env) 3935 { 3936 register_non_embedded_sprs(env); 3937 register_sdr1_sprs(env); 3938 register_7xx_sprs(env); 3939 3940 spr_register(env, SPR_L2CR, "L2CR", 3941 SPR_NOACCESS, SPR_NOACCESS, 3942 &spr_read_generic, spr_access_nop, 3943 0x00000000); 3944 /* Thermal management */ 3945 register_thrm_sprs(env); 3946 3947 spr_register(env, SPR_750_THRM4, "THRM4", 3948 SPR_NOACCESS, SPR_NOACCESS, 3949 &spr_read_generic, &spr_write_generic, 3950 0x00000000); 3951 /* Hardware implementation registers */ 3952 spr_register(env, SPR_750FX_HID2, "HID2", 3953 SPR_NOACCESS, SPR_NOACCESS, 3954 &spr_read_generic, &spr_write_generic, 3955 0x00000000); 3956 /* Memory management */ 3957 register_low_BATs(env); 3958 /* PowerPC 750fx & 750gx has 8 DBATs and 8 IBATs */ 3959 register_high_BATs(env); 3960 init_excp_7x0(env); 3961 env->dcache_line_size = 32; 3962 env->icache_line_size = 32; 3963 /* Allocate hardware IRQ controller */ 3964 ppc6xx_irq_init(env_archcpu(env)); 3965 } 3966 3967 POWERPC_FAMILY(750gx)(ObjectClass *oc, void *data) 3968 { 3969 DeviceClass *dc = DEVICE_CLASS(oc); 3970 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 3971 3972 dc->desc = "PowerPC 750GX"; 3973 pcc->init_proc = init_proc_750gx; 3974 pcc->check_pow = check_pow_hid0; 3975 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 3976 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 3977 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 3978 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 3979 PPC_MEM_SYNC | PPC_MEM_EIEIO | 3980 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 3981 PPC_SEGMENT | PPC_EXTERN; 3982 pcc->msr_mask = (1ull << MSR_POW) | 3983 (1ull << MSR_ILE) | 3984 (1ull << MSR_EE) | 3985 (1ull << MSR_PR) | 3986 (1ull << MSR_FP) | 3987 (1ull << MSR_ME) | 3988 (1ull << MSR_FE0) | 3989 (1ull << MSR_SE) | 3990 (1ull << MSR_DE) | 3991 (1ull << MSR_FE1) | 3992 (1ull << MSR_EP) | 3993 (1ull << MSR_IR) | 3994 (1ull << MSR_DR) | 3995 (1ull << MSR_PMM) | 3996 (1ull << MSR_RI) | 3997 (1ull << MSR_LE); 3998 pcc->mmu_model = POWERPC_MMU_32B; 3999 pcc->excp_model = POWERPC_EXCP_7xx; 4000 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 4001 pcc->bfd_mach = bfd_mach_ppc_750; 4002 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 4003 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 4004 } 4005 4006 static void init_proc_745(CPUPPCState *env) 4007 { 4008 register_non_embedded_sprs(env); 4009 register_sdr1_sprs(env); 4010 register_7xx_sprs(env); 4011 register_745_sprs(env); 4012 /* Thermal management */ 4013 register_thrm_sprs(env); 4014 4015 /* Memory management */ 4016 register_low_BATs(env); 4017 register_high_BATs(env); 4018 register_6xx_7xx_soft_tlb(env, 64, 2); 4019 init_excp_7x5(env); 4020 env->dcache_line_size = 32; 4021 env->icache_line_size = 32; 4022 /* Allocate hardware IRQ controller */ 4023 ppc6xx_irq_init(env_archcpu(env)); 4024 } 4025 4026 POWERPC_FAMILY(745)(ObjectClass *oc, void *data) 4027 { 4028 DeviceClass *dc = DEVICE_CLASS(oc); 4029 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 4030 4031 dc->desc = "PowerPC 745"; 4032 pcc->init_proc = init_proc_745; 4033 pcc->check_pow = check_pow_hid0; 4034 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 4035 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 4036 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 4037 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 4038 PPC_MEM_SYNC | PPC_MEM_EIEIO | 4039 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_6xx_TLB | 4040 PPC_SEGMENT | PPC_EXTERN; 4041 pcc->msr_mask = (1ull << MSR_POW) | 4042 (1ull << MSR_ILE) | 4043 (1ull << MSR_EE) | 4044 (1ull << MSR_PR) | 4045 (1ull << MSR_FP) | 4046 (1ull << MSR_ME) | 4047 (1ull << MSR_FE0) | 4048 (1ull << MSR_SE) | 4049 (1ull << MSR_DE) | 4050 (1ull << MSR_FE1) | 4051 (1ull << MSR_EP) | 4052 (1ull << MSR_IR) | 4053 (1ull << MSR_DR) | 4054 (1ull << MSR_PMM) | 4055 (1ull << MSR_RI) | 4056 (1ull << MSR_LE); 4057 pcc->mmu_model = POWERPC_MMU_SOFT_6xx; 4058 pcc->excp_model = POWERPC_EXCP_7xx; 4059 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 4060 pcc->bfd_mach = bfd_mach_ppc_750; 4061 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 4062 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 4063 } 4064 4065 static void init_proc_755(CPUPPCState *env) 4066 { 4067 init_proc_745(env); 4068 register_755_sprs(env); 4069 } 4070 4071 POWERPC_FAMILY(755)(ObjectClass *oc, void *data) 4072 { 4073 DeviceClass *dc = DEVICE_CLASS(oc); 4074 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 4075 4076 dc->desc = "PowerPC 755"; 4077 pcc->init_proc = init_proc_755; 4078 pcc->check_pow = check_pow_hid0; 4079 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 4080 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 4081 PPC_FLOAT_FRSQRTE | PPC_FLOAT_STFIWX | 4082 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 4083 PPC_MEM_SYNC | PPC_MEM_EIEIO | 4084 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | PPC_6xx_TLB | 4085 PPC_SEGMENT | PPC_EXTERN; 4086 pcc->msr_mask = (1ull << MSR_POW) | 4087 (1ull << MSR_ILE) | 4088 (1ull << MSR_EE) | 4089 (1ull << MSR_PR) | 4090 (1ull << MSR_FP) | 4091 (1ull << MSR_ME) | 4092 (1ull << MSR_FE0) | 4093 (1ull << MSR_SE) | 4094 (1ull << MSR_DE) | 4095 (1ull << MSR_FE1) | 4096 (1ull << MSR_EP) | 4097 (1ull << MSR_IR) | 4098 (1ull << MSR_DR) | 4099 (1ull << MSR_PMM) | 4100 (1ull << MSR_RI) | 4101 (1ull << MSR_LE); 4102 pcc->mmu_model = POWERPC_MMU_SOFT_6xx; 4103 pcc->excp_model = POWERPC_EXCP_7xx; 4104 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 4105 pcc->bfd_mach = bfd_mach_ppc_750; 4106 pcc->flags = POWERPC_FLAG_SE | POWERPC_FLAG_BE | 4107 POWERPC_FLAG_PMM | POWERPC_FLAG_BUS_CLK; 4108 } 4109 4110 static void init_proc_7400(CPUPPCState *env) 4111 { 4112 register_non_embedded_sprs(env); 4113 register_sdr1_sprs(env); 4114 register_74xx_sprs(env); 4115 vscr_init(env, 0x00010000); 4116 4117 spr_register(env, SPR_UBAMR, "UBAMR", 4118 &spr_read_ureg, SPR_NOACCESS, 4119 &spr_read_ureg, SPR_NOACCESS, 4120 0x00000000); 4121 4122 spr_register(env, SPR_MSSCR1, "MSSCR1", 4123 SPR_NOACCESS, SPR_NOACCESS, 4124 &spr_read_generic, &spr_write_generic, 4125 0x00000000); 4126 /* Thermal management */ 4127 register_thrm_sprs(env); 4128 /* Memory management */ 4129 register_low_BATs(env); 4130 init_excp_7400(env); 4131 env->dcache_line_size = 32; 4132 env->icache_line_size = 32; 4133 /* Allocate hardware IRQ controller */ 4134 ppc6xx_irq_init(env_archcpu(env)); 4135 } 4136 4137 POWERPC_FAMILY(7400)(ObjectClass *oc, void *data) 4138 { 4139 DeviceClass *dc = DEVICE_CLASS(oc); 4140 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 4141 4142 dc->desc = "PowerPC 7400 (aka G4)"; 4143 pcc->init_proc = init_proc_7400; 4144 pcc->check_pow = check_pow_hid0; 4145 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 4146 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 4147 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 4148 PPC_FLOAT_STFIWX | 4149 PPC_CACHE | PPC_CACHE_ICBI | 4150 PPC_CACHE_DCBA | PPC_CACHE_DCBZ | 4151 PPC_MEM_SYNC | PPC_MEM_EIEIO | 4152 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 4153 PPC_MEM_TLBIA | 4154 PPC_SEGMENT | PPC_EXTERN | 4155 PPC_ALTIVEC; 4156 pcc->msr_mask = (1ull << MSR_VR) | 4157 (1ull << MSR_POW) | 4158 (1ull << MSR_ILE) | 4159 (1ull << MSR_EE) | 4160 (1ull << MSR_PR) | 4161 (1ull << MSR_FP) | 4162 (1ull << MSR_ME) | 4163 (1ull << MSR_FE0) | 4164 (1ull << MSR_SE) | 4165 (1ull << MSR_DE) | 4166 (1ull << MSR_FE1) | 4167 (1ull << MSR_EP) | 4168 (1ull << MSR_IR) | 4169 (1ull << MSR_DR) | 4170 (1ull << MSR_PMM) | 4171 (1ull << MSR_RI) | 4172 (1ull << MSR_LE); 4173 pcc->mmu_model = POWERPC_MMU_32B; 4174 pcc->excp_model = POWERPC_EXCP_74xx; 4175 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 4176 pcc->bfd_mach = bfd_mach_ppc_7400; 4177 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 4178 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 4179 POWERPC_FLAG_BUS_CLK; 4180 } 4181 4182 static void init_proc_7410(CPUPPCState *env) 4183 { 4184 register_non_embedded_sprs(env); 4185 register_sdr1_sprs(env); 4186 register_74xx_sprs(env); 4187 vscr_init(env, 0x00010000); 4188 4189 spr_register(env, SPR_UBAMR, "UBAMR", 4190 &spr_read_ureg, SPR_NOACCESS, 4191 &spr_read_ureg, SPR_NOACCESS, 4192 0x00000000); 4193 /* Thermal management */ 4194 register_thrm_sprs(env); 4195 /* L2PMCR */ 4196 4197 spr_register(env, SPR_L2PMCR, "L2PMCR", 4198 SPR_NOACCESS, SPR_NOACCESS, 4199 &spr_read_generic, &spr_write_generic, 4200 0x00000000); 4201 /* LDSTDB */ 4202 4203 spr_register(env, SPR_LDSTDB, "LDSTDB", 4204 SPR_NOACCESS, SPR_NOACCESS, 4205 &spr_read_generic, &spr_write_generic, 4206 0x00000000); 4207 /* Memory management */ 4208 register_low_BATs(env); 4209 init_excp_7400(env); 4210 env->dcache_line_size = 32; 4211 env->icache_line_size = 32; 4212 /* Allocate hardware IRQ controller */ 4213 ppc6xx_irq_init(env_archcpu(env)); 4214 } 4215 4216 POWERPC_FAMILY(7410)(ObjectClass *oc, void *data) 4217 { 4218 DeviceClass *dc = DEVICE_CLASS(oc); 4219 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 4220 4221 dc->desc = "PowerPC 7410 (aka G4)"; 4222 pcc->init_proc = init_proc_7410; 4223 pcc->check_pow = check_pow_hid0; 4224 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 4225 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 4226 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 4227 PPC_FLOAT_STFIWX | 4228 PPC_CACHE | PPC_CACHE_ICBI | 4229 PPC_CACHE_DCBA | PPC_CACHE_DCBZ | 4230 PPC_MEM_SYNC | PPC_MEM_EIEIO | 4231 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 4232 PPC_MEM_TLBIA | 4233 PPC_SEGMENT | PPC_EXTERN | 4234 PPC_ALTIVEC; 4235 pcc->msr_mask = (1ull << MSR_VR) | 4236 (1ull << MSR_POW) | 4237 (1ull << MSR_ILE) | 4238 (1ull << MSR_EE) | 4239 (1ull << MSR_PR) | 4240 (1ull << MSR_FP) | 4241 (1ull << MSR_ME) | 4242 (1ull << MSR_FE0) | 4243 (1ull << MSR_SE) | 4244 (1ull << MSR_DE) | 4245 (1ull << MSR_FE1) | 4246 (1ull << MSR_EP) | 4247 (1ull << MSR_IR) | 4248 (1ull << MSR_DR) | 4249 (1ull << MSR_PMM) | 4250 (1ull << MSR_RI) | 4251 (1ull << MSR_LE); 4252 pcc->mmu_model = POWERPC_MMU_32B; 4253 pcc->excp_model = POWERPC_EXCP_74xx; 4254 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 4255 pcc->bfd_mach = bfd_mach_ppc_7400; 4256 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 4257 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 4258 POWERPC_FLAG_BUS_CLK; 4259 } 4260 4261 static void init_proc_7440(CPUPPCState *env) 4262 { 4263 register_non_embedded_sprs(env); 4264 register_sdr1_sprs(env); 4265 register_74xx_sprs(env); 4266 vscr_init(env, 0x00010000); 4267 4268 spr_register(env, SPR_UBAMR, "UBAMR", 4269 &spr_read_ureg, SPR_NOACCESS, 4270 &spr_read_ureg, SPR_NOACCESS, 4271 0x00000000); 4272 /* LDSTCR */ 4273 spr_register(env, SPR_LDSTCR, "LDSTCR", 4274 SPR_NOACCESS, SPR_NOACCESS, 4275 &spr_read_generic, &spr_write_generic, 4276 0x00000000); 4277 /* ICTRL */ 4278 spr_register(env, SPR_ICTRL, "ICTRL", 4279 SPR_NOACCESS, SPR_NOACCESS, 4280 &spr_read_generic, &spr_write_generic, 4281 0x00000000); 4282 /* MSSSR0 */ 4283 spr_register(env, SPR_MSSSR0, "MSSSR0", 4284 SPR_NOACCESS, SPR_NOACCESS, 4285 &spr_read_generic, &spr_write_generic, 4286 0x00000000); 4287 /* PMC */ 4288 spr_register(env, SPR_7XX_PMC5, "PMC5", 4289 SPR_NOACCESS, SPR_NOACCESS, 4290 &spr_read_generic, &spr_write_generic, 4291 0x00000000); 4292 4293 spr_register(env, SPR_7XX_UPMC5, "UPMC5", 4294 &spr_read_ureg, SPR_NOACCESS, 4295 &spr_read_ureg, SPR_NOACCESS, 4296 0x00000000); 4297 4298 spr_register(env, SPR_7XX_PMC6, "PMC6", 4299 SPR_NOACCESS, SPR_NOACCESS, 4300 &spr_read_generic, &spr_write_generic, 4301 0x00000000); 4302 4303 spr_register(env, SPR_7XX_UPMC6, "UPMC6", 4304 &spr_read_ureg, SPR_NOACCESS, 4305 &spr_read_ureg, SPR_NOACCESS, 4306 0x00000000); 4307 /* Memory management */ 4308 register_low_BATs(env); 4309 init_excp_7450(env); 4310 env->dcache_line_size = 32; 4311 env->icache_line_size = 32; 4312 /* Allocate hardware IRQ controller */ 4313 ppc6xx_irq_init(env_archcpu(env)); 4314 } 4315 4316 POWERPC_FAMILY(7440)(ObjectClass *oc, void *data) 4317 { 4318 DeviceClass *dc = DEVICE_CLASS(oc); 4319 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 4320 4321 dc->desc = "PowerPC 7440 (aka G4)"; 4322 pcc->init_proc = init_proc_7440; 4323 pcc->check_pow = check_pow_hid0_74xx; 4324 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 4325 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 4326 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 4327 PPC_FLOAT_STFIWX | 4328 PPC_CACHE | PPC_CACHE_ICBI | 4329 PPC_CACHE_DCBA | PPC_CACHE_DCBZ | 4330 PPC_MEM_SYNC | PPC_MEM_EIEIO | 4331 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 4332 PPC_MEM_TLBIA | 4333 PPC_SEGMENT | PPC_EXTERN | 4334 PPC_ALTIVEC; 4335 pcc->msr_mask = (1ull << MSR_VR) | 4336 (1ull << MSR_POW) | 4337 (1ull << MSR_ILE) | 4338 (1ull << MSR_EE) | 4339 (1ull << MSR_PR) | 4340 (1ull << MSR_FP) | 4341 (1ull << MSR_ME) | 4342 (1ull << MSR_FE0) | 4343 (1ull << MSR_SE) | 4344 (1ull << MSR_DE) | 4345 (1ull << MSR_FE1) | 4346 (1ull << MSR_EP) | 4347 (1ull << MSR_IR) | 4348 (1ull << MSR_DR) | 4349 (1ull << MSR_PMM) | 4350 (1ull << MSR_RI) | 4351 (1ull << MSR_LE); 4352 pcc->mmu_model = POWERPC_MMU_32B; 4353 pcc->excp_model = POWERPC_EXCP_74xx; 4354 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 4355 pcc->bfd_mach = bfd_mach_ppc_7400; 4356 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 4357 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 4358 POWERPC_FLAG_BUS_CLK; 4359 } 4360 4361 static void init_proc_7450(CPUPPCState *env) 4362 { 4363 register_non_embedded_sprs(env); 4364 register_sdr1_sprs(env); 4365 register_74xx_sprs(env); 4366 vscr_init(env, 0x00010000); 4367 /* Level 3 cache control */ 4368 register_l3_ctrl(env); 4369 /* L3ITCR1 */ 4370 spr_register(env, SPR_L3ITCR1, "L3ITCR1", 4371 SPR_NOACCESS, SPR_NOACCESS, 4372 &spr_read_generic, &spr_write_generic, 4373 0x00000000); 4374 /* L3ITCR2 */ 4375 spr_register(env, SPR_L3ITCR2, "L3ITCR2", 4376 SPR_NOACCESS, SPR_NOACCESS, 4377 &spr_read_generic, &spr_write_generic, 4378 0x00000000); 4379 /* L3ITCR3 */ 4380 spr_register(env, SPR_L3ITCR3, "L3ITCR3", 4381 SPR_NOACCESS, SPR_NOACCESS, 4382 &spr_read_generic, &spr_write_generic, 4383 0x00000000); 4384 /* L3OHCR */ 4385 spr_register(env, SPR_L3OHCR, "L3OHCR", 4386 SPR_NOACCESS, SPR_NOACCESS, 4387 &spr_read_generic, &spr_write_generic, 4388 0x00000000); 4389 4390 spr_register(env, SPR_UBAMR, "UBAMR", 4391 &spr_read_ureg, SPR_NOACCESS, 4392 &spr_read_ureg, SPR_NOACCESS, 4393 0x00000000); 4394 /* LDSTCR */ 4395 spr_register(env, SPR_LDSTCR, "LDSTCR", 4396 SPR_NOACCESS, SPR_NOACCESS, 4397 &spr_read_generic, &spr_write_generic, 4398 0x00000000); 4399 /* ICTRL */ 4400 spr_register(env, SPR_ICTRL, "ICTRL", 4401 SPR_NOACCESS, SPR_NOACCESS, 4402 &spr_read_generic, &spr_write_generic, 4403 0x00000000); 4404 /* MSSSR0 */ 4405 spr_register(env, SPR_MSSSR0, "MSSSR0", 4406 SPR_NOACCESS, SPR_NOACCESS, 4407 &spr_read_generic, &spr_write_generic, 4408 0x00000000); 4409 /* PMC */ 4410 spr_register(env, SPR_7XX_PMC5, "PMC5", 4411 SPR_NOACCESS, SPR_NOACCESS, 4412 &spr_read_generic, &spr_write_generic, 4413 0x00000000); 4414 4415 spr_register(env, SPR_7XX_UPMC5, "UPMC5", 4416 &spr_read_ureg, SPR_NOACCESS, 4417 &spr_read_ureg, SPR_NOACCESS, 4418 0x00000000); 4419 4420 spr_register(env, SPR_7XX_PMC6, "PMC6", 4421 SPR_NOACCESS, SPR_NOACCESS, 4422 &spr_read_generic, &spr_write_generic, 4423 0x00000000); 4424 4425 spr_register(env, SPR_7XX_UPMC6, "UPMC6", 4426 &spr_read_ureg, SPR_NOACCESS, 4427 &spr_read_ureg, SPR_NOACCESS, 4428 0x00000000); 4429 /* Memory management */ 4430 register_low_BATs(env); 4431 init_excp_7450(env); 4432 env->dcache_line_size = 32; 4433 env->icache_line_size = 32; 4434 /* Allocate hardware IRQ controller */ 4435 ppc6xx_irq_init(env_archcpu(env)); 4436 } 4437 4438 POWERPC_FAMILY(7450)(ObjectClass *oc, void *data) 4439 { 4440 DeviceClass *dc = DEVICE_CLASS(oc); 4441 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 4442 4443 dc->desc = "PowerPC 7450 (aka G4)"; 4444 pcc->init_proc = init_proc_7450; 4445 pcc->check_pow = check_pow_hid0_74xx; 4446 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 4447 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 4448 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 4449 PPC_FLOAT_STFIWX | 4450 PPC_CACHE | PPC_CACHE_ICBI | 4451 PPC_CACHE_DCBA | PPC_CACHE_DCBZ | 4452 PPC_MEM_SYNC | PPC_MEM_EIEIO | 4453 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 4454 PPC_MEM_TLBIA | 4455 PPC_SEGMENT | PPC_EXTERN | 4456 PPC_ALTIVEC; 4457 pcc->msr_mask = (1ull << MSR_VR) | 4458 (1ull << MSR_POW) | 4459 (1ull << MSR_ILE) | 4460 (1ull << MSR_EE) | 4461 (1ull << MSR_PR) | 4462 (1ull << MSR_FP) | 4463 (1ull << MSR_ME) | 4464 (1ull << MSR_FE0) | 4465 (1ull << MSR_SE) | 4466 (1ull << MSR_DE) | 4467 (1ull << MSR_FE1) | 4468 (1ull << MSR_EP) | 4469 (1ull << MSR_IR) | 4470 (1ull << MSR_DR) | 4471 (1ull << MSR_PMM) | 4472 (1ull << MSR_RI) | 4473 (1ull << MSR_LE); 4474 pcc->mmu_model = POWERPC_MMU_32B; 4475 pcc->excp_model = POWERPC_EXCP_74xx; 4476 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 4477 pcc->bfd_mach = bfd_mach_ppc_7400; 4478 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 4479 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 4480 POWERPC_FLAG_BUS_CLK; 4481 } 4482 4483 static void init_proc_7445(CPUPPCState *env) 4484 { 4485 register_non_embedded_sprs(env); 4486 register_sdr1_sprs(env); 4487 register_74xx_sprs(env); 4488 vscr_init(env, 0x00010000); 4489 /* LDSTCR */ 4490 spr_register(env, SPR_LDSTCR, "LDSTCR", 4491 SPR_NOACCESS, SPR_NOACCESS, 4492 &spr_read_generic, &spr_write_generic, 4493 0x00000000); 4494 /* ICTRL */ 4495 spr_register(env, SPR_ICTRL, "ICTRL", 4496 SPR_NOACCESS, SPR_NOACCESS, 4497 &spr_read_generic, &spr_write_generic, 4498 0x00000000); 4499 /* MSSSR0 */ 4500 spr_register(env, SPR_MSSSR0, "MSSSR0", 4501 SPR_NOACCESS, SPR_NOACCESS, 4502 &spr_read_generic, &spr_write_generic, 4503 0x00000000); 4504 /* PMC */ 4505 spr_register(env, SPR_7XX_PMC5, "PMC5", 4506 SPR_NOACCESS, SPR_NOACCESS, 4507 &spr_read_generic, &spr_write_generic, 4508 0x00000000); 4509 4510 spr_register(env, SPR_7XX_UPMC5, "UPMC5", 4511 &spr_read_ureg, SPR_NOACCESS, 4512 &spr_read_ureg, SPR_NOACCESS, 4513 0x00000000); 4514 4515 spr_register(env, SPR_7XX_PMC6, "PMC6", 4516 SPR_NOACCESS, SPR_NOACCESS, 4517 &spr_read_generic, &spr_write_generic, 4518 0x00000000); 4519 4520 spr_register(env, SPR_7XX_UPMC6, "UPMC6", 4521 &spr_read_ureg, SPR_NOACCESS, 4522 &spr_read_ureg, SPR_NOACCESS, 4523 0x00000000); 4524 /* SPRGs */ 4525 spr_register(env, SPR_SPRG4, "SPRG4", 4526 SPR_NOACCESS, SPR_NOACCESS, 4527 &spr_read_generic, &spr_write_generic, 4528 0x00000000); 4529 spr_register(env, SPR_USPRG4, "USPRG4", 4530 &spr_read_ureg, SPR_NOACCESS, 4531 &spr_read_ureg, SPR_NOACCESS, 4532 0x00000000); 4533 spr_register(env, SPR_SPRG5, "SPRG5", 4534 SPR_NOACCESS, SPR_NOACCESS, 4535 &spr_read_generic, &spr_write_generic, 4536 0x00000000); 4537 spr_register(env, SPR_USPRG5, "USPRG5", 4538 &spr_read_ureg, SPR_NOACCESS, 4539 &spr_read_ureg, SPR_NOACCESS, 4540 0x00000000); 4541 spr_register(env, SPR_SPRG6, "SPRG6", 4542 SPR_NOACCESS, SPR_NOACCESS, 4543 &spr_read_generic, &spr_write_generic, 4544 0x00000000); 4545 spr_register(env, SPR_USPRG6, "USPRG6", 4546 &spr_read_ureg, SPR_NOACCESS, 4547 &spr_read_ureg, SPR_NOACCESS, 4548 0x00000000); 4549 spr_register(env, SPR_SPRG7, "SPRG7", 4550 SPR_NOACCESS, SPR_NOACCESS, 4551 &spr_read_generic, &spr_write_generic, 4552 0x00000000); 4553 spr_register(env, SPR_USPRG7, "USPRG7", 4554 &spr_read_ureg, SPR_NOACCESS, 4555 &spr_read_ureg, SPR_NOACCESS, 4556 0x00000000); 4557 /* Memory management */ 4558 register_low_BATs(env); 4559 register_high_BATs(env); 4560 init_excp_7450(env); 4561 env->dcache_line_size = 32; 4562 env->icache_line_size = 32; 4563 /* Allocate hardware IRQ controller */ 4564 ppc6xx_irq_init(env_archcpu(env)); 4565 } 4566 4567 POWERPC_FAMILY(7445)(ObjectClass *oc, void *data) 4568 { 4569 DeviceClass *dc = DEVICE_CLASS(oc); 4570 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 4571 4572 dc->desc = "PowerPC 7445 (aka G4)"; 4573 pcc->init_proc = init_proc_7445; 4574 pcc->check_pow = check_pow_hid0_74xx; 4575 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 4576 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 4577 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 4578 PPC_FLOAT_STFIWX | 4579 PPC_CACHE | PPC_CACHE_ICBI | 4580 PPC_CACHE_DCBA | PPC_CACHE_DCBZ | 4581 PPC_MEM_SYNC | PPC_MEM_EIEIO | 4582 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 4583 PPC_MEM_TLBIA | 4584 PPC_SEGMENT | PPC_EXTERN | 4585 PPC_ALTIVEC; 4586 pcc->msr_mask = (1ull << MSR_VR) | 4587 (1ull << MSR_POW) | 4588 (1ull << MSR_ILE) | 4589 (1ull << MSR_EE) | 4590 (1ull << MSR_PR) | 4591 (1ull << MSR_FP) | 4592 (1ull << MSR_ME) | 4593 (1ull << MSR_FE0) | 4594 (1ull << MSR_SE) | 4595 (1ull << MSR_DE) | 4596 (1ull << MSR_FE1) | 4597 (1ull << MSR_EP) | 4598 (1ull << MSR_IR) | 4599 (1ull << MSR_DR) | 4600 (1ull << MSR_PMM) | 4601 (1ull << MSR_RI) | 4602 (1ull << MSR_LE); 4603 pcc->mmu_model = POWERPC_MMU_32B; 4604 pcc->excp_model = POWERPC_EXCP_74xx; 4605 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 4606 pcc->bfd_mach = bfd_mach_ppc_7400; 4607 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 4608 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 4609 POWERPC_FLAG_BUS_CLK; 4610 } 4611 4612 static void init_proc_7455(CPUPPCState *env) 4613 { 4614 register_non_embedded_sprs(env); 4615 register_sdr1_sprs(env); 4616 register_74xx_sprs(env); 4617 vscr_init(env, 0x00010000); 4618 /* Level 3 cache control */ 4619 register_l3_ctrl(env); 4620 /* LDSTCR */ 4621 spr_register(env, SPR_LDSTCR, "LDSTCR", 4622 SPR_NOACCESS, SPR_NOACCESS, 4623 &spr_read_generic, &spr_write_generic, 4624 0x00000000); 4625 /* ICTRL */ 4626 spr_register(env, SPR_ICTRL, "ICTRL", 4627 SPR_NOACCESS, SPR_NOACCESS, 4628 &spr_read_generic, &spr_write_generic, 4629 0x00000000); 4630 /* MSSSR0 */ 4631 spr_register(env, SPR_MSSSR0, "MSSSR0", 4632 SPR_NOACCESS, SPR_NOACCESS, 4633 &spr_read_generic, &spr_write_generic, 4634 0x00000000); 4635 /* PMC */ 4636 spr_register(env, SPR_7XX_PMC5, "PMC5", 4637 SPR_NOACCESS, SPR_NOACCESS, 4638 &spr_read_generic, &spr_write_generic, 4639 0x00000000); 4640 4641 spr_register(env, SPR_7XX_UPMC5, "UPMC5", 4642 &spr_read_ureg, SPR_NOACCESS, 4643 &spr_read_ureg, SPR_NOACCESS, 4644 0x00000000); 4645 4646 spr_register(env, SPR_7XX_PMC6, "PMC6", 4647 SPR_NOACCESS, SPR_NOACCESS, 4648 &spr_read_generic, &spr_write_generic, 4649 0x00000000); 4650 4651 spr_register(env, SPR_7XX_UPMC6, "UPMC6", 4652 &spr_read_ureg, SPR_NOACCESS, 4653 &spr_read_ureg, SPR_NOACCESS, 4654 0x00000000); 4655 /* SPRGs */ 4656 spr_register(env, SPR_SPRG4, "SPRG4", 4657 SPR_NOACCESS, SPR_NOACCESS, 4658 &spr_read_generic, &spr_write_generic, 4659 0x00000000); 4660 spr_register(env, SPR_USPRG4, "USPRG4", 4661 &spr_read_ureg, SPR_NOACCESS, 4662 &spr_read_ureg, SPR_NOACCESS, 4663 0x00000000); 4664 spr_register(env, SPR_SPRG5, "SPRG5", 4665 SPR_NOACCESS, SPR_NOACCESS, 4666 &spr_read_generic, &spr_write_generic, 4667 0x00000000); 4668 spr_register(env, SPR_USPRG5, "USPRG5", 4669 &spr_read_ureg, SPR_NOACCESS, 4670 &spr_read_ureg, SPR_NOACCESS, 4671 0x00000000); 4672 spr_register(env, SPR_SPRG6, "SPRG6", 4673 SPR_NOACCESS, SPR_NOACCESS, 4674 &spr_read_generic, &spr_write_generic, 4675 0x00000000); 4676 spr_register(env, SPR_USPRG6, "USPRG6", 4677 &spr_read_ureg, SPR_NOACCESS, 4678 &spr_read_ureg, SPR_NOACCESS, 4679 0x00000000); 4680 spr_register(env, SPR_SPRG7, "SPRG7", 4681 SPR_NOACCESS, SPR_NOACCESS, 4682 &spr_read_generic, &spr_write_generic, 4683 0x00000000); 4684 spr_register(env, SPR_USPRG7, "USPRG7", 4685 &spr_read_ureg, SPR_NOACCESS, 4686 &spr_read_ureg, SPR_NOACCESS, 4687 0x00000000); 4688 /* Memory management */ 4689 register_low_BATs(env); 4690 register_high_BATs(env); 4691 init_excp_7450(env); 4692 env->dcache_line_size = 32; 4693 env->icache_line_size = 32; 4694 /* Allocate hardware IRQ controller */ 4695 ppc6xx_irq_init(env_archcpu(env)); 4696 } 4697 4698 POWERPC_FAMILY(7455)(ObjectClass *oc, void *data) 4699 { 4700 DeviceClass *dc = DEVICE_CLASS(oc); 4701 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 4702 4703 dc->desc = "PowerPC 7455 (aka G4)"; 4704 pcc->init_proc = init_proc_7455; 4705 pcc->check_pow = check_pow_hid0_74xx; 4706 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 4707 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 4708 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 4709 PPC_FLOAT_STFIWX | 4710 PPC_CACHE | PPC_CACHE_ICBI | 4711 PPC_CACHE_DCBA | PPC_CACHE_DCBZ | 4712 PPC_MEM_SYNC | PPC_MEM_EIEIO | 4713 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 4714 PPC_MEM_TLBIA | 4715 PPC_SEGMENT | PPC_EXTERN | 4716 PPC_ALTIVEC; 4717 pcc->msr_mask = (1ull << MSR_VR) | 4718 (1ull << MSR_POW) | 4719 (1ull << MSR_ILE) | 4720 (1ull << MSR_EE) | 4721 (1ull << MSR_PR) | 4722 (1ull << MSR_FP) | 4723 (1ull << MSR_ME) | 4724 (1ull << MSR_FE0) | 4725 (1ull << MSR_SE) | 4726 (1ull << MSR_DE) | 4727 (1ull << MSR_FE1) | 4728 (1ull << MSR_EP) | 4729 (1ull << MSR_IR) | 4730 (1ull << MSR_DR) | 4731 (1ull << MSR_PMM) | 4732 (1ull << MSR_RI) | 4733 (1ull << MSR_LE); 4734 pcc->mmu_model = POWERPC_MMU_32B; 4735 pcc->excp_model = POWERPC_EXCP_74xx; 4736 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 4737 pcc->bfd_mach = bfd_mach_ppc_7400; 4738 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 4739 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 4740 POWERPC_FLAG_BUS_CLK; 4741 } 4742 4743 static void init_proc_7457(CPUPPCState *env) 4744 { 4745 register_non_embedded_sprs(env); 4746 register_sdr1_sprs(env); 4747 register_74xx_sprs(env); 4748 vscr_init(env, 0x00010000); 4749 /* Level 3 cache control */ 4750 register_l3_ctrl(env); 4751 /* L3ITCR1 */ 4752 spr_register(env, SPR_L3ITCR1, "L3ITCR1", 4753 SPR_NOACCESS, SPR_NOACCESS, 4754 &spr_read_generic, &spr_write_generic, 4755 0x00000000); 4756 /* L3ITCR2 */ 4757 spr_register(env, SPR_L3ITCR2, "L3ITCR2", 4758 SPR_NOACCESS, SPR_NOACCESS, 4759 &spr_read_generic, &spr_write_generic, 4760 0x00000000); 4761 /* L3ITCR3 */ 4762 spr_register(env, SPR_L3ITCR3, "L3ITCR3", 4763 SPR_NOACCESS, SPR_NOACCESS, 4764 &spr_read_generic, &spr_write_generic, 4765 0x00000000); 4766 /* L3OHCR */ 4767 spr_register(env, SPR_L3OHCR, "L3OHCR", 4768 SPR_NOACCESS, SPR_NOACCESS, 4769 &spr_read_generic, &spr_write_generic, 4770 0x00000000); 4771 /* LDSTCR */ 4772 spr_register(env, SPR_LDSTCR, "LDSTCR", 4773 SPR_NOACCESS, SPR_NOACCESS, 4774 &spr_read_generic, &spr_write_generic, 4775 0x00000000); 4776 /* ICTRL */ 4777 spr_register(env, SPR_ICTRL, "ICTRL", 4778 SPR_NOACCESS, SPR_NOACCESS, 4779 &spr_read_generic, &spr_write_generic, 4780 0x00000000); 4781 /* MSSSR0 */ 4782 spr_register(env, SPR_MSSSR0, "MSSSR0", 4783 SPR_NOACCESS, SPR_NOACCESS, 4784 &spr_read_generic, &spr_write_generic, 4785 0x00000000); 4786 /* PMC */ 4787 spr_register(env, SPR_7XX_PMC5, "PMC5", 4788 SPR_NOACCESS, SPR_NOACCESS, 4789 &spr_read_generic, &spr_write_generic, 4790 0x00000000); 4791 4792 spr_register(env, SPR_7XX_UPMC5, "UPMC5", 4793 &spr_read_ureg, SPR_NOACCESS, 4794 &spr_read_ureg, SPR_NOACCESS, 4795 0x00000000); 4796 4797 spr_register(env, SPR_7XX_PMC6, "PMC6", 4798 SPR_NOACCESS, SPR_NOACCESS, 4799 &spr_read_generic, &spr_write_generic, 4800 0x00000000); 4801 4802 spr_register(env, SPR_7XX_UPMC6, "UPMC6", 4803 &spr_read_ureg, SPR_NOACCESS, 4804 &spr_read_ureg, SPR_NOACCESS, 4805 0x00000000); 4806 /* SPRGs */ 4807 spr_register(env, SPR_SPRG4, "SPRG4", 4808 SPR_NOACCESS, SPR_NOACCESS, 4809 &spr_read_generic, &spr_write_generic, 4810 0x00000000); 4811 spr_register(env, SPR_USPRG4, "USPRG4", 4812 &spr_read_ureg, SPR_NOACCESS, 4813 &spr_read_ureg, SPR_NOACCESS, 4814 0x00000000); 4815 spr_register(env, SPR_SPRG5, "SPRG5", 4816 SPR_NOACCESS, SPR_NOACCESS, 4817 &spr_read_generic, &spr_write_generic, 4818 0x00000000); 4819 spr_register(env, SPR_USPRG5, "USPRG5", 4820 &spr_read_ureg, SPR_NOACCESS, 4821 &spr_read_ureg, SPR_NOACCESS, 4822 0x00000000); 4823 spr_register(env, SPR_SPRG6, "SPRG6", 4824 SPR_NOACCESS, SPR_NOACCESS, 4825 &spr_read_generic, &spr_write_generic, 4826 0x00000000); 4827 spr_register(env, SPR_USPRG6, "USPRG6", 4828 &spr_read_ureg, SPR_NOACCESS, 4829 &spr_read_ureg, SPR_NOACCESS, 4830 0x00000000); 4831 spr_register(env, SPR_SPRG7, "SPRG7", 4832 SPR_NOACCESS, SPR_NOACCESS, 4833 &spr_read_generic, &spr_write_generic, 4834 0x00000000); 4835 spr_register(env, SPR_USPRG7, "USPRG7", 4836 &spr_read_ureg, SPR_NOACCESS, 4837 &spr_read_ureg, SPR_NOACCESS, 4838 0x00000000); 4839 /* Memory management */ 4840 register_low_BATs(env); 4841 register_high_BATs(env); 4842 init_excp_7450(env); 4843 env->dcache_line_size = 32; 4844 env->icache_line_size = 32; 4845 /* Allocate hardware IRQ controller */ 4846 ppc6xx_irq_init(env_archcpu(env)); 4847 } 4848 4849 POWERPC_FAMILY(7457)(ObjectClass *oc, void *data) 4850 { 4851 DeviceClass *dc = DEVICE_CLASS(oc); 4852 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 4853 4854 dc->desc = "PowerPC 7457 (aka G4)"; 4855 pcc->init_proc = init_proc_7457; 4856 pcc->check_pow = check_pow_hid0_74xx; 4857 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 4858 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 4859 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 4860 PPC_FLOAT_STFIWX | 4861 PPC_CACHE | PPC_CACHE_ICBI | 4862 PPC_CACHE_DCBA | PPC_CACHE_DCBZ | 4863 PPC_MEM_SYNC | PPC_MEM_EIEIO | 4864 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 4865 PPC_MEM_TLBIA | 4866 PPC_SEGMENT | PPC_EXTERN | 4867 PPC_ALTIVEC; 4868 pcc->msr_mask = (1ull << MSR_VR) | 4869 (1ull << MSR_POW) | 4870 (1ull << MSR_ILE) | 4871 (1ull << MSR_EE) | 4872 (1ull << MSR_PR) | 4873 (1ull << MSR_FP) | 4874 (1ull << MSR_ME) | 4875 (1ull << MSR_FE0) | 4876 (1ull << MSR_SE) | 4877 (1ull << MSR_DE) | 4878 (1ull << MSR_FE1) | 4879 (1ull << MSR_EP) | 4880 (1ull << MSR_IR) | 4881 (1ull << MSR_DR) | 4882 (1ull << MSR_PMM) | 4883 (1ull << MSR_RI) | 4884 (1ull << MSR_LE); 4885 pcc->mmu_model = POWERPC_MMU_32B; 4886 pcc->excp_model = POWERPC_EXCP_74xx; 4887 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 4888 pcc->bfd_mach = bfd_mach_ppc_7400; 4889 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 4890 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 4891 POWERPC_FLAG_BUS_CLK; 4892 } 4893 4894 static void init_proc_e600(CPUPPCState *env) 4895 { 4896 register_non_embedded_sprs(env); 4897 register_sdr1_sprs(env); 4898 register_74xx_sprs(env); 4899 vscr_init(env, 0x00010000); 4900 4901 spr_register(env, SPR_UBAMR, "UBAMR", 4902 &spr_read_ureg, SPR_NOACCESS, 4903 &spr_read_ureg, SPR_NOACCESS, 4904 0x00000000); 4905 4906 spr_register(env, SPR_LDSTCR, "LDSTCR", 4907 SPR_NOACCESS, SPR_NOACCESS, 4908 &spr_read_generic, &spr_write_generic, 4909 0x00000000); 4910 4911 spr_register(env, SPR_ICTRL, "ICTRL", 4912 SPR_NOACCESS, SPR_NOACCESS, 4913 &spr_read_generic, &spr_write_generic, 4914 0x00000000); 4915 4916 spr_register(env, SPR_MSSSR0, "MSSSR0", 4917 SPR_NOACCESS, SPR_NOACCESS, 4918 &spr_read_generic, &spr_write_generic, 4919 0x00000000); 4920 4921 spr_register(env, SPR_7XX_PMC5, "PMC5", 4922 SPR_NOACCESS, SPR_NOACCESS, 4923 &spr_read_generic, &spr_write_generic, 4924 0x00000000); 4925 4926 spr_register(env, SPR_7XX_UPMC5, "UPMC5", 4927 &spr_read_ureg, SPR_NOACCESS, 4928 &spr_read_ureg, SPR_NOACCESS, 4929 0x00000000); 4930 4931 spr_register(env, SPR_7XX_PMC6, "PMC6", 4932 SPR_NOACCESS, SPR_NOACCESS, 4933 &spr_read_generic, &spr_write_generic, 4934 0x00000000); 4935 4936 spr_register(env, SPR_7XX_UPMC6, "UPMC6", 4937 &spr_read_ureg, SPR_NOACCESS, 4938 &spr_read_ureg, SPR_NOACCESS, 4939 0x00000000); 4940 /* SPRGs */ 4941 spr_register(env, SPR_SPRG4, "SPRG4", 4942 SPR_NOACCESS, SPR_NOACCESS, 4943 &spr_read_generic, &spr_write_generic, 4944 0x00000000); 4945 spr_register(env, SPR_USPRG4, "USPRG4", 4946 &spr_read_ureg, SPR_NOACCESS, 4947 &spr_read_ureg, SPR_NOACCESS, 4948 0x00000000); 4949 spr_register(env, SPR_SPRG5, "SPRG5", 4950 SPR_NOACCESS, SPR_NOACCESS, 4951 &spr_read_generic, &spr_write_generic, 4952 0x00000000); 4953 spr_register(env, SPR_USPRG5, "USPRG5", 4954 &spr_read_ureg, SPR_NOACCESS, 4955 &spr_read_ureg, SPR_NOACCESS, 4956 0x00000000); 4957 spr_register(env, SPR_SPRG6, "SPRG6", 4958 SPR_NOACCESS, SPR_NOACCESS, 4959 &spr_read_generic, &spr_write_generic, 4960 0x00000000); 4961 spr_register(env, SPR_USPRG6, "USPRG6", 4962 &spr_read_ureg, SPR_NOACCESS, 4963 &spr_read_ureg, SPR_NOACCESS, 4964 0x00000000); 4965 spr_register(env, SPR_SPRG7, "SPRG7", 4966 SPR_NOACCESS, SPR_NOACCESS, 4967 &spr_read_generic, &spr_write_generic, 4968 0x00000000); 4969 spr_register(env, SPR_USPRG7, "USPRG7", 4970 &spr_read_ureg, SPR_NOACCESS, 4971 &spr_read_ureg, SPR_NOACCESS, 4972 0x00000000); 4973 /* Memory management */ 4974 register_low_BATs(env); 4975 register_high_BATs(env); 4976 init_excp_7450(env); 4977 env->dcache_line_size = 32; 4978 env->icache_line_size = 32; 4979 /* Allocate hardware IRQ controller */ 4980 ppc6xx_irq_init(env_archcpu(env)); 4981 } 4982 4983 POWERPC_FAMILY(e600)(ObjectClass *oc, void *data) 4984 { 4985 DeviceClass *dc = DEVICE_CLASS(oc); 4986 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 4987 4988 dc->desc = "PowerPC e600"; 4989 pcc->init_proc = init_proc_e600; 4990 pcc->check_pow = check_pow_hid0_74xx; 4991 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 4992 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 4993 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 4994 PPC_FLOAT_STFIWX | 4995 PPC_CACHE | PPC_CACHE_ICBI | 4996 PPC_CACHE_DCBA | PPC_CACHE_DCBZ | 4997 PPC_MEM_SYNC | PPC_MEM_EIEIO | 4998 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 4999 PPC_MEM_TLBIA | 5000 PPC_SEGMENT | PPC_EXTERN | 5001 PPC_ALTIVEC; 5002 pcc->insns_flags2 = PPC_NONE; 5003 pcc->msr_mask = (1ull << MSR_VR) | 5004 (1ull << MSR_POW) | 5005 (1ull << MSR_ILE) | 5006 (1ull << MSR_EE) | 5007 (1ull << MSR_PR) | 5008 (1ull << MSR_FP) | 5009 (1ull << MSR_ME) | 5010 (1ull << MSR_FE0) | 5011 (1ull << MSR_SE) | 5012 (1ull << MSR_DE) | 5013 (1ull << MSR_FE1) | 5014 (1ull << MSR_EP) | 5015 (1ull << MSR_IR) | 5016 (1ull << MSR_DR) | 5017 (1ull << MSR_PMM) | 5018 (1ull << MSR_RI) | 5019 (1ull << MSR_LE); 5020 pcc->mmu_model = POWERPC_MMU_32B; 5021 pcc->excp_model = POWERPC_EXCP_74xx; 5022 pcc->bus_model = PPC_FLAGS_INPUT_6xx; 5023 pcc->bfd_mach = bfd_mach_ppc_7400; 5024 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 5025 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 5026 POWERPC_FLAG_BUS_CLK; 5027 } 5028 5029 #if defined(TARGET_PPC64) 5030 #if defined(CONFIG_USER_ONLY) 5031 #define POWERPC970_HID5_INIT 0x00000080 5032 #else 5033 #define POWERPC970_HID5_INIT 0x00000000 5034 #endif 5035 5036 static int check_pow_970(CPUPPCState *env) 5037 { 5038 if (env->spr[SPR_HID0] & (HID0_DEEPNAP | HID0_DOZE | HID0_NAP)) { 5039 return 1; 5040 } 5041 5042 return 0; 5043 } 5044 5045 static void register_970_hid_sprs(CPUPPCState *env) 5046 { 5047 /* Hardware implementation registers */ 5048 spr_register(env, SPR_HID0, "HID0", 5049 SPR_NOACCESS, SPR_NOACCESS, 5050 &spr_read_generic, &spr_write_clear, 5051 0x60000000); 5052 spr_register(env, SPR_HID1, "HID1", 5053 SPR_NOACCESS, SPR_NOACCESS, 5054 &spr_read_generic, &spr_write_generic, 5055 0x00000000); 5056 spr_register(env, SPR_970_HID5, "HID5", 5057 SPR_NOACCESS, SPR_NOACCESS, 5058 &spr_read_generic, &spr_write_generic, 5059 POWERPC970_HID5_INIT); 5060 } 5061 5062 static void register_970_hior_sprs(CPUPPCState *env) 5063 { 5064 spr_register(env, SPR_HIOR, "SPR_HIOR", 5065 SPR_NOACCESS, SPR_NOACCESS, 5066 &spr_read_hior, &spr_write_hior, 5067 0x00000000); 5068 } 5069 5070 static void register_book3s_ctrl_sprs(CPUPPCState *env) 5071 { 5072 spr_register(env, SPR_CTRL, "SPR_CTRL", 5073 SPR_NOACCESS, SPR_NOACCESS, 5074 SPR_NOACCESS, &spr_write_CTRL, 5075 0x00000000); 5076 spr_register(env, SPR_UCTRL, "SPR_UCTRL", 5077 &spr_read_ureg, SPR_NOACCESS, 5078 &spr_read_ureg, SPR_NOACCESS, 5079 0x00000000); 5080 } 5081 5082 static void register_book3s_altivec_sprs(CPUPPCState *env) 5083 { 5084 if (!(env->insns_flags & PPC_ALTIVEC)) { 5085 return; 5086 } 5087 5088 spr_register_kvm(env, SPR_VRSAVE, "VRSAVE", 5089 &spr_read_generic, &spr_write_generic, 5090 &spr_read_generic, &spr_write_generic, 5091 KVM_REG_PPC_VRSAVE, 0x00000000); 5092 5093 } 5094 5095 static void register_book3s_dbg_sprs(CPUPPCState *env) 5096 { 5097 /* 5098 * TODO: different specs define different scopes for these, 5099 * will have to address this: 5100 * 970: super/write and super/read 5101 * powerisa 2.03..2.04: hypv/write and super/read. 5102 * powerisa 2.05 and newer: hypv/write and hypv/read. 5103 */ 5104 spr_register_kvm(env, SPR_DABR, "DABR", 5105 SPR_NOACCESS, SPR_NOACCESS, 5106 &spr_read_generic, &spr_write_generic, 5107 KVM_REG_PPC_DABR, 0x00000000); 5108 spr_register_kvm(env, SPR_DABRX, "DABRX", 5109 SPR_NOACCESS, SPR_NOACCESS, 5110 &spr_read_generic, &spr_write_generic, 5111 KVM_REG_PPC_DABRX, 0x00000000); 5112 } 5113 5114 static void register_book3s_207_dbg_sprs(CPUPPCState *env) 5115 { 5116 spr_register_kvm_hv(env, SPR_DAWR0, "DAWR0", 5117 SPR_NOACCESS, SPR_NOACCESS, 5118 SPR_NOACCESS, SPR_NOACCESS, 5119 &spr_read_generic, &spr_write_generic, 5120 KVM_REG_PPC_DAWR, 0x00000000); 5121 spr_register_kvm_hv(env, SPR_DAWRX0, "DAWRX0", 5122 SPR_NOACCESS, SPR_NOACCESS, 5123 SPR_NOACCESS, SPR_NOACCESS, 5124 &spr_read_generic, &spr_write_generic, 5125 KVM_REG_PPC_DAWRX, 0x00000000); 5126 spr_register_kvm_hv(env, SPR_CIABR, "CIABR", 5127 SPR_NOACCESS, SPR_NOACCESS, 5128 SPR_NOACCESS, SPR_NOACCESS, 5129 &spr_read_generic, &spr_write_generic, 5130 KVM_REG_PPC_CIABR, 0x00000000); 5131 } 5132 5133 static void register_970_dbg_sprs(CPUPPCState *env) 5134 { 5135 /* Breakpoints */ 5136 spr_register(env, SPR_IABR, "IABR", 5137 SPR_NOACCESS, SPR_NOACCESS, 5138 &spr_read_generic, &spr_write_generic, 5139 0x00000000); 5140 } 5141 5142 static void register_book3s_pmu_sup_sprs(CPUPPCState *env) 5143 { 5144 spr_register_kvm(env, SPR_POWER_MMCR0, "MMCR0", 5145 SPR_NOACCESS, SPR_NOACCESS, 5146 &spr_read_generic, &spr_write_MMCR0, 5147 KVM_REG_PPC_MMCR0, 0x80000000); 5148 spr_register_kvm(env, SPR_POWER_MMCR1, "MMCR1", 5149 SPR_NOACCESS, SPR_NOACCESS, 5150 &spr_read_generic, &spr_write_MMCR1, 5151 KVM_REG_PPC_MMCR1, 0x00000000); 5152 spr_register_kvm(env, SPR_POWER_MMCRA, "MMCRA", 5153 SPR_NOACCESS, SPR_NOACCESS, 5154 &spr_read_generic, &spr_write_generic, 5155 KVM_REG_PPC_MMCRA, 0x00000000); 5156 spr_register_kvm(env, SPR_POWER_PMC1, "PMC1", 5157 SPR_NOACCESS, SPR_NOACCESS, 5158 &spr_read_PMC, &spr_write_PMC, 5159 KVM_REG_PPC_PMC1, 0x00000000); 5160 spr_register_kvm(env, SPR_POWER_PMC2, "PMC2", 5161 SPR_NOACCESS, SPR_NOACCESS, 5162 &spr_read_PMC, &spr_write_PMC, 5163 KVM_REG_PPC_PMC2, 0x00000000); 5164 spr_register_kvm(env, SPR_POWER_PMC3, "PMC3", 5165 SPR_NOACCESS, SPR_NOACCESS, 5166 &spr_read_PMC, &spr_write_PMC, 5167 KVM_REG_PPC_PMC3, 0x00000000); 5168 spr_register_kvm(env, SPR_POWER_PMC4, "PMC4", 5169 SPR_NOACCESS, SPR_NOACCESS, 5170 &spr_read_PMC, &spr_write_PMC, 5171 KVM_REG_PPC_PMC4, 0x00000000); 5172 spr_register_kvm(env, SPR_POWER_PMC5, "PMC5", 5173 SPR_NOACCESS, SPR_NOACCESS, 5174 &spr_read_PMC, &spr_write_PMC, 5175 KVM_REG_PPC_PMC5, 0x00000000); 5176 spr_register_kvm(env, SPR_POWER_PMC6, "PMC6", 5177 SPR_NOACCESS, SPR_NOACCESS, 5178 &spr_read_PMC, &spr_write_PMC, 5179 KVM_REG_PPC_PMC6, 0x00000000); 5180 spr_register_kvm(env, SPR_POWER_SIAR, "SIAR", 5181 SPR_NOACCESS, SPR_NOACCESS, 5182 &spr_read_generic, &spr_write_generic, 5183 KVM_REG_PPC_SIAR, 0x00000000); 5184 spr_register_kvm(env, SPR_POWER_SDAR, "SDAR", 5185 SPR_NOACCESS, SPR_NOACCESS, 5186 &spr_read_generic, &spr_write_generic, 5187 KVM_REG_PPC_SDAR, 0x00000000); 5188 } 5189 5190 static void register_book3s_pmu_user_sprs(CPUPPCState *env) 5191 { 5192 spr_register(env, SPR_POWER_UMMCR0, "UMMCR0", 5193 &spr_read_MMCR0_ureg, &spr_write_MMCR0_ureg, 5194 &spr_read_ureg, &spr_write_ureg, 5195 0x80000000); 5196 spr_register(env, SPR_POWER_UMMCR1, "UMMCR1", 5197 &spr_read_ureg, SPR_NOACCESS, 5198 &spr_read_ureg, &spr_write_ureg, 5199 0x00000000); 5200 spr_register(env, SPR_POWER_UMMCRA, "UMMCRA", 5201 &spr_read_ureg, SPR_NOACCESS, 5202 &spr_read_ureg, &spr_write_ureg, 5203 0x00000000); 5204 spr_register(env, SPR_POWER_UPMC1, "UPMC1", 5205 &spr_read_PMC14_ureg, &spr_write_PMC14_ureg, 5206 &spr_read_ureg, &spr_write_ureg, 5207 0x00000000); 5208 spr_register(env, SPR_POWER_UPMC2, "UPMC2", 5209 &spr_read_PMC14_ureg, &spr_write_PMC14_ureg, 5210 &spr_read_ureg, &spr_write_ureg, 5211 0x00000000); 5212 spr_register(env, SPR_POWER_UPMC3, "UPMC3", 5213 &spr_read_PMC14_ureg, &spr_write_PMC14_ureg, 5214 &spr_read_ureg, &spr_write_ureg, 5215 0x00000000); 5216 spr_register(env, SPR_POWER_UPMC4, "UPMC4", 5217 &spr_read_PMC14_ureg, &spr_write_PMC14_ureg, 5218 &spr_read_ureg, &spr_write_ureg, 5219 0x00000000); 5220 spr_register(env, SPR_POWER_UPMC5, "UPMC5", 5221 &spr_read_PMC56_ureg, &spr_write_PMC56_ureg, 5222 &spr_read_ureg, &spr_write_ureg, 5223 0x00000000); 5224 spr_register(env, SPR_POWER_UPMC6, "UPMC6", 5225 &spr_read_PMC56_ureg, &spr_write_PMC56_ureg, 5226 &spr_read_ureg, &spr_write_ureg, 5227 0x00000000); 5228 spr_register(env, SPR_POWER_USIAR, "USIAR", 5229 &spr_read_ureg, SPR_NOACCESS, 5230 &spr_read_ureg, &spr_write_ureg, 5231 0x00000000); 5232 spr_register(env, SPR_POWER_USDAR, "USDAR", 5233 &spr_read_ureg, SPR_NOACCESS, 5234 &spr_read_ureg, &spr_write_ureg, 5235 0x00000000); 5236 } 5237 5238 static void register_970_pmu_sup_sprs(CPUPPCState *env) 5239 { 5240 spr_register_kvm(env, SPR_970_PMC7, "PMC7", 5241 SPR_NOACCESS, SPR_NOACCESS, 5242 &spr_read_generic, &spr_write_generic, 5243 KVM_REG_PPC_PMC7, 0x00000000); 5244 spr_register_kvm(env, SPR_970_PMC8, "PMC8", 5245 SPR_NOACCESS, SPR_NOACCESS, 5246 &spr_read_generic, &spr_write_generic, 5247 KVM_REG_PPC_PMC8, 0x00000000); 5248 } 5249 5250 static void register_970_pmu_user_sprs(CPUPPCState *env) 5251 { 5252 spr_register(env, SPR_970_UPMC7, "UPMC7", 5253 &spr_read_ureg, SPR_NOACCESS, 5254 &spr_read_ureg, &spr_write_ureg, 5255 0x00000000); 5256 spr_register(env, SPR_970_UPMC8, "UPMC8", 5257 &spr_read_ureg, SPR_NOACCESS, 5258 &spr_read_ureg, &spr_write_ureg, 5259 0x00000000); 5260 } 5261 5262 static void register_power8_pmu_sup_sprs(CPUPPCState *env) 5263 { 5264 spr_register_kvm(env, SPR_POWER_MMCR2, "MMCR2", 5265 SPR_NOACCESS, SPR_NOACCESS, 5266 &spr_read_generic, &spr_write_generic, 5267 KVM_REG_PPC_MMCR2, 0x00000000); 5268 spr_register_kvm(env, SPR_POWER_MMCRS, "MMCRS", 5269 SPR_NOACCESS, SPR_NOACCESS, 5270 &spr_read_generic, &spr_write_generic, 5271 KVM_REG_PPC_MMCRS, 0x00000000); 5272 spr_register_kvm(env, SPR_POWER_SIER, "SIER", 5273 SPR_NOACCESS, SPR_NOACCESS, 5274 &spr_read_generic, &spr_write_generic, 5275 KVM_REG_PPC_SIER, 0x00000000); 5276 spr_register_kvm(env, SPR_POWER_SPMC1, "SPMC1", 5277 SPR_NOACCESS, SPR_NOACCESS, 5278 &spr_read_generic, &spr_write_generic, 5279 KVM_REG_PPC_SPMC1, 0x00000000); 5280 spr_register_kvm(env, SPR_POWER_SPMC2, "SPMC2", 5281 SPR_NOACCESS, SPR_NOACCESS, 5282 &spr_read_generic, &spr_write_generic, 5283 KVM_REG_PPC_SPMC2, 0x00000000); 5284 spr_register_kvm(env, SPR_TACR, "TACR", 5285 SPR_NOACCESS, SPR_NOACCESS, 5286 &spr_read_generic, &spr_write_generic, 5287 KVM_REG_PPC_TACR, 0x00000000); 5288 spr_register_kvm(env, SPR_TCSCR, "TCSCR", 5289 SPR_NOACCESS, SPR_NOACCESS, 5290 &spr_read_generic, &spr_write_generic, 5291 KVM_REG_PPC_TCSCR, 0x00000000); 5292 spr_register_kvm(env, SPR_CSIGR, "CSIGR", 5293 SPR_NOACCESS, SPR_NOACCESS, 5294 &spr_read_generic, &spr_write_generic, 5295 KVM_REG_PPC_CSIGR, 0x00000000); 5296 } 5297 5298 static void register_power8_pmu_user_sprs(CPUPPCState *env) 5299 { 5300 spr_register(env, SPR_POWER_UMMCR2, "UMMCR2", 5301 &spr_read_MMCR2_ureg, &spr_write_MMCR2_ureg, 5302 &spr_read_ureg, &spr_write_ureg, 5303 0x00000000); 5304 spr_register(env, SPR_POWER_USIER, "USIER", 5305 &spr_read_generic, SPR_NOACCESS, 5306 &spr_read_generic, &spr_write_generic, 5307 0x00000000); 5308 } 5309 5310 static void register_power5p_ear_sprs(CPUPPCState *env) 5311 { 5312 /* External access control */ 5313 spr_register(env, SPR_EAR, "EAR", 5314 SPR_NOACCESS, SPR_NOACCESS, 5315 &spr_read_generic, &spr_write_generic, 5316 0x00000000); 5317 } 5318 5319 static void register_power5p_tb_sprs(CPUPPCState *env) 5320 { 5321 /* TBU40 (High 40 bits of the Timebase register */ 5322 spr_register_hv(env, SPR_TBU40, "TBU40", 5323 SPR_NOACCESS, SPR_NOACCESS, 5324 SPR_NOACCESS, SPR_NOACCESS, 5325 SPR_NOACCESS, &spr_write_tbu40, 5326 0x00000000); 5327 } 5328 5329 static void register_970_lpar_sprs(CPUPPCState *env) 5330 { 5331 #if !defined(CONFIG_USER_ONLY) 5332 /* 5333 * PPC970: HID4 covers things later controlled by the LPCR and 5334 * RMOR in later CPUs, but with a different encoding. We only 5335 * support the 970 in "Apple mode" which has all hypervisor 5336 * facilities disabled by strapping, so we can basically just 5337 * ignore it 5338 */ 5339 spr_register(env, SPR_970_HID4, "HID4", 5340 SPR_NOACCESS, SPR_NOACCESS, 5341 &spr_read_generic, &spr_write_generic, 5342 0x00000000); 5343 #endif 5344 } 5345 5346 static void register_power5p_lpar_sprs(CPUPPCState *env) 5347 { 5348 #if !defined(CONFIG_USER_ONLY) 5349 /* Logical partitionning */ 5350 spr_register_kvm_hv(env, SPR_LPCR, "LPCR", 5351 SPR_NOACCESS, SPR_NOACCESS, 5352 SPR_NOACCESS, SPR_NOACCESS, 5353 &spr_read_generic, &spr_write_lpcr, 5354 KVM_REG_PPC_LPCR, LPCR_LPES0 | LPCR_LPES1); 5355 spr_register_hv(env, SPR_HDEC, "HDEC", 5356 SPR_NOACCESS, SPR_NOACCESS, 5357 SPR_NOACCESS, SPR_NOACCESS, 5358 &spr_read_hdecr, &spr_write_hdecr, 0); 5359 #endif 5360 } 5361 5362 static void register_book3s_ids_sprs(CPUPPCState *env) 5363 { 5364 /* FIXME: Will need to deal with thread vs core only SPRs */ 5365 5366 /* Processor identification */ 5367 spr_register_hv(env, SPR_PIR, "PIR", 5368 SPR_NOACCESS, SPR_NOACCESS, 5369 &spr_read_generic, SPR_NOACCESS, 5370 &spr_read_generic, NULL, 5371 0x00000000); 5372 spr_register_hv(env, SPR_HID0, "HID0", 5373 SPR_NOACCESS, SPR_NOACCESS, 5374 SPR_NOACCESS, SPR_NOACCESS, 5375 &spr_read_generic, &spr_write_generic, 5376 0x00000000); 5377 spr_register_hv(env, SPR_TSCR, "TSCR", 5378 SPR_NOACCESS, SPR_NOACCESS, 5379 SPR_NOACCESS, SPR_NOACCESS, 5380 &spr_read_generic, &spr_write_generic, 5381 0x00000000); 5382 spr_register_hv(env, SPR_HMER, "HMER", 5383 SPR_NOACCESS, SPR_NOACCESS, 5384 SPR_NOACCESS, SPR_NOACCESS, 5385 &spr_read_generic, &spr_write_hmer, 5386 0x00000000); 5387 spr_register_hv(env, SPR_HMEER, "HMEER", 5388 SPR_NOACCESS, SPR_NOACCESS, 5389 SPR_NOACCESS, SPR_NOACCESS, 5390 &spr_read_generic, &spr_write_generic, 5391 0x00000000); 5392 spr_register_hv(env, SPR_TFMR, "TFMR", 5393 SPR_NOACCESS, SPR_NOACCESS, 5394 SPR_NOACCESS, SPR_NOACCESS, 5395 &spr_read_generic, &spr_write_generic, 5396 0x00000000); 5397 spr_register_hv(env, SPR_LPIDR, "LPIDR", 5398 SPR_NOACCESS, SPR_NOACCESS, 5399 SPR_NOACCESS, SPR_NOACCESS, 5400 &spr_read_generic, &spr_write_lpidr, 5401 0x00000000); 5402 spr_register_hv(env, SPR_HFSCR, "HFSCR", 5403 SPR_NOACCESS, SPR_NOACCESS, 5404 SPR_NOACCESS, SPR_NOACCESS, 5405 &spr_read_generic, &spr_write_generic, 5406 0x00000000); 5407 spr_register_hv(env, SPR_MMCRC, "MMCRC", 5408 SPR_NOACCESS, SPR_NOACCESS, 5409 SPR_NOACCESS, SPR_NOACCESS, 5410 &spr_read_generic, &spr_write_generic, 5411 0x00000000); 5412 spr_register_hv(env, SPR_MMCRH, "MMCRH", 5413 SPR_NOACCESS, SPR_NOACCESS, 5414 SPR_NOACCESS, SPR_NOACCESS, 5415 &spr_read_generic, &spr_write_generic, 5416 0x00000000); 5417 spr_register_hv(env, SPR_HSPRG0, "HSPRG0", 5418 SPR_NOACCESS, SPR_NOACCESS, 5419 SPR_NOACCESS, SPR_NOACCESS, 5420 &spr_read_generic, &spr_write_generic, 5421 0x00000000); 5422 spr_register_hv(env, SPR_HSPRG1, "HSPRG1", 5423 SPR_NOACCESS, SPR_NOACCESS, 5424 SPR_NOACCESS, SPR_NOACCESS, 5425 &spr_read_generic, &spr_write_generic, 5426 0x00000000); 5427 spr_register_hv(env, SPR_HSRR0, "HSRR0", 5428 SPR_NOACCESS, SPR_NOACCESS, 5429 SPR_NOACCESS, SPR_NOACCESS, 5430 &spr_read_generic, &spr_write_generic, 5431 0x00000000); 5432 spr_register_hv(env, SPR_HSRR1, "HSRR1", 5433 SPR_NOACCESS, SPR_NOACCESS, 5434 SPR_NOACCESS, SPR_NOACCESS, 5435 &spr_read_generic, &spr_write_generic, 5436 0x00000000); 5437 spr_register_hv(env, SPR_HDAR, "HDAR", 5438 SPR_NOACCESS, SPR_NOACCESS, 5439 SPR_NOACCESS, SPR_NOACCESS, 5440 &spr_read_generic, &spr_write_generic, 5441 0x00000000); 5442 spr_register_hv(env, SPR_HDSISR, "HDSISR", 5443 SPR_NOACCESS, SPR_NOACCESS, 5444 SPR_NOACCESS, SPR_NOACCESS, 5445 &spr_read_generic, &spr_write_generic, 5446 0x00000000); 5447 spr_register_hv(env, SPR_HRMOR, "HRMOR", 5448 SPR_NOACCESS, SPR_NOACCESS, 5449 SPR_NOACCESS, SPR_NOACCESS, 5450 &spr_read_generic, &spr_write_generic, 5451 0x00000000); 5452 } 5453 5454 static void register_rmor_sprs(CPUPPCState *env) 5455 { 5456 spr_register_hv(env, SPR_RMOR, "RMOR", 5457 SPR_NOACCESS, SPR_NOACCESS, 5458 SPR_NOACCESS, SPR_NOACCESS, 5459 &spr_read_generic, &spr_write_generic, 5460 0x00000000); 5461 } 5462 5463 static void register_power8_ids_sprs(CPUPPCState *env) 5464 { 5465 /* Thread identification */ 5466 spr_register(env, SPR_TIR, "TIR", 5467 SPR_NOACCESS, SPR_NOACCESS, 5468 &spr_read_generic, SPR_NOACCESS, 5469 0x00000000); 5470 } 5471 5472 static void register_book3s_purr_sprs(CPUPPCState *env) 5473 { 5474 #if !defined(CONFIG_USER_ONLY) 5475 /* PURR & SPURR: Hack - treat these as aliases for the TB for now */ 5476 spr_register_kvm_hv(env, SPR_PURR, "PURR", 5477 &spr_read_purr, SPR_NOACCESS, 5478 &spr_read_purr, SPR_NOACCESS, 5479 &spr_read_purr, &spr_write_purr, 5480 KVM_REG_PPC_PURR, 0x00000000); 5481 spr_register_kvm_hv(env, SPR_SPURR, "SPURR", 5482 &spr_read_purr, SPR_NOACCESS, 5483 &spr_read_purr, SPR_NOACCESS, 5484 &spr_read_purr, &spr_write_purr, 5485 KVM_REG_PPC_SPURR, 0x00000000); 5486 #endif 5487 } 5488 5489 static void register_power6_dbg_sprs(CPUPPCState *env) 5490 { 5491 #if !defined(CONFIG_USER_ONLY) 5492 spr_register(env, SPR_CFAR, "SPR_CFAR", 5493 SPR_NOACCESS, SPR_NOACCESS, 5494 &spr_read_cfar, &spr_write_cfar, 5495 0x00000000); 5496 #endif 5497 } 5498 5499 static void register_power5p_common_sprs(CPUPPCState *env) 5500 { 5501 spr_register_kvm(env, SPR_PPR, "PPR", 5502 &spr_read_generic, &spr_write_generic, 5503 &spr_read_generic, &spr_write_generic, 5504 KVM_REG_PPC_PPR, 0x00000000); 5505 } 5506 5507 static void register_power6_common_sprs(CPUPPCState *env) 5508 { 5509 #if !defined(CONFIG_USER_ONLY) 5510 spr_register_kvm(env, SPR_DSCR, "SPR_DSCR", 5511 SPR_NOACCESS, SPR_NOACCESS, 5512 &spr_read_generic, &spr_write_generic, 5513 KVM_REG_PPC_DSCR, 0x00000000); 5514 #endif 5515 /* 5516 * Register PCR to report POWERPC_EXCP_PRIV_REG instead of 5517 * POWERPC_EXCP_INVAL_SPR in userspace. Permit hypervisor access. 5518 */ 5519 spr_register_hv(env, SPR_PCR, "PCR", 5520 SPR_NOACCESS, SPR_NOACCESS, 5521 SPR_NOACCESS, SPR_NOACCESS, 5522 &spr_read_generic, &spr_write_pcr, 5523 0x00000000); 5524 } 5525 5526 static void register_power8_tce_address_control_sprs(CPUPPCState *env) 5527 { 5528 spr_register_kvm(env, SPR_TAR, "TAR", 5529 &spr_read_tar, &spr_write_tar, 5530 &spr_read_generic, &spr_write_generic, 5531 KVM_REG_PPC_TAR, 0x00000000); 5532 } 5533 5534 static void register_power8_tm_sprs(CPUPPCState *env) 5535 { 5536 spr_register_kvm(env, SPR_TFHAR, "TFHAR", 5537 &spr_read_tm, &spr_write_tm, 5538 &spr_read_tm, &spr_write_tm, 5539 KVM_REG_PPC_TFHAR, 0x00000000); 5540 spr_register_kvm(env, SPR_TFIAR, "TFIAR", 5541 &spr_read_tm, &spr_write_tm, 5542 &spr_read_tm, &spr_write_tm, 5543 KVM_REG_PPC_TFIAR, 0x00000000); 5544 spr_register_kvm(env, SPR_TEXASR, "TEXASR", 5545 &spr_read_tm, &spr_write_tm, 5546 &spr_read_tm, &spr_write_tm, 5547 KVM_REG_PPC_TEXASR, 0x00000000); 5548 spr_register(env, SPR_TEXASRU, "TEXASRU", 5549 &spr_read_tm_upper32, &spr_write_tm_upper32, 5550 &spr_read_tm_upper32, &spr_write_tm_upper32, 5551 0x00000000); 5552 } 5553 5554 static void register_power8_ebb_sprs(CPUPPCState *env) 5555 { 5556 spr_register(env, SPR_BESCRS, "BESCRS", 5557 &spr_read_ebb, &spr_write_ebb, 5558 &spr_read_generic, &spr_write_generic, 5559 0x00000000); 5560 spr_register(env, SPR_BESCRSU, "BESCRSU", 5561 &spr_read_ebb_upper32, &spr_write_ebb_upper32, 5562 &spr_read_prev_upper32, &spr_write_prev_upper32, 5563 0x00000000); 5564 spr_register(env, SPR_BESCRR, "BESCRR", 5565 &spr_read_ebb, &spr_write_ebb, 5566 &spr_read_generic, &spr_write_generic, 5567 0x00000000); 5568 spr_register(env, SPR_BESCRRU, "BESCRRU", 5569 &spr_read_ebb_upper32, &spr_write_ebb_upper32, 5570 &spr_read_prev_upper32, &spr_write_prev_upper32, 5571 0x00000000); 5572 spr_register_kvm(env, SPR_EBBHR, "EBBHR", 5573 &spr_read_ebb, &spr_write_ebb, 5574 &spr_read_generic, &spr_write_generic, 5575 KVM_REG_PPC_EBBHR, 0x00000000); 5576 spr_register_kvm(env, SPR_EBBRR, "EBBRR", 5577 &spr_read_ebb, &spr_write_ebb, 5578 &spr_read_generic, &spr_write_generic, 5579 KVM_REG_PPC_EBBRR, 0x00000000); 5580 spr_register_kvm(env, SPR_BESCR, "BESCR", 5581 &spr_read_ebb, &spr_write_ebb, 5582 &spr_read_generic, &spr_write_generic, 5583 KVM_REG_PPC_BESCR, 0x00000000); 5584 } 5585 5586 /* Virtual Time Base */ 5587 static void register_vtb_sprs(CPUPPCState *env) 5588 { 5589 spr_register_kvm_hv(env, SPR_VTB, "VTB", 5590 SPR_NOACCESS, SPR_NOACCESS, 5591 &spr_read_vtb, SPR_NOACCESS, 5592 &spr_read_vtb, &spr_write_vtb, 5593 KVM_REG_PPC_VTB, 0x00000000); 5594 } 5595 5596 static void register_power8_fscr_sprs(CPUPPCState *env) 5597 { 5598 #if defined(CONFIG_USER_ONLY) 5599 target_ulong initval = 1ULL << FSCR_TAR; 5600 #else 5601 target_ulong initval = 0; 5602 #endif 5603 spr_register_kvm(env, SPR_FSCR, "FSCR", 5604 SPR_NOACCESS, SPR_NOACCESS, 5605 &spr_read_generic, &spr_write_generic, 5606 KVM_REG_PPC_FSCR, initval); 5607 } 5608 5609 static void register_power8_pspb_sprs(CPUPPCState *env) 5610 { 5611 spr_register_kvm(env, SPR_PSPB, "PSPB", 5612 SPR_NOACCESS, SPR_NOACCESS, 5613 &spr_read_generic, &spr_write_generic32, 5614 KVM_REG_PPC_PSPB, 0); 5615 } 5616 5617 static void register_power8_dpdes_sprs(CPUPPCState *env) 5618 { 5619 #if !defined(CONFIG_USER_ONLY) 5620 /* Directed Privileged Door-bell Exception State, used for IPI */ 5621 spr_register_kvm_hv(env, SPR_DPDES, "DPDES", 5622 SPR_NOACCESS, SPR_NOACCESS, 5623 &spr_read_dpdes, SPR_NOACCESS, 5624 &spr_read_dpdes, &spr_write_dpdes, 5625 KVM_REG_PPC_DPDES, 0x00000000); 5626 #endif 5627 } 5628 5629 static void register_power8_ic_sprs(CPUPPCState *env) 5630 { 5631 #if !defined(CONFIG_USER_ONLY) 5632 spr_register_hv(env, SPR_IC, "IC", 5633 SPR_NOACCESS, SPR_NOACCESS, 5634 &spr_read_generic, SPR_NOACCESS, 5635 &spr_read_generic, &spr_write_generic, 5636 0); 5637 #endif 5638 } 5639 5640 static void register_power8_book4_sprs(CPUPPCState *env) 5641 { 5642 /* Add a number of P8 book4 registers */ 5643 #if !defined(CONFIG_USER_ONLY) 5644 spr_register_kvm(env, SPR_ACOP, "ACOP", 5645 SPR_NOACCESS, SPR_NOACCESS, 5646 &spr_read_generic, &spr_write_generic, 5647 KVM_REG_PPC_ACOP, 0); 5648 spr_register_kvm(env, SPR_BOOKS_PID, "PID", 5649 SPR_NOACCESS, SPR_NOACCESS, 5650 &spr_read_generic, &spr_write_pidr, 5651 KVM_REG_PPC_PID, 0); 5652 spr_register_kvm(env, SPR_WORT, "WORT", 5653 SPR_NOACCESS, SPR_NOACCESS, 5654 &spr_read_generic, &spr_write_generic, 5655 KVM_REG_PPC_WORT, 0); 5656 #endif 5657 } 5658 5659 static void register_power7_book4_sprs(CPUPPCState *env) 5660 { 5661 /* Add a number of P7 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_generic, 5670 KVM_REG_PPC_PID, 0); 5671 #endif 5672 } 5673 5674 static void register_power8_rpr_sprs(CPUPPCState *env) 5675 { 5676 #if !defined(CONFIG_USER_ONLY) 5677 spr_register_hv(env, SPR_RPR, "RPR", 5678 SPR_NOACCESS, SPR_NOACCESS, 5679 SPR_NOACCESS, SPR_NOACCESS, 5680 &spr_read_generic, &spr_write_generic, 5681 0x00000103070F1F3F); 5682 #endif 5683 } 5684 5685 static void register_power9_mmu_sprs(CPUPPCState *env) 5686 { 5687 #if !defined(CONFIG_USER_ONLY) 5688 /* Partition Table Control */ 5689 spr_register_kvm_hv(env, SPR_PTCR, "PTCR", 5690 SPR_NOACCESS, SPR_NOACCESS, 5691 SPR_NOACCESS, SPR_NOACCESS, 5692 &spr_read_generic, &spr_write_ptcr, 5693 KVM_REG_PPC_PTCR, 0x00000000); 5694 /* Address Segment Descriptor Register */ 5695 spr_register_hv(env, SPR_ASDR, "ASDR", 5696 SPR_NOACCESS, SPR_NOACCESS, 5697 SPR_NOACCESS, SPR_NOACCESS, 5698 &spr_read_generic, &spr_write_generic, 5699 0x0000000000000000); 5700 #endif 5701 } 5702 5703 /* 5704 * Initialize PMU counter overflow timers for Power8 and 5705 * newer Power chips when using TCG. 5706 */ 5707 static void init_tcg_pmu_power8(CPUPPCState *env) 5708 { 5709 /* Init PMU overflow timers */ 5710 if (tcg_enabled()) { 5711 cpu_ppc_pmu_init(env); 5712 } 5713 } 5714 5715 static void init_proc_book3s_common(CPUPPCState *env) 5716 { 5717 register_non_embedded_sprs(env); 5718 register_book3s_altivec_sprs(env); 5719 register_book3s_pmu_sup_sprs(env); 5720 register_book3s_pmu_user_sprs(env); 5721 register_book3s_ctrl_sprs(env); 5722 /* 5723 * Can't find information on what this should be on reset. This 5724 * value is the one used by 74xx processors. 5725 */ 5726 vscr_init(env, 0x00010000); 5727 5728 spr_register(env, SPR_USPRG3, "USPRG3", 5729 &spr_read_ureg, SPR_NOACCESS, 5730 &spr_read_ureg, SPR_NOACCESS, 5731 0x00000000); 5732 } 5733 5734 static void init_proc_970(CPUPPCState *env) 5735 { 5736 /* Common Registers */ 5737 init_proc_book3s_common(env); 5738 register_sdr1_sprs(env); 5739 register_book3s_dbg_sprs(env); 5740 5741 /* 970 Specific Registers */ 5742 register_970_hid_sprs(env); 5743 register_970_hior_sprs(env); 5744 register_low_BATs(env); 5745 register_970_pmu_sup_sprs(env); 5746 register_970_pmu_user_sprs(env); 5747 register_970_lpar_sprs(env); 5748 register_970_dbg_sprs(env); 5749 5750 /* env variables */ 5751 env->dcache_line_size = 128; 5752 env->icache_line_size = 128; 5753 5754 /* Allocate hardware IRQ controller */ 5755 init_excp_970(env); 5756 ppc970_irq_init(env_archcpu(env)); 5757 } 5758 5759 POWERPC_FAMILY(970)(ObjectClass *oc, void *data) 5760 { 5761 DeviceClass *dc = DEVICE_CLASS(oc); 5762 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 5763 5764 dc->desc = "PowerPC 970"; 5765 pcc->init_proc = init_proc_970; 5766 pcc->check_pow = check_pow_970; 5767 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 5768 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 5769 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 5770 PPC_FLOAT_STFIWX | 5771 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 5772 PPC_MEM_SYNC | PPC_MEM_EIEIO | 5773 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 5774 PPC_64B | PPC_ALTIVEC | 5775 PPC_SEGMENT_64B | PPC_SLBI; 5776 pcc->insns_flags2 = PPC2_FP_CVT_S64 | PPC2_MEM_LWSYNC; 5777 pcc->msr_mask = (1ull << MSR_SF) | 5778 (1ull << MSR_VR) | 5779 (1ull << MSR_POW) | 5780 (1ull << MSR_EE) | 5781 (1ull << MSR_PR) | 5782 (1ull << MSR_FP) | 5783 (1ull << MSR_ME) | 5784 (1ull << MSR_FE0) | 5785 (1ull << MSR_SE) | 5786 (1ull << MSR_DE) | 5787 (1ull << MSR_FE1) | 5788 (1ull << MSR_IR) | 5789 (1ull << MSR_DR) | 5790 (1ull << MSR_PMM) | 5791 (1ull << MSR_RI); 5792 pcc->mmu_model = POWERPC_MMU_64B; 5793 #if defined(CONFIG_SOFTMMU) 5794 pcc->hash64_opts = &ppc_hash64_opts_basic; 5795 #endif 5796 pcc->excp_model = POWERPC_EXCP_970; 5797 pcc->bus_model = PPC_FLAGS_INPUT_970; 5798 pcc->bfd_mach = bfd_mach_ppc64; 5799 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 5800 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 5801 POWERPC_FLAG_BUS_CLK; 5802 pcc->l1_dcache_size = 0x8000; 5803 pcc->l1_icache_size = 0x10000; 5804 } 5805 5806 static void init_proc_power5plus(CPUPPCState *env) 5807 { 5808 /* Common Registers */ 5809 init_proc_book3s_common(env); 5810 register_sdr1_sprs(env); 5811 register_book3s_dbg_sprs(env); 5812 5813 /* POWER5+ Specific Registers */ 5814 register_970_hid_sprs(env); 5815 register_970_hior_sprs(env); 5816 register_low_BATs(env); 5817 register_970_pmu_sup_sprs(env); 5818 register_970_pmu_user_sprs(env); 5819 register_power5p_common_sprs(env); 5820 register_power5p_lpar_sprs(env); 5821 register_power5p_ear_sprs(env); 5822 register_power5p_tb_sprs(env); 5823 5824 /* env variables */ 5825 env->dcache_line_size = 128; 5826 env->icache_line_size = 128; 5827 5828 /* Allocate hardware IRQ controller */ 5829 init_excp_970(env); 5830 ppc970_irq_init(env_archcpu(env)); 5831 } 5832 5833 POWERPC_FAMILY(POWER5P)(ObjectClass *oc, void *data) 5834 { 5835 DeviceClass *dc = DEVICE_CLASS(oc); 5836 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 5837 5838 dc->fw_name = "PowerPC,POWER5"; 5839 dc->desc = "POWER5+"; 5840 pcc->init_proc = init_proc_power5plus; 5841 pcc->check_pow = check_pow_970; 5842 pcc->insns_flags = PPC_INSNS_BASE | PPC_STRING | PPC_MFTB | 5843 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 5844 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 5845 PPC_FLOAT_STFIWX | 5846 PPC_FLOAT_EXT | 5847 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 5848 PPC_MEM_SYNC | PPC_MEM_EIEIO | 5849 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 5850 PPC_64B | 5851 PPC_POPCNTB | 5852 PPC_SEGMENT_64B | PPC_SLBI; 5853 pcc->insns_flags2 = PPC2_FP_CVT_S64 | PPC2_MEM_LWSYNC; 5854 pcc->msr_mask = (1ull << MSR_SF) | 5855 (1ull << MSR_VR) | 5856 (1ull << MSR_POW) | 5857 (1ull << MSR_EE) | 5858 (1ull << MSR_PR) | 5859 (1ull << MSR_FP) | 5860 (1ull << MSR_ME) | 5861 (1ull << MSR_FE0) | 5862 (1ull << MSR_SE) | 5863 (1ull << MSR_DE) | 5864 (1ull << MSR_FE1) | 5865 (1ull << MSR_IR) | 5866 (1ull << MSR_DR) | 5867 (1ull << MSR_PMM) | 5868 (1ull << MSR_RI); 5869 pcc->lpcr_mask = LPCR_RMLS | LPCR_ILE | LPCR_LPES0 | LPCR_LPES1 | 5870 LPCR_RMI | LPCR_HDICE; 5871 pcc->mmu_model = POWERPC_MMU_2_03; 5872 #if defined(CONFIG_SOFTMMU) 5873 pcc->hash64_opts = &ppc_hash64_opts_basic; 5874 pcc->lrg_decr_bits = 32; 5875 #endif 5876 pcc->excp_model = POWERPC_EXCP_970; 5877 pcc->bus_model = PPC_FLAGS_INPUT_970; 5878 pcc->bfd_mach = bfd_mach_ppc64; 5879 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 5880 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 5881 POWERPC_FLAG_BUS_CLK; 5882 pcc->l1_dcache_size = 0x8000; 5883 pcc->l1_icache_size = 0x10000; 5884 } 5885 5886 static void init_proc_POWER7(CPUPPCState *env) 5887 { 5888 /* Common Registers */ 5889 init_proc_book3s_common(env); 5890 register_sdr1_sprs(env); 5891 register_book3s_dbg_sprs(env); 5892 5893 /* POWER7 Specific Registers */ 5894 register_book3s_ids_sprs(env); 5895 register_rmor_sprs(env); 5896 register_amr_sprs(env); 5897 register_book3s_purr_sprs(env); 5898 register_power5p_common_sprs(env); 5899 register_power5p_lpar_sprs(env); 5900 register_power5p_ear_sprs(env); 5901 register_power5p_tb_sprs(env); 5902 register_power6_common_sprs(env); 5903 register_power6_dbg_sprs(env); 5904 register_power7_book4_sprs(env); 5905 5906 /* env variables */ 5907 env->dcache_line_size = 128; 5908 env->icache_line_size = 128; 5909 5910 /* Allocate hardware IRQ controller */ 5911 init_excp_POWER7(env); 5912 ppcPOWER7_irq_init(env_archcpu(env)); 5913 } 5914 5915 static bool ppc_pvr_match_power7(PowerPCCPUClass *pcc, uint32_t pvr, bool best) 5916 { 5917 uint32_t base = pvr & CPU_POWERPC_POWER_SERVER_MASK; 5918 uint32_t pcc_base = pcc->pvr & CPU_POWERPC_POWER_SERVER_MASK; 5919 5920 if (!best) { 5921 if (base == CPU_POWERPC_POWER7_BASE) { 5922 return true; 5923 } 5924 if (base == CPU_POWERPC_POWER7P_BASE) { 5925 return true; 5926 } 5927 } 5928 5929 if (base != pcc_base) { 5930 return false; 5931 } 5932 5933 return true; 5934 } 5935 5936 static bool cpu_has_work_POWER7(CPUState *cs) 5937 { 5938 PowerPCCPU *cpu = POWERPC_CPU(cs); 5939 CPUPPCState *env = &cpu->env; 5940 5941 if (cs->halted) { 5942 if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) { 5943 return false; 5944 } 5945 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) && 5946 (env->spr[SPR_LPCR] & LPCR_P7_PECE0)) { 5947 return true; 5948 } 5949 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) && 5950 (env->spr[SPR_LPCR] & LPCR_P7_PECE1)) { 5951 return true; 5952 } 5953 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK)) && 5954 (env->spr[SPR_LPCR] & LPCR_P7_PECE2)) { 5955 return true; 5956 } 5957 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HMI)) && 5958 (env->spr[SPR_LPCR] & LPCR_P7_PECE2)) { 5959 return true; 5960 } 5961 if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) { 5962 return true; 5963 } 5964 return false; 5965 } else { 5966 return FIELD_EX64(env->msr, MSR, EE) && 5967 (cs->interrupt_request & CPU_INTERRUPT_HARD); 5968 } 5969 } 5970 5971 POWERPC_FAMILY(POWER7)(ObjectClass *oc, void *data) 5972 { 5973 DeviceClass *dc = DEVICE_CLASS(oc); 5974 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 5975 CPUClass *cc = CPU_CLASS(oc); 5976 5977 dc->fw_name = "PowerPC,POWER7"; 5978 dc->desc = "POWER7"; 5979 pcc->pvr_match = ppc_pvr_match_power7; 5980 pcc->pcr_mask = PCR_VEC_DIS | PCR_VSX_DIS | PCR_COMPAT_2_05; 5981 pcc->pcr_supported = PCR_COMPAT_2_06 | PCR_COMPAT_2_05; 5982 pcc->init_proc = init_proc_POWER7; 5983 pcc->check_pow = check_pow_nocheck; 5984 cc->has_work = cpu_has_work_POWER7; 5985 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB | 5986 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 5987 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 5988 PPC_FLOAT_FRSQRTES | 5989 PPC_FLOAT_STFIWX | 5990 PPC_FLOAT_EXT | 5991 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 5992 PPC_MEM_SYNC | PPC_MEM_EIEIO | 5993 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 5994 PPC_64B | PPC_64H | PPC_64BX | PPC_ALTIVEC | 5995 PPC_SEGMENT_64B | PPC_SLBI | 5996 PPC_POPCNTB | PPC_POPCNTWD | 5997 PPC_CILDST; 5998 pcc->insns_flags2 = PPC2_VSX | PPC2_DFP | PPC2_DBRX | PPC2_ISA205 | 5999 PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | 6000 PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 | 6001 PPC2_FP_TST_ISA206 | PPC2_FP_CVT_S64 | 6002 PPC2_PM_ISA206 | PPC2_MEM_LWSYNC | PPC2_BCDA_ISA206; 6003 pcc->msr_mask = (1ull << MSR_SF) | 6004 (1ull << MSR_VR) | 6005 (1ull << MSR_VSX) | 6006 (1ull << MSR_EE) | 6007 (1ull << MSR_PR) | 6008 (1ull << MSR_FP) | 6009 (1ull << MSR_ME) | 6010 (1ull << MSR_FE0) | 6011 (1ull << MSR_SE) | 6012 (1ull << MSR_DE) | 6013 (1ull << MSR_FE1) | 6014 (1ull << MSR_IR) | 6015 (1ull << MSR_DR) | 6016 (1ull << MSR_PMM) | 6017 (1ull << MSR_RI) | 6018 (1ull << MSR_LE); 6019 pcc->lpcr_mask = LPCR_VPM0 | LPCR_VPM1 | LPCR_ISL | LPCR_DPFD | 6020 LPCR_VRMASD | LPCR_RMLS | LPCR_ILE | 6021 LPCR_P7_PECE0 | LPCR_P7_PECE1 | LPCR_P7_PECE2 | 6022 LPCR_MER | LPCR_TC | 6023 LPCR_LPES0 | LPCR_LPES1 | LPCR_HDICE; 6024 pcc->lpcr_pm = LPCR_P7_PECE0 | LPCR_P7_PECE1 | LPCR_P7_PECE2; 6025 pcc->mmu_model = POWERPC_MMU_2_06; 6026 #if defined(CONFIG_SOFTMMU) 6027 pcc->hash64_opts = &ppc_hash64_opts_POWER7; 6028 pcc->lrg_decr_bits = 32; 6029 #endif 6030 pcc->excp_model = POWERPC_EXCP_POWER7; 6031 pcc->bus_model = PPC_FLAGS_INPUT_POWER7; 6032 pcc->bfd_mach = bfd_mach_ppc64; 6033 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 6034 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 6035 POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR | 6036 POWERPC_FLAG_VSX; 6037 pcc->l1_dcache_size = 0x8000; 6038 pcc->l1_icache_size = 0x8000; 6039 } 6040 6041 static void init_proc_POWER8(CPUPPCState *env) 6042 { 6043 /* Common Registers */ 6044 init_proc_book3s_common(env); 6045 register_sdr1_sprs(env); 6046 register_book3s_207_dbg_sprs(env); 6047 6048 /* Common TCG PMU */ 6049 init_tcg_pmu_power8(env); 6050 6051 /* POWER8 Specific Registers */ 6052 register_book3s_ids_sprs(env); 6053 register_rmor_sprs(env); 6054 register_amr_sprs(env); 6055 register_iamr_sprs(env); 6056 register_book3s_purr_sprs(env); 6057 register_power5p_common_sprs(env); 6058 register_power5p_lpar_sprs(env); 6059 register_power5p_ear_sprs(env); 6060 register_power5p_tb_sprs(env); 6061 register_power6_common_sprs(env); 6062 register_power6_dbg_sprs(env); 6063 register_power8_tce_address_control_sprs(env); 6064 register_power8_ids_sprs(env); 6065 register_power8_ebb_sprs(env); 6066 register_power8_fscr_sprs(env); 6067 register_power8_pmu_sup_sprs(env); 6068 register_power8_pmu_user_sprs(env); 6069 register_power8_tm_sprs(env); 6070 register_power8_pspb_sprs(env); 6071 register_power8_dpdes_sprs(env); 6072 register_vtb_sprs(env); 6073 register_power8_ic_sprs(env); 6074 register_power8_book4_sprs(env); 6075 register_power8_rpr_sprs(env); 6076 6077 /* env variables */ 6078 env->dcache_line_size = 128; 6079 env->icache_line_size = 128; 6080 6081 /* Allocate hardware IRQ controller */ 6082 init_excp_POWER8(env); 6083 ppcPOWER7_irq_init(env_archcpu(env)); 6084 } 6085 6086 static bool ppc_pvr_match_power8(PowerPCCPUClass *pcc, uint32_t pvr, bool best) 6087 { 6088 uint32_t base = pvr & CPU_POWERPC_POWER_SERVER_MASK; 6089 uint32_t pcc_base = pcc->pvr & CPU_POWERPC_POWER_SERVER_MASK; 6090 6091 if (!best) { 6092 if (base == CPU_POWERPC_POWER8_BASE) { 6093 return true; 6094 } 6095 if (base == CPU_POWERPC_POWER8E_BASE) { 6096 return true; 6097 } 6098 if (base == CPU_POWERPC_POWER8NVL_BASE) { 6099 return true; 6100 } 6101 } 6102 if (base != pcc_base) { 6103 return false; 6104 } 6105 6106 return true; 6107 } 6108 6109 static bool cpu_has_work_POWER8(CPUState *cs) 6110 { 6111 PowerPCCPU *cpu = POWERPC_CPU(cs); 6112 CPUPPCState *env = &cpu->env; 6113 6114 if (cs->halted) { 6115 if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) { 6116 return false; 6117 } 6118 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) && 6119 (env->spr[SPR_LPCR] & LPCR_P8_PECE2)) { 6120 return true; 6121 } 6122 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) && 6123 (env->spr[SPR_LPCR] & LPCR_P8_PECE3)) { 6124 return true; 6125 } 6126 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK)) && 6127 (env->spr[SPR_LPCR] & LPCR_P8_PECE4)) { 6128 return true; 6129 } 6130 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HMI)) && 6131 (env->spr[SPR_LPCR] & LPCR_P8_PECE4)) { 6132 return true; 6133 } 6134 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DOORBELL)) && 6135 (env->spr[SPR_LPCR] & LPCR_P8_PECE0)) { 6136 return true; 6137 } 6138 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HDOORBELL)) && 6139 (env->spr[SPR_LPCR] & LPCR_P8_PECE1)) { 6140 return true; 6141 } 6142 if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) { 6143 return true; 6144 } 6145 return false; 6146 } else { 6147 return FIELD_EX64(env->msr, MSR, EE) && 6148 (cs->interrupt_request & CPU_INTERRUPT_HARD); 6149 } 6150 } 6151 6152 POWERPC_FAMILY(POWER8)(ObjectClass *oc, void *data) 6153 { 6154 DeviceClass *dc = DEVICE_CLASS(oc); 6155 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 6156 CPUClass *cc = CPU_CLASS(oc); 6157 6158 dc->fw_name = "PowerPC,POWER8"; 6159 dc->desc = "POWER8"; 6160 pcc->pvr_match = ppc_pvr_match_power8; 6161 pcc->pcr_mask = PCR_TM_DIS | PCR_COMPAT_2_06 | PCR_COMPAT_2_05; 6162 pcc->pcr_supported = PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | PCR_COMPAT_2_05; 6163 pcc->init_proc = init_proc_POWER8; 6164 pcc->check_pow = check_pow_nocheck; 6165 cc->has_work = cpu_has_work_POWER8; 6166 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB | 6167 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 6168 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 6169 PPC_FLOAT_FRSQRTES | 6170 PPC_FLOAT_STFIWX | 6171 PPC_FLOAT_EXT | 6172 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 6173 PPC_MEM_SYNC | PPC_MEM_EIEIO | 6174 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 6175 PPC_64B | PPC_64H | PPC_64BX | PPC_ALTIVEC | 6176 PPC_SEGMENT_64B | PPC_SLBI | 6177 PPC_POPCNTB | PPC_POPCNTWD | 6178 PPC_CILDST; 6179 pcc->insns_flags2 = PPC2_VSX | PPC2_VSX207 | PPC2_DFP | PPC2_DBRX | 6180 PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | 6181 PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 | 6182 PPC2_FP_TST_ISA206 | PPC2_BCTAR_ISA207 | 6183 PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 | 6184 PPC2_ISA205 | PPC2_ISA207S | PPC2_FP_CVT_S64 | 6185 PPC2_TM | PPC2_PM_ISA206 | PPC2_MEM_LWSYNC | 6186 PPC2_BCDA_ISA206; 6187 pcc->msr_mask = (1ull << MSR_SF) | 6188 (1ull << MSR_HV) | 6189 (1ull << MSR_TM) | 6190 (1ull << MSR_VR) | 6191 (1ull << MSR_VSX) | 6192 (1ull << MSR_EE) | 6193 (1ull << MSR_PR) | 6194 (1ull << MSR_FP) | 6195 (1ull << MSR_ME) | 6196 (1ull << MSR_FE0) | 6197 (1ull << MSR_SE) | 6198 (1ull << MSR_DE) | 6199 (1ull << MSR_FE1) | 6200 (1ull << MSR_IR) | 6201 (1ull << MSR_DR) | 6202 (1ull << MSR_PMM) | 6203 (1ull << MSR_RI) | 6204 (1ull << MSR_TS0) | 6205 (1ull << MSR_TS1) | 6206 (1ull << MSR_LE); 6207 pcc->lpcr_mask = LPCR_VPM0 | LPCR_VPM1 | LPCR_ISL | LPCR_KBV | 6208 LPCR_DPFD | LPCR_VRMASD | LPCR_RMLS | LPCR_ILE | 6209 LPCR_AIL | LPCR_ONL | LPCR_P8_PECE0 | LPCR_P8_PECE1 | 6210 LPCR_P8_PECE2 | LPCR_P8_PECE3 | LPCR_P8_PECE4 | 6211 LPCR_MER | LPCR_TC | LPCR_LPES0 | LPCR_HDICE; 6212 pcc->lpcr_pm = LPCR_P8_PECE0 | LPCR_P8_PECE1 | LPCR_P8_PECE2 | 6213 LPCR_P8_PECE3 | LPCR_P8_PECE4; 6214 pcc->mmu_model = POWERPC_MMU_2_07; 6215 #if defined(CONFIG_SOFTMMU) 6216 pcc->hash64_opts = &ppc_hash64_opts_POWER7; 6217 pcc->lrg_decr_bits = 32; 6218 pcc->n_host_threads = 8; 6219 #endif 6220 pcc->excp_model = POWERPC_EXCP_POWER8; 6221 pcc->bus_model = PPC_FLAGS_INPUT_POWER7; 6222 pcc->bfd_mach = bfd_mach_ppc64; 6223 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 6224 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 6225 POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR | 6226 POWERPC_FLAG_VSX | POWERPC_FLAG_TM; 6227 pcc->l1_dcache_size = 0x8000; 6228 pcc->l1_icache_size = 0x8000; 6229 } 6230 6231 #ifdef CONFIG_SOFTMMU 6232 /* 6233 * Radix pg sizes and AP encodings for dt node ibm,processor-radix-AP-encodings 6234 * Encoded as array of int_32s in the form: 6235 * 0bxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 6236 * x -> AP encoding 6237 * y -> radix mode supported page size (encoded as a shift) 6238 */ 6239 static struct ppc_radix_page_info POWER9_radix_page_info = { 6240 .count = 4, 6241 .entries = { 6242 0x0000000c, /* 4K - enc: 0x0 */ 6243 0xa0000010, /* 64K - enc: 0x5 */ 6244 0x20000015, /* 2M - enc: 0x1 */ 6245 0x4000001e /* 1G - enc: 0x2 */ 6246 } 6247 }; 6248 #endif /* CONFIG_SOFTMMU */ 6249 6250 static void init_proc_POWER9(CPUPPCState *env) 6251 { 6252 /* Common Registers */ 6253 init_proc_book3s_common(env); 6254 register_book3s_207_dbg_sprs(env); 6255 6256 /* Common TCG PMU */ 6257 init_tcg_pmu_power8(env); 6258 6259 /* POWER8 Specific Registers */ 6260 register_book3s_ids_sprs(env); 6261 register_amr_sprs(env); 6262 register_iamr_sprs(env); 6263 register_book3s_purr_sprs(env); 6264 register_power5p_common_sprs(env); 6265 register_power5p_lpar_sprs(env); 6266 register_power5p_ear_sprs(env); 6267 register_power5p_tb_sprs(env); 6268 register_power6_common_sprs(env); 6269 register_power6_dbg_sprs(env); 6270 register_power8_tce_address_control_sprs(env); 6271 register_power8_ids_sprs(env); 6272 register_power8_ebb_sprs(env); 6273 register_power8_fscr_sprs(env); 6274 register_power8_pmu_sup_sprs(env); 6275 register_power8_pmu_user_sprs(env); 6276 register_power8_tm_sprs(env); 6277 register_power8_pspb_sprs(env); 6278 register_power8_dpdes_sprs(env); 6279 register_vtb_sprs(env); 6280 register_power8_ic_sprs(env); 6281 register_power8_book4_sprs(env); 6282 register_power8_rpr_sprs(env); 6283 register_power9_mmu_sprs(env); 6284 6285 /* POWER9 Specific registers */ 6286 spr_register_kvm(env, SPR_TIDR, "TIDR", NULL, NULL, 6287 spr_read_generic, spr_write_generic, 6288 KVM_REG_PPC_TIDR, 0); 6289 6290 /* FIXME: Filter fields properly based on privilege level */ 6291 spr_register_kvm_hv(env, SPR_PSSCR, "PSSCR", NULL, NULL, NULL, NULL, 6292 spr_read_generic, spr_write_generic, 6293 KVM_REG_PPC_PSSCR, 0); 6294 6295 /* env variables */ 6296 env->dcache_line_size = 128; 6297 env->icache_line_size = 128; 6298 6299 /* Allocate hardware IRQ controller */ 6300 init_excp_POWER9(env); 6301 ppcPOWER9_irq_init(env_archcpu(env)); 6302 } 6303 6304 static bool ppc_pvr_match_power9(PowerPCCPUClass *pcc, uint32_t pvr, bool best) 6305 { 6306 uint32_t base = pvr & CPU_POWERPC_POWER_SERVER_MASK; 6307 uint32_t pcc_base = pcc->pvr & CPU_POWERPC_POWER_SERVER_MASK; 6308 6309 if (!best) { 6310 if (base == CPU_POWERPC_POWER9_BASE) { 6311 return true; 6312 } 6313 } 6314 6315 if (base != pcc_base) { 6316 return false; 6317 } 6318 6319 if ((pvr & 0x0f00) == (pcc->pvr & 0x0f00)) { 6320 /* Major DD version matches to power9_v1.0 and power9_v2.0 */ 6321 return true; 6322 } 6323 6324 return false; 6325 } 6326 6327 static bool cpu_has_work_POWER9(CPUState *cs) 6328 { 6329 PowerPCCPU *cpu = POWERPC_CPU(cs); 6330 CPUPPCState *env = &cpu->env; 6331 6332 if (cs->halted) { 6333 uint64_t psscr = env->spr[SPR_PSSCR]; 6334 6335 if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) { 6336 return false; 6337 } 6338 6339 /* If EC is clear, just return true on any pending interrupt */ 6340 if (!(psscr & PSSCR_EC)) { 6341 return true; 6342 } 6343 /* External Exception */ 6344 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) && 6345 (env->spr[SPR_LPCR] & LPCR_EEE)) { 6346 bool heic = !!(env->spr[SPR_LPCR] & LPCR_HEIC); 6347 if (!heic || !FIELD_EX64_HV(env->msr) || 6348 FIELD_EX64(env->msr, MSR, PR)) { 6349 return true; 6350 } 6351 } 6352 /* Decrementer Exception */ 6353 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) && 6354 (env->spr[SPR_LPCR] & LPCR_DEE)) { 6355 return true; 6356 } 6357 /* Machine Check or Hypervisor Maintenance Exception */ 6358 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK | 6359 1u << PPC_INTERRUPT_HMI)) && (env->spr[SPR_LPCR] & LPCR_OEE)) { 6360 return true; 6361 } 6362 /* Privileged Doorbell Exception */ 6363 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DOORBELL)) && 6364 (env->spr[SPR_LPCR] & LPCR_PDEE)) { 6365 return true; 6366 } 6367 /* Hypervisor Doorbell Exception */ 6368 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HDOORBELL)) && 6369 (env->spr[SPR_LPCR] & LPCR_HDEE)) { 6370 return true; 6371 } 6372 /* Hypervisor virtualization exception */ 6373 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HVIRT)) && 6374 (env->spr[SPR_LPCR] & LPCR_HVEE)) { 6375 return true; 6376 } 6377 if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) { 6378 return true; 6379 } 6380 return false; 6381 } else { 6382 return FIELD_EX64(env->msr, MSR, EE) && 6383 (cs->interrupt_request & CPU_INTERRUPT_HARD); 6384 } 6385 } 6386 6387 POWERPC_FAMILY(POWER9)(ObjectClass *oc, void *data) 6388 { 6389 DeviceClass *dc = DEVICE_CLASS(oc); 6390 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 6391 CPUClass *cc = CPU_CLASS(oc); 6392 6393 dc->fw_name = "PowerPC,POWER9"; 6394 dc->desc = "POWER9"; 6395 pcc->pvr_match = ppc_pvr_match_power9; 6396 pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06 | PCR_COMPAT_2_07; 6397 pcc->pcr_supported = PCR_COMPAT_3_00 | PCR_COMPAT_2_07 | PCR_COMPAT_2_06 | 6398 PCR_COMPAT_2_05; 6399 pcc->init_proc = init_proc_POWER9; 6400 pcc->check_pow = check_pow_nocheck; 6401 cc->has_work = cpu_has_work_POWER9; 6402 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB | 6403 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 6404 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 6405 PPC_FLOAT_FRSQRTES | 6406 PPC_FLOAT_STFIWX | 6407 PPC_FLOAT_EXT | 6408 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 6409 PPC_MEM_SYNC | PPC_MEM_EIEIO | 6410 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 6411 PPC_64B | PPC_64H | PPC_64BX | PPC_ALTIVEC | 6412 PPC_SEGMENT_64B | PPC_SLBI | 6413 PPC_POPCNTB | PPC_POPCNTWD | 6414 PPC_CILDST; 6415 pcc->insns_flags2 = PPC2_VSX | PPC2_VSX207 | PPC2_DFP | PPC2_DBRX | 6416 PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | 6417 PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 | 6418 PPC2_FP_TST_ISA206 | PPC2_BCTAR_ISA207 | 6419 PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 | 6420 PPC2_ISA205 | PPC2_ISA207S | PPC2_FP_CVT_S64 | 6421 PPC2_TM | PPC2_ISA300 | PPC2_PRCNTL | PPC2_MEM_LWSYNC | 6422 PPC2_BCDA_ISA206; 6423 pcc->msr_mask = (1ull << MSR_SF) | 6424 (1ull << MSR_HV) | 6425 (1ull << MSR_TM) | 6426 (1ull << MSR_VR) | 6427 (1ull << MSR_VSX) | 6428 (1ull << MSR_EE) | 6429 (1ull << MSR_PR) | 6430 (1ull << MSR_FP) | 6431 (1ull << MSR_ME) | 6432 (1ull << MSR_FE0) | 6433 (1ull << MSR_SE) | 6434 (1ull << MSR_DE) | 6435 (1ull << MSR_FE1) | 6436 (1ull << MSR_IR) | 6437 (1ull << MSR_DR) | 6438 (1ull << MSR_PMM) | 6439 (1ull << MSR_RI) | 6440 (1ull << MSR_LE); 6441 pcc->lpcr_mask = LPCR_VPM1 | LPCR_ISL | LPCR_KBV | LPCR_DPFD | 6442 (LPCR_PECE_U_MASK & LPCR_HVEE) | LPCR_ILE | LPCR_AIL | 6443 LPCR_UPRT | LPCR_EVIRT | LPCR_ONL | LPCR_HR | LPCR_LD | 6444 (LPCR_PECE_L_MASK & (LPCR_PDEE | LPCR_HDEE | LPCR_EEE | 6445 LPCR_DEE | LPCR_OEE)) 6446 | LPCR_MER | LPCR_GTSE | LPCR_TC | 6447 LPCR_HEIC | LPCR_LPES0 | LPCR_HVICE | LPCR_HDICE; 6448 pcc->lpcr_pm = LPCR_PDEE | LPCR_HDEE | LPCR_EEE | LPCR_DEE | LPCR_OEE; 6449 pcc->mmu_model = POWERPC_MMU_3_00; 6450 #if defined(CONFIG_SOFTMMU) 6451 /* segment page size remain the same */ 6452 pcc->hash64_opts = &ppc_hash64_opts_POWER7; 6453 pcc->radix_page_info = &POWER9_radix_page_info; 6454 pcc->lrg_decr_bits = 56; 6455 pcc->n_host_threads = 4; 6456 #endif 6457 pcc->excp_model = POWERPC_EXCP_POWER9; 6458 pcc->bus_model = PPC_FLAGS_INPUT_POWER9; 6459 pcc->bfd_mach = bfd_mach_ppc64; 6460 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 6461 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 6462 POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR | 6463 POWERPC_FLAG_VSX | POWERPC_FLAG_TM | POWERPC_FLAG_SCV; 6464 pcc->l1_dcache_size = 0x8000; 6465 pcc->l1_icache_size = 0x8000; 6466 } 6467 6468 #ifdef CONFIG_SOFTMMU 6469 /* 6470 * Radix pg sizes and AP encodings for dt node ibm,processor-radix-AP-encodings 6471 * Encoded as array of int_32s in the form: 6472 * 0bxxxyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 6473 * x -> AP encoding 6474 * y -> radix mode supported page size (encoded as a shift) 6475 */ 6476 static struct ppc_radix_page_info POWER10_radix_page_info = { 6477 .count = 4, 6478 .entries = { 6479 0x0000000c, /* 4K - enc: 0x0 */ 6480 0xa0000010, /* 64K - enc: 0x5 */ 6481 0x20000015, /* 2M - enc: 0x1 */ 6482 0x4000001e /* 1G - enc: 0x2 */ 6483 } 6484 }; 6485 #endif /* CONFIG_SOFTMMU */ 6486 6487 static void init_proc_POWER10(CPUPPCState *env) 6488 { 6489 /* Common Registers */ 6490 init_proc_book3s_common(env); 6491 register_book3s_207_dbg_sprs(env); 6492 6493 /* Common TCG PMU */ 6494 init_tcg_pmu_power8(env); 6495 6496 /* POWER8 Specific Registers */ 6497 register_book3s_ids_sprs(env); 6498 register_amr_sprs(env); 6499 register_iamr_sprs(env); 6500 register_book3s_purr_sprs(env); 6501 register_power5p_common_sprs(env); 6502 register_power5p_lpar_sprs(env); 6503 register_power5p_ear_sprs(env); 6504 register_power5p_tb_sprs(env); 6505 register_power6_common_sprs(env); 6506 register_power6_dbg_sprs(env); 6507 register_power8_tce_address_control_sprs(env); 6508 register_power8_ids_sprs(env); 6509 register_power8_ebb_sprs(env); 6510 register_power8_fscr_sprs(env); 6511 register_power8_pmu_sup_sprs(env); 6512 register_power8_pmu_user_sprs(env); 6513 register_power8_tm_sprs(env); 6514 register_power8_pspb_sprs(env); 6515 register_power8_dpdes_sprs(env); 6516 register_vtb_sprs(env); 6517 register_power8_ic_sprs(env); 6518 register_power8_book4_sprs(env); 6519 register_power8_rpr_sprs(env); 6520 register_power9_mmu_sprs(env); 6521 6522 /* FIXME: Filter fields properly based on privilege level */ 6523 spr_register_kvm_hv(env, SPR_PSSCR, "PSSCR", NULL, NULL, NULL, NULL, 6524 spr_read_generic, spr_write_generic, 6525 KVM_REG_PPC_PSSCR, 0); 6526 6527 /* env variables */ 6528 env->dcache_line_size = 128; 6529 env->icache_line_size = 128; 6530 6531 /* Allocate hardware IRQ controller */ 6532 init_excp_POWER10(env); 6533 ppcPOWER9_irq_init(env_archcpu(env)); 6534 } 6535 6536 static bool ppc_pvr_match_power10(PowerPCCPUClass *pcc, uint32_t pvr, bool best) 6537 { 6538 uint32_t base = pvr & CPU_POWERPC_POWER_SERVER_MASK; 6539 uint32_t pcc_base = pcc->pvr & CPU_POWERPC_POWER_SERVER_MASK; 6540 6541 if (!best) { 6542 if (base == CPU_POWERPC_POWER10_BASE) { 6543 return true; 6544 } 6545 } 6546 6547 if (base != pcc_base) { 6548 return false; 6549 } 6550 6551 if ((pvr & 0x0f00) == (pcc->pvr & 0x0f00)) { 6552 /* Major DD version matches to power10_v1.0 and power10_v2.0 */ 6553 return true; 6554 } 6555 6556 return false; 6557 } 6558 6559 static bool cpu_has_work_POWER10(CPUState *cs) 6560 { 6561 PowerPCCPU *cpu = POWERPC_CPU(cs); 6562 CPUPPCState *env = &cpu->env; 6563 6564 if (cs->halted) { 6565 uint64_t psscr = env->spr[SPR_PSSCR]; 6566 6567 if (!(cs->interrupt_request & CPU_INTERRUPT_HARD)) { 6568 return false; 6569 } 6570 6571 /* If EC is clear, just return true on any pending interrupt */ 6572 if (!(psscr & PSSCR_EC)) { 6573 return true; 6574 } 6575 /* External Exception */ 6576 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_EXT)) && 6577 (env->spr[SPR_LPCR] & LPCR_EEE)) { 6578 bool heic = !!(env->spr[SPR_LPCR] & LPCR_HEIC); 6579 if (!heic || !FIELD_EX64_HV(env->msr) || 6580 FIELD_EX64(env->msr, MSR, PR)) { 6581 return true; 6582 } 6583 } 6584 /* Decrementer Exception */ 6585 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DECR)) && 6586 (env->spr[SPR_LPCR] & LPCR_DEE)) { 6587 return true; 6588 } 6589 /* Machine Check or Hypervisor Maintenance Exception */ 6590 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_MCK | 6591 1u << PPC_INTERRUPT_HMI)) && (env->spr[SPR_LPCR] & LPCR_OEE)) { 6592 return true; 6593 } 6594 /* Privileged Doorbell Exception */ 6595 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_DOORBELL)) && 6596 (env->spr[SPR_LPCR] & LPCR_PDEE)) { 6597 return true; 6598 } 6599 /* Hypervisor Doorbell Exception */ 6600 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HDOORBELL)) && 6601 (env->spr[SPR_LPCR] & LPCR_HDEE)) { 6602 return true; 6603 } 6604 /* Hypervisor virtualization exception */ 6605 if ((env->pending_interrupts & (1u << PPC_INTERRUPT_HVIRT)) && 6606 (env->spr[SPR_LPCR] & LPCR_HVEE)) { 6607 return true; 6608 } 6609 if (env->pending_interrupts & (1u << PPC_INTERRUPT_RESET)) { 6610 return true; 6611 } 6612 return false; 6613 } else { 6614 return FIELD_EX64(env->msr, MSR, EE) && 6615 (cs->interrupt_request & CPU_INTERRUPT_HARD); 6616 } 6617 } 6618 6619 POWERPC_FAMILY(POWER10)(ObjectClass *oc, void *data) 6620 { 6621 DeviceClass *dc = DEVICE_CLASS(oc); 6622 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 6623 CPUClass *cc = CPU_CLASS(oc); 6624 6625 dc->fw_name = "PowerPC,POWER10"; 6626 dc->desc = "POWER10"; 6627 pcc->pvr_match = ppc_pvr_match_power10; 6628 pcc->pcr_mask = PCR_COMPAT_2_05 | PCR_COMPAT_2_06 | PCR_COMPAT_2_07 | 6629 PCR_COMPAT_3_00; 6630 pcc->pcr_supported = PCR_COMPAT_3_10 | PCR_COMPAT_3_00 | PCR_COMPAT_2_07 | 6631 PCR_COMPAT_2_06 | PCR_COMPAT_2_05; 6632 pcc->init_proc = init_proc_POWER10; 6633 pcc->check_pow = check_pow_nocheck; 6634 cc->has_work = cpu_has_work_POWER10; 6635 pcc->insns_flags = PPC_INSNS_BASE | PPC_ISEL | PPC_STRING | PPC_MFTB | 6636 PPC_FLOAT | PPC_FLOAT_FSEL | PPC_FLOAT_FRES | 6637 PPC_FLOAT_FSQRT | PPC_FLOAT_FRSQRTE | 6638 PPC_FLOAT_FRSQRTES | 6639 PPC_FLOAT_STFIWX | 6640 PPC_FLOAT_EXT | 6641 PPC_CACHE | PPC_CACHE_ICBI | PPC_CACHE_DCBZ | 6642 PPC_MEM_SYNC | PPC_MEM_EIEIO | 6643 PPC_MEM_TLBIE | PPC_MEM_TLBSYNC | 6644 PPC_64B | PPC_64H | PPC_64BX | PPC_ALTIVEC | 6645 PPC_SEGMENT_64B | PPC_SLBI | 6646 PPC_POPCNTB | PPC_POPCNTWD | 6647 PPC_CILDST; 6648 pcc->insns_flags2 = PPC2_VSX | PPC2_VSX207 | PPC2_DFP | PPC2_DBRX | 6649 PPC2_PERM_ISA206 | PPC2_DIVE_ISA206 | 6650 PPC2_ATOMIC_ISA206 | PPC2_FP_CVT_ISA206 | 6651 PPC2_FP_TST_ISA206 | PPC2_BCTAR_ISA207 | 6652 PPC2_LSQ_ISA207 | PPC2_ALTIVEC_207 | 6653 PPC2_ISA205 | PPC2_ISA207S | PPC2_FP_CVT_S64 | 6654 PPC2_TM | PPC2_ISA300 | PPC2_PRCNTL | PPC2_ISA310 | 6655 PPC2_MEM_LWSYNC | PPC2_BCDA_ISA206; 6656 pcc->msr_mask = (1ull << MSR_SF) | 6657 (1ull << MSR_HV) | 6658 (1ull << MSR_TM) | 6659 (1ull << MSR_VR) | 6660 (1ull << MSR_VSX) | 6661 (1ull << MSR_EE) | 6662 (1ull << MSR_PR) | 6663 (1ull << MSR_FP) | 6664 (1ull << MSR_ME) | 6665 (1ull << MSR_FE0) | 6666 (1ull << MSR_SE) | 6667 (1ull << MSR_DE) | 6668 (1ull << MSR_FE1) | 6669 (1ull << MSR_IR) | 6670 (1ull << MSR_DR) | 6671 (1ull << MSR_PMM) | 6672 (1ull << MSR_RI) | 6673 (1ull << MSR_LE); 6674 pcc->lpcr_mask = LPCR_VPM1 | LPCR_ISL | LPCR_KBV | LPCR_DPFD | 6675 (LPCR_PECE_U_MASK & LPCR_HVEE) | LPCR_ILE | LPCR_AIL | 6676 LPCR_UPRT | LPCR_EVIRT | LPCR_ONL | LPCR_HR | LPCR_LD | 6677 (LPCR_PECE_L_MASK & (LPCR_PDEE | LPCR_HDEE | LPCR_EEE | 6678 LPCR_DEE | LPCR_OEE)) 6679 | LPCR_MER | LPCR_GTSE | LPCR_TC | 6680 LPCR_HEIC | LPCR_LPES0 | LPCR_HVICE | LPCR_HDICE; 6681 /* DD2 adds an extra HAIL bit */ 6682 pcc->lpcr_mask |= LPCR_HAIL; 6683 6684 pcc->lpcr_pm = LPCR_PDEE | LPCR_HDEE | LPCR_EEE | LPCR_DEE | LPCR_OEE; 6685 pcc->mmu_model = POWERPC_MMU_3_00; 6686 #if defined(CONFIG_SOFTMMU) 6687 /* segment page size remain the same */ 6688 pcc->hash64_opts = &ppc_hash64_opts_POWER7; 6689 pcc->radix_page_info = &POWER10_radix_page_info; 6690 pcc->lrg_decr_bits = 56; 6691 #endif 6692 pcc->excp_model = POWERPC_EXCP_POWER10; 6693 pcc->bus_model = PPC_FLAGS_INPUT_POWER9; 6694 pcc->bfd_mach = bfd_mach_ppc64; 6695 pcc->flags = POWERPC_FLAG_VRE | POWERPC_FLAG_SE | 6696 POWERPC_FLAG_BE | POWERPC_FLAG_PMM | 6697 POWERPC_FLAG_BUS_CLK | POWERPC_FLAG_CFAR | 6698 POWERPC_FLAG_VSX | POWERPC_FLAG_TM | POWERPC_FLAG_SCV; 6699 pcc->l1_dcache_size = 0x8000; 6700 pcc->l1_icache_size = 0x8000; 6701 } 6702 6703 #if !defined(CONFIG_USER_ONLY) 6704 void cpu_ppc_set_vhyp(PowerPCCPU *cpu, PPCVirtualHypervisor *vhyp) 6705 { 6706 CPUPPCState *env = &cpu->env; 6707 6708 cpu->vhyp = vhyp; 6709 6710 /* 6711 * With a virtual hypervisor mode we never allow the CPU to go 6712 * hypervisor mode itself 6713 */ 6714 env->msr_mask &= ~MSR_HVB; 6715 } 6716 6717 #endif /* !defined(CONFIG_USER_ONLY) */ 6718 6719 #endif /* defined(TARGET_PPC64) */ 6720 6721 /*****************************************************************************/ 6722 /* Generic CPU instantiation routine */ 6723 static void init_ppc_proc(PowerPCCPU *cpu) 6724 { 6725 PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); 6726 CPUPPCState *env = &cpu->env; 6727 #if !defined(CONFIG_USER_ONLY) 6728 int i; 6729 6730 /* Set all exception vectors to an invalid address */ 6731 for (i = 0; i < POWERPC_EXCP_NB; i++) { 6732 env->excp_vectors[i] = (target_ulong)(-1ULL); 6733 } 6734 env->ivor_mask = 0x00000000; 6735 env->ivpr_mask = 0x00000000; 6736 /* Default MMU definitions */ 6737 env->nb_BATs = 0; 6738 env->nb_tlb = 0; 6739 env->nb_ways = 0; 6740 env->tlb_type = TLB_NONE; 6741 #endif 6742 /* Register SPR common to all PowerPC implementations */ 6743 register_generic_sprs(cpu); 6744 6745 /* PowerPC implementation specific initialisations (SPRs, timers, ...) */ 6746 (*pcc->init_proc)(env); 6747 6748 #if !defined(CONFIG_USER_ONLY) 6749 ppc_gdb_gen_spr_xml(cpu); 6750 #endif 6751 6752 /* MSR bits & flags consistency checks */ 6753 if (env->msr_mask & (1 << 25)) { 6754 switch (env->flags & (POWERPC_FLAG_SPE | POWERPC_FLAG_VRE)) { 6755 case POWERPC_FLAG_SPE: 6756 case POWERPC_FLAG_VRE: 6757 break; 6758 default: 6759 fprintf(stderr, "PowerPC MSR definition inconsistency\n" 6760 "Should define POWERPC_FLAG_SPE or POWERPC_FLAG_VRE\n"); 6761 exit(1); 6762 } 6763 } else if (env->flags & (POWERPC_FLAG_SPE | POWERPC_FLAG_VRE)) { 6764 fprintf(stderr, "PowerPC MSR definition inconsistency\n" 6765 "Should not define POWERPC_FLAG_SPE nor POWERPC_FLAG_VRE\n"); 6766 exit(1); 6767 } 6768 if (env->msr_mask & (1 << 17)) { 6769 switch (env->flags & (POWERPC_FLAG_TGPR | POWERPC_FLAG_CE)) { 6770 case POWERPC_FLAG_TGPR: 6771 case POWERPC_FLAG_CE: 6772 break; 6773 default: 6774 fprintf(stderr, "PowerPC MSR definition inconsistency\n" 6775 "Should define POWERPC_FLAG_TGPR or POWERPC_FLAG_CE\n"); 6776 exit(1); 6777 } 6778 } else if (env->flags & (POWERPC_FLAG_TGPR | POWERPC_FLAG_CE)) { 6779 fprintf(stderr, "PowerPC MSR definition inconsistency\n" 6780 "Should not define POWERPC_FLAG_TGPR nor POWERPC_FLAG_CE\n"); 6781 exit(1); 6782 } 6783 if (env->msr_mask & (1 << 10)) { 6784 switch (env->flags & (POWERPC_FLAG_SE | POWERPC_FLAG_DWE | 6785 POWERPC_FLAG_UBLE)) { 6786 case POWERPC_FLAG_SE: 6787 case POWERPC_FLAG_DWE: 6788 case POWERPC_FLAG_UBLE: 6789 break; 6790 default: 6791 fprintf(stderr, "PowerPC MSR definition inconsistency\n" 6792 "Should define POWERPC_FLAG_SE or POWERPC_FLAG_DWE or " 6793 "POWERPC_FLAG_UBLE\n"); 6794 exit(1); 6795 } 6796 } else if (env->flags & (POWERPC_FLAG_SE | POWERPC_FLAG_DWE | 6797 POWERPC_FLAG_UBLE)) { 6798 fprintf(stderr, "PowerPC MSR definition inconsistency\n" 6799 "Should not define POWERPC_FLAG_SE nor POWERPC_FLAG_DWE nor " 6800 "POWERPC_FLAG_UBLE\n"); 6801 exit(1); 6802 } 6803 if (env->msr_mask & (1 << 9)) { 6804 switch (env->flags & (POWERPC_FLAG_BE | POWERPC_FLAG_DE)) { 6805 case POWERPC_FLAG_BE: 6806 case POWERPC_FLAG_DE: 6807 break; 6808 default: 6809 fprintf(stderr, "PowerPC MSR definition inconsistency\n" 6810 "Should define POWERPC_FLAG_BE or POWERPC_FLAG_DE\n"); 6811 exit(1); 6812 } 6813 } else if (env->flags & (POWERPC_FLAG_BE | POWERPC_FLAG_DE)) { 6814 fprintf(stderr, "PowerPC MSR definition inconsistency\n" 6815 "Should not define POWERPC_FLAG_BE nor POWERPC_FLAG_DE\n"); 6816 exit(1); 6817 } 6818 if (env->msr_mask & (1 << 2)) { 6819 switch (env->flags & (POWERPC_FLAG_PX | POWERPC_FLAG_PMM)) { 6820 case POWERPC_FLAG_PX: 6821 case POWERPC_FLAG_PMM: 6822 break; 6823 default: 6824 fprintf(stderr, "PowerPC MSR definition inconsistency\n" 6825 "Should define POWERPC_FLAG_PX or POWERPC_FLAG_PMM\n"); 6826 exit(1); 6827 } 6828 } else if (env->flags & (POWERPC_FLAG_PX | POWERPC_FLAG_PMM)) { 6829 fprintf(stderr, "PowerPC MSR definition inconsistency\n" 6830 "Should not define POWERPC_FLAG_PX nor POWERPC_FLAG_PMM\n"); 6831 exit(1); 6832 } 6833 if ((env->flags & POWERPC_FLAG_BUS_CLK) == 0) { 6834 fprintf(stderr, "PowerPC flags inconsistency\n" 6835 "Should define the time-base and decrementer clock source\n"); 6836 exit(1); 6837 } 6838 /* Allocate TLBs buffer when needed */ 6839 #if !defined(CONFIG_USER_ONLY) 6840 if (env->nb_tlb != 0) { 6841 int nb_tlb = env->nb_tlb; 6842 if (env->id_tlbs != 0) { 6843 nb_tlb *= 2; 6844 } 6845 switch (env->tlb_type) { 6846 case TLB_6XX: 6847 env->tlb.tlb6 = g_new0(ppc6xx_tlb_t, nb_tlb); 6848 break; 6849 case TLB_EMB: 6850 env->tlb.tlbe = g_new0(ppcemb_tlb_t, nb_tlb); 6851 break; 6852 case TLB_MAS: 6853 env->tlb.tlbm = g_new0(ppcmas_tlb_t, nb_tlb); 6854 break; 6855 } 6856 /* Pre-compute some useful values */ 6857 env->tlb_per_way = env->nb_tlb / env->nb_ways; 6858 } 6859 #endif 6860 if (env->check_pow == NULL) { 6861 warn_report("no power management check handler registered." 6862 " Attempt QEMU to crash very soon !"); 6863 } 6864 } 6865 6866 6867 static void ppc_cpu_realize(DeviceState *dev, Error **errp) 6868 { 6869 CPUState *cs = CPU(dev); 6870 PowerPCCPU *cpu = POWERPC_CPU(dev); 6871 PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); 6872 Error *local_err = NULL; 6873 6874 cpu_exec_realizefn(cs, &local_err); 6875 if (local_err != NULL) { 6876 error_propagate(errp, local_err); 6877 return; 6878 } 6879 if (cpu->vcpu_id == UNASSIGNED_CPU_INDEX) { 6880 cpu->vcpu_id = cs->cpu_index; 6881 } 6882 6883 if (tcg_enabled()) { 6884 if (ppc_fixup_cpu(cpu) != 0) { 6885 error_setg(errp, "Unable to emulate selected CPU with TCG"); 6886 goto unrealize; 6887 } 6888 } 6889 6890 create_ppc_opcodes(cpu, &local_err); 6891 if (local_err != NULL) { 6892 error_propagate(errp, local_err); 6893 goto unrealize; 6894 } 6895 init_ppc_proc(cpu); 6896 6897 ppc_gdb_init(cs, pcc); 6898 qemu_init_vcpu(cs); 6899 6900 pcc->parent_realize(dev, errp); 6901 6902 return; 6903 6904 unrealize: 6905 cpu_exec_unrealizefn(cs); 6906 } 6907 6908 static void ppc_cpu_unrealize(DeviceState *dev) 6909 { 6910 PowerPCCPU *cpu = POWERPC_CPU(dev); 6911 PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); 6912 6913 pcc->parent_unrealize(dev); 6914 6915 cpu_remove_sync(CPU(cpu)); 6916 6917 destroy_ppc_opcodes(cpu); 6918 } 6919 6920 static gint ppc_cpu_compare_class_pvr(gconstpointer a, gconstpointer b) 6921 { 6922 ObjectClass *oc = (ObjectClass *)a; 6923 uint32_t pvr = *(uint32_t *)b; 6924 PowerPCCPUClass *pcc = (PowerPCCPUClass *)a; 6925 6926 /* -cpu host does a PVR lookup during construction */ 6927 if (unlikely(strcmp(object_class_get_name(oc), 6928 TYPE_HOST_POWERPC_CPU) == 0)) { 6929 return -1; 6930 } 6931 6932 return pcc->pvr == pvr ? 0 : -1; 6933 } 6934 6935 PowerPCCPUClass *ppc_cpu_class_by_pvr(uint32_t pvr) 6936 { 6937 GSList *list, *item; 6938 PowerPCCPUClass *pcc = NULL; 6939 6940 list = object_class_get_list(TYPE_POWERPC_CPU, false); 6941 item = g_slist_find_custom(list, &pvr, ppc_cpu_compare_class_pvr); 6942 if (item != NULL) { 6943 pcc = POWERPC_CPU_CLASS(item->data); 6944 } 6945 g_slist_free(list); 6946 6947 return pcc; 6948 } 6949 6950 static gint ppc_cpu_compare_class_pvr_mask(gconstpointer a, gconstpointer b) 6951 { 6952 ObjectClass *oc = (ObjectClass *)a; 6953 uint32_t pvr = *(uint32_t *)b; 6954 PowerPCCPUClass *pcc = (PowerPCCPUClass *)a; 6955 6956 /* -cpu host does a PVR lookup during construction */ 6957 if (unlikely(strcmp(object_class_get_name(oc), 6958 TYPE_HOST_POWERPC_CPU) == 0)) { 6959 return -1; 6960 } 6961 6962 if (pcc->pvr_match(pcc, pvr, true)) { 6963 return 0; 6964 } 6965 6966 return -1; 6967 } 6968 6969 PowerPCCPUClass *ppc_cpu_class_by_pvr_mask(uint32_t pvr) 6970 { 6971 GSList *list, *item; 6972 PowerPCCPUClass *pcc = NULL; 6973 6974 list = object_class_get_list(TYPE_POWERPC_CPU, true); 6975 item = g_slist_find_custom(list, &pvr, ppc_cpu_compare_class_pvr_mask); 6976 if (item != NULL) { 6977 pcc = POWERPC_CPU_CLASS(item->data); 6978 } 6979 g_slist_free(list); 6980 6981 return pcc; 6982 } 6983 6984 static const char *ppc_cpu_lookup_alias(const char *alias) 6985 { 6986 int ai; 6987 6988 for (ai = 0; ppc_cpu_aliases[ai].alias != NULL; ai++) { 6989 if (strcmp(ppc_cpu_aliases[ai].alias, alias) == 0) { 6990 return ppc_cpu_aliases[ai].model; 6991 } 6992 } 6993 6994 return NULL; 6995 } 6996 6997 static ObjectClass *ppc_cpu_class_by_name(const char *name) 6998 { 6999 char *cpu_model, *typename; 7000 ObjectClass *oc; 7001 const char *p; 7002 unsigned long pvr; 7003 7004 /* 7005 * Lookup by PVR if cpu_model is valid 8 digit hex number (excl: 7006 * 0x prefix if present) 7007 */ 7008 if (!qemu_strtoul(name, &p, 16, &pvr)) { 7009 int len = p - name; 7010 len = (len == 10) && (name[1] == 'x') ? len - 2 : len; 7011 if ((len == 8) && (*p == '\0')) { 7012 return OBJECT_CLASS(ppc_cpu_class_by_pvr(pvr)); 7013 } 7014 } 7015 7016 /* 7017 * All ppc CPUs represent hardware that exists in the real world, i.e.: we 7018 * do not have a "max" CPU with all possible emulated features enabled. 7019 * Return the default CPU type for the machine because that has greater 7020 * chance of being useful as the "max" CPU. 7021 */ 7022 #if !defined(CONFIG_USER_ONLY) 7023 if (strcmp(name, "max") == 0) { 7024 MachineClass *mc = MACHINE_GET_CLASS(qdev_get_machine()); 7025 if (mc) { 7026 return object_class_by_name(mc->default_cpu_type); 7027 } 7028 } 7029 #endif 7030 7031 cpu_model = g_ascii_strdown(name, -1); 7032 p = ppc_cpu_lookup_alias(cpu_model); 7033 if (p) { 7034 g_free(cpu_model); 7035 cpu_model = g_strdup(p); 7036 } 7037 7038 typename = g_strdup_printf("%s" POWERPC_CPU_TYPE_SUFFIX, cpu_model); 7039 oc = object_class_by_name(typename); 7040 g_free(typename); 7041 g_free(cpu_model); 7042 7043 return oc; 7044 } 7045 7046 PowerPCCPUClass *ppc_cpu_get_family_class(PowerPCCPUClass *pcc) 7047 { 7048 ObjectClass *oc = OBJECT_CLASS(pcc); 7049 7050 while (oc && !object_class_is_abstract(oc)) { 7051 oc = object_class_get_parent(oc); 7052 } 7053 assert(oc); 7054 7055 return POWERPC_CPU_CLASS(oc); 7056 } 7057 7058 /* Sort by PVR, ordering special case "host" last. */ 7059 static gint ppc_cpu_list_compare(gconstpointer a, gconstpointer b) 7060 { 7061 ObjectClass *oc_a = (ObjectClass *)a; 7062 ObjectClass *oc_b = (ObjectClass *)b; 7063 PowerPCCPUClass *pcc_a = POWERPC_CPU_CLASS(oc_a); 7064 PowerPCCPUClass *pcc_b = POWERPC_CPU_CLASS(oc_b); 7065 const char *name_a = object_class_get_name(oc_a); 7066 const char *name_b = object_class_get_name(oc_b); 7067 7068 if (strcmp(name_a, TYPE_HOST_POWERPC_CPU) == 0) { 7069 return 1; 7070 } else if (strcmp(name_b, TYPE_HOST_POWERPC_CPU) == 0) { 7071 return -1; 7072 } else { 7073 /* Avoid an integer overflow during subtraction */ 7074 if (pcc_a->pvr < pcc_b->pvr) { 7075 return -1; 7076 } else if (pcc_a->pvr > pcc_b->pvr) { 7077 return 1; 7078 } else { 7079 return 0; 7080 } 7081 } 7082 } 7083 7084 static void ppc_cpu_list_entry(gpointer data, gpointer user_data) 7085 { 7086 ObjectClass *oc = data; 7087 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 7088 DeviceClass *family = DEVICE_CLASS(ppc_cpu_get_family_class(pcc)); 7089 const char *typename = object_class_get_name(oc); 7090 char *name; 7091 int i; 7092 7093 if (unlikely(strcmp(typename, TYPE_HOST_POWERPC_CPU) == 0)) { 7094 return; 7095 } 7096 7097 name = g_strndup(typename, 7098 strlen(typename) - strlen(POWERPC_CPU_TYPE_SUFFIX)); 7099 qemu_printf("PowerPC %-16s PVR %08x\n", name, pcc->pvr); 7100 for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) { 7101 PowerPCCPUAlias *alias = &ppc_cpu_aliases[i]; 7102 ObjectClass *alias_oc = ppc_cpu_class_by_name(alias->model); 7103 7104 if (alias_oc != oc) { 7105 continue; 7106 } 7107 /* 7108 * If running with KVM, we might update the family alias later, so 7109 * avoid printing the wrong alias here and use "preferred" instead 7110 */ 7111 if (strcmp(alias->alias, family->desc) == 0) { 7112 qemu_printf("PowerPC %-16s (alias for preferred %s CPU)\n", 7113 alias->alias, family->desc); 7114 } else { 7115 qemu_printf("PowerPC %-16s (alias for %s)\n", 7116 alias->alias, name); 7117 } 7118 } 7119 g_free(name); 7120 } 7121 7122 void ppc_cpu_list(void) 7123 { 7124 GSList *list; 7125 7126 list = object_class_get_list(TYPE_POWERPC_CPU, false); 7127 list = g_slist_sort(list, ppc_cpu_list_compare); 7128 g_slist_foreach(list, ppc_cpu_list_entry, NULL); 7129 g_slist_free(list); 7130 7131 #ifdef CONFIG_KVM 7132 qemu_printf("\n"); 7133 qemu_printf("PowerPC %s\n", "host"); 7134 #endif 7135 } 7136 7137 static void ppc_cpu_defs_entry(gpointer data, gpointer user_data) 7138 { 7139 ObjectClass *oc = data; 7140 CpuDefinitionInfoList **first = user_data; 7141 const char *typename; 7142 CpuDefinitionInfo *info; 7143 7144 typename = object_class_get_name(oc); 7145 info = g_malloc0(sizeof(*info)); 7146 info->name = g_strndup(typename, 7147 strlen(typename) - strlen(POWERPC_CPU_TYPE_SUFFIX)); 7148 7149 QAPI_LIST_PREPEND(*first, info); 7150 } 7151 7152 CpuDefinitionInfoList *qmp_query_cpu_definitions(Error **errp) 7153 { 7154 CpuDefinitionInfoList *cpu_list = NULL; 7155 GSList *list; 7156 int i; 7157 7158 list = object_class_get_list(TYPE_POWERPC_CPU, false); 7159 g_slist_foreach(list, ppc_cpu_defs_entry, &cpu_list); 7160 g_slist_free(list); 7161 7162 for (i = 0; ppc_cpu_aliases[i].alias != NULL; i++) { 7163 PowerPCCPUAlias *alias = &ppc_cpu_aliases[i]; 7164 ObjectClass *oc; 7165 CpuDefinitionInfo *info; 7166 7167 oc = ppc_cpu_class_by_name(alias->model); 7168 if (oc == NULL) { 7169 continue; 7170 } 7171 7172 info = g_malloc0(sizeof(*info)); 7173 info->name = g_strdup(alias->alias); 7174 info->q_typename = g_strdup(object_class_get_name(oc)); 7175 7176 QAPI_LIST_PREPEND(cpu_list, info); 7177 } 7178 7179 return cpu_list; 7180 } 7181 7182 static void ppc_cpu_set_pc(CPUState *cs, vaddr value) 7183 { 7184 PowerPCCPU *cpu = POWERPC_CPU(cs); 7185 7186 cpu->env.nip = value; 7187 } 7188 7189 static bool ppc_cpu_has_work(CPUState *cs) 7190 { 7191 PowerPCCPU *cpu = POWERPC_CPU(cs); 7192 CPUPPCState *env = &cpu->env; 7193 7194 return FIELD_EX64(env->msr, MSR, EE) && 7195 (cs->interrupt_request & CPU_INTERRUPT_HARD); 7196 } 7197 7198 static void ppc_cpu_reset(DeviceState *dev) 7199 { 7200 CPUState *s = CPU(dev); 7201 PowerPCCPU *cpu = POWERPC_CPU(s); 7202 PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); 7203 CPUPPCState *env = &cpu->env; 7204 target_ulong msr; 7205 int i; 7206 7207 pcc->parent_reset(dev); 7208 7209 msr = (target_ulong)0; 7210 msr |= (target_ulong)MSR_HVB; 7211 msr |= (target_ulong)1 << MSR_EP; 7212 #if defined(DO_SINGLE_STEP) && 0 7213 /* Single step trace mode */ 7214 msr |= (target_ulong)1 << MSR_SE; 7215 msr |= (target_ulong)1 << MSR_BE; 7216 #endif 7217 #if defined(CONFIG_USER_ONLY) 7218 msr |= (target_ulong)1 << MSR_FP; /* Allow floating point usage */ 7219 msr |= (target_ulong)1 << MSR_FE0; /* Allow floating point exceptions */ 7220 msr |= (target_ulong)1 << MSR_FE1; 7221 msr |= (target_ulong)1 << MSR_VR; /* Allow altivec usage */ 7222 msr |= (target_ulong)1 << MSR_VSX; /* Allow VSX usage */ 7223 msr |= (target_ulong)1 << MSR_SPE; /* Allow SPE usage */ 7224 msr |= (target_ulong)1 << MSR_PR; 7225 #if defined(TARGET_PPC64) 7226 msr |= (target_ulong)1 << MSR_TM; /* Transactional memory */ 7227 #endif 7228 #if !TARGET_BIG_ENDIAN 7229 msr |= (target_ulong)1 << MSR_LE; /* Little-endian user mode */ 7230 if (!((env->msr_mask >> MSR_LE) & 1)) { 7231 fprintf(stderr, "Selected CPU does not support little-endian.\n"); 7232 exit(1); 7233 } 7234 #endif 7235 #endif 7236 7237 #if defined(TARGET_PPC64) 7238 if (mmu_is_64bit(env->mmu_model)) { 7239 msr |= (1ULL << MSR_SF); 7240 } 7241 #endif 7242 7243 hreg_store_msr(env, msr, 1); 7244 7245 #if !defined(CONFIG_USER_ONLY) 7246 env->nip = env->hreset_vector | env->excp_prefix; 7247 7248 if (tcg_enabled()) { 7249 if (env->mmu_model != POWERPC_MMU_REAL) { 7250 ppc_tlb_invalidate_all(env); 7251 } 7252 pmu_update_summaries(env); 7253 } 7254 7255 /* clean any pending stop state */ 7256 env->resume_as_sreset = 0; 7257 #endif 7258 hreg_compute_hflags(env); 7259 env->reserve_addr = (target_ulong)-1ULL; 7260 /* Be sure no exception or interrupt is pending */ 7261 env->pending_interrupts = 0; 7262 s->exception_index = POWERPC_EXCP_NONE; 7263 env->error_code = 0; 7264 ppc_irq_reset(cpu); 7265 7266 /* tininess for underflow is detected before rounding */ 7267 set_float_detect_tininess(float_tininess_before_rounding, 7268 &env->fp_status); 7269 7270 for (i = 0; i < ARRAY_SIZE(env->spr_cb); i++) { 7271 ppc_spr_t *spr = &env->spr_cb[i]; 7272 7273 if (!spr->name) { 7274 continue; 7275 } 7276 env->spr[i] = spr->default_value; 7277 } 7278 } 7279 7280 #ifndef CONFIG_USER_ONLY 7281 7282 static bool ppc_cpu_is_big_endian(CPUState *cs) 7283 { 7284 PowerPCCPU *cpu = POWERPC_CPU(cs); 7285 CPUPPCState *env = &cpu->env; 7286 7287 cpu_synchronize_state(cs); 7288 7289 return !FIELD_EX64(env->msr, MSR, LE); 7290 } 7291 7292 #ifdef CONFIG_TCG 7293 static void ppc_cpu_exec_enter(CPUState *cs) 7294 { 7295 PowerPCCPU *cpu = POWERPC_CPU(cs); 7296 7297 if (cpu->vhyp) { 7298 PPCVirtualHypervisorClass *vhc = 7299 PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp); 7300 vhc->cpu_exec_enter(cpu->vhyp, cpu); 7301 } 7302 } 7303 7304 static void ppc_cpu_exec_exit(CPUState *cs) 7305 { 7306 PowerPCCPU *cpu = POWERPC_CPU(cs); 7307 7308 if (cpu->vhyp) { 7309 PPCVirtualHypervisorClass *vhc = 7310 PPC_VIRTUAL_HYPERVISOR_GET_CLASS(cpu->vhyp); 7311 vhc->cpu_exec_exit(cpu->vhyp, cpu); 7312 } 7313 } 7314 #endif /* CONFIG_TCG */ 7315 7316 #endif /* !CONFIG_USER_ONLY */ 7317 7318 static void ppc_cpu_instance_init(Object *obj) 7319 { 7320 PowerPCCPU *cpu = POWERPC_CPU(obj); 7321 PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); 7322 CPUPPCState *env = &cpu->env; 7323 7324 cpu_set_cpustate_pointers(cpu); 7325 cpu->vcpu_id = UNASSIGNED_CPU_INDEX; 7326 7327 env->msr_mask = pcc->msr_mask; 7328 env->mmu_model = pcc->mmu_model; 7329 env->excp_model = pcc->excp_model; 7330 env->bus_model = pcc->bus_model; 7331 env->insns_flags = pcc->insns_flags; 7332 env->insns_flags2 = pcc->insns_flags2; 7333 env->flags = pcc->flags; 7334 env->bfd_mach = pcc->bfd_mach; 7335 env->check_pow = pcc->check_pow; 7336 7337 /* 7338 * Mark HV mode as supported if the CPU has an MSR_HV bit in the 7339 * msr_mask. The mask can later be cleared by PAPR mode but the hv 7340 * mode support will remain, thus enforcing that we cannot use 7341 * priv. instructions in guest in PAPR mode. For 970 we currently 7342 * simply don't set HV in msr_mask thus simulating an "Apple mode" 7343 * 970. If we ever want to support 970 HV mode, we'll have to add 7344 * a processor attribute of some sort. 7345 */ 7346 #if !defined(CONFIG_USER_ONLY) 7347 env->has_hv_mode = !!(env->msr_mask & MSR_HVB); 7348 #endif 7349 7350 ppc_hash64_init(cpu); 7351 } 7352 7353 static void ppc_cpu_instance_finalize(Object *obj) 7354 { 7355 PowerPCCPU *cpu = POWERPC_CPU(obj); 7356 7357 ppc_hash64_finalize(cpu); 7358 } 7359 7360 static bool ppc_pvr_match_default(PowerPCCPUClass *pcc, uint32_t pvr, bool best) 7361 { 7362 return pcc->pvr == pvr; 7363 } 7364 7365 static void ppc_disas_set_info(CPUState *cs, disassemble_info *info) 7366 { 7367 PowerPCCPU *cpu = POWERPC_CPU(cs); 7368 CPUPPCState *env = &cpu->env; 7369 7370 if ((env->hflags >> MSR_LE) & 1) { 7371 info->endian = BFD_ENDIAN_LITTLE; 7372 } 7373 info->mach = env->bfd_mach; 7374 if (!env->bfd_mach) { 7375 #ifdef TARGET_PPC64 7376 info->mach = bfd_mach_ppc64; 7377 #else 7378 info->mach = bfd_mach_ppc; 7379 #endif 7380 } 7381 7382 info->cap_arch = CS_ARCH_PPC; 7383 #ifdef TARGET_PPC64 7384 info->cap_mode = CS_MODE_64; 7385 #endif 7386 } 7387 7388 static Property ppc_cpu_properties[] = { 7389 DEFINE_PROP_BOOL("pre-2.8-migration", PowerPCCPU, pre_2_8_migration, false), 7390 DEFINE_PROP_BOOL("pre-2.10-migration", PowerPCCPU, pre_2_10_migration, 7391 false), 7392 DEFINE_PROP_BOOL("pre-3.0-migration", PowerPCCPU, pre_3_0_migration, 7393 false), 7394 DEFINE_PROP_END_OF_LIST(), 7395 }; 7396 7397 #ifndef CONFIG_USER_ONLY 7398 #include "hw/core/sysemu-cpu-ops.h" 7399 7400 static const struct SysemuCPUOps ppc_sysemu_ops = { 7401 .get_phys_page_debug = ppc_cpu_get_phys_page_debug, 7402 .write_elf32_note = ppc32_cpu_write_elf32_note, 7403 .write_elf64_note = ppc64_cpu_write_elf64_note, 7404 .virtio_is_big_endian = ppc_cpu_is_big_endian, 7405 .legacy_vmsd = &vmstate_ppc_cpu, 7406 }; 7407 #endif 7408 7409 #ifdef CONFIG_TCG 7410 #include "hw/core/tcg-cpu-ops.h" 7411 7412 static const struct TCGCPUOps ppc_tcg_ops = { 7413 .initialize = ppc_translate_init, 7414 7415 #ifdef CONFIG_USER_ONLY 7416 .record_sigsegv = ppc_cpu_record_sigsegv, 7417 #else 7418 .tlb_fill = ppc_cpu_tlb_fill, 7419 .cpu_exec_interrupt = ppc_cpu_exec_interrupt, 7420 .do_interrupt = ppc_cpu_do_interrupt, 7421 .cpu_exec_enter = ppc_cpu_exec_enter, 7422 .cpu_exec_exit = ppc_cpu_exec_exit, 7423 .do_unaligned_access = ppc_cpu_do_unaligned_access, 7424 #endif /* !CONFIG_USER_ONLY */ 7425 }; 7426 #endif /* CONFIG_TCG */ 7427 7428 static void ppc_cpu_class_init(ObjectClass *oc, void *data) 7429 { 7430 PowerPCCPUClass *pcc = POWERPC_CPU_CLASS(oc); 7431 CPUClass *cc = CPU_CLASS(oc); 7432 DeviceClass *dc = DEVICE_CLASS(oc); 7433 7434 device_class_set_parent_realize(dc, ppc_cpu_realize, 7435 &pcc->parent_realize); 7436 device_class_set_parent_unrealize(dc, ppc_cpu_unrealize, 7437 &pcc->parent_unrealize); 7438 pcc->pvr_match = ppc_pvr_match_default; 7439 device_class_set_props(dc, ppc_cpu_properties); 7440 7441 device_class_set_parent_reset(dc, ppc_cpu_reset, &pcc->parent_reset); 7442 7443 cc->class_by_name = ppc_cpu_class_by_name; 7444 cc->has_work = ppc_cpu_has_work; 7445 cc->dump_state = ppc_cpu_dump_state; 7446 cc->set_pc = ppc_cpu_set_pc; 7447 cc->gdb_read_register = ppc_cpu_gdb_read_register; 7448 cc->gdb_write_register = ppc_cpu_gdb_write_register; 7449 #ifndef CONFIG_USER_ONLY 7450 cc->sysemu_ops = &ppc_sysemu_ops; 7451 #endif 7452 7453 cc->gdb_num_core_regs = 71; 7454 #ifndef CONFIG_USER_ONLY 7455 cc->gdb_get_dynamic_xml = ppc_gdb_get_dynamic_xml; 7456 #endif 7457 #ifdef USE_APPLE_GDB 7458 cc->gdb_read_register = ppc_cpu_gdb_read_register_apple; 7459 cc->gdb_write_register = ppc_cpu_gdb_write_register_apple; 7460 cc->gdb_num_core_regs = 71 + 32; 7461 #endif 7462 7463 cc->gdb_arch_name = ppc_gdb_arch_name; 7464 #if defined(TARGET_PPC64) 7465 cc->gdb_core_xml_file = "power64-core.xml"; 7466 #else 7467 cc->gdb_core_xml_file = "power-core.xml"; 7468 #endif 7469 cc->disas_set_info = ppc_disas_set_info; 7470 7471 dc->fw_name = "PowerPC,UNKNOWN"; 7472 7473 #ifdef CONFIG_TCG 7474 cc->tcg_ops = &ppc_tcg_ops; 7475 #endif /* CONFIG_TCG */ 7476 } 7477 7478 static const TypeInfo ppc_cpu_type_info = { 7479 .name = TYPE_POWERPC_CPU, 7480 .parent = TYPE_CPU, 7481 .instance_size = sizeof(PowerPCCPU), 7482 .instance_align = __alignof__(PowerPCCPU), 7483 .instance_init = ppc_cpu_instance_init, 7484 .instance_finalize = ppc_cpu_instance_finalize, 7485 .abstract = true, 7486 .class_size = sizeof(PowerPCCPUClass), 7487 .class_init = ppc_cpu_class_init, 7488 }; 7489 7490 #ifndef CONFIG_USER_ONLY 7491 static const TypeInfo ppc_vhyp_type_info = { 7492 .name = TYPE_PPC_VIRTUAL_HYPERVISOR, 7493 .parent = TYPE_INTERFACE, 7494 .class_size = sizeof(PPCVirtualHypervisorClass), 7495 }; 7496 #endif 7497 7498 static void ppc_cpu_register_types(void) 7499 { 7500 type_register_static(&ppc_cpu_type_info); 7501 #ifndef CONFIG_USER_ONLY 7502 type_register_static(&ppc_vhyp_type_info); 7503 #endif 7504 } 7505 7506 void ppc_cpu_dump_state(CPUState *cs, FILE *f, int flags) 7507 { 7508 #define RGPL 4 7509 #define RFPL 4 7510 7511 PowerPCCPU *cpu = POWERPC_CPU(cs); 7512 CPUPPCState *env = &cpu->env; 7513 int i; 7514 7515 qemu_fprintf(f, "NIP " TARGET_FMT_lx " LR " TARGET_FMT_lx " CTR " 7516 TARGET_FMT_lx " XER " TARGET_FMT_lx " CPU#%d\n", 7517 env->nip, env->lr, env->ctr, cpu_read_xer(env), 7518 cs->cpu_index); 7519 qemu_fprintf(f, "MSR " TARGET_FMT_lx " HID0 " TARGET_FMT_lx " HF " 7520 "%08x iidx %d didx %d\n", 7521 env->msr, env->spr[SPR_HID0], env->hflags, 7522 cpu_mmu_index(env, true), cpu_mmu_index(env, false)); 7523 #if !defined(CONFIG_USER_ONLY) 7524 if (env->tb_env) { 7525 qemu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64 7526 " DECR " TARGET_FMT_lu "\n", cpu_ppc_load_tbu(env), 7527 cpu_ppc_load_tbl(env), cpu_ppc_load_decr(env)); 7528 } 7529 #else 7530 qemu_fprintf(f, "TB %08" PRIu32 " %08" PRIu64 "\n", cpu_ppc_load_tbu(env), 7531 cpu_ppc_load_tbl(env)); 7532 #endif 7533 for (i = 0; i < 32; i++) { 7534 if ((i & (RGPL - 1)) == 0) { 7535 qemu_fprintf(f, "GPR%02d", i); 7536 } 7537 qemu_fprintf(f, " %016" PRIx64, ppc_dump_gpr(env, i)); 7538 if ((i & (RGPL - 1)) == (RGPL - 1)) { 7539 qemu_fprintf(f, "\n"); 7540 } 7541 } 7542 qemu_fprintf(f, "CR "); 7543 for (i = 0; i < 8; i++) 7544 qemu_fprintf(f, "%01x", env->crf[i]); 7545 qemu_fprintf(f, " ["); 7546 for (i = 0; i < 8; i++) { 7547 char a = '-'; 7548 if (env->crf[i] & 0x08) { 7549 a = 'L'; 7550 } else if (env->crf[i] & 0x04) { 7551 a = 'G'; 7552 } else if (env->crf[i] & 0x02) { 7553 a = 'E'; 7554 } 7555 qemu_fprintf(f, " %c%c", a, env->crf[i] & 0x01 ? 'O' : ' '); 7556 } 7557 qemu_fprintf(f, " ] RES " TARGET_FMT_lx "\n", 7558 env->reserve_addr); 7559 7560 if (flags & CPU_DUMP_FPU) { 7561 for (i = 0; i < 32; i++) { 7562 if ((i & (RFPL - 1)) == 0) { 7563 qemu_fprintf(f, "FPR%02d", i); 7564 } 7565 qemu_fprintf(f, " %016" PRIx64, *cpu_fpr_ptr(env, i)); 7566 if ((i & (RFPL - 1)) == (RFPL - 1)) { 7567 qemu_fprintf(f, "\n"); 7568 } 7569 } 7570 qemu_fprintf(f, "FPSCR " TARGET_FMT_lx "\n", env->fpscr); 7571 } 7572 7573 #if !defined(CONFIG_USER_ONLY) 7574 qemu_fprintf(f, " SRR0 " TARGET_FMT_lx " SRR1 " TARGET_FMT_lx 7575 " PVR " TARGET_FMT_lx " VRSAVE " TARGET_FMT_lx "\n", 7576 env->spr[SPR_SRR0], env->spr[SPR_SRR1], 7577 env->spr[SPR_PVR], env->spr[SPR_VRSAVE]); 7578 7579 qemu_fprintf(f, "SPRG0 " TARGET_FMT_lx " SPRG1 " TARGET_FMT_lx 7580 " SPRG2 " TARGET_FMT_lx " SPRG3 " TARGET_FMT_lx "\n", 7581 env->spr[SPR_SPRG0], env->spr[SPR_SPRG1], 7582 env->spr[SPR_SPRG2], env->spr[SPR_SPRG3]); 7583 7584 qemu_fprintf(f, "SPRG4 " TARGET_FMT_lx " SPRG5 " TARGET_FMT_lx 7585 " SPRG6 " TARGET_FMT_lx " SPRG7 " TARGET_FMT_lx "\n", 7586 env->spr[SPR_SPRG4], env->spr[SPR_SPRG5], 7587 env->spr[SPR_SPRG6], env->spr[SPR_SPRG7]); 7588 7589 switch (env->excp_model) { 7590 #if defined(TARGET_PPC64) 7591 case POWERPC_EXCP_POWER7: 7592 case POWERPC_EXCP_POWER8: 7593 case POWERPC_EXCP_POWER9: 7594 case POWERPC_EXCP_POWER10: 7595 qemu_fprintf(f, "HSRR0 " TARGET_FMT_lx " HSRR1 " TARGET_FMT_lx "\n", 7596 env->spr[SPR_HSRR0], env->spr[SPR_HSRR1]); 7597 break; 7598 #endif 7599 case POWERPC_EXCP_BOOKE: 7600 qemu_fprintf(f, "CSRR0 " TARGET_FMT_lx " CSRR1 " TARGET_FMT_lx 7601 " MCSRR0 " TARGET_FMT_lx " MCSRR1 " TARGET_FMT_lx "\n", 7602 env->spr[SPR_BOOKE_CSRR0], env->spr[SPR_BOOKE_CSRR1], 7603 env->spr[SPR_BOOKE_MCSRR0], env->spr[SPR_BOOKE_MCSRR1]); 7604 7605 qemu_fprintf(f, " TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx 7606 " ESR " TARGET_FMT_lx " DEAR " TARGET_FMT_lx "\n", 7607 env->spr[SPR_BOOKE_TCR], env->spr[SPR_BOOKE_TSR], 7608 env->spr[SPR_BOOKE_ESR], env->spr[SPR_BOOKE_DEAR]); 7609 7610 qemu_fprintf(f, " PIR " TARGET_FMT_lx " DECAR " TARGET_FMT_lx 7611 " IVPR " TARGET_FMT_lx " EPCR " TARGET_FMT_lx "\n", 7612 env->spr[SPR_BOOKE_PIR], env->spr[SPR_BOOKE_DECAR], 7613 env->spr[SPR_BOOKE_IVPR], env->spr[SPR_BOOKE_EPCR]); 7614 7615 qemu_fprintf(f, " MCSR " TARGET_FMT_lx " SPRG8 " TARGET_FMT_lx 7616 " EPR " TARGET_FMT_lx "\n", 7617 env->spr[SPR_BOOKE_MCSR], env->spr[SPR_BOOKE_SPRG8], 7618 env->spr[SPR_BOOKE_EPR]); 7619 7620 /* FSL-specific */ 7621 qemu_fprintf(f, " MCAR " TARGET_FMT_lx " PID1 " TARGET_FMT_lx 7622 " PID2 " TARGET_FMT_lx " SVR " TARGET_FMT_lx "\n", 7623 env->spr[SPR_Exxx_MCAR], env->spr[SPR_BOOKE_PID1], 7624 env->spr[SPR_BOOKE_PID2], env->spr[SPR_E500_SVR]); 7625 7626 /* 7627 * IVORs are left out as they are large and do not change often -- 7628 * they can be read with "p $ivor0", "p $ivor1", etc. 7629 */ 7630 break; 7631 case POWERPC_EXCP_40x: 7632 qemu_fprintf(f, " TCR " TARGET_FMT_lx " TSR " TARGET_FMT_lx 7633 " ESR " TARGET_FMT_lx " DEAR " TARGET_FMT_lx "\n", 7634 env->spr[SPR_40x_TCR], env->spr[SPR_40x_TSR], 7635 env->spr[SPR_40x_ESR], env->spr[SPR_40x_DEAR]); 7636 7637 qemu_fprintf(f, " EVPR " TARGET_FMT_lx " SRR2 " TARGET_FMT_lx 7638 " SRR3 " TARGET_FMT_lx " PID " TARGET_FMT_lx "\n", 7639 env->spr[SPR_40x_EVPR], env->spr[SPR_40x_SRR2], 7640 env->spr[SPR_40x_SRR3], env->spr[SPR_40x_PID]); 7641 break; 7642 default: 7643 break; 7644 } 7645 7646 #if defined(TARGET_PPC64) 7647 if (env->flags & POWERPC_FLAG_CFAR) { 7648 qemu_fprintf(f, " CFAR " TARGET_FMT_lx"\n", env->cfar); 7649 } 7650 #endif 7651 7652 if (env->spr_cb[SPR_LPCR].name) { 7653 qemu_fprintf(f, " LPCR " TARGET_FMT_lx "\n", env->spr[SPR_LPCR]); 7654 } 7655 7656 switch (env->mmu_model) { 7657 case POWERPC_MMU_32B: 7658 case POWERPC_MMU_SOFT_6xx: 7659 #if defined(TARGET_PPC64) 7660 case POWERPC_MMU_64B: 7661 case POWERPC_MMU_2_03: 7662 case POWERPC_MMU_2_06: 7663 case POWERPC_MMU_2_07: 7664 case POWERPC_MMU_3_00: 7665 #endif 7666 if (env->spr_cb[SPR_SDR1].name) { /* SDR1 Exists */ 7667 qemu_fprintf(f, " SDR1 " TARGET_FMT_lx " ", env->spr[SPR_SDR1]); 7668 } 7669 if (env->spr_cb[SPR_PTCR].name) { /* PTCR Exists */ 7670 qemu_fprintf(f, " PTCR " TARGET_FMT_lx " ", env->spr[SPR_PTCR]); 7671 } 7672 qemu_fprintf(f, " DAR " TARGET_FMT_lx " DSISR " TARGET_FMT_lx "\n", 7673 env->spr[SPR_DAR], env->spr[SPR_DSISR]); 7674 break; 7675 case POWERPC_MMU_BOOKE206: 7676 qemu_fprintf(f, " MAS0 " TARGET_FMT_lx " MAS1 " TARGET_FMT_lx 7677 " MAS2 " TARGET_FMT_lx " MAS3 " TARGET_FMT_lx "\n", 7678 env->spr[SPR_BOOKE_MAS0], env->spr[SPR_BOOKE_MAS1], 7679 env->spr[SPR_BOOKE_MAS2], env->spr[SPR_BOOKE_MAS3]); 7680 7681 qemu_fprintf(f, " MAS4 " TARGET_FMT_lx " MAS6 " TARGET_FMT_lx 7682 " MAS7 " TARGET_FMT_lx " PID " TARGET_FMT_lx "\n", 7683 env->spr[SPR_BOOKE_MAS4], env->spr[SPR_BOOKE_MAS6], 7684 env->spr[SPR_BOOKE_MAS7], env->spr[SPR_BOOKE_PID]); 7685 7686 qemu_fprintf(f, "MMUCFG " TARGET_FMT_lx " TLB0CFG " TARGET_FMT_lx 7687 " TLB1CFG " TARGET_FMT_lx "\n", 7688 env->spr[SPR_MMUCFG], env->spr[SPR_BOOKE_TLB0CFG], 7689 env->spr[SPR_BOOKE_TLB1CFG]); 7690 break; 7691 default: 7692 break; 7693 } 7694 #endif 7695 7696 #undef RGPL 7697 #undef RFPL 7698 } 7699 type_init(ppc_cpu_register_types) 7700