From: kettenis Date: Sat, 1 May 2021 12:29:05 +0000 (+0000) Subject: Implement early console functionality based on available SBI calls. X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=76154e282cbf409aaa938ddefcaf904b5ab5d226;p=openbsd Implement early console functionality based on available SBI calls. While these calls are part of the legacy extensions and deprecated, they are really useful for debugging purposes. ok jsg@ --- diff --git a/sys/arch/riscv64/conf/files.riscv64 b/sys/arch/riscv64/conf/files.riscv64 index 2e08f6b1d0b..6111eec5a5d 100644 --- a/sys/arch/riscv64/conf/files.riscv64 +++ b/sys/arch/riscv64/conf/files.riscv64 @@ -8,8 +8,6 @@ major { sd = 0 } #major { wd = 4 } major { rd = 8 } -file dev/cninit.c - file arch/riscv64/riscv64/autoconf.c file arch/riscv64/riscv64/ast.c file arch/riscv64/riscv64/bus_space.c diff --git a/sys/arch/riscv64/riscv64/machdep.c b/sys/arch/riscv64/riscv64/machdep.c index 834631f275e..90da72abc14 100644 --- a/sys/arch/riscv64/riscv64/machdep.c +++ b/sys/arch/riscv64/riscv64/machdep.c @@ -75,8 +75,6 @@ struct vm_map *phys_map = NULL; int physmem; -//struct consdev *cn_tab; - caddr_t msgbufaddr; paddr_t msgbufphys; @@ -180,12 +178,6 @@ consinit(void) com_fdt_init_cons(); } -//XXX TODO: need to populate console for qemu -//maybe no longer needed, as already have cn_tab ?? -struct consdev constab[] = { - { NULL } -}; - void cpu_idle_enter(void) { @@ -919,5 +911,3 @@ pmap_bootstrap_bs_map(bus_space_tag_t t, bus_addr_t bpa, bus_size_t size, return 0; } - - diff --git a/sys/arch/riscv64/riscv64/sbi.c b/sys/arch/riscv64/riscv64/sbi.c index a988a652253..02deb807cc7 100644 --- a/sys/arch/riscv64/riscv64/sbi.c +++ b/sys/arch/riscv64/riscv64/sbi.c @@ -25,17 +25,14 @@ * SUCH DAMAGE. */ -#include - #include #include #include -#if 0 -#include -#endif #include +#include + /* SBI Implementation-Specific Definitions */ #define OPENSBI_VERSION_MAJOR_OFFSET 16 #define OPENSBI_VERSION_MINOR_MASK 0xFFFF @@ -167,3 +164,52 @@ sbi_init(void) KASSERTMSG(sbi_probe_extension(SBI_SHUTDOWN) != 0, "SBI doesn't implement sbi_shutdown()"); } + +/* + * Early console implementation based on the Console Putchar and + * Console Getchar legacy extensions. These extensions are deprecated + * but extremely useful for bringing up new boards. + */ + +void +sbi_cnprobe(struct consdev *cd) +{ +} + +void +sbi_cninit(struct consdev *cd) +{ +} + +int +sbi_cngetc(dev_t dev) +{ + int c; + + for (;;) { + c = sbi_console_getchar(); + if (c != -1) + return c; + } +} + +void +sbi_cnputc(dev_t dev, int c) +{ + sbi_console_putchar(c); +} + +void +sbi_cnpollc(dev_t dev, int on) +{ +} + +struct consdev sbi_consdev = { + .cn_probe = sbi_cnprobe, + .cn_init = sbi_cninit, + .cn_getc = sbi_cngetc, + .cn_putc = sbi_cnputc, + .cn_pollc = sbi_cnpollc, +}; + +struct consdev *cn_tab = &sbi_consdev;