2 .\" Copyright (c) 1996, Sun Microsystems, Inc. All Rights Reserved
3 .\" 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.
4 .\" 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.
5 .\" 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]
6 .TH CSX_EVENT_HANDLER 9E "Nov 22, 1996"
8 csx_event_handler \- PC Card driver event handler
12 #include <sys/pccard.h>
16 \fBint32_t prefix\fR\fBevent_handler\fR(\fBevent_t\fR \fIevent\fR, \fBint32_t\fR \fIpriority\fR,
17 \fBevent_callback_args_t *\fR\fIargs\fR);
23 Solaris architecture specific (Solaris \fBDDI) \fR
40 The priority of the event.
49 A pointer to the \fBevent_callback_t\fR structure.
55 Each instance of a \fBPC \fRCard driver must register an event handler to
56 manage events associated with its \fBPC \fRCard. The driver event handler is
57 registered using the \fBevent_handler\fR field of the \fBclient_req_t\fR
58 structure passed to \fBcsx_RegisterClient\fR(9F). The driver may also supply a
59 parameter to be passed to its event handler function using the
60 \fBevent_callback_args.client_data\fR field. Typically, this argument is the
61 driver instance's soft state pointer. The driver also registers which events it
62 is interested in receiving through the \fBEventMask\fR field of the
63 \fBclient_req_t\fR structure.
66 Each event is delivered to the driver with a priority, \fIpriority\fR. High
67 priority events with \fBCS_EVENT_PRI_HIGH\fR set in \fIpriority\fR are
68 delivered above lock level, and the driver must use its high-level event mutex
69 initialized with the \fBiblk_cookie\fR returned by \fBcsx_RegisterClient\fR(9F)
70 to protect such events. Low priority events with \fBCS_EVENT_PRI_LOW\fR set in
71 \fIpriority\fR are delivered below lock level, and the driver must use its
72 low-level event mutex initialized with a \fBNULL \fRinterrupt cookie to protect
76 \fBcsx_RegisterClient\fR(9F) registers the driver's event handler, but no
77 events begin to be delivered to the driver until after a successful call to
78 \fBcsx_RequestSocketMask\fR(9F).
81 In all cases, Card Services delivers an event to each driver instance
82 associated with a function on a multiple function \fBPC \fRCard.
83 .SS "Event Indications"
86 The events and their indications are listed below; they are always delivered as
87 low priority unless otherwise noted:
91 \fB\fBCS_EVENT_REGISTRATION_COMPLETE\fR\fR
95 A registration request processed in the background has been completed.
101 \fB\fBCS_EVENT_CARD_INSERTION\fR\fR
105 A \fBPC \fRCard has been inserted in a socket.
111 \fB\fBCS_EVENT_CARD_READY\fR\fR
115 A \fBPC \fRCard's \fBREADY \fRline has transitioned from the busy to ready
122 \fB\fBCS_EVENT_CARD_REMOVAL\fR\fR
126 A \fBPC \fRCard has been removed from a socket. This event is delivered twice;
127 first as a high priority event, followed by delivery as a low priority event.
128 As a high priority event, the event handler should only note that the \fBPC
129 \fRCard is no longer present to prevent accesses to the hardware from
130 occurring. As a low priority event, the event handler should release the
131 configuration and free all \fBI/O\fR, window and \fBIRQ \fRresources for use by
132 other \fBPC \fRCards.
138 \fB\fBCS_EVENT_BATTERY_LOW\fR\fR
142 The battery on a \fBPC \fRCard is weak and is in need of replacement.
148 \fB\fBCS_EVENT_BATTERY_DEAD\fR\fR
152 The battery on a \fBPC \fRCard is no longer providing operational voltage.
158 \fB\fBCS_EVENT_PM_RESUME\fR\fR
162 Card Services has received a resume notification from the system's Power
169 \fB\fBCS_EVENT_PM_SUSPEND\fR\fR
173 Card Services has received a suspend notification from the system's Power
180 \fB\fBCS_EVENT_CARD_LOCK\fR\fR
184 A mechanical latch has been manipulated preventing the removal of the \fBPC
185 \fRCard from the socket.
191 \fB\fBCS_EVENT_CARD_UNLOCK\fR\fR
195 A mechanical latch has been manipulated allowing the removal of the \fBPC
196 \fRCard from the socket.
202 \fB\fBCS_EVENT_EJECTION_REQUEST\fR\fR
206 A request that the \fBPC \fRCard be ejected from a socket using a motor-driven
213 \fB\fBCS_EVENT_EJECTION_COMPLETE\fR\fR
217 A motor has completed ejecting a \fBPC \fRCard from a socket.
223 \fB\fBCS_EVENT_ERASE_COMPLETE\fR\fR
227 A queued erase request that is processed in the background has been completed.
233 \fB\fBCS_EVENT_INSERTION_REQUEST\fR\fR
237 A request that a \fBPC \fRCard be inserted into a socket using a motor-driven
244 \fB\fBCS_EVENT_INSERTION_COMPLETE\fR\fR
248 A motor has completed inserting a \fBPC \fRCard in a socket.
254 \fB\fBCS_EVENT_CARD_RESET\fR\fR
258 A hardware reset has occurred.
264 \fB\fBCS_EVENT_RESET_REQUEST\fR\fR
268 A request for a physical reset by a client.
274 \fB\fBCS_EVENT_RESET_COMPLETE\fR\fR
278 A reset request that is processed in the background has been completed.
284 \fB\fBCS_EVENT_RESET_PHYSICAL\fR\fR
288 A reset is about to occur.
294 \fB\fBCS_EVENT_CLIENT_INFO\fR\fR
298 A request that the client return its client information data. If
299 \fBGET_CLIENT_INFO_SUBSVC(args->client_info.Attributes)\fR is equal to
300 \fBCS_CLIENT_INFO_SUBSVC_CS\fR, the driver should fill in the other fields in
301 the \fBclient_info\fR structure as described below, and return
302 \fBCS_SUCCESS\fR. Otherwise, it should return \fBCS_UNSUPPORTED_EVENT.\fR
306 \fB\fBargs->client_data.Attributes\fR\fR
310 Must be \fBOR\fR'ed with \fBCS_CLIENT_INFO_VALID\fR.
316 \fB\fBargs->client_data.Revision\fR\fR
320 Must be set to a driver-private version number.
326 \fB\fBargs->client_data.CSLevel\fR\fR
330 Must be set to \fBCS_VERSION\fR.
336 \fB\fBargs->client_data.RevDate\fR\fR
340 Must be set to the revision date of the \fBPC \fRCard driver, using
341 \fBCS_CLIENT_INFO_MAKE_DATE(\fIday\fR,\fR \fImonth\fR, \fIyear\fR). \fIday\fR
342 must be the day of the month, \fImonth\fR must be the month of the year, and
343 \fIyear\fR must be the year, offset from a base of 1980. For example, this
344 field could be set to a revision date of July 4 1997 with
345 \fBCS_CLIENT_INFO_MAKE_DATE(4, 7, 17)\fR.
351 \fB\fBargs->client_data.ClientName\fR\fR
355 A string describing the \fBPC \fRCard driver should be copied into this space.
361 \fB\fBargs->client_data.VendorName\fR\fR
365 A string supplying the name of the \fBPC \fRCard driver vendor should be copied
372 \fB\fBargs->client_data.DriverName\fR\fR
376 A string supplying the name of the \fBPC \fRCard driver will be copied into
377 this space by Card Services after the \fBPC \fRCard driver has successfully
378 processed this event; the driver does not need to initialize this field.
386 \fB\fBCS_EVENT_WRITE_PROTECT\fR\fR
390 The write protect status of the \fBPC \fRCard in the indicated socket has
391 changed. The current write protect state of the \fBPC \fRCard is in the
392 \fBargs->info\fR field:
396 \fB\fBCS_EVENT_WRITE_PROTECT_WPOFF\fR\fR
400 Card is not write protected.
406 \fB\fBCS_EVENT_WRITE_PROTECT_WPON\fR\fR
410 Card is write protected.
415 .SH STRUCTURE MEMBERS
418 The structure members of \fBevent_callback_args_t\fR are:
422 void *info; /* event-specific information */
423 void *client_data; /* driver-private data */
424 client_info_t client_info; /* client information*/
430 The structure members of \fBclient_info_t\fR are:
434 unit32_t Attributes; /* attributes */
435 unit32_t Revisions; /* version number */
436 uint32_t CSLevel; /* Card Services version */
437 uint32_t RevDate; /* revision date */
438 char ClientName[CS_CLIENT_INFO_MAX_NAME_LEN];
439 /*PC Card driver description */
440 char VendorName[CS_CLIENT_INFO_MAX_NAME_LEN];
441 /*PC Card driver vendor name */
442 char DriverName[MODMAXNAMELEN];
443 /* PC Card driver name */
451 \fB\fBCS_SUCCESS\fR\fR
454 The event was handled successfully.
460 \fB\fBCS_UNSUPPORTED_EVENT\fR\fR
463 Driver does not support this event.
469 \fB\fBCS_FAILURE\fR\fR
472 Error occurred while handling this event.
478 This function is called from high-level interrupt context in the case of high
479 priority events, and from kernel context in the case of low priority events.
485 xx_event(event_t event, int priority, event_callback_args_t *args)
488 struct xxx *xxx = args->client_data;
489 client_info_t *info = &args->client_info;
492 case CS_EVENT_REGISTRATION_COMPLETE:
493 ASSERT(priority & CS_EVENT_PRI_LOW);
494 mutex_enter(&xxx->event_mutex);
495 xxx->card_state |= XX_REGISTRATION_COMPLETE;
496 mutex_exit(&xxx->event_mutex);
500 case CS_EVENT_CARD_READY:
501 ASSERT(priority & CS_EVENT_PRI_LOW);
502 rval = xx_card_ready(xxx);
503 mutex_exit(&xxx->event_mutex);
506 case CS_EVENT_CARD_INSERTION:
507 ASSERT(priority & CS_EVENT_PRI_LOW);
508 mutex_enter(&xxx->event_mutex);
509 rval = xx_card_insertion(xxx);
510 mutex_exit(&xxx->event_mutex);
513 case CS_EVENT_CARD_REMOVAL:
514 if (priority & CS_EVENT_PRI_HIGH) {
515 mutex_enter(&xxx->hi_event_mutex);
516 xxx->card_state &= ~XX_CARD_PRESENT;
517 mutex_exit(&xxx->hi_event_mutex);
519 mutex_enter(&xxx->event_mutex);
520 rval = xx_card_removal(xxx);
521 mutex_exit(&xxx->event_mutex);
525 case CS_EVENT_CLIENT_INFO:
526 ASSERT(priority & CS_EVENT_PRI_LOW);
527 if (GET_CLIENT_INFO_SUBSVC_CS(info->Attributes) ==
528 CS_CLIENT_INFO_SUBSVC_CS) {
529 info->Attributes |= CS_CLIENT_INFO_VALID;
531 info->CSLevel = CS_VERSION;
532 info->RevDate = CS_CLIENT_INFO_MAKE_DATE(4, 7, 17);
533 (void)strncpy(info->ClientName,
534 "WhizBang Ultra Zowie PC card driver",
535 CS_CLIENT_INFO_MAX_NAME_LEN)
537 "ACME PC card drivers, Inc.",
538 CS_CLIENT_INFO_MAX_NAME_LEN);
541 rval = CS_UNSUPPORTED_EVENT;
546 case CS_EVENT_WRITE_PROTECT:
547 ASSERT(priority & CS_EVENT_PRI_LOW);
548 mutex_enter(&xxx->event_mutex);
549 if (args->info == CS_EVENT_WRITE_PROTECT_WPOFF) {
550 xxx->card_state &= ~XX_WRITE_PROTECTED;
552 xxx->card_state |= XX_WRITE_PROTECTED;
554 mutex_exit(&xxx->event_mutex);
559 rval = CS_UNSUPPORTED_EVENT;
571 \fBcsx_Event2Text\fR(9F), \fBcsx_RegisterClient\fR(9F),
572 \fBcsx_RequestSocketMask\fR(9F)
575 \fIPC Card 95 Standard\fR, PCMCIA/JEIDA