libsel4platsupport: Update 'new_io_ops'
This commit updates the 'new_io_ops' function in regards to the addition
of the IRQ interfaces in the I/O ops interface. An additional call has
been added to initialise the IRQ interface with the I/O mapper and
malloc interface. Also add in clean-up functionality when some of the
interfaces fail to initialise.
diff --git a/libsel4platsupport/include/sel4platsupport/io.h b/libsel4platsupport/include/sel4platsupport/io.h
index e947030..34fc824 100644
--- a/libsel4platsupport/include/sel4platsupport/io.h
+++ b/libsel4platsupport/include/sel4platsupport/io.h
@@ -16,6 +16,7 @@
#include <vspace/vspace.h>
#include <platsupport/io.h>
#include <simple/simple.h>
+#include <sel4platsupport/irq.h>
#include <stdio.h>
#include <stdlib.h>
@@ -67,11 +68,12 @@
*
* @param vspace VSpace interface to use for mapping
* @param vka VKA interface for allocating physical frames, and any extra objects or cslots
+ * @param simple A simple interface to access init caps from
* @param io_ops Interface to fill in
*
* @return returns 0 on success
*/
-int sel4platsupport_new_io_ops(vspace_t *vspace, vka_t *vka, ps_io_ops_t *io_ops);
+int sel4platsupport_new_io_ops(vspace_t *vspace, vka_t *vka, simple_t *simple, ps_io_ops_t *io_ops);
/* Initialise all arch-specific io ops for this platform
*
diff --git a/libsel4platsupport/src/io.c b/libsel4platsupport/src/io.c
index 52b6944..bb0b0d3 100644
--- a/libsel4platsupport/src/io.c
+++ b/libsel4platsupport/src/io.c
@@ -344,23 +344,39 @@
#endif
}
-int sel4platsupport_new_io_ops(vspace_t *vspace, vka_t *vka, ps_io_ops_t *io_ops)
+int sel4platsupport_new_io_ops(vspace_t *vspace, vka_t *vka, simple_t *simple, ps_io_ops_t *io_ops)
{
memset(io_ops, 0, sizeof(ps_io_ops_t));
- int err = sel4platsupport_new_io_mapper(vspace, vka, &io_ops->io_mapper);
- if (err) {
- return err;
+ int error = 0;
+
+ /* Initialise the interfaces which do not require memory allocation/need to be initialised first */
+ error = sel4platsupport_new_malloc_ops(&io_ops->malloc_ops)
+#ifdef ARCH_ARM
+ || clock_sys_init(io_ops, &io_ops->clock_sys)
+#ifdef CONFIG_PLAT_TK1
+ || gpio_sys_init(io_ops, &gpio_sys)
+#endif
+ || mux_sys_init(io_ops, get_mux_dependencies(), &io_ops->mux_sys)
+#endif
+ ;
+ if (error) {
+ return error;
}
-#ifdef ARCH_ARM
- clock_sys_init(io_ops, &io_ops->clock_sys);
-#ifdef CONFIG_PLAT_TK1
- gpio_sys_init(io_ops, &gpio_sys);
-#endif
- mux_sys_init(io_ops, get_mux_dependencies(), &io_ops->mux_sys);
-#endif
+ /* Now allocate the IO-specific interfaces (the ones that can be found in this file) */
+ error = sel4platsupport_new_io_mapper(vspace, vka, &io_ops->io_mapper);
+ if (error) {
+ return error;
+ }
- sel4platsupport_new_malloc_ops(&io_ops->malloc_ops);
- return err;
+ error = sel4platsupport_new_irq_ops(&io_ops->irq_ops, vka, simple, DEFAULT_IRQ_INTERFACE_CONFIG,
+ &io_ops->malloc_ops);
+ if (error) {
+ free(io_ops->io_mapper.cookie);
+ io_ops->io_mapper.cookie = NULL;
+ return error;
+ }
+
+ return 0;
}