Ejemplo n.º 1
0
/* 
 * The back door to the keyboard driver!
 * This function is called by the console driver, via the kbdio module,
 * to tickle keyboard drivers when the low-level console is being initialized.
 * Almost nothing in the kernel has been initialied yet.  Try to probe
 * keyboards if possible.
 * NOTE: because of the way the low-level conole is initialized, this routine
 * may be called more than once!!
 */
static int
pckbd_configure(int flags)
{
	keyboard_t *kbd;
	int arg[2];
	int i;

	/* XXX: a kludge to obtain the device configuration flags */
	if (resource_int_value(DRIVER_NAME, 0, "flags", &i) == 0) {
		flags |= i;
		/* if the driver is disabled, unregister the keyboard if any */
		if (resource_int_value(DRIVER_NAME, 0, "disabled", &i) == 0
		    && i != 0) {
			i = kbd_find_keyboard(DRIVER_NAME, PC98KBD_DEFAULT);
			if (i >= 0) {
				kbd = kbd_get_keyboard(i);
				kbd_unregister(kbd);
				kbd->kb_flags &= ~KB_REGISTERED;
				return 0;
			}
		}
	}

	/* probe the default keyboard */
	arg[0] = -1;
	arg[1] = -1;
	kbd = NULL;
	if (pckbd_probe(PC98KBD_DEFAULT, arg, flags))
		return 0;
	if (pckbd_init(PC98KBD_DEFAULT, &kbd, arg, flags))
		return 0;

	/* return the number of found keyboards */
	return 1;
}
Ejemplo n.º 2
0
int
ukbd_detach(device_t self)
{
	keyboard_t *kbd;
	int error;

	kbd = kbd_get_keyboard(kbd_find_keyboard(DRIVER_NAME,
						 device_get_unit(self)));
	if (kbd == NULL) {
		DPRINTF(("%s: keyboard not attached!?\n", device_get_nameunit(self)));
		return ENXIO;
	}
	kbd_disable(kbd);

#ifdef KBD_INSTALL_CDEV
	error = kbd_detach(kbd);
	if (error)
		return error;
#endif
	error = kbd_term(kbd);
	if (error)
		return error;

	DPRINTF(("%s: disconnected\n", device_get_nameunit(self)));

	return (0);
}
Ejemplo n.º 3
0
static int 
adb_kbd_detach(device_t dev) 
{
	struct adb_kbd_softc *sc;
	keyboard_t *kbd;

	sc = device_get_softc(dev);

	adb_set_autopoll(dev,0);
	callout_stop(&sc->sc_repeater);

	mtx_lock(&sc->sc_mutex);

	kbd = kbd_get_keyboard(kbd_find_keyboard(KBD_DRIVER_NAME,
	          device_get_unit(dev)));

	kbdd_disable(kbd);

#ifdef KBD_INSTALL_CDEV
	kbd_detach(kbd);
#endif

	kbdd_term(kbd);

	mtx_unlock(&sc->sc_mutex);

	mtx_destroy(&sc->sc_mutex);
	cv_destroy(&sc->sc_cv);

	return (0);
}
Ejemplo n.º 4
0
int
ukbd_detach(device_t self)
{
	keyboard_t *kbd;
	int error;

	kbd = kbd_get_keyboard(kbd_find_keyboard(DRIVER_NAME,
						 device_get_unit(self)));
	if (kbd == NULL) {
		DPRINTF(("%s: keyboard not attached!?\n", USBDEVNAME(self)));
		return ENXIO;
	}
	(*kbdsw[kbd->kb_index]->disable)(kbd);

#ifdef KBD_INSTALL_CDEV
	error = kbd_detach(kbd);
	if (error)
		return error;
#endif
	error = (*kbdsw[kbd->kb_index]->term)(kbd);
	if (error)
		return error;

	DPRINTF(("%s: disconnected\n", USBDEVNAME(self)));

	return (0);
}
Ejemplo n.º 5
0
static int
ukbd_resume(device_t self)
{
	keyboard_t *kbd;

	kbd = kbd_get_keyboard(kbd_find_keyboard(DRIVER_NAME,
						 device_get_unit(self)));
	if (kbd)
		kbd_clear_state(kbd);

	return (0);
}
Ejemplo n.º 6
0
static int
pckbdresume(device_t dev)
{
	keyboard_t *kbd;

	kbd = kbd_get_keyboard(kbd_find_keyboard(DRIVER_NAME,
						 device_get_unit(dev)));
	if (kbd)
		kbdd_clear_state(kbd);

	return (0);
}
Ejemplo n.º 7
0
static int
atkbdresume(device_t dev)
{
	atkbd_softc_t *sc;
	keyboard_t *kbd;
	int args[2];

	sc = device_get_softc(dev);
	kbd = kbd_get_keyboard(kbd_find_keyboard(ATKBD_DRIVER_NAME,
						 device_get_unit(dev)));
	if (kbd) {
		kbd->kb_flags &= ~KB_INITIALIZED;
		args[0] = device_get_unit(device_get_parent(dev));
		args[1] = rman_get_start(sc->intr);
		kbdd_init(kbd, device_get_unit(dev), &kbd, args,
		    device_get_flags(dev));
		kbdd_clear_state(kbd);
	}
	return 0;
}
Ejemplo n.º 8
0
/* 
 * The back door to the keyboard driver!
 * This function is called by the console driver, via the kbdio module,
 * to tickle keyboard drivers when the low-level console is being initialized.
 * Almost nothing in the kernel has been initialied yet.  Try to probe
 * keyboards if possible.
 * NOTE: because of the way the low-level console is initialized, this routine
 * may be called more than once!!
 */
static int
atkbd_configure(int flags)
{
	keyboard_t *kbd;
	int arg[2];
	int i;

	/*
	 * Probe the keyboard controller, if not present or if the driver
	 * is disabled, unregister the keyboard if any.
	 */
	if (atkbdc_configure() != 0 ||
	    resource_disabled("atkbd", ATKBD_DEFAULT)) {
		i = kbd_find_keyboard(ATKBD_DRIVER_NAME, ATKBD_DEFAULT);
		if (i >= 0) {
			kbd = kbd_get_keyboard(i);
			KBD_ALWAYS_LOCK(kbd);
			kbd_unregister(kbd);
			kbd = NULL; /* huh? */
		}
		return 0;
	}
	
	/* XXX: a kludge to obtain the device configuration flags */
	if (resource_int_value("atkbd", ATKBD_DEFAULT, "flags", &i) == 0)
		flags |= i;

	/* probe the default keyboard */
	arg[0] = -1;
	arg[1] = -1;
	kbd = NULL;
	if (atkbd_probe(ATKBD_DEFAULT, arg, flags)) {
		return 0;
	}
	if (atkbd_init(ATKBD_DEFAULT, &kbd, arg, flags)) {
		return 0;
	}

	/* return the number of found keyboards */
	return 1;
}
Ejemplo n.º 9
0
/* 
 * The back door to the keyboard driver!
 * This function is called by the console driver, via the kbdio module,
 * to tickle keyboard drivers when the low-level console is being initialized.
 * Almost nothing in the kernel has been initialied yet.  Try to probe
 * keyboards if possible.
 * NOTE: because of the way the low-level conole is initialized, this routine
 * may be called more than once!!
 */
static int
atkbd_configure(int flags)
{
	keyboard_t *kbd;
	int arg[2];
#ifdef __i386__
	struct isa_device *dev;
	int i;

	/* XXX: a kludge to obtain the device configuration flags */
	dev = find_isadev(isa_devtab_tty, &atkbddriver, 0);
	if (dev != NULL) {
		flags |= dev->id_flags;
		/* if the driver is disabled, unregister the keyboard if any */
		if (!dev->id_enabled) {
			i = kbd_find_keyboard(ATKBD_DRIVER_NAME, ATKBD_DEFAULT);
			if (i >= 0) {
				kbd = kbd_get_keyboard(i);
				kbd_unregister(kbd);
				kbd->kb_flags &= ~KB_REGISTERED;
				return 0;
			}
		}
	}
#endif

	/* probe the keyboard controller */
	atkbdc_configure();

	/* probe the default keyboard */
	arg[0] = -1;
	arg[1] = -1;
	kbd = NULL;
	if (atkbd_probe(ATKBD_DEFAULT, arg, flags))
		return 0;
	if (atkbd_init(ATKBD_DEFAULT, &kbd, arg, flags))
		return 0;

	/* return the number of found keyboards */
	return 1;
}