summaryrefslogtreecommitdiffstats
path: root/sys/dev/uart/uart_cpu.h
diff options
context:
space:
mode:
authormarcel <marcel@FreeBSD.org>2007-04-02 22:00:22 +0000
committermarcel <marcel@FreeBSD.org>2007-04-02 22:00:22 +0000
commitf30daf4b49b0b9e3c8eeb46082244bf7a7f354ae (patch)
treeb3ad51f3cb65c3badfb015aea4f71d800157abb8 /sys/dev/uart/uart_cpu.h
parent5f0f57215ba83757397d27e8dcc686612e48e921 (diff)
downloadFreeBSD-src-f30daf4b49b0b9e3c8eeb46082244bf7a7f354ae.zip
FreeBSD-src-f30daf4b49b0b9e3c8eeb46082244bf7a7f354ae.tar.gz
Don't expose the uart_ops structure directly, but instead have
it obtained through the uart_class structure. This allows us to declare the uart_class structure as weak and as such allows us to reference it even when it's not compiled-in. It also allows is to get the uart_ops structure by name, which makes it possible to implement the dt tag handling in uart_getenv(). The side-effect of all this is that we're using the uart_class structure more consistently which means that we now also have access to the size of the bus space block needed by the hardware when we map the bus space, eliminating any hardcoding.
Diffstat (limited to 'sys/dev/uart/uart_cpu.h')
-rw-r--r--sys/dev/uart/uart_cpu.h29
1 files changed, 14 insertions, 15 deletions
diff --git a/sys/dev/uart/uart_cpu.h b/sys/dev/uart/uart_cpu.h
index b41ed50..db64d49 100644
--- a/sys/dev/uart/uart_cpu.h
+++ b/sys/dev/uart/uart_cpu.h
@@ -45,11 +45,6 @@ struct uart_ops {
int (*getc)(struct uart_bas *, struct mtx *);
};
-extern struct uart_ops uart_i8251_ops;
-extern struct uart_ops uart_ns8250_ops;
-extern struct uart_ops uart_sab82532_ops;
-extern struct uart_ops uart_z8530_ops;
-
extern bus_space_tag_t uart_bus_space_io;
extern bus_space_tag_t uart_bus_space_mem;
@@ -59,7 +54,7 @@ extern bus_space_tag_t uart_bus_space_mem;
struct uart_softc;
struct uart_devinfo {
SLIST_ENTRY(uart_devinfo) next;
- struct uart_ops ops;
+ struct uart_ops *ops;
struct uart_bas bas;
int baudrate;
int databits;
@@ -77,7 +72,11 @@ struct uart_devinfo {
int uart_cpu_eqres(struct uart_bas *, struct uart_bas *);
int uart_cpu_getdev(int, struct uart_devinfo *);
-int uart_getenv(int, struct uart_devinfo *);
+
+int uart_getenv(int, struct uart_devinfo *, struct uart_class *);
+const char *uart_getname(struct uart_class *);
+struct uart_ops *uart_getops(struct uart_class *);
+int uart_getrange(struct uart_class *);
void uart_add_sysdev(struct uart_devinfo *);
@@ -106,7 +105,7 @@ uart_probe(struct uart_devinfo *di)
int res;
uart_lock(di->hwmtx);
- res = di->ops.probe(&di->bas);
+ res = di->ops->probe(&di->bas);
uart_unlock(di->hwmtx);
return (res);
}
@@ -115,7 +114,7 @@ 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->ops->init(&di->bas, di->baudrate, di->databits, di->stopbits,
di->parity);
uart_unlock(di->hwmtx);
}
@@ -124,7 +123,7 @@ static __inline void
uart_term(struct uart_devinfo *di)
{
uart_lock(di->hwmtx);
- di->ops.term(&di->bas);
+ di->ops->term(&di->bas);
uart_unlock(di->hwmtx);
}
@@ -132,7 +131,7 @@ static __inline void
uart_putc(struct uart_devinfo *di, int c)
{
uart_lock(di->hwmtx);
- di->ops.putc(&di->bas, c);
+ di->ops->putc(&di->bas, c);
uart_unlock(di->hwmtx);
}
@@ -142,7 +141,7 @@ uart_rxready(struct uart_devinfo *di)
int res;
uart_lock(di->hwmtx);
- res = di->ops.rxready(&di->bas);
+ res = di->ops->rxready(&di->bas);
uart_unlock(di->hwmtx);
return (res);
}
@@ -153,8 +152,8 @@ uart_poll(struct uart_devinfo *di)
int res;
uart_lock(di->hwmtx);
- if (di->ops.rxready(&di->bas))
- res = di->ops.getc(&di->bas, NULL);
+ if (di->ops->rxready(&di->bas))
+ res = di->ops->getc(&di->bas, NULL);
else
res = -1;
uart_unlock(di->hwmtx);
@@ -165,7 +164,7 @@ static __inline int
uart_getc(struct uart_devinfo *di)
{
- return (di->ops.getc(&di->bas, di->hwmtx));
+ return (di->ops->getc(&di->bas, di->hwmtx));
}
#endif /* _DEV_UART_CPU_H_ */
OpenPOWER on IntegriCloud