Message ID | 25cd3586fa51980279f25a82eed5ded1622bc212.1673362493.git.oleksii.kurochko@gmail.com (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | Basic early_printk and smoke test implementation | expand |
On 10.01.2023 16:17, Oleksii Kurochko wrote: > --- a/xen/arch/riscv/Kconfig.debug > +++ b/xen/arch/riscv/Kconfig.debug > @@ -0,0 +1,7 @@ > +config EARLY_PRINTK > + bool "Enable early printk" > + default DEBUG > + depends on RISCV_64 || RISCV_32 You're in a RISC-V-specific Kconfig - do you really need this line? > --- /dev/null > +++ b/xen/arch/riscv/early_printk.c > @@ -0,0 +1,33 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * RISC-V early printk using SBI > + * > + * Copyright (C) 2021 Bobby Eshleman <bobbyeshleman@gmail.com> > + */ > +#include <asm/early_printk.h> > +#include <asm/sbi.h> > + > +/* > + * TODO: > + * sbi_console_putchar is already planned for deprecation > + * so it should be reworked to use UART directly. > +*/ > +void early_puts(const char *s, size_t nr) > +{ > + while ( nr-- > 0 ) > + { > + if (*s == '\n') Nit (style): Missing blanks. > + sbi_console_putchar('\r'); > + sbi_console_putchar(*s); > + s++; > + } > +} > + > +void early_printk(const char *str) > +{ > + while (*str) Again. > --- a/xen/arch/riscv/setup.c > +++ b/xen/arch/riscv/setup.c > @@ -1,12 +1,16 @@ > #include <xen/compile.h> > #include <xen/init.h> > > +#include <asm/early_printk.h> > + > /* Xen stack for bringing up the first CPU. */ > unsigned char __initdata cpu0_boot_stack[STACK_SIZE] > __aligned(STACK_SIZE); > > void __init noreturn start_xen(void) > { > + early_printk("Hello from C env\n"); > + > for ( ;; ) > asm volatile ("wfi"); While this is only context here, it affects an earlier patch in the series; this wants to be for ( ; ; ) asm volatile ( "wfi" ); Jan
diff --git a/xen/arch/riscv/Kconfig.debug b/xen/arch/riscv/Kconfig.debug index e69de29bb2..e21649781d 100644 --- a/xen/arch/riscv/Kconfig.debug +++ b/xen/arch/riscv/Kconfig.debug @@ -0,0 +1,7 @@ +config EARLY_PRINTK + bool "Enable early printk" + default DEBUG + depends on RISCV_64 || RISCV_32 + help + + Enables early printk debug messages diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile index fd916e1004..1a4f1a6015 100644 --- a/xen/arch/riscv/Makefile +++ b/xen/arch/riscv/Makefile @@ -1,3 +1,4 @@ +obj-$(CONFIG_EARLY_PRINTK) += early_printk.o obj-$(CONFIG_RISCV_64) += riscv64/ obj-y += sbi.o obj-y += setup.o diff --git a/xen/arch/riscv/early_printk.c b/xen/arch/riscv/early_printk.c new file mode 100644 index 0000000000..348c21bdaa --- /dev/null +++ b/xen/arch/riscv/early_printk.c @@ -0,0 +1,33 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * RISC-V early printk using SBI + * + * Copyright (C) 2021 Bobby Eshleman <bobbyeshleman@gmail.com> + */ +#include <asm/early_printk.h> +#include <asm/sbi.h> + +/* + * TODO: + * sbi_console_putchar is already planned for deprecation + * so it should be reworked to use UART directly. +*/ +void early_puts(const char *s, size_t nr) +{ + while ( nr-- > 0 ) + { + if (*s == '\n') + sbi_console_putchar('\r'); + sbi_console_putchar(*s); + s++; + } +} + +void early_printk(const char *str) +{ + while (*str) + { + early_puts(str, 1); + str++; + } +} diff --git a/xen/arch/riscv/include/asm/early_printk.h b/xen/arch/riscv/include/asm/early_printk.h new file mode 100644 index 0000000000..05106e160d --- /dev/null +++ b/xen/arch/riscv/include/asm/early_printk.h @@ -0,0 +1,12 @@ +#ifndef __EARLY_PRINTK_H__ +#define __EARLY_PRINTK_H__ + +#include <xen/early_printk.h> + +#ifdef CONFIG_EARLY_PRINTK +void early_printk(const char *str); +#else +static inline void early_printk(const char *s) {}; +#endif + +#endif /* __EARLY_PRINTK_H__ */ diff --git a/xen/arch/riscv/setup.c b/xen/arch/riscv/setup.c index 13e24e2fe1..d09ffe1454 100644 --- a/xen/arch/riscv/setup.c +++ b/xen/arch/riscv/setup.c @@ -1,12 +1,16 @@ #include <xen/compile.h> #include <xen/init.h> +#include <asm/early_printk.h> + /* Xen stack for bringing up the first CPU. */ unsigned char __initdata cpu0_boot_stack[STACK_SIZE] __aligned(STACK_SIZE); void __init noreturn start_xen(void) { + early_printk("Hello from C env\n"); + for ( ;; ) asm volatile ("wfi");