Module Name: src
Committed By: uwe
Date: Mon Jul 20 01:06:33 UTC 2020
Modified Files:
src/sys/arch/evbsh3/nextvod: stasc.c
Log Message:
Implement cngetc to be able to talk to DDB.
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/evbsh3/nextvod/stasc.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/evbsh3/nextvod/stasc.c
diff -u src/sys/arch/evbsh3/nextvod/stasc.c:1.1 src/sys/arch/evbsh3/nextvod/stasc.c:1.2
--- src/sys/arch/evbsh3/nextvod/stasc.c:1.1 Sun Jul 19 23:44:36 2020
+++ src/sys/arch/evbsh3/nextvod/stasc.c Mon Jul 20 01:06:33 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: stasc.c,v 1.1 2020/07/19 23:44:36 uwe Exp $ */
+/* $NetBSD: stasc.c,v 1.2 2020/07/20 01:06:33 uwe Exp $ */
/*
* Copyright (c) 2020 Valery Ushakov
* All rights reserved.
@@ -28,7 +28,7 @@
* STMicroelectronics ST40 Asynchronous Serial Controller
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: stasc.c,v 1.1 2020/07/19 23:44:36 uwe Exp $");
+__KERNEL_RCSID(0, "$NetBSD: stasc.c,v 1.2 2020/07/20 01:06:33 uwe Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -54,6 +54,7 @@ __KERNEL_RCSID(0, "$NetBSD: stasc.c,v 1.
#define ASC_RETRIES_OFFSET 0x28
#define ASC_TX_BUFF (*(volatile uint32_t *)(STM_ASC_BASE + ASC_TX_BUFF_OFFSET))
+#define ASC_RX_BUFF (*(volatile uint32_t *)(STM_ASC_BASE + ASC_RX_BUFF_OFFSET))
#define ASC_INT_EN (*(volatile uint32_t *)(STM_ASC_BASE + ASC_INT_EN_OFFSET))
#define ASC_INT_STA (*(volatile uint32_t *)(STM_ASC_BASE + ASC_INT_STA_OFFSET))
@@ -183,22 +184,39 @@ stasc_cninit(struct consdev *cp)
int
stasc_cngetc(dev_t dev)
{
- return -1;
+ int s = splserial();
+ uint32_t status;
+ int c;
+
+ /* don't block if Rx buffer is empty */
+ status = ASC_INT_STA;
+ if (!ISSET(status, ASC_INT_STA_RBF)) {
+ splx(s);
+ return -1;
+ }
+
+ /* can read the character now */
+ c = ASC_RX_BUFF;
+ splx(s);
+ return (unsigned char)c;
}
void
stasc_cnputc(dev_t dev, int c)
{
- uint32_t status;
+ int s = splserial();
+ uint32_t timo, status;
- /* wait for Tx FULL to become zero */
+ /* wait for Tx Full to become clear */
+ timo = 150000;
do {
status = ASC_INT_STA;
- } while ((status & ASC_INT_STA_TF) != 0);
+ } while (ISSET(status, ASC_INT_STA_TF) && --timo);
/* can write the character now */
ASC_TX_BUFF = c;
+ splx(s);
}