1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
|
'\" te
.\" 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]
.TH csx_event_handler 9E "22 Nov 1996" "SunOS 5.11" "Driver Entry Points"
.SH NAME
csx_event_handler \- PC Card driver event handler
.SH SYNOPSIS
.LP
.nf
#include <sys/pccard.h>
\fBint32_t prefix\fR\fBevent_handler\fR(\fBevent_t\fR \fIevent\fR, \fBint32_t\fR \fIpriority\fR,
\fBevent_callback_args_t *\fR\fIargs\fR);
.fi
.SH INTERFACE LEVEL
.sp
.LP
Solaris architecture specific (Solaris \fBDDI) \fR
.SH PARAMETERS
.sp
.ne 2
.mk
.na
\fB\fIevent\fR\fR
.ad
.RS 12n
.rt
The event.
.RE
.sp
.ne 2
.mk
.na
\fB\fIpriority\fR\fR
.ad
.RS 12n
.rt
The priority of the event.
.RE
.sp
.ne 2
.mk
.na
\fB\fIargs\fR\fR
.ad
.RS 12n
.rt
A pointer to the \fBevent_callback_t\fR structure.
.RE
.SH DESCRIPTION
.sp
.LP
Each instance of a \fBPC \fRCard driver must register an event handler to
manage events associated with its \fBPC \fRCard. The driver event handler is
registered using the \fBevent_handler\fR field of the \fBclient_req_t\fR
structure passed to \fBcsx_RegisterClient\fR(9F). The driver may also supply a
parameter to be passed to its event handler function using the
\fBevent_callback_args.client_data\fR 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 \fBEventMask\fR field of the
\fBclient_req_t\fR structure.
.sp
.LP
Each event is delivered to the driver with a priority, \fIpriority\fR. High
priority events with \fBCS_EVENT_PRI_HIGH\fR set in \fIpriority\fR are
delivered above lock level, and the driver must use its high-level event mutex
initialized with the \fBiblk_cookie\fR returned by \fBcsx_RegisterClient\fR(9F)
to protect such events. Low priority events with \fBCS_EVENT_PRI_LOW\fR set in
\fIpriority\fR are delivered below lock level, and the driver must use its
low-level event mutex initialized with a \fBNULL \fRinterrupt cookie to protect
these events.
.sp
.LP
\fBcsx_RegisterClient\fR(9F) registers the driver's event handler, but no
events begin to be delivered to the driver until after a successful call to
\fBcsx_RequestSocketMask\fR(9F).
.sp
.LP
In all cases, Card Services delivers an event to each driver instance
associated with a function on a multiple function \fBPC \fRCard.
.SS "Event Indications"
.sp
.LP
The events and their indications are listed below; they are always delivered as
low priority unless otherwise noted:
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_REGISTRATION_COMPLETE\fR\fR
.ad
.sp .6
.RS 4n
A registration request processed in the background has been completed.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_CARD_INSERTION\fR\fR
.ad
.sp .6
.RS 4n
A \fBPC \fRCard has been inserted in a socket.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_CARD_READY\fR\fR
.ad
.sp .6
.RS 4n
A \fBPC \fRCard's \fBREADY \fRline has transitioned from the busy to ready
state.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_CARD_REMOVAL\fR\fR
.ad
.sp .6
.RS 4n
A \fBPC \fRCard 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 \fBPC
\fRCard 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 \fBI/O\fR, window and \fBIRQ \fRresources for use by
other \fBPC \fRCards.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_BATTERY_LOW\fR\fR
.ad
.sp .6
.RS 4n
The battery on a \fBPC \fRCard is weak and is in need of replacement.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_BATTERY_DEAD\fR\fR
.ad
.sp .6
.RS 4n
The battery on a \fBPC \fRCard is no longer providing operational voltage.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_PM_RESUME\fR\fR
.ad
.sp .6
.RS 4n
Card Services has received a resume notification from the system's Power
Management software.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_PM_SUSPEND\fR\fR
.ad
.sp .6
.RS 4n
Card Services has received a suspend notification from the system's Power
Management software.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_CARD_LOCK\fR\fR
.ad
.sp .6
.RS 4n
A mechanical latch has been manipulated preventing the removal of the \fBPC
\fRCard from the socket.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_CARD_UNLOCK\fR\fR
.ad
.sp .6
.RS 4n
A mechanical latch has been manipulated allowing the removal of the \fBPC
\fRCard from the socket.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_EJECTION_REQUEST\fR\fR
.ad
.sp .6
.RS 4n
A request that the \fBPC \fRCard be ejected from a socket using a motor-driven
mechanism.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_EJECTION_COMPLETE\fR\fR
.ad
.sp .6
.RS 4n
A motor has completed ejecting a \fBPC \fRCard from a socket.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_ERASE_COMPLETE\fR\fR
.ad
.sp .6
.RS 4n
A queued erase request that is processed in the background has been completed.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_INSERTION_REQUEST\fR\fR
.ad
.sp .6
.RS 4n
A request that a \fBPC \fRCard be inserted into a socket using a motor-driven
mechanism.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_INSERTION_COMPLETE\fR\fR
.ad
.sp .6
.RS 4n
A motor has completed inserting a \fBPC \fRCard in a socket.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_CARD_RESET\fR\fR
.ad
.sp .6
.RS 4n
A hardware reset has occurred.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_RESET_REQUEST\fR\fR
.ad
.sp .6
.RS 4n
A request for a physical reset by a client.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_RESET_COMPLETE\fR\fR
.ad
.sp .6
.RS 4n
A reset request that is processed in the background has been completed.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_RESET_PHYSICAL\fR\fR
.ad
.sp .6
.RS 4n
A reset is about to occur.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_CLIENT_INFO\fR\fR
.ad
.sp .6
.RS 4n
A request that the client return its client information data. If
\fBGET_CLIENT_INFO_SUBSVC(args->client_info.Attributes)\fR is equal to
\fBCS_CLIENT_INFO_SUBSVC_CS\fR, the driver should fill in the other fields in
the \fBclient_info\fR structure as described below, and return
\fBCS_SUCCESS\fR. Otherwise, it should return \fBCS_UNSUPPORTED_EVENT.\fR
.sp
.ne 2
.mk
.na
\fB\fBargs->client_data.Attributes\fR\fR
.ad
.sp .6
.RS 4n
Must be \fBOR\fR'ed with \fBCS_CLIENT_INFO_VALID\fR.
.RE
.sp
.ne 2
.mk
.na
\fB\fBargs->client_data.Revision\fR\fR
.ad
.sp .6
.RS 4n
Must be set to a driver-private version number.
.RE
.sp
.ne 2
.mk
.na
\fB\fBargs->client_data.CSLevel\fR\fR
.ad
.sp .6
.RS 4n
Must be set to \fBCS_VERSION\fR.
.RE
.sp
.ne 2
.mk
.na
\fB\fBargs->client_data.RevDate\fR\fR
.ad
.sp .6
.RS 4n
Must be set to the revision date of the \fBPC \fRCard driver, using
\fBCS_CLIENT_INFO_MAKE_DATE(\fIday\fR,\fR \fImonth\fR, \fIyear\fR). \fIday\fR
must be the day of the month, \fImonth\fR must be the month of the year, and
\fIyear\fR 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
\fBCS_CLIENT_INFO_MAKE_DATE(4, 7, 17)\fR.
.RE
.sp
.ne 2
.mk
.na
\fB\fBargs->client_data.ClientName\fR\fR
.ad
.sp .6
.RS 4n
A string describing the \fBPC \fRCard driver should be copied into this space.
.RE
.sp
.ne 2
.mk
.na
\fB\fBargs->client_data.VendorName\fR\fR
.ad
.sp .6
.RS 4n
A string supplying the name of the \fBPC \fRCard driver vendor should be copied
into this space.
.RE
.sp
.ne 2
.mk
.na
\fB\fBargs->client_data.DriverName\fR\fR
.ad
.sp .6
.RS 4n
A string supplying the name of the \fBPC \fRCard driver will be copied into
this space by Card Services after the \fBPC \fRCard driver has successfully
processed this event; the driver does not need to initialize this field.
.RE
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_WRITE_PROTECT\fR\fR
.ad
.sp .6
.RS 4n
The write protect status of the \fBPC \fRCard in the indicated socket has
changed. The current write protect state of the \fBPC \fRCard is in the
\fBargs->info\fR field:
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_WRITE_PROTECT_WPOFF\fR\fR
.ad
.sp .6
.RS 4n
Card is not write protected.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_EVENT_WRITE_PROTECT_WPON\fR\fR
.ad
.sp .6
.RS 4n
Card is write protected.
.RE
.RE
.SH STRUCTURE MEMBERS
.sp
.LP
The structure members of \fBevent_callback_args_t\fR are:
.sp
.in +2
.nf
void *info; /* event-specific information */
void *client_data; /* driver-private data */
client_info_t client_info; /* client information*/
.fi
.in -2
.sp
.LP
The structure members of \fBclient_info_t\fR are:
.sp
.in +2
.nf
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 */
.fi
.in -2
.SH RETURN VALUES
.sp
.ne 2
.mk
.na
\fB\fBCS_SUCCESS\fR\fR
.ad
.RS 24n
.rt
The event was handled successfully.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_UNSUPPORTED_EVENT\fR\fR
.ad
.RS 24n
.rt
Driver does not support this event.
.RE
.sp
.ne 2
.mk
.na
\fB\fBCS_FAILURE\fR\fR
.ad
.RS 24n
.rt
Error occurred while handling this event.
.RE
.SH CONTEXT
.sp
.LP
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.
.SH EXAMPLES
.sp
.in +2
.nf
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);
}
.fi
.in -2
.SH SEE ALSO
.sp
.LP
\fBcsx_Event2Text\fR(9F), \fBcsx_RegisterClient\fR(9F),
\fBcsx_RequestSocketMask\fR(9F)
.sp
.LP
\fIPC Card 95 Standard\fR, PCMCIA/JEIDA
|