Message ID | 5ec3a7157f7d96943b5701f8d57e102181cd56d2.1611103406.git.thehajime@gmail.com |
---|---|
State | RFC |
Headers | show |
Series | [RFC,v8,01/20] um: split build in kernel and host parts | expand |
> > -obj-y := stdio_console.o fd.o chan_kern.o chan_user.o line.o > +ifndef CONFIG_UMMODE_LIB > +obj-y := stdio_console.o > +else > +obj-y := > +endif > +obj-y += fd.o chan_kern.o chan_user.o line.o Might nicer to do via Kconfig, such as config STDIO_CONSOLE def_bool y depends on !UMMODE_LIB and then obj-$(CONFIG_STDIO_CONSOLE) += stdio_console.o here. Similar to CONFIG_STDDER_CONSOLE, after all. > +/** > + * lkl_print - optional operation that receives console messages How is it optional? I don't see you having a __weak definition? johannes
On Mon, 15 Mar 2021 05:42:52 +0900, Johannes Berg wrote: > > > > > > -obj-y := stdio_console.o fd.o chan_kern.o chan_user.o line.o > > +ifndef CONFIG_UMMODE_LIB > > +obj-y := stdio_console.o > > +else > > +obj-y := > > +endif > > +obj-y += fd.o chan_kern.o chan_user.o line.o > > Might nicer to do via Kconfig, such as > > config STDIO_CONSOLE > def_bool y > depends on !UMMODE_LIB > > and then > > obj-$(CONFIG_STDIO_CONSOLE) += stdio_console.o > > here. Similar to CONFIG_STDDER_CONSOLE, after all. Agree. I'll fix them. > > +/** > > + * lkl_print - optional operation that receives console messages > > How is it optional? I don't see you having a __weak definition? Optional is misleading... I will fix the comment. -- Hajime
diff --git a/arch/um/drivers/Makefile b/arch/um/drivers/Makefile index ae96c83e312d..dc0d32d62294 100644 --- a/arch/um/drivers/Makefile +++ b/arch/um/drivers/Makefile @@ -37,7 +37,13 @@ $(obj)/vde.o: $(obj)/vde_kern.o $(obj)/vde_user.o # When the above is fixed, don't forget to add this too! #targets += $(obj)/pcap.o -obj-y := stdio_console.o fd.o chan_kern.o chan_user.o line.o +ifndef CONFIG_UMMODE_LIB +obj-y := stdio_console.o +else +obj-y := +endif +obj-y += fd.o chan_kern.o chan_user.o line.o + obj-$(CONFIG_SSL) += ssl.o obj-$(CONFIG_STDERR_CONSOLE) += stderr_console.o diff --git a/arch/um/lkl/include/uapi/asm/host_ops.h b/arch/um/lkl/include/uapi/asm/host_ops.h index b97aa1099a17..976fc4301b3d 100644 --- a/arch/um/lkl/include/uapi/asm/host_ops.h +++ b/arch/um/lkl/include/uapi/asm/host_ops.h @@ -243,4 +243,13 @@ int lkl_tls_set(struct lkl_tls_key *key, void *data); */ void *lkl_tls_get(struct lkl_tls_key *key); +/** + * lkl_print - optional operation that receives console messages + * + * @str: strings to be printed + * @len: the length of @str + * + */ +void lkl_print(const char *str, int len); + #endif diff --git a/arch/um/lkl/um/console.c b/arch/um/lkl/um/console.c new file mode 100644 index 000000000000..f2b48dc7ae22 --- /dev/null +++ b/arch/um/lkl/um/console.c @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: GPL-2.0 +#include <linux/init.h> +#include <linux/kernel.h> +#include <linux/console.h> +#include <asm/host_ops.h> + +static void console_write(struct console *con, const char *str, unsigned len) +{ + lkl_print(str, len); +} + +#ifdef CONFIG_LKL_EARLY_CONSOLE +static struct console lkl_boot_console = { + .name = "lkl_boot_console", + .write = console_write, + .flags = CON_PRINTBUFFER | CON_BOOT, + .index = -1, +}; + +int __init lkl_boot_console_init(void) +{ + register_console(&lkl_boot_console); + return 0; +} +early_initcall(lkl_boot_console_init); +#endif + +static struct console lkl_console = { + .name = "lkl_console", + .write = console_write, + .flags = CON_PRINTBUFFER, + .index = -1, +}; + +int __init lkl_console_init(void) +{ + register_console(&lkl_console); + return 0; +} +core_initcall(lkl_console_init); +
This patch adds a basic structure of console support in kernel. Write operations are deferred to the host print operation. This commit also disables stdio-console of UML when library mode to avoid conflicts between multiple consoles. Signed-off-by: Hajime Tazaki <thehajime@gmail.com> --- arch/um/drivers/Makefile | 8 ++++- arch/um/lkl/include/uapi/asm/host_ops.h | 9 ++++++ arch/um/lkl/um/console.c | 41 +++++++++++++++++++++++++ 3 files changed, 57 insertions(+), 1 deletion(-) create mode 100644 arch/um/lkl/um/console.c