From nobody Sun Jul 26 13:27:25 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=1781156454; cv=none; d=zohomail.com; s=zohoarc; b=QyO43Zm91eY/9slaQGESrzMyYdjdM+M/lLd7+ghPup9vtOgcaTPcZIC9Ir4aRSYxj92pIfvTvuThw12BZ6euiBNeZYAEPwrhwGkxCREszBC66qSFbWedMkRZBfKiNBDaGAa8ib6StkBOkCiIPEhEgFzg/FFohl8oADXXY0FYhbo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1781156454; 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=IR53Mjz5etxJrjMQaZOHC4cu/qgzTKOGEQyPVYlQwQ0=; b=Dh8Uukp6tIyA7wLPdhmv/+7qrDII44qQ7l12lnpqDiv37bMSPFO4r9r2OwyA2JI9V2+10cMoQgTgU19GaJOgdBJlvsDHsA6CrkuSVztEtmYEyfO3LxnqsobwtnhVh9s/6Ip5fV2Sgqha9Pr3BG0TQANW67QDvI7qalb95TgAgH8= 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 1781156454042568.9632153896539; Wed, 10 Jun 2026 22:40:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wXY9E-0000Av-IQ; Thu, 11 Jun 2026 01:40:13 -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 1wXY8J-0007t7-4L for qemu-devel@nongnu.org; Thu, 11 Jun 2026 01:39:18 -0400 Received: from mx0a-0031df01.pphosted.com ([205.220.168.131]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wXY8G-0004tA-T9 for qemu-devel@nongnu.org; Thu, 11 Jun 2026 01:39:14 -0400 Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 65B5GDNd3724520 for ; Thu, 11 Jun 2026 05:39:10 GMT Received: from mail-dy1-f199.google.com (mail-dy1-f199.google.com [74.125.82.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4eqe6v9rhu-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 11 Jun 2026 05:39:10 +0000 (GMT) Received: by mail-dy1-f199.google.com with SMTP id 5a478bee46e88-304df51ff3eso8607391eec.0 for ; Wed, 10 Jun 2026 22:39:10 -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.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Jun 2026 22:39:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:content-type:date:from :in-reply-to:message-id:mime-version:references:subject:to; s= qcppdkim1; bh=IR53Mjz5etxJrjMQaZOHC4cu/qgzTKOGEQyPVYlQwQ0=; b=He 3oxR16k8oYGaNje5grQvdh/vCMwcRuSL4izHphGtNc/4sUgFog/qwCC03A7v+lgX 7ZV0xn/emGiSXokTND/RVa6xywK70XzC3U0S0uik4FPSGLhJUhFLx9PwcrV6jHQq YT1DPj/TDHCwdTjj6sMcxWFjGsSs4ogp40/xZeo2NWA6YBytDeda4jXfFLwey0lc WPQkWqiNP6+w98su4edUyJy1siHgVAYqkDstkCzKpapOAOSCVMsewVluXz1nMZvF hJCjXKVaX2KvyaI86wm1Sy6YxMtSLJzxcWDZvZTSEmyVhZ8KhHHg0N/AcfPpfYLT naxLByvzHhcmirt2r+nw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1781156350; x=1781761150; 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=IR53Mjz5etxJrjMQaZOHC4cu/qgzTKOGEQyPVYlQwQ0=; b=Oqx5Hg6KAyDY4IHTphubLhf2MaVmg4ifZh/XP2SP2yHDNXC7a+ybA1zZJWibrg4CiH IbCIFdeTNgmTFBSqwqhxtPQsBt+Z79Ac7HeL8Jvj/41FAjuRTYFfUy3x/79VwGuIZjGA FUn6bdT5IYY6b0Uv/WW3HsmJ6b1NRQPqsNb62DJ90sbAukIrBudzbBJetCgfXH3bdDCt GBIUCYgywe0HVO0lgjo+Q8tWq319tjnX2T5zAwtMnhJC5k6WH1EC7YOVhaWXN2oeV+Uf nVaHWtN+3vK0HVQUD7Aj6AX1jDyLCUt0dwGMtU1XKsKZ2WY3xfv4IG3YgEZndlpgCi9h hNxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781156350; x=1781761150; 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=IR53Mjz5etxJrjMQaZOHC4cu/qgzTKOGEQyPVYlQwQ0=; b=QL+f6YWL8hrleyYo/cQ0GYvIwYvObw5NNq45FWzN6KXymKiXiC5jPhJAkTqBPCWyb3 FflRZ7C17p1ab6Kah51ei0l9zSX1pf9WokRbBzr/uOIsmh5HpTsSGs5apnCOKLxOk6o5 SpxsnsttKZ+MR6HcMjZbclWr96GPmjNEN4DlJsTPPetgiF61xEmQ9yNOqgPPfbrfpev3 z5rL9okbQjlr6cMV65mWBSj3rBQtSnLFmJbVizlNqxY7PqkrlKWgskKSKGAUtl+W+c3M f3oet22A1pIUhD8o1ZlcTZgtq2qoNlKwDpuGz8UsWIZlWPMuhsIPkvYMSBdQoqKwkCjn ZWgQ== X-Gm-Message-State: AOJu0YyeoHYKwt2GkllYBcR+7gV3JJM6gjTKOPEzaXJSCCyUZLu9fpki Sjkjbs1aNRHGCXcSitIFC9AVxs6xgBKdcp2aXmgcH+vwSO4uqdSvVl4fBIn01PuJyDBbFSkJzgZ Zi6vk+xjZIP3Wd613xujcN3aIAU2cM1146GFDbAD1aIgNZawCQVxIAdhhgbbD5SQLvA== X-Gm-Gg: Acq92OHsTV2xq1V51yF9VlxbWDBK87nL4sWAqe1Wnvu2whTsZgRhGwZgZgXT1h1kGd0 F5oFpUNU4ojyFraiTecmsC3U9A4BtSqLbVaddVZisty0rW9wGWSMTVy5071q8IaHo1vN0qfIeTN 5eKarndtiy0DS8/c0UdGecu+pfnluXrEnr+1ssjIu6rzLhSYkvSD0Aj0rSA4TMUED27881LrNyu yKj/XCQrASfATJoaKra5HWy5hYfZhhkEABPFGpqEoGOxqSHdhDFA6fNpeidYUIbUFfI7uOeDxrQ 8b+F+yG7GU+TMxxA9Z60SI00YE6R8S7p5YkeiBiY+Iv+S1VHiorql+xJvnt7Qtaa/pFzCeinFua NFl7QXEzLlQRAWLJJEPFJ7Z/Of17FjEePh207gBsY68h37/q/wrMG5LbRygK319IvdVGCC4GrYD n4d89v X-Received: by 2002:a05:7300:f187:b0:304:2e00:5fb5 with SMTP id 5a478bee46e88-30804633f36mr963089eec.3.1781156349493; Wed, 10 Jun 2026 22:39:09 -0700 (PDT) X-Received: by 2002:a05:7300:f187:b0:304:2e00:5fb5 with SMTP id 5a478bee46e88-30804633f36mr963059eec.3.1781156348873; Wed, 10 Jun 2026 22:39:08 -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, Sid Manning , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v7] hw/hexagon: Add globalreg model Date: Wed, 10 Jun 2026 22:38:54 -0700 Message-Id: <20260611053902.3927367-2-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-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: C7HhE9dcEFXawKen6qHDzdeUhtMyNuce X-Proofpoint-Spam-Info: AW1haW4tMjYwNjExMDA1MyBTYWx0ZWRfX7h6ZLipdA+OG 7iriGspi3NtrHu7G5ZB3ZdbjlBA5yEimmXW+IqhlHu8cL5lCpd5nUQMsW75KOtk9Pn51zrZhB6W pghLSzGOpI9Yw38x+CVmvv4U79lanm0= X-Proofpoint-GUID: C7HhE9dcEFXawKen6qHDzdeUhtMyNuce X-Authority-Analysis: v=2.4 cv=UsRT8ewB c=1 sm=1 tr=0 ts=6a2a49fe cx=c_pps a=cFYjgdjTJScbgFmBucgdfQ==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=FelO9ux0wxsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=EUspDBNiAAAA:8 a=KKAkSRfTAAAA:8 a=ykHTVMA0J60qDn7DFlgA:9 a=QEXdDO2ut3YA:10 a=scEy_gLbYbu1JhEsrz4S:22 a=cvBusfyB2V15izCimMoJ:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjExMDA1MyBTYWx0ZWRfX40Gw8+ANBz0K f18bixs+lFuidl6+1MqCnEMEVzR9qCyxQUqCzbhRQaaJn8mrnVlodn5ROH2DxOuE4nzV6uhmYt6 4r1anDGlNucreGBKV+cwrLtzWi4CrTOhxYVJRMK2+IQ2P/lQ5BWHOJ7lzgnPe1B6xs8LnUmaSMN ZaJXlpZL3rw51xzjYRx6eYwQkx18nRoVDWxiNPsLcmralxBH5fKReW52zR1C4WIolortELkZiic ghF54LvPZPlXX+ANxyOYbxNGAyNqmWaumh+HRwLYbCO07JpigSM7wR0xOD86SkPcapnipbh1O7V 0My8BuNJIFkZk1kQhekr9BKyW9Rl8blFlBcW1TDL8svXG6Xgl4RSIudehX1QX3/i5eWRtahhfae C2ocAH5jL0enaSHafCKe7YvT1v9hiRNq66ZXAgY76cNefft20ffN40cevbJVk8F4B86HDEiTX0P 5XokVNzzPJCOA/dLmrw== 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 priorityscore=1501 phishscore=0 clxscore=1015 lowpriorityscore=0 spamscore=0 adultscore=0 bulkscore=0 suspectscore=0 impostorscore=0 malwarescore=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.168.131; envelope-from=brian.cain@oss.qualcomm.com; helo=mx0a-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, RCVD_IN_MSPIKE_H2=0.001, 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: 1781156456035158500 Content-Type: text/plain; charset="utf-8" Some of the system registers are shared among all threads in the core. This object contains the representation and interface to the system registers. Reviewed-by: Sid Manning Acked-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Brian Cain --- include/hw/hexagon/hexagon_globalreg.h | 55 ++++++ hw/hexagon/hexagon_globalreg.c | 243 +++++++++++++++++++++++++ 2 files changed, 298 insertions(+) create mode 100644 include/hw/hexagon/hexagon_globalreg.h create mode 100644 hw/hexagon/hexagon_globalreg.c diff --git a/include/hw/hexagon/hexagon_globalreg.h b/include/hw/hexagon/he= xagon_globalreg.h new file mode 100644 index 00000000000..950099808fd --- /dev/null +++ b/include/hw/hexagon/hexagon_globalreg.h @@ -0,0 +1,55 @@ +/* + * Hexagon Global Registers QOM Object + * + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#ifndef HEXAGON_GLOBALREG_H +#define HEXAGON_GLOBALREG_H + +#include "hw/core/qdev.h" +#include "hw/core/sysbus.h" +#include "qom/object.h" +#include "target/hexagon/cpu.h" + +#define TYPE_HEXAGON_GLOBALREG "hexagon-globalreg" +OBJECT_DECLARE_SIMPLE_TYPE(HexagonGlobalRegState, HEXAGON_GLOBALREG) + +struct HexagonGlobalRegState { + SysBusDevice parent_obj; + + /* Array of system registers */ + uint32_t regs[NUM_SREGS]; + + /* Global performance cycle counter base */ + uint64_t g_pcycle_base; + + /* Properties for global register reset values */ + uint32_t boot_evb; /* Boot Exception Vector Base (HEX_SREG_E= VB) */ + uint64_t config_table_addr; /* Configuration table base */ + uint32_t dsp_rev; /* DSP revision register (HEX_SREG_REV) */ + + /* ISDB properties */ + bool isdben_etm_enable; /* ISDB ETM enable bit */ + bool isdben_dfd_enable; /* ISDB DFD enable bit */ + bool isdben_trusted; /* ISDB trusted mode bit */ + bool isdben_secure; /* ISDB secure mode bit */ +}; + +/* Public interface functions */ +uint32_t hexagon_globalreg_read(HexagonGlobalRegState *s, uint32_t reg, + uint32_t htid); +void hexagon_globalreg_write(HexagonGlobalRegState *s, uint32_t reg, + uint32_t value, uint32_t htid); +uint32_t hexagon_globalreg_masked_value(HexagonGlobalRegState *s, uint32_t= reg, + uint32_t value); +void hexagon_globalreg_write_masked(HexagonGlobalRegState *s, uint32_t reg, + uint32_t value); + +/* Global performance cycle counter access */ +uint64_t hexagon_globalreg_get_pcycle_base(HexagonGlobalRegState *s); +void hexagon_globalreg_set_pcycle_base(HexagonGlobalRegState *s, + uint64_t value); + +#endif /* HEXAGON_GLOBALREG_H */ diff --git a/hw/hexagon/hexagon_globalreg.c b/hw/hexagon/hexagon_globalreg.c new file mode 100644 index 00000000000..28cb5a4158d --- /dev/null +++ b/hw/hexagon/hexagon_globalreg.c @@ -0,0 +1,243 @@ +/* + * Hexagon Global Registers + * + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/hexagon/hexagon.h" +#include "hw/hexagon/hexagon_globalreg.h" +#include "hw/core/qdev-properties.h" +#include "hw/core/sysbus.h" +#include "hw/core/resettable.h" +#include "migration/vmstate.h" +#include "qom/object.h" +#include "target/hexagon/cpu.h" +#include "target/hexagon/hex_regs.h" +#include "qemu/log.h" +#include "qapi/error.h" + +#define IMMUTABLE (~0) +#define INVALID_REG_VAL 0xdeadbeef + +/* Global system register mutability masks */ +static const uint32_t global_sreg_immut_masks[NUM_SREGS] =3D { + [HEX_SREG_EVB] =3D 0x000000ff, + [HEX_SREG_MODECTL] =3D IMMUTABLE, + [HEX_SREG_SYSCFG] =3D 0x80001c00, + [HEX_SREG_IPENDAD] =3D IMMUTABLE, + [HEX_SREG_VID] =3D 0xfc00fc00, + [HEX_SREG_VID1] =3D 0xfc00fc00, + [HEX_SREG_BESTWAIT] =3D 0xfffffe00, + [HEX_SREG_IAHL] =3D 0x00000000, + [HEX_SREG_SCHEDCFG] =3D 0xfffffee0, + [HEX_SREG_CFGBASE] =3D IMMUTABLE, + [HEX_SREG_DIAG] =3D 0x00000000, + [HEX_SREG_REV] =3D IMMUTABLE, + [HEX_SREG_ISDBST] =3D IMMUTABLE, + [HEX_SREG_ISDBCFG0] =3D 0xe0000000, + [HEX_SREG_BRKPTPC0] =3D 0x00000003, + [HEX_SREG_BRKPTCFG0] =3D 0xfc007000, + [HEX_SREG_BRKPTPC1] =3D 0x00000003, + [HEX_SREG_BRKPTCFG1] =3D 0xfc007000, + [HEX_SREG_ISDBMBXIN] =3D IMMUTABLE, + [HEX_SREG_ISDBMBXOUT] =3D 0x00000000, + [HEX_SREG_ISDBEN] =3D 0xfffffffe, + [HEX_SREG_TIMERLO] =3D IMMUTABLE, + [HEX_SREG_TIMERHI] =3D IMMUTABLE, +}; + +static void hexagon_globalreg_init(Object *obj) +{ + HexagonGlobalRegState *s =3D HEXAGON_GLOBALREG(obj); + + memset(s->regs, 0, sizeof(s->regs)); +} + +static inline uint32_t apply_write_mask(uint32_t new_val, uint32_t cur_val, + uint32_t reg_mask) +{ + if (reg_mask) { + return (new_val & ~reg_mask) | (cur_val & reg_mask); + } + return new_val; +} + +uint32_t hexagon_globalreg_read(HexagonGlobalRegState *s, uint32_t reg, + uint32_t htid) +{ + uint32_t value; + + if (!s) { + return 0; + } + g_assert(reg < NUM_SREGS); + g_assert(reg >=3D HEX_SREG_GLB_START); + + value =3D s->regs[reg]; + + return value; +} + +void hexagon_globalreg_write(HexagonGlobalRegState *s, uint32_t reg, + uint32_t value, uint32_t htid) +{ + if (!s) { + return; + } + g_assert(reg < NUM_SREGS); + g_assert(reg >=3D HEX_SREG_GLB_START); + s->regs[reg] =3D value; +} + +uint32_t hexagon_globalreg_masked_value(HexagonGlobalRegState *s, uint32_t= reg, + uint32_t value) +{ + uint32_t reg_mask; + + if (!s) { + return value; + } + g_assert(reg < NUM_SREGS); + g_assert(reg >=3D HEX_SREG_GLB_START); + reg_mask =3D global_sreg_immut_masks[reg]; + return reg_mask =3D=3D IMMUTABLE ? + s->regs[reg] : + apply_write_mask(value, s->regs[reg], reg_mask); +} + +void hexagon_globalreg_write_masked(HexagonGlobalRegState *s, uint32_t reg, + uint32_t value) +{ + if (!s) { + return; + } + s->regs[reg] =3D hexagon_globalreg_masked_value(s, reg, value); +} + +uint64_t hexagon_globalreg_get_pcycle_base(HexagonGlobalRegState *s) +{ + g_assert(s); + return s->g_pcycle_base; +} + +void hexagon_globalreg_set_pcycle_base(HexagonGlobalRegState *s, + uint64_t value) +{ + g_assert(s); + s->g_pcycle_base =3D value; +} + +static void do_hexagon_globalreg_reset(HexagonGlobalRegState *s) +{ + uint32_t isdben_val =3D 0; + + g_assert(s); + memset(s->regs, 0, sizeof(s->regs)); + + s->g_pcycle_base =3D 0; + + s->regs[HEX_SREG_EVB] =3D s->boot_evb; + s->regs[HEX_SREG_CFGBASE] =3D HEXAGON_CFG_ADDR_BASE(s->config_table_ad= dr); + s->regs[HEX_SREG_REV] =3D s->dsp_rev; + + if (s->isdben_etm_enable) { + isdben_val |=3D (1 << 0); /* ETM enable bit */ + } + if (s->isdben_dfd_enable) { + isdben_val |=3D (1 << 1); /* DFD enable bit */ + } + if (s->isdben_trusted) { + isdben_val |=3D (1 << 2); /* Trusted bit */ + } + if (s->isdben_secure) { + isdben_val |=3D (1 << 3); /* Secure bit */ + } + s->regs[HEX_SREG_ISDBEN] =3D isdben_val; + s->regs[HEX_SREG_MODECTL] =3D 0x1; + + /* + * These register indices are placeholders in these arrays + * and their actual values are synthesized from state elsewhere. + * We can initialize these with invalid values so that if we + * mistakenly generate reads, they will look obviously wrong. + */ + s->regs[HEX_SREG_PCYCLELO] =3D INVALID_REG_VAL; + s->regs[HEX_SREG_PCYCLEHI] =3D INVALID_REG_VAL; + s->regs[HEX_SREG_TIMERLO] =3D INVALID_REG_VAL; + s->regs[HEX_SREG_TIMERHI] =3D INVALID_REG_VAL; + s->regs[HEX_SREG_PMUCNT0] =3D INVALID_REG_VAL; + s->regs[HEX_SREG_PMUCNT1] =3D INVALID_REG_VAL; + s->regs[HEX_SREG_PMUCNT2] =3D INVALID_REG_VAL; + s->regs[HEX_SREG_PMUCNT3] =3D INVALID_REG_VAL; + s->regs[HEX_SREG_PMUCNT4] =3D INVALID_REG_VAL; + s->regs[HEX_SREG_PMUCNT5] =3D INVALID_REG_VAL; + s->regs[HEX_SREG_PMUCNT6] =3D INVALID_REG_VAL; + s->regs[HEX_SREG_PMUCNT7] =3D INVALID_REG_VAL; +} + +static void hexagon_globalreg_reset_hold(Object *obj, ResetType type) +{ + HexagonGlobalRegState *s =3D HEXAGON_GLOBALREG(obj); + do_hexagon_globalreg_reset(s); +} + +static const VMStateDescription vmstate_hexagon_globalreg =3D { + .name =3D "hexagon_globalreg", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (const VMStateField[]){ + VMSTATE_UINT32_ARRAY(regs, HexagonGlobalRegState, NUM_SREGS), + VMSTATE_UINT64(g_pcycle_base, HexagonGlobalRegState), + VMSTATE_UINT32(boot_evb, HexagonGlobalRegState), + VMSTATE_UINT64(config_table_addr, HexagonGlobalRegState), + VMSTATE_UINT32(dsp_rev, HexagonGlobalRegState), + VMSTATE_BOOL(isdben_etm_enable, HexagonGlobalRegState), + VMSTATE_BOOL(isdben_dfd_enable, HexagonGlobalRegState), + VMSTATE_BOOL(isdben_trusted, HexagonGlobalRegState), + VMSTATE_BOOL(isdben_secure, HexagonGlobalRegState), + VMSTATE_END_OF_LIST() + } +}; + +static const Property hexagon_globalreg_properties[] =3D { + DEFINE_PROP_UINT32("boot-evb", HexagonGlobalRegState, boot_evb, 0x0), + DEFINE_PROP_UINT64("config-table-addr", HexagonGlobalRegState, + config_table_addr, 0xffffffffULL), + DEFINE_PROP_UINT32("dsp-rev", HexagonGlobalRegState, dsp_rev, 0), + DEFINE_PROP_BOOL("isdben-etm-enable", HexagonGlobalRegState, + isdben_etm_enable, false), + DEFINE_PROP_BOOL("isdben-dfd-enable", HexagonGlobalRegState, + isdben_dfd_enable, false), + DEFINE_PROP_BOOL("isdben-trusted", HexagonGlobalRegState, + isdben_trusted, false), + DEFINE_PROP_BOOL("isdben-secure", HexagonGlobalRegState, + isdben_secure, false), +}; + +static void hexagon_globalreg_class_init(ObjectClass *klass, const void *d= ata) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); + + rc->phases.hold =3D hexagon_globalreg_reset_hold; + dc->vmsd =3D &vmstate_hexagon_globalreg; + dc->user_creatable =3D false; + device_class_set_props(dc, hexagon_globalreg_properties); +} + +static const TypeInfo hexagon_globalreg_info =3D { + .name =3D TYPE_HEXAGON_GLOBALREG, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(HexagonGlobalRegState), + .instance_init =3D hexagon_globalreg_init, + .class_init =3D hexagon_globalreg_class_init, +}; + +static void hexagon_globalreg_register_types(void) +{ + type_register_static(&hexagon_globalreg_info); +} + +type_init(hexagon_globalreg_register_types) --=20 2.34.1