From patchwork Tue Aug 6 07:33:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 1969366 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=vQ7MfCIB; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=ventanamicro.com header.i=@ventanamicro.com header.a=rsa-sha256 header.s=google header.b=aSa9OOpJ; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4WdQ7C1DVJz1yYD for ; Tue, 6 Aug 2024 17:34:47 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=NKEFtRxOQABolHV621/SxqhcI0g7LA/vnVkv5botvmM=; b=vQ7MfCIBwJEXb9 vrz3zi1VaQfF9DwpiLrp1TVpfYVH2Fld43NKPRMbIT7lC9Mmjr9K/qPmv6AWTyO0Y/eFFZ2T8tWWJ NIRggvb5RXrHT6awhb+wbqM9fFHUG52MhcRKAW288M4+6ELBglDN54CIaZb9sPvz6yGtF9xrM2SuI QFcp6lSFYhMDt93MAJp5Lzt43ZydN+RK2rw70kWyrcV3jQ66Z0sLHjrwpDOnvivmdfMvGLsjNIKK5 4egP61Dk6/M1vpBdjEqjkWSHCkrokJdd7Spp1Wz7FUYPdSTAM8kUb/fOIs1jQaw7J8LkoqSOWEXRz 80ueakwvolzKYIPBH7Mg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbEiM-00000000oFu-2KfV; Tue, 06 Aug 2024 07:34:38 +0000 Received: from mail-pf1-x42e.google.com ([2607:f8b0:4864:20::42e]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sbEiA-00000000o6z-0Af2 for opensbi@lists.infradead.org; Tue, 06 Aug 2024 07:34:34 +0000 Received: by mail-pf1-x42e.google.com with SMTP id d2e1a72fcca58-70d399da0b5so267489b3a.3 for ; Tue, 06 Aug 2024 00:34:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1722929665; x=1723534465; darn=lists.infradead.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=DTMgQSIF0PsA1GYIwrb/EZG4t4iBAxlXpBWeON010ig=; b=aSa9OOpJAYzB0S9/8MyaUlJegIeBjTvqo/5yldvwBHGWequzf0uxChk4kK6RMmI033 L0hhAVSXOvnRSnkKgIWks475Dng9SrOlLizbLcFh8uYVN8cConiurVO59Wd2WpqlyuRT JSVGi1LJGYy3vq7k8NVlwSkZtEZ6+614OSHJ/G3zHgdwvMF6Ktpt5m3g/H0UbwEeijdN Go9IuX1V4Sn4DyqSAfyMMt3CaoPknYAAyNCa5fCGJn4QClB/ihIVGy41oA6qQvg/WGGA e26gMwB7n9n2nsJbybVD46Q31ddV5rfei+C2dlOcj+nKDFmC2QrduMxLhLL7r/pCEh6D QzFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722929665; x=1723534465; 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=DTMgQSIF0PsA1GYIwrb/EZG4t4iBAxlXpBWeON010ig=; b=BhZm0sBxoI36cRZAQB7QFaL8/DE1ZUS3hylL1jZXoS7xDlh61XcmaNhJY471RZF9Ev KGjyhjMg0H9yhhCi/AXWEPeyiHabZM9bfBU8HxYhK4+hNccsBksDz4GJvJx0UrjbNMzE glTQHIWYhYstH3TJP87p2kQ3HPftQqLK2LkLJQx0g32DvqlMaXEfsVW8qAgavVJPrzTR IWQZ1H6EvEP5dvfiaq5vriTFodE2a5pMftyl/FpFxw8KJn12RyPcgxXjQgbqU1Jynk4W EL4I1qiSh/yK34/IFZgV9BADjb0JFr6kQIw3fOwD2TVymxYFAYBpTEDphop29ddRdokX Us5Q== X-Forwarded-Encrypted: i=1; AJvYcCWTN/I6+wqHKFiA6CtXPr//9+mnQ6xro4swhILFiUN3bsFI8eqxOUslhxX+8l0lTEgMfpm6D50HuRkJtsgJEiAwTidFBn3GqSyLfyc= X-Gm-Message-State: AOJu0YwED1O77KSxyNA6Y0xgrzfZppaQynqiHCWLUxpp9wP8ohCue4fp J9CvGPzoSrhHrznAUbv2eRRo6SMrh9z/dadEi9+T6Ni2Lf6ZXQQ7mO5OAB56M3M= X-Google-Smtp-Source: AGHT+IGjETU3HoV18fIZENbotBTcXlIvuxQ2KwQPhlwzfyi9A/AqYZ/I2VJ4XrQoOqB5GP2ysl5kLw== X-Received: by 2002:a05:6a20:6a1e:b0:1c4:7dbc:d21a with SMTP id adf61e73a8af0-1c6995d5686mr22111545637.32.1722929665083; Tue, 06 Aug 2024 00:34:25 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([223.185.134.124]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7106ed2de28sm6455011b3a.191.2024.08.06.00.34.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Aug 2024 00:34:24 -0700 (PDT) From: Anup Patel To: Atish Patra Cc: Andrew Jones , Anup Patel , opensbi@lists.infradead.org, Anup Patel , Rahul Pathak Subject: [PATCH 14/16] lib: sbi: Implement SBI MPXY extension Date: Tue, 6 Aug 2024 13:03:36 +0530 Message-Id: <20240806073338.1856901-15-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240806073338.1856901-1-apatel@ventanamicro.com> References: <20240806073338.1856901-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240806_003426_378910_EE651D69 X-CRM114-Status: GOOD ( 15.11 ) X-Spam-Score: -2.1 (--) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: Implement the SBI MPXY extension which provides an SBI interface to the supervisor software for send messages via MPXY framework. Signed-off-by: Rahul Pathak Co-developed-by: Anup Patel Signed-off-by: Anup Patel --- include/sbi/sbi_ecall_interface.h | [...] Content analysis details: (-2.1 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:42e listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] X-BeenThere: opensbi@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "opensbi" Errors-To: opensbi-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org Implement the SBI MPXY extension which provides an SBI interface to the supervisor software for send messages via MPXY framework. Signed-off-by: Rahul Pathak Co-developed-by: Anup Patel Signed-off-by: Anup Patel --- include/sbi/sbi_ecall_interface.h | 10 +++++ lib/sbi/Kconfig | 3 ++ lib/sbi/objects.mk | 3 ++ lib/sbi/sbi_ecall_mpxy.c | 68 +++++++++++++++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 lib/sbi/sbi_ecall_mpxy.c diff --git a/include/sbi/sbi_ecall_interface.h b/include/sbi/sbi_ecall_interface.h index 6b993b18..085b33e7 100644 --- a/include/sbi/sbi_ecall_interface.h +++ b/include/sbi/sbi_ecall_interface.h @@ -35,6 +35,7 @@ #define SBI_EXT_DBTR 0x44425452 #define SBI_EXT_SSE 0x535345 #define SBI_EXT_FWFT 0x46574654 +#define SBI_EXT_MPXY 0x4D505859 /* SBI function IDs for BASE extension*/ #define SBI_EXT_BASE_GET_SPEC_VERSION 0x0 @@ -406,6 +407,15 @@ enum sbi_sse_state { #define SBI_SSE_EVENT_GLOBAL_BIT (1 << 15) #define SBI_SSE_EVENT_PLATFORM_BIT (1 << 14) +/* SBI function IDs for MPXY extension */ +#define SBI_EXT_MPXY_SET_SHMEM 0x0 +#define SBI_EXT_MPXY_GET_CHANNEL_IDS 0x1 +#define SBI_EXT_MPXY_READ_ATTRS 0x2 +#define SBI_EXT_MPXY_WRITE_ATTRS 0x3 +#define SBI_EXT_MPXY_SEND_MSG_WITH_RESP 0x4 +#define SBI_EXT_MPXY_SEND_MSG_NO_RESP 0x5 +#define SBI_EXT_MPXY_GET_NOTIFICATION_EVENTS 0x6 + /* SBI base specification related macros */ #define SBI_SPEC_VERSION_MAJOR_OFFSET 24 #define SBI_SPEC_VERSION_MAJOR_MASK 0x7f diff --git a/lib/sbi/Kconfig b/lib/sbi/Kconfig index bd8ba2b6..c6cc04bc 100644 --- a/lib/sbi/Kconfig +++ b/lib/sbi/Kconfig @@ -66,4 +66,7 @@ config SBI_ECALL_SSE bool "SSE extension" default y +config SBI_ECALL_MPXY + bool "MPXY extension" + default y endmenu diff --git a/lib/sbi/objects.mk b/lib/sbi/objects.mk index 2cea93b9..c199b834 100644 --- a/lib/sbi/objects.mk +++ b/lib/sbi/objects.mk @@ -61,6 +61,9 @@ libsbi-objs-$(CONFIG_SBI_ECALL_DBTR) += sbi_ecall_dbtr.o carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_SSE) += ecall_sse libsbi-objs-$(CONFIG_SBI_ECALL_SSE) += sbi_ecall_sse.o +carray-sbi_ecall_exts-$(CONFIG_SBI_ECALL_MPXY) += ecall_mpxy +libsbi-objs-$(CONFIG_SBI_ECALL_MPXY) += sbi_ecall_mpxy.o + libsbi-objs-y += sbi_bitmap.o libsbi-objs-y += sbi_bitops.o libsbi-objs-y += sbi_console.o diff --git a/lib/sbi/sbi_ecall_mpxy.c b/lib/sbi/sbi_ecall_mpxy.c new file mode 100644 index 00000000..5f717b76 --- /dev/null +++ b/lib/sbi/sbi_ecall_mpxy.c @@ -0,0 +1,68 @@ +/* + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 Ventana Micro Systems Inc. + * + * Authors: + * Anup Patel + */ + +#include +#include +#include +#include +#include + +static int sbi_ecall_mpxy_handler(unsigned long extid, unsigned long funcid, + struct sbi_trap_regs *regs, + struct sbi_ecall_return *out) +{ + int ret = 0; + + switch (funcid) { + case SBI_EXT_MPXY_SET_SHMEM: + ret = sbi_mpxy_set_shmem(regs->a0, regs->a1, regs->a2, regs->a3); + break; + case SBI_EXT_MPXY_GET_CHANNEL_IDS: + ret = sbi_mpxy_get_channel_ids(regs->a0); + break; + case SBI_EXT_MPXY_READ_ATTRS: + ret = sbi_mpxy_read_attrs(regs->a0, regs->a1, regs->a2); + break; + case SBI_EXT_MPXY_WRITE_ATTRS: + ret = sbi_mpxy_write_attrs(regs->a0, regs->a1, regs->a2); + break; + case SBI_EXT_MPXY_SEND_MSG_WITH_RESP: + ret = sbi_mpxy_send_message(regs->a0, regs->a1, + regs->a2, &out->value); + break; + case SBI_EXT_MPXY_SEND_MSG_NO_RESP: + ret = sbi_mpxy_send_message(regs->a0, regs->a1, regs->a2, + NULL); + break; + case SBI_EXT_MPXY_GET_NOTIFICATION_EVENTS: + ret = sbi_mpxy_get_notification_events(regs->a0, &out->value); + break; + default: + ret = SBI_ENOTSUPP; + } + + return ret; +} + +struct sbi_ecall_extension ecall_mpxy; + +static int sbi_ecall_mpxy_register_extensions(void) +{ + if (!sbi_mpxy_channel_available()) + return 0; + + return sbi_ecall_register_extension(&ecall_mpxy); +} + +struct sbi_ecall_extension ecall_mpxy = { + .extid_start = SBI_EXT_MPXY, + .extid_end = SBI_EXT_MPXY, + .register_extensions = sbi_ecall_mpxy_register_extensions, + .handle = sbi_ecall_mpxy_handler, +};