
* Update to QEMU v9.0.0 --------- Signed-off-by: Peter Maydell <peter.maydell@linaro.org> Signed-off-by: Fabiano Rosas <farosas@suse.de> Signed-off-by: Peter Xu <peterx@redhat.com> Signed-off-by: Thomas Huth <thuth@redhat.com> Signed-off-by: Cédric Le Goater <clg@redhat.com> Signed-off-by: Zheyu Ma <zheyuma97@gmail.com> Signed-off-by: Ido Plat <ido.plat@ibm.com> Signed-off-by: Ilya Leoshkevich <iii@linux.ibm.com> Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Signed-off-by: David Hildenbrand <david@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com> Signed-off-by: Gregory Price <gregory.price@memverge.com> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org> Signed-off-by: Lorenz Brun <lorenz@brun.one> Signed-off-by: Yao Xingtao <yaoxt.fnst@fujitsu.com> Signed-off-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> Signed-off-by: Inès Varhol <ines.varhol@telecom-paris.fr> Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu> Signed-off-by: Igor Mammedov <imammedo@redhat.com> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com> Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Signed-off-by: Sven Schnelle <svens@stackframe.org> Signed-off-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Signed-off-by: Christian Schoenebeck <qemu_oss@crudebyte.com> Signed-off-by: Jason Wang <jasowang@redhat.com> Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Nicholas Piggin <npiggin@gmail.com> Signed-off-by: Benjamin Gray <bgray@linux.ibm.com> Signed-off-by: Avihai Horon <avihaih@nvidia.com> Signed-off-by: Michael Tokarev <mjt@tls.msk.ru> Signed-off-by: Joonas Kankaala <joonas.a.kankaala@gmail.com> Signed-off-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Zhao Liu <zhao1.liu@intel.com> Signed-off-by: Glenn Miles <milesg@linux.ibm.com> Signed-off-by: Oleg Sviridov <oleg.sviridov@red-soft.ru> Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru> Signed-off-by: Yajun Wu <yajunw@nvidia.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Signed-off-by: Pierre-Clément Tosi <ptosi@google.com> Signed-off-by: Lei Wang <lei4.wang@intel.com> Signed-off-by: Wei Wang <wei.w.wang@intel.com> Signed-off-by: Martin Hundebøll <martin@geanix.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Signed-off-by: Wafer <wafer@jaguarmicro.com> Signed-off-by: Yuxue Liu <yuxue.liu@jaguarmicro.com> Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Nguyen Dinh Phi <phind.uet@gmail.com> Signed-off-by: Zack Buhman <zack@buhman.org> Signed-off-by: Keith Packard <keithp@keithp.com> Signed-off-by: Yuquan Wang wangyuquan1236@phytium.com.cn Signed-off-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com> Signed-off-by: Cindy Lu <lulu@redhat.com> Co-authored-by: Peter Maydell <peter.maydell@linaro.org> Co-authored-by: Fabiano Rosas <farosas@suse.de> Co-authored-by: Peter Xu <peterx@redhat.com> Co-authored-by: Thomas Huth <thuth@redhat.com> Co-authored-by: Cédric Le Goater <clg@redhat.com> Co-authored-by: Zheyu Ma <zheyuma97@gmail.com> Co-authored-by: Ido Plat <ido.plat@ibm.com> Co-authored-by: Ilya Leoshkevich <iii@linux.ibm.com> Co-authored-by: Markus Armbruster <armbru@redhat.com> Co-authored-by: Marc-André Lureau <marcandre.lureau@redhat.com> Co-authored-by: Paolo Bonzini <pbonzini@redhat.com> Co-authored-by: Vladimir Sementsov-Ogievskiy <vsementsov@yandex-team.ru> Co-authored-by: David Hildenbrand <david@redhat.com> Co-authored-by: Kevin Wolf <kwolf@redhat.com> Co-authored-by: Stefan Reiter <s.reiter@proxmox.com> Co-authored-by: Fiona Ebner <f.ebner@proxmox.com> Co-authored-by: Gregory Price <gregory.price@memverge.com> Co-authored-by: Lorenz Brun <lorenz@brun.one> Co-authored-by: Yao Xingtao <yaoxt.fnst@fujitsu.com> Co-authored-by: Philippe Mathieu-Daudé <philmd@linaro.org> Co-authored-by: Arnaud Minier <arnaud.minier@telecom-paris.fr> Co-authored-by: BALATON Zoltan <balaton@eik.bme.hu> Co-authored-by: Igor Mammedov <imammedo@redhat.com> Co-authored-by: Akihiko Odaki <akihiko.odaki@daynix.com> Co-authored-by: Richard Henderson <richard.henderson@linaro.org> Co-authored-by: Sven Schnelle <svens@stackframe.org> Co-authored-by: Daniel Henrique Barboza <dbarboza@ventanamicro.com> Co-authored-by: Helge Deller <deller@kernel.org> Co-authored-by: Harsh Prateek Bora <harshpb@linux.ibm.com> Co-authored-by: Benjamin Gray <bgray@linux.ibm.com> Co-authored-by: Nicholas Piggin <npiggin@gmail.com> Co-authored-by: Avihai Horon <avihaih@nvidia.com> Co-authored-by: Michael Tokarev <mjt@tls.msk.ru> Co-authored-by: Joonas Kankaala <joonas.a.kankaala@gmail.com> Co-authored-by: Marcin Juszkiewicz <marcin.juszkiewicz@linaro.org> Co-authored-by: Stefan Weil <sw@weilnetz.de> Co-authored-by: Dayu Liu <liu.dayu@zte.com.cn> Co-authored-by: Zhao Liu <zhao1.liu@intel.com> Co-authored-by: Glenn Miles <milesg@linux.vnet.ibm.com> Co-authored-by: Artem Chernyshev <artem.chernyshev@red-soft.ru> Co-authored-by: Yajun Wu <yajunw@nvidia.com> Co-authored-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk> Co-authored-by: Pierre-Clément Tosi <ptosi@google.com> Co-authored-by: Wei Wang <wei.w.wang@intel.com> Co-authored-by: Martin Hundebøll <martin@geanix.com> Co-authored-by: Michael S. Tsirkin <mst@redhat.com> Co-authored-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org> Co-authored-by: Wafer <wafer@jaguarmicro.com> Co-authored-by: lyx634449800 <yuxue.liu@jaguarmicro.com> Co-authored-by: Gerd Hoffmann <kraxel@redhat.com> Co-authored-by: Nguyen Dinh Phi <phind.uet@gmail.com> Co-authored-by: Zack Buhman <zack@buhman.org> Co-authored-by: Keith Packard <keithp@keithp.com> Co-authored-by: Yuquan Wang <wangyuquan1236@phytium.com.cn> Co-authored-by: Matheus Tavares Bernardino <quic_mathbern@quicinc.com> Co-authored-by: Cindy Lu <lulu@redhat.com>
640 lines
17 KiB
C
640 lines
17 KiB
C
/*
|
|
* QEMU PowerPC PowerNV CPU Core model
|
|
*
|
|
* Copyright (c) 2016, IBM Corporation.
|
|
*
|
|
* This library is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU Lesser General Public License
|
|
* as published by the Free Software Foundation; either version 2.1 of
|
|
* the License, or (at your option) any later version.
|
|
*
|
|
* This library is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
* Lesser General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
* License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#include "qemu/osdep.h"
|
|
#include "sysemu/reset.h"
|
|
#include "qapi/error.h"
|
|
#include "qemu/log.h"
|
|
#include "qemu/module.h"
|
|
#include "target/ppc/cpu.h"
|
|
#include "hw/ppc/ppc.h"
|
|
#include "hw/ppc/pnv.h"
|
|
#include "hw/ppc/pnv_chip.h"
|
|
#include "hw/ppc/pnv_core.h"
|
|
#include "hw/ppc/pnv_xscom.h"
|
|
#include "hw/ppc/xics.h"
|
|
#include "hw/qdev-properties.h"
|
|
#include "helper_regs.h"
|
|
|
|
static const char *pnv_core_cpu_typename(PnvCore *pc)
|
|
{
|
|
const char *core_type = object_class_get_name(object_get_class(OBJECT(pc)));
|
|
int len = strlen(core_type) - strlen(PNV_CORE_TYPE_SUFFIX);
|
|
char *s = g_strdup_printf(POWERPC_CPU_TYPE_NAME("%.*s"), len, core_type);
|
|
const char *cpu_type = object_class_get_name(object_class_by_name(s));
|
|
g_free(s);
|
|
return cpu_type;
|
|
}
|
|
|
|
static void pnv_core_cpu_reset(PnvCore *pc, PowerPCCPU *cpu)
|
|
{
|
|
CPUState *cs = CPU(cpu);
|
|
CPUPPCState *env = &cpu->env;
|
|
PnvChipClass *pcc = PNV_CHIP_GET_CLASS(pc->chip);
|
|
|
|
cpu_reset(cs);
|
|
|
|
/*
|
|
* the skiboot firmware elects a primary thread to initialize the
|
|
* system and it can be any.
|
|
*/
|
|
env->gpr[3] = PNV_FDT_ADDR;
|
|
env->nip = 0x10;
|
|
env->msr |= MSR_HVB; /* Hypervisor mode */
|
|
env->spr[SPR_HRMOR] = pc->hrmor;
|
|
hreg_compute_hflags(env);
|
|
ppc_maybe_interrupt(env);
|
|
|
|
cpu_ppc_tb_reset(env);
|
|
|
|
pcc->intc_reset(pc->chip, cpu);
|
|
}
|
|
|
|
/*
|
|
* These values are read by the PowerNV HW monitors under Linux
|
|
*/
|
|
#define PNV_XSCOM_EX_DTS_RESULT0 0x50000
|
|
#define PNV_XSCOM_EX_DTS_RESULT1 0x50001
|
|
|
|
static uint64_t pnv_core_power8_xscom_read(void *opaque, hwaddr addr,
|
|
unsigned int width)
|
|
{
|
|
uint32_t offset = addr >> 3;
|
|
uint64_t val = 0;
|
|
|
|
/* The result should be 38 C */
|
|
switch (offset) {
|
|
case PNV_XSCOM_EX_DTS_RESULT0:
|
|
val = 0x26f024f023f0000ull;
|
|
break;
|
|
case PNV_XSCOM_EX_DTS_RESULT1:
|
|
val = 0x24f000000000000ull;
|
|
break;
|
|
default:
|
|
qemu_log_mask(LOG_UNIMP, "%s: unimp read 0x%08x\n", __func__,
|
|
offset);
|
|
}
|
|
|
|
return val;
|
|
}
|
|
|
|
static void pnv_core_power8_xscom_write(void *opaque, hwaddr addr, uint64_t val,
|
|
unsigned int width)
|
|
{
|
|
uint32_t offset = addr >> 3;
|
|
|
|
qemu_log_mask(LOG_UNIMP, "%s: unimp write 0x%08x\n", __func__,
|
|
offset);
|
|
}
|
|
|
|
static const MemoryRegionOps pnv_core_power8_xscom_ops = {
|
|
.read = pnv_core_power8_xscom_read,
|
|
.write = pnv_core_power8_xscom_write,
|
|
.valid.min_access_size = 8,
|
|
.valid.max_access_size = 8,
|
|
.impl.min_access_size = 8,
|
|
.impl.max_access_size = 8,
|
|
.endianness = DEVICE_BIG_ENDIAN,
|
|
};
|
|
|
|
|
|
/*
|
|
* POWER9 core controls
|
|
*/
|
|
#define PNV9_XSCOM_EC_PPM_SPECIAL_WKUP_HYP 0xf010d
|
|
#define PNV9_XSCOM_EC_PPM_SPECIAL_WKUP_OTR 0xf010a
|
|
|
|
#define PNV9_XSCOM_EC_CORE_THREAD_STATE 0x10ab3
|
|
|
|
static uint64_t pnv_core_power9_xscom_read(void *opaque, hwaddr addr,
|
|
unsigned int width)
|
|
{
|
|
uint32_t offset = addr >> 3;
|
|
uint64_t val = 0;
|
|
|
|
/* The result should be 38 C */
|
|
switch (offset) {
|
|
case PNV_XSCOM_EX_DTS_RESULT0:
|
|
val = 0x26f024f023f0000ull;
|
|
break;
|
|
case PNV_XSCOM_EX_DTS_RESULT1:
|
|
val = 0x24f000000000000ull;
|
|
break;
|
|
case PNV9_XSCOM_EC_PPM_SPECIAL_WKUP_HYP:
|
|
case PNV9_XSCOM_EC_PPM_SPECIAL_WKUP_OTR:
|
|
val = 0x0;
|
|
break;
|
|
case PNV9_XSCOM_EC_CORE_THREAD_STATE:
|
|
val = 0;
|
|
break;
|
|
default:
|
|
qemu_log_mask(LOG_UNIMP, "%s: unimp read 0x%08x\n", __func__,
|
|
offset);
|
|
}
|
|
|
|
return val;
|
|
}
|
|
|
|
static void pnv_core_power9_xscom_write(void *opaque, hwaddr addr, uint64_t val,
|
|
unsigned int width)
|
|
{
|
|
uint32_t offset = addr >> 3;
|
|
|
|
switch (offset) {
|
|
case PNV9_XSCOM_EC_PPM_SPECIAL_WKUP_HYP:
|
|
case PNV9_XSCOM_EC_PPM_SPECIAL_WKUP_OTR:
|
|
break;
|
|
default:
|
|
qemu_log_mask(LOG_UNIMP, "%s: unimp write 0x%08x\n", __func__,
|
|
offset);
|
|
}
|
|
}
|
|
|
|
static const MemoryRegionOps pnv_core_power9_xscom_ops = {
|
|
.read = pnv_core_power9_xscom_read,
|
|
.write = pnv_core_power9_xscom_write,
|
|
.valid.min_access_size = 8,
|
|
.valid.max_access_size = 8,
|
|
.impl.min_access_size = 8,
|
|
.impl.max_access_size = 8,
|
|
.endianness = DEVICE_BIG_ENDIAN,
|
|
};
|
|
|
|
/*
|
|
* POWER10 core controls
|
|
*/
|
|
|
|
#define PNV10_XSCOM_EC_CORE_THREAD_STATE 0x412
|
|
|
|
static uint64_t pnv_core_power10_xscom_read(void *opaque, hwaddr addr,
|
|
unsigned int width)
|
|
{
|
|
uint32_t offset = addr >> 3;
|
|
uint64_t val = 0;
|
|
|
|
switch (offset) {
|
|
case PNV10_XSCOM_EC_CORE_THREAD_STATE:
|
|
val = 0;
|
|
break;
|
|
default:
|
|
qemu_log_mask(LOG_UNIMP, "%s: unimp read 0x%08x\n", __func__,
|
|
offset);
|
|
}
|
|
|
|
return val;
|
|
}
|
|
|
|
static void pnv_core_power10_xscom_write(void *opaque, hwaddr addr,
|
|
uint64_t val, unsigned int width)
|
|
{
|
|
uint32_t offset = addr >> 3;
|
|
|
|
switch (offset) {
|
|
default:
|
|
qemu_log_mask(LOG_UNIMP, "%s: unimp write 0x%08x\n", __func__,
|
|
offset);
|
|
}
|
|
}
|
|
|
|
static const MemoryRegionOps pnv_core_power10_xscom_ops = {
|
|
.read = pnv_core_power10_xscom_read,
|
|
.write = pnv_core_power10_xscom_write,
|
|
.valid.min_access_size = 8,
|
|
.valid.max_access_size = 8,
|
|
.impl.min_access_size = 8,
|
|
.impl.max_access_size = 8,
|
|
.endianness = DEVICE_BIG_ENDIAN,
|
|
};
|
|
|
|
static void pnv_core_cpu_realize(PnvCore *pc, PowerPCCPU *cpu, Error **errp,
|
|
int thread_index)
|
|
{
|
|
CPUPPCState *env = &cpu->env;
|
|
int core_hwid;
|
|
ppc_spr_t *pir = &env->spr_cb[SPR_PIR];
|
|
ppc_spr_t *tir = &env->spr_cb[SPR_TIR];
|
|
Error *local_err = NULL;
|
|
PnvChipClass *pcc = PNV_CHIP_GET_CLASS(pc->chip);
|
|
|
|
if (!qdev_realize(DEVICE(cpu), NULL, errp)) {
|
|
return;
|
|
}
|
|
|
|
pcc->intc_create(pc->chip, cpu, &local_err);
|
|
if (local_err) {
|
|
error_propagate(errp, local_err);
|
|
return;
|
|
}
|
|
|
|
core_hwid = object_property_get_uint(OBJECT(pc), "hwid", &error_abort);
|
|
|
|
tir->default_value = thread_index;
|
|
pir->default_value = pcc->chip_pir(pc->chip, core_hwid, thread_index);
|
|
|
|
/* Set time-base frequency to 512 MHz */
|
|
cpu_ppc_tb_init(env, PNV_TIMEBASE_FREQ);
|
|
}
|
|
|
|
static void pnv_core_reset(void *dev)
|
|
{
|
|
CPUCore *cc = CPU_CORE(dev);
|
|
PnvCore *pc = PNV_CORE(dev);
|
|
int i;
|
|
|
|
for (i = 0; i < cc->nr_threads; i++) {
|
|
pnv_core_cpu_reset(pc, pc->threads[i]);
|
|
}
|
|
}
|
|
|
|
static void pnv_core_realize(DeviceState *dev, Error **errp)
|
|
{
|
|
PnvCore *pc = PNV_CORE(OBJECT(dev));
|
|
PnvCoreClass *pcc = PNV_CORE_GET_CLASS(pc);
|
|
CPUCore *cc = CPU_CORE(OBJECT(dev));
|
|
const char *typename = pnv_core_cpu_typename(pc);
|
|
Error *local_err = NULL;
|
|
void *obj;
|
|
int i, j;
|
|
char name[32];
|
|
|
|
assert(pc->chip);
|
|
|
|
pc->threads = g_new(PowerPCCPU *, cc->nr_threads);
|
|
for (i = 0; i < cc->nr_threads; i++) {
|
|
PowerPCCPU *cpu;
|
|
|
|
obj = object_new(typename);
|
|
cpu = POWERPC_CPU(obj);
|
|
|
|
pc->threads[i] = POWERPC_CPU(obj);
|
|
|
|
snprintf(name, sizeof(name), "thread[%d]", i);
|
|
object_property_add_child(OBJECT(pc), name, obj);
|
|
|
|
cpu->machine_data = g_new0(PnvCPUState, 1);
|
|
|
|
object_unref(obj);
|
|
}
|
|
|
|
for (j = 0; j < cc->nr_threads; j++) {
|
|
pnv_core_cpu_realize(pc, pc->threads[j], &local_err, j);
|
|
if (local_err) {
|
|
goto err;
|
|
}
|
|
}
|
|
|
|
snprintf(name, sizeof(name), "xscom-core.%d", cc->core_id);
|
|
pnv_xscom_region_init(&pc->xscom_regs, OBJECT(dev), pcc->xscom_ops,
|
|
pc, name, pcc->xscom_size);
|
|
|
|
qemu_register_reset(pnv_core_reset, pc);
|
|
return;
|
|
|
|
err:
|
|
while (--i >= 0) {
|
|
obj = OBJECT(pc->threads[i]);
|
|
object_unparent(obj);
|
|
}
|
|
g_free(pc->threads);
|
|
error_propagate(errp, local_err);
|
|
}
|
|
|
|
static void pnv_core_cpu_unrealize(PnvCore *pc, PowerPCCPU *cpu)
|
|
{
|
|
PnvCPUState *pnv_cpu = pnv_cpu_state(cpu);
|
|
PnvChipClass *pcc = PNV_CHIP_GET_CLASS(pc->chip);
|
|
|
|
pcc->intc_destroy(pc->chip, cpu);
|
|
cpu_remove_sync(CPU(cpu));
|
|
cpu->machine_data = NULL;
|
|
g_free(pnv_cpu);
|
|
object_unparent(OBJECT(cpu));
|
|
}
|
|
|
|
static void pnv_core_unrealize(DeviceState *dev)
|
|
{
|
|
PnvCore *pc = PNV_CORE(dev);
|
|
CPUCore *cc = CPU_CORE(dev);
|
|
int i;
|
|
|
|
qemu_unregister_reset(pnv_core_reset, pc);
|
|
|
|
for (i = 0; i < cc->nr_threads; i++) {
|
|
pnv_core_cpu_unrealize(pc, pc->threads[i]);
|
|
}
|
|
g_free(pc->threads);
|
|
}
|
|
|
|
static Property pnv_core_properties[] = {
|
|
DEFINE_PROP_UINT32("hwid", PnvCore, hwid, 0),
|
|
DEFINE_PROP_UINT64("hrmor", PnvCore, hrmor, 0),
|
|
DEFINE_PROP_LINK("chip", PnvCore, chip, TYPE_PNV_CHIP, PnvChip *),
|
|
DEFINE_PROP_END_OF_LIST(),
|
|
};
|
|
|
|
static void pnv_core_power8_class_init(ObjectClass *oc, void *data)
|
|
{
|
|
PnvCoreClass *pcc = PNV_CORE_CLASS(oc);
|
|
|
|
pcc->xscom_ops = &pnv_core_power8_xscom_ops;
|
|
pcc->xscom_size = PNV_XSCOM_EX_SIZE;
|
|
}
|
|
|
|
static void pnv_core_power9_class_init(ObjectClass *oc, void *data)
|
|
{
|
|
PnvCoreClass *pcc = PNV_CORE_CLASS(oc);
|
|
|
|
pcc->xscom_ops = &pnv_core_power9_xscom_ops;
|
|
pcc->xscom_size = PNV_XSCOM_EX_SIZE;
|
|
}
|
|
|
|
static void pnv_core_power10_class_init(ObjectClass *oc, void *data)
|
|
{
|
|
PnvCoreClass *pcc = PNV_CORE_CLASS(oc);
|
|
|
|
pcc->xscom_ops = &pnv_core_power10_xscom_ops;
|
|
pcc->xscom_size = PNV10_XSCOM_EC_SIZE;
|
|
}
|
|
|
|
static void pnv_core_class_init(ObjectClass *oc, void *data)
|
|
{
|
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
|
|
|
dc->realize = pnv_core_realize;
|
|
dc->unrealize = pnv_core_unrealize;
|
|
device_class_set_props(dc, pnv_core_properties);
|
|
dc->user_creatable = false;
|
|
}
|
|
|
|
#define DEFINE_PNV_CORE_TYPE(family, cpu_model) \
|
|
{ \
|
|
.parent = TYPE_PNV_CORE, \
|
|
.name = PNV_CORE_TYPE_NAME(cpu_model), \
|
|
.class_init = pnv_core_##family##_class_init, \
|
|
}
|
|
|
|
static const TypeInfo pnv_core_infos[] = {
|
|
{
|
|
.name = TYPE_PNV_CORE,
|
|
.parent = TYPE_CPU_CORE,
|
|
.instance_size = sizeof(PnvCore),
|
|
.class_size = sizeof(PnvCoreClass),
|
|
.class_init = pnv_core_class_init,
|
|
.abstract = true,
|
|
},
|
|
DEFINE_PNV_CORE_TYPE(power8, "power8e_v2.1"),
|
|
DEFINE_PNV_CORE_TYPE(power8, "power8_v2.0"),
|
|
DEFINE_PNV_CORE_TYPE(power8, "power8nvl_v1.0"),
|
|
DEFINE_PNV_CORE_TYPE(power9, "power9_v2.2"),
|
|
DEFINE_PNV_CORE_TYPE(power10, "power10_v2.0"),
|
|
};
|
|
|
|
DEFINE_TYPES(pnv_core_infos)
|
|
|
|
/*
|
|
* POWER9 Quads
|
|
*/
|
|
|
|
#define P9X_EX_NCU_SPEC_BAR 0x11010
|
|
|
|
static uint64_t pnv_quad_power9_xscom_read(void *opaque, hwaddr addr,
|
|
unsigned int width)
|
|
{
|
|
uint32_t offset = addr >> 3;
|
|
uint64_t val = -1;
|
|
|
|
switch (offset) {
|
|
case P9X_EX_NCU_SPEC_BAR:
|
|
case P9X_EX_NCU_SPEC_BAR + 0x400: /* Second EX */
|
|
val = 0;
|
|
break;
|
|
default:
|
|
qemu_log_mask(LOG_UNIMP, "%s: unimp read 0x%08x\n", __func__,
|
|
offset);
|
|
}
|
|
|
|
return val;
|
|
}
|
|
|
|
static void pnv_quad_power9_xscom_write(void *opaque, hwaddr addr, uint64_t val,
|
|
unsigned int width)
|
|
{
|
|
uint32_t offset = addr >> 3;
|
|
|
|
switch (offset) {
|
|
case P9X_EX_NCU_SPEC_BAR:
|
|
case P9X_EX_NCU_SPEC_BAR + 0x400: /* Second EX */
|
|
break;
|
|
default:
|
|
qemu_log_mask(LOG_UNIMP, "%s: unimp write 0x%08x\n", __func__,
|
|
offset);
|
|
}
|
|
}
|
|
|
|
static const MemoryRegionOps pnv_quad_power9_xscom_ops = {
|
|
.read = pnv_quad_power9_xscom_read,
|
|
.write = pnv_quad_power9_xscom_write,
|
|
.valid.min_access_size = 8,
|
|
.valid.max_access_size = 8,
|
|
.impl.min_access_size = 8,
|
|
.impl.max_access_size = 8,
|
|
.endianness = DEVICE_BIG_ENDIAN,
|
|
};
|
|
|
|
/*
|
|
* POWER10 Quads
|
|
*/
|
|
|
|
static uint64_t pnv_quad_power10_xscom_read(void *opaque, hwaddr addr,
|
|
unsigned int width)
|
|
{
|
|
uint32_t offset = addr >> 3;
|
|
uint64_t val = -1;
|
|
|
|
switch (offset) {
|
|
default:
|
|
qemu_log_mask(LOG_UNIMP, "%s: unimp read 0x%08x\n", __func__,
|
|
offset);
|
|
}
|
|
|
|
return val;
|
|
}
|
|
|
|
static void pnv_quad_power10_xscom_write(void *opaque, hwaddr addr,
|
|
uint64_t val, unsigned int width)
|
|
{
|
|
uint32_t offset = addr >> 3;
|
|
|
|
switch (offset) {
|
|
default:
|
|
qemu_log_mask(LOG_UNIMP, "%s: unimp write 0x%08x\n", __func__,
|
|
offset);
|
|
}
|
|
}
|
|
|
|
static const MemoryRegionOps pnv_quad_power10_xscom_ops = {
|
|
.read = pnv_quad_power10_xscom_read,
|
|
.write = pnv_quad_power10_xscom_write,
|
|
.valid.min_access_size = 8,
|
|
.valid.max_access_size = 8,
|
|
.impl.min_access_size = 8,
|
|
.impl.max_access_size = 8,
|
|
.endianness = DEVICE_BIG_ENDIAN,
|
|
};
|
|
|
|
#define P10_QME_SPWU_HYP 0x83c
|
|
#define P10_QME_SSH_HYP 0x82c
|
|
|
|
static uint64_t pnv_qme_power10_xscom_read(void *opaque, hwaddr addr,
|
|
unsigned int width)
|
|
{
|
|
uint32_t offset = addr >> 3;
|
|
uint64_t val = -1;
|
|
|
|
/*
|
|
* Forth nibble selects the core within a quad, mask it to process read
|
|
* for any core.
|
|
*/
|
|
switch (offset & ~0xf000) {
|
|
case P10_QME_SPWU_HYP:
|
|
case P10_QME_SSH_HYP:
|
|
return 0;
|
|
default:
|
|
qemu_log_mask(LOG_UNIMP, "%s: unimp read 0x%08x\n", __func__,
|
|
offset);
|
|
}
|
|
|
|
return val;
|
|
}
|
|
|
|
static void pnv_qme_power10_xscom_write(void *opaque, hwaddr addr,
|
|
uint64_t val, unsigned int width)
|
|
{
|
|
uint32_t offset = addr >> 3;
|
|
|
|
switch (offset) {
|
|
default:
|
|
qemu_log_mask(LOG_UNIMP, "%s: unimp write 0x%08x\n", __func__,
|
|
offset);
|
|
}
|
|
}
|
|
|
|
static const MemoryRegionOps pnv_qme_power10_xscom_ops = {
|
|
.read = pnv_qme_power10_xscom_read,
|
|
.write = pnv_qme_power10_xscom_write,
|
|
.valid.min_access_size = 8,
|
|
.valid.max_access_size = 8,
|
|
.impl.min_access_size = 8,
|
|
.impl.max_access_size = 8,
|
|
.endianness = DEVICE_BIG_ENDIAN,
|
|
};
|
|
|
|
static void pnv_quad_power9_realize(DeviceState *dev, Error **errp)
|
|
{
|
|
PnvQuad *eq = PNV_QUAD(dev);
|
|
PnvQuadClass *pqc = PNV_QUAD_GET_CLASS(eq);
|
|
char name[32];
|
|
|
|
snprintf(name, sizeof(name), "xscom-quad.%d", eq->quad_id);
|
|
pnv_xscom_region_init(&eq->xscom_regs, OBJECT(dev),
|
|
pqc->xscom_ops,
|
|
eq, name,
|
|
pqc->xscom_size);
|
|
}
|
|
|
|
static void pnv_quad_power10_realize(DeviceState *dev, Error **errp)
|
|
{
|
|
PnvQuad *eq = PNV_QUAD(dev);
|
|
PnvQuadClass *pqc = PNV_QUAD_GET_CLASS(eq);
|
|
char name[32];
|
|
|
|
snprintf(name, sizeof(name), "xscom-quad.%d", eq->quad_id);
|
|
pnv_xscom_region_init(&eq->xscom_regs, OBJECT(dev),
|
|
pqc->xscom_ops,
|
|
eq, name,
|
|
pqc->xscom_size);
|
|
|
|
snprintf(name, sizeof(name), "xscom-qme.%d", eq->quad_id);
|
|
pnv_xscom_region_init(&eq->xscom_qme_regs, OBJECT(dev),
|
|
pqc->xscom_qme_ops,
|
|
eq, name,
|
|
pqc->xscom_qme_size);
|
|
}
|
|
|
|
static Property pnv_quad_properties[] = {
|
|
DEFINE_PROP_UINT32("quad-id", PnvQuad, quad_id, 0),
|
|
DEFINE_PROP_END_OF_LIST(),
|
|
};
|
|
|
|
static void pnv_quad_power9_class_init(ObjectClass *oc, void *data)
|
|
{
|
|
PnvQuadClass *pqc = PNV_QUAD_CLASS(oc);
|
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
|
|
|
dc->realize = pnv_quad_power9_realize;
|
|
|
|
pqc->xscom_ops = &pnv_quad_power9_xscom_ops;
|
|
pqc->xscom_size = PNV9_XSCOM_EQ_SIZE;
|
|
}
|
|
|
|
static void pnv_quad_power10_class_init(ObjectClass *oc, void *data)
|
|
{
|
|
PnvQuadClass *pqc = PNV_QUAD_CLASS(oc);
|
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
|
|
|
dc->realize = pnv_quad_power10_realize;
|
|
|
|
pqc->xscom_ops = &pnv_quad_power10_xscom_ops;
|
|
pqc->xscom_size = PNV10_XSCOM_EQ_SIZE;
|
|
|
|
pqc->xscom_qme_ops = &pnv_qme_power10_xscom_ops;
|
|
pqc->xscom_qme_size = PNV10_XSCOM_QME_SIZE;
|
|
}
|
|
|
|
static void pnv_quad_class_init(ObjectClass *oc, void *data)
|
|
{
|
|
DeviceClass *dc = DEVICE_CLASS(oc);
|
|
|
|
device_class_set_props(dc, pnv_quad_properties);
|
|
dc->user_creatable = false;
|
|
}
|
|
|
|
static const TypeInfo pnv_quad_infos[] = {
|
|
{
|
|
.name = TYPE_PNV_QUAD,
|
|
.parent = TYPE_DEVICE,
|
|
.instance_size = sizeof(PnvQuad),
|
|
.class_size = sizeof(PnvQuadClass),
|
|
.class_init = pnv_quad_class_init,
|
|
.abstract = true,
|
|
},
|
|
{
|
|
.parent = TYPE_PNV_QUAD,
|
|
.name = PNV_QUAD_TYPE_NAME("power9"),
|
|
.class_init = pnv_quad_power9_class_init,
|
|
},
|
|
{
|
|
.parent = TYPE_PNV_QUAD,
|
|
.name = PNV_QUAD_TYPE_NAME("power10"),
|
|
.class_init = pnv_quad_power10_class_init,
|
|
},
|
|
};
|
|
|
|
DEFINE_TYPES(pnv_quad_infos);
|