i8042.c revision fbac63660cc7a6ccfe2042916ea594ac07d63fcb
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* booting with ACPI enumeration turned off (acpi-enum=off).
*/
/*
* Unfortunately, soft interrupts are implemented poorly. Each additional
* soft interrupt user impacts the performance of all existing soft interrupt
* users. This is not the case on SPARC, however.
*/
#ifdef __sparc
#define USE_SOFT_INTRS
#else
#endif
/*
* The command bytes are different for x86 and for SPARC because on x86,
* all modern 8042s can properly translate scan code set 2 codes to
* scan code set 1. On SPARC systems that have 8042s (e.g. Tadpole laptops),
* setting the "translation" bit in the command byte has no effect.
* This is potentially dangerous if, in the future, new SPARC systems uses 8042s
* that implement the scan code translation when the translation bit is set.
*
* On SPARC, kb8042 will attempt to detect which scan code set the keyboard
* is using. In order for that code to work, the real scan code set must be the
* set that is returned by the keyboard (and not a different set that is
* translated by the 8042). (e.g. If the translation bit were enabled here,
* and the keyboard returned scan code set 2 when kb8042 queried it, kb8042
* would not be able to know with certainty that the scan codes it will receive
* are set 2 scancodes, or set 1 translations made by the 8042).
*/
/*
* 8042 Command Byte Layout:
*
* 0x80: 0 = Reserved, must be zero.
* 0x40: 1 = Translate to XT codes. (0=No translation)
* 0x20: 1 = Disable aux (mouse) port. (0=Enable port)
* 0x10: 1 = Disable main (keyboard) port. (0=Enable port)
* 0x08: 0 = Reserved, must be zero.
* 0x04: 1 = System flag, 1 means passed self-test.
* Caution: setting this bit to zero causes some
* systems (HP Kayak XA) to fail to reboot without
* a hard reset.
* 0x02: 0 = Disable aux port interrupts. (1=Enable aux port interrupts)
* 0x01: 0 = Disable main port interrupts. (1=Enable main port interrupts)
*
*/
#if defined(__sparc)
#define I8042_CMD_DISABLE_ALL 0x34
#define I8042_CMD_ENABLE_ALL 0x07
#define I8042_CMD_DISABLE_ALL 0x74
#define I8042_CMD_ENABLE_ALL 0x47
#endif
#define BUFSIZ 64
/*
* Child nodes, used to determine which to create at bus_config time
*/
#define I8042_KEYBOARD 2
#define I8042_MOUSE 1
enum i8042_ports {
MAIN_PORT = 0,
};
#define NUM_PORTS 2
/*
* Only register at most MAX_INTERRUPTS interrupt handlers,
* regardless of the number of interrupts in the prom node.
* This is important, as registering for all interrupts on
* some systems (e.g. Tadpole laptops) results in a flood
* of spurious interrupts (for Tadpole, the first 2 interrupts
* are for the keyboard and mouse, respectively, and the
* third is for a proprietary device that is also accessed
* via the same I/O addresses.)
*/
#define MAX_INTERRUPTS 2
/*
* One of these for each port - main (keyboard) and aux (mouse).
*/
struct i8042_port {
int inumber;
#if defined(USE_SOFT_INTRS)
#else
#endif
struct i8042 *i8042_global;
/*
* wptr is next byte to write
*/
int wptr;
/*
* rptr is next byte to read, == wptr means empty
* NB: At full, one byte is unused.
*/
int rptr;
int overruns;
/*
* Used during i8042_rep_put8 to intercept the 8042 response in
* i8042_intr()
*/
};
/*
* Describes entire 8042 device.
*/
struct i8042 {
int nintrs;
/* Initialization states: */
#define I8042_INIT_BASIC 0x00000001
#define I8042_INIT_REGS_MAPPED 0x00000002
#define I8042_INIT_MUTEXES 0x00000004
#define I8042_INIT_INTRS_ENABLED 0x00000010
#ifdef __sparc
#endif
#ifdef DEBUG
/*
* intr_thread is set to curthread in i8042_intr and is
* tested against curthread in i8402_rep_put8().
*/
#endif
};
/*
* i8042 hardware register definitions
*/
/*
* These are I/O registers, relative to the device's base (normally 0x60).
*/
/*
* These are bits in I8042_STAT.
*/
/*
* These are commands to the i8042 itself (as distinct from the devices
* attached to it).
*/
/*
* Maximum number of times to loop while clearing pending data from the
* keyboard controller.
*/
#define MAX_JUNK_ITERATIONS 1000
/*
* Maximum time to wait for the keyboard to become ready to accept data
* (maximum time = MAX_WAIT_ITERATIONS * USECS_PER_WAIT (default is 250ms))
*/
#define MAX_WAIT_ITERATIONS 25000
#define USECS_PER_WAIT 10
#ifdef __sparc
(s), strlen(s)) == 0)
/*
* On some older SPARC platforms that have problems with the
* may be necessary to change the operating mode of the nexus
* to a polling-based (instead of interrupt-based) method.
* this variable is present to enable a worst-case workaround so
* owners of these systems can still retain a working keyboard.
*
* The `i8042_polled_mode' variable can be used to force polled
* mode for platforms that have this issue, but for which
* automatic relief is not implemented.
*
* In the off chance that one of the platforms is misidentified
* as requiried polling mode, `i8042_force_interrupt_mode' can
* be set to force the nexus to use interrupts.
*/
int i8042_fast_poll_interval; /* usecs */
int i8042_slow_poll_interval; /* usecs */
#endif /* __sparc */
#ifdef DEBUG
int i8042_debug = 0;
#endif
/*
* function prototypes for bus ops routines:
*/
/*
* function prototypes for dev ops routines:
*/
void *, dev_info_t **);
ddi_bus_config_op_t, void *);
#ifdef __sparc
static boolean_t i8042_is_polling_platform(void);
#endif
/*
* bus ops and dev ops structures:
*/
static struct bus_ops i8042_bus_ops = {
NULL,
NULL,
NULL,
NULL, /* ddi_map_fault */
NULL, /* ddi_dma_map */
NULL, /* ddi_dma_allochdl */
NULL, /* ddi_dma_freehdl */
NULL, /* ddi_dma_bindhdl */
NULL, /* ddi_dma_unbindhdl */
NULL, /* ddi_dma_flush */
NULL, /* ddi_dma_win */
NULL, /* ddi_dma_mctl */
NULL, /* (*bus_get_eventcookie)(); */
NULL, /* (*bus_add_eventcall)(); */
NULL, /* (*bus_remove_eventcall)(); */
NULL, /* (*bus_post_event)(); */
NULL, /* bus_intr_ctl */
i8042_bus_config, /* bus_config */
i8042_bus_unconfig, /* bus_unconfig */
NULL, /* bus_fm_init */
NULL, /* bus_fm_fini */
NULL, /* bus_fm_access_enter */
NULL, /* bus_fm_access_exit */
NULL, /* bus_power */
i8042_intr_ops /* bus_intr_op */
};
0,
0,
(struct cb_ops *)0,
NULL,
};
/*
* module definitions:
*/
extern struct mod_ops mod_driverops;
&mod_driverops, /* Type of module. This one is a driver */
"i8042 nexus driver", /* Name of module. */
&i8042_ops, /* driver ops */
};
static struct modlinkage modlinkage = {
};
int
_init(void)
{
int e;
/*
* Install the module.
*/
e = mod_install(&modlinkage);
return (e);
}
int
_fini(void)
{
int e;
/*
* Remove the module.
*/
e = mod_remove(&modlinkage);
if (e != 0)
return (e);
return (e);
}
int
{
}
static void i8042_timeout(void *arg);
static void i8042_write_command_byte(struct i8042 *, unsigned char);
unsigned int i8042_unclaimed_interrupts = 0;
static void
{
/* Discard any junk data that may have been left around */
for (;;) {
unsigned char stat;
if (! (stat & I8042_STAT_OUTBF))
break;
}
}
static int
{
int which_port, i;
struct i8042_port *port;
/*
* If any children still have regs mapped or interrupts
* registered, return immediate failure (and do nothing).
*/
return (DDI_FAILURE);
}
#if defined(USE_SOFT_INTRS)
return (DDI_FAILURE);
}
#else
return (DDI_FAILURE);
}
#endif
}
}
#ifdef __sparc
/* If there may be an outstanding timeout, cancel it */
if (global->timeout_id != 0) {
}
#endif
/* Stop the controller from generating interrupts */
if (global->intrs_added) {
/*
* Remove the interrupts in the reverse order in
* which they were added
*/
global->iblock_cookies[i]);
}
}
#ifndef USE_SOFT_INTRS
#endif
}
}
sizeof (ddi_iblock_cookie_t));
}
}
return (DDI_SUCCESS);
}
/*
* Wait for the 8042 to fill the 'output' (from 8042 to host)
* buffer. If 8042 fails to fill the output buffer within an
* allowed time, return 1 (which means there is no data available),
* otherwise return 0
*/
static int
{
int timer = 0;
I8042_STAT_OUTBF)) {
if (++timer > OBF_WAIT_COUNT)
return (1);
drv_usecwait(10);
}
return (0);
}
/*
* Drain all queued bytes from the 8042.
* Return 0 for no error, <> 0 if there was an error.
*/
static int
{
int i;
for (i = 0; i < MAX_JUNK_ITERATIONS; i++) {
if (i8042_wait_obf(global))
break;
}
/*
* If we hit the maximum number of iterations, then there
* was a serious problem (e.g. our hardware may not be
* present or working properly).
*/
return (i == MAX_JUNK_ITERATIONS);
}
static int
{
struct i8042_port *port;
enum i8042_ports which_port;
int i;
#if !defined(USE_SOFT_INTRS)
#endif
static ddi_device_acc_attr_t attr = {
};
#ifdef __sparc
int interval;
#endif
switch (cmd) {
case DDI_RESUME:
return (DDI_SUCCESS);
case DDI_ATTACH:
/* Handled in the main function block */
break;
default:
return (DDI_FAILURE);
}
/*
* DDI_ATTACH processing
*/
!= DDI_SUCCESS)
goto fail;
/*
* Get the number of interrupts for this nexus
*/
goto fail;
#ifdef __sparc
if ((i8042_polled_mode || i8042_is_polling_platform()) &&
/*
* If we're on a platform that has known
* use polled mode.
*/
/*
* If there are no interrupts on the i8042 node,
* we may be on a brain-dead platform that only
* has interrupts properties on i8042's children
* (e.g. some UltraII-based boards)
* In this case, scan first-level children, and
* build a list of interrupts that each child uses,
* then create an `interrupts' property on the nexus node
* that contains the interrupts used by all children
*/
goto fail;
}
}
#else
goto fail;
}
#endif
sizeof (ddi_iblock_cookie_t), KM_NOSLEEP);
if (ddi_get_iblock_cookie(dip, i,
goto fail;
}
} else
#if defined(USE_SOFT_INTRS)
#else
(void *)DDI_INTR_SOFTPRI_DEFAULT);
/*
* Assume that the interrupt block cookie for port <n>
* is iblock_cookies[<n>] (a 1:1 mapping). If there are not
* enough interrupts to cover the number of ports, use
* the cookie from interrupt 0.
*/
cookie);
} else {
NULL);
}
#endif
}
/*
* Disable input and interrupts from both the main and aux ports.
*
* It is difficult if not impossible to read the command byte in
* a completely clean way. Reading the command byte may cause
* an interrupt, and there is no way to suppress interrupts without
* writing the command byte. On a PC we might rely on the fact
* that IRQ 1 is disabled and guaranteed not shared, but on
* other platforms the interrupt line might be shared and so
* causing an interrupt could be bad.
*
* Since we can't read the command byte and update it, we
* just set it to static values.
*/
/* Discard any junk data that may have been left around */
if (i8042_purge_outbuf(global) != 0)
goto fail;
!= DDI_SUCCESS)
goto fail;
/*
* Assume the number of interrupts is less that the number of
* bits in the variable used to keep track of which interrupt
* was added.
*/
/*
* The 8042 handles all interrupts, because all
* device access goes through the same I/O addresses.
*/
if (ddi_add_intr(dip, i,
goto fail;
}
/*
* Enable the main and aux data ports and interrupts
*/
#ifdef __sparc
if (i8042_polled_mode) {
/*
* Do not allow anyone to set the polling interval
* to an interval more frequent than I8042_MIN_POLL_INTERVAL --
* it could hose the system.
*/
if (interval < I8042_MIN_POLL_INTERVAL)
}
#endif
return (DDI_SUCCESS);
fail:
/* cleanup will succeed because no children have attached yet */
(void) i8042_cleanup(global);
return (DDI_FAILURE);
}
/*ARGSUSED*/
static int
{
switch (cmd) {
case DDI_SUSPEND:
/*
* Do not disable the keyboard controller for x86 suspend, as
* the keyboard can be used to bring the system out of
* suspend.
*/
#ifdef __sparc
/* Disable interrupts and controller devices before suspend */
#endif
return (DDI_SUCCESS);
case DDI_DETACH:
/* DETACH can only succeed if cleanup succeeds */
return (i8042_cleanup(global));
default:
return (DDI_FAILURE);
}
}
/*
* The primary interface to us from our children is via virtual registers.
* This is the entry point that allows our children to "map" these
* virtual registers.
*/
static int
{
struct i8042_port *port;
enum i8042_ports which_port;
int *iprop;
unsigned int iprop_len;
int rnumber;
case DDI_MT_REGSPEC:
break;
case DDI_MT_RNUMBER:
DDI_SUCCESS) {
#if defined(DEBUG)
#endif
return (DDI_FAILURE);
}
#if defined(DEBUG)
if (iprop_len != 1) {
return (DDI_FAILURE);
}
return (DDI_FAILURE);
}
#endif
ddi_prop_free((void *)iprop);
#if defined(DEBUG)
"%s #%d: bad 'reg' value %d on %s@%s",
return (DDI_FAILURE);
}
#endif
break;
default:
#if defined(DEBUG)
#endif
return (DDI_FAILURE);
}
#if defined(DEBUG)
"%s #%d: partial mapping attempt for %s@%s ignored",
}
#endif
case DDI_MO_MAP_LOCKED:
#if defined(USE_SOFT_INTRS)
#else
#endif
/*
* Support get8, put8 and _rep_put8
*/
*addrp = 0;
return (DDI_SUCCESS);
case DDI_MO_UNMAP:
return (DDI_SUCCESS);
default:
return (DDI_FAILURE);
}
}
#ifdef __sparc
static void
i8042_timeout(void *arg)
{
int interval;
/*
* Allow the polling speed to be changed on the fly --
* catch it here and update the intervals used.
*/
if (i8042_fast_poll_interval != i8042_poll_interval) {
if (interval < I8042_MIN_POLL_INTERVAL)
}
/*
* If the ISR returned true, start polling at a faster rate to
* increate responsiveness. Once the keyboard or mouse go idle,
* the ISR will return UNCLAIMED, and we'll go back to the slower
* polling rate. This gives some positive hysteresis (but not
* negative, since we go back to the slower polling interval after
* only one UNCLAIMED). This has shown to be responsive enough,
* even for fast typers.
*/
if (i8042_polled_mode)
else
i8042_p->timeout_id = 0;
}
#endif
/*
* i8042 hardware interrupt routine. Called for both main and aux port
* interrupts.
*/
static unsigned int
{
enum i8042_ports which_port;
unsigned char stat;
unsigned char byte;
int new_wptr;
struct i8042_port *port;
#ifdef DEBUG
#endif
if (! (stat & I8042_STAT_OUTBF)) {
#ifdef DEBUG
#endif
return (DDI_INTR_UNCLAIMED);
}
if (! port->initialized) {
#ifdef DEBUG
#endif
return (DDI_INTR_CLAIMED);
}
/*
* If interception is enabled, and the byte matches what is being
* waited for, clear the interception flag and trigger a softintr
* that will signal the waiter, then exit the interrupt handler
* without passing the byte to the child's interrupt handler.
*/
#ifdef DEBUG
#endif
return (DDI_INTR_CLAIMED);
}
#if defined(DEBUG)
}
#endif
#ifdef DEBUG
#endif
return (DDI_INTR_CLAIMED);
}
#if defined(USE_SOFT_INTRS)
if (port->soft_intr_enabled)
#endif
#if !defined(USE_SOFT_INTRS)
#endif
#ifdef DEBUG
#endif
return (DDI_INTR_CLAIMED);
}
static void
{
}
/*
* Send a byte to either the i8042 command or data register, depending on
* the argument.
*/
static void
{
int tries = 0;
/*
* First, wait for the i8042 to be ready to accept data.
*/
/*CONSTANTCONDITION*/
while (1) {
if ((stat & I8042_STAT_INBF) == 0) {
break;
}
/* Don't wait unless we're going to check again */
if (++tries >= max_wait_iterations)
break;
else
}
#ifdef DEBUG
if (tries >= MAX_WAIT_ITERATIONS)
#endif
}
/*
* Here's the interface to the virtual registers on the device.
*
* Normal interrupt-driven I/O:
*
* I8042_INT_INPUT_AVAIL (r/o)
* Interrupt mode input bytes available? Zero = No.
* I8042_INT_INPUT_DATA (r/o)
* Fetch interrupt mode input byte.
* I8042_INT_OUTPUT_DATA (w/o)
* Interrupt mode output byte.
*
* Polled I/O, used by (e.g.) kmdb, when normal system services are
* unavailable:
*
* I8042_POLL_INPUT_AVAIL (r/o)
* Polled mode input bytes available? Zero = No.
* I8042_POLL_INPUT_DATA (r/o)
* Polled mode input byte.
* I8042_POLL_OUTPUT_DATA (w/o)
* Polled mode output byte.
*
* Note that in polled mode we cannot use cmn_err; only prom_printf is safe.
*/
static uint8_t
{
struct i8042_port *port;
ddi_acc_hdl_t *h;
h = (ddi_acc_hdl_t *)handlep;
case I8042_INT_INPUT_AVAIL:
return (ret);
case I8042_INT_INPUT_DATA:
} else {
#if defined(DEBUG)
"i8042: Tried to read from empty buffer");
#endif
ret = 0;
}
break;
#if defined(DEBUG)
case I8042_INT_OUTPUT_DATA:
case I8042_POLL_OUTPUT_DATA:
(void *)addr);
ret = 0;
break;
#endif
case I8042_POLL_INPUT_AVAIL:
return (B_TRUE);
for (;;) {
if ((stat & I8042_STAT_OUTBF) == 0)
return (B_FALSE);
case MAIN_PORT:
if ((stat & I8042_STAT_AUXBF) == 0)
return (B_TRUE);
break;
case AUX_PORT:
if ((stat & I8042_STAT_AUXBF) != 0)
return (B_TRUE);
break;
default:
}
/*
* Data for wrong port pending; discard it.
*/
}
/* NOTREACHED */
case I8042_POLL_INPUT_DATA:
return (ret);
}
if ((stat & I8042_STAT_OUTBF) == 0) {
#if defined(DEBUG)
prom_printf("I8042_POLL_INPUT_DATA: no data!\n");
#endif
return (0);
}
case MAIN_PORT:
if ((stat & I8042_STAT_AUXBF) == 0)
return (ret);
break;
case AUX_PORT:
if ((stat & I8042_STAT_AUXBF) != 0)
return (ret);
break;
}
#if defined(DEBUG)
prom_printf("I8042_POLL_INPUT_DATA: data for wrong port!\n");
#endif
return (0);
default:
#if defined(DEBUG)
(void *)addr);
#endif
ret = 0;
break;
}
return (ret);
}
/*
* Send the byte specified and wait for a reply -- either the retry response,
* or another response (assumed to be an acknowledgement). If the retry
* response is received within the timeout period, the initial byte is resent
* to the 8042.
*/
static int
{
int timedout = 0;
/*
* Intercept the command response so that the 8042 interrupt handler
* does not call the port's interrupt handler.
*/
/* Maximum time to wait: */
do {
/*
* Wait for the command response
*/
while (!port->intercept_complete) {
!port->intercept_complete) {
timedout = 1;
break;
}
}
/*
* If the intercepted byte is the retry response, keep retrying
* until we time out, or until the success response is received.
*/
if (port->intercept_complete &&
return (timedout);
}
/*
* The _rep_put8() operation is designed to allow child drivers to
* execute commands that have responses or that have responses plus an
* option byte. These commands need to be executed atomically with respect
* to commands from other children (some 8042 implementations get confused
* when other child devices intersperse their commands while a command
* to a different 8042-connected device is in flight).
*
* haddr points to a buffer with either 3 or 4 bytes. Three bytes if a
* command (byte 0) is being sent for which we expect a response code (byte 1)
* (this function blocks until we either read a response code (or the retry
* code (byte 2)) or until a timer expires).
* Four if the command (byte 0) requires a response (byte 1) and then an
* option byte (byte 3). The option byte is only sent iff the response code
* expected is received before the timeout. As with the 3-byte request, byte
* 2 is the retry response.
*
* While this function may technically called in interrupt context, it may
* block (depending on the IPL of the i8042 interrupt handler vs. the handler
* executing) for as long as the timeout (and fail if i8042_intr cannot run).
*
* flags are ignored.
*
*/
/*ARGSUSED*/
static void
{
struct i8042_port *port;
int timedout = 0;
ddi_acc_hdl_t *h;
h = (ddi_acc_hdl_t *)handlep;
/*
* If this function is called, somehow, while we're in i8042_intr,
* the logic below will not work. That situation should never be
* possible.
*/
/*
* Only support the main port for now
*/
devaddr != I8042_POLL_CMD_PLUS_PARAM)) {
#ifdef DEBUG
prom_printf("WARNING: i8042_rep_put8(): port or address "
"invalid\n");
#endif
return;
}
/*
* Only support commands with MAX one parameter. The format of the
* buffer supplied must be { <CMD>, <CMD_OK_RESPONSE>[, <PARAMETER>] }
*/
#ifdef DEBUG
prom_printf("WARNING: i8042_rep_put8(): Invalid repetition "
"count (%d)\n", (int)repcount);
#endif
return;
}
if (polled) {
} else {
/*
* Mutexes are only required for the non-polled (polled
* via the virtual registers, NOT via the polling mechanism
* used for systems without 8042 interrupts) case, because
* when polling is used, the system is single-threaded
* with interrupts disabled.
*/
}
/* Initialize the response and retry bytes from the caller */
/*
* If the first byte was processed before the timeout period, and
* there's an option byte, send it now.
*/
haddr[2]);
}
#ifdef DEBUG
if (timedout && i8042_debug)
prom_printf("WARNING: i8042_rep_put8(): timed out waiting for "
"command response\n");
#endif
if (!polled)
}
static void
{
struct i8042_port *port;
ddi_acc_hdl_t *h;
h = (ddi_acc_hdl_t *)handlep;
case I8042_INT_OUTPUT_DATA:
case I8042_POLL_OUTPUT_DATA:
break;
}
}
static void
{
ddi_acc_hdl_t *h;
h = (ddi_acc_hdl_t *)handlep;
case I8042_INT_OUTPUT_DATA:
case I8042_POLL_OUTPUT_DATA:
break;
case I8042_INT_CMD_PLUS_PARAM:
break;
#if defined(DEBUG)
case I8042_INT_INPUT_AVAIL:
case I8042_INT_INPUT_DATA:
case I8042_POLL_INPUT_AVAIL:
case I8042_POLL_INPUT_DATA:
(void *)addr);
break;
default:
(void *)addr);
break;
#endif
}
}
/* ARGSUSED */
static int
{
struct i8042_port *port;
#if defined(USE_SOFT_INTRS)
int ret;
#endif
switch (intr_op) {
*(int *)result = DDI_INTR_TYPE_FIXED;
break;
case DDI_INTROP_GETCAP:
== DDI_FAILURE)
*(int *)result = 0;
break;
case DDI_INTROP_NINTRS:
case DDI_INTROP_NAVAIL:
*(int *)result = 1;
break;
case DDI_INTROP_ALLOC:
break;
case DDI_INTROP_FREE:
break;
case DDI_INTROP_GETPRI:
/* Hard coding it for x86 */
*(int *)result = 5;
break;
case DDI_INTROP_ADDISR:
#if defined(USE_SOFT_INTRS)
if (ret != DDI_SUCCESS) {
#if defined(DEBUG)
"Cannot add soft interrupt for %s #%d, ret=%d.",
#endif /* defined(DEBUG) */
return (ret);
}
#else /* defined(USE_SOFT_INTRS) */
#endif /* defined(USE_SOFT_INTRS) */
break;
case DDI_INTROP_REMISR:
#if defined(USE_SOFT_INTRS)
#else /* defined(USE_SOFT_INTRS) */
#endif /* defined(USE_SOFT_INTRS) */
break;
case DDI_INTROP_ENABLE:
#if defined(USE_SOFT_INTRS)
#else /* defined(USE_SOFT_INTRS) */
#endif /* defined(USE_SOFT_INTRS) */
break;
case DDI_INTROP_DISABLE:
#if defined(USE_SOFT_INTRS)
#endif /* defined(USE_SOFT_INTRS) */
break;
default:
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
static int
{
int *iprop;
unsigned int iprop_len;
int which_port;
char name[16];
switch (op) {
case DDI_CTLOPS_INITCHILD:
DDI_SUCCESS) {
#if defined(DEBUG)
#endif
return (DDI_FAILURE);
}
which_port = iprop[0];
ddi_prop_free((void *)iprop);
return (DDI_SUCCESS);
case DDI_CTLOPS_UNINITCHILD:
return (DDI_SUCCESS);
case DDI_CTLOPS_REPORTDEV:
return (DDI_SUCCESS);
default:
}
/* NOTREACHED */
}
static dev_info_t *
{
return ((dev_info_t *)NULL);
}
break;
}
return (child);
}
static void
{
int acpi_off = 0;
char *acpi_prop;
/* don't alloc unless acpi is off */
acpi_off = 1;
}
}
if (acpi_off == 0) {
return;
}
if (nodes_needed & I8042_MOUSE) {
/* mouse */
"reg", 1);
"interrupts", 2);
"compatible", "pnpPNP,f03");
/*
* The device_type property does not matter on SPARC. Retain it
* on x86 for compatibility with the previous pseudo-prom.
*/
"device_type", "mouse");
(void) ndi_devi_bind_driver(xdip, 0);
}
if (nodes_needed & I8042_KEYBOARD) {
/* keyboard */
"reg", 0);
"interrupts", 1);
"compatible", "pnpPNP,303");
"device_type", "keyboard");
(void) ndi_devi_bind_driver(xdip, 0);
}
}
#endif
static int
{
int nodes_needed = 0;
int circ;
/*
* On x86 systems, if ACPI is disabled, the only way the
* keyboard and mouse can be enumerated is by creating them
* manually. The following code searches for the existence of
* the keyboard and mouse nodes and creates them if they are not
* found.
*/
/* If the mouse and keyboard nodes do not already exist, create them */
if (nodes_needed)
#endif
}
static int
{
/*
* The NDI_UNCONFIG flag allows the reference count on this nexus to be
* decremented when children's drivers are unloaded, enabling the nexus
* itself to be unloaded.
*/
}
#ifdef __sparc
static int
{
int interrupts[MAX_INTERRUPTS];
int i = 0;
/* Walk the children of this node, scanning for interrupts properties */
while (nintr > 0 && i < MAX_INTERRUPTS) {
}
}
}
interrupts, i) != DDI_PROP_SUCCESS) {
return (DDI_FAILURE);
}
/*
* Oh, the humanity. On the platforms on which we need to
* synthesize an interrupts property, we ALSO need to update the
* device_type property, and set it to "serial" in order for the
* correct interrupt PIL to be chosen by the framework.
*/
!= DDI_PROP_SUCCESS) {
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
static boolean_t
{
/*
* Returns true if this platform is one of the platforms
*/
if (PLATFORM_MATCH("SUNW,UltraAX-"))
return (B_TRUE);
else
return (B_FALSE);
}
#endif
/*
* arg1 is the global i8042 state pointer (not used)
* arg2 is the port pointer for the intercepted port
*/
/*ARGSUSED*/
static uint_t
{
if (!port->intercept_complete) {
return (DDI_INTR_CLAIMED);
}
return (DDI_INTR_UNCLAIMED);
}