Module Name:    src
Committed By:   skrll
Date:           Wed Sep 28 06:05:28 UTC 2022

Modified Files:
        src/sys/arch/riscv/include: machdep.h
        src/sys/arch/riscv/riscv: locore.S riscv_machdep.c

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


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/riscv/include/machdep.h
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/riscv/riscv/locore.S
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/riscv/riscv/riscv_machdep.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/riscv/include/machdep.h
diff -u src/sys/arch/riscv/include/machdep.h:1.1 src/sys/arch/riscv/include/machdep.h:1.2
--- src/sys/arch/riscv/include/machdep.h:1.1	Tue Sep 20 07:18:23 2022
+++ src/sys/arch/riscv/include/machdep.h	Wed Sep 28 06:05:28 2022
@@ -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 @@ riscv_kern_phystov(paddr_t pa)
 
 
 void	uartputc(int);
+int	uartgetc(void);
 
 paddr_t	init_mmu(paddr_t);
 void	init_riscv(register_t, vaddr_t);

Index: src/sys/arch/riscv/riscv/locore.S
diff -u src/sys/arch/riscv/riscv/locore.S:1.27 src/sys/arch/riscv/riscv/locore.S:1.28
--- src/sys/arch/riscv/riscv/locore.S:1.27	Wed Sep 28 05:02:02 2022
+++ src/sys/arch/riscv/riscv/locore.S	Wed Sep 28 06:05:28 2022
@@ -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 @@ ENTRY_NP(uartputc)
 #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 @@ ENTRY_NP(uartputc)
 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:

Index: src/sys/arch/riscv/riscv/riscv_machdep.c
diff -u src/sys/arch/riscv/riscv/riscv_machdep.c:1.18 src/sys/arch/riscv/riscv/riscv_machdep.c:1.19
--- src/sys/arch/riscv/riscv/riscv_machdep.c:1.18	Tue Sep 20 07:18:24 2022
+++ src/sys/arch/riscv/riscv/riscv_machdep.c	Wed Sep 28 06:05:28 2022
@@ -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 @@ earlyconsputc(dev_t dev, int c)
 static int
 earlyconsgetc(dev_t dev)
 {
-	return 0;
+	return uartgetc();
 }
 
 static struct consdev earlycons = {

Reply via email to