|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Minios-devel] [UNIKRAFT PATCH] lib/ukbus: Move uk_bus_init/probe to the inittab
With the introduction of the inittab, there shouldn't be a need to
perform explicit initialization from ukboot. We move the uk_bus
initialization functions into the library and register these
function with the inittab
Signed-off-by: Sharan Santhanam <sharan.santhanam@xxxxxxxxx>
---
lib/ukboot/boot.c | 10 --------
lib/ukbus/bus.c | 61 ++++++++++++++++++++++++++++++++++++++++++++--
lib/ukbus/exportsyms.uk | 2 --
lib/ukbus/include/uk/bus.h | 46 ----------------------------------
4 files changed, 59 insertions(+), 60 deletions(-)
diff --git a/lib/ukboot/boot.c b/lib/ukboot/boot.c
index 2977a0f..c115179 100644
--- a/lib/ukboot/boot.c
+++ b/lib/ukboot/boot.c
@@ -58,9 +58,6 @@
#include <uk/ctors.h>
#include <uk/init.h>
#include <uk/argparse.h>
-#if CONFIG_LIBUKBUS
-#include <uk/bus.h>
-#endif /* CONFIG_LIBUKBUS */
#ifdef CONFIG_LIBUKLIBPARAM
#include <uk/libparam.h>
#endif /* CONFIG_LIBUKLIBPARAM */
@@ -99,13 +96,6 @@ static void main_thread_func(void *arg)
}
}
-#ifdef CONFIG_LIBUKBUS
- uk_pr_info("Initialize bus handlers...\n");
- uk_bus_init_all(uk_alloc_get_default());
- uk_pr_info("Probe buses...\n");
- uk_bus_probe_all();
-#endif /* CONFIG_LIBUKBUS */
-
#ifdef CONFIG_LIBLWIP
/*
* TODO: This is an initial implementation where we call the
diff --git a/lib/ukbus/bus.c b/lib/ukbus/bus.c
index 2b53f3f..45de244 100644
--- a/lib/ukbus/bus.c
+++ b/lib/ukbus/bus.c
@@ -35,10 +35,17 @@
#include <uk/bus.h>
#include <uk/assert.h>
#include <uk/print.h>
+#include <uk/init.h>
UK_LIST_HEAD(uk_bus_list);
static unsigned int bus_count;
+static int uk_bus_init(struct uk_bus *b, struct uk_alloc *a);
+static int uk_bus_probe(struct uk_bus *b);
+static unsigned int uk_bus_init_all(struct uk_alloc *a);
+static unsigned int uk_bus_probe_all(void);
+static int uk_bus_lib_init(void);
+
void _uk_bus_register(struct uk_bus *b)
{
UK_ASSERT(b != NULL);
@@ -64,7 +71,7 @@ unsigned int uk_bus_count(void)
return bus_count;
}
-int uk_bus_init(struct uk_bus *b, struct uk_alloc *a)
+static int uk_bus_init(struct uk_bus *b, struct uk_alloc *a)
{
UK_ASSERT(b != NULL);
@@ -75,7 +82,7 @@ int uk_bus_init(struct uk_bus *b, struct uk_alloc *a)
}
-int uk_bus_probe(struct uk_bus *b)
+static int uk_bus_probe(struct uk_bus *b)
{
UK_ASSERT(b != NULL);
UK_ASSERT(b->probe != NULL);
@@ -83,3 +90,53 @@ int uk_bus_probe(struct uk_bus *b)
uk_pr_debug("Probe bus %p...\n", b);
return b->probe();
}
+
+/* Returns the number of successfully initialized device buses */
+static unsigned int uk_bus_init_all(struct uk_alloc *a)
+{
+ struct uk_bus *b, *b_next;
+ unsigned int ret = 0;
+ int status = 0;
+
+ if (uk_bus_count() == 0)
+ return 0;
+
+ uk_list_for_each_entry_safe(b, b_next, &uk_bus_list, list) {
+ if ((status = uk_bus_init(b, a)) >= 0) {
+ ++ret;
+ } else {
+ uk_pr_err("Failed to initialize bus driver %p: %d\n",
+ b, status);
+
+ /* Remove the failed driver from the list */
+ _uk_bus_unregister(b);
+ }
+ }
+ return ret;
+}
+
+/* Returns the number of successfully probed device buses */
+static unsigned int uk_bus_probe_all(void)
+{
+ struct uk_bus *b;
+ unsigned int ret = 0;
+
+ if (uk_bus_count() == 0)
+ return 0;
+
+ uk_list_for_each_entry(b, &uk_bus_list, list) {
+ if (uk_bus_probe(b) >= 0)
+ ++ret;
+ }
+ return ret;
+}
+
+static int uk_bus_lib_init(void)
+{
+ uk_pr_info("Initialize bus handlers...\n");
+ uk_bus_init_all(uk_alloc_get_default());
+ uk_pr_info("Probe buses...\n");
+ uk_bus_probe_all();
+ return 0;
+}
+uk_early_initcall_prio(uk_bus_lib_init, 0);
diff --git a/lib/ukbus/exportsyms.uk b/lib/ukbus/exportsyms.uk
index b202357..b25fa97 100644
--- a/lib/ukbus/exportsyms.uk
+++ b/lib/ukbus/exportsyms.uk
@@ -1,6 +1,4 @@
uk_bus_count
-uk_bus_init
-uk_bus_probe
_uk_bus_register
_uk_bus_unregister
uk_bus_list
diff --git a/lib/ukbus/include/uk/bus.h b/lib/ukbus/include/uk/bus.h
index 633636a..bff94bb 100644
--- a/lib/ukbus/include/uk/bus.h
+++ b/lib/ukbus/include/uk/bus.h
@@ -64,52 +64,6 @@ void _uk_bus_register(struct uk_bus *b);
/* Do not use this function directly: */
void _uk_bus_unregister(struct uk_bus *b);
-/* Initializes a bus driver */
-int uk_bus_init(struct uk_bus *b, struct uk_alloc *a);
-
-/* Scan for devices on the bus */
-int uk_bus_probe(struct uk_bus *b);
-
-/* Returns the number of successfully initialized device buses */
-static inline unsigned int uk_bus_init_all(struct uk_alloc *a)
-{
- struct uk_bus *b, *b_next;
- unsigned int ret = 0;
- int status = 0;
-
- if (uk_bus_count() == 0)
- return 0;
-
- uk_list_for_each_entry_safe(b, b_next, &uk_bus_list, list) {
- if ((status = uk_bus_init(b, a)) >= 0) {
- ++ret;
- } else {
- uk_pr_err("Failed to initialize bus driver %p: %d\n",
- b, status);
-
- /* Remove the failed driver from the list */
- _uk_bus_unregister(b);
- }
- }
- return ret;
-}
-
-/* Returns the number of successfully probed device buses */
-static inline unsigned int uk_bus_probe_all(void)
-{
- struct uk_bus *b;
- unsigned int ret = 0;
-
- if (uk_bus_count() == 0)
- return 0;
-
- uk_list_for_each_entry(b, &uk_bus_list, list) {
- if (uk_bus_probe(b) >= 0)
- ++ret;
- }
- return ret;
-}
-
/* registers a bus driver to the bus system */
#define UK_BUS_REGISTER(b) \
_UK_BUS_REGISTER(__LIBNAME__, b)
--
2.7.4
_______________________________________________
Minios-devel mailing list
Minios-devel@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/minios-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |