Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Aug 2003 18:27:14 -0700 (PDT)
From:      Marcel Moolenaar <marcel@FreeBSD.org>
To:        Perforce Change Reviews <perforce@freebsd.org>
Subject:   PERFORCE change 37001 for review
Message-ID:  <200308270127.h7R1REOU034403@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=37001

Change 37001 by marcel@marcel_nfs on 2003/08/26 18:27:02

	Teach the uart core code about keyboards. We already had
	some suggesting code, but this takes it slightly further.
	This commit exposes a fundamental problem:
	
	Low-level access to the hardware prior to initialization
	of the bus framework and thus prior to bus enumeration
	is currently not scalable. We need to create static
	structures for each of the different kinds of accesses
	(ie console, debug port and keyboard). This means that if
	there's a fourth "consumer" we need to teach the uart
	driver about yet another "exception". What if there are
	different kinds of keyboards? What if we want 2 serial
	consoles?
	
	It makes sense to approach it slightly differently:
	o  assume an uart can only be used for one kind of
	   special usage at the same time (ie a console is
	   never a debug port nor a keyboard). That way we
	   only need to have a single enumeration. Enumerations
	   are more scalable than bit fields.
	o  struct uart_devinfo should have a field for the
	   kind of consumer and pointers to link them together
	   so that we can have an arbitrary number of devinfos
	   with possibly multiple of the same kind.
	o  If we also put function pointers to helpers for
	   attach and detach in struct uart_devinfo, we don't
	   really need to know anything special and we should
	   have something that's generic enough.
	
	Something to work on I guess..
	
	Submitted by: jake

Affected files ...

.. //depot/projects/uart/dev/uart/uart_bus.h#18 edit
.. //depot/projects/uart/dev/uart/uart_core.c#24 edit
.. //depot/projects/uart/dev/uart/uart_cpu.h#4 edit
.. //depot/projects/uart/dev/uart/uart_cpu_sparc64.c#5 edit
.. //depot/projects/uart/dev/uart/uart_dev_ns8250.c#20 edit
.. //depot/projects/uart/dev/uart/uart_dev_sab82532.c#16 edit

Differences ...

==== //depot/projects/uart/dev/uart/uart_bus.h#18 (text+ko) ====

@@ -109,8 +109,8 @@
 	int		sc_dbgport:1;	/* This UART is a debug port. */
 	int		sc_fastintr:1;	/* This UART uses fast interrupts. */
 	int		sc_hasfifo:1;	/* This UART has FIFOs. */
+	int		sc_keyboard:1;	/* This UART is a keyboard. */
 	int		sc_leaving:1;	/* This UART is going away. */
-	int		sc_keyboard:1;	/* This UART is a keyboard device. */
 	int		sc_opened:1;	/* This UART is open for business. */
 	int		sc_polled:1;	/* This UART has no interrupts. */
 	int		sc_txbusy:1;	/* This UART is transmitting. */

==== //depot/projects/uart/dev/uart/uart_core.c#24 (text+ko) ====

@@ -258,6 +258,10 @@
 		sc->sc_dbgport = 1;
 		/* XXX check if ops matches class. */
 	}
+	if (uart_cpu_eqres(&sc->sc_bas, &uart_keyboard.bas)) {
+		sc->sc_keyboard = 1;
+		/* XXX check if ops matches class. */
+	}
 #endif
 
 	error = UART_PROBE(sc);
@@ -338,7 +342,7 @@
 	if (error)
 		goto fail;
 
-	if (sc->sc_console || sc->sc_dbgport) {
+	if (sc->sc_console || sc->sc_dbgport || sc->sc_keyboard) {
 		sep = "";
 		device_print_prettyname(dev);
 		if (sc->sc_console) {
@@ -349,6 +353,10 @@
 			printf("%sdebug port", sep);
 			sep = ", ";
 		}
+		if (sc->sc_keyboard) {
+			printf("%skeyboard", sep);
+			sep = ", ";
+		}
 		printf("\n");
 	}
 

==== //depot/projects/uart/dev/uart/uart_cpu.h#4 (text+ko) ====

@@ -59,9 +59,11 @@
 
 extern struct uart_devinfo uart_console;
 extern struct uart_devinfo uart_dbgport;
+extern struct uart_devinfo uart_keyboard;
 
 #define	UART_DEV_CONSOLE	0
 #define	UART_DEV_DBGPORT	1
+#define	UART_DEV_KEYBOARD	2
 
 int uart_cpu_getdev(int devtype, struct uart_devinfo *di);
 int uart_cpu_eqres(struct uart_bas *b1, struct uart_bas *b2);

==== //depot/projects/uart/dev/uart/uart_cpu_sparc64.c#5 (text+ko) ====

@@ -40,7 +40,7 @@
 
 int OF_decode_addr(phandle_t node, int *space, bus_addr_t *addr);
 
-static struct bus_space_tag bst_store[2];
+static struct bus_space_tag bst_store[3];
 
 int
 uart_cpu_getdev(int devtype, struct uart_devinfo *di)
@@ -68,14 +68,20 @@
 		return (ENXIO);
 	if ((consout = OF_instance_to_package(stdout)) == -1)
 		return (ENXIO);
-	if (consin != consout)
-		return (ENXIO);
-	if (OF_getprop(consout, "device_type", buffer, sizeof(buffer)) == -1)
+	if (devtype == UART_DEV_CONSOLE) {
+		if (consin != consout)
+			return (ENXIO);
+	} else if (devtype == UART_DEV_KEYBOARD) {
+		if (OF_getprop(consin, "keyboard", buffer,
+		    sizeof(buffer)) == -1)
+			return (ENXIO);
+	}
+	if (OF_getprop(consin, "device_type", buffer, sizeof(buffer)) == -1)
 		return (ENXIO);
 	if (strcmp(buffer, "serial"))
 		return (ENXIO);
 
-	error = OF_decode_addr(consout, &space, &addr);
+	error = OF_decode_addr(consin, &space, &addr);
 	if (error)
 		return (error);
 
@@ -86,7 +92,7 @@
 	di->bas.rclk = 0;
 
 	/* Get the device class. */
-	if (OF_getprop(consout, "name", buffer, sizeof(buffer)) == -1)
+	if (OF_getprop(consin, "name", buffer, sizeof(buffer)) == -1)
 		return (ENXIO);
 	if (!strcmp(buffer, "se"))
 		di->ops = uart_sab82532_ops;

==== //depot/projects/uart/dev/uart/uart_dev_ns8250.c#20 (text+ko) ====

@@ -507,7 +507,7 @@
 		return (error);
 
 	mcr = MCR_IENABLE;
-	if (!sc->sc_console && !sc->sc_dbgport) {
+	if (!sc->sc_console && !sc->sc_dbgport && !sc->sc_keyboard) {
 		/* By using ns8250_init() we also set DTR and RTS. */
 		ns8250_init(bas, 9600, 8, 1, UART_PARITY_NONE);
 	} else

==== //depot/projects/uart/dev/uart/uart_dev_sab82532.c#16 (text+ko) ====

@@ -383,7 +383,7 @@
 	uint8_t imr0, imr1;
 
 	bas = &sc->sc_bas;
-	if (!sc->sc_console && !sc->sc_dbgport)
+	if (!sc->sc_console && !sc->sc_dbgport && !sc->sc_keyboard)
 		sab82532_init(bas, 9600, 8, 1, UART_PARITY_NONE);
 
 	sc->sc_rxfifosz = 32;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200308270127.h7R1REOU034403>