From nobody Sun Dec 29 01:38:11 2024 Delivered-To: importer2@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+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1721141108; cv=none; d=zohomail.com; s=zohoarc; b=UVIIssQWwBL6DPmn6jAzGAiRI/grv4h0Y9DvM5+o55QuDKamQTQDDfrW19kPqRqSWMuUAX11YuN+yBpg/5fL3inPVii3nyGFK1Ig3GhVfa7DlnIX6X7++/IA2OvGlDwmFBrB8D2qQ7kVYA++lkb9ZZR2Ovq3QOx97tm/0ERpB/0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1721141108; h=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=/5uhu6Kg5Ht8M//pg+LE9MtLky6V7L27T+s5kfGc6lw=; b=kRk/v9v8j0hw7DducuUhR8IJeUjC4g47vAs9BZkF7OFL2OJ0rEMNlqp/2E/Fpb+zoqmGkDlNUlIABR1BCrLBqq9o5i4LMlsPt7DHmQdU0L68iQtxxfd7cTflvyRa1ZIyPERbb2qGTXPjZgWLYE/5AjH4X4NDdPOwQ0/18adpDfk= 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+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1721141108444912.2820650156299; Tue, 16 Jul 2024 07:45:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sTjOs-0004DL-Q6; Tue, 16 Jul 2024 10:43:30 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sTjOr-000498-Mx for qemu-devel@nongnu.org; Tue, 16 Jul 2024 10:43:29 -0400 Received: from mail-pg1-x52d.google.com ([2607:f8b0:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sTjOp-000302-1w for qemu-devel@nongnu.org; Tue, 16 Jul 2024 10:43:29 -0400 Received: by mail-pg1-x52d.google.com with SMTP id 41be03b00d2f7-793a3a79a83so1347750a12.3 for ; Tue, 16 Jul 2024 07:43:26 -0700 (PDT) Received: from sunil-pc.tail07344b.ts.net ([106.51.187.237]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-2caf480d61bsm6084782a91.18.2024.07.16.07.43.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Jul 2024 07:43:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1721141003; x=1721745803; 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=/5uhu6Kg5Ht8M//pg+LE9MtLky6V7L27T+s5kfGc6lw=; b=lBy839MFdao5hsNdnm1wqpBwv03rNcJUmkKXUEcpDIgQ0F3CQ7bCOTta4LaJRRHLcD cU0NtM5642pdRpEBRtiW4+aS9lkgOCMQjrffSY/W/ry1X2z40iHX6wGNu4FnimrT6xq+ Y8Yoj0F7h+oxHUf3hs0M1RTjNqpBNhV0916YF462QRYLUB0hZnH4LXUcJXNftEhhpJG5 yfIGPRjB4mPhipIC0K7hAEHuJNbu8xaxDdwAupYfuyBvlkoecxgplQJFcNsRpQiDpujv 3zarCPsnSl7/xdKXM5dgptLXPr7ri36Iemip5nlCtebQDiPUDyBg5+6GZiuJifuJeR0x vwug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1721141003; x=1721745803; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/5uhu6Kg5Ht8M//pg+LE9MtLky6V7L27T+s5kfGc6lw=; b=e3hZDZb5WxO/NCtnKHIovRMfrARXfZfD15nAHwl3lMMAsoxLPpsfbxoEbItS51Fu2B 1M2vhhwTqI27c5V78OSi3227ZVXKO0CBkp8If19MZSsVEghmnlQAxhKHLDJeGHTjT9Cg 351vYxgifRo24r4Rn41yBH5GuRcHYfSWLQSI2/SPdhw68YGre5Tb+XxIB+tY8EM170o0 wxzs+TSuWUGqYFDI0DN9MedZV1xGVlfg4M/LfukdpSnn0OEJRrsppzFYmBiojW7mi8PM NdoQ5NsNW698g0fvU3tyR8a3qco+OU9kxo41X0ObALMRo4FiB1E/5KrWJ3dSSrge/nF9 6BvQ== X-Gm-Message-State: AOJu0YyE3i2rASHpu8tUNAz7XsMEieWt6sOhOx1kHJ4mUOdqlblE/awd /cfPbqpoLw+JWhvFLJ+B0sPYxIzba7KliZmwd+9kLJUjNbUzKsH1BAkhlP82re94dyoG9LpyCJr 8cbs= X-Google-Smtp-Source: AGHT+IEMnZ/SVXv0PH6LBaG6KNxSoZA0HahYQLf7NWYbXCp+0P4uu+KVIPdVsk51tkfDwUr1wfG9Ng== X-Received: by 2002:a05:6a20:6a0f:b0:1be:c4bb:6f31 with SMTP id adf61e73a8af0-1c3f1210aacmr3016275637.18.1721141003650; Tue, 16 Jul 2024 07:43:23 -0700 (PDT) From: Sunil V L To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org Cc: Palmer Dabbelt , Alistair Francis , Bin Meng , Weiwei Li , Daniel Henrique Barboza , Liu Zhiwei , "Michael S . Tsirkin" , Igor Mammedov , Ani Sinha , Sunil V L Subject: [PATCH v4 1/9] hw/riscv/virt-acpi-build.c: Add namespace devices for PLIC and APLIC Date: Tue, 16 Jul 2024 20:12:58 +0530 Message-ID: <20240716144306.2432257-2-sunilvl@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240716144306.2432257-1-sunilvl@ventanamicro.com> References: <20240716144306.2432257-1-sunilvl@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::52d; envelope-from=sunilvl@ventanamicro.com; helo=mail-pg1-x52d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer2=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @ventanamicro.com) X-ZM-MESSAGEID: 1721141110368116300 Content-Type: text/plain; charset="utf-8" As per the requirement ACPI_080 in the RISC-V Boot and Runtime Services (BRS) specification [1], PLIC and APLIC should be in namespace as well. So, add them using the defined HID. [1] - https://github.com/riscv-non-isa/riscv-brs/releases/download/v0.0.2/r= iscv-brs-spec.pdf (Chapter 6) Signed-off-by: Sunil V L Acked-by: Alistair Francis Acked-by: Igor Mammedov --- hw/riscv/virt-acpi-build.c | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c index 0925528160..5f5082a35b 100644 --- a/hw/riscv/virt-acpi-build.c +++ b/hw/riscv/virt-acpi-build.c @@ -141,6 +141,30 @@ static void acpi_dsdt_add_cpus(Aml *scope, RISCVVirtSt= ate *s) } } =20 +static void acpi_dsdt_add_plic_aplic(Aml *scope, uint8_t socket_count, + uint64_t mmio_base, uint64_t mmio_siz= e, + const char *hid) +{ + uint64_t plic_aplic_addr; + uint32_t gsi_base; + uint8_t socket; + + for (socket =3D 0; socket < socket_count; socket++) { + plic_aplic_addr =3D mmio_base + mmio_size * socket; + gsi_base =3D VIRT_IRQCHIP_NUM_SOURCES * socket; + Aml *dev =3D aml_device("IC%.02X", socket); + aml_append(dev, aml_name_decl("_HID", aml_string("%s", hid))); + aml_append(dev, aml_name_decl("_UID", aml_int(socket))); + aml_append(dev, aml_name_decl("_GSB", aml_int(gsi_base))); + + Aml *crs =3D aml_resource_template(); + aml_append(crs, aml_memory32_fixed(plic_aplic_addr, mmio_size, + AML_READ_WRITE)); + aml_append(dev, aml_name_decl("_CRS", crs)); + aml_append(scope, dev); + } +} + static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, uint32_t uart_irq) @@ -411,6 +435,14 @@ static void build_dsdt(GArray *table_data, =20 socket_count =3D riscv_socket_count(ms); =20 + if (s->aia_type =3D=3D VIRT_AIA_TYPE_NONE) { + acpi_dsdt_add_plic_aplic(scope, socket_count, memmap[VIRT_PLIC].ba= se, + memmap[VIRT_PLIC].size, "RSCV0001"); + } else { + acpi_dsdt_add_plic_aplic(scope, socket_count, memmap[VIRT_APLIC_S]= .base, + memmap[VIRT_APLIC_S].size, "RSCV0002"); + } + acpi_dsdt_add_uart(scope, &memmap[VIRT_UART0], UART0_IRQ); =20 if (socket_count =3D=3D 1) { --=20 2.43.0