From nobody Sun Jul 26 13:28:56 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=reject dis=none) header.from=oss.qualcomm.com ARC-Seal: i=1; a=rsa-sha256; t=1781156387; cv=none; d=zohomail.com; s=zohoarc; b=c/f6p8yaUoD3IxKM10tiBoXtQt6VxoxnXKqSrd/i/IVSIRKkK6GhNq8xVRAg3/B/mX4VMm4EJ/HuE+VhTU7O5t3w1eYMp56zjoeytTUZ1dheidh9H5acZrFXSiPQyWaik1i7fSwr6ScMaGTws66AysPmP7G9+HMNEhff6QuM0ss= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781156387; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=Lv10MxyW8cqiiFnswTi797E7COTZ83BLO0ApDD7FX5U=; b=K1LJRAqmup1y7CSwomPBwAeey8X6aCevxLJJo5xs4FXXJ9xs+JM9oRYHuYA/nsrEU+iz9zXJ+OIIR9ur4utTC0GlIjlUjbqrEEN7dvxsh9c+FYStY8+OBYX8mOF6SVyScZ0a5ZxmCkykhIw8plSvQ5c9WUcoUwDvKbQkMF2n+6M= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1781156387721524.1717315947693; Wed, 10 Jun 2026 22:39:47 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXY8e-0007zu-Mo; Thu, 11 Jun 2026 01:39:38 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXY8N-0007te-Tw for qemu-devel@nongnu.org; Thu, 11 Jun 2026 01:39:20 -0400 Received: from mx0b-0031df01.pphosted.com ([205.220.180.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXY8K-0004tu-FT for qemu-devel@nongnu.org; Thu, 11 Jun 2026 01:39:19 -0400 Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 65B5GUCb3846382 for ; Thu, 11 Jun 2026 05:39:15 GMT Received: from mail-dy1-f200.google.com (mail-dy1-f200.google.com [74.125.82.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4eqe6u1sm3-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 11 Jun 2026 05:39:15 +0000 (GMT) Received: by mail-dy1-f200.google.com with SMTP id 5a478bee46e88-304f23c55b2so8220320eec.0 for ; Wed, 10 Jun 2026 22:39:15 -0700 (PDT) Received: from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com. [129.46.96.20]) by smtp.gmail.com with ESMTPSA id 5a478bee46e88-30806e8a9fesm735778eec.16.2026.06.10.22.39.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2026 22:39:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= Lv10MxyW8cqiiFnswTi797E7COTZ83BLO0ApDD7FX5U=; b=eUqu9EifoLHa+4KZ 6a1vjf99xNOZenJA1vWOrcTSu6wEpM+CvYRkpP1feXkMHMbx8xeiY77fZ6VMlEl6 iuX6lojyZ3Scr7mCRNFgbb4AK5x9RpfIJVMXGj+U7rHKlJjjYZ/0ELHYgG9Kn3qO O7OW779GtNzlVtRulJ9B+UihqM4RsOYO62fYpKdXSuIl6RZFsD2r1RpI9C5QA0Rt 4FKojViTSN12teFbBu+/CjqGc5gGk2o+aI2QJB8avSg4oof39Ne9MFJtzzvikVX1 YAM9qfT4T8cMwtrQVTXFCneQw3hTDk9tM6BxjmONiTg6qLsQp3eyLF2axQigqop3 dOklKw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1781156354; x=1781761154; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Lv10MxyW8cqiiFnswTi797E7COTZ83BLO0ApDD7FX5U=; b=e88FPp8fmERCU6aXQ/1zoWNuoq8RHQxd/lPltEXfDrMLQGMcJqvqhGD6mZGgrgCEgS MQrx4S8uE7X4gGVzUR5cdAMvdcw2hm6Kk/Hoi0kGbNqtouZso4UTmwYW/OlWWSYnBhBs PCOS0J38mmpPotmlguHgD8Hal5KIAhEDgib5QSBGHbBi8BDzBnbyu7R1+qMK0uKVFE9U pRt/7Yq3aMjr4J8QGv18jQ8Gv65ASpdbntjwnBNRQxA1B+qxmooqtSC+dB4bGdXwvoXR vo1q7SF94hQSWycOXg6VeHK9YEmewv22Lpiqkk/BoRngJJI9BT37w+GAe524Wa3P5BwY u26w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781156354; x=1781761154; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=Lv10MxyW8cqiiFnswTi797E7COTZ83BLO0ApDD7FX5U=; b=cmeUyV5Z+xD27qe7/WZZWH8ixs8GDjspVSTU4EdhuXk8MIMkJSfwVs8sNbwulLX4SY y6GZpiMO3u6WndCIxFV4c+muxDvEm/mlPuCx5EwXqmJOFFd+lxPoZYX/fM1YTq+b1HNO hsjTE2o0KSgXkDlscXTWK7B87nQyqt4NYqOf2PnW5Ne8vcvVN8yBJf02IR7dTnxvpOEy bYETfxOXke0GusaDQVoaHTLHnpx4hHEfFr9Tj9m25AHtTz+oT3yyiUQ/XGUy6cByrUAs nKmj2rmKfo3ijdmGqByfIjAtxSpyOpEY0l+sd7EjRbNrCgHXU7oN975otC5MoiGRKIHf Hm2Q== X-Gm-Message-State: AOJu0YyHOzrpCGwZY0b5ekDVmwq0F6QdCd8WUag9wJJU+OXqdAPYPVio jolxQUXQAgVqwOuhsJ37KUpyoFuYbUObyqFYbI0k9TgIYsGIxjsEwcDrID3iwRH3Ew494gsQh/N Vwy1Nr5GsCCjFztvdD8eJo7h3DtnZfQnzz/ZOSjVSFLff/dRjtM8dQjBiSHmsG4e9DQ== X-Gm-Gg: Acq92OEPrggYJa/aV2xuC98JFiqPgfXPqfDaj9aTykkPQ3jds8nWQVo7gUGE72WZO/I ZW6yLaEW3GLUZJl7i2nTCJU284N7DTPLK+ypTUHXw6QpIPeJrmNN4NqB8w/Pe6sFkfT8MvHWSqv b3H0MpAj0uRmaWiUc1QETTjb/vu68Gg/fDIXqseBM1V2i0RTGLIavNGAVa9omSY7LCp643VwN+Q pazIKiSjMG7cS91u7LJAYCaTrOGY8gEkAig4gfc81egYcCFMRkv1D91VajydBHgmVQThQo0E9Ev 59DFoQTtuQVZ4RhwY4dZB7tkJWwWXfWtgz+/zJ49ckkqpFCbhM5/VHyhyZIR/siGHJomUkJH1ZB RIppq29wZ5Ato0i/GuAH3Ihz1wsL/Qv9ElXBJZzE2wl2zbDaEniXqn8WjQbSUfAqVJUjuEmpkHg V5R/jz X-Received: by 2002:a05:7301:1291:b0:2f5:3fb3:4a76 with SMTP id 5a478bee46e88-30804657494mr973726eec.10.1781156354137; Wed, 10 Jun 2026 22:39:14 -0700 (PDT) X-Received: by 2002:a05:7301:1291:b0:2f5:3fb3:4a76 with SMTP id 5a478bee46e88-30804657494mr973680eec.10.1781156353404; Wed, 10 Jun 2026 22:39:13 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: brian.cain@oss.qualcomm.com, matheus.bernardino@oss.qualcomm.com, pierrick.bouvier@oss.qualcomm.com, ltaylorsimpson@gmail.com, philmd@mailo.org, philmd@oss.qualcomm.com, Brian Cain , Markus Armbruster , Mike Lambert , Sid Manning , Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= Subject: [PATCH v7] hw/hexagon: Add machine configs for sysemu Date: Wed, 10 Jun 2026 22:38:57 -0700 Message-Id: <20260611053902.3927367-5-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260611053902.3927367-1-brian.cain@oss.qualcomm.com> References: <20260611053902.3927367-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Authority-Analysis: v=2.4 cv=PZPPQChd c=1 sm=1 tr=0 ts=6a2a4a03 cx=c_pps a=PfFC4Oe2JQzmKTvty2cRDw==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=FelO9ux0wxsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=COk6AnOGAAAA:8 a=20KFwNOVAAAA:8 a=EUspDBNiAAAA:8 a=eE4CN_At-pr7qPS3jZsA:9 a=hiJlUhq8NronkB9Q:21 a=QEXdDO2ut3YA:10 a=6Ab_bkdmUrQuMsNx7PHu:22 a=TjNXssC_j7lpFel5tvFf:22 X-Proofpoint-ORIG-GUID: k4OzlwLXRTZ-P9KMR4JeQlu3_a-fHmC6 X-Proofpoint-GUID: k4OzlwLXRTZ-P9KMR4JeQlu3_a-fHmC6 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjExMDA1MyBTYWx0ZWRfXw1E1wTEoyA18 8Le2D4eBSoC/pos7Gx01g9/wpNXb2CXT7E0XiDd09HgCGlwNud+JjvY0FohjNDJHKu4nQc6wnES BoglVDXMRe/0G857cNYQyVUFtti0muq7EkQNHun1VhaOvAW3SjCNbZpvsyy29NDNNQE1QfJE6uZ YaTuywfuKl3x6q1l9XCtwWyiZhFwWcQf0PLB9XTZoyyHYv7FWf5AMSVXBQaWise3vmhZHzVQovo 0vyjaKpMFzEpuGnHV06eU8cVvwE4jyy+oeWB0lr34K+TPOp3tySTZe0wIdjw3Fortog4KcHlnby J3nEGFPO8wqWLWTQIk3UAiy+qAangA3/vozNk8KKPzIHI20pV2rxs0xzi+ACwUA5u9E1PpdbsJ5 51uRYQfFRXnwudclWSCDKglCFGS3DBq6rSuMPEdhlCz8d5LHTtMI38109pqQLX0k1plJxVXzCMH LzwcAwwMAWLtVsntl0A== X-Proofpoint-Spam-Info: AW1haW4tMjYwNjExMDA1MyBTYWx0ZWRfX/KXF54PM2xhG 1cIWhxnFmuqU7RN41Q7mYmuSPNbfp+EvnE+cnycibUvM3yhWy0biDq5HqJX/aiAnZhG1g9hcHJQ J7fst/hyF8kBIQbE5SVtdST+v8zgIlQ= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-11_01,2026-06-09_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 malwarescore=0 priorityscore=1501 adultscore=0 lowpriorityscore=0 clxscore=1015 phishscore=0 spamscore=0 suspectscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606040000 definitions=main-2606110053 Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=205.220.180.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0b-0031df01.pphosted.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @qualcomm.com) X-ZM-MESSAGEID: 1781156389558158500 From: Brian Cain Some header includes are modified here: these are uniquely required for basic system emulation functionality and had not been required for linux-us= er. Acked-by: Markus Armbruster Co-authored-by: Mike Lambert Co-authored-by: Sid Manning Reviewed-by: Pierrick Bouvier Signed-off-by: Brian Cain --- MAINTAINERS | 12 ++ include/hw/hexagon/hexagon.h | 161 ++++++++++++++++++ hw/hexagon/machine_cfg_v66g_1024.h.inc | 64 +++++++ hw/hexagon/hexagon_dsp.c | 220 +++++++++++++++++++++++++ system/qdev-monitor.c | 2 +- target/hexagon/translate.c | 1 + hw/Kconfig | 1 + hw/hexagon/Kconfig | 4 + hw/hexagon/meson.build | 6 + hw/meson.build | 1 + 10 files changed, 471 insertions(+), 1 deletion(-) create mode 100644 include/hw/hexagon/hexagon.h create mode 100644 hw/hexagon/machine_cfg_v66g_1024.h.inc create mode 100644 hw/hexagon/hexagon_dsp.c create mode 100644 hw/hexagon/Kconfig create mode 100644 hw/hexagon/meson.build diff --git a/MAINTAINERS b/MAINTAINERS index a2b04177be0..2103c33ffdc 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1353,6 +1353,18 @@ F: pc-bios/hppa-firmware.img F: roms/seabios-hppa/ F: tests/functional/hppa/ =20 +Hexagon Machines +---------------- +V66G_1024, V68N_1024, sa8775-cdsp0 +M: Brian Cain +R: Pierrick Bouvier +S: Supported +F: hw/hexagon/ +F: include/hw/hexagon/ +F: configs/devices/hexagon-softmmu/default.mak +F: docs/system/hexagon/ +F: docs/devel/hexagon-sys.rst + LoongArch Machines ------------------ Virt diff --git a/include/hw/hexagon/hexagon.h b/include/hw/hexagon/hexagon.h new file mode 100644 index 00000000000..1034b09c2ac --- /dev/null +++ b/include/hw/hexagon/hexagon.h @@ -0,0 +1,161 @@ +/* + * Hexagon Baseboard System emulation. + * + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + + +#ifndef HW_HEXAGON_H +#define HW_HEXAGON_H + +#include "system/memory.h" +#include "hw/core/boards.h" + +struct hexagon_board_boot_info { + uint64_t ram_size; + const char *kernel_filename; + uint32_t kernel_elf_flags; +}; + +typedef enum { + unknown_rev =3D 0, + v66_rev =3D 0xa666, + v67_rev =3D 0x2667, + v68_rev =3D 0x8d68, + v69_rev =3D 0x8c69, + v71_rev =3D 0x8c71, + v73_rev =3D 0x8c73, + v73m_rev =3D 0xcc73, +} Rev_t; +#define HEXAGON_LATEST_REV v73 +#define HEXAGON_LATEST_REV_UPPER V73 + +/* + * Config table address bases represent bits [35:16]. + */ +#define HEXAGON_CFG_ADDR_BASE(addr) (((addr) >> 16) & 0x0fffff) + +#define HEXAGON_CFGSPACE_ENTRIES (128) + +union hexagon_config_table { + struct { + /* Base address of L2TCM space */ + uint32_t l2tcm_base; + uint32_t reserved0; + /* Base address of subsystem space */ + uint32_t subsystem_base; + /* Base address of ETM space */ + uint32_t etm_base; + /* Base address of L2 configuration space */ + uint32_t l2cfg_base; + uint32_t reserved1; + /* Base address of L1S */ + uint32_t l1s0_base; + /* Base address of AXI2 */ + uint32_t axi2_lowaddr; + /* Base address of streamer base */ + uint32_t streamer_base; + uint32_t reserved2; + /* Base address of fast L2VIC */ + uint32_t fastl2vic_base; + /* Number of entries in JTLB */ + uint32_t jtlb_size_entries; + /* Coprocessor type */ + uint32_t coproc_present; + /* Number of extension execution contexts available */ + uint32_t ext_contexts; + /* Base address of Hexagon Vector Tightly Coupled Memory (VTCM) */ + uint32_t vtcm_base; + /* Size of VTCM (in KB) */ + uint32_t vtcm_size_kb; + /* L2 tag size */ + uint32_t l2tag_size; + /* Amount of physical L2 memory in released version */ + uint32_t l2ecomem_size; + /* Hardware threads available on the core */ + uint32_t thread_enable_mask; + /* Base address of the ECC registers */ + uint32_t eccreg_base; + /* L2 line size */ + uint32_t l2line_size; + /* Small Core processor (also implies audio extension) */ + uint32_t tiny_core; + /* Size of L2TCM */ + uint32_t l2itcm_size; + /* Base address of L2-ITCM */ + uint32_t l2itcm_base; + uint32_t reserved3; + /* DTM is present */ + uint32_t dtm_present; + /* Version of the DMA */ + uint32_t dma_version; + /* Native HVX vector length in log of bytes */ + uint32_t hvx_vec_log_length; + /* Core ID of the multi-core */ + uint32_t core_id; + /* Number of multi-core cores */ + uint32_t core_count; + uint32_t coproc2_reg0; + uint32_t coproc2_reg1; + /* Supported HVX vector length */ + uint32_t v2x_mode; + uint32_t coproc2_reg2; + uint32_t coproc2_reg3; + uint32_t coproc2_reg4; + uint32_t coproc2_reg5; + uint32_t coproc2_reg6; + uint32_t coproc2_reg7; + /* Voltage droop mitigation technique parameter */ + uint32_t acd_preset; + /* Voltage droop mitigation technique parameter */ + uint32_t mnd_preset; + /* L1 data cache size (in KB) */ + uint32_t l1d_size_kb; + /* L1 instruction cache size in (KB) */ + uint32_t l1i_size_kb; + /* L1 data cache write policy: see HexagonL1WritePolicy */ + uint32_t l1d_write_policy; + /* VTCM bank width */ + uint32_t vtcm_bank_width; + uint32_t reserved4; + uint32_t reserved5; + uint32_t reserved6; + uint32_t coproc2_cvt_mpy_size; + uint32_t consistency_domain; + uint32_t capacity_domain; + uint32_t axi3_lowaddr; + uint32_t coproc2_int8_subcolumns; + uint32_t corecfg_present; + uint32_t coproc2_fp16_acc_exp; + uint32_t AXIM2_secondary_base; + }; + uint32_t raw[HEXAGON_CFGSPACE_ENTRIES]; +}; + +struct hexagon_machine_config { + /* Base address of config table */ + uint32_t cfgbase; + /* Size of L2 TCM */ + uint32_t l2tcm_size; + /* Base address of L2VIC */ + uint32_t l2vic_base; + /* Size of L2VIC region */ + uint32_t l2vic_size; + /* QTimer csr base */ + uint32_t csr_base; + uint32_t qtmr_region; + union hexagon_config_table cfgtable; +}; + +#define TYPE_HEXAGON_COMMON_MACHINE "hexagon-common-machine" +OBJECT_DECLARE_SIMPLE_TYPE(HexagonCommonMachineState, HEXAGON_COMMON_MACHI= NE) + +struct HexagonCommonMachineState { + MachineState parent_obj; + + MemoryRegion ram; + MemoryRegion cfgtable_rom; +}; + +#endif diff --git a/hw/hexagon/machine_cfg_v66g_1024.h.inc b/hw/hexagon/machine_cf= g_v66g_1024.h.inc new file mode 100644 index 00000000000..cc4d89b89c9 --- /dev/null +++ b/hw/hexagon/machine_cfg_v66g_1024.h.inc @@ -0,0 +1,64 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later */ + +static const struct hexagon_machine_config v66g_1024 =3D { + .cfgbase =3D 0xd8180000, + .l2tcm_size =3D 0x00000000, + .l2vic_base =3D 0xfc910000, + .l2vic_size =3D 0x00001000, + .csr_base =3D 0xfc900000, + .qtmr_region =3D 0xfc921000, + .cfgtable =3D { + .l2tcm_base =3D 0x0000d800, + .reserved0 =3D 0x0000d400, + .subsystem_base =3D 0x0000fc90, + .etm_base =3D 0x0000d805, + .l2cfg_base =3D 0x0000d81a, + .reserved1 =3D 0x00000000, + .l1s0_base =3D 0x0000d820, + .axi2_lowaddr =3D 0x00003000, + .streamer_base =3D 0x00000000, + .reserved2 =3D 0x0000d819, + .fastl2vic_base =3D 0x0000d81e, + .jtlb_size_entries =3D 0x00000080, + .coproc_present =3D 0x00000001, + .ext_contexts =3D 0x00000004, + .vtcm_base =3D 0x0000d820, + .vtcm_size_kb =3D 0x00000100, + .l2tag_size =3D 0x00000400, + .l2ecomem_size =3D 0x00000400, + .thread_enable_mask =3D 0x0000000f, + .eccreg_base =3D 0x0000d81f, + .l2line_size =3D 0x00000080, + .tiny_core =3D 0x00000000, + .l2itcm_size =3D 0x00000000, + .l2itcm_base =3D 0x0000d820, + .reserved3 =3D 0x00000000, + .dtm_present =3D 0x00000000, + .dma_version =3D 0x00000000, + .hvx_vec_log_length =3D 0x00000080, + .core_id =3D 0x00000000, + .core_count =3D 0x00000000, + .coproc2_reg0 =3D 0x00000000, + .coproc2_reg1 =3D 0x00000000, + .v2x_mode =3D 0x00000000, + .coproc2_reg2 =3D 0x00000000, + .coproc2_reg3 =3D 0x00000000, + .coproc2_reg4 =3D 0x00000000, + .coproc2_reg5 =3D 0x00000000, + .coproc2_reg6 =3D 0x00000000, + .coproc2_reg7 =3D 0x00000000, + .acd_preset =3D 0x00000000, + .mnd_preset =3D 0x00000000, + .l1d_size_kb =3D 0x00000000, + .l1i_size_kb =3D 0x00000000, + .l1d_write_policy =3D 0x00000000, + .vtcm_bank_width =3D 0x00000000, + .reserved4 =3D 0x00000000, + .reserved5 =3D 0x00000000, + .reserved6 =3D 0x00000000, + .coproc2_cvt_mpy_size =3D 0x00000000, + .consistency_domain =3D 0x00000000, + .capacity_domain =3D 0x00000000, + .axi3_lowaddr =3D 0x00000000, + }, +}; diff --git a/hw/hexagon/hexagon_dsp.c b/hw/hexagon/hexagon_dsp.c new file mode 100644 index 00000000000..5934a99b522 --- /dev/null +++ b/hw/hexagon/hexagon_dsp.c @@ -0,0 +1,220 @@ +/* + * Hexagon DSP Subsystem emulation. This represents a generic DSP + * subsystem with few peripherals, like the Compute DSP. + * + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + + +#include "qemu/osdep.h" +#include "qemu/units.h" +#include "system/address-spaces.h" +#include "hw/core/boards.h" +#include "hw/core/qdev-properties.h" +#include "hw/hexagon/hexagon.h" +#include "hw/hexagon/hexagon_globalreg.h" +#include "hw/hexagon/hexagon_tlb.h" +#include "hw/core/loader.h" +#include "qapi/error.h" +#include "qemu/error-report.h" +#include "qemu/log.h" +#include "elf.h" +#include "cpu.h" +#include "migration/cpu.h" +#include "system/system.h" +#include "target/hexagon/internal.h" +#include "system/reset.h" + +#include "machine_cfg_v66g_1024.h.inc" + +#define TYPE_HEXAGON_DSP_MACHINE "hexagon-dsp-machine" +OBJECT_DECLARE_SIMPLE_TYPE(HexagonDspMachineState, HEXAGON_DSP_MACHINE) + +struct HexagonDspMachineState { + HexagonCommonMachineState parent_obj; + + hwaddr isdb_secure_flag; + hwaddr isdb_trusted_flag; +}; + +static HexagonDspMachineState *current_dms; + +static void hex_symbol_callback(const char *st_name, int st_info, + uint64_t st_value, uint64_t st_size) +{ + if (!g_strcmp0("isdb_secure_flag", st_name)) { + current_dms->isdb_secure_flag =3D st_value; + } + if (!g_strcmp0("isdb_trusted_flag", st_name)) { + current_dms->isdb_trusted_flag =3D st_value; + } +} + +/* Board init. */ +static struct hexagon_board_boot_info hexagon_binfo; + +static void hexagon_load_kernel(HexagonDspMachineState *dms, HexagonCPU *c= pu) +{ + uint64_t pentry; + long kernel_size; + + current_dms =3D dms; + kernel_size =3D load_elf_ram_sym(hexagon_binfo.kernel_filename, NULL, = NULL, + NULL, &pentry, NULL, NULL, + &hexagon_binfo.kernel_elf_flags, 0, EM_HEXAGON, 0, 0, + &address_space_memory, false, hex_symbol_callback); + current_dms =3D NULL; + + if (kernel_size <=3D 0) { + error_report("no kernel file '%s'", + hexagon_binfo.kernel_filename); + exit(1); + } + + qdev_prop_set_uint32(DEVICE(cpu), "exec-start-addr", pentry); +} + +static void hexagon_init_bootstrap(HexagonDspMachineState *dms, HexagonCPU= *cpu) +{ + MachineState *machine =3D MACHINE(dms); + + if (machine->kernel_filename) { + uint32_t mem =3D 1; + + hexagon_load_kernel(dms, cpu); + if (dms->isdb_secure_flag) { + cpu_physical_memory_write(dms->isdb_secure_flag, + &mem, sizeof(mem)); + } + if (dms->isdb_trusted_flag) { + cpu_physical_memory_write(dms->isdb_trusted_flag, + &mem, sizeof(mem)); + } + } +} + +static void do_cpu_reset(void *opaque) +{ + HexagonCPU *cpu =3D opaque; + CPUState *cs =3D CPU(cpu); + cpu_reset(cs); +} + +static void hexagon_common_init(MachineState *machine, Rev_t rev, + const struct hexagon_machine_config *m_cfg) +{ + HexagonCommonMachineState *hms =3D HEXAGON_COMMON_MACHINE(machine); + HexagonDspMachineState *dms =3D HEXAGON_DSP_MACHINE(machine); + MemoryRegion *address_space; + DeviceState *glob_regs_dev; + DeviceState *tlb_dev; + + memset(&hexagon_binfo, 0, sizeof(hexagon_binfo)); + if (machine->kernel_filename) { + hexagon_binfo.ram_size =3D machine->ram_size; + hexagon_binfo.kernel_filename =3D machine->kernel_filename; + } + + machine->enable_graphics =3D 0; + + address_space =3D get_system_memory(); + + memory_region_init_rom(&hms->cfgtable_rom, NULL, "config_table.rom", + sizeof(m_cfg->cfgtable), &error_fatal); + memory_region_add_subregion(address_space, m_cfg->cfgbase, + &hms->cfgtable_rom); + + memory_region_init_ram(&hms->ram, NULL, "ddr.ram", + machine->ram_size, &error_fatal); + memory_region_add_subregion(address_space, 0x0, &hms->ram); + + glob_regs_dev =3D qdev_new(TYPE_HEXAGON_GLOBALREG); + object_property_add_child(OBJECT(machine), "global-regs", + OBJECT(glob_regs_dev)); + qdev_prop_set_uint64(glob_regs_dev, "config-table-addr", m_cfg->cfgbas= e); + qdev_prop_set_uint32(glob_regs_dev, "dsp-rev", rev); + sysbus_realize_and_unref(SYS_BUS_DEVICE(glob_regs_dev), &error_fatal); + + tlb_dev =3D qdev_new(TYPE_HEXAGON_TLB); + object_property_add_child(OBJECT(machine), "tlb", OBJECT(tlb_dev)); + qdev_prop_set_uint32(tlb_dev, "num-entries", + m_cfg->cfgtable.jtlb_size_entries); + sysbus_realize_and_unref(SYS_BUS_DEVICE(tlb_dev), &error_fatal); + + for (int i =3D 0; i < machine->smp.cpus; i++) { + HexagonCPU *cpu =3D HEXAGON_CPU(object_new(machine->cpu_type)); + qemu_register_reset(do_cpu_reset, cpu); + + /* + * CPU #0 is the only CPU running at boot, others must be + * explicitly enabled via start instruction. + */ + qdev_prop_set_bit(DEVICE(cpu), "start-powered-off", (i !=3D 0)); + if (i =3D=3D 0) { + hexagon_init_bootstrap(dms, cpu); + } + object_property_set_link(OBJECT(cpu), "global-regs", + OBJECT(glob_regs_dev), &error_fatal); + object_property_set_link(OBJECT(cpu), "tlb", + OBJECT(tlb_dev), &error_fatal); + qdev_realize_and_unref(DEVICE(cpu), NULL, &error_fatal); + } +} + +static void init_mc(MachineClass *mc) +{ + mc->block_default_type =3D IF_SD; + mc->default_ram_size =3D 4 * GiB; + mc->no_parallel =3D 1; + mc->no_floppy =3D 1; + mc->no_cdrom =3D 1; + mc->no_serial =3D 1; + mc->is_default =3D false; + mc->max_cpus =3D 8; +} + +/* ----------------------------------------------------------------- */ +/* Core-specific configuration settings are defined below this line. */ +/* Config table values defined in machine_configs.h.inc */ +/* ----------------------------------------------------------------- */ + +static void v66g_1024_config_init(MachineState *machine) +{ + hexagon_common_init(machine, v66_rev, &v66g_1024); +} + +static void v66g_1024_init(ObjectClass *oc, const void *data) +{ + MachineClass *mc =3D MACHINE_CLASS(oc); + + mc->desc =3D "Hexagon V66G_1024"; + mc->init =3D v66g_1024_config_init; + init_mc(mc); + mc->is_default =3D true; + mc->default_cpu_type =3D TYPE_HEXAGON_CPU_V66; + mc->default_cpus =3D 4; +} + +static const TypeInfo hexagon_machine_types[] =3D { + { + .name =3D TYPE_HEXAGON_COMMON_MACHINE, + .parent =3D TYPE_MACHINE, + .instance_size =3D sizeof(HexagonCommonMachineState), + .abstract =3D true, + }, + { + .name =3D TYPE_HEXAGON_DSP_MACHINE, + .parent =3D TYPE_HEXAGON_COMMON_MACHINE, + .instance_size =3D sizeof(HexagonDspMachineState), + .abstract =3D true, + }, + { + .name =3D MACHINE_TYPE_NAME("V66G_1024"), + .parent =3D TYPE_HEXAGON_DSP_MACHINE, + .class_init =3D v66g_1024_init, + }, +}; + +DEFINE_TYPES(hexagon_machine_types) diff --git a/system/qdev-monitor.c b/system/qdev-monitor.c index dfc95a08c10..00fed791cce 100644 --- a/system/qdev-monitor.c +++ b/system/qdev-monitor.c @@ -71,7 +71,7 @@ typedef struct QDevAlias QEMU_ARCH_SPARC | \ QEMU_ARCH_XTENSA) #define QEMU_ARCH_VIRTIO_CCW (QEMU_ARCH_S390X) -#define QEMU_ARCH_VIRTIO_MMIO (QEMU_ARCH_M68K) +#define QEMU_ARCH_VIRTIO_MMIO (QEMU_ARCH_M68K | QEMU_ARCH_HEXAGON) =20 /* Please keep this table sorted by typename. */ static const QDevAlias qdev_alias_table[] =3D { diff --git a/target/hexagon/translate.c b/target/hexagon/translate.c index e0418ee990d..77235916f4b 100644 --- a/target/hexagon/translate.c +++ b/target/hexagon/translate.c @@ -32,6 +32,7 @@ #include "translate.h" #include "genptr.h" #include "printinsn.h" +#include "exec/target_page.h" =20 #define HELPER_H "helper.h" #include "exec/helper-info.c.inc" diff --git a/hw/Kconfig b/hw/Kconfig index c109f5537b2..c92ca2b13a3 100644 --- a/hw/Kconfig +++ b/hw/Kconfig @@ -53,6 +53,7 @@ source arm/Kconfig source cpu/Kconfig source alpha/Kconfig source avr/Kconfig +source hexagon/Kconfig source hppa/Kconfig source i386/Kconfig source loongarch/Kconfig diff --git a/hw/hexagon/Kconfig b/hw/hexagon/Kconfig new file mode 100644 index 00000000000..cdf7770a305 --- /dev/null +++ b/hw/hexagon/Kconfig @@ -0,0 +1,4 @@ +config HEX_DSP + bool + default y + depends on HEXAGON diff --git a/hw/hexagon/meson.build b/hw/hexagon/meson.build new file mode 100644 index 00000000000..f528d2bc4ab --- /dev/null +++ b/hw/hexagon/meson.build @@ -0,0 +1,6 @@ +hexagon_ss =3D ss.source_set() +hexagon_ss.add(files('hexagon_tlb.c')) +hexagon_ss.add(files('hexagon_globalreg.c')) +hexagon_ss.add(when: 'CONFIG_HEX_DSP', if_true: files('hexagon_dsp.c')) + +hw_arch +=3D {'hexagon': hexagon_ss} diff --git a/hw/meson.build b/hw/meson.build index ef65ba51950..7fa81db453e 100644 --- a/hw/meson.build +++ b/hw/meson.build @@ -3,6 +3,7 @@ subdir('alpha') subdir('arm') subdir('avr') subdir('hppa') +subdir('hexagon') subdir('xenpv') # i386 uses it subdir('i386') subdir('loongarch') --=20 2.34.1