xref: /illumos-gate/usr/src/uts/common/pcmcia/cs/cs_stubs.c (revision 3df2e8b2fd61f45437285750d2880d6416a9200c)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * This is the PCMCIA Card Services kernel stubs module. It provides
29  *	the various PCMCIA kernel framework entry points.
30  */
31 
32 #if defined(DEBUG)
33 #define	CS_STUBS_DEBUG
34 #endif
35 
36 #include <sys/types.h>
37 #include <sys/systm.h>
38 #include <sys/user.h>
39 #include <sys/buf.h>
40 #include <sys/file.h>
41 #include <sys/uio.h>
42 #include <sys/conf.h>
43 #include <sys/stat.h>
44 #include <sys/autoconf.h>
45 #include <sys/vtoc.h>
46 #include <sys/dkio.h>
47 #include <sys/ddi.h>
48 #include <sys/sunddi.h>
49 #include <sys/debug.h>
50 #include <sys/varargs.h>
51 #include <sys/var.h>
52 #include <sys/proc.h>
53 #include <sys/thread.h>
54 #include <sys/utsname.h>
55 #include <sys/vtrace.h>
56 #include <sys/kstat.h>
57 #include <sys/kmem.h>
58 #include <sys/modctl.h>
59 #include <sys/kobj.h>
60 #include <sys/callb.h>
61 
62 #include <sys/pctypes.h>
63 #include <pcmcia/sys/cs_types.h>
64 #include <sys/pcmcia.h>
65 #include <sys/sservice.h>
66 #include <pcmcia/sys/cis.h>
67 #include <pcmcia/sys/cis_handlers.h>
68 #include <pcmcia/sys/cs.h>
69 #include <pcmcia/sys/cs_priv.h>
70 #include <pcmcia/sys/cs_stubs.h>
71 
72 #ifdef	CS_STUBS_DEBUG
73 int cs_stubs_debug = 0;
74 #endif
75 
76 static csfunction_t *cardservices = NULL;
77 static int do_cs_call = 0;
78 static int cs_no_carservices(int32_t, ...);
79 
80 #define	CardServices	(do_cs_call ? (*cardservices) :		\
81 			(cs_no_carservices))
82 
83 #ifdef	USE_CS_STUBS_MODULE
84 
85 /*
86  * Module linkage information for the kernel.
87  */
88 static struct modlmisc modlmisc = {
89 	&mod_miscops,
90 	"PCMCIA Card Services stub module"
91 };
92 
93 static struct modlinkage modlinkage = {
94 	MODREV_1,
95 	(void *)&modlmisc,
96 	NULL
97 };
98 
99 int
_init(void)100 _init(void)
101 {
102 	return (mod_install(&modlinkage));
103 }
104 
105 int
_fini(void)106 _fini(void)
107 {
108 	if (!do_cs_call)
109 	    return (mod_remove(&modlinkage));
110 	else
111 	    return (EBUSY);
112 }
113 
114 int
_info(struct modinfo * modinfop)115 _info(struct modinfo *modinfop)
116 {
117 	return (mod_info(&modlinkage, modinfop));
118 }
119 #endif	/* USE_CS_STUBS_MODULE */
120 
121 /*
122  * csx_register_cardservices - The Card Services loadable module
123  *	calls this runction to register it's entry point.
124  *
125  * Returns:	CS_SUCCESS - if operation sucessful
126  *		CS_UNSUPPORTED_FUNCTION - if invalid function code
127  *		CS_BAD_HANDLE - if Card Services is not registered
128  */
129 int32_t
csx_register_cardservices(cs_register_cardservices_t * rcs)130 csx_register_cardservices(cs_register_cardservices_t *rcs)
131 {
132 #ifdef	CS_STUBS_DEBUG
133 	if (cs_stubs_debug > 2)
134 		cmn_err(CE_CONT, "csx_register_cardservices: "
135 		    "magic: 0x%x function: 0x%x cardservices: 0x%p\n",
136 		    rcs->magic, rcs->function, (void *)rcs->cardservices);
137 #endif
138 
139 	if (rcs->magic != CS_STUBS_MAGIC)
140 	    return (CS_BAD_ARGS);
141 
142 	switch (rcs->function) {
143 	    case CS_ENTRY_REGISTER:
144 		cardservices = rcs->cardservices;
145 		do_cs_call = 1;
146 #ifdef	CS_STUBS_DEBUG
147 		if (cs_stubs_debug > 2)
148 			cmn_err(CE_CONT, "csx_register_cardservices: "
149 			    "CS_ENTRY_REGISTER\n");
150 #endif
151 
152 		return (CS_SUCCESS);
153 
154 	    case CS_ENTRY_DEREGISTER:
155 		do_cs_call = 0;
156 		cardservices = cs_no_carservices;
157 #ifdef	CS_STUBS_DEBUG
158 		if (cs_stubs_debug > 2)
159 			cmn_err(CE_CONT, "csx_register_cardservices: "
160 			    "CS_ENTRY_DEREGISTER\n");
161 #endif
162 		return (CS_UNSUPPORTED_FUNCTION);
163 
164 	    case CS_ENTRY_INQUIRE:
165 		rcs->cardservices = cardservices;
166 #ifdef	CS_STUBS_DEBUG
167 		if (cs_stubs_debug > 2)
168 			cmn_err(CE_CONT, "csx_register_cardservices: "
169 			    "CS_ENTRY_INQUIRE\n");
170 #endif
171 
172 		if (do_cs_call)
173 		    return (CS_SUCCESS);
174 		else
175 		    return (CS_BAD_HANDLE);
176 
177 	    default:
178 #ifdef	CS_STUBS_DEBUG
179 		if (cs_stubs_debug > 2)
180 			cmn_err(CE_CONT, "csx_register_cardservices: "
181 			    "(unknown function)\n");
182 #endif
183 		return (CS_UNSUPPORTED_FUNCTION);
184 	}
185 
186 }
187 
188 int32_t
csx_RegisterClient(client_handle_t * ch,client_reg_t * cr)189 csx_RegisterClient(client_handle_t *ch, client_reg_t *cr)
190 {
191 #ifdef	CS_STUBS_DEBUG
192 	if (cs_stubs_debug > 3)
193 	    cmn_err(CE_CONT, "csx_RegisterClient: (no handle yet)\n");
194 #endif
195 	return (CardServices(RegisterClient, ch, cr));
196 }
197 
198 int32_t
csx_DeregisterClient(client_handle_t ch)199 csx_DeregisterClient(client_handle_t ch)
200 {
201 #ifdef	CS_STUBS_DEBUG
202 	if (cs_stubs_debug > 3)
203 	    cmn_err(CE_CONT, "csx_DeregisterClient: handle: 0x%x\n", ch);
204 #endif
205 	return (CardServices(DeregisterClient, ch));
206 }
207 
208 int32_t
csx_GetStatus(client_handle_t ch,get_status_t * gs)209 csx_GetStatus(client_handle_t ch, get_status_t *gs)
210 {
211 #ifdef	CS_STUBS_DEBUG
212 	if (cs_stubs_debug > 3)
213 	    cmn_err(CE_CONT, "csx_GetStatus: handle: 0x%x\n", ch);
214 #endif
215 	return (CardServices(GetStatus, ch, gs));
216 }
217 
218 int32_t
csx_SetEventMask(client_handle_t ch,sockevent_t * se)219 csx_SetEventMask(client_handle_t ch, sockevent_t *se)
220 {
221 #ifdef	CS_STUBS_DEBUG
222 	if (cs_stubs_debug > 3)
223 	    cmn_err(CE_CONT, "csx_SetEventMask: handle: 0x%x\n", ch);
224 #endif
225 	return (CardServices(SetEventMask, ch, se));
226 }
227 
228 int32_t
csx_GetEventMask(client_handle_t ch,sockevent_t * se)229 csx_GetEventMask(client_handle_t ch, sockevent_t *se)
230 {
231 #ifdef	CS_STUBS_DEBUG
232 	if (cs_stubs_debug > 3)
233 	    cmn_err(CE_CONT, "csx_GetEventMask: handle: 0x%x\n", ch);
234 #endif
235 	return (CardServices(GetEventMask, ch, se));
236 }
237 
238 int32_t
csx_RequestIO(client_handle_t ch,io_req_t * ior)239 csx_RequestIO(client_handle_t ch, io_req_t *ior)
240 {
241 #ifdef	CS_STUBS_DEBUG
242 	if (cs_stubs_debug > 3)
243 	    cmn_err(CE_CONT, "csx_RequestIO: handle: 0x%x\n", ch);
244 #endif
245 	return (CardServices(RequestIO, ch, ior));
246 }
247 
248 int32_t
csx_ReleaseIO(client_handle_t ch,io_req_t * ior)249 csx_ReleaseIO(client_handle_t ch, io_req_t *ior)
250 {
251 #ifdef	CS_STUBS_DEBUG
252 	if (cs_stubs_debug > 3)
253 	    cmn_err(CE_CONT, "csx_ReleaseIO: handle: 0x%x\n", ch);
254 #endif
255 	return (CardServices(ReleaseIO, ch, ior));
256 }
257 
258 int32_t
csx_RequestIRQ(client_handle_t ch,irq_req_t * irqr)259 csx_RequestIRQ(client_handle_t ch, irq_req_t *irqr)
260 {
261 #ifdef	CS_STUBS_DEBUG
262 	if (cs_stubs_debug > 3)
263 	    cmn_err(CE_CONT, "csx_RequestIRQ: handle: 0x%x\n", ch);
264 #endif
265 	return (CardServices(RequestIRQ, ch, irqr));
266 }
267 
268 int32_t
csx_ReleaseIRQ(client_handle_t ch,irq_req_t * irqr)269 csx_ReleaseIRQ(client_handle_t ch, irq_req_t *irqr)
270 {
271 #ifdef	CS_STUBS_DEBUG
272 	if (cs_stubs_debug > 3)
273 	    cmn_err(CE_CONT, "csx_ReleaseIRQ: handle: 0x%x\n", ch);
274 #endif
275 	return (CardServices(ReleaseIRQ, ch, irqr));
276 }
277 
278 int32_t
csx_RequestWindow(client_handle_t ch,window_handle_t * wh,win_req_t * wr)279 csx_RequestWindow(client_handle_t ch, window_handle_t *wh, win_req_t *wr)
280 {
281 #ifdef	CS_STUBS_DEBUG
282 	if (cs_stubs_debug > 3)
283 	    cmn_err(CE_CONT, "csx_RequestWindow: handle: 0x%x\n", ch);
284 #endif
285 	return (CardServices(RequestWindow, ch, wh, wr));
286 }
287 
288 int32_t
csx_ReleaseWindow(window_handle_t wh)289 csx_ReleaseWindow(window_handle_t wh)
290 {
291 #ifdef	CS_STUBS_DEBUG
292 	if (cs_stubs_debug > 3)
293 	    cmn_err(CE_CONT, "csx_ReleaseWindow: handle: 0x%x\n", wh);
294 #endif
295 	return (CardServices(ReleaseWindow, wh));
296 }
297 
298 int32_t
csx_ModifyWindow(window_handle_t wh,modify_win_t * mw)299 csx_ModifyWindow(window_handle_t wh, modify_win_t *mw)
300 {
301 #ifdef	CS_STUBS_DEBUG
302 	if (cs_stubs_debug > 3)
303 	    cmn_err(CE_CONT, "csx_ModifyWindow: handle: 0x%x\n", wh);
304 #endif
305 	return (CardServices(ModifyWindow, wh, mw));
306 }
307 
308 int32_t
csx_MapMemPage(window_handle_t wh,map_mem_page_t * mmp)309 csx_MapMemPage(window_handle_t wh, map_mem_page_t *mmp)
310 {
311 #ifdef	CS_STUBS_DEBUG
312 	if (cs_stubs_debug > 3)
313 	    cmn_err(CE_CONT, "csx_MapMemPage: handle: 0x%x\n", wh);
314 #endif
315 	return (CardServices(MapMemPage, wh, mmp));
316 }
317 
318 int32_t
csx_RequestSocketMask(client_handle_t ch,request_socket_mask_t * sm)319 csx_RequestSocketMask(client_handle_t ch, request_socket_mask_t *sm)
320 {
321 #ifdef	CS_STUBS_DEBUG
322 	if (cs_stubs_debug > 3)
323 	    cmn_err(CE_CONT, "csx_RequestSocketMask: handle: 0x%x\n", ch);
324 #endif
325 	return (CardServices(RequestSocketMask, ch, sm));
326 }
327 
328 int32_t
csx_ReleaseSocketMask(client_handle_t ch,release_socket_mask_t * rsm)329 csx_ReleaseSocketMask(client_handle_t ch, release_socket_mask_t *rsm)
330 {
331 #ifdef	CS_STUBS_DEBUG
332 	if (cs_stubs_debug > 3)
333 	    cmn_err(CE_CONT, "csx_ReleaseSocketMask: handle: 0x%x\n", ch);
334 #endif
335 	return (CardServices(ReleaseSocketMask, ch, rsm));
336 }
337 
338 int32_t
csx_RequestConfiguration(client_handle_t ch,config_req_t * cr)339 csx_RequestConfiguration(client_handle_t ch, config_req_t *cr)
340 {
341 #ifdef	CS_STUBS_DEBUG
342 	if (cs_stubs_debug > 3)
343 	    cmn_err(CE_CONT, "csx_RequestConfiguration: handle: 0x%x\n", ch);
344 #endif
345 	return (CardServices(RequestConfiguration, ch, cr));
346 }
347 
348 int32_t
csx_ModifyConfiguration(client_handle_t ch,modify_config_t * mc)349 csx_ModifyConfiguration(client_handle_t ch, modify_config_t *mc)
350 {
351 #ifdef	CS_STUBS_DEBUG
352 	if (cs_stubs_debug > 3)
353 	    cmn_err(CE_CONT, "csx_ModifyConfiguration: handle: 0x%x\n", ch);
354 #endif
355 	return (CardServices(ModifyConfiguration, ch, mc));
356 }
357 
358 int32_t
csx_ReleaseConfiguration(client_handle_t ch,release_config_t * rc)359 csx_ReleaseConfiguration(client_handle_t ch, release_config_t *rc)
360 {
361 #ifdef	CS_STUBS_DEBUG
362 	if (cs_stubs_debug > 3)
363 	    cmn_err(CE_CONT, "csx_ReleaseConfiguration: handle: 0x%x\n", ch);
364 #endif
365 	return (CardServices(ReleaseConfiguration, ch, rc));
366 }
367 
368 int32_t
csx_AccessConfigurationRegister(client_handle_t ch,access_config_reg_t * acr)369 csx_AccessConfigurationRegister(client_handle_t ch, access_config_reg_t *acr)
370 {
371 #ifdef	CS_STUBS_DEBUG
372 	if (cs_stubs_debug > 3)
373 	    cmn_err(CE_CONT,
374 		"csx_AccessConfigurationRegister: handle: 0x%x\n", ch);
375 #endif
376 	return (CardServices(AccessConfigurationRegister, ch, acr));
377 }
378 
379 int32_t
csx_GetFirstTuple(client_handle_t ch,tuple_t * tp)380 csx_GetFirstTuple(client_handle_t ch, tuple_t *tp)
381 {
382 #ifdef	CS_STUBS_DEBUG
383 	if (cs_stubs_debug > 3)
384 	    cmn_err(CE_CONT, "csx_GetFirstTuple: handle: 0x%x\n", ch);
385 #endif
386 	return (CardServices(GetFirstTuple, ch, tp));
387 }
388 
389 int32_t
csx_GetNextTuple(client_handle_t ch,tuple_t * tp)390 csx_GetNextTuple(client_handle_t ch, tuple_t *tp)
391 {
392 #ifdef	CS_STUBS_DEBUG
393 	if (cs_stubs_debug > 3)
394 	    cmn_err(CE_CONT, "csx_GetNextTuple: handle: 0x%x\n", ch);
395 #endif
396 	return (CardServices(GetNextTuple, ch, tp));
397 }
398 
399 int32_t
csx_GetTupleData(client_handle_t ch,tuple_t * tp)400 csx_GetTupleData(client_handle_t ch, tuple_t *tp)
401 {
402 #ifdef	CS_STUBS_DEBUG
403 	if (cs_stubs_debug > 3)
404 	    cmn_err(CE_CONT, "csx_GetTupleData: handle: 0x%x\n", ch);
405 #endif
406 	return (CardServices(GetTupleData, ch, tp));
407 }
408 
409 int32_t
csx_MapLogSocket(client_handle_t ch,map_log_socket_t * mls)410 csx_MapLogSocket(client_handle_t ch, map_log_socket_t *mls)
411 {
412 #ifdef	CS_STUBS_DEBUG
413 	if (cs_stubs_debug > 3)
414 	    cmn_err(CE_CONT, "csx_MapLogSocket: handle: 0x%x\n", ch);
415 #endif
416 	return (CardServices(MapLogSocket, ch, mls));
417 }
418 
419 int32_t
csx_ValidateCIS(client_handle_t ch,cisinfo_t * ci)420 csx_ValidateCIS(client_handle_t ch, cisinfo_t *ci)
421 {
422 #ifdef	CS_STUBS_DEBUG
423 	if (cs_stubs_debug > 3)
424 	    cmn_err(CE_CONT, "csx_ValidateCIS: handle: 0x%x\n", ch);
425 #endif
426 	return (CardServices(ValidateCIS, ch, ci));
427 }
428 
429 int32_t
csx_MakeDeviceNode(client_handle_t ch,make_device_node_t * mdn)430 csx_MakeDeviceNode(client_handle_t ch, make_device_node_t *mdn)
431 {
432 #ifdef	CS_STUBS_DEBUG
433 	if (cs_stubs_debug > 3)
434 	    cmn_err(CE_CONT, "csx_MakeDeviceNode: handle: 0x%x\n", ch);
435 #endif
436 	return (CardServices(MakeDeviceNode, ch, mdn));
437 }
438 
439 int32_t
csx_RemoveDeviceNode(client_handle_t ch,remove_device_node_t * rdn)440 csx_RemoveDeviceNode(client_handle_t ch, remove_device_node_t *rdn)
441 {
442 #ifdef	CS_STUBS_DEBUG
443 	if (cs_stubs_debug > 3)
444 	    cmn_err(CE_CONT, "csx_RemoveDeviceNode: handle: 0x%x\n", ch);
445 #endif
446 	return (CardServices(RemoveDeviceNode, ch, rdn));
447 }
448 
449 int32_t
csx_ConvertSpeed(convert_speed_t * cp)450 csx_ConvertSpeed(convert_speed_t *cp)
451 {
452 #ifdef	CS_STUBS_DEBUG
453 	if (cs_stubs_debug > 3)
454 	    cmn_err(CE_CONT, "csx_ConvertSpeed\n");
455 #endif
456 	return (CardServices(ConvertSpeed, cp));
457 }
458 
459 int32_t
csx_ConvertSize(convert_size_t * cp)460 csx_ConvertSize(convert_size_t *cp)
461 {
462 #ifdef	CS_STUBS_DEBUG
463 	if (cs_stubs_debug > 3)
464 	    cmn_err(CE_CONT, "csx_ConvertSize\n");
465 #endif
466 	return (CardServices(ConvertSize, cp));
467 }
468 
469 int32_t
csx_Event2Text(event2text_t * e2t)470 csx_Event2Text(event2text_t *e2t)
471 {
472 #ifdef	CS_STUBS_DEBUG
473 	if (cs_stubs_debug > 3)
474 	    cmn_err(CE_CONT, "csx_Event2Text\n");
475 #endif
476 	return (CardServices(Event2Text, e2t));
477 }
478 
479 int32_t
csx_Error2Text(error2text_t * e2t)480 csx_Error2Text(error2text_t *e2t)
481 {
482 #ifdef	CS_STUBS_DEBUG
483 	if (cs_stubs_debug > 3)
484 	    cmn_err(CE_CONT, "csx_Error2Text\n");
485 #endif
486 	return (CardServices(Error2Text, e2t));
487 }
488 
489 int32_t
csx_CS_DDI_Info(cs_ddi_info_t * cp)490 csx_CS_DDI_Info(cs_ddi_info_t *cp)
491 {
492 #ifdef	CS_STUBS_DEBUG
493 	if (cs_stubs_debug > 3)
494 	    cmn_err(CE_CONT, "csx_CS_DDI_Info\n");
495 #endif
496 	return (CardServices(CS_DDI_Info, cp));
497 }
498 
499 int32_t
csx_CS_Sys_Ctl(cs_sys_ctl_t * csc)500 csx_CS_Sys_Ctl(cs_sys_ctl_t *csc)
501 {
502 #ifdef	CS_STUBS_DEBUG
503 	if (cs_stubs_debug > 3)
504 	    cmn_err(CE_CONT, "csx_CS_Sys_Ctl\n");
505 #endif
506 	return (CardServices(CS_Sys_Ctl, csc));
507 }
508 
509 int32_t
csx_GetClientInfo(client_handle_t ch,client_info_t * ci)510 csx_GetClientInfo(client_handle_t ch, client_info_t *ci)
511 {
512 #ifdef	CS_STUBS_DEBUG
513 	if (cs_stubs_debug > 3)
514 	    cmn_err(CE_CONT, "csx_GetClientInfo: handle: 0x%x\n", ch);
515 #endif
516 
517 	return (CardServices(GetClientInfo, ch, ci));
518 }
519 
520 int32_t
csx_GetFirstClient(get_firstnext_client_t * fnc)521 csx_GetFirstClient(get_firstnext_client_t *fnc)
522 {
523 #ifdef	CS_STUBS_DEBUG
524 	if (cs_stubs_debug > 3)
525 	    cmn_err(CE_CONT, "csx_GetFirstClient\n");
526 #endif
527 
528 	return (CardServices(GetFirstClient, fnc));
529 }
530 
531 int32_t
csx_GetNextClient(get_firstnext_client_t * fnc)532 csx_GetNextClient(get_firstnext_client_t *fnc)
533 {
534 #ifdef	CS_STUBS_DEBUG
535 	if (cs_stubs_debug > 3)
536 	    cmn_err(CE_CONT, "csx_GetNextClient\n");
537 #endif
538 
539 	return (CardServices(GetNextClient, fnc));
540 }
541 
542 int32_t
csx_ResetFunction(client_handle_t ch,reset_function_t * rf)543 csx_ResetFunction(client_handle_t ch, reset_function_t *rf)
544 {
545 #ifdef	CS_STUBS_DEBUG
546 	if (cs_stubs_debug > 3)
547 	    cmn_err(CE_CONT, "csx_ResetFunction: handle: 0x%x\n", ch);
548 #endif
549 
550 	return (CardServices(ResetFunction, ch, rf));
551 }
552 
553 int32_t
csx_GetCardServicesInfo(client_handle_t ch,get_cardservices_info_t * gcsi)554 csx_GetCardServicesInfo(client_handle_t ch, get_cardservices_info_t *gcsi)
555 {
556 #ifdef	CS_STUBS_DEBUG
557 	if (cs_stubs_debug > 3)
558 	    cmn_err(CE_CONT, "csx_GetCardServicesInfo: handle: 0x%x\n", ch);
559 #endif
560 
561 	return (CardServices(GetCardServicesInfo, ch, gcsi));
562 }
563 
564 int32_t
csx_GetConfigurationInfo(client_handle_t * ch,get_configuration_info_t * gci)565 csx_GetConfigurationInfo(client_handle_t *ch, get_configuration_info_t *gci)
566 {
567 #ifdef	CS_STUBS_DEBUG
568 	if (cs_stubs_debug > 3)
569 	    cmn_err(CE_CONT, "csx_GetConfigurationInfo: "
570 		"handle: (no handle yet)\n");
571 #endif
572 
573 	return (CardServices(GetConfigurationInfo, ch, gci));
574 }
575 
576 int32_t
csx_GetPhysicalAdapterInfo(client_handle_t ch,get_physical_adapter_info_t * gp)577 csx_GetPhysicalAdapterInfo(client_handle_t ch, get_physical_adapter_info_t *gp)
578 {
579 #ifdef	CS_STUBS_DEBUG
580 	if (cs_stubs_debug > 3)
581 	    cmn_err(CE_CONT, "csx_GetPhysicalAdapterInfo: handle: 0x%x\n", ch);
582 #endif
583 
584 	return (CardServices(GetPhysicalAdapterInfo, ch, gp));
585 }
586 
587 /*
588  * CIS tuple parsing functions - one entrypoint per tuple that we know
589  *	how to parse
590  */
591 int32_t
csx_Parse_CISTPL_CONFIG(client_handle_t ch,tuple_t * tp,cistpl_config_t * pt)592 csx_Parse_CISTPL_CONFIG(client_handle_t ch, tuple_t *tp, cistpl_config_t *pt)
593 {
594 #ifdef	CS_STUBS_DEBUG
595 	if (cs_stubs_debug > 3)
596 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_CONFIG: handle: 0x%x\n", ch);
597 #endif
598 	tp->DesiredTuple = CISTPL_CONFIG;
599 	return (CardServices(ParseTuple, ch, tp, pt));
600 }
601 
602 int32_t
csx_Parse_CISTPL_DEVICE(client_handle_t ch,tuple_t * tp,cistpl_device_t * pt)603 csx_Parse_CISTPL_DEVICE(client_handle_t ch, tuple_t *tp, cistpl_device_t *pt)
604 {
605 #ifdef	CS_STUBS_DEBUG
606 	if (cs_stubs_debug > 3)
607 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_DEVICE: handle: 0x%x\n", ch);
608 #endif
609 	tp->DesiredTuple = CISTPL_DEVICE;
610 	return (CardServices(ParseTuple, ch, tp, pt));
611 }
612 
613 int32_t
csx_Parse_CISTPL_DEVICE_A(client_handle_t ch,tuple_t * tp,cistpl_device_t * pt)614 csx_Parse_CISTPL_DEVICE_A(client_handle_t ch, tuple_t *tp, cistpl_device_t *pt)
615 {
616 #ifdef	CS_STUBS_DEBUG
617 	if (cs_stubs_debug > 3)
618 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_DEVICE_A: handle: 0x%x\n", ch);
619 #endif
620 	tp->DesiredTuple = CISTPL_DEVICE_A;
621 	return (CardServices(ParseTuple, ch, tp, pt));
622 }
623 
624 int32_t
csx_Parse_CISTPL_DEVICE_OA(client_handle_t ch,tuple_t * tp,cistpl_device_t * pt)625 csx_Parse_CISTPL_DEVICE_OA(client_handle_t ch, tuple_t *tp, cistpl_device_t *pt)
626 {
627 #ifdef	CS_STUBS_DEBUG
628 	if (cs_stubs_debug > 3)
629 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_DEVICE_OA: handle: 0x%x\n", ch);
630 #endif
631 	tp->DesiredTuple = CISTPL_DEVICE_OA;
632 	return (CardServices(ParseTuple, ch, tp, pt));
633 }
634 
635 int32_t
csx_Parse_CISTPL_DEVICE_OC(client_handle_t ch,tuple_t * tp,cistpl_device_t * pt)636 csx_Parse_CISTPL_DEVICE_OC(client_handle_t ch, tuple_t *tp, cistpl_device_t *pt)
637 {
638 #ifdef	CS_STUBS_DEBUG
639 	if (cs_stubs_debug > 3)
640 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_DEVICE_OC: handle: 0x%x\n", ch);
641 #endif
642 	tp->DesiredTuple = CISTPL_DEVICE_OC;
643 	return (CardServices(ParseTuple, ch, tp, pt));
644 }
645 
646 int32_t
csx_Parse_CISTPL_VERS_1(client_handle_t ch,tuple_t * tp,cistpl_vers_1_t * pt)647 csx_Parse_CISTPL_VERS_1(client_handle_t ch, tuple_t *tp, cistpl_vers_1_t *pt)
648 {
649 #ifdef	CS_STUBS_DEBUG
650 	if (cs_stubs_debug > 3)
651 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_VERS_1: handle: 0x%x\n", ch);
652 #endif
653 	tp->DesiredTuple = CISTPL_VERS_1;
654 	return (CardServices(ParseTuple, ch, tp, pt));
655 }
656 
657 int32_t
csx_Parse_CISTPL_VERS_2(client_handle_t ch,tuple_t * tp,cistpl_vers_2_t * pt)658 csx_Parse_CISTPL_VERS_2(client_handle_t ch, tuple_t *tp, cistpl_vers_2_t *pt)
659 {
660 #ifdef	CS_STUBS_DEBUG
661 	if (cs_stubs_debug > 3)
662 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_VERS_2: handle: 0x%x\n", ch);
663 #endif
664 	tp->DesiredTuple = CISTPL_VERS_2;
665 	return (CardServices(ParseTuple, ch, tp, pt));
666 }
667 
668 int32_t
csx_Parse_CISTPL_JEDEC_A(client_handle_t ch,tuple_t * tp,cistpl_jedec_t * pt)669 csx_Parse_CISTPL_JEDEC_A(client_handle_t ch, tuple_t *tp, cistpl_jedec_t *pt)
670 {
671 #ifdef	CS_STUBS_DEBUG
672 	if (cs_stubs_debug > 3)
673 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_JEDEC_A: handle: 0x%x\n", ch);
674 #endif
675 	tp->DesiredTuple = CISTPL_JEDEC_A;
676 	return (CardServices(ParseTuple, ch, tp, pt));
677 }
678 
679 int32_t
csx_Parse_CISTPL_JEDEC_C(client_handle_t ch,tuple_t * tp,cistpl_jedec_t * pt)680 csx_Parse_CISTPL_JEDEC_C(client_handle_t ch, tuple_t *tp, cistpl_jedec_t *pt)
681 {
682 #ifdef	CS_STUBS_DEBUG
683 	if (cs_stubs_debug > 3)
684 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_JEDEC_C: handle: 0x%x\n", ch);
685 #endif
686 	tp->DesiredTuple = CISTPL_JEDEC_C;
687 	return (CardServices(ParseTuple, ch, tp, pt));
688 }
689 
690 int32_t
csx_Parse_CISTPL_FORMAT(client_handle_t ch,tuple_t * tp,cistpl_format_t * pt)691 csx_Parse_CISTPL_FORMAT(client_handle_t ch, tuple_t *tp, cistpl_format_t *pt)
692 {
693 #ifdef	CS_STUBS_DEBUG
694 	if (cs_stubs_debug > 3)
695 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_FORMAT: handle: 0x%x\n", ch);
696 #endif
697 	tp->DesiredTuple = CISTPL_FORMAT;
698 	return (CardServices(ParseTuple, ch, tp, pt));
699 }
700 
701 int32_t
csx_Parse_CISTPL_FORMAT_A(client_handle_t ch,tuple_t * tp,cistpl_format_t * pt)702 csx_Parse_CISTPL_FORMAT_A(client_handle_t ch, tuple_t *tp, cistpl_format_t *pt)
703 {
704 #ifdef	CS_STUBS_DEBUG
705 	if (cs_stubs_debug > 3)
706 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_FORMAT_A: handle: 0x%x\n", ch);
707 #endif
708 	tp->DesiredTuple = CISTPL_FORMAT_A;
709 	return (CardServices(ParseTuple, ch, tp, pt));
710 }
711 
712 int32_t
csx_Parse_CISTPL_GEOMETRY(client_handle_t ch,tuple_t * tp,cistpl_geometry_t * pt)713 csx_Parse_CISTPL_GEOMETRY(client_handle_t ch, tuple_t *tp,
714     cistpl_geometry_t *pt)
715 {
716 #ifdef	CS_STUBS_DEBUG
717 	if (cs_stubs_debug > 3)
718 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_GEOMETRY: handle: 0x%x\n", ch);
719 #endif
720 	tp->DesiredTuple = CISTPL_GEOMETRY;
721 	return (CardServices(ParseTuple, ch, tp, pt));
722 }
723 
724 int32_t
csx_Parse_CISTPL_BYTEORDER(client_handle_t ch,tuple_t * tp,cistpl_byteorder_t * pt)725 csx_Parse_CISTPL_BYTEORDER(client_handle_t ch, tuple_t *tp,
726     cistpl_byteorder_t *pt)
727 {
728 #ifdef	CS_STUBS_DEBUG
729 	if (cs_stubs_debug > 3)
730 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_BYTEORDER: handle: 0x%x\n", ch);
731 #endif
732 	tp->DesiredTuple = CISTPL_BYTEORDER;
733 	return (CardServices(ParseTuple, ch, tp, pt));
734 }
735 
736 int32_t
csx_Parse_CISTPL_DATE(client_handle_t ch,tuple_t * tp,cistpl_date_t * pt)737 csx_Parse_CISTPL_DATE(client_handle_t ch, tuple_t *tp, cistpl_date_t *pt)
738 {
739 #ifdef	CS_STUBS_DEBUG
740 	if (cs_stubs_debug > 3)
741 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_DATE: handle: 0x%x\n", ch);
742 #endif
743 	tp->DesiredTuple = CISTPL_DATE;
744 	return (CardServices(ParseTuple, ch, tp, pt));
745 }
746 
747 int32_t
csx_Parse_CISTPL_BATTERY(client_handle_t ch,tuple_t * tp,cistpl_battery_t * pt)748 csx_Parse_CISTPL_BATTERY(client_handle_t ch, tuple_t *tp, cistpl_battery_t *pt)
749 {
750 #ifdef	CS_STUBS_DEBUG
751 	if (cs_stubs_debug > 3)
752 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_BATTERY: handle: 0x%x\n", ch);
753 #endif
754 	tp->DesiredTuple = CISTPL_BATTERY;
755 	return (CardServices(ParseTuple, ch, tp, pt));
756 }
757 
758 int32_t
csx_Parse_CISTPL_ORG(client_handle_t ch,tuple_t * tp,cistpl_org_t * pt)759 csx_Parse_CISTPL_ORG(client_handle_t ch, tuple_t *tp, cistpl_org_t *pt)
760 {
761 #ifdef	CS_STUBS_DEBUG
762 	if (cs_stubs_debug > 3)
763 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_ORG: handle: 0x%x\n", ch);
764 #endif
765 	tp->DesiredTuple = CISTPL_ORG;
766 	return (CardServices(ParseTuple, ch, tp, pt));
767 }
768 
769 int32_t
csx_Parse_CISTPL_MANFID(client_handle_t ch,tuple_t * tp,cistpl_manfid_t * pt)770 csx_Parse_CISTPL_MANFID(client_handle_t ch, tuple_t *tp, cistpl_manfid_t *pt)
771 {
772 #ifdef	CS_STUBS_DEBUG
773 	if (cs_stubs_debug > 3)
774 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_MANFID: handle: 0x%x\n", ch);
775 #endif
776 	tp->DesiredTuple = CISTPL_MANFID;
777 	return (CardServices(ParseTuple, ch, tp, pt));
778 }
779 
780 int32_t
csx_Parse_CISTPL_FUNCID(client_handle_t ch,tuple_t * tp,cistpl_funcid_t * pt)781 csx_Parse_CISTPL_FUNCID(client_handle_t ch, tuple_t *tp, cistpl_funcid_t *pt)
782 {
783 #ifdef	CS_STUBS_DEBUG
784 	if (cs_stubs_debug > 3)
785 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_FUNCID: handle: 0x%x\n", ch);
786 #endif
787 	tp->DesiredTuple = CISTPL_FUNCID;
788 	return (CardServices(ParseTuple, ch, tp, pt));
789 }
790 
791 int32_t
csx_Parse_CISTPL_FUNCE(client_handle_t ch,tuple_t * tp,cistpl_funce_t * pt,uint32_t function)792 csx_Parse_CISTPL_FUNCE(client_handle_t ch, tuple_t *tp,
793     cistpl_funce_t *pt, uint32_t function)
794 {
795 #ifdef	CS_STUBS_DEBUG
796 	if (cs_stubs_debug > 3)
797 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_FUNCE: handle: 0x%x\n", ch);
798 #endif
799 	tp->DesiredTuple = CISTPL_FUNCE;
800 	return (CardServices(ParseTuple, ch, tp, pt, function));
801 }
802 
803 int32_t
csx_Parse_CISTPL_CFTABLE_ENTRY(client_handle_t ch,tuple_t * tp,cistpl_cftable_entry_t * pt)804 csx_Parse_CISTPL_CFTABLE_ENTRY(client_handle_t ch, tuple_t *tp,
805     cistpl_cftable_entry_t *pt)
806 {
807 #ifdef	CS_STUBS_DEBUG
808 	if (cs_stubs_debug > 3)
809 	    cmn_err(CE_CONT,
810 		"csx_Parse_CISTPL_CFTABLE_ENTRY: handle: 0x%x\n", ch);
811 #endif
812 	tp->DesiredTuple = CISTPL_CFTABLE_ENTRY;
813 	return (CardServices(ParseTuple, ch, tp, pt));
814 }
815 
816 int32_t
csx_Parse_CISTPL_LINKTARGET(client_handle_t ch,tuple_t * tp,cistpl_linktarget_t * pt)817 csx_Parse_CISTPL_LINKTARGET(client_handle_t ch, tuple_t *tp,
818     cistpl_linktarget_t *pt)
819 {
820 #ifdef	CS_STUBS_DEBUG
821 	if (cs_stubs_debug > 3)
822 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_LINKTARGET: handle: 0x%x\n", ch);
823 #endif
824 	tp->DesiredTuple = CISTPL_LINKTARGET;
825 	return (CardServices(ParseTuple, ch, tp, pt));
826 }
827 
828 int32_t
csx_Parse_CISTPL_LONGLINK_A(client_handle_t ch,tuple_t * tp,cistpl_longlink_ac_t * pt)829 csx_Parse_CISTPL_LONGLINK_A(client_handle_t ch, tuple_t *tp,
830     cistpl_longlink_ac_t *pt)
831 {
832 #ifdef	CS_STUBS_DEBUG
833 	if (cs_stubs_debug > 3)
834 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_LONGLINK_A: handle: 0x%x\n", ch);
835 #endif
836 	tp->DesiredTuple = CISTPL_LONGLINK_A;
837 	return (CardServices(ParseTuple, ch, tp, pt));
838 }
839 
840 int32_t
csx_Parse_CISTPL_LONGLINK_C(client_handle_t ch,tuple_t * tp,cistpl_longlink_ac_t * pt)841 csx_Parse_CISTPL_LONGLINK_C(client_handle_t ch, tuple_t *tp,
842     cistpl_longlink_ac_t *pt)
843 {
844 #ifdef	CS_STUBS_DEBUG
845 	if (cs_stubs_debug > 3)
846 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_LONGLINK_C: handle: 0x%x\n", ch);
847 #endif
848 	tp->DesiredTuple = CISTPL_LONGLINK_C;
849 	return (CardServices(ParseTuple, ch, tp, pt));
850 }
851 
852 int32_t
csx_Parse_CISTPL_LONGLINK_MFC(client_handle_t ch,tuple_t * tp,cistpl_longlink_mfc_t * pt)853 csx_Parse_CISTPL_LONGLINK_MFC(client_handle_t ch, tuple_t *tp,
854     cistpl_longlink_mfc_t *pt)
855 {
856 #ifdef	CS_STUBS_DEBUG
857 	if (cs_stubs_debug > 3)
858 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_LONGLINK_MFC: "
859 						"handle: 0x%x\n", ch);
860 #endif
861 	tp->DesiredTuple = CISTPL_LONGLINK_MFC;
862 	return (CardServices(ParseTuple, ch, tp, pt));
863 }
864 
csx_Parse_CISTPL_LONGLINK_CB(client_handle_t ch,tuple_t * tp,cistpl_longlink_cb_t * pt)865 int32_t csx_Parse_CISTPL_LONGLINK_CB(client_handle_t ch, tuple_t *tp,
866     cistpl_longlink_cb_t *pt)
867 {
868 #ifdef	CS_STUBS_DEBUG
869 	if (cs_stubs_debug > 3)
870 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_LONGLINK_CB: "
871 						"handle: 0x%x\n", ch);
872 #endif
873 	tp->DesiredTuple = CISTPL_LONGLINK_CB;
874 	return (CardServices(ParseTuple, ch, tp, pt));
875 }
876 
877 int32_t
csx_Parse_CISTPL_SPCL(client_handle_t ch,tuple_t * tp,cistpl_spcl_t * pt)878 csx_Parse_CISTPL_SPCL(client_handle_t ch, tuple_t *tp,
879     cistpl_spcl_t *pt)
880 {
881 #ifdef	CS_STUBS_DEBUG
882 	if (cs_stubs_debug > 3)
883 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_SPCL: handle: 0x%x\n", ch);
884 #endif
885 	tp->DesiredTuple = CISTPL_SPCL;
886 	return (CardServices(ParseTuple, ch, tp, pt));
887 }
888 
889 int32_t
csx_Parse_CISTPL_SWIL(client_handle_t ch,tuple_t * tp,cistpl_swil_t * pt)890 csx_Parse_CISTPL_SWIL(client_handle_t ch, tuple_t *tp,
891     cistpl_swil_t *pt)
892 {
893 #ifdef	CS_STUBS_DEBUG
894 	if (cs_stubs_debug > 3)
895 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_SWIL: handle: 0x%x\n", ch);
896 #endif
897 	tp->DesiredTuple = CISTPL_SWIL;
898 	return (CardServices(ParseTuple, ch, tp, pt));
899 }
900 
csx_Parse_CISTPL_BAR(client_handle_t ch,tuple_t * tp,cistpl_bar_t * pt)901 int32_t csx_Parse_CISTPL_BAR(client_handle_t ch, tuple_t *tp,
902     cistpl_bar_t *pt)
903 {
904 #ifdef	CS_STUBS_DEBUG
905 	if (cs_stubs_debug > 3)
906 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_BAR: handle: 0x%x\n", ch);
907 #endif
908 	tp->DesiredTuple = CISTPL_BAR;
909 	return (CardServices(ParseTuple, ch, tp, pt));
910 }
911 
912 int32_t
csx_Parse_CISTPL_DEVICEGEO(client_handle_t ch,tuple_t * tp,cistpl_devicegeo_t * pt)913 csx_Parse_CISTPL_DEVICEGEO(client_handle_t ch, tuple_t *tp,
914     cistpl_devicegeo_t *pt)
915 {
916 #ifdef	CS_STUBS_DEBUG
917 	if (cs_stubs_debug > 3)
918 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_DEVICEGEO: handle: 0x%x\n", ch);
919 #endif
920 	tp->DesiredTuple = CISTPL_DEVICEGEO;
921 	return (CardServices(ParseTuple, ch, tp, pt));
922 }
923 
924 int32_t
csx_Parse_CISTPL_DEVICEGEO_A(client_handle_t ch,tuple_t * tp,cistpl_devicegeo_t * pt)925 csx_Parse_CISTPL_DEVICEGEO_A(client_handle_t ch, tuple_t *tp,
926     cistpl_devicegeo_t *pt)
927 {
928 #ifdef	CS_STUBS_DEBUG
929 	if (cs_stubs_debug > 3)
930 	    cmn_err(CE_CONT, "csx_Parse_CISTPL_DEVICEGEO_A: "
931 						"handle: 0x%x\n", ch);
932 #endif
933 	tp->DesiredTuple = CISTPL_DEVICEGEO_A;
934 	return (CardServices(ParseTuple, ch, tp, pt));
935 }
936 
937 int32_t
csx_ParseTuple(client_handle_t ch,tuple_t * tp,cisparse_t * cp,uint32_t ef)938 csx_ParseTuple(client_handle_t ch, tuple_t *tp, cisparse_t *cp, uint32_t ef)
939 {
940 #ifdef	CS_STUBS_DEBUG
941 	if (cs_stubs_debug > 3)
942 	    cmn_err(CE_CONT, "csx_ParseTuple: handle: 0x%x\n", ch);
943 #endif
944 	return (CardServices(ParseTuple, ch, tp, cp, ef));
945 }
946 
947 /*
948  * The following functions are used to access various datatypes.
949  *	These functions are not specific to PCMCIA client drivers
950  *	and they don't depend on Card Services being present to
951  *	operate.
952  */
953 void
csx_Put8(acc_handle_t handle,uint32_t offset,uint8_t value)954 csx_Put8(acc_handle_t handle, uint32_t offset, uint8_t value)
955 {
956 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
957 
958 	ddi_put8(handle, (uint8_t *)(hp->ah_addr + offset), value);
959 }
960 
961 void
csx_Put16(acc_handle_t handle,uint32_t offset,uint16_t value)962 csx_Put16(acc_handle_t handle, uint32_t offset, uint16_t value)
963 {
964 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
965 
966 	ddi_put16(handle, (uint16_t *)(hp->ah_addr + offset), value);
967 }
968 
969 void
csx_Put32(acc_handle_t handle,uint32_t offset,uint32_t value)970 csx_Put32(acc_handle_t handle, uint32_t offset, uint32_t value)
971 {
972 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
973 
974 	ddi_put32(handle, (uint32_t *)(hp->ah_addr + offset), value);
975 }
976 
977 void
csx_Put64(acc_handle_t handle,uint32_t offset,uint64_t value)978 csx_Put64(acc_handle_t handle, uint32_t offset, uint64_t value)
979 {
980 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
981 
982 	ddi_put64(handle, (uint64_t *)(hp->ah_addr + offset), value);
983 }
984 
985 uint8_t
csx_Get8(acc_handle_t handle,uint32_t offset)986 csx_Get8(acc_handle_t handle, uint32_t offset)
987 {
988 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
989 
990 	return (ddi_get8(handle, (uint8_t *)(hp->ah_addr + offset)));
991 }
992 
993 uint16_t
csx_Get16(acc_handle_t handle,uint32_t offset)994 csx_Get16(acc_handle_t handle, uint32_t offset)
995 {
996 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
997 
998 	return (ddi_get16(handle, (uint16_t *)(hp->ah_addr + offset)));
999 }
1000 
1001 uint32_t
csx_Get32(acc_handle_t handle,uint32_t offset)1002 csx_Get32(acc_handle_t handle, uint32_t offset)
1003 {
1004 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
1005 
1006 	return (ddi_get32(handle, (uint32_t *)(hp->ah_addr + offset)));
1007 }
1008 
1009 uint64_t
csx_Get64(acc_handle_t handle,uint32_t offset)1010 csx_Get64(acc_handle_t handle, uint32_t offset)
1011 {
1012 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
1013 
1014 	return (ddi_get64(handle, (uint64_t *)(hp->ah_addr + offset)));
1015 }
1016 
1017 void
csx_RepPut8(acc_handle_t handle,uint8_t * hostaddr,uint32_t offset,uint32_t rc,uint32_t flags)1018 csx_RepPut8(acc_handle_t handle, uint8_t *hostaddr, uint32_t offset,
1019 						uint32_t rc, uint32_t flags)
1020 {
1021 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
1022 
1023 	ddi_rep_put8(handle, hostaddr, (uint8_t *)(hp->ah_addr + offset),
1024 		rc, (uint32_t)flags);
1025 }
1026 
1027 void
csx_RepPut16(acc_handle_t handle,uint16_t * hostaddr,uint32_t offset,uint32_t rc,uint32_t flags)1028 csx_RepPut16(acc_handle_t handle, uint16_t *hostaddr, uint32_t offset,
1029 						uint32_t rc, uint32_t flags)
1030 {
1031 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
1032 
1033 	ddi_rep_put16(handle, hostaddr, (uint16_t *)(hp->ah_addr + offset),
1034 		rc, (uint32_t)flags);
1035 }
1036 
1037 void
csx_RepPut32(acc_handle_t handle,uint32_t * hostaddr,uint32_t offset,uint32_t rc,uint32_t flags)1038 csx_RepPut32(acc_handle_t handle, uint32_t *hostaddr, uint32_t offset,
1039 						uint32_t rc, uint32_t flags)
1040 {
1041 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
1042 
1043 	ddi_rep_put32(handle, hostaddr, (uint32_t *)(hp->ah_addr + offset),
1044 		rc, (uint32_t)flags);
1045 }
1046 
1047 void
csx_RepPut64(acc_handle_t handle,uint64_t * hostaddr,uint32_t offset,uint32_t rc,uint32_t flags)1048 csx_RepPut64(acc_handle_t handle, uint64_t *hostaddr, uint32_t offset,
1049 						uint32_t rc, uint32_t flags)
1050 {
1051 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
1052 
1053 	ddi_rep_put64(handle, hostaddr, (uint64_t *)(hp->ah_addr + offset),
1054 		rc, (uint32_t)flags);
1055 }
1056 
1057 void
csx_RepGet8(acc_handle_t handle,uint8_t * hostaddr,uint32_t offset,uint32_t rc,uint32_t flags)1058 csx_RepGet8(acc_handle_t handle, uint8_t *hostaddr, uint32_t offset,
1059 						uint32_t rc, uint32_t flags)
1060 {
1061 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
1062 
1063 	ddi_rep_get8(handle, hostaddr, (uint8_t *)(hp->ah_addr + offset),
1064 		rc, (uint32_t)flags);
1065 }
1066 
1067 void
csx_RepGet16(acc_handle_t handle,uint16_t * hostaddr,uint32_t offset,uint32_t rc,uint32_t flags)1068 csx_RepGet16(acc_handle_t handle, uint16_t *hostaddr, uint32_t offset,
1069 						uint32_t rc, uint32_t flags)
1070 {
1071 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
1072 
1073 	ddi_rep_get16(handle, hostaddr, (uint16_t *)(hp->ah_addr + offset),
1074 		rc, (uint32_t)flags);
1075 }
1076 
1077 void
csx_RepGet32(acc_handle_t handle,uint32_t * hostaddr,uint32_t offset,uint32_t rc,uint32_t flags)1078 csx_RepGet32(acc_handle_t handle, uint32_t *hostaddr, uint32_t offset,
1079 						uint32_t rc, uint32_t flags)
1080 {
1081 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
1082 
1083 	ddi_rep_get32(handle, hostaddr, (uint32_t *)(hp->ah_addr + offset),
1084 		rc, (uint32_t)flags);
1085 }
1086 
1087 void
csx_RepGet64(acc_handle_t handle,uint64_t * hostaddr,uint32_t offset,uint32_t rc,uint32_t flags)1088 csx_RepGet64(acc_handle_t handle, uint64_t *hostaddr, uint32_t offset,
1089 						uint32_t rc, uint32_t flags)
1090 {
1091 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
1092 
1093 	ddi_rep_get64(handle, hostaddr, (uint64_t *)(hp->ah_addr + offset),
1094 		rc, (uint32_t)flags);
1095 }
1096 
1097 /*
1098  * The following two functions return the mapped (virtual) or physical
1099  *	base address associated with the passed handle if the address
1100  *	can be directly accessed by the caller. If the object represented
1101  *	by the handle needs to be accessed through a common access
1102  *	function, CS_BAD_BASE is returned.
1103  *
1104  * XXX - Need to figure out how to determine when to return CS_BAD_BASE
1105  *	and also we need more generic return codes not tied to CS.
1106  */
1107 int32_t
csx_GetMappedAddr(acc_handle_t handle,void ** addr)1108 csx_GetMappedAddr(acc_handle_t handle, void **addr)
1109 {
1110 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
1111 
1112 #ifdef	CS_STUBS_DEBUG
1113 	if (cs_stubs_debug > 3)
1114 	    cmn_err(CE_CONT, "csx_GetMappedAddr: handle: 0x%p\n", handle);
1115 #endif
1116 
1117 	*addr = hp->ah_addr;
1118 
1119 	return (CS_SUCCESS);	/* XXX should be generic return code */
1120 }
1121 
1122 int32_t
csx_GetPhysAddr(acc_handle_t handle,void ** addr)1123 csx_GetPhysAddr(acc_handle_t handle, void **addr)
1124 {
1125 #ifndef	lint
1126 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
1127 #endif	/* lint */
1128 
1129 #ifdef	CS_STUBS_DEBUG
1130 	if (cs_stubs_debug > 3)
1131 	    cmn_err(CE_CONT, "csx_GetPhysAddr: handle: 0x%p\n", handle);
1132 #endif
1133 
1134 	*addr = NULL;
1135 
1136 	return (CS_BAD_BASE);
1137 }
1138 
1139 /*ARGSUSED*/
1140 int32_t
csx_DupHandle(acc_handle_t handle,acc_handle_t * dup,uint32_t flags)1141 csx_DupHandle(acc_handle_t handle, acc_handle_t *dup, uint32_t flags)
1142 {
1143 #ifndef	lint
1144 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
1145 #endif	/* lint */
1146 
1147 #ifdef	CS_STUBS_DEBUG
1148 	if (cs_stubs_debug > 3)
1149 	    cmn_err(CE_CONT, "csx_DupHandle: handle: 0x%p\n", handle);
1150 #endif
1151 
1152 	return (CS_BAD_HANDLE);
1153 
1154 #ifdef	XXX
1155 	*dup = (acc_handle_t)kmem_alloc(sizeof (acc_hdl_t), KM_SLEEP);
1156 	((acc_hdl_t *)*dup)->ddi_handle =
1157 		(ddi_acc_handle_t *)kmem_alloc(sizeof (ddi_acc_impl_t),
1158 		    KM_SLEEP);
1159 
1160 	bcopy((caddr_t)hp, (caddr_t)((acc_hdl_t *)*dup)->ddi_handle,
1161 	    sizeof (ddi_acc_impl_t));
1162 
1163 	return (CS_SUCCESS);
1164 #endif
1165 }
1166 
1167 int32_t
csx_FreeHandle(acc_handle_t * handle)1168 csx_FreeHandle(acc_handle_t *handle)
1169 {
1170 #ifdef	CS_STUBS_DEBUG
1171 	if (cs_stubs_debug > 3)
1172 	    cmn_err(CE_CONT, "csx_FreeHandle: handle: 0x%p\n", *handle);
1173 #endif
1174 	return (CS_BAD_HANDLE);
1175 
1176 #ifdef	XXX
1177 
1178 	kmem_free((void *)((acc_hdl_t *)*handle)->ddi_handle,
1179 		sizeof (ddi_acc_impl_t));
1180 	kmem_free((void *)(acc_hdl_t *)*handle, sizeof (acc_hdl_t));
1181 
1182 	return (CS_SUCCESS);
1183 #endif
1184 }
1185 
1186 /*
1187  * XXX - Probably want to remove these fucntions soon
1188  */
1189 int32_t
csx_GetHandleOffset(acc_handle_t handle,uint32_t * offset)1190 csx_GetHandleOffset(acc_handle_t handle, uint32_t *offset)
1191 {
1192 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
1193 
1194 #ifdef	CS_STUBS_DEBUG
1195 	if (cs_stubs_debug > 3)
1196 	    cmn_err(CE_CONT, "csx_GetHandleOffset: handle: 0x%p\n", handle);
1197 #endif
1198 
1199 	*offset = hp->ah_offset;
1200 
1201 	return (CS_SUCCESS);
1202 }
1203 
1204 int32_t
csx_SetHandleOffset(acc_handle_t handle,uint32_t offset)1205 csx_SetHandleOffset(acc_handle_t handle, uint32_t offset)
1206 {
1207 	ddi_acc_hdl_t *hp = impl_acc_hdl_get(handle);
1208 
1209 #ifdef	CS_STUBS_DEBUG
1210 	if (cs_stubs_debug > 3)
1211 	    cmn_err(CE_CONT, "csx_SetHandleOffset: handle: 0x%p\n", handle);
1212 #endif
1213 
1214 	hp->ah_offset = offset;
1215 
1216 	return (CS_SUCCESS);
1217 }
1218 
1219 static int
cs_no_carservices(int32_t arg __unused,...)1220 cs_no_carservices(int32_t arg __unused, ...)
1221 {
1222 #ifdef	CS_STUBS_DEBUG
1223 	if (cs_stubs_debug > 3)
1224 	    cmn_err(CE_CONT, "cs_no_carservices\n");
1225 #endif
1226 	return (CS_UNSUPPORTED_FUNCTION);
1227 }
1228