summaryrefslogtreecommitdiffstats
path: root/sys/dev/uart/uart_cpu.h
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2006-03-30 18:37:03 +0000
committermarcel <marcel@FreeBSD.org>2006-03-30 18:37:03 +0000
commit11ffb007e1549b15e2bf78d86bac71a035dbfe40 (patch)
tree2ef44b482f61d5295bba3a89871f7ab766e70886 /sys/dev/uart/uart_cpu.h
parent0215f8085c24d9281307a8a89dd8c19cbd285316 (diff)
downloadFreeBSD-src-11ffb007e1549b15e2bf78d86bac71a035dbfe40.zip
FreeBSD-src-11ffb007e1549b15e2bf78d86bac71a035dbfe40.tar.gz
Add support for scc(4).
Diffstat (limited to 'sys/dev/uart/uart_cpu.h')
-rw-r--r--sys/dev/uart/uart_cpu.h47
1 files changed, 44 insertions, 3 deletions
diff --git a/sys/dev/uart/uart_cpu.h b/sys/dev/uart/uart_cpu.h
index 702ee5e..310d6b9 100644
--- a/sys/dev/uart/uart_cpu.h
+++ b/sys/dev/uart/uart_cpu.h
@@ -29,6 +29,10 @@
#ifndef _DEV_UART_CPU_H_
#define _DEV_UART_CPU_H_
+#include <sys/kdb.h>
+#include <sys/lock.h>
+#include <sys/mutex.h>
+
/*
* Low-level operations for use by console and/or debug port support.
*/
@@ -68,6 +72,7 @@ struct uart_devinfo {
int (*attach)(struct uart_softc*);
int (*detach)(struct uart_softc*);
void *cookie; /* Type dependent use. */
+ struct mtx *hwmtx;
};
int uart_cpu_eqres(struct uart_bas *, struct uart_bas *);
@@ -80,41 +85,77 @@ void uart_add_sysdev(struct uart_devinfo *);
* Operations for low-level access to the UART. Primarily for use
* by console and debug port logic.
*/
+
+static __inline void
+uart_lock(struct mtx *hwmtx)
+{
+ if (!kdb_active && hwmtx != NULL)
+ mtx_lock_spin(hwmtx);
+}
+
+static __inline void
+uart_unlock(struct mtx *hwmtx)
+{
+ if (!kdb_active && hwmtx != NULL)
+ mtx_unlock_spin(hwmtx);
+}
+
static __inline int
uart_probe(struct uart_devinfo *di)
{
- return (di->ops.probe(&di->bas));
+ int res;
+
+ uart_lock(di->hwmtx);
+ res = di->ops.probe(&di->bas);
+ uart_unlock(di->hwmtx);
+ return (res);
}
static __inline void
uart_init(struct uart_devinfo *di)
{
+ uart_lock(di->hwmtx);
di->ops.init(&di->bas, di->baudrate, di->databits, di->stopbits,
di->parity);
+ uart_unlock(di->hwmtx);
}
static __inline void
uart_term(struct uart_devinfo *di)
{
+ uart_lock(di->hwmtx);
di->ops.term(&di->bas);
+ uart_unlock(di->hwmtx);
}
static __inline void
uart_putc(struct uart_devinfo *di, int c)
{
+ uart_lock(di->hwmtx);
di->ops.putc(&di->bas, c);
+ uart_unlock(di->hwmtx);
}
static __inline int
uart_poll(struct uart_devinfo *di)
{
- return (di->ops.poll(&di->bas));
+ int res;
+
+ uart_lock(di->hwmtx);
+ res = di->ops.poll(&di->bas);
+ uart_unlock(di->hwmtx);
+ return (res);
}
static __inline int
uart_getc(struct uart_devinfo *di)
{
- return (di->ops.getc(&di->bas));
+ int res;
+
+ uart_lock(di->hwmtx);
+ res = di->ops.getc(&di->bas);
+ uart_unlock(di->hwmtx);
+ return (res);
}
#endif /* _DEV_UART_CPU_H_ */
OpenPOWER on IntegriCloud