From patchwork Thu Jan 18 18:37:57 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alistair Francis X-Patchwork-Id: 863091 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="hKnLOdLG"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zMtMZ3b7Hz9s7M for ; Fri, 19 Jan 2018 05:51:06 +1100 (AEDT) Received: from localhost ([::1]:47554 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecFHE-0005xJ-Kb for incoming@patchwork.ozlabs.org; Thu, 18 Jan 2018 13:51:04 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41669) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ecF8t-0007cT-VH for qemu-devel@nongnu.org; Thu, 18 Jan 2018 13:42:31 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ecF8q-0002zW-Pe for qemu-devel@nongnu.org; Thu, 18 Jan 2018 13:42:28 -0500 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:38468) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1ecF8q-0002zH-GZ; Thu, 18 Jan 2018 13:42:24 -0500 Received: by mail-pg0-x243.google.com with SMTP id y27so8993037pgc.5; Thu, 18 Jan 2018 10:42:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=DVWFHJPUwgQ+3kgB3q991tAQNhIal3fXQX2kPrJ22SU=; b=hKnLOdLGFI8QNAzSrABbBnyL3Pd25RkEBqqBZixFy3vSpdtPG+QC6nztHACykOfhr/ 0v6uCq7LEaUF+FA6YemlsjwojGfr/RwCtcopfNFk02V4bOD1cEjpNMC6rZEjjpJI2CHO xoPFvKsmKMNm0/sYOwS7xwg3nsGk2LMsfp+ntmwAENk6yGdgLKfN74AwwZE8AeBwhSG/ k2L/sQx/4JaxPS1MUaxYbadlLg/O55tL2nBOiIZsIQrg1PUkMeknDzdZPuKA30o7NDlT x057Ynj5ZVsvaE0Vr9W0yMtV6kT3/OUieFLUcvwLWH0CA4G3HUEnx0YBBq/OdiPAhK1b mWgA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=DVWFHJPUwgQ+3kgB3q991tAQNhIal3fXQX2kPrJ22SU=; b=E3r7GK4We4mVCYvZ76NMu84G/jsRqHXvEdARZuxqFvX+LdvxV1C0f3Gu66Ug8F1Jip 7gpVT9M+8ocihwho02IQAMIv1ViBaR0Apb3FzXHpw53HitBoVCSJSMMdb8+Qs+CYW8L6 R5n73uhJrDryhXQ/Jij3ib5U9+3k/5EWyU5BceMlulKZuRqSol9UIjFrfnxMGQUPx/pJ eU1y4VcKI6ZbHJ+AvLmcWpk1j6NnTUKvFNMqAB13zGvRoDis6DSk7yUAMOG/1KEvlfYA OB7eB1WF3uhDlb8n7d4CKWi9fxvgyg2Mu7Dakfu5LLwGCV/JGDHh9eVcxDLfbaIDx3rC GnNA== X-Gm-Message-State: AKwxytenM1Mu/SLO4Eo9+oS4hY2UmFSPpNRVKYtgFkUZM5UnQOqSjL8n xPYuOTOMCsA64AbEoDhoIi2OAsHeYCk= X-Google-Smtp-Source: ACJfBosNEMtsRp4Sz80xdHZVgegw3X4IQk+HKGYlxHXESPS9GZTKiwVeY4yLq4Ern938ScA83bz04w== X-Received: by 2002:a17:902:8607:: with SMTP id f7-v6mr239458plo.273.1516300943251; Thu, 18 Jan 2018 10:42:23 -0800 (PST) Received: from localhost ([149.199.62.254]) by smtp.gmail.com with ESMTPSA id n128sm13178495pga.57.2018.01.18.10.42.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Jan 2018 10:42:22 -0800 (PST) From: Alistair Francis To: qemu-devel@nongnu.org, edgar.iglesias@xilinx.com, edgar.iglesias@gmail.com Date: Thu, 18 Jan 2018 10:37:57 -0800 Message-Id: <0a8d39fc3fd536d9470ba74ecfb1ad0b05171ae4.1516300623.git.alistair.francis@xilinx.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH v6 3/9] xlnx-zynqmp-pmu: Add the CPU and memory X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: alistair23@gmail.com, qemu-arm@nongnu.org, alistair.francis@xilinx.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Connect the MicroBlaze CPU and the ROM and RAM memory regions. Signed-off-by: Alistair Francis Reviewed-by: Edgar E. Iglesias --- V6: - Pass initrd instead of kernel to microblaze_load_kernel() V4: - Remove the ZCU102 name V2: - Fix the pmu-cpu name - Use err and errp for CPU realise instead of error_fatal hw/microblaze/xlnx-zynqmp-pmu.c | 70 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 68 insertions(+), 2 deletions(-) diff --git a/hw/microblaze/xlnx-zynqmp-pmu.c b/hw/microblaze/xlnx-zynqmp-pmu.c index ac0f78928a..145837b372 100644 --- a/hw/microblaze/xlnx-zynqmp-pmu.c +++ b/hw/microblaze/xlnx-zynqmp-pmu.c @@ -18,8 +18,11 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu-common.h" +#include "exec/address-spaces.h" #include "hw/boards.h" +#include "hw/qdev-properties.h" #include "cpu.h" +#include "boot.h" /* Define the PMU device */ @@ -27,21 +30,56 @@ #define XLNX_ZYNQMP_PMU_SOC(obj) OBJECT_CHECK(XlnxZynqMPPMUSoCState, (obj), \ TYPE_XLNX_ZYNQMP_PMU_SOC) +#define XLNX_ZYNQMP_PMU_ROM_SIZE 0x8000 +#define XLNX_ZYNQMP_PMU_ROM_ADDR 0xFFD00000 +#define XLNX_ZYNQMP_PMU_RAM_ADDR 0xFFDC0000 + typedef struct XlnxZynqMPPMUSoCState { /*< private >*/ DeviceState parent_obj; /*< public >*/ + MicroBlazeCPU cpu; } XlnxZynqMPPMUSoCState; static void xlnx_zynqmp_pmu_soc_init(Object *obj) { + XlnxZynqMPPMUSoCState *s = XLNX_ZYNQMP_PMU_SOC(obj); + object_initialize(&s->cpu, sizeof(s->cpu), + TYPE_MICROBLAZE_CPU); + object_property_add_child(obj, "pmu-cpu", OBJECT(&s->cpu), + &error_abort); } static void xlnx_zynqmp_pmu_soc_realize(DeviceState *dev, Error **errp) { - + XlnxZynqMPPMUSoCState *s = XLNX_ZYNQMP_PMU_SOC(dev); + Error *err = NULL; + + object_property_set_uint(OBJECT(&s->cpu), XLNX_ZYNQMP_PMU_ROM_ADDR, + "base-vectors", &error_abort); + object_property_set_bool(OBJECT(&s->cpu), true, "use-stack-protection", + &error_abort); + object_property_set_uint(OBJECT(&s->cpu), 0, "use-fpu", &error_abort); + object_property_set_uint(OBJECT(&s->cpu), 0, "use-hw-mul", &error_abort); + object_property_set_bool(OBJECT(&s->cpu), true, "use-barrel", + &error_abort); + object_property_set_bool(OBJECT(&s->cpu), true, "use-msr-instr", + &error_abort); + object_property_set_bool(OBJECT(&s->cpu), true, "use-pcmp-instr", + &error_abort); + object_property_set_bool(OBJECT(&s->cpu), false, "use-mmu", &error_abort); + object_property_set_bool(OBJECT(&s->cpu), true, "endianness", + &error_abort); + object_property_set_str(OBJECT(&s->cpu), "8.40.b", "version", + &error_abort); + object_property_set_uint(OBJECT(&s->cpu), 0, "pvr", &error_abort); + object_property_set_bool(OBJECT(&s->cpu), true, "realized", &err); + if (err) { + error_propagate(errp, err); + return; + } } static void xlnx_zynqmp_pmu_soc_class_init(ObjectClass *oc, void *data) @@ -70,7 +108,35 @@ type_init(xlnx_zynqmp_pmu_soc_register_types) static void xlnx_zynqmp_pmu_init(MachineState *machine) { - + XlnxZynqMPPMUSoCState *pmu = g_new0(XlnxZynqMPPMUSoCState, 1); + MemoryRegion *address_space_mem = get_system_memory(); + MemoryRegion *pmu_rom = g_new(MemoryRegion, 1); + MemoryRegion *pmu_ram = g_new(MemoryRegion, 1); + + /* Create the ROM */ + memory_region_init_rom(pmu_rom, NULL, "xlnx-zynqmp-pmu.rom", + XLNX_ZYNQMP_PMU_ROM_SIZE, &error_fatal); + memory_region_add_subregion(address_space_mem, XLNX_ZYNQMP_PMU_ROM_ADDR, + pmu_rom); + + /* Create the RAM */ + memory_region_init_ram(pmu_ram, NULL, "xlnx-zynqmp-pmu.ram", + machine->ram_size, &error_fatal); + memory_region_add_subregion(address_space_mem, XLNX_ZYNQMP_PMU_RAM_ADDR, + pmu_ram); + + /* Create the PMU device */ + object_initialize(pmu, sizeof(XlnxZynqMPPMUSoCState), TYPE_XLNX_ZYNQMP_PMU_SOC); + object_property_add_child(OBJECT(machine), "pmu", OBJECT(pmu), + &error_abort); + object_property_set_bool(OBJECT(pmu), true, "realized", &error_fatal); + + /* Load the kernel */ + microblaze_load_kernel(&pmu->cpu, XLNX_ZYNQMP_PMU_RAM_ADDR, + machine->ram_size, + machine->initrd_filename, + machine->dtb, + NULL); } static void xlnx_zynqmp_pmu_machine_init(MachineClass *mc)