xref: /openbmc/qemu/include/hw/ppc/spapr_cpu_core.h (revision c709e8ea)
13b542549SBharata B Rao /*
23b542549SBharata B Rao  * sPAPR CPU core device.
33b542549SBharata B Rao  *
43b542549SBharata B Rao  * Copyright (C) 2016 Bharata B Rao <bharata@linux.vnet.ibm.com>
53b542549SBharata B Rao  *
63b542549SBharata B Rao  * This work is licensed under the terms of the GNU GPL, version 2 or later.
73b542549SBharata B Rao  * See the COPYING file in the top-level directory.
83b542549SBharata B Rao  */
93b542549SBharata B Rao #ifndef HW_SPAPR_CPU_CORE_H
103b542549SBharata B Rao #define HW_SPAPR_CPU_CORE_H
113b542549SBharata B Rao 
123b542549SBharata B Rao #include "hw/cpu/core.h"
13a27bd6c7SMarkus Armbruster #include "hw/qdev-core.h"
14fcf5ef2aSThomas Huth #include "target/ppc/cpu-qom.h"
1584369f63SDavid Gibson #include "target/ppc/cpu.h"
16db1015e9SEduardo Habkost #include "qom/object.h"
173b542549SBharata B Rao 
183b542549SBharata B Rao #define TYPE_SPAPR_CPU_CORE "spapr-cpu-core"
19c821774aSEduardo Habkost OBJECT_DECLARE_TYPE(SpaprCpuCore, SpaprCpuCoreClass,
2030b5707cSEduardo Habkost                     SPAPR_CPU_CORE)
213b542549SBharata B Rao 
2244cd95e3SIgor Mammedov #define SPAPR_CPU_CORE_TYPE_NAME(model) model "-" TYPE_SPAPR_CPU_CORE
2344cd95e3SIgor Mammedov 
24db1015e9SEduardo Habkost struct SpaprCpuCore {
253b542549SBharata B Rao     /*< private >*/
263b542549SBharata B Rao     CPUCore parent_obj;
273b542549SBharata B Rao 
283b542549SBharata B Rao     /*< public >*/
2994ad93bdSGreg Kurz     PowerPCCPU **threads;
300b8497f0SIgor Mammedov     int node_id;
31ce2918cbSDavid Gibson     bool pre_3_0_migration; /* older machine don't know about SpaprCpuState */
32db1015e9SEduardo Habkost };
333b542549SBharata B Rao 
34db1015e9SEduardo Habkost struct SpaprCpuCoreClass {
357ebaf795SBharata B Rao     DeviceClass parent_class;
36b51d3c88SIgor Mammedov     const char *cpu_type;
37db1015e9SEduardo Habkost };
387ebaf795SBharata B Rao 
392e9c10ebSIgor Mammedov const char *spapr_get_cpu_core_type(const char *cpu_type);
40395a20d3SAlexey Kardashevskiy void spapr_cpu_set_entry_state(PowerPCCPU *cpu, target_ulong nip,
41395a20d3SAlexey Kardashevskiy                                target_ulong r1, target_ulong r3,
42395a20d3SAlexey Kardashevskiy                                target_ulong r4);
4384369f63SDavid Gibson 
44*c709e8eaSNicholas Piggin struct nested_ppc_state;
45*c709e8eaSNicholas Piggin 
46ce2918cbSDavid Gibson typedef struct SpaprCpuState {
477388efafSDavid Gibson     uint64_t vpa_addr;
487388efafSDavid Gibson     uint64_t slb_shadow_addr, slb_shadow_size;
497388efafSDavid Gibson     uint64_t dtl_addr, dtl_size;
503a6e6224SNicholas Piggin     bool prod; /* not migrated, only used to improve dispatch latencies */
51a28b9a5aSCédric Le Goater     struct ICPState *icp;
52a28b9a5aSCédric Le Goater     struct XiveTCTX *tctx;
53120f738aSNicholas Piggin 
54120f738aSNicholas Piggin     /* Fields for nested-HV support */
55120f738aSNicholas Piggin     bool in_nested; /* true while the L2 is executing */
56*c709e8eaSNicholas Piggin     struct nested_ppc_state *nested_host_state; /* holds the L1 state while L2 executes */
57ce2918cbSDavid Gibson } SpaprCpuState;
587388efafSDavid Gibson 
spapr_cpu_state(PowerPCCPU * cpu)59ce2918cbSDavid Gibson static inline SpaprCpuState *spapr_cpu_state(PowerPCCPU *cpu)
607388efafSDavid Gibson {
61ce2918cbSDavid Gibson     return (SpaprCpuState *)cpu->machine_data;
627388efafSDavid Gibson }
637388efafSDavid Gibson 
643b542549SBharata B Rao #endif
65