xref: /openbmc/qemu/include/hw/cpu/cluster.h (revision 135b03cb)
1 /*
2  * QEMU CPU cluster
3  *
4  * Copyright (c) 2018 GreenSocs SAS
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, see
18  * <http://www.gnu.org/licenses/gpl-2.0.html>
19  */
20 #ifndef HW_CPU_CLUSTER_H
21 #define HW_CPU_CLUSTER_H
22 
23 #include "hw/qdev-core.h"
24 
25 /*
26  * CPU Cluster type
27  *
28  * A cluster is a group of CPUs which are all identical and have the same view
29  * of the rest of the system. It is mainly an internal QEMU representation and
30  * does not necessarily match with the notion of clusters on the real hardware.
31  *
32  * If CPUs are not identical (for example, Cortex-A53 and Cortex-A57 CPUs in an
33  * Arm big.LITTLE system) they should be in different clusters. If the CPUs do
34  * not have the same view of memory (for example the main CPU and a management
35  * controller processor) they should be in different clusters.
36  *
37  * A cluster is created by creating an object of TYPE_CPU_CLUSTER, and then
38  * adding the CPUs to it as QOM child objects (e.g. using the
39  * object_initialize_child() or object_property_add_child() functions).
40  * The CPUs may be either direct children of the cluster object, or indirect
41  * children (e.g. children of children of the cluster object).
42  *
43  * All CPUs must be added as children before the cluster is realized.
44  * (Regrettably QOM provides no way to prevent adding children to a realized
45  * object and no way for the parent to be notified when a new child is added
46  * to it, so this restriction is not checked for, but the system will not
47  * behave correctly if it is not adhered to. The cluster will assert that
48  * it contains at least one CPU, which should catch most inadvertent
49  * violations of this constraint.)
50  *
51  * A CPU which is not put into any cluster will be considered implicitly
52  * to be in a cluster with all the other "loose" CPUs, so all CPUs that are
53  * not assigned to clusters must be identical.
54  */
55 
56 #define TYPE_CPU_CLUSTER "cpu-cluster"
57 #define CPU_CLUSTER(obj) \
58     OBJECT_CHECK(CPUClusterState, (obj), TYPE_CPU_CLUSTER)
59 
60 /*
61  * This limit is imposed by TCG, which puts the cluster ID into an
62  * 8 bit field (and uses all-1s for the default "not in any cluster").
63  */
64 #define MAX_CLUSTERS 255
65 
66 /**
67  * CPUClusterState:
68  * @cluster_id: The cluster ID. This value is for internal use only and should
69  *   not be exposed directly to the user or to the guest.
70  *
71  * State of a CPU cluster.
72  */
73 typedef struct CPUClusterState {
74     /*< private >*/
75     DeviceState parent_obj;
76 
77     /*< public >*/
78     uint32_t cluster_id;
79 } CPUClusterState;
80 
81 #endif
82