From nobody Wed Sep 23 00:45:42 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=1784141968; cv=none; d=zohomail.com; s=zohoarc; b=TQdYeQgFhxACh9sDcK9ukQ954jQy6x1TpbFBfyRbUSRWHvIoEPZcJ7Zz+Ok750Vh1j9XLqfKly9/YRzuRVoBo8MwXPOhtJ9u2p1LuNbB5JuZPtVwPjdeQGCA2s3StSVp9mTv1mF8BhfN3ahgEwUN/3sV3jcNgfI/jA5/ZfIj2xU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1784141968; 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=g+lOAJm4dp+Q6b10nK/z1keGmZtXGgk1p0fj4OUJDTQ=; b=JHzhQnYX/MRYyl/NRdbbcftLuw3qItJFw/TOtSFcqJ8RJjDtC4i18Qq4i+dzMvk6GdHE447IvOkePvRWKZ+a2It1SdHCTmWsrSLrj7AW/yVmK3nuUBAmwNOgnRm+ozCW2ALYbyTbzt+ZskJuA2EnIB9KD+qPWGHhbUcm5Kuk3dQ= 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 178414196831130.475805495739564; Wed, 15 Jul 2026 11:59:28 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wk4nK-0002ma-J1; Wed, 15 Jul 2026 14:57:22 -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 1wk4nI-0002lh-EG for qemu-devel@nongnu.org; Wed, 15 Jul 2026 14:57:20 -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 1wk4nC-0005zU-Kq for qemu-devel@nongnu.org; Wed, 15 Jul 2026 14:57:17 -0400 Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 66FHB9a3252981 for ; Wed, 15 Jul 2026 18:57:13 GMT Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fe652auq7-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 15 Jul 2026 18:57:12 +0000 (GMT) Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-c88ad1558f4so406222a12.2 for ; Wed, 15 Jul 2026 11:57:12 -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-3140e6c2b17sm5469546eec.25.2026.07.15.11.57.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jul 2026 11:57:10 -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= g+lOAJm4dp+Q6b10nK/z1keGmZtXGgk1p0fj4OUJDTQ=; b=aub8hAvYIEtW9H0N LJfBROPdw/zAoQGnoXN26TjDEUIG//6XxvoOQsTg/kzD/+VIndmiYzdyIdf8xfXi RoTKTLXX1hyQGvoxIiDGVD4rtZmjm9fSN5DYU5+8CfUjTsSGMllzoSiBK8yVBRQL U7+Mjgui5S25PaS2eOViASGbDnaA8dLIHfi28IvpKBl+Iqj4OAKtYZ67A4A/jTBz X+DiuaE7lKeY5w5lY2xfydQfeD58clV6ehedF/IvGQWJUb6u6+zL6ADRnILVKz8J 4jF0+6TH0p16icS0ONkvq+ULKe7WkDMRPYVhBrN6FM0MM4HGqAg/4o1+aamFI+HU Al+UkQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1784141832; x=1784746632; darn=nongnu.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=g+lOAJm4dp+Q6b10nK/z1keGmZtXGgk1p0fj4OUJDTQ=; b=S8+XX+vJv0ietw0ShMi/flNNq394OlgmNEkzkP/MeHK11vLcQ1FaT5gAUtm+++jJiz 7P6SEy6d5zbIIL7y5a6hSLzDkPvX2C7Asxa6KOskd0MtctY+kIDveBPace+I0ABBfOUe Akl8Pg1yAhA4kKPc+ShpzYYNQ6T8FpKT561xOlGpgNtmIUR9owmJpDIp8tOXvTvMTh6q tTQ1yzMjT/PPpUiquvWdgAVO4K3sNtILlLSJJYkkYdwf714iijKD9KqIyuzN/6IJRsy9 au8uMUBSaie3aEE/qlDteXEhkOxLL+dOMoNCe8ZPfIuQqAUTDK9AM8YKRXLCp6Sf839W Ug3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784141832; x=1784746632; h=content-transfer-encoding:content-type: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 :content-type; bh=g+lOAJm4dp+Q6b10nK/z1keGmZtXGgk1p0fj4OUJDTQ=; b=LNQtIIlkMlb7p/9zBn9iCMGA0HMcg2gdw9t+pQCiZvdLXf+imdYEq+ud/md7TOBB6W +VLHwBsMTcZKtPaG3l/G9kCGVV76on9YS/o6jdubpGy1vmlRajchS3k7tTD+hxFfO7HV kNRZe+c+74TeeHZ5W1vA6VNGOzvDvmO0Uj6FCMKrVFovIAD5EW3qMpbcqnqtIOXtrAh0 kjdllly6pcB2g7bB6JdW+956PfJjIs/960FsLQtwKQozzHoagz4kRp3tf/RVqcN32LJD zJ7eL+zT7VLEaPohfeGts+KuabBGdfWDkXAvbL/fQI27/fPWGBE12Vs0AkEOLixKERMw gI9g== X-Gm-Message-State: AOJu0YwNoPnDghy8VB28sgYfI3ZcwA0hl4/8oZ6Iw1ey9mYmsuXt6k68 ycd3BY7R62iYCk3S8MUeMePEiUf1wkCTop1NLO94mfDgW5VrkftuuUfoaFoT1dDhRJ4AmM+w4Ha 3gwNHkM1bhMRmfuMaOt6jAftAUSJbI0LsKBCnzZcra9oykhRg8uZhNXR1gYSBvp2i9w== X-Gm-Gg: AfdE7cms3E4VIXlld5f5hQvYQvVvsd5gWbnu+mZQdnHvehWU0s3E7RBoiZTXMuXmmks NiZokPZ4MikNG9Yc1Uw1aFHu52h1IxCpX5uP2bLC5EclaVWleL0DJUnSmPSA/vs+echc+OizTFC WJ96AncADtANP5nCTUBr7/H9P+o4Y4uAB9K0aSaNE164gtWI1gOyo6zvD/WClS2EcAeILUycAwU 3of1NocYJC3gaMLPDl5KVNNuPsAw6gLTdsgyn69NJ79zXgTXBNjSVv/LtzwIoOR5n8GKyvmjkxO Lld5ZbzBw7fqZffms6qGtU30XPm5Grnt5W3VToQ6EsInw42tiwTwt61JYLlh9prUZLLkaLcdgOf oeYfrwHsly8Bx6JoMYpbJI0Xkk056uyk70LF25Cv+gMI5yG0MAzK8WqsAHO8= X-Received: by 2002:a05:6a20:4394:b0:3bf:d1f9:b1d9 with SMTP id adf61e73a8af0-3c3576386b2mr8793301637.57.1784141832021; Wed, 15 Jul 2026 11:57:12 -0700 (PDT) X-Received: by 2002:a05:6a20:4394:b0:3bf:d1f9:b1d9 with SMTP id adf61e73a8af0-3c3576386b2mr8793258637.57.1784141831422; Wed, 15 Jul 2026 11:57:11 -0700 (PDT) From: Brian Cain To: qemu-devel@nongnu.org Cc: philmd@oss.qualcomm.com, pierrick.bouvier@oss.qualcomm.com, Paolo Bonzini , =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= , peter.maydell@linaro.org, matheus.bernardino@oss.qualcomm.com, ltaylorsimpson@gmail.com, Thomas Huth , Brian Cain , Laurent Vivier , Fabiano Rosas , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 5/7] hw/hexagon: connect l2vic device Date: Wed, 15 Jul 2026 11:56:59 -0700 Message-Id: <20260715185701.1287176-6-brian.cain@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20260715185701.1287176-1-brian.cain@oss.qualcomm.com> References: <20260715185701.1287176-1-brian.cain@oss.qualcomm.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzE1MDE4OCBTYWx0ZWRfX7CQv/KJRgGFu PazRWIfeMgzemNo2+Zk7kexGsUhBwOtMjWxupRGO770nAHFcg2OJUe6K+k3toiMZNIXY8EuCTHr EZUNFs4dZX34kiC2GEWw3CPncLLA7weMwCIa2IG1DDdQX8oDlIntOq7ndqhOIZkaX2EIydqsK8I THWQkwDVw4spZO3AH/NDBN4UsNEoIFVvL8fOFPd90mqvT+7gGfuYwNeYZBRnX+lzNePj/bq3B0w rHnaojETrAqy621dBPiMks1rv0COC9rh4vYthrvPuuFYY5TQU5EbJ1x9Mffx7JHIs0Jhu3psZcE ahqBmjPklJKkMf2tCJOvET+COls5NOBlUR/rbuudpl+VQYheNQHLafw48XE3zqOi8f0ahQ/38xv dkPF3aNFVpHeGB0fLMeiBKm9bdXr+wsvSi72V96jkuj/EHij5L+kbwZSzkIyGDTIonx3UAy0W+M DEWnNTL3ZUhuyRzzMZw== X-Proofpoint-Spam-Info: AW1haW4tMjYwNzE1MDE4OCBTYWx0ZWRfXwwVLngtyl3lj BBJ2oO2A7hsFqbMmuIG2/bvm/Zi0wXiUQdMR4QKPg6R5W1xBUGEDtoU0nb0t2DkGsh7Mk58IMsv ZBkiL9A00hx90/AfWnbWeCP00uc66GM= X-Authority-Analysis: v=2.4 cv=bKcm5v+Z c=1 sm=1 tr=0 ts=6a57d808 cx=c_pps a=Qgeoaf8Lrialg5Z894R3/Q==:117 a=ouPCqIW2jiPt+lZRy3xVPw==:17 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=ch7oxrfPrZXSMDqqmA0A:9 a=QEXdDO2ut3YA:10 a=x9snwWr2DeNwDh03kgHS:22 X-Proofpoint-ORIG-GUID: fEhMedPwsigCMTyGg_SECgmrJQ-AaNhc X-Proofpoint-GUID: fEhMedPwsigCMTyGg_SECgmrJQ-AaNhc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-15_04,2026-07-15_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 bulkscore=0 clxscore=1015 adultscore=0 malwarescore=0 impostorscore=0 suspectscore=0 priorityscore=1501 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607150188 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, 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: 1784141969059158500 Instantiate the L2VIC device in both machine models, map its slow and MMIO regions, and link it to each CPU via the "l2vic" property. Reviewed-by: Pierrick Bouvier Signed-off-by: Brian Cain --- include/hw/hexagon/hexagon.h | 1 + include/hw/hexagon/hexagon_globalreg.h | 4 +++ hw/hexagon/hexagon_dsp.c | 20 +++++++++++++ hw/hexagon/hexagon_globalreg.c | 41 ++++++++++++++++++++++---- hw/hexagon/virt.c | 22 ++++++++++++++ 5 files changed, 83 insertions(+), 5 deletions(-) diff --git a/include/hw/hexagon/hexagon.h b/include/hw/hexagon/hexagon.h index 1034b09c2ac..6753ae32cde 100644 --- a/include/hw/hexagon/hexagon.h +++ b/include/hw/hexagon/hexagon.h @@ -156,6 +156,7 @@ struct HexagonCommonMachineState { =20 MemoryRegion ram; MemoryRegion cfgtable_rom; + DeviceState *l2vic_dev; }; =20 #endif diff --git a/include/hw/hexagon/hexagon_globalreg.h b/include/hw/hexagon/he= xagon_globalreg.h index 950099808fd..397dc6854c9 100644 --- a/include/hw/hexagon/hexagon_globalreg.h +++ b/include/hw/hexagon/hexagon_globalreg.h @@ -10,6 +10,7 @@ =20 #include "hw/core/qdev.h" #include "hw/core/sysbus.h" +#include "hw/intc/hex-l2vic.h" #include "qom/object.h" #include "target/hexagon/cpu.h" =20 @@ -22,6 +23,9 @@ struct HexagonGlobalRegState { /* Array of system registers */ uint32_t regs[NUM_SREGS]; =20 + /* L2VIC interface used to back the VID/VID1 registers */ + HexL2VicInterface *l2vic; + /* Global performance cycle counter base */ uint64_t g_pcycle_base; =20 diff --git a/hw/hexagon/hexagon_dsp.c b/hw/hexagon/hexagon_dsp.c index aa493993229..4cf88627c8f 100644 --- a/hw/hexagon/hexagon_dsp.c +++ b/hw/hexagon/hexagon_dsp.c @@ -16,6 +16,7 @@ #include "hw/hexagon/hexagon.h" #include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" +#include "hw/intc/hex-l2vic.h" #include "hw/core/loader.h" #include "qapi/error.h" #include "qemu/error-report.h" @@ -111,6 +112,7 @@ static void hexagon_common_init(MachineState *machine, = Rev_t rev, MemoryRegion *address_space; DeviceState *glob_regs_dev; DeviceState *tlb_dev; + DeviceState *cpu0 =3D NULL; =20 memset(&hexagon_binfo, 0, sizeof(hexagon_binfo)); if (machine->kernel_filename) { @@ -131,11 +133,21 @@ static void hexagon_common_init(MachineState *machine= , Rev_t rev, machine->ram_size, &error_fatal); memory_region_add_subregion(address_space, 0x0, &hms->ram); =20 + hms->l2vic_dev =3D qdev_new(TYPE_HEX_L2VIC); + object_property_add_child(OBJECT(machine), "l2vic", + OBJECT(hms->l2vic_dev)); + sysbus_realize_and_unref(SYS_BUS_DEVICE(hms->l2vic_dev), &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(hms->l2vic_dev), 0, m_cfg->l2vic_base); + sysbus_mmio_map(SYS_BUS_DEVICE(hms->l2vic_dev), 1, + m_cfg->cfgtable.fastl2vic_base << 16); + 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); + object_property_set_link(OBJECT(glob_regs_dev), "l2vic", + OBJECT(hms->l2vic_dev), &error_fatal); sysbus_realize_and_unref(SYS_BUS_DEVICE(glob_regs_dev), &error_fatal); =20 tlb_dev =3D qdev_new(TYPE_HEXAGON_TLB); @@ -154,15 +166,23 @@ static void hexagon_common_init(MachineState *machine= , Rev_t rev, */ qdev_prop_set_bit(DEVICE(cpu), "start-powered-off", (i !=3D 0)); if (i =3D=3D 0) { + cpu0 =3D DEVICE(cpu); 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); + object_property_set_link(OBJECT(cpu), "l2vic", + OBJECT(hms->l2vic_dev), &error_fatal); qdev_realize_and_unref(DEVICE(cpu), NULL, &error_fatal); } =20 + for (int i =3D 0; i < 8; i++) { + sysbus_connect_irq(SYS_BUS_DEVICE(hms->l2vic_dev), i, + qdev_get_gpio_in(cpu0, i)); + } + rom_add_blob_fixed_as("config_table.rom", &m_cfg->cfgtable, sizeof(m_cfg->cfgtable), m_cfg->cfgbase, &address_space_memory); diff --git a/hw/hexagon/hexagon_globalreg.c b/hw/hexagon/hexagon_globalreg.c index b5e5913507e..3d0d6f9516c 100644 --- a/hw/hexagon/hexagon_globalreg.c +++ b/hw/hexagon/hexagon_globalreg.c @@ -11,6 +11,7 @@ #include "hw/core/qdev-properties.h" #include "hw/core/sysbus.h" #include "hw/core/resettable.h" +#include "hw/intc/hex-l2vic.h" #include "migration/vmstate.h" #include "qom/object.h" #include "target/hexagon/cpu.h" @@ -135,6 +136,32 @@ static inline uint32_t apply_write_mask(uint32_t new_v= al, uint32_t cur_val, return new_val; } =20 +static inline bool is_vid_reg(uint32_t reg) +{ + return reg =3D=3D HEX_SREG_VID || reg =3D=3D HEX_SREG_VID1; +} + +/* + * HEX_SREG_VID/VID1 are backed by the L2VIC's VID group registers + * rather than the plain regs[] array, when an L2VIC is wired up. + */ +static uint32_t get_reg_value(HexagonGlobalRegState *s, uint32_t reg) +{ + if (is_vid_reg(reg) && s->l2vic) { + return l2vic_read_vid(s->l2vic, reg =3D=3D HEX_SREG_VID ? 0 : 1); + } + return s->regs[reg]; +} + +static void set_reg_value(HexagonGlobalRegState *s, uint32_t reg, + uint32_t value) +{ + s->regs[reg] =3D value; + if (is_vid_reg(reg) && s->l2vic) { + l2vic_update_vid(s->l2vic, reg =3D=3D HEX_SREG_VID ? 0 : 1, value); + } +} + uint32_t hexagon_globalreg_read(HexagonGlobalRegState *s, uint32_t reg, uint32_t htid) { @@ -146,7 +173,7 @@ uint32_t hexagon_globalreg_read(HexagonGlobalRegState *= s, uint32_t reg, g_assert(reg < NUM_SREGS); g_assert(reg >=3D HEX_SREG_GLB_START); =20 - value =3D s->regs[reg]; + value =3D get_reg_value(s, reg); =20 trace_hexagon_globalreg_read(htid, get_sreg_name(reg), value); return value; @@ -160,7 +187,7 @@ void hexagon_globalreg_write(HexagonGlobalRegState *s, = uint32_t reg, } g_assert(reg < NUM_SREGS); g_assert(reg >=3D HEX_SREG_GLB_START); - s->regs[reg] =3D value; + set_reg_value(s, reg, value); trace_hexagon_globalreg_write(htid, get_sreg_name(reg), value); } =20 @@ -168,6 +195,7 @@ uint32_t hexagon_globalreg_masked_value(HexagonGlobalRe= gState *s, uint32_t reg, uint32_t value) { uint32_t reg_mask; + uint32_t cur_val; =20 if (!s) { return value; @@ -175,9 +203,10 @@ uint32_t hexagon_globalreg_masked_value(HexagonGlobalR= egState *s, uint32_t reg, g_assert(reg < NUM_SREGS); g_assert(reg >=3D HEX_SREG_GLB_START); reg_mask =3D global_sreg_immut_masks[reg]; + cur_val =3D get_reg_value(s, reg); return reg_mask =3D=3D IMMUTABLE ? - s->regs[reg] : - apply_write_mask(value, s->regs[reg], reg_mask); + cur_val : + apply_write_mask(value, cur_val, reg_mask); } =20 void hexagon_globalreg_write_masked(HexagonGlobalRegState *s, uint32_t reg, @@ -186,7 +215,7 @@ void hexagon_globalreg_write_masked(HexagonGlobalRegSta= te *s, uint32_t reg, if (!s) { return; } - s->regs[reg] =3D hexagon_globalreg_masked_value(s, reg, value); + set_reg_value(s, reg, hexagon_globalreg_masked_value(s, reg, value)); } =20 uint64_t hexagon_globalreg_get_pcycle_base(HexagonGlobalRegState *s) @@ -275,6 +304,8 @@ static const VMStateDescription vmstate_hexagon_globalr= eg =3D { }; =20 static const Property hexagon_globalreg_properties[] =3D { + DEFINE_PROP_LINK("l2vic", HexagonGlobalRegState, l2vic, + TYPE_HEX_L2VIC_INTERFACE, HexL2VicInterface *), DEFINE_PROP_UINT32("boot-evb", HexagonGlobalRegState, boot_evb, 0x0), DEFINE_PROP_UINT64("config-table-addr", HexagonGlobalRegState, config_table_addr, 0xffffffffULL), diff --git a/hw/hexagon/virt.c b/hw/hexagon/virt.c index a3638998b87..2256d3d53a5 100644 --- a/hw/hexagon/virt.c +++ b/hw/hexagon/virt.c @@ -15,6 +15,7 @@ #include "hw/hexagon/hexagon.h" #include "hw/hexagon/hexagon_globalreg.h" #include "hw/hexagon/hexagon_tlb.h" +#include "hw/intc/hex-l2vic.h" #include "hw/core/loader.h" #include "hw/core/qdev-properties.h" #include "hw/core/qdev-clock.h" @@ -268,10 +269,22 @@ static void virt_init(MachineState *ms) &vms->parent_obj.cfgtable_rom); fdt_add_hvx(vms, m_cfg); =20 + vms->parent_obj.l2vic_dev =3D qdev_new(TYPE_HEX_L2VIC); + object_property_add_child(OBJECT(ms), "l2vic", + OBJECT(vms->parent_obj.l2vic_dev)); + sysbus_realize_and_unref(SYS_BUS_DEVICE(vms->parent_obj.l2vic_dev), + &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(vms->parent_obj.l2vic_dev), 0, + m_cfg->l2vic_base); + sysbus_mmio_map(SYS_BUS_DEVICE(vms->parent_obj.l2vic_dev), 1, + m_cfg->cfgtable.fastl2vic_base << 16); + gsregs_dev =3D qdev_new(TYPE_HEXAGON_GLOBALREG); object_property_add_child(OBJECT(ms), "global-regs", OBJECT(gsregs_dev= )); qdev_prop_set_uint64(gsregs_dev, "config-table-addr", m_cfg->cfgbase); qdev_prop_set_uint32(gsregs_dev, "dsp-rev", v68_rev); + object_property_set_link(OBJECT(gsregs_dev), "l2vic", + OBJECT(vms->parent_obj.l2vic_dev), &error_fat= al); sysbus_realize_and_unref(SYS_BUS_DEVICE(gsregs_dev), &error_fatal); =20 tlb_dev =3D qdev_new(TYPE_HEXAGON_TLB); @@ -301,9 +314,18 @@ static void virt_init(MachineState *ms) OBJECT(gsregs_dev), &error_fatal); object_property_set_link(OBJECT(cpu), "tlb", OBJECT(tlb_dev), &error_fatal); + object_property_set_link(OBJECT(cpu), "l2vic", + OBJECT(vms->parent_obj.l2vic_dev), + &error_fatal); =20 qdev_realize_and_unref(DEVICE(cpu), NULL, &error_fatal); } + + for (int i =3D 0; i < 8; i++) { + sysbus_connect_irq(SYS_BUS_DEVICE(vms->parent_obj.l2vic_dev), i, + qdev_get_gpio_in(cpu0, i)); + } + fdt_add_cpu_nodes(vms); clk_phandle =3D fdt_add_clocks(vms); fdt_add_uart(vms, VIRT_UART0, clk_phandle); --=20 2.34.1