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