]> xenbits.xensource.com Git - unikraft/unikraft.git/commitdiff
drivers/xen/emg_console: Add Xen emergency console
authorThassilo Schulze <thassilo@unikraft.io>
Wed, 11 Sep 2024 14:22:10 +0000 (16:22 +0200)
committerUnikraft Bot <monkey@unikraft.io>
Fri, 13 Sep 2024 13:28:42 +0000 (13:28 +0000)
The emergency console is kept in a separate library from
the HV console for simplicity. The emergency console also
registers in the early init tab.

Signed-off-by: Thassilo Schulze <thassilo@unikraft.io>
Approved-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Simon Kuenzer <simon@unikraft.io>
Reviewed-by: Michalis Pappas <michalis@unikraft.io>
GitHub-Closes: #1464

drivers/xen/Makefile.uk
drivers/xen/emg_console/Config.uk [new file with mode: 0644]
drivers/xen/emg_console/Makefile.uk [new file with mode: 0644]
drivers/xen/emg_console/emg_console.c

index 69d37623f9a3feeee20b4f365b64e1be5f61eec7..2870dd16862f0b5b38efbe081eaf3c897127fb8c 100644 (file)
@@ -11,3 +11,4 @@ $(eval $(call import_lib,$(UK_DRIV_XEN_BASE)/blk))
 $(eval $(call import_lib,$(UK_DRIV_XEN_BASE)/net))
 $(eval $(call import_lib,$(UK_DRIV_XEN_BASE)/xenbus))
 $(eval $(call import_lib,$(UK_DRIV_XEN_BASE)/console))
+$(eval $(call import_lib,$(UK_DRIV_XEN_BASE)/emg_console))
diff --git a/drivers/xen/emg_console/Config.uk b/drivers/xen/emg_console/Config.uk
new file mode 100644 (file)
index 0000000..3905d7f
--- /dev/null
@@ -0,0 +1,6 @@
+menuconfig LIBXEN_EMG_CONSOLE
+       bool "Emergency console"
+       select LIBUKCONSOLE
+       depends on PLAT_XEN
+       help
+               Driver for the Xen emergency console
diff --git a/drivers/xen/emg_console/Makefile.uk b/drivers/xen/emg_console/Makefile.uk
new file mode 100644 (file)
index 0000000..30e0005
--- /dev/null
@@ -0,0 +1,6 @@
+$(eval $(call addlib_s,libxenemgconsole,$(CONFIG_LIBXEN_EMG_CONSOLE)))
+
+LIBXENEMGCONSOLE_CFLAGS-y        += $(LIBXENPLAT_CFLAGS-y)
+LIBXENEMGCONSOLE_CINCLUDES-y     += $(LIBXENPLAT_CINCLUDES-y)
+
+LIBXENEMGCONSOLE_SRCS-y          += $(LIBXENEMGCONSOLE_BASE)/emg_console.c|isr
index d5868a120daa4d2d0dc3cb76dbdd66ae7dc9097d..f086e8c81ed7fecfa6a6845e4078e4299cb40572 100644 (file)
  * DEALINGS IN THE SOFTWARE.
  */
 
-#include <uk/essentials.h>
+#include <uk/console/driver.h>
 #include <common/hypervisor.h>
+#include <uk/boot/earlytab.h>
+#include <uk/prio.h>
+#include <uk/plat/common/bootinfo.h>
 
-#define __XEN_CONSOLE_IMPL__
-#include "emg_console.h"
-
-int emg_console_output(const char *str, unsigned int len)
+static __ssz console_out(struct uk_console *dev __unused, const char *str,
+                        __sz len)
 {
        int rc;
 
        rc = HYPERVISOR_console_io(CONSOLEIO_write, len, DECONST(char *, str));
        if (unlikely(rc < 0))
                return rc;
+
        return len;
 }
+
+static __ssz console_in(struct uk_console *dev __unused, char *str __unused,
+                       __sz len __unused)
+{
+       return 0;
+}
+
+static struct uk_console_ops console_ops = {
+       .out = console_out,
+       .in = console_in
+};
+
+static struct uk_console console_dev;
+
+static int init_console(struct ukplat_bootinfo *bi __unused)
+{
+       uk_console_init(&console_dev, "Emergency console", &console_ops,
+                       UK_CONSOLE_FLAG_STDOUT);
+       uk_console_register(&console_dev);
+       return 0;
+}
+
+UK_BOOT_EARLYTAB_ENTRY(init_console, UK_PRIO_AFTER(UK_PRIO_EARLIEST));