From: Bobby Eshleman <bobby.eshleman@gmail.com>
To: Alistair Francis <alistair23@gmail.com>
Cc: Alistair Francis <alistair.francis@wdc.com>,
Andrew Cooper <andrew.cooper3@citrix.com>,
Connor Davis <connojdavis@gmail.com>,
Gianluca Guida <gianluca@rivosinc.com>,
Jan Beulich <jbeulich@suse.com>, Julien Grall <julien@xen.org>,
Oleksii Kurochko <oleksii.kurochko@gmail.com>,
Stefano Stabellini <sstabellini@kernel.org>,
xen-devel@lists.xenproject.org
Subject: Re: [PATCH v2 6/8] xen/riscv: introduce early_printk basic stuff
Date: Mon, 9 Jan 2023 23:28:56 -0800 [thread overview]
Message-ID: <CAKB00G3nVtcBppt2TJa-dFzz4TKqVT6B-1swjzkZwqsRkFxwsA@mail.gmail.com> (raw)
In-Reply-To: <CAKmqyKNyRfAhyP-3uZwEf3OZEv5be4KNdGvNjUiQGu8w-vf_8g@mail.gmail.com>
[-- Attachment #1: Type: text/plain, Size: 4494 bytes --]
On Mon, Jan 9, 2023 at 4:28 PM Alistair Francis <alistair23@gmail.com>
wrote:
> On Tue, Jan 10, 2023 at 1:47 AM Oleksii Kurochko
> <oleksii.kurochko@gmail.com> wrote:
> >
> > The patch introduces a basic stuff of early_printk functionality
> > which will be enough to print 'hello from C environment".
> > early_printk() function was changed in comparison with original as
> > common isn't being built now so there is no vscnprintf.
> >
> > Because printk() relies on a serial driver (like the ns16550 driver)
> > and drivers require working virtual memory (ioremap()) there is not
> > print functionality early in Xen boot.
> >
> > This commit adds early printk implementation built on the putc SBI call.
> >
> > As sbi_console_putchar() is being already planned for deprecation
> > it is used temporary now and will be removed or reworked after
> > real uart will be ready.
>
> There was a discussion to add a new SBI putchar replacement. It
> doesn't seem to be completed yet, but there might be an SBI
> replacement for this in the future as well.
>
> Alistair
>
Are you referring to the Debug Console Extension (EID #0x4442434E "DBCN")”?
https://lists.riscv.org/g/tech-prs/topic/96051183#84
Best,
Bobby
> >
> > Signed-off-by: Bobby Eshleman <bobby.eshleman@gmail.com>
> > Signed-off-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
> > ---
> > Changes in V2:
> > - add license to early_printk.c
> > - add signed-off-by Bobby
> > - add RISCV_32 to Kconfig.debug to EARLY_PRINTK config
> > - update commit message
> > - order the files alphabetically in Makefile
> > ---
> > xen/arch/riscv/Kconfig.debug | 7 +++++
> > xen/arch/riscv/Makefile | 1 +
> > xen/arch/riscv/early_printk.c | 33 +++++++++++++++++++++++
> > xen/arch/riscv/include/asm/early_printk.h | 12 +++++++++
> > 4 files changed, 53 insertions(+)
> > create mode 100644 xen/arch/riscv/early_printk.c
> > create mode 100644 xen/arch/riscv/include/asm/early_printk.h
> >
> > diff --git a/xen/arch/riscv/Kconfig.debug b/xen/arch/riscv/Kconfig.debug
> > index e69de29bb2..6ba0bd1e5a 100644
> > --- a/xen/arch/riscv/Kconfig.debug
> > +++ b/xen/arch/riscv/Kconfig.debug
> > @@ -0,0 +1,7 @@
> > +config EARLY_PRINTK
> > + bool "Enable early printk config"
> > + 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..88da5169ed
> > --- /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/sbi.h>
> > +#include <asm/early_printk.h>
> > +
> > +/*
> > + * TODO:
> > + * sbi_console_putchar is already planned for deprication
> > + * 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__ */
> > --
> > 2.38.1
> >
> >
>
[-- Attachment #2: Type: text/html, Size: 6858 bytes --]
next prev parent reply other threads:[~2023-01-10 7:29 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-09 15:46 [PATCH v2 0/8] Basic early_printk and smoke test implementation Oleksii Kurochko
2023-01-09 15:46 ` [PATCH v2 1/8] xen/riscv: introduce dummy asm/init.h Oleksii Kurochko
2023-01-09 15:46 ` [PATCH v2 2/8] xen/riscv: introduce asm/types.h header file Oleksii Kurochko
2023-01-09 15:46 ` [PATCH v2 3/8] xen/riscv: introduce stack stuff Oleksii Kurochko
2023-01-09 16:11 ` Julien Grall
2023-01-10 8:29 ` Oleksii
2023-01-09 16:19 ` Jan Beulich
2023-01-09 15:46 ` [PATCH v2 4/8] xen/riscv: introduce sbi call to putchar to console Oleksii Kurochko
2023-01-09 16:00 ` Jan Beulich
2023-01-10 8:18 ` Oleksii
2023-01-09 16:03 ` Julien Grall
2023-01-10 8:21 ` Oleksii
2023-01-10 12:43 ` Julien Grall
2023-01-10 12:44 ` Julien Grall
2023-01-09 15:46 ` [PATCH v2 5/8] xen/include: include <asm/types.h> in <xen/early_printk.h> Oleksii Kurochko
2023-01-09 15:46 ` [PATCH v2 6/8] xen/riscv: introduce early_printk basic stuff Oleksii Kurochko
2023-01-09 16:07 ` Julien Grall
2023-01-09 16:22 ` Jan Beulich
2023-01-10 0:28 ` Alistair Francis
2023-01-10 7:28 ` Bobby Eshleman [this message]
2023-01-10 10:47 ` Alistair Francis
2023-01-09 15:46 ` [PATCH v2 7/8] xen/riscv: print hello message from C env Oleksii Kurochko
2023-01-10 0:29 ` Alistair Francis
2023-01-09 15:46 ` [PATCH v2 8/8] automation: add RISC-V smoke test Oleksii Kurochko
2023-01-10 2:21 ` Stefano Stabellini
2023-01-10 8:09 ` Oleksii
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAKB00G3nVtcBppt2TJa-dFzz4TKqVT6B-1swjzkZwqsRkFxwsA@mail.gmail.com \
--to=bobby.eshleman@gmail.com \
--cc=alistair.francis@wdc.com \
--cc=alistair23@gmail.com \
--cc=andrew.cooper3@citrix.com \
--cc=connojdavis@gmail.com \
--cc=gianluca@rivosinc.com \
--cc=jbeulich@suse.com \
--cc=julien@xen.org \
--cc=oleksii.kurochko@gmail.com \
--cc=sstabellini@kernel.org \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).