From: Andrew Jones <ajones@ventanamicro.com>
To: opensbi@lists.infradead.org
Subject: [PATCH v4 3/3] lib: sbi: Apply register_extensions to vendor extensions
Date: Thu, 11 May 2023 18:11:04 +0200 [thread overview]
Message-ID: <20230511161104.115168-4-ajones@ventanamicro.com> (raw)
In-Reply-To: <20230511161104.115168-1-ajones@ventanamicro.com>
The vendor extension ID range is large, but at runtime at most a
single ID will be available. Apply the register_extensions callback
to check if that single ID is available. When it isn't, don't
register the vendor extension at all. When it is, then narrow the
extension range to the single ID and register it.
Signed-off-by: Andrew Jones <ajones@ventanamicro.com>
---
lib/sbi/sbi_ecall_vendor.c | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/lib/sbi/sbi_ecall_vendor.c b/lib/sbi/sbi_ecall_vendor.c
index 8b8dab00c92d..a64a82a8a3b1 100644
--- a/lib/sbi/sbi_ecall_vendor.c
+++ b/lib/sbi/sbi_ecall_vendor.c
@@ -47,9 +47,26 @@ static int sbi_ecall_vendor_handler(unsigned long extid, unsigned long funcid,
out_val, out_trap);
}
+struct sbi_ecall_extension ecall_vendor;
+
+static int sbi_ecall_vendor_register_extensions(void)
+{
+ unsigned long extid = sbi_ecall_vendor_id(), out_val;
+
+ if (sbi_ecall_vendor_probe(extid, &out_val) || !out_val)
+ return 0;
+
+ ecall_vendor.extid_start = extid;
+ ecall_vendor.extid_end = extid;
+ ecall_vendor.register_extensions = NULL;
+
+ return sbi_ecall_register_extension(&ecall_vendor);
+}
+
struct sbi_ecall_extension ecall_vendor = {
.extid_start = SBI_EXT_VENDOR_START,
.extid_end = SBI_EXT_VENDOR_END,
.probe = sbi_ecall_vendor_probe,
.handle = sbi_ecall_vendor_handler,
+ .register_extensions = sbi_ecall_vendor_register_extensions,
};
--
2.40.0
prev parent reply other threads:[~2023-05-11 16:11 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-11 16:11 [PATCH v4 0/3] lib: sbi: Ensure SBI extension is available Andrew Jones
2023-05-11 16:11 ` [PATCH v4 1/3] lib: sbi: Don't register unavailable single ID extensions Andrew Jones
2023-05-11 16:11 ` [PATCH v4 2/3] lib: sbi: Introduce register_extensions extension callback Andrew Jones
2023-05-12 14:25 ` Anup Patel
2023-05-12 15:06 ` Andrew Jones
2023-05-12 16:47 ` Anup Patel
2023-05-15 6:01 ` Andrew Jones
2023-05-11 16:11 ` Andrew Jones [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230511161104.115168-4-ajones@ventanamicro.com \
--to=ajones@ventanamicro.com \
--cc=opensbi@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.