コード例 #1
0
static int
ukbd_attach(device_t self)
{
	struct ukbd_softc *sc = device_get_softc(self);
	struct usb_attach_arg *uaa = device_get_ivars(self);

	keyboard_switch_t *sw;
	keyboard_t *kbd;
	void *arg[2];
	int unit = device_get_unit(self);

	sc->sc_dev = self;

	sw = kbd_get_switch(DRIVER_NAME);
	if (sw == NULL)
		return ENXIO;

	arg[0] = (void *)uaa;
	arg[1] = (void *)ukbd_intr;
	kbd = NULL;
	if ((*sw->probe)(unit, (void *)arg, 0))
		return ENXIO;
	if ((*sw->init)(unit, &kbd, (void *)arg, 0))
		return ENXIO;
	(*sw->enable)(kbd);

#ifdef KBD_INSTALL_CDEV
	if (kbd_attach(kbd))
		return ENXIO;
#endif
	if (bootverbose)
		(*sw->diag)(kbd, bootverbose);
	return 0;
}
コード例 #2
0
ファイル: atkbd.c プロジェクト: FreeBSDFoundation/freebsd
int
atkbd_attach_unit(device_t dev, keyboard_t **kbd, int irq, int flags)
{
	keyboard_switch_t *sw;
	atkbd_state_t *state;
	int args[2];
	int error;
	int unit;

	sw = kbd_get_switch(ATKBD_DRIVER_NAME);
	if (sw == NULL)
		return ENXIO;

	/* reset, initialize and enable the device */
	unit = device_get_unit(dev);
	args[0] = device_get_unit(device_get_parent(dev));
	args[1] = irq;
	*kbd = NULL;
	error = (*sw->probe)(unit, args, flags);
	if (error)
		return error;
	error = (*sw->init)(unit, kbd, args, flags);
	if (error)
		return error;
	(*sw->enable)(*kbd);

#ifdef KBD_INSTALL_CDEV
	/* attach a virtual keyboard cdev */
	error = kbd_attach(*kbd);
	if (error)
		return error;
#endif

	/*
	 * This is a kludge to compensate for lost keyboard interrupts.
	 * A similar code used to be in syscons. See below. XXX
	 */
	state = (atkbd_state_t *)(*kbd)->kb_data;
	callout_init(&state->ks_timer, 0);
	atkbd_timeout(*kbd);

	if (bootverbose)
		(*sw->diag)(*kbd, bootverbose);

	EVENTHANDLER_REGISTER(shutdown_final, atkbd_shutdown_final, *kbd,
	    SHUTDOWN_PRI_DEFAULT);

	return 0;
}
コード例 #3
0
ファイル: pckbd.c プロジェクト: 2asoft/freebsd
static int
pckbd_attach_unit(device_t dev, keyboard_t **kbd, int port, int irq, int flags)
{
	keyboard_switch_t *sw;
	pckbd_state_t *state;
	int args[2];
	int error;
	int unit;

	sw = kbd_get_switch(DRIVER_NAME);
	if (sw == NULL)
		return ENXIO;

	/* reset, initialize and enable the device */
	unit = device_get_unit(dev);
	args[0] = port;
	args[1] = irq;
	*kbd = NULL;
	error = (*sw->probe)(unit, args, flags);
	if (error)
		return error;
	error = (*sw->init)(unit, kbd, args, flags);
	if (error)
		return error;
	(*sw->enable)(*kbd);

#ifdef KBD_INSTALL_CDEV
	/* attach a virtual keyboard cdev */
	error = kbd_attach(*kbd);
	if (error)
		return error;
#endif /* KBD_INSTALL_CDEV */

	/*
	 * This is a kludge to compensate for lost keyboard interrupts.
	 * A similar code used to be in syscons. See below. XXX
	 */
	state = (pckbd_state_t *)(*kbd)->kb_data;
	callout_init(&state->ks_timer, 0);
	pckbd_timeout(*kbd);

	if (bootverbose)
		(*sw->diag)(*kbd, bootverbose);

	return 0;
}
コード例 #4
0
ファイル: pc98kbd.c プロジェクト: UnitedMarsupials/kame
static int
pckbd_attach_unit(int unit, pckbd_softc_t *sc, int port, int irq, int flags)
{
	keyboard_switch_t *sw;
	int args[2];
	int error;

	if (sc->flags & PC98KBD_ATTACHED)
		return 0;

	sw = kbd_get_switch(DRIVER_NAME);
	if (sw == NULL)
		return ENXIO;

	/* reset, initialize and enable the device */
	args[0] = port;
	args[1] = irq;
	sc->kbd = NULL;
	error = (*sw->probe)(unit, args, flags);
	if (error)
		return error;
	error = (*sw->init)(unit, &sc->kbd, args, flags);
	if (error)
		return error;
	(*sw->enable)(sc->kbd);

#ifdef KBD_INSTALL_CDEV
	/* attach a virtual keyboard cdev */
	error = kbd_attach(makedev(0, PC98KBD_MKMINOR(unit)), sc->kbd,
			   &pckbd_cdevsw);
	if (error)
		return error;
#endif /* KBD_INSTALL_CDEV */

	/*
	 * This is a kludge to compensate for lost keyboard interrupts.
	 * A similar code used to be in syscons. See below. XXX
	 */
	pckbd_timeout(sc->kbd);

	if (bootverbose)
		(*sw->diag)(sc->kbd, bootverbose);

	sc->flags |= PC98KBD_ATTACHED;
	return 0;
}
コード例 #5
0
int
atkbd_attach_unit(int unit, keyboard_t **kbd, int ctlr, int irq, int flags)
{
	keyboard_switch_t *sw;
	int args[2];
	int error;

	sw = kbd_get_switch(ATKBD_DRIVER_NAME);
	if (sw == NULL) {
		return ENXIO;
	}

	/* reset, initialize and enable the device */
	args[0] = ctlr;
	args[1] = irq;
	*kbd = NULL;
	error = (*sw->probe)(unit, args, flags);
	if (error) {
		return error;
	}
	error = (*sw->init)(unit, kbd, args, flags);
	if (error) {
		return error;
	}
	(*sw->enable)(*kbd);

#ifdef KBD_INSTALL_CDEV
	/* attach a virtual keyboard cdev */
	error = kbd_attach(*kbd);
	if (error) {
		return error;
	}
#endif

	/*
	 * This is a kludge to compensate for lost keyboard interrupts.
	 * A similar code used to be in syscons. See below. XXX
	 */
	atkbd_timeout(*kbd);

	if (bootverbose)
		(*sw->diag)(*kbd, bootverbose);

	return 0;
}
コード例 #6
0
ファイル: pc98kbd.c プロジェクト: UnitedMarsupials/kame
static int
pckbd_probe_unit(int unit, int port, int irq, int flags)
{
	keyboard_switch_t *sw;
	int args[2];
	int error;

	sw = kbd_get_switch(DRIVER_NAME);
	if (sw == NULL)
		return ENXIO;

	args[0] = port;
	args[1] = irq;
	error = (*sw->probe)(unit, args, flags);
	if (error)
		return error;
	return 0;
}
コード例 #7
0
ファイル: atkbd.c プロジェクト: dcui/FreeBSD-9.3_kernel
int
atkbd_probe_unit(device_t dev, int irq, int flags)
{
	keyboard_switch_t *sw;
	int args[2];
	int error;

	sw = kbd_get_switch(ATKBD_DRIVER_NAME);
	if (sw == NULL)
		return ENXIO;

	args[0] = device_get_unit(device_get_parent(dev));
	args[1] = irq;
	error = (*sw->probe)(device_get_unit(dev), args, flags);
	if (error)
		return error;
	return 0;
}
コード例 #8
0
static int
ukbd_match(device_t self)
{
	struct usb_attach_arg *uaa = device_get_ivars(self);

	keyboard_switch_t *sw;
	void *arg[2];
	int unit = device_get_unit(self);

	sw = kbd_get_switch(DRIVER_NAME);
	if (sw == NULL)
		return (UMATCH_NONE);

	arg[0] = (void *)uaa;
	arg[1] = (void *)ukbd_intr;
	if ((*sw->probe)(unit, (void *)arg, 0))
		return (UMATCH_NONE);

	return (UMATCH_IFACECLASS_IFACESUBCLASS_IFACEPROTO);
}
コード例 #9
0
int
atkbd_probe_unit(int unit, int ctlr, int irq, int flags)
{
	keyboard_switch_t *sw;
	int args[2];
	int error;

	sw = kbd_get_switch(ATKBD_DRIVER_NAME);
	if (sw == NULL) {
		return ENXIO;
	}

	args[0] = ctlr;
	args[1] = irq;
	error = (*sw->probe)(unit, args, flags);

	if (error)
		return error;
	return 0;
}
コード例 #10
0
ファイル: adb_kbd.c プロジェクト: ele7enxxh/dtrace-pf
static int 
adb_kbd_attach(device_t dev) 
{
	struct adb_kbd_softc *sc;
	keyboard_switch_t *sw;
	uint32_t fkeys;
	phandle_t handle;

	sw = kbd_get_switch(KBD_DRIVER_NAME);
	if (sw == NULL) {
		return ENXIO;
	}

	sc = device_get_softc(dev);
	sc->sc_dev = dev;
	sc->sc_mode = K_RAW;
	sc->sc_state = 0;
	sc->have_led_control = 0;
	sc->buffers = 0;

	/* Try stepping forward to the extended keyboard protocol */
	adb_set_device_handler(dev,3);

	mtx_init(&sc->sc_mutex, KBD_DRIVER_NAME, NULL, MTX_DEF);
	cv_init(&sc->sc_cv,KBD_DRIVER_NAME);
	callout_init(&sc->sc_repeater, 0);

#ifdef AKBD_EMULATE_ATKBD
	kbd_init_struct(&sc->sc_kbd, KBD_DRIVER_NAME, KB_101, 0, 0, 0, 0);
	kbd_set_maps(&sc->sc_kbd, &key_map, &accent_map, fkey_tab,
            sizeof(fkey_tab) / sizeof(fkey_tab[0]));
#else
	#error ADB raw mode not implemented
#endif

	KBD_FOUND_DEVICE(&sc->sc_kbd);
	KBD_PROBE_DONE(&sc->sc_kbd);
	KBD_INIT_DONE(&sc->sc_kbd);
	KBD_CONFIG_DONE(&sc->sc_kbd);

	(*sw->enable)(&sc->sc_kbd);

	kbd_register(&sc->sc_kbd);

#ifdef KBD_INSTALL_CDEV
	if (kbd_attach(&sc->sc_kbd)) {
		adb_kbd_detach(dev);
		return ENXIO;
	}
#endif

	/* Check if we can read out the LED state from 
	   this keyboard by reading the key state register */
	if (adb_read_register(dev, 2, NULL) == 2)
		sc->have_led_control = 1;

	adb_set_autopoll(dev,1);

	handle = OF_finddevice("mac-io/via-pmu/adb/keyboard");
	if (handle != -1 && OF_getprop(handle, "AAPL,has-embedded-fn-keys",
	    &fkeys, sizeof(fkeys)) != -1) {
		static const char *key_names[] = {"F1", "F2", "F3", "F4", "F5",
		    "F6", "F7", "F8", "F9", "F10", "F11", "F12"};
		struct sysctl_ctx_list *ctx;
		struct sysctl_oid *tree;
		int i;

		if (bootverbose)
			device_printf(dev, "Keyboard has embedded Fn keys\n");

		for (i = 0; i < 12; i++) {
			uint32_t keyval;
			char buf[3];
			if (OF_getprop(handle, key_names[i], &keyval,
			    sizeof(keyval)) < 0)
				continue;
			buf[0] = 1;
			buf[1] = i+1;
			buf[2] = keyval;
			adb_write_register(dev, 0, 3, buf);
		}
		adb_write_register(dev, 1, 2, &(uint16_t){0});

		ctx = device_get_sysctl_ctx(dev);
		tree = device_get_sysctl_tree(dev);

		SYSCTL_ADD_PROC(ctx, SYSCTL_CHILDREN(tree), OID_AUTO,
		    "fn_keys_function_as_primary", CTLTYPE_INT | CTLFLAG_RW, sc,
		    0, adb_fn_keys, "I",
		    "Set the Fn keys to be their F-key type as default");
	}

	return (0);
}