@@ -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,
};
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(+)