From patchwork Mon Nov 6 15:48:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Andrey Smirnov X-Patchwork-Id: 10043825 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 53006602BF for ; Mon, 6 Nov 2017 16:17:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4A42729A53 for ; Mon, 6 Nov 2017 16:17:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D58B29ECF; Mon, 6 Nov 2017 16:17:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id AB44729A53 for ; Mon, 6 Nov 2017 16:17:16 +0000 (UTC) Received: from localhost ([::1]:48937 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBk5L-0005Tv-Oo for patchwork-qemu-devel@patchwork.kernel.org; Mon, 06 Nov 2017 11:17:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eBje9-0007c8-QA for qemu-devel@nongnu.org; Mon, 06 Nov 2017 10:49:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eBje8-0000p0-LA for qemu-devel@nongnu.org; Mon, 06 Nov 2017 10:49:09 -0500 Received: from mail-pg0-x22a.google.com ([2607:f8b0:400e:c05::22a]:51153) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eBje0-0000hm-Fm; Mon, 06 Nov 2017 10:49:00 -0500 Received: by mail-pg0-x22a.google.com with SMTP id y5so8506337pgq.7; Mon, 06 Nov 2017 07:49:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RiLjggeRCcOfUciZjmgDU5rvimlAJjeVBARBtVCXyjU=; b=u0lrC8+ft5QTttKB00+vQyV/NMMFU4SSbOdN1rXiErhoaHCwx2yGxOu3K+QdAFn1ic CxohnlFglPmXA6BaOzdV5Z9EIo3iLJ0PmEZuz3cOPo03MiVEvuwZcOOK5sGHmJh2pVxb A8TzQKwfZaoFjfQ9basMLIImrEpkTNkPJ+BvigpqPJI1MwR1saf3+cIt+UfKTNhtmOHc Fjqotjzrv9BGvllVJ+TD7s1byPWB5zpEBNrsmSyToAJOVcVZ9qGaEPUwfskj9TW6zCG7 9JmneP7W86eL5VJZ1qeJCaEWfmM6DUClMk2Fdp8WL6OVjiIM9RQ5o2CdT+vVzP15R4/T 2BvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RiLjggeRCcOfUciZjmgDU5rvimlAJjeVBARBtVCXyjU=; b=XVOlQIL+Z/pqHJU63Ft4hBUhYN0PeZni3nqzdQW4L3MJHfBIy14V4A2qv+VOS5pHDo 4kCE/zSoL6ZY4r/yc8RGpgZs4io9A7uv42h6lbsDO12h0YWQzy1+UHXcg1ik6Fjv6xja pqFHo246gBqOCxOG+DuyRuBB1OEn4jofm8bkbWI8/oXs4juAC3UVDBeCRRjby7Kq0a68 Nzs4d0Kl7LzMbzb+xU7Wjb2/zIP3PXVxMuYmjzauiURq34lrxW5j10mwwa26vkOnNcWZ fX8e3BKnh0oPVZXSvv73JLA8R5aRGxhESzW7/PjC4CiiP4R16+T65it/xGQDbOtFsoov 2b+A== X-Gm-Message-State: AMCzsaVXB3HrMX3YPuNsZ/NrtzX0x0T61FZUvWhPNqjz1+LpDDzrXGwt YOIbeh2VS0GRwPx9D0uRUKCL3paH1n0= X-Google-Smtp-Source: ABhQp+S4sZ/XbzWUC6TUv3163B8S/VBqQ7jDolRV1j3/SIbhORnH9ECGgK4aBjr/ZiODmIHRFgIAgA== X-Received: by 10.159.244.18 with SMTP id x18mr15163410plr.338.1509983339116; Mon, 06 Nov 2017 07:48:59 -0800 (PST) Received: from squirtle.lan (c-24-22-235-96.hsd1.wa.comcast.net. [24.22.235.96]) by smtp.gmail.com with ESMTPSA id x1sm22719590pfh.113.2017.11.06.07.48.57 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Nov 2017 07:48:58 -0800 (PST) From: Andrey Smirnov To: qemu-arm@nongnu.org Date: Mon, 6 Nov 2017 07:48:10 -0800 Message-Id: <20171106154813.19936-28-andrew.smirnov@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171106154813.19936-1-andrew.smirnov@gmail.com> References: <20171106154813.19936-1-andrew.smirnov@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22a Subject: [Qemu-devel] [PATCH v3 27/30] ARM: Add basic code to emulate A7MPCore DAP block 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: Peter Maydell , Andrey Smirnov , Jason Wang , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org, yurovsky@gmail.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add minimal code to emulate A7MPCore DAP block needed to boot Linux guest. Cc: Peter Maydell Cc: Jason Wang Cc: Philippe Mathieu-Daudé Cc: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org Cc: yurovsky@gmail.com Signed-off-by: Andrey Smirnov --- hw/arm/Makefile.objs | 2 +- hw/arm/coresight.c | 120 +++++++++++++++++++++++++++++++++++++++++++++ include/hw/arm/coresight.h | 24 +++++++++ 3 files changed, 145 insertions(+), 1 deletion(-) create mode 100644 hw/arm/coresight.c create mode 100644 include/hw/arm/coresight.h diff --git a/hw/arm/Makefile.objs b/hw/arm/Makefile.objs index a2e56ecaae..459a3fa6be 100644 --- a/hw/arm/Makefile.objs +++ b/hw/arm/Makefile.objs @@ -1,4 +1,4 @@ -obj-y += boot.o collie.o exynos4_boards.o gumstix.o highbank.o +obj-y += boot.o collie.o exynos4_boards.o gumstix.o highbank.o coresight.o obj-$(CONFIG_DIGIC) += digic_boards.o obj-y += integratorcp.o mainstone.o musicpal.o nseries.o obj-y += omap_sx1.o palm.o realview.o spitz.o stellaris.o diff --git a/hw/arm/coresight.c b/hw/arm/coresight.c new file mode 100644 index 0000000000..d0a8c1b005 --- /dev/null +++ b/hw/arm/coresight.c @@ -0,0 +1,120 @@ +/* + * Copyright (c) 2017, Impinj, Inc. + * + * CoreSight block emulation code + * + * Author: Andrey Smirnov + * + * This work is licensed under the terms of the GNU GPL, version 2 or later. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "hw/arm/coresight.h" +#include "qemu/log.h" + +static uint64_t coresight_read(void *opaque, hwaddr offset, + unsigned size) +{ + return 0; +} + +static void coresight_write(void *opaque, hwaddr offset, + uint64_t value, unsigned size) +{ +} + +static const struct MemoryRegionOps coresight_ops = { + .read = coresight_read, + .write = coresight_write, + .endianness = DEVICE_NATIVE_ENDIAN, + .impl = { + /* + * Our device would not work correctly if the guest was doing + * unaligned access. This might not be a limitation on the real + * device but in practice there is no reason for a guest to access + * this device unaligned. + */ + .min_access_size = 4, + .max_access_size = 4, + .unaligned = false, + }, +}; + +static void a7mpcore_dap_init(Object *obj) +{ + SysBusDevice *sd = SYS_BUS_DEVICE(obj); + A7MPCoreDAPState *s = A7MPCORE_DAP(obj); + + memory_region_init(&s->container, obj, "a7mpcore-dap-container", 0x100000); + sysbus_init_mmio(sd, &s->container); + + memory_region_init_io(&s->ca7_atb_funnel, + obj, + &coresight_ops, + s, + TYPE_A7MPCORE_DAP ".ca7-atb-funnel", + 0x1000); + memory_region_add_subregion(&s->container, 0x41000, &s->ca7_atb_funnel); + + memory_region_init_io(&s->cpu0_etm, + obj, + &coresight_ops, + s, + TYPE_A7MPCORE_DAP ".cpu0-etm", + 0x1000); + memory_region_add_subregion(&s->container, 0x7C000, &s->cpu0_etm); + + memory_region_init_io(&s->atb_funnel, + obj, + &coresight_ops, + s, + TYPE_A7MPCORE_DAP ".atb-funnel", + 0x1000); + memory_region_add_subregion(&s->container, 0x83000, &s->atb_funnel); + + memory_region_init_io(&s->tmc_etb, + obj, + &coresight_ops, + s, + TYPE_A7MPCORE_DAP ".tmc-etb", + 0x1000); + memory_region_add_subregion(&s->container, 0x84000, &s->tmc_etb); + + memory_region_init_io(&s->tmc_etr, + obj, + &coresight_ops, + s, + TYPE_A7MPCORE_DAP ".tmc-etr", + 0x1000); + memory_region_add_subregion(&s->container, 0x86000, &s->tmc_etr); + + memory_region_init_io(&s->tpiu, + obj, + &coresight_ops, + s, + TYPE_A7MPCORE_DAP ".tpiu", + 0x1000); + memory_region_add_subregion(&s->container, 0x87000, &s->tpiu); +} + +static void a7mpcore_dap_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + + dc->desc = "A7MPCore DAP Module"; +} + +static const TypeInfo a7mpcore_dap_info = { + .name = TYPE_A7MPCORE_DAP, + .parent = TYPE_SYS_BUS_DEVICE, + .instance_size = sizeof(A7MPCoreDAPState), + .instance_init = a7mpcore_dap_init, + .class_init = a7mpcore_dap_class_init, +}; + +static void coresight_register_type(void) +{ + type_register_static(&a7mpcore_dap_info); +} +type_init(coresight_register_type) diff --git a/include/hw/arm/coresight.h b/include/hw/arm/coresight.h new file mode 100644 index 0000000000..d1480e825b --- /dev/null +++ b/include/hw/arm/coresight.h @@ -0,0 +1,24 @@ +#ifndef CORESIGHT_H +#define CORESIGHT_H + +#include "hw/sysbus.h" + +typedef struct A7MPCoreDAPState { + /*< private >*/ + SysBusDevice parent_obj; + + MemoryRegion container; + + MemoryRegion ca7_atb_funnel; + MemoryRegion cpu0_etm; + MemoryRegion atb_funnel; + MemoryRegion tmc_etb; + MemoryRegion tmc_etr; + MemoryRegion tpiu; + +} A7MPCoreDAPState; + +#define TYPE_A7MPCORE_DAP "a7mpcore-dap" +#define A7MPCORE_DAP(obj) OBJECT_CHECK(A7MPCoreDAPState, (obj), TYPE_A7MPCORE_DAP) + +#endif /* CORESIGHT_H */