1335d52f4SLuc Michel /* 2335d52f4SLuc Michel * QEMU CPU cluster 3335d52f4SLuc Michel * 4335d52f4SLuc Michel * Copyright (c) 2018 GreenSocs SAS 5335d52f4SLuc Michel * 6335d52f4SLuc Michel * This program is free software; you can redistribute it and/or 7335d52f4SLuc Michel * modify it under the terms of the GNU General Public License 8335d52f4SLuc Michel * as published by the Free Software Foundation; either version 2 9335d52f4SLuc Michel * of the License, or (at your option) any later version. 10335d52f4SLuc Michel * 11335d52f4SLuc Michel * This program is distributed in the hope that it will be useful, 12335d52f4SLuc Michel * but WITHOUT ANY WARRANTY; without even the implied warranty of 13335d52f4SLuc Michel * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14335d52f4SLuc Michel * GNU General Public License for more details. 15335d52f4SLuc Michel * 16335d52f4SLuc Michel * You should have received a copy of the GNU General Public License 17335d52f4SLuc Michel * along with this program; if not, see 18335d52f4SLuc Michel * <http://www.gnu.org/licenses/gpl-2.0.html> 19335d52f4SLuc Michel */ 20335d52f4SLuc Michel #ifndef HW_CPU_CLUSTER_H 21335d52f4SLuc Michel #define HW_CPU_CLUSTER_H 22335d52f4SLuc Michel 23a27bd6c7SMarkus Armbruster #include "hw/qdev-core.h" 24db1015e9SEduardo Habkost #include "qom/object.h" 25335d52f4SLuc Michel 26335d52f4SLuc Michel /* 27335d52f4SLuc Michel * CPU Cluster type 28335d52f4SLuc Michel * 29335d52f4SLuc Michel * A cluster is a group of CPUs which are all identical and have the same view 30335d52f4SLuc Michel * of the rest of the system. It is mainly an internal QEMU representation and 31335d52f4SLuc Michel * does not necessarily match with the notion of clusters on the real hardware. 32335d52f4SLuc Michel * 33335d52f4SLuc Michel * If CPUs are not identical (for example, Cortex-A53 and Cortex-A57 CPUs in an 34335d52f4SLuc Michel * Arm big.LITTLE system) they should be in different clusters. If the CPUs do 35335d52f4SLuc Michel * not have the same view of memory (for example the main CPU and a management 36335d52f4SLuc Michel * controller processor) they should be in different clusters. 377ea7b9adSPeter Maydell * 387ea7b9adSPeter Maydell * A cluster is created by creating an object of TYPE_CPU_CLUSTER, and then 397ea7b9adSPeter Maydell * adding the CPUs to it as QOM child objects (e.g. using the 407ea7b9adSPeter Maydell * object_initialize_child() or object_property_add_child() functions). 417ea7b9adSPeter Maydell * The CPUs may be either direct children of the cluster object, or indirect 427ea7b9adSPeter Maydell * children (e.g. children of children of the cluster object). 437ea7b9adSPeter Maydell * 447ea7b9adSPeter Maydell * All CPUs must be added as children before the cluster is realized. 457ea7b9adSPeter Maydell * (Regrettably QOM provides no way to prevent adding children to a realized 467ea7b9adSPeter Maydell * object and no way for the parent to be notified when a new child is added 477ea7b9adSPeter Maydell * to it, so this restriction is not checked for, but the system will not 487ea7b9adSPeter Maydell * behave correctly if it is not adhered to. The cluster will assert that 497ea7b9adSPeter Maydell * it contains at least one CPU, which should catch most inadvertent 507ea7b9adSPeter Maydell * violations of this constraint.) 517ea7b9adSPeter Maydell * 527ea7b9adSPeter Maydell * A CPU which is not put into any cluster will be considered implicitly 537ea7b9adSPeter Maydell * to be in a cluster with all the other "loose" CPUs, so all CPUs that are 547ea7b9adSPeter Maydell * not assigned to clusters must be identical. 55335d52f4SLuc Michel */ 56335d52f4SLuc Michel 57335d52f4SLuc Michel #define TYPE_CPU_CLUSTER "cpu-cluster" 58*8063396bSEduardo Habkost OBJECT_DECLARE_SIMPLE_TYPE(CPUClusterState, CPU_CLUSTER) 59335d52f4SLuc Michel 607ea7b9adSPeter Maydell /* 617ea7b9adSPeter Maydell * This limit is imposed by TCG, which puts the cluster ID into an 627ea7b9adSPeter Maydell * 8 bit field (and uses all-1s for the default "not in any cluster"). 637ea7b9adSPeter Maydell */ 647ea7b9adSPeter Maydell #define MAX_CLUSTERS 255 657ea7b9adSPeter Maydell 66335d52f4SLuc Michel /** 67335d52f4SLuc Michel * CPUClusterState: 68335d52f4SLuc Michel * @cluster_id: The cluster ID. This value is for internal use only and should 69335d52f4SLuc Michel * not be exposed directly to the user or to the guest. 70335d52f4SLuc Michel * 71335d52f4SLuc Michel * State of a CPU cluster. 72335d52f4SLuc Michel */ 73db1015e9SEduardo Habkost struct CPUClusterState { 74335d52f4SLuc Michel /*< private >*/ 75335d52f4SLuc Michel DeviceState parent_obj; 76335d52f4SLuc Michel 77335d52f4SLuc Michel /*< public >*/ 78335d52f4SLuc Michel uint32_t cluster_id; 79db1015e9SEduardo Habkost }; 80335d52f4SLuc Michel 81335d52f4SLuc Michel #endif 82