[PATCH v4 15/44] x86/boot: introduce boot module interator

Daniel P. Smith posted 44 patches 3 months ago
There is a newer version of this series
[PATCH v4 15/44] x86/boot: introduce boot module interator
Posted by Daniel P. Smith 3 months ago
Provide an iterator to go through boot module array searching based on type.

Signed-off-by: Daniel P. Smith <dpsmith@apertussolutions.com>
---
 xen/arch/x86/include/asm/bootinfo.h | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/include/asm/bootinfo.h b/xen/arch/x86/include/asm/bootinfo.h
index 37132afb4e6a..99f8c9b83b25 100644
--- a/xen/arch/x86/include/asm/bootinfo.h
+++ b/xen/arch/x86/include/asm/bootinfo.h
@@ -42,8 +42,24 @@ struct boot_info {
     uint32_t mmap_length;
 };
 
-#endif
+static inline int __init next_boot_module_index(
+    const struct boot_info *bi, enum bootmod_type t, int offset)
+{
+    int i;
+
+    for ( i = offset; i < bi->nr_mods; i++ )
+    {
+        if ( bi->mods[i].type == t )
+            return i;
+    }
+
+    return -1;
+}
 
+#define first_boot_module_index(bi, t)              \
+    next_boot_module_index(bi, t, 0)
+
+#endif
 /*
  * Local variables:
  * mode: C
-- 
2.30.2