Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/evbsh3/nextvod Implement cngetc to be able to talk ...
details: https://anonhg.NetBSD.org/src/rev/dd2924374975
branches: trunk
changeset: 1012029:dd2924374975
user: uwe <uwe%NetBSD.org@localhost>
date: Mon Jul 20 01:06:33 2020 +0000
description:
Implement cngetc to be able to talk to DDB.
diffstat:
sys/arch/evbsh3/nextvod/stasc.c | 30 ++++++++++++++++++++++++------
1 files changed, 24 insertions(+), 6 deletions(-)
diffs (70 lines):
diff -r 00569a21c9cf -r dd2924374975 sys/arch/evbsh3/nextvod/stasc.c
--- a/sys/arch/evbsh3/nextvod/stasc.c Sun Jul 19 23:44:36 2020 +0000
+++ b/sys/arch/evbsh3/nextvod/stasc.c Mon Jul 20 01:06:33 2020 +0000
@@ -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 @@
#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 @@
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);
}
Home |
Main Index |
Thread Index |
Old Index