summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brown <mcb30@ipxe.org>2023-02-05 22:02:05 +0000
committerMichael Brown <mcb30@ipxe.org>2023-02-05 22:21:36 +0000
commita2bed43939b40ec843fd99bc9fd0d0e58124e082 (patch)
tree90fd251383b5265592cd2df3d25044150072c024
parent7cc305f7b4fb3508e64afa8c4c54bee1fff1f405 (diff)
downloadqemu-ipxe-a2bed43939b40ec843fd99bc9fd0d0e58124e082.tar.gz
[xen] Allow for platforms that have no Xen support
The Xen headers support only x86 and ARM. Allow for platforms such as LoongArch64 to build despite the absence of Xen support by providing an architecture-specific <bits/xen.h> that simply does: #ifndef _BITS_XEN_H #define _BITS_XEN_H #include <ipxe/nonxen.h> #endif /* _BITS_XEN_H */ Signed-off-by: Michael Brown <mcb30@ipxe.org>
-rw-r--r--src/include/ipxe/nonxen.h76
-rwxr-xr-xsrc/include/xen/import.pl4
-rw-r--r--src/include/xen/xen.h2
3 files changed, 81 insertions, 1 deletions
diff --git a/src/include/ipxe/nonxen.h b/src/include/ipxe/nonxen.h
new file mode 100644
index 00000000..b3b67894
--- /dev/null
+++ b/src/include/ipxe/nonxen.h
@@ -0,0 +1,76 @@
+#ifndef _IPXE_NONXEN_H
+#define _IPXE_NONXEN_H
+
+/** @file
+ *
+ * Stub Xen definitions for platforms with no Xen support
+ *
+ */
+
+FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
+
+#define __XEN_GUEST_HANDLE(name) __guest_handle_ ## name
+
+#define XEN_GUEST_HANDLE(name) __XEN_GUEST_HANDLE(name)
+
+#define ___DEFINE_XEN_GUEST_HANDLE(name, type) \
+ typedef type * __XEN_GUEST_HANDLE(name)
+
+#define __DEFINE_XEN_GUEST_HANDLE(name, type) \
+ ___DEFINE_XEN_GUEST_HANDLE(name, type); \
+ ___DEFINE_XEN_GUEST_HANDLE(const_##name, const type)
+
+#define DEFINE_XEN_GUEST_HANDLE(name) __DEFINE_XEN_GUEST_HANDLE(name, name)
+
+typedef unsigned long xen_pfn_t;
+
+typedef unsigned long xen_ulong_t;
+
+struct arch_vcpu_info {};
+
+struct arch_shared_info {};
+
+#define XEN_LEGACY_MAX_VCPUS 0
+
+struct xen_hypervisor;
+
+static inline __attribute__ (( always_inline )) unsigned long
+xen_hypercall_1 ( struct xen_hypervisor *xen __unused,
+ unsigned int hypercall __unused,
+ unsigned long arg1 __unused ) {
+ return 1;
+}
+
+static inline __attribute__ (( always_inline )) unsigned long
+xen_hypercall_2 ( struct xen_hypervisor *xen __unused,
+ unsigned int hypercall __unused,
+ unsigned long arg1 __unused, unsigned long arg2 __unused ) {
+ return 1;
+}
+
+static inline __attribute__ (( always_inline )) unsigned long
+xen_hypercall_3 ( struct xen_hypervisor *xen __unused,
+ unsigned int hypercall __unused,
+ unsigned long arg1 __unused, unsigned long arg2 __unused,
+ unsigned long arg3 __unused ) {
+ return 1;
+}
+
+static inline __attribute__ (( always_inline )) unsigned long
+xen_hypercall_4 ( struct xen_hypervisor *xen __unused,
+ unsigned int hypercall __unused,
+ unsigned long arg1 __unused, unsigned long arg2 __unused,
+ unsigned long arg3 __unused, unsigned long arg4 __unused ) {
+ return 1;
+}
+
+static inline __attribute__ (( always_inline )) unsigned long
+xen_hypercall_5 ( struct xen_hypervisor *xen __unused,
+ unsigned int hypercall __unused,
+ unsigned long arg1 __unused, unsigned long arg2 __unused,
+ unsigned long arg3 __unused, unsigned long arg4 __unused,
+ unsigned long arg5 __unused ) {
+ return 1;
+}
+
+#endif /* _IPXE_NONXEN_H */
diff --git a/src/include/xen/import.pl b/src/include/xen/import.pl
index 9f09a77a..12c7b001 100755
--- a/src/include/xen/import.pl
+++ b/src/include/xen/import.pl
@@ -59,6 +59,10 @@ sub try_import_file {
if ( /^\#include\s+[<\"](\S+)[>\"]/ ) {
push @dependencies, catfile ( $subdir, $1 );
}
+ # Patch "Unsupported architecture" line
+ if ( /^\#error\s+"Unsupported\sarchitecture"/ ) {
+ $_ = "#include <bits/xen.h>"
+ }
# Write out line
print $outfh "$_\n";
# Apply FILE_LICENCE() immediately after include guard
diff --git a/src/include/xen/xen.h b/src/include/xen/xen.h
index 8a4b30b3..c35008aa 100644
--- a/src/include/xen/xen.h
+++ b/src/include/xen/xen.h
@@ -19,7 +19,7 @@ FILE_LICENCE ( MIT );
#elif defined(__arm__) || defined (__aarch64__)
#include "arch-arm.h"
#else
-#error "Unsupported architecture"
+#include <bits/xen.h>
#endif
#ifndef __ASSEMBLY__