svn commit: r246045 - stable/9/sys/dev/atkbdc
Warner Losh
imp at FreeBSD.org
Mon Jan 28 23:16:48 UTC 2013
Author: imp
Date: Mon Jan 28 23:16:47 2013
New Revision: 246045
URL: http://svnweb.freebsd.org/changeset/base/246045
Log:
MFC: r245314 and r245315:
r245315 | imp | 2013-01-11 14:42:23 -0700 (Fri, 11 Jan 2013) | 4 lines
Pass the device_t into atkbd_{probe,attach}_unit and get the
controller unit and keyboard unit from there. It will be needed
for other things in the future as well...
r245314 | imp | 2013-01-11 14:19:45 -0700 (Fri, 11 Jan 2013) | 2 lines
style(9) changes before I do more real changes.
Modified:
stable/9/sys/dev/atkbdc/atkbd.c
stable/9/sys/dev/atkbdc/atkbd_atkbdc.c
stable/9/sys/dev/atkbdc/atkbdreg.h
Directory Properties:
stable/9/sys/ (props changed)
stable/9/sys/dev/ (props changed)
Modified: stable/9/sys/dev/atkbdc/atkbd.c
==============================================================================
--- stable/9/sys/dev/atkbdc/atkbd.c Mon Jan 28 22:53:08 2013 (r246044)
+++ stable/9/sys/dev/atkbdc/atkbd.c Mon Jan 28 23:16:47 2013 (r246045)
@@ -66,7 +66,7 @@ static timeout_t atkbd_timeout;
static void atkbd_shutdown_final(void *v);
int
-atkbd_probe_unit(int unit, int ctlr, int irq, int flags)
+atkbd_probe_unit(device_t dev, int irq, int flags)
{
keyboard_switch_t *sw;
int args[2];
@@ -76,27 +76,29 @@ atkbd_probe_unit(int unit, int ctlr, int
if (sw == NULL)
return ENXIO;
- args[0] = ctlr;
+ args[0] = device_get_unit(device_get_parent(dev));
args[1] = irq;
- error = (*sw->probe)(unit, args, flags);
+ error = (*sw->probe)(device_get_unit(dev), args, flags);
if (error)
return error;
return 0;
}
int
-atkbd_attach_unit(int unit, keyboard_t **kbd, int ctlr, int irq, int flags)
+atkbd_attach_unit(device_t dev, keyboard_t **kbd, int irq, int flags)
{
keyboard_switch_t *sw;
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 */
- args[0] = ctlr;
+ 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);
@@ -401,7 +403,7 @@ atkbd_init(int unit, keyboard_t **kbdp,
bcopy(&key_map, keymap, sizeof(key_map));
bcopy(&accent_map, accmap, sizeof(accent_map));
bcopy(fkey_tab, fkeymap,
- imin(fkeymap_size*sizeof(fkeymap[0]), sizeof(fkey_tab)));
+ imin(fkeymap_size * sizeof(fkeymap[0]), sizeof(fkey_tab)));
kbd_set_maps(kbd, keymap, accmap, fkeymap, fkeymap_size);
kbd->kb_data = (void *)state;
@@ -424,8 +426,8 @@ atkbd_init(int unit, keyboard_t **kbdp,
if (!KBD_IS_INITIALIZED(kbd) && !(flags & KB_CONF_PROBE_ONLY)) {
kbd->kb_config = flags & ~KB_CONF_PROBE_ONLY;
if (KBD_HAS_DEVICE(kbd)
- && init_keyboard(state->kbdc, &kbd->kb_type, kbd->kb_config)
- && (kbd->kb_config & KB_CONF_FAIL_IF_NO_KBD)) {
+ && init_keyboard(state->kbdc, &kbd->kb_type, kbd->kb_config)
+ && (kbd->kb_config & KB_CONF_FAIL_IF_NO_KBD)) {
kbd_unregister(kbd);
error = ENXIO;
goto bad;
@@ -485,8 +487,7 @@ atkbd_intr(keyboard_t *kbd, void *arg)
* The keyboard was not detected before;
* it must have been reconnected!
*/
- init_keyboard(state->kbdc, &kbd->kb_type,
- kbd->kb_config);
+ init_keyboard(state->kbdc, &kbd->kb_type, kbd->kb_config);
KBD_FOUND_DEVICE(kbd);
atkbd_ioctl(kbd, KDSETLED, (caddr_t)&state->ks_state);
get_typematic(kbd);
@@ -645,7 +646,7 @@ next_code:
goto next_code;
}
break;
- case 0xE0: /* 0xE0 prefix */
+ case 0xE0: /* 0xE0 prefix */
state->ks_prefix = 0;
switch (keycode) {
case 0x1C: /* right enter key */
@@ -655,57 +656,57 @@ next_code:
keycode = 0x5A;
break;
case 0x35: /* keypad divide key */
- keycode = 0x5B;
- break;
+ keycode = 0x5B;
+ break;
case 0x37: /* print scrn key */
- keycode = 0x5C;
- break;
+ keycode = 0x5C;
+ break;
case 0x38: /* right alt key (alt gr) */
- keycode = 0x5D;
- break;
+ keycode = 0x5D;
+ break;
case 0x46: /* ctrl-pause/break on AT 101 (see below) */
keycode = 0x68;
- break;
+ break;
case 0x47: /* grey home key */
- keycode = 0x5E;
- break;
+ keycode = 0x5E;
+ break;
case 0x48: /* grey up arrow key */
- keycode = 0x5F;
- break;
+ keycode = 0x5F;
+ break;
case 0x49: /* grey page up key */
- keycode = 0x60;
- break;
+ keycode = 0x60;
+ break;
case 0x4B: /* grey left arrow key */
- keycode = 0x61;
- break;
+ keycode = 0x61;
+ break;
case 0x4D: /* grey right arrow key */
- keycode = 0x62;
- break;
+ keycode = 0x62;
+ break;
case 0x4F: /* grey end key */
- keycode = 0x63;
- break;
+ keycode = 0x63;
+ break;
case 0x50: /* grey down arrow key */
- keycode = 0x64;
- break;
+ keycode = 0x64;
+ break;
case 0x51: /* grey page down key */
- keycode = 0x65;
- break;
+ keycode = 0x65;
+ break;
case 0x52: /* grey insert key */
- keycode = 0x66;
- break;
+ keycode = 0x66;
+ break;
case 0x53: /* grey delete key */
- keycode = 0x67;
- break;
- /* the following 3 are only used on the MS "Natural" keyboard */
+ keycode = 0x67;
+ break;
+ /* the following 3 are only used on the MS "Natural" keyboard */
case 0x5b: /* left Window key */
- keycode = 0x69;
- break;
+ keycode = 0x69;
+ break;
case 0x5c: /* right Window key */
- keycode = 0x6a;
- break;
+ keycode = 0x6a;
+ break;
case 0x5d: /* menu key */
- keycode = 0x6b;
- break;
+ keycode = 0x6b;
+ break;
case 0x5e: /* power key */
keycode = 0x6d;
break;
@@ -716,10 +717,10 @@ next_code:
keycode = 0x6f;
break;
default: /* ignore everything else */
- goto next_code;
+ goto next_code;
}
break;
- case 0xE1: /* 0xE1 prefix */
+ case 0xE1: /* 0xE1 prefix */
/*
* The pause/break key on the 101 keyboard produces:
* E1-1D-45 E1-9D-C5
@@ -728,10 +729,10 @@ next_code:
*/
state->ks_prefix = 0;
if (keycode == 0x1D)
- state->ks_prefix = 0x1D;
+ state->ks_prefix = 0x1D;
goto next_code;
/* NOT REACHED */
- case 0x1D: /* pause / break */
+ case 0x1D: /* pause / break */
state->ks_prefix = 0;
if (keycode != 0x45)
goto next_code;
@@ -743,7 +744,7 @@ next_code:
switch (keycode) {
case 0x37: /* *(numpad)/print screen */
if (state->ks_flags & SHIFTS)
- keycode = 0x5c; /* print screen */
+ keycode = 0x5c; /* print screen */
break;
case 0x45: /* num lock/pause */
if (state->ks_flags & CTLS)
@@ -1177,7 +1178,7 @@ get_kbd_echo(KBDC kbdc)
*/
return ENXIO;
}
-
+
return 0;
}
@@ -1275,7 +1276,7 @@ init_keyboard(KBDC kbdc, int *type, int
}
if (bootverbose)
printf("atkbd: the current kbd controller command byte %04x\n",
- c);
+ c);
#if 0
/* override the keyboard lock switch */
c |= KBD_OVERRIDE_KBD_LOCK;
@@ -1415,52 +1416,49 @@ init_keyboard(KBDC kbdc, int *type, int
static int
write_kbd(KBDC kbdc, int command, int data)
{
- int s;
+ int s;
- /* prevent the timeout routine from polling the keyboard */
- if (!kbdc_lock(kbdc, TRUE))
- return EBUSY;
+ /* prevent the timeout routine from polling the keyboard */
+ if (!kbdc_lock(kbdc, TRUE))
+ return EBUSY;
- /* disable the keyboard and mouse interrupt */
- s = spltty();
+ /* disable the keyboard and mouse interrupt */
+ s = spltty();
#if 0
- c = get_controller_command_byte(kbdc);
- if ((c == -1)
- || !set_controller_command_byte(kbdc,
- kbdc_get_device_mask(kbdc),
- KBD_DISABLE_KBD_PORT | KBD_DISABLE_KBD_INT
- | KBD_DISABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
- /* CONTROLLER ERROR */
- kbdc_lock(kbdc, FALSE);
+ c = get_controller_command_byte(kbdc);
+ if ((c == -1)
+ || !set_controller_command_byte(kbdc,
+ kbdc_get_device_mask(kbdc),
+ KBD_DISABLE_KBD_PORT | KBD_DISABLE_KBD_INT
+ | KBD_DISABLE_AUX_PORT | KBD_DISABLE_AUX_INT)) {
+ /* CONTROLLER ERROR */
+ kbdc_lock(kbdc, FALSE);
+ splx(s);
+ return EIO;
+ }
+ /*
+ * Now that the keyboard controller is told not to generate
+ * the keyboard and mouse interrupts, call `splx()' to allow
+ * the other tty interrupts. The clock interrupt may also occur,
+ * but the timeout routine (`scrn_timer()') will be blocked
+ * by the lock flag set via `kbdc_lock()'
+ */
splx(s);
- return EIO;
- }
- /*
- * Now that the keyboard controller is told not to generate
- * the keyboard and mouse interrupts, call `splx()' to allow
- * the other tty interrupts. The clock interrupt may also occur,
- * but the timeout routine (`scrn_timer()') will be blocked
- * by the lock flag set via `kbdc_lock()'
- */
- splx(s);
#endif
-
- if (send_kbd_command_and_data(kbdc, command, data) != KBD_ACK)
- send_kbd_command(kbdc, KBDC_ENABLE_KBD);
-
+ if (send_kbd_command_and_data(kbdc, command, data) != KBD_ACK)
+ send_kbd_command(kbdc, KBDC_ENABLE_KBD);
#if 0
- /* restore the interrupts */
- if (!set_controller_command_byte(kbdc,
- kbdc_get_device_mask(kbdc),
+ /* restore the interrupts */
+ if (!set_controller_command_byte(kbdc, kbdc_get_device_mask(kbdc),
c & (KBD_KBD_CONTROL_BITS | KBD_AUX_CONTROL_BITS))) {
- /* CONTROLLER ERROR */
- }
+ /* CONTROLLER ERROR */
+ }
#else
- splx(s);
+ splx(s);
#endif
- kbdc_lock(kbdc, FALSE);
+ kbdc_lock(kbdc, FALSE);
- return 0;
+ return 0;
}
static int
Modified: stable/9/sys/dev/atkbdc/atkbd_atkbdc.c
==============================================================================
--- stable/9/sys/dev/atkbdc/atkbd_atkbdc.c Mon Jan 28 22:53:08 2013 (r246044)
+++ stable/9/sys/dev/atkbdc/atkbd_atkbdc.c Mon Jan 28 23:16:47 2013 (r246045)
@@ -104,9 +104,7 @@ atkbdprobe(device_t dev)
bus_release_resource(dev, SYS_RES_IRQ, rid, res);
/* probe the device */
- return atkbd_probe_unit(device_get_unit(dev),
- device_get_unit(device_get_parent(dev)),
- irq, flags);
+ return atkbd_probe_unit(dev, irq, flags);
}
static int
@@ -124,9 +122,7 @@ atkbdattach(device_t dev)
rid = KBDC_RID_KBD;
irq = bus_get_resource_start(dev, SYS_RES_IRQ, rid);
flags = device_get_flags(dev);
- error = atkbd_attach_unit(device_get_unit(dev), &kbd,
- device_get_unit(device_get_parent(dev)),
- irq, flags);
+ error = atkbd_attach_unit(dev, &kbd, irq, flags);
if (error)
return error;
Modified: stable/9/sys/dev/atkbdc/atkbdreg.h
==============================================================================
--- stable/9/sys/dev/atkbdc/atkbdreg.h Mon Jan 28 22:53:08 2013 (r246044)
+++ stable/9/sys/dev/atkbdc/atkbdreg.h Mon Jan 28 23:16:47 2013 (r246045)
@@ -39,9 +39,8 @@
#ifdef _KERNEL
-int atkbd_probe_unit(int unit, int ctlr, int irq, int flags);
-int atkbd_attach_unit(int unit, keyboard_t **kbd,
- int ctlr, int irq, int flags);
+int atkbd_probe_unit(device_t dev, int irq, int flags);
+int atkbd_attach_unit(device_t dev, keyboard_t **kbd, int irq, int flags);
#endif
More information about the svn-src-stable-9
mailing list