pnv_core.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. /*
  2. * QEMU PowerPC PowerNV CPU Core model
  3. *
  4. * Copyright (c) 2016, IBM Corporation.
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public License
  8. * as published by the Free Software Foundation; either version 2.1 of
  9. * the License, or (at your option) any later version.
  10. *
  11. * This library is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with this library; if not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifndef PPC_PNV_CORE_H
  20. #define PPC_PNV_CORE_H
  21. #include "hw/cpu/core.h"
  22. #include "target/ppc/cpu.h"
  23. #include "hw/ppc/pnv.h"
  24. #include "qom/object.h"
  25. /* Per-core ChipTOD / TimeBase state */
  26. typedef struct PnvCoreTODState {
  27. /*
  28. * POWER10 DD2.0 - big core TFMR drives the state machine on the even
  29. * small core. Skiboot has a workaround that targets the even small core
  30. * for CHIPTOD_TO_TB ops.
  31. */
  32. bool big_core_quirk;
  33. int tb_ready_for_tod; /* core TB ready to receive TOD from chiptod */
  34. int tod_sent_to_tb; /* chiptod sent TOD to the core TB */
  35. /*
  36. * "Timers" for async TBST events are simulated by mfTFAC because TFAC
  37. * is polled for such events. These are just used to ensure firmware
  38. * performs the polling at least a few times.
  39. */
  40. int tb_state_timer;
  41. int tb_sync_pulse_timer;
  42. } PnvCoreTODState;
  43. #define TYPE_PNV_CORE "powernv-cpu-core"
  44. OBJECT_DECLARE_TYPE(PnvCore, PnvCoreClass,
  45. PNV_CORE)
  46. struct PnvCore {
  47. /*< private >*/
  48. CPUCore parent_obj;
  49. /*< public >*/
  50. PowerPCCPU **threads;
  51. bool big_core;
  52. bool lpar_per_core;
  53. uint32_t pir;
  54. uint32_t hwid;
  55. uint64_t hrmor;
  56. target_ulong scratch[8]; /* SPRC/SPRD indirect SCRATCH registers */
  57. PnvCoreTODState tod_state;
  58. PnvChip *chip;
  59. MemoryRegion xscom_regs;
  60. };
  61. struct PnvCoreClass {
  62. DeviceClass parent_class;
  63. const MemoryRegionOps *xscom_ops;
  64. uint64_t xscom_size;
  65. };
  66. #define PNV_CORE_TYPE_SUFFIX "-" TYPE_PNV_CORE
  67. #define PNV_CORE_TYPE_NAME(cpu_model) cpu_model PNV_CORE_TYPE_SUFFIX
  68. typedef struct PnvCPUState {
  69. PnvCore *pnv_core;
  70. Object *intc;
  71. } PnvCPUState;
  72. static inline PnvCPUState *pnv_cpu_state(PowerPCCPU *cpu)
  73. {
  74. return (PnvCPUState *)cpu->machine_data;
  75. }
  76. struct PnvQuadClass {
  77. DeviceClass parent_class;
  78. const MemoryRegionOps *xscom_ops;
  79. uint64_t xscom_size;
  80. const MemoryRegionOps *xscom_qme_ops;
  81. uint64_t xscom_qme_size;
  82. };
  83. #define TYPE_PNV_QUAD "powernv-cpu-quad"
  84. #define PNV_QUAD_TYPE_SUFFIX "-" TYPE_PNV_QUAD
  85. #define PNV_QUAD_TYPE_NAME(cpu_model) cpu_model PNV_QUAD_TYPE_SUFFIX
  86. OBJECT_DECLARE_TYPE(PnvQuad, PnvQuadClass, PNV_QUAD)
  87. struct PnvQuad {
  88. DeviceState parent_obj;
  89. bool special_wakeup_done;
  90. bool special_wakeup[4];
  91. uint32_t quad_id;
  92. MemoryRegion xscom_regs;
  93. MemoryRegion xscom_qme_regs;
  94. };
  95. #endif /* PPC_PNV_CORE_H */