1d2fd9612SCédric Le Goater /* 2d2fd9612SCédric Le Goater * QEMU PowerPC PowerNV CPU Core model 3d2fd9612SCédric Le Goater * 4d2fd9612SCédric Le Goater * Copyright (c) 2016, IBM Corporation. 5d2fd9612SCédric Le Goater * 6d2fd9612SCédric Le Goater * This library is free software; you can redistribute it and/or 7d2fd9612SCédric Le Goater * modify it under the terms of the GNU Lesser General Public License 8f70c5966SChetan Pant * as published by the Free Software Foundation; either version 2.1 of 9d2fd9612SCédric Le Goater * the License, or (at your option) any later version. 10d2fd9612SCédric Le Goater * 11d2fd9612SCédric Le Goater * This library is distributed in the hope that it will be useful, but 12d2fd9612SCédric Le Goater * WITHOUT ANY WARRANTY; without even the implied warranty of 13d2fd9612SCédric Le Goater * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14d2fd9612SCédric Le Goater * Lesser General Public License for more details. 15d2fd9612SCédric Le Goater * 16d2fd9612SCédric Le Goater * You should have received a copy of the GNU Lesser General Public 17d2fd9612SCédric Le Goater * License along with this library; if not, see <http://www.gnu.org/licenses/>. 18d2fd9612SCédric Le Goater */ 19a8b991b5SMarkus Armbruster 20a8b991b5SMarkus Armbruster #ifndef PPC_PNV_CORE_H 21a8b991b5SMarkus Armbruster #define PPC_PNV_CORE_H 22d2fd9612SCédric Le Goater 23d2fd9612SCédric Le Goater #include "hw/cpu/core.h" 24ec150c7eSMarkus Armbruster #include "target/ppc/cpu.h" 25b6c80037SMarkus Armbruster #include "hw/ppc/pnv.h" 26db1015e9SEduardo Habkost #include "qom/object.h" 27d2fd9612SCédric Le Goater 280ca94b2fSNicholas Piggin /* Per-core ChipTOD / TimeBase state */ 290ca94b2fSNicholas Piggin typedef struct PnvCoreTODState { 300ca94b2fSNicholas Piggin int tb_ready_for_tod; /* core TB ready to receive TOD from chiptod */ 310ca94b2fSNicholas Piggin int tod_sent_to_tb; /* chiptod sent TOD to the core TB */ 320ca94b2fSNicholas Piggin 330ca94b2fSNicholas Piggin /* 340ca94b2fSNicholas Piggin * "Timers" for async TBST events are simulated by mfTFAC because TFAC 350ca94b2fSNicholas Piggin * is polled for such events. These are just used to ensure firmware 360ca94b2fSNicholas Piggin * performs the polling at least a few times. 370ca94b2fSNicholas Piggin */ 380ca94b2fSNicholas Piggin int tb_state_timer; 390ca94b2fSNicholas Piggin int tb_sync_pulse_timer; 400ca94b2fSNicholas Piggin } PnvCoreTODState; 410ca94b2fSNicholas Piggin 42d2fd9612SCédric Le Goater #define TYPE_PNV_CORE "powernv-cpu-core" 43c821774aSEduardo Habkost OBJECT_DECLARE_TYPE(PnvCore, PnvCoreClass, 4430b5707cSEduardo Habkost PNV_CORE) 45d2fd9612SCédric Le Goater 46db1015e9SEduardo Habkost struct PnvCore { 47d2fd9612SCédric Le Goater /*< private >*/ 48d2fd9612SCédric Le Goater CPUCore parent_obj; 49d2fd9612SCédric Le Goater 50d2fd9612SCédric Le Goater /*< public >*/ 5108304a86SDavid Gibson PowerPCCPU **threads; 52d2fd9612SCédric Le Goater uint32_t pir; 539940412aSCaleb Schlossin uint32_t hwid; 5408c3f3a7SCédric Le Goater uint64_t hrmor; 550ca94b2fSNicholas Piggin 56*60d30cffSNicholas Piggin target_ulong scratch[8]; /* SPRC/SPRD indirect SCRATCH registers */ 570ca94b2fSNicholas Piggin PnvCoreTODState tod_state; 580ca94b2fSNicholas Piggin 59aa5ac64bSCédric Le Goater PnvChip *chip; 6024ece072SCédric Le Goater 6124ece072SCédric Le Goater MemoryRegion xscom_regs; 62db1015e9SEduardo Habkost }; 63d2fd9612SCédric Le Goater 64db1015e9SEduardo Habkost struct PnvCoreClass { 65d2fd9612SCédric Le Goater DeviceClass parent_class; 6690ef386cSCédric Le Goater 6790ef386cSCédric Le Goater const MemoryRegionOps *xscom_ops; 68aa2addf9SNicholas Piggin uint64_t xscom_size; 69db1015e9SEduardo Habkost }; 70d2fd9612SCédric Le Goater 717fd544d8SIgor Mammedov #define PNV_CORE_TYPE_SUFFIX "-" TYPE_PNV_CORE 727fd544d8SIgor Mammedov #define PNV_CORE_TYPE_NAME(cpu_model) cpu_model PNV_CORE_TYPE_SUFFIX 73d2fd9612SCédric Le Goater 748907fc25SCédric Le Goater typedef struct PnvCPUState { 75060e6143SNicholas Piggin PnvCore *pnv_core; 76956b8f46SCédric Le Goater Object *intc; 778907fc25SCédric Le Goater } PnvCPUState; 788907fc25SCédric Le Goater 798907fc25SCédric Le Goater static inline PnvCPUState *pnv_cpu_state(PowerPCCPU *cpu) 808907fc25SCédric Le Goater { 818907fc25SCédric Le Goater return (PnvCPUState *)cpu->machine_data; 828907fc25SCédric Le Goater } 838907fc25SCédric Le Goater 84fdc2b46aSJoel Stanley struct PnvQuadClass { 85fdc2b46aSJoel Stanley DeviceClass parent_class; 86fdc2b46aSJoel Stanley 87fdc2b46aSJoel Stanley const MemoryRegionOps *xscom_ops; 88fdc2b46aSJoel Stanley uint64_t xscom_size; 89bdb97596SJoel Stanley 90bdb97596SJoel Stanley const MemoryRegionOps *xscom_qme_ops; 91bdb97596SJoel Stanley uint64_t xscom_qme_size; 92fdc2b46aSJoel Stanley }; 93fdc2b46aSJoel Stanley 945dad902cSCédric Le Goater #define TYPE_PNV_QUAD "powernv-cpu-quad" 95fdc2b46aSJoel Stanley 96fdc2b46aSJoel Stanley #define PNV_QUAD_TYPE_SUFFIX "-" TYPE_PNV_QUAD 97fdc2b46aSJoel Stanley #define PNV_QUAD_TYPE_NAME(cpu_model) cpu_model PNV_QUAD_TYPE_SUFFIX 98fdc2b46aSJoel Stanley 99fdc2b46aSJoel Stanley OBJECT_DECLARE_TYPE(PnvQuad, PnvQuadClass, PNV_QUAD) 1005dad902cSCédric Le Goater 101db1015e9SEduardo Habkost struct PnvQuad { 1025dad902cSCédric Le Goater DeviceState parent_obj; 1035dad902cSCédric Le Goater 10492612f15SCédric Le Goater uint32_t quad_id; 1055dad902cSCédric Le Goater MemoryRegion xscom_regs; 106bdb97596SJoel Stanley MemoryRegion xscom_qme_regs; 107db1015e9SEduardo Habkost }; 108a8b991b5SMarkus Armbruster #endif /* PPC_PNV_CORE_H */ 109