summaryrefslogtreecommitdiffstats
path: root/sys/dev/uart/uart_cpu_i386.c
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_i386.c
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_i386.c')
-rw-r--r--sys/dev/uart/uart_cpu_i386.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/sys/dev/uart/uart_cpu_i386.c b/sys/dev/uart/uart_cpu_i386.c
index c8e2e2e..0d0f0f7 100644
--- a/sys/dev/uart/uart_cpu_i386.c
+++ b/sys/dev/uart/uart_cpu_i386.c
@@ -49,11 +49,15 @@ uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2)
int
uart_cpu_getdev(int devtype, struct uart_devinfo *di)
{
+ struct uart_class *class;
unsigned int i, ivar;
+ class = &uart_ns8250_class;
+ if (class == NULL)
+ return (ENXIO);
+
/* Check the environment. */
- di->ops = uart_ns8250_ops;
- if (uart_getenv(devtype, di) == 0)
+ if (uart_getenv(devtype, di, class) == 0)
return (0);
/*
@@ -82,10 +86,11 @@ uart_cpu_getdev(int devtype, struct uart_devinfo *di)
* Got it. Fill in the instance and return it. We only have
* ns8250 and successors on i386.
*/
- di->ops = uart_ns8250_ops;
+ di->ops = uart_getops(class);
di->bas.chan = 0;
di->bas.bst = uart_bus_space_io;
- if (bus_space_map(di->bas.bst, ivar, 8, 0, &di->bas.bsh) != 0)
+ if (bus_space_map(di->bas.bst, ivar, uart_getrange(class), 0,
+ &di->bas.bsh) != 0)
continue;
di->bas.regshft = 0;
di->bas.rclk = 0;
OpenPOWER on IntegriCloud