[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Minios-devel] [UNIKRAFT PATCH 2/4] include/uk: Introduce init table



The patch introduces the interface for the inittab. The patch provides
implementation to group the init function into the respective linker
section.

Signed-off-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>
---
 include/uk/init.h    | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 lib/ukboot/Config.uk |  1 +
 2 files changed, 66 insertions(+)
 create mode 100644 include/uk/init.h

diff --git a/include/uk/init.h b/include/uk/init.h
new file mode 100644
index 0000000..91cb6ef
--- /dev/null
+++ b/include/uk/init.h
@@ -0,0 +1,65 @@
+#ifndef _UK_INIT_H
+#define _UK_INIT_H
+
+#include <uk/config.h>
+#include <uk/essentials.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef int (*uk_init_t)(void);
+
+#define INITTAB_STR_VAR(libname, fn, base, prio) libname ## fn ## base ## prio
+#define INITTAB_SECTION(base, prio)  .uk_inittab_ ## base ## prio
+#define INITTAB_SECTION_NAME(name) STRINGIFY(name)
+
+#define __inittab(libname, fn, base, prio)                             \
+       static  const __used __section(INITTAB_SECTION_NAME(            \
+                                       INITTAB_SECTION(base, prio))    \
+                                     )                                 \
+               uk_init_t INITTAB_STR_VAR(libname, fn, base, prio) = fn
+
+/**
+ * Define a library initialization. At this point in time some platform
+ * component may not be initialized, so it wise to initializes those component
+ * to initialized.
+ */
+#define uk_early_initcall_prio(fn, prio)  __inittab(LIBNAME, fn, 1, prio)
+/**
+ * Define a stage for platform initialization. Platform at this point read
+ * all the device and device are initialized.
+ */
+#define uk_plat_initcall_prio(fn, prio)  __inittab(LIBNAME, fn, 2, prio)
+/**
+ * Define a stage for performing library initialization. This library
+ * initialization is performed after the platform is completely initialized.
+ */
+#define uk_lib_initcall_prio(fn, prio) __inittab(LIBNAME, fn, 3, prio)
+/**
+ * Define a stage for filesystem initialization.
+ */
+#define uk_rootfs_initcall_prio(fn, prio) __inittab(LIBNAME, fn, 4, prio)
+/**
+ * Define a stage for device initialization
+ */
+#define uk_sys_initcall_prio(fn, prio) __inittab(LIBNAME, fn, 5, prio)
+/**
+ * Define a stage for application pre-initialization
+ */
+#define uk_late_initcall_prio(fn, prio)  __inittab(LIBNAME, fn, 6, prio)
+
+/**
+ * Similar interface without priority.
+ */
+#define uk_early_initcall(fn)     uk_early_initcall_prio(fn, 9)
+#define uk_plat_initcall(fn)      uk_plat_initcall_prio(fn, 9)
+#define uk_lib_initcall(fn)       uk_lib_initcall_prio(fn, 9)
+#define uk_rootfs_initcall(fn)    uk_rootfs_initcall_prio(fn, 9)
+#define uk_sys_initcall(fn)       uk_sys_initcall_prio(fn, 9)
+#define uk_late_initcall(fn)      uk_late_initcall_prio(fn, 9)
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+#endif /* _UK_INIT_H */
diff --git a/lib/ukboot/Config.uk b/lib/ukboot/Config.uk
index 841a876..4ebd650 100644
--- a/lib/ukboot/Config.uk
+++ b/lib/ukboot/Config.uk
@@ -21,4 +21,5 @@ if LIBUKBOOT
        bool "Initialize ukallocbbuddy as allocator"
        default y
        select LIBUKALLOCBBUDDY
+
 endif
-- 
2.7.4


_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.