Copyright (c) 1996, Sun Microsystems, Inc. All Rights Reserved
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 or http://www.opensolaris.org/os/licensing. 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]
#include <sys/pccard.h> int32_t prefixevent_handler(event_t event, int32_t priority, event_callback_args_t *args);
Solaris architecture specific (Solaris DDI)
The event.
The priority of the event.
A pointer to the event_callback_t structure.
Each instance of a PC Card driver must register an event handler to manage events associated with its PC Card. The driver event handler is registered using the event_handler field of the client_req_t structure passed to csx_RegisterClient(9F). The driver may also supply a parameter to be passed to its event handler function using the event_callback_args.client_data field. Typically, this argument is the driver instance's soft state pointer. The driver also registers which events it is interested in receiving through the EventMask field of the client_req_t structure.
Each event is delivered to the driver with a priority, priority. High priority events with CS_EVENT_PRI_HIGH set in priority are delivered above lock level, and the driver must use its high-level event mutex initialized with the iblk_cookie returned by csx_RegisterClient(9F) to protect such events. Low priority events with CS_EVENT_PRI_LOW set in priority are delivered below lock level, and the driver must use its low-level event mutex initialized with a NULL interrupt cookie to protect these events.
csx_RegisterClient(9F) registers the driver's event handler, but no events begin to be delivered to the driver until after a successful call to csx_RequestSocketMask(9F).
In all cases, Card Services delivers an event to each driver instance associated with a function on a multiple function PC Card.
The events and their indications are listed below; they are always delivered as low priority unless otherwise noted: CS_EVENT_REGISTRATION_COMPLETE
A registration request processed in the background has been completed.
A PC Card has been inserted in a socket.
A PC Card's READY line has transitioned from the busy to ready state.
A PC Card has been removed from a socket. This event is delivered twice; first as a high priority event, followed by delivery as a low priority event. As a high priority event, the event handler should only note that the PC Card is no longer present to prevent accesses to the hardware from occurring. As a low priority event, the event handler should release the configuration and free all I/O, window and IRQ resources for use by other PC Cards.
The battery on a PC Card is weak and is in need of replacement.
The battery on a PC Card is no longer providing operational voltage.
Card Services has received a resume notification from the system's Power Management software.
Card Services has received a suspend notification from the system's Power Management software.
A mechanical latch has been manipulated preventing the removal of the PC Card from the socket.
A mechanical latch has been manipulated allowing the removal of the PC Card from the socket.
A request that the PC Card be ejected from a socket using a motor-driven mechanism.
A motor has completed ejecting a PC Card from a socket.
A queued erase request that is processed in the background has been completed.
A request that a PC Card be inserted into a socket using a motor-driven mechanism.
A motor has completed inserting a PC Card in a socket.
A hardware reset has occurred.
A request for a physical reset by a client.
A reset request that is processed in the background has been completed.
A reset is about to occur.
A request that the client return its client information data. If GET_CLIENT_INFO_SUBSVC(args->client_info.Attributes) is equal to CS_CLIENT_INFO_SUBSVC_CS, the driver should fill in the other fields in the client_info structure as described below, and return CS_SUCCESS. Otherwise, it should return CS_UNSUPPORTED_EVENT. args->client_data.Attributes
Must be OR'ed with CS_CLIENT_INFO_VALID.
Must be set to a driver-private version number.
Must be set to CS_VERSION.
Must be set to the revision date of the PC Card driver, using CS_CLIENT_INFO_MAKE_DATE(day, month, year). day must be the day of the month, month must be the month of the year, and year must be the year, offset from a base of 1980. For example, this field could be set to a revision date of July 4 1997 with CS_CLIENT_INFO_MAKE_DATE(4, 7, 17).
A string describing the PC Card driver should be copied into this space.
A string supplying the name of the PC Card driver vendor should be copied into this space.
A string supplying the name of the PC Card driver will be copied into this space by Card Services after the PC Card driver has successfully processed this event; the driver does not need to initialize this field.
The write protect status of the PC Card in the indicated socket has changed. The current write protect state of the PC Card is in the args->info field: CS_EVENT_WRITE_PROTECT_WPOFF
Card is not write protected.
Card is write protected.
The structure members of event_callback_args_t are:
void *info; /* event-specific information */ void *client_data; /* driver-private data */ client_info_t client_info; /* client information*/
The structure members of client_info_t are:
unit32_t Attributes; /* attributes */ unit32_t Revisions; /* version number */ uint32_t CSLevel; /* Card Services version */ uint32_t RevDate; /* revision date */ char ClientName[CS_CLIENT_INFO_MAX_NAME_LEN]; /*PC Card driver description */ char VendorName[CS_CLIENT_INFO_MAX_NAME_LEN]; /*PC Card driver vendor name */ char DriverName[MODMAXNAMELEN]; /* PC Card driver name */
The event was handled successfully.
Driver does not support this event.
Error occurred while handling this event.
This function is called from high-level interrupt context in the case of high priority events, and from kernel context in the case of low priority events.
static int xx_event(event_t event, int priority, event_callback_args_t *args) { int rval; struct xxx *xxx = args->client_data; client_info_t *info = &args->client_info; switch (event) { case CS_EVENT_REGISTRATION_COMPLETE: ASSERT(priority & CS_EVENT_PRI_LOW); mutex_enter(&xxx->event_mutex); xxx->card_state |= XX_REGISTRATION_COMPLETE; mutex_exit(&xxx->event_mutex); rval = CS_SUCCESS; break; case CS_EVENT_CARD_READY: ASSERT(priority & CS_EVENT_PRI_LOW); rval = xx_card_ready(xxx); mutex_exit(&xxx->event_mutex); break; case CS_EVENT_CARD_INSERTION: ASSERT(priority & CS_EVENT_PRI_LOW); mutex_enter(&xxx->event_mutex); rval = xx_card_insertion(xxx); mutex_exit(&xxx->event_mutex); break; case CS_EVENT_CARD_REMOVAL: if (priority & CS_EVENT_PRI_HIGH) { mutex_enter(&xxx->hi_event_mutex); xxx->card_state &= ~XX_CARD_PRESENT; mutex_exit(&xxx->hi_event_mutex); } else { mutex_enter(&xxx->event_mutex); rval = xx_card_removal(xxx); mutex_exit(&xxx->event_mutex); } break; case CS_EVENT_CLIENT_INFO: ASSERT(priority & CS_EVENT_PRI_LOW); if (GET_CLIENT_INFO_SUBSVC_CS(info->Attributes) == CS_CLIENT_INFO_SUBSVC_CS) { info->Attributes |= CS_CLIENT_INFO_VALID; info->Revision = 4; info->CSLevel = CS_VERSION; info->RevDate = CS_CLIENT_INFO_MAKE_DATE(4, 7, 17); (void)strncpy(info->ClientName, "WhizBang Ultra Zowie PC card driver", CS_CLIENT_INFO_MAX_NAME_LEN) "ACME PC card drivers, Inc.", CS_CLIENT_INFO_MAX_NAME_LEN); rval = CS_SUCCESS; } else { rval = CS_UNSUPPORTED_EVENT; } break; case CS_EVENT_WRITE_PROTECT: ASSERT(priority & CS_EVENT_PRI_LOW); mutex_enter(&xxx->event_mutex); if (args->info == CS_EVENT_WRITE_PROTECT_WPOFF) { xxx->card_state &= ~XX_WRITE_PROTECTED; } else { xxx->card_state |= XX_WRITE_PROTECTED; } mutex_exit(&xxx->event_mutex); rval = CS_SUCCESS; break; default: rval = CS_UNSUPPORTED_EVENT; break; } return (rval); }
csx_Event2Text(9F), csx_RegisterClient(9F), csx_RequestSocketMask(9F)