Rework the way ukbd attaches itself as the console (again). We now allow

the code to pick the first USB keyboard instance as the console, ignoring
which USB controller it's on.  Should eventually allow detaching of the
console keyboard.

From Jason Thorpe <thorpej@nas.nasa.gov>
This commit is contained in:
thorpej 1999-05-13 23:34:38 +00:00
parent e16867970c
commit 0d0cc4aa14
5 changed files with 73 additions and 69 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ohci_pci.c,v 1.7 1999/05/06 19:12:22 thorpej Exp $ */
/* $NetBSD: ohci_pci.c,v 1.8 1999/05/13 23:34:38 thorpej Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -70,13 +70,6 @@ struct cfattach ohci_pci_ca = {
sizeof(struct ohci_softc), ohci_pci_match, ohci_pci_attach
};
struct {
pcitag_t tag;
int valid;
} ohci_pci_console_info;
void ohci_pci_has_console __P((pcitag_t));
int
ohci_pci_match(parent, match, aux)
struct device *parent;
@ -159,22 +152,6 @@ ohci_pci_attach(parent, self, aux)
return;
}
if (ohci_pci_console_info.valid &&
memcmp(&ohci_pci_console_info.tag, &pa->pa_tag,
sizeof(pcitag_t)) == 0)
sc->sc_bus.has_console = 1;
else
sc->sc_bus.has_console = 0;
/* Attach usb device. */
config_found((void *)sc, &sc->sc_bus, usbctlprint);
}
void
ohci_pci_has_console(tag)
pcitag_t tag;
{
ohci_pci_console_info.tag = tag;
ohci_pci_console_info.valid = 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: uhci_pci.c,v 1.5 1999/05/06 19:12:22 thorpej Exp $ */
/* $NetBSD: uhci_pci.c,v 1.6 1999/05/13 23:34:38 thorpej Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -63,13 +63,6 @@ struct cfattach uhci_pci_ca = {
sizeof(uhci_softc_t), uhci_pci_match, uhci_pci_attach
};
struct {
pcitag_t tag;
int valid;
} uhci_pci_console_info;
void uhci_pci_has_console __P((pcitag_t));
int
uhci_pci_match(parent, match, aux)
struct device *parent;
@ -165,22 +158,6 @@ uhci_pci_attach(parent, self, aux)
return;
}
if (uhci_pci_console_info.valid &&
memcmp(&uhci_pci_console_info.tag, &pa->pa_tag,
sizeof(pcitag_t)) == 0)
sc->sc_bus.has_console = 1;
else
sc->sc_bus.has_console = 0;
/* Attach usb device. */
config_found((void *)sc, &sc->sc_bus, usbctlprint);
}
void
uhci_pci_has_console(tag)
pcitag_t tag;
{
uhci_pci_console_info.tag = tag;
uhci_pci_console_info.valid = 1;
}

View File

@ -1,4 +1,4 @@
/* $NetBSD: ukbd.c,v 1.30 1999/05/09 15:10:30 augustss Exp $ */
/* $NetBSD: ukbd.c,v 1.31 1999/05/13 23:34:38 thorpej Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -68,6 +68,7 @@
#include <dev/usb/usbdevs.h>
#include <dev/usb/usb_quirks.h>
#include <dev/usb/hid.h>
#include <dev/usb/ukbdvar.h>
#if defined(__NetBSD__)
#include <dev/wscons/wsconsio.h>
@ -213,6 +214,8 @@ struct ukbd_softc {
#define UKBD_CHUNK 128 /* chunk size for read */
#define UKBD_BSIZE 1020 /* buffer size */
int ukbd_is_console;
void ukbd_cngetc __P((void *, u_int *, int *));
void ukbd_cnpollc __P((void *, int));
@ -231,16 +234,12 @@ void ukbd_set_leds __P((void *, int));
#if defined(__NetBSD__)
int ukbd_ioctl __P((void *, u_long, caddr_t, int, struct proc *));
int ukbd_cnattach __P((void *v));
void ukbd_rawrepeat __P((void *v));
const struct wskbd_accessops ukbd_accessops = {
ukbd_enable,
ukbd_set_leds,
ukbd_ioctl,
#if defined(CNATTACH)
ukbd_cnattach,
#endif
};
extern const struct wscons_keydesc ukbd_keydesctab[];
@ -334,18 +333,19 @@ USB_ATTACH(ukbd)
/*
* Remember if we're the console keyboard.
*
* XXX This always picks the first keyboard on the bus, but
* what else can we really do?
* XXX This always picks the first keyboard on the
* first USB bus, but what else can we really do?
*/
sc->sc_console_keyboard = uaa->device->bus->has_console;
if (sc->sc_console_keyboard) {
if ((sc->sc_console_keyboard = ukbd_is_console) != 0) {
/* Don't let any other keyboard have it. */
uaa->device->bus->has_console = 0;
ukbd_is_console = 0;
}
#if defined(__NetBSD__)
if (sc->sc_console_keyboard)
ukbd_cnattach(sc);
if (sc->sc_console_keyboard) {
DPRINTF(("ukbd_attach: console keyboard\n", sc));
wskbd_cnattach(&ukbd_consops, sc, &ukbd_keymapdata);
}
a.console = sc->sc_console_keyboard;
@ -412,9 +412,13 @@ ukbd_disco(p)
if (sc->sc_console_keyboard) {
/*
* XXX Should probably disconnect our consops,
* XXX and set has_console in the bus handle back
* XXX to 1.
* XXX and either notify some other keyboard that
* XXX it can now be the console, or if there aren't
* XXX any more USB keyboards, set ukbd_is_console
* XXX back to 1 so that the next USB keyboard attached
* XXX to the system will get it.
*/
panic("ukbd_disco: console keyboard");
}
}
@ -709,13 +713,15 @@ ukbd_cnpollc(v, on)
}
int
ukbd_cnattach(v)
void *v;
ukbd_cnattach()
{
struct ukbd_softc *sc = v;
DPRINTF(("ukbd_cnattach: sc=%p\n", sc));
wskbd_cnattach(&ukbd_consops, sc, &ukbd_keymapdata);
/*
* XXX USB requires too many parts of the kernel to be running
* XXX in order to work, so we can't do much for the console
* XXX keyboard until autconfiguration has run its course.
*/
ukbd_is_console = 1;
return (0);
}

45
sys/dev/usb/ukbdvar.h Normal file
View File

@ -0,0 +1,45 @@
/* $NetBSD: ukbdvar.h,v 1.1 1999/05/13 23:34:38 thorpej Exp $ */
/*-
* Copyright (c) 1999 The NetBSD Foundation, Inc.
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
* by Jason R. Thorpe of the Numerical Aerospace Simulation Facility,
* NASA Ames Research Center.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the NetBSD
* Foundation, Inc. and its contributors.
* 4. Neither the name of The NetBSD Foundation nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef _DEV_USB_UKBDVAR_H_
#define _DEV_USB_UKBDVAR_H_
int ukbd_cnattach __P((void));
#endif /* _DEV_USB_UKBDVAR_H_ */

View File

@ -1,4 +1,4 @@
/* $NetBSD: usbdivar.h,v 1.18 1999/05/06 19:12:23 thorpej Exp $ */
/* $NetBSD: usbdivar.h,v 1.19 1999/05/13 23:34:38 thorpej Exp $ */
/*
* Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -85,7 +85,6 @@ struct usbd_bus {
usbd_status (*open_pipe)__P((struct usbd_pipe *pipe));
u_int32_t pipe_size; /* size of a pipe struct */
void (*do_poll)__P((struct usbd_bus *));
int has_console; /* console input on this bus */
/* Filled by usb driver */
struct usbd_device *root_hub;
usbd_device_handle devices[USB_MAX_DEVICES];