{"id":2221217,"url":"http://patchwork.ozlabs.org/api/1.1/patches/2221217/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260408042149.1902796-2-brian.cain@oss.qualcomm.com/","project":{"id":14,"url":"http://patchwork.ozlabs.org/api/1.1/projects/14/?format=json","name":"QEMU Development","link_name":"qemu-devel","list_id":"qemu-devel.nongnu.org","list_email":"qemu-devel@nongnu.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20260408042149.1902796-2-brian.cain@oss.qualcomm.com>","date":"2026-04-08T04:21:40","name":"[v4,1/9] hw/hexagon: Add globalreg model","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"7a2003fbf68cfcb83872df7f827f3d1b78379add","submitter":{"id":89839,"url":"http://patchwork.ozlabs.org/api/1.1/people/89839/?format=json","name":"Brian Cain","email":"brian.cain@oss.qualcomm.com"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/qemu-devel/patch/20260408042149.1902796-2-brian.cain@oss.qualcomm.com/mbox/","series":[{"id":499184,"url":"http://patchwork.ozlabs.org/api/1.1/series/499184/?format=json","web_url":"http://patchwork.ozlabs.org/project/qemu-devel/list/?series=499184","date":"2026-04-08T04:21:47","name":"Hexagon system emulation - Part 3/3","version":4,"mbox":"http://patchwork.ozlabs.org/series/499184/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/2221217/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2221217/checks/","tags":{},"headers":{"Return-Path":"<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>","X-Original-To":"incoming@patchwork.ozlabs.org","Delivered-To":"patchwork-incoming@legolas.ozlabs.org","Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.a=rsa-sha256\n header.s=qcppdkim1 header.b=UGXV7Gzn;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com\n header.a=rsa-sha256 header.s=google header.b=bS83ycVo;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"],"Received":["from lists.gnu.org (lists1p.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4frYhl4d8Bz1yD6\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 09 Apr 2026 05:55:51 +1000 (AEST)","from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1wAYaF-0006lD-JZ; Wed, 08 Apr 2026 15:29:03 -0400","from eggs.gnu.org ([2001:470:142:3::10])\n by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <brian.cain@oss.qualcomm.com>)\n id 1wAY8I-00088h-8N\n for qemu-devel@nongnu.org; Wed, 08 Apr 2026 15:00:10 -0400","from mx0b-0031df01.pphosted.com ([205.220.180.131])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <brian.cain@oss.qualcomm.com>)\n id 1wAKQN-0005i2-1h\n for qemu-devel@nongnu.org; Wed, 08 Apr 2026 00:21:56 -0400","from pps.filterd (m0279870.ppops.net [127.0.0.1])\n by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id\n 637M6pF52451580\n for <qemu-devel@nongnu.org>; Wed, 8 Apr 2026 04:21:54 GMT","from mail-dl1-f70.google.com (mail-dl1-f70.google.com\n [74.125.82.70])\n by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ddae68wra-1\n (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT)\n for <qemu-devel@nongnu.org>; Wed, 08 Apr 2026 04:21:54 +0000 (GMT)","by mail-dl1-f70.google.com with SMTP id\n a92af1059eb24-12c0ed22849so283088c88.1\n for <qemu-devel@nongnu.org>; Tue, 07 Apr 2026 21:21:53 -0700 (PDT)","from hu-bcain-lv.qualcomm.com (Global_NAT1.qualcomm.com.\n [129.46.96.20]) by smtp.gmail.com with ESMTPSA id\n a92af1059eb24-12bed93f861sm23474816c88.0.2026.04.07.21.21.51\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Tue, 07 Apr 2026 21:21:51 -0700 (PDT)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h=\n cc:content-transfer-encoding:content-type:date:from:in-reply-to\n :message-id:mime-version:references:subject:to; s=qcppdkim1; bh=\n u4RjKyvpnz+y/VOl95Hj6W3WCKJiAaBCbdGTrB3Z9UQ=; b=UGXV7GznwDDaqaYL\n dT8/rIDg31ZXke6sRDgo6Pab2R6tX6fyIC0e/d6yT6sGKS+eYAsIBB5pdYYxnbhi\n tphJ1BlyWLSJKZOSBUimXcJivLt07InBxZa5b/LChkJKEE7J504kS1Ltwn1lVQs6\n DyAOU8AJuknPHzn9nXZUiKJoQMuBC28Z9HfYA4LwUMIE0TkUT2c/QqZ6VHY6askA\n J7NePKKz+ymRobAaFvprb5lhsHc1bZJflEWwAkMyEV5dyHgB7y2qnirKQJHBOT/H\n Ez+70tBD2l6YhBzxz5AJUAPGgxymJFJSwTBopChYqdDZ+R1x/tHX9+YS5Ssw7r5z\n N0IG7A==","v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=oss.qualcomm.com; s=google; t=1775622113; x=1776226913; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=u4RjKyvpnz+y/VOl95Hj6W3WCKJiAaBCbdGTrB3Z9UQ=;\n b=bS83ycVotwlZbyJzBFPLluT7kfrmHG4QBNjr7mP/4VVn7gNTiQKnpJeX5GFrkeoKv1\n /bhTGloWaB7x7Pau3mcsrDFHVEOMkIduuWakVJntohaTEsUzgjZNhPTh18tMDLgJS9Ln\n X/eYwB3kZA2B585yrqphXoJMKndX4pQaNIgiOmNEsjL+H8x548cfe8c35sb/G4QyFhgI\n 5ZUXXOCtHSGLbIctTEKLAtpVnUuepWbBAra2ZzQh6jKuGfJBALjC8KsmWwlrxAEw4wDf\n koESNfPRAlLbMvAKOK3Ur7yn/PS9u8+sDd7COvZc0qXd1EzLqIolBXel9E6+9VdzjLQc\n SexQ=="],"X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1775622113; x=1776226913;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=u4RjKyvpnz+y/VOl95Hj6W3WCKJiAaBCbdGTrB3Z9UQ=;\n b=rc0lvwrfzGqQ75tD+AnpU9a6cImhNW19pgf8FhXKhDfPCnHS1f4IXuyEZcjVF3uKxd\n Z1o7ht8387n9k7BAmNE6pz0QnNJNGymtnCY78Pq+m7uNjNih9OA3CMFgc2LFrOzopiV1\n xQVT+QlZKQ46sB22XeulbWaz//7cRjcBDkiOqCvp/QRBbMosyl5xA0mhBOVo3SJ6LXaz\n 41ZOjdeIAv/bTGI0FI1DVumv5gz8g++FqNUTgSn7BgSwON00bHQb7kmLmwSYFioDW1fw\n hJuCI+2eLU0tD8t1rKUgevY1+yFV7vgRJrNuY5o8UPCeWL0JVOA0rT06NL1agV32VqFB\n S/Gg==","X-Gm-Message-State":"AOJu0YyKW/Y70wtiHSrizUj3d5aLLNyVNNHT4cyMIIdUPKCOQ05Ouis1\n Z/JFQIDMv8r7m1DiIk4tlVKHiqx7MBycugsUT8P7rnOQRE4LFx51YYiC7fcj/YtB5e19URs1NJa\n CdSKa3vOTKb/cL3SZEhR1CsTuvptDwOPpqjg1BD70tJKVy/mKlrv2KmV/OwGh4O2BFw==","X-Gm-Gg":"AeBDievw2L+u0kU0MkqSkMO8YtXoVU1DmJ5M37SWKX3Y+wKEsR4WFJFfbp7dv2hD9wB\n ewEVKOKxghq227ATeBjG/hqBx6EwEqoXFPb4hafjoT0fHxLVN6FtDhqD9ZgzIDW3vbZzHGRnUVt\n dkT+f+oFQ2rU6+9MqP28Nhi7rWndV2U8S3v0uBktjiomfbK+o3MLQcsVVygFMmWnEQ2cODwX2ac\n 8T/I9l7uJ4Y8l8Hpcy9Z4MzcHWTPoTqQuS/Pa44Hvn0fghJ53zzQb75phn7U/n0nc4IJlt4000S\n J1XrKBhKDxZhfPtazFq0Wy0opU7Ai+vS7B1WlGXtsPCTBkGIaLw8qUi7AQYs1XUsmj19CvL2BEy\n 0tPX76X9iv8hPIPGACvQ16FTprp4OqfLEgEtrDg817qXEJBHNoOJSqEU8IybWdy4GVw9L5g==","X-Received":["by 2002:a05:7022:220b:b0:11e:3e9:3e92 with SMTP id\n a92af1059eb24-12bf08ba9f5mr9309261c88.23.1775622112817;\n Tue, 07 Apr 2026 21:21:52 -0700 (PDT)","by 2002:a05:7022:220b:b0:11e:3e9:3e92 with SMTP id\n a92af1059eb24-12bf08ba9f5mr9309248c88.23.1775622112205;\n Tue, 07 Apr 2026 21:21:52 -0700 (PDT)"],"From":"Brian Cain <brian.cain@oss.qualcomm.com>","To":"qemu-devel@nongnu.org","Cc":"brian.cain@oss.qualcomm.com, philmd@linaro.org, ltaylorsimpson@gmail.com,\n matheus.bernardino@oss.qualcomm.com, marco.liebel@oss.qualcomm.com,\n quic_mburton@quicinc.com, sid.manning@oss.qualcomm.com, ale@rev.ng,\n anjo@rev.ng","Subject":"[PATCH v4 1/9] hw/hexagon: Add globalreg model","Date":"Tue,  7 Apr 2026 21:21:40 -0700","Message-Id":"<20260408042149.1902796-2-brian.cain@oss.qualcomm.com>","X-Mailer":"git-send-email 2.34.1","In-Reply-To":"<20260408042149.1902796-1-brian.cain@oss.qualcomm.com>","References":"<20260408042149.1902796-1-brian.cain@oss.qualcomm.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","X-Proofpoint-Spam-Details-Enc":"AW1haW4tMjYwNDA4MDAzNiBTYWx0ZWRfX/gjSg6/pyc1Y\n bSM604X+WFQEJg1pJvbfplw8vfEXkKLzGKU3H+ev48U6WjXvudO2CxYvSd9F1/EgKLSGGJhBN/7\n H8FmtlEdvSynauZ9sB1WcPNvMcpwSCEAHm2txIn8CT8q1mqRfpjdymBoPCfbRAgfEZqxYEe0sxx\n yf94651C4hi/DkJhuwCw1lG7R968RDOdXmYb3dRfSU0Q2a+p/F3dIjFDkDlr3GU1IDTZOjFIhp6\n ufhhJPNJMtppuUWhLF0qPKneouBIJhKGj+RvT479KHUouZEypRGui5bueoAKFuwEIpxNMejXuLh\n n9K5LR3XxkIAMese8qMhSEa/g6eYwj5Ch3Iv+XU/O1GswjQs6A505fSHYbDzgSmjq3sx25+kSgA\n AOVGyWYVU7u8B7mlzYzwUgQTyKrIEbdfyx3PIcuSF0cBXQkC5+OyTs/IoAzAssdgkXKssMuXJGF\n Y9cJbfDfDCjJB9nA4RA==","X-Proofpoint-GUID":"kS3jqrbuIebPWIbj1pMDGZ8n3_W5xcDQ","X-Proofpoint-ORIG-GUID":"kS3jqrbuIebPWIbj1pMDGZ8n3_W5xcDQ","X-Authority-Analysis":"v=2.4 cv=K4AS2SWI c=1 sm=1 tr=0 ts=69d5d7e2 cx=c_pps\n a=SvEPeNj+VMjHSW//kvnxuw==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17\n a=IkcTkHD0fZMA:10 a=A5OVakUREuEA:10 a=s4-Qcg_JpJYA:10\n a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22\n a=EUspDBNiAAAA:8 a=issYwmIsIXpfOU_0AR4A:9 a=QEXdDO2ut3YA:10\n a=Kq8ClHjjuc5pcCNDwlU0:22","X-Proofpoint-Virus-Version":"vendor=baseguard\n engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49\n definitions=2026-04-08_02,2026-04-07_05,2025-10-01_01","X-Proofpoint-Spam-Details":"rule=outbound_notspam policy=outbound score=0\n priorityscore=1501 impostorscore=0 lowpriorityscore=0 clxscore=1015\n phishscore=0 malwarescore=0 spamscore=0 bulkscore=0 adultscore=0\n suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc=\n route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2604010000\n definitions=main-2604080036","Received-SPF":"pass client-ip=205.220.180.131;\n 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,\n DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001,\n RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, SPF_HELO_NONE=0.001,\n 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 <qemu-devel.nongnu.org>","List-Unsubscribe":"<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>","List-Archive":"<https://lists.nongnu.org/archive/html/qemu-devel>","List-Post":"<mailto:qemu-devel@nongnu.org>","List-Help":"<mailto:qemu-devel-request@nongnu.org?subject=help>","List-Subscribe":"<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>","Errors-To":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org","Sender":"qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"},"content":"Some of the system registers are shared among all threads\nin the core.  This object contains the representation and\ninterface to the system registers.\n\nSigned-off-by: Brian Cain <brian.cain@oss.qualcomm.com>\n---\n include/hw/hexagon/hexagon_globalreg.h |  56 ++++++\n hw/hexagon/hexagon_globalreg.c         | 245 +++++++++++++++++++++++++\n 2 files changed, 301 insertions(+)\n create mode 100644 include/hw/hexagon/hexagon_globalreg.h\n create mode 100644 hw/hexagon/hexagon_globalreg.c","diff":"diff --git a/include/hw/hexagon/hexagon_globalreg.h b/include/hw/hexagon/hexagon_globalreg.h\nnew file mode 100644\nindex 00000000000..c9e72f30b0a\n--- /dev/null\n+++ b/include/hw/hexagon/hexagon_globalreg.h\n@@ -0,0 +1,56 @@\n+/*\n+ * Hexagon Global Registers QOM Object\n+ *\n+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.\n+ * SPDX-License-Identifier: GPL-2.0-or-later\n+ */\n+\n+#ifndef HEXAGON_GLOBALREG_H\n+#define HEXAGON_GLOBALREG_H\n+\n+#include \"hw/core/qdev.h\"\n+#include \"hw/core/sysbus.h\"\n+#include \"qom/object.h\"\n+#include \"target/hexagon/cpu.h\"\n+\n+#define TYPE_HEXAGON_GLOBALREG \"hexagon-globalreg\"\n+OBJECT_DECLARE_SIMPLE_TYPE(HexagonGlobalRegState, HEXAGON_GLOBALREG)\n+\n+struct HexagonGlobalRegState {\n+    SysBusDevice parent_obj;\n+\n+    /* Array of system registers */\n+    uint32_t regs[NUM_SREGS];\n+\n+    /* Global performance cycle counter base */\n+    uint64_t g_pcycle_base;\n+\n+    /* Properties for global register reset values */\n+    uint32_t boot_evb;           /* Boot Exception Vector Base (HEX_SREG_EVB) */\n+    uint64_t config_table_addr;  /* Configuration table base */\n+    uint32_t dsp_rev;           /* DSP revision register (HEX_SREG_REV) */\n+\n+    /* ISDB properties */\n+    bool isdben_etm_enable;     /* ISDB ETM enable bit */\n+    bool isdben_dfd_enable;     /* ISDB DFD enable bit */\n+    bool isdben_trusted;        /* ISDB trusted mode bit */\n+    bool isdben_secure;         /* ISDB secure mode bit */\n+};\n+\n+/* Public interface functions */\n+uint32_t hexagon_globalreg_read(HexagonGlobalRegState *s, uint32_t reg,\n+                                uint32_t htid);\n+void hexagon_globalreg_write(HexagonGlobalRegState *s, uint32_t reg,\n+                             uint32_t value, uint32_t htid);\n+uint32_t hexagon_globalreg_masked_value(HexagonGlobalRegState *s, uint32_t reg,\n+                                        uint32_t value);\n+void hexagon_globalreg_write_masked(HexagonGlobalRegState *s, uint32_t reg,\n+                                    uint32_t value);\n+void hexagon_globalreg_reset(HexagonGlobalRegState *s);\n+\n+/* Global performance cycle counter access */\n+uint64_t hexagon_globalreg_get_pcycle_base(HexagonGlobalRegState *s);\n+void hexagon_globalreg_set_pcycle_base(HexagonGlobalRegState *s,\n+                                       uint64_t value);\n+\n+#endif /* HEXAGON_GLOBALREG_H */\ndiff --git a/hw/hexagon/hexagon_globalreg.c b/hw/hexagon/hexagon_globalreg.c\nnew file mode 100644\nindex 00000000000..634d3b169fd\n--- /dev/null\n+++ b/hw/hexagon/hexagon_globalreg.c\n@@ -0,0 +1,245 @@\n+/*\n+ * Hexagon Global Registers\n+ *\n+ * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.\n+ * SPDX-License-Identifier: GPL-2.0-or-later\n+ */\n+\n+#include \"qemu/osdep.h\"\n+#include \"hw/hexagon/hexagon.h\"\n+#include \"hw/hexagon/hexagon_globalreg.h\"\n+#include \"hw/core/qdev-properties.h\"\n+#include \"hw/core/sysbus.h\"\n+#include \"hw/core/resettable.h\"\n+#include \"migration/vmstate.h\"\n+#include \"qom/object.h\"\n+#include \"target/hexagon/cpu.h\"\n+#include \"target/hexagon/hex_regs.h\"\n+#include \"qemu/log.h\"\n+#include \"qapi/error.h\"\n+\n+#define IMMUTABLE (~0)\n+#define INVALID_REG_VAL 0xdeadbeef\n+\n+/* Global system register mutability masks */\n+static const uint32_t global_sreg_immut_masks[NUM_SREGS] = {\n+    [HEX_SREG_EVB] = 0x000000ff,\n+    [HEX_SREG_MODECTL] = IMMUTABLE,\n+    [HEX_SREG_SYSCFG] = 0x80001c00,\n+    [HEX_SREG_IPENDAD] = IMMUTABLE,\n+    [HEX_SREG_VID] = 0xfc00fc00,\n+    [HEX_SREG_VID1] = 0xfc00fc00,\n+    [HEX_SREG_BESTWAIT] = 0xfffffe00,\n+    [HEX_SREG_IAHL] = 0x00000000,\n+    [HEX_SREG_SCHEDCFG] = 0xfffffee0,\n+    [HEX_SREG_CFGBASE] = IMMUTABLE,\n+    [HEX_SREG_DIAG] = 0x00000000,\n+    [HEX_SREG_REV] = IMMUTABLE,\n+    [HEX_SREG_ISDBST] = IMMUTABLE,\n+    [HEX_SREG_ISDBCFG0] = 0xe0000000,\n+    [HEX_SREG_BRKPTPC0] = 0x00000003,\n+    [HEX_SREG_BRKPTCFG0] = 0xfc007000,\n+    [HEX_SREG_BRKPTPC1] = 0x00000003,\n+    [HEX_SREG_BRKPTCFG1] = 0xfc007000,\n+    [HEX_SREG_ISDBMBXIN] = IMMUTABLE,\n+    [HEX_SREG_ISDBMBXOUT] = 0x00000000,\n+    [HEX_SREG_ISDBEN] = 0xfffffffe,\n+    [HEX_SREG_TIMERLO] = IMMUTABLE,\n+    [HEX_SREG_TIMERHI] = IMMUTABLE,\n+};\n+\n+static void hexagon_globalreg_init(Object *obj)\n+{\n+    HexagonGlobalRegState *s = HEXAGON_GLOBALREG(obj);\n+\n+    memset(s->regs, 0, sizeof(uint32_t) * NUM_SREGS);\n+}\n+\n+static inline uint32_t apply_write_mask(uint32_t new_val, uint32_t cur_val,\n+                                        uint32_t reg_mask)\n+{\n+    if (reg_mask) {\n+        return (new_val & ~reg_mask) | (cur_val & reg_mask);\n+    }\n+    return new_val;\n+}\n+\n+uint32_t hexagon_globalreg_read(HexagonGlobalRegState *s, uint32_t reg,\n+                                uint32_t htid)\n+{\n+    uint32_t value;\n+\n+    g_assert(reg < NUM_SREGS);\n+    g_assert(reg >= HEX_SREG_GLB_START);\n+    g_assert(s);\n+\n+    value = s->regs[reg];\n+\n+    return value;\n+}\n+\n+void hexagon_globalreg_write(HexagonGlobalRegState *s, uint32_t reg,\n+                             uint32_t value, uint32_t htid)\n+{\n+    g_assert(s);\n+    g_assert(reg < NUM_SREGS);\n+    g_assert(reg >= HEX_SREG_GLB_START);\n+    s->regs[reg] = value;\n+}\n+\n+uint32_t hexagon_globalreg_masked_value(HexagonGlobalRegState *s, uint32_t reg,\n+                                        uint32_t value)\n+{\n+    uint32_t reg_mask;\n+\n+    g_assert(s);\n+    g_assert(reg < NUM_SREGS);\n+    g_assert(reg >= HEX_SREG_GLB_START);\n+    reg_mask = global_sreg_immut_masks[reg];\n+    return reg_mask == IMMUTABLE ?\n+            s->regs[reg] :\n+            apply_write_mask(value, s->regs[reg], reg_mask);\n+}\n+\n+void hexagon_globalreg_write_masked(HexagonGlobalRegState *s, uint32_t reg,\n+                                    uint32_t value)\n+{\n+    g_assert(s);\n+    s->regs[reg] = hexagon_globalreg_masked_value(s, reg, value);\n+}\n+\n+uint64_t hexagon_globalreg_get_pcycle_base(HexagonGlobalRegState *s)\n+{\n+    g_assert(s);\n+    return s->g_pcycle_base;\n+}\n+\n+void hexagon_globalreg_set_pcycle_base(HexagonGlobalRegState *s,\n+                                       uint64_t value)\n+{\n+    g_assert(s);\n+    s->g_pcycle_base = value;\n+}\n+\n+static void do_hexagon_globalreg_reset(HexagonGlobalRegState *s)\n+{\n+    uint32_t isdben_val = 0;\n+\n+    g_assert(s);\n+    memset(s->regs, 0, sizeof(uint32_t) * NUM_SREGS);\n+\n+    s->g_pcycle_base = 0;\n+\n+    s->regs[HEX_SREG_EVB] = s->boot_evb;\n+    s->regs[HEX_SREG_CFGBASE] = HEXAGON_CFG_ADDR_BASE(s->config_table_addr);\n+    s->regs[HEX_SREG_REV] = s->dsp_rev;\n+\n+    if (s->isdben_etm_enable) {\n+        isdben_val |= (1 << 0);  /* ETM enable bit */\n+    }\n+    if (s->isdben_dfd_enable) {\n+        isdben_val |= (1 << 1);  /* DFD enable bit */\n+    }\n+    if (s->isdben_trusted) {\n+        isdben_val |= (1 << 2);  /* Trusted bit */\n+    }\n+    if (s->isdben_secure) {\n+        isdben_val |= (1 << 3);  /* Secure bit */\n+    }\n+    s->regs[HEX_SREG_ISDBEN] = isdben_val;\n+    s->regs[HEX_SREG_MODECTL] = 0x1;\n+\n+    /*\n+     * These register indices are placeholders in these arrays\n+     * and their actual values are synthesized from state elsewhere.\n+     * We can initialize these with invalid values so that if we\n+     * mistakenly generate reads, they will look obviously wrong.\n+     */\n+    s->regs[HEX_SREG_PCYCLELO] = INVALID_REG_VAL;\n+    s->regs[HEX_SREG_PCYCLEHI] = INVALID_REG_VAL;\n+    s->regs[HEX_SREG_TIMERLO] = INVALID_REG_VAL;\n+    s->regs[HEX_SREG_TIMERHI] = INVALID_REG_VAL;\n+    s->regs[HEX_SREG_PMUCNT0] = INVALID_REG_VAL;\n+    s->regs[HEX_SREG_PMUCNT1] = INVALID_REG_VAL;\n+    s->regs[HEX_SREG_PMUCNT2] = INVALID_REG_VAL;\n+    s->regs[HEX_SREG_PMUCNT3] = INVALID_REG_VAL;\n+    s->regs[HEX_SREG_PMUCNT4] = INVALID_REG_VAL;\n+    s->regs[HEX_SREG_PMUCNT5] = INVALID_REG_VAL;\n+    s->regs[HEX_SREG_PMUCNT6] = INVALID_REG_VAL;\n+    s->regs[HEX_SREG_PMUCNT7] = INVALID_REG_VAL;\n+}\n+\n+static void hexagon_globalreg_realize(DeviceState *dev, Error **errp)\n+{\n+}\n+\n+void hexagon_globalreg_reset(HexagonGlobalRegState *s)\n+{\n+    do_hexagon_globalreg_reset(s);\n+}\n+\n+static void hexagon_globalreg_reset_hold(Object *obj, ResetType type)\n+{\n+    HexagonGlobalRegState *s = HEXAGON_GLOBALREG(obj);\n+    do_hexagon_globalreg_reset(s);\n+}\n+\n+static const VMStateDescription vmstate_hexagon_globalreg = {\n+    .name = \"hexagon_globalreg\",\n+    .version_id = 1,\n+    .minimum_version_id = 1,\n+    .fields = (const VMStateField[]){\n+        VMSTATE_UINT32_ARRAY(regs, HexagonGlobalRegState, NUM_SREGS),\n+        VMSTATE_UINT64(g_pcycle_base, HexagonGlobalRegState),\n+        VMSTATE_UINT32(boot_evb, HexagonGlobalRegState),\n+        VMSTATE_UINT64(config_table_addr, HexagonGlobalRegState),\n+        VMSTATE_UINT32(dsp_rev, HexagonGlobalRegState),\n+        VMSTATE_BOOL(isdben_etm_enable, HexagonGlobalRegState),\n+        VMSTATE_BOOL(isdben_dfd_enable, HexagonGlobalRegState),\n+        VMSTATE_BOOL(isdben_trusted, HexagonGlobalRegState),\n+        VMSTATE_BOOL(isdben_secure, HexagonGlobalRegState),\n+        VMSTATE_END_OF_LIST()\n+    }\n+};\n+\n+static const Property hexagon_globalreg_properties[] = {\n+    DEFINE_PROP_UINT32(\"boot-evb\", HexagonGlobalRegState, boot_evb, 0x0),\n+    DEFINE_PROP_UINT64(\"config-table-addr\", HexagonGlobalRegState,\n+                       config_table_addr, 0xffffffffULL),\n+    DEFINE_PROP_UINT32(\"dsp-rev\", HexagonGlobalRegState, dsp_rev, 0),\n+    DEFINE_PROP_BOOL(\"isdben-etm-enable\", HexagonGlobalRegState,\n+                     isdben_etm_enable, false),\n+    DEFINE_PROP_BOOL(\"isdben-dfd-enable\", HexagonGlobalRegState,\n+                     isdben_dfd_enable, false),\n+    DEFINE_PROP_BOOL(\"isdben-trusted\", HexagonGlobalRegState,\n+                     isdben_trusted, false),\n+    DEFINE_PROP_BOOL(\"isdben-secure\", HexagonGlobalRegState,\n+                     isdben_secure, false),\n+};\n+\n+static void hexagon_globalreg_class_init(ObjectClass *klass, const void *data)\n+{\n+    DeviceClass *dc = DEVICE_CLASS(klass);\n+    ResettableClass *rc = RESETTABLE_CLASS(klass);\n+\n+    dc->realize = hexagon_globalreg_realize;\n+    rc->phases.hold = hexagon_globalreg_reset_hold;\n+    dc->vmsd = &vmstate_hexagon_globalreg;\n+    dc->user_creatable = false;\n+    device_class_set_props(dc, hexagon_globalreg_properties);\n+}\n+\n+static const TypeInfo hexagon_globalreg_info = {\n+    .name = TYPE_HEXAGON_GLOBALREG,\n+    .parent = TYPE_SYS_BUS_DEVICE,\n+    .instance_size = sizeof(HexagonGlobalRegState),\n+    .instance_init = hexagon_globalreg_init,\n+    .class_init = hexagon_globalreg_class_init,\n+};\n+\n+static void hexagon_globalreg_register_types(void)\n+{\n+    type_register_static(&hexagon_globalreg_info);\n+}\n+\n+type_init(hexagon_globalreg_register_types)\n","prefixes":["v4","1/9"]}