Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/riscv Use legacy SBI Console GetChar for earlycons....



details:   https://anonhg.NetBSD.org/src/rev/6211bb9eef5e
branches:  trunk
changeset: 371194:6211bb9eef5e
user:      skrll <skrll%NetBSD.org@localhost>
date:      Wed Sep 28 06:05:28 2022 +0000

description:
Use legacy SBI Console GetChar for earlycons.  It works on qemu.

diffstat:

 sys/arch/riscv/include/machdep.h     |   5 +++--
 sys/arch/riscv/riscv/locore.S        |  15 +++++++++++++--
 sys/arch/riscv/riscv/riscv_machdep.c |   6 +++---
 3 files changed, 19 insertions(+), 7 deletions(-)

diffs (89 lines):

diff -r 84e068611ad2 -r 6211bb9eef5e sys/arch/riscv/include/machdep.h
--- a/sys/arch/riscv/include/machdep.h  Wed Sep 28 05:54:24 2022 +0000
+++ b/sys/arch/riscv/include/machdep.h  Wed Sep 28 06:05:28 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.h,v 1.1 2022/09/20 07:18:23 skrll Exp $        */
+/*     $NetBSD: machdep.h,v 1.2 2022/09/28 06:05:28 skrll Exp $        */
 
 /*-
  * Copyright (c) 2022 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #define _RISCV_MACHDEP_H_
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.h,v 1.1 2022/09/20 07:18:23 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.h,v 1.2 2022/09/28 06:05:28 skrll Exp $");
 
 #include <sys/proc.h>
 #include <sys/lwp.h>
@@ -60,6 +60,7 @@
 
 
 void   uartputc(int);
+int    uartgetc(void);
 
 paddr_t        init_mmu(paddr_t);
 void   init_riscv(register_t, vaddr_t);
diff -r 84e068611ad2 -r 6211bb9eef5e sys/arch/riscv/riscv/locore.S
--- a/sys/arch/riscv/riscv/locore.S     Wed Sep 28 05:54:24 2022 +0000
+++ b/sys/arch/riscv/riscv/locore.S     Wed Sep 28 06:05:28 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: locore.S,v 1.27 2022/09/28 05:02:02 skrll Exp $ */
+/* $NetBSD: locore.S,v 1.28 2022/09/28 06:05:28 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014, 2022 The NetBSD Foundation, Inc.
@@ -408,7 +408,7 @@
 #ifdef EARLYCONS
        tail    ___CONCAT(EARLYCONS, _platform_early_putchar)
 #else
-#define SBI_LEGACY_CONSOLE_PUTCHAR        1
+#define        SBI_LEGACY_CONSOLE_PUTCHAR      1
        li      a7, SBI_LEGACY_CONSOLE_PUTCHAR
        ecall
        ret
@@ -416,6 +416,17 @@
 END(uartputc)
 
 
+ENTRY_NP(uartgetc)
+#ifdef EARLYCONS
+       li      a0, -1
+#else
+#define        SBI_LEGACY_CONSOLE_GETCHAR      2
+       li      a7, SBI_LEGACY_CONSOLE_GETCHAR
+       ecall
+       ret
+#endif
+
+
 ENTRY_NP(clear_bss)
        bgeu    a0, a1, 1f
 2:
diff -r 84e068611ad2 -r 6211bb9eef5e sys/arch/riscv/riscv/riscv_machdep.c
--- a/sys/arch/riscv/riscv/riscv_machdep.c      Wed Sep 28 05:54:24 2022 +0000
+++ b/sys/arch/riscv/riscv/riscv_machdep.c      Wed Sep 28 06:05:28 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: riscv_machdep.c,v 1.18 2022/09/20 07:18:24 skrll Exp $ */
+/*     $NetBSD: riscv_machdep.c,v 1.19 2022/09/28 06:05:28 skrll Exp $ */
 
 /*-
  * Copyright (c) 2014, 2019, 2022 The NetBSD Foundation, Inc.
@@ -33,7 +33,7 @@
 #include "opt_riscv_debug.h"
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: riscv_machdep.c,v 1.18 2022/09/20 07:18:24 skrll Exp $");
+__RCSID("$NetBSD: riscv_machdep.c,v 1.19 2022/09/28 06:05:28 skrll Exp $");
 
 #include <sys/param.h>
 
@@ -87,7 +87,7 @@
 static int
 earlyconsgetc(dev_t dev)
 {
-       return 0;
+       return uartgetc();
 }
 
 static struct consdev earlycons = {



Home | Main Index | Thread Index | Old Index