1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate #ifndef _CS_PRIV_H 28*0Sstevel@tonic-gate #define _CS_PRIV_H 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*0Sstevel@tonic-gate 32*0Sstevel@tonic-gate #ifdef __cplusplus 33*0Sstevel@tonic-gate extern "C" { 34*0Sstevel@tonic-gate #endif 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate /* 37*0Sstevel@tonic-gate * PCMCIA Card Services private header file 38*0Sstevel@tonic-gate */ 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate /* 41*0Sstevel@tonic-gate * typedef for function pointers to quiet lint and cc -v 42*0Sstevel@tonic-gate */ 43*0Sstevel@tonic-gate typedef int32_t (f_t)(int32_t, ...); /* for lint - cc -v quieting */ 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate /* 46*0Sstevel@tonic-gate * Magic number we use when talking with Socket Services 47*0Sstevel@tonic-gate */ 48*0Sstevel@tonic-gate #define CS_MAGIC PCCS_MAGIC 49*0Sstevel@tonic-gate 50*0Sstevel@tonic-gate /* 51*0Sstevel@tonic-gate * Make the calls to SocketServices and the CIS Parser look like 52*0Sstevel@tonic-gate * function calls. 53*0Sstevel@tonic-gate */ 54*0Sstevel@tonic-gate #define SocketServices (*cs_socket_services) 55*0Sstevel@tonic-gate #define CIS_PARSER (*cis_parser) 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gate /* 58*0Sstevel@tonic-gate * CIS_DEFAULT_SPEED is the default speed to use to read the CIS 59*0Sstevel@tonic-gate * in AM space. It is expressed in nS. 60*0Sstevel@tonic-gate */ 61*0Sstevel@tonic-gate #define CIS_DEFAULT_SPEED 250 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gate /* 64*0Sstevel@tonic-gate * This is the IO window speed. 65*0Sstevel@tonic-gate */ 66*0Sstevel@tonic-gate #define IO_WIN_SPEED 250 67*0Sstevel@tonic-gate 68*0Sstevel@tonic-gate /* 69*0Sstevel@tonic-gate * Flags to support various internal first/next functions. All of 70*0Sstevel@tonic-gate * these must be within CIS_GET_LTUPLE_OPMASK which is defined 71*0Sstevel@tonic-gate * in the cis.h file. Values outside this mask range are used 72*0Sstevel@tonic-gate * internally by the CIS parser. 73*0Sstevel@tonic-gate */ 74*0Sstevel@tonic-gate #define CS_GET_FIRST_FLAG 0x0001 75*0Sstevel@tonic-gate #define CS_GET_NEXT_FLAG 0x0002 76*0Sstevel@tonic-gate 77*0Sstevel@tonic-gate /* 78*0Sstevel@tonic-gate * Macros to manipulate bits - only does up to uint32_t size 79*0Sstevel@tonic-gate */ 80*0Sstevel@tonic-gate #define CS_BIT_WORDSIZE (sizeof (uint32_t)) 81*0Sstevel@tonic-gate 82*0Sstevel@tonic-gate #define CS_BIT_GET(val, bit) \ 83*0Sstevel@tonic-gate ((uint32_t)(val) & (uint32_t)(1<<(uint32_t)(bit))) 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gate #define CS_BIT_CLEAR(val, bit) ((val) &= (uint32_t)~(1<<(uint32_t)(bit))) 86*0Sstevel@tonic-gate 87*0Sstevel@tonic-gate #define CS_BIT_SET(val, bit) \ 88*0Sstevel@tonic-gate ((uint32_t)(val) |= (uint32_t)(1<<(uint32_t)(bit))) 89*0Sstevel@tonic-gate 90*0Sstevel@tonic-gate /* 91*0Sstevel@tonic-gate * Minimum time to wait after socket reset before we are allowed to 92*0Sstevel@tonic-gate * access the card. The PCMCIA specification says at least 20mS 93*0Sstevel@tonic-gate * must elapse from the time that the card is reset until the 94*0Sstevel@tonic-gate * first access of any kind can be made to the card. This time 95*0Sstevel@tonic-gate * value is expressed in mS. 96*0Sstevel@tonic-gate */ 97*0Sstevel@tonic-gate #define RESET_TIMEOUT_TIME 180 98*0Sstevel@tonic-gate 99*0Sstevel@tonic-gate /* 100*0Sstevel@tonic-gate * Maximum time to wait for card ready after resetting the socket. 101*0Sstevel@tonic-gate * We wait for card ready a maximum of 20 seconds after card 102*0Sstevel@tonic-gate * reset before considering that we have an error condition. 103*0Sstevel@tonic-gate * XXX - what does PCMCIA specify as the max time here?? 104*0Sstevel@tonic-gate */ 105*0Sstevel@tonic-gate #define READY_TIMEOUT_TIME (drv_usectohz(20000000)) 106*0Sstevel@tonic-gate 107*0Sstevel@tonic-gate /* 108*0Sstevel@tonic-gate * Time between periodically kicking the soft interrupt handler. 109*0Sstevel@tonic-gate */ 110*0Sstevel@tonic-gate #define SOFTINT_TIMEOUT_TIME (drv_usectohz(2000000)) 111*0Sstevel@tonic-gate 112*0Sstevel@tonic-gate /* 113*0Sstevel@tonic-gate * Various delays are necessary when switching the card and socket 114*0Sstevel@tonic-gate * between IO and memory modes. All delays are in mS. 115*0Sstevel@tonic-gate * 116*0Sstevel@tonic-gate * cs_request_configuration parameters: 117*0Sstevel@tonic-gate * CS_RC1_DELAY - delay between writing COR and switching socket 118*0Sstevel@tonic-gate * to IO mode 119*0Sstevel@tonic-gate * CS_RC2_DELAY - delay after switching socket to IO mode 120*0Sstevel@tonic-gate * 121*0Sstevel@tonic-gate * cs_release_configuration parameters: 122*0Sstevel@tonic-gate * CS_RQ_DELAY - amount of time that the RESET bit in the COR is 123*0Sstevel@tonic-gate * held asserted 124*0Sstevel@tonic-gate */ 125*0Sstevel@tonic-gate #define CS_RC1_DELAY 20 /* COR->IO delay in mS */ 126*0Sstevel@tonic-gate #define CS_RC2_DELAY 300 /* post-COR delay in mS */ 127*0Sstevel@tonic-gate #define CS_RQ_DELAY 100 /* COR(RESET) delay in mS */ 128*0Sstevel@tonic-gate 129*0Sstevel@tonic-gate /* 130*0Sstevel@tonic-gate * Handy macro to do untimeout. 131*0Sstevel@tonic-gate */ 132*0Sstevel@tonic-gate #define UNTIMEOUT(id) \ 133*0Sstevel@tonic-gate if ((id)) { \ 134*0Sstevel@tonic-gate (void) untimeout((id)); \ 135*0Sstevel@tonic-gate (id) = 0; \ 136*0Sstevel@tonic-gate } 137*0Sstevel@tonic-gate 138*0Sstevel@tonic-gate /* 139*0Sstevel@tonic-gate * Macros to enter/exit event thread mutex 140*0Sstevel@tonic-gate */ 141*0Sstevel@tonic-gate #define EVENT_THREAD_MUTEX_ENTER(acq, sp) \ 142*0Sstevel@tonic-gate acq = !MUTEX_HELD(&sp->client_lock); \ 143*0Sstevel@tonic-gate if (acq) \ 144*0Sstevel@tonic-gate mutex_enter(&sp->client_lock); 145*0Sstevel@tonic-gate #define EVENT_THREAD_MUTEX_EXIT(acq, sp) \ 146*0Sstevel@tonic-gate if (acq) \ 147*0Sstevel@tonic-gate mutex_exit(&sp->client_lock); 148*0Sstevel@tonic-gate 149*0Sstevel@tonic-gate /* 150*0Sstevel@tonic-gate * cisregister_t structure is used to support the CISRegister 151*0Sstevel@tonic-gate * and the CISUnregister function calls 152*0Sstevel@tonic-gate */ 153*0Sstevel@tonic-gate typedef struct cisregister_t { 154*0Sstevel@tonic-gate uint32_t cis_magic; 155*0Sstevel@tonic-gate uint32_t cis_version; 156*0Sstevel@tonic-gate void * (*cis_parser)(int32_t function, ...); 157*0Sstevel@tonic-gate cistpl_callout_t *cistpl_std_callout; /* standard callout list */ 158*0Sstevel@tonic-gate } cisregister_t; 159*0Sstevel@tonic-gate 160*0Sstevel@tonic-gate /* 161*0Sstevel@tonic-gate * These two defines are to support CISRegister and CISUnregister 162*0Sstevel@tonic-gate */ 163*0Sstevel@tonic-gate #define CIS_MAGIC 0x20434953 164*0Sstevel@tonic-gate #define CIS_VERSION _VERSION(0, 1) 165*0Sstevel@tonic-gate 166*0Sstevel@tonic-gate /* 167*0Sstevel@tonic-gate * CS_MAX_CIS defines the number of CIS chains that we hang off the per-socket 168*0Sstevel@tonic-gate * structure. 169*0Sstevel@tonic-gate * 170*0Sstevel@tonic-gate * CS_GLOBAL_CIS defines the index where the CIS parser puts the first CIS list 171*0Sstevel@tonic-gate * for a single-function card or the global CIS list for a multi-function 172*0Sstevel@tonic-gate * card. 173*0Sstevel@tonic-gate * 174*0Sstevel@tonic-gate * CS_MAX_CIS is one greater than CIS_MAX_FUNCTIONS since the CIS parser 175*0Sstevel@tonic-gate * puts the global CIS chain on the CS_GLOBAL_CIS function index as 176*0Sstevel@tonic-gate * follows: 177*0Sstevel@tonic-gate * 178*0Sstevel@tonic-gate * For single-function cards: 179*0Sstevel@tonic-gate * sp->cis[0] - CIS chain 180*0Sstevel@tonic-gate * sp->cis[1..(CIS_MAX_FUNCTIONS - 1)] - not used 181*0Sstevel@tonic-gate * sp->cis[CS_GLOBAL_CIS] - not used 182*0Sstevel@tonic-gate * 183*0Sstevel@tonic-gate * For multi-function cards: 184*0Sstevel@tonic-gate * sp->cis[0..(CIS_MAX_FUNCTIONS - 1)] - global CIS chain followed 185*0Sstevel@tonic-gate * by per-function CIS chain 186*0Sstevel@tonic-gate * sp->cis[CS_GLOBAL_CIS] - global CIS chain 187*0Sstevel@tonic-gate */ 188*0Sstevel@tonic-gate #define CS_MAX_CIS (CIS_MAX_FUNCTIONS + 1) 189*0Sstevel@tonic-gate #define CS_GLOBAL_CIS CIS_MAX_FUNCTIONS 190*0Sstevel@tonic-gate 191*0Sstevel@tonic-gate /* 192*0Sstevel@tonic-gate * CS_SS_CLIENT_HANDLE is a special client handle that Socket Services gets 193*0Sstevel@tonic-gate * when it registers with RegisterClient. 194*0Sstevel@tonic-gate */ 195*0Sstevel@tonic-gate #define CS_SS_CLIENT_HANDLE 0x00000000 196*0Sstevel@tonic-gate 197*0Sstevel@tonic-gate /* 198*0Sstevel@tonic-gate * Client handle, socket number, function number and socket pointer 199*0Sstevel@tonic-gate * macros. The client handle encoding is private to Card Services, 200*0Sstevel@tonic-gate * and external modules should not use these macros to manipulate 201*0Sstevel@tonic-gate * client handles. 202*0Sstevel@tonic-gate * 203*0Sstevel@tonic-gate * The encoding of the client handle is: 204*0Sstevel@tonic-gate * 205*0Sstevel@tonic-gate * xxxxxfff | xsssssss | cccccccc | cccccccc 206*0Sstevel@tonic-gate * 207*0Sstevel@tonic-gate * f - function number bit 208*0Sstevel@tonic-gate * s - socket number bit 209*0Sstevel@tonic-gate * c - client number bit 210*0Sstevel@tonic-gate * x - don't care bits 211*0Sstevel@tonic-gate */ 212*0Sstevel@tonic-gate #define CLIENT_HANDLE_IS_SS(ch) (!GET_CLIENT_MINOR((ch))) 213*0Sstevel@tonic-gate #define CS_MAX_SOCKETS_MASK (PCMCIA_MAX_SOCKETS - 1) 214*0Sstevel@tonic-gate #define CS_MAX_FUNCTIONS_MASK (CIS_MAX_FUNCTIONS - 1) 215*0Sstevel@tonic-gate #define CS_MAX_CLIENTS_MASK 0x0ffff 216*0Sstevel@tonic-gate #define CS_MAX_CLIENTS (CS_MAX_CLIENTS_MASK - 2) 217*0Sstevel@tonic-gate #define MAKE_CLIENT_HANDLE(s, f, c) ((((f)&CS_MAX_FUNCTIONS_MASK)<<24) | \ 218*0Sstevel@tonic-gate (((s)&CS_MAX_SOCKETS_MASK)<<16) | \ 219*0Sstevel@tonic-gate ((c)&CS_MAX_CLIENTS_MASK)) 220*0Sstevel@tonic-gate #define GET_CLIENT_SOCKET(ch) (((ch)>>16)&CS_MAX_SOCKETS_MASK) 221*0Sstevel@tonic-gate #define GET_CLIENT_FUNCTION(ch) (((ch)>>24)&CS_MAX_FUNCTIONS_MASK) 222*0Sstevel@tonic-gate #define GET_CLIENT_MINOR(ch) ((ch)&CS_MAX_CLIENTS_MASK) 223*0Sstevel@tonic-gate 224*0Sstevel@tonic-gate /* 225*0Sstevel@tonic-gate * Socket number macros. These are used by Socket Services, CSI 226*0Sstevel@tonic-gate * drivers and the "super-client" driver to specify which 227*0Sstevel@tonic-gate * socket and function number on that socket they wish to 228*0Sstevel@tonic-gate * manipulate. This socket number encoding is typically passed 229*0Sstevel@tonic-gate * to various Card Services functions by these drivers. 230*0Sstevel@tonic-gate * 231*0Sstevel@tonic-gate * The encoding of the socket number is: 232*0Sstevel@tonic-gate * 233*0Sstevel@tonic-gate * xxxxxxxx | xxxxgfff | xxxxxxxx | xsssssss 234*0Sstevel@tonic-gate * 235*0Sstevel@tonic-gate * g - global CIS bit 236*0Sstevel@tonic-gate * f - function number bit 237*0Sstevel@tonic-gate * s - socket number bit 238*0Sstevel@tonic-gate * x - don't care bits 239*0Sstevel@tonic-gate */ 240*0Sstevel@tonic-gate #define CS_GET_SOCKET_NUMBER(s) ((s)&CS_MAX_SOCKETS_MASK) 241*0Sstevel@tonic-gate #define CS_GET_FUNCTION_NUMBER(s) (((s)>>16)&(CS_MAX_FUNCTIONS_MASK | \ 242*0Sstevel@tonic-gate CIS_MAX_FUNCTIONS)) 243*0Sstevel@tonic-gate #define CS_SET_SOCKET_NUMBER(s) ((s)&CS_MAX_SOCKETS_MASK) 244*0Sstevel@tonic-gate #define CS_SET_FUNCTION_NUMBER(f) (((f)&(CS_MAX_FUNCTIONS_MASK | \ 245*0Sstevel@tonic-gate CIS_MAX_FUNCTIONS))<<16) 246*0Sstevel@tonic-gate #define CS_MAKE_SOCKET_NUMBER(s, f) (CS_SET_SOCKET_NUMBER(s) | \ 247*0Sstevel@tonic-gate CS_SET_FUNCTION_NUMBER(f)) 248*0Sstevel@tonic-gate 249*0Sstevel@tonic-gate /* 250*0Sstevel@tonic-gate * DIP2SOCKET_NUM(dip) - this macro gets the PCM_DEV_SOCKET property from 251*0Sstevel@tonic-gate * the passed dip. If the property can't be found, then the default 252*0Sstevel@tonic-gate * value of cs_globals.max_socket_num is returned. 253*0Sstevel@tonic-gate */ 254*0Sstevel@tonic-gate #define DIP2SOCKET_NUM(dip) ddi_getprop(DDI_DEV_T_NONE, dip,\ 255*0Sstevel@tonic-gate (DDI_PROP_CANSLEEP | \ 256*0Sstevel@tonic-gate DDI_PROP_NOTPROM), \ 257*0Sstevel@tonic-gate PCM_DEV_SOCKET, \ 258*0Sstevel@tonic-gate cs_globals.max_socket_num) 259*0Sstevel@tonic-gate 260*0Sstevel@tonic-gate /* 261*0Sstevel@tonic-gate * Range checking macros 262*0Sstevel@tonic-gate * 263*0Sstevel@tonic-gate * CHECK_SOCKET_NUM(socket_number, max_sockets) returns 1 if 264*0Sstevel@tonic-gate * socket_number is in range 265*0Sstevel@tonic-gate */ 266*0Sstevel@tonic-gate #define CHECK_SOCKET_NUM(sn, ms) (((sn) >= (ms))?0:1) 267*0Sstevel@tonic-gate 268*0Sstevel@tonic-gate /* 269*0Sstevel@tonic-gate * window macros 270*0Sstevel@tonic-gate * 271*0Sstevel@tonic-gate * These all expect that the window has been validated as a valid 272*0Sstevel@tonic-gate * window (i.e. CW_WINDOW_VALID is set in window state) 273*0Sstevel@tonic-gate * 274*0Sstevel@tonic-gate * Note that WINDOW_FOR_SOCKET expects a socket mask for the wsm 275*0Sstevel@tonic-gate * parameter (this is a socket_enum_t type, and NOT just a 276*0Sstevel@tonic-gate * plain old uint32_t) 277*0Sstevel@tonic-gate */ 278*0Sstevel@tonic-gate #define WINDOW_FOR_SOCKET(wsm, sn) ((wsm)[sn/PR_WORDSIZE] & \ 279*0Sstevel@tonic-gate (1 << ((sn) & PR_MASK))) 280*0Sstevel@tonic-gate #define WINDOW_AVAILABLE_FOR_MEM(cwp) (!(cwp->state & CW_WIN_IN_USE)) 281*0Sstevel@tonic-gate #define WINDOW_AVAILABLE_FOR_IO(cwp) \ 282*0Sstevel@tonic-gate (!(cwp->state & (CW_CIS | CW_MEM | CW_ALLOCATED))) 283*0Sstevel@tonic-gate 284*0Sstevel@tonic-gate /* 285*0Sstevel@tonic-gate * IO Base and NumPorts address frobnitz macros 286*0Sstevel@tonic-gate */ 287*0Sstevel@tonic-gate #define IOADDR_FROBNITZ(Base, IOAddrLines) (Base&((1<<IOAddrLines)-1)) 288*0Sstevel@tonic-gate #define IONUMPORTS_FROBNITZ(np) (((np)&1)?((np)+1):(np)) 289*0Sstevel@tonic-gate 290*0Sstevel@tonic-gate /* 291*0Sstevel@tonic-gate * Structure that contains offsets to the card's configuration registers 292*0Sstevel@tonic-gate * as well as copies of the data written to them in RequestConfiguration. 293*0Sstevel@tonic-gate * We use an offset per register approach since not all cards have 294*0Sstevel@tonic-gate * all registers implemented, and by specifying a NULL register offset, 295*0Sstevel@tonic-gate * we know not to try to access that register. 296*0Sstevel@tonic-gate */ 297*0Sstevel@tonic-gate typedef struct config_regs_t { 298*0Sstevel@tonic-gate cfg_regs_t cor; /* Configuration Option Register */ 299*0Sstevel@tonic-gate uint32_t cor_p; 300*0Sstevel@tonic-gate cfg_regs_t ccsr; /* Configuration and Status Register */ 301*0Sstevel@tonic-gate uint32_t ccsr_p; 302*0Sstevel@tonic-gate cfg_regs_t prr; /* Pin Replacement Register */ 303*0Sstevel@tonic-gate uint32_t prr_p; 304*0Sstevel@tonic-gate cfg_regs_t scr; /* Socket and Copy Register */ 305*0Sstevel@tonic-gate uint32_t scr_p; 306*0Sstevel@tonic-gate cfg_regs_t exstat; /* Extended Status Register */ 307*0Sstevel@tonic-gate uint32_t exstat_p; 308*0Sstevel@tonic-gate cfg_regs_t iobase0; /* IO Base 0 Register */ 309*0Sstevel@tonic-gate uint32_t iobase0_p; 310*0Sstevel@tonic-gate cfg_regs_t iobase1; /* IO Base 1 Register */ 311*0Sstevel@tonic-gate uint32_t iobase1_p; 312*0Sstevel@tonic-gate cfg_regs_t iobase2; /* IO Base 2 Register */ 313*0Sstevel@tonic-gate uint32_t iobase2_p; 314*0Sstevel@tonic-gate cfg_regs_t iobase3; /* IO Base 3 Register */ 315*0Sstevel@tonic-gate uint32_t iobase3_p; 316*0Sstevel@tonic-gate cfg_regs_t iolimit; /* IO Limit Register */ 317*0Sstevel@tonic-gate uint32_t iolimit_p; 318*0Sstevel@tonic-gate } config_regs_t; 319*0Sstevel@tonic-gate 320*0Sstevel@tonic-gate /* 321*0Sstevel@tonic-gate * Macro to make calling the client's event handler look like a function. 322*0Sstevel@tonic-gate */ 323*0Sstevel@tonic-gate #define CLIENT_EVENT_CALLBACK(cp, event, pri) \ 324*0Sstevel@tonic-gate (cp)->event_callback_handler(event, pri, \ 325*0Sstevel@tonic-gate &(cp)->event_callback_args) 326*0Sstevel@tonic-gate 327*0Sstevel@tonic-gate /* 328*0Sstevel@tonic-gate * Macro to return event in PRR - this also clears the changed bit if 329*0Sstevel@tonic-gate * the event occured. 330*0Sstevel@tonic-gate */ 331*0Sstevel@tonic-gate #define PRR_EVENT(prrx, pe, ps, ce, re) \ 332*0Sstevel@tonic-gate if (prrx & pe) { \ 333*0Sstevel@tonic-gate if (prrx & ps) \ 334*0Sstevel@tonic-gate (re) |= ce; \ 335*0Sstevel@tonic-gate prrx &= ~pe; \ 336*0Sstevel@tonic-gate prrx |= ps; \ 337*0Sstevel@tonic-gate } 338*0Sstevel@tonic-gate 339*0Sstevel@tonic-gate /* 340*0Sstevel@tonic-gate * io_alloc_t struct used to keep track of a client's IO window allocation 341*0Sstevel@tonic-gate */ 342*0Sstevel@tonic-gate typedef struct io_alloc_t { 343*0Sstevel@tonic-gate uint32_t Window1; /* allocated IO window no. for set #1 */ 344*0Sstevel@tonic-gate baseaddru_t BasePort1; /* 1st IO range base address or port */ 345*0Sstevel@tonic-gate uint32_t NumPorts1; /* 1st IO range no. contiguous ports */ 346*0Sstevel@tonic-gate uint32_t Attributes1; /* 1st IO range attributes */ 347*0Sstevel@tonic-gate uint32_t Window2; /* allocated IO window no. for set #2 */ 348*0Sstevel@tonic-gate baseaddru_t BasePort2; /* s2nd IO range base address or port */ 349*0Sstevel@tonic-gate uint32_t NumPorts2; /* 2nd IO range no. contiguous ports */ 350*0Sstevel@tonic-gate uint32_t Attributes2; /* second IO range attributes */ 351*0Sstevel@tonic-gate uint32_t IOAddrLines; /* number of IO address lines decoded */ 352*0Sstevel@tonic-gate } io_alloc_t; 353*0Sstevel@tonic-gate 354*0Sstevel@tonic-gate /* 355*0Sstevel@tonic-gate * irq_alloc_t structure used to keep track of a client's IRQ allocation 356*0Sstevel@tonic-gate */ 357*0Sstevel@tonic-gate typedef struct irq_alloc_t { 358*0Sstevel@tonic-gate uint32_t Attributes; /* IRQ attribute flags */ 359*0Sstevel@tonic-gate uint32_t irq; /* assigned IRQ number */ 360*0Sstevel@tonic-gate uint32_t handler_id; /* IRQ handler ID for this IRQ */ 361*0Sstevel@tonic-gate f_t *irq_handler; 362*0Sstevel@tonic-gate void *irq_handler_arg1; 363*0Sstevel@tonic-gate void *irq_handler_arg2; 364*0Sstevel@tonic-gate } irq_alloc_t; 365*0Sstevel@tonic-gate 366*0Sstevel@tonic-gate /* 367*0Sstevel@tonic-gate * The client data structure 368*0Sstevel@tonic-gate */ 369*0Sstevel@tonic-gate typedef struct client_t { 370*0Sstevel@tonic-gate client_handle_t client_handle; /* this client's client handle */ 371*0Sstevel@tonic-gate unsigned flags; /* client flags */ 372*0Sstevel@tonic-gate /* resource control */ 373*0Sstevel@tonic-gate uint32_t memwin_count; /* number of mem windows allocated */ 374*0Sstevel@tonic-gate io_alloc_t io_alloc; /* IO resource allocations */ 375*0Sstevel@tonic-gate irq_alloc_t irq_alloc; /* IRQ resource allocations */ 376*0Sstevel@tonic-gate /* event support */ 377*0Sstevel@tonic-gate uint32_t event_mask; /* client event mask */ 378*0Sstevel@tonic-gate uint32_t global_mask; /* client global event mask */ 379*0Sstevel@tonic-gate uint32_t events; /* current events pending */ 380*0Sstevel@tonic-gate uint32_t pending_events; /* events pending in RegisterClient */ 381*0Sstevel@tonic-gate csfunction_t *event_callback_handler; 382*0Sstevel@tonic-gate event_callback_args_t event_callback_args; 383*0Sstevel@tonic-gate /* config registers support */ 384*0Sstevel@tonic-gate config_regs_t config_regs; /* pointers to config registers */ 385*0Sstevel@tonic-gate uint32_t config_regs_offset; /* offset from start of AM */ 386*0Sstevel@tonic-gate unsigned pin; /* valid bits in PRR */ 387*0Sstevel@tonic-gate uint32_t present; /* which config registers present */ 388*0Sstevel@tonic-gate /* DDI support */ 389*0Sstevel@tonic-gate dev_info_t *dip; /* this client's dip */ 390*0Sstevel@tonic-gate char *driver_name; /* client's driver name */ 391*0Sstevel@tonic-gate int32_t instance; /* client's driver instance */ 392*0Sstevel@tonic-gate /* list control */ 393*0Sstevel@tonic-gate struct client_t *next; /* next client pointer */ 394*0Sstevel@tonic-gate struct client_t *prev; /* previous client pointer */ 395*0Sstevel@tonic-gate } client_t; 396*0Sstevel@tonic-gate 397*0Sstevel@tonic-gate /* 398*0Sstevel@tonic-gate * Flags for client structure - note that we share the client_t->flags 399*0Sstevel@tonic-gate * member with the definitions in cs.h that are used by the 400*0Sstevel@tonic-gate * RegisterClient function. 401*0Sstevel@tonic-gate * 402*0Sstevel@tonic-gate * We can start our flags from 0x00001000 and on up. 403*0Sstevel@tonic-gate */ 404*0Sstevel@tonic-gate #define REQ_CONFIGURATION_DONE 0x00001000 /* RequestConfiguration done */ 405*0Sstevel@tonic-gate #define REQ_SOCKET_MASK_DONE 0x00002000 /* RequestSocketMask done */ 406*0Sstevel@tonic-gate #define REQ_IO_DONE 0x00004000 /* RequestIO done */ 407*0Sstevel@tonic-gate #define REQ_IRQ_DONE 0x00008000 /* RequestIRQ done */ 408*0Sstevel@tonic-gate #define CLIENT_SUPER_CLIENT 0x00010000 /* "super-client" client */ 409*0Sstevel@tonic-gate #define CLIENT_CSI_CLIENT 0x00020000 /* CSI client */ 410*0Sstevel@tonic-gate #define CLIENT_CARD_INSERTED 0x00100000 /* current card for client */ 411*0Sstevel@tonic-gate #define CLIENT_SENT_INSERTION 0x00200000 /* send CARD_INSERTION */ 412*0Sstevel@tonic-gate #define CLIENT_MTD_IN_PROGRESS 0x01000000 /* MTD op in progress */ 413*0Sstevel@tonic-gate #define CLIENT_IO_ALLOCATED 0x02000000 /* IO resources allocated */ 414*0Sstevel@tonic-gate #define CLIENT_IRQ_ALLOCATED 0x04000000 /* IRQ resources allocated */ 415*0Sstevel@tonic-gate #define CLIENT_WIN_ALLOCATED 0x08000000 /* window resources allocated */ 416*0Sstevel@tonic-gate 417*0Sstevel@tonic-gate #ifdef USE_IOMMAP_WINDOW 418*0Sstevel@tonic-gate /* 419*0Sstevel@tonic-gate * io_mmap_window_t structure that describes the memory-mapped IO 420*0Sstevel@tonic-gate * window on this socket 421*0Sstevel@tonic-gate */ 422*0Sstevel@tonic-gate typedef struct io_mmap_window_t { 423*0Sstevel@tonic-gate uint32_t flags; /* window flags */ 424*0Sstevel@tonic-gate uint32_t number; /* IO window number */ 425*0Sstevel@tonic-gate uint32_t size; /* size of mapped IO window */ 426*0Sstevel@tonic-gate ddi_acc_handle_t handle; /* window mapped base address */ 427*0Sstevel@tonic-gate uint32_t count; /* referance count */ 428*0Sstevel@tonic-gate } io_mmap_window_t; 429*0Sstevel@tonic-gate #endif /* USE_IOMMAP_WINDOW */ 430*0Sstevel@tonic-gate 431*0Sstevel@tonic-gate /* 432*0Sstevel@tonic-gate * cis_info_t structure used to hold per-socket CIS information 433*0Sstevel@tonic-gate */ 434*0Sstevel@tonic-gate typedef struct cis_info_t { 435*0Sstevel@tonic-gate uint32_t flags; /* CIS-specific flags */ 436*0Sstevel@tonic-gate cistpl_t *cis; /* CIS linked lists */ 437*0Sstevel@tonic-gate uint32_t nchains; /* number of tuple chains in CIS */ 438*0Sstevel@tonic-gate uint32_t ntuples; /* number of tuples in CIS */ 439*0Sstevel@tonic-gate } cis_info_t; 440*0Sstevel@tonic-gate 441*0Sstevel@tonic-gate /* 442*0Sstevel@tonic-gate * cs_adapter_t structure used to hold per-socket 443*0Sstevel@tonic-gate * adapter-specific info 444*0Sstevel@tonic-gate */ 445*0Sstevel@tonic-gate typedef struct cs_adapter_t { 446*0Sstevel@tonic-gate uint32_t flags; /* adapter flags */ 447*0Sstevel@tonic-gate char name[MODMAXNAMELEN]; /* adapter module name */ 448*0Sstevel@tonic-gate uint32_t major; /* adapter major number */ 449*0Sstevel@tonic-gate uint32_t minor; /* adapter minor number */ 450*0Sstevel@tonic-gate uint32_t instance; /* instance number of this adapter */ 451*0Sstevel@tonic-gate uint32_t number; /* canonical adapter number */ 452*0Sstevel@tonic-gate uint32_t num_sockets; /* # sockets on this adapter */ 453*0Sstevel@tonic-gate uint32_t first_socket; /* first socket # on this adapter */ 454*0Sstevel@tonic-gate } cs_adapter_t; 455*0Sstevel@tonic-gate 456*0Sstevel@tonic-gate /* 457*0Sstevel@tonic-gate * The per-socket structure. 458*0Sstevel@tonic-gate */ 459*0Sstevel@tonic-gate typedef struct cs_socket_t { 460*0Sstevel@tonic-gate unsigned socket_num; /* socket number */ 461*0Sstevel@tonic-gate uint32_t flags; /* socket flags */ 462*0Sstevel@tonic-gate uint32_t init_state; /* cs_init state */ 463*0Sstevel@tonic-gate cs_adapter_t adapter; /* adapter info */ 464*0Sstevel@tonic-gate /* socket thread control and status */ 465*0Sstevel@tonic-gate kthread_t *event_thread; /* per-socket work thread */ 466*0Sstevel@tonic-gate uint32_t thread_state; /* socket thread state flags */ 467*0Sstevel@tonic-gate kmutex_t lock; /* protects events and clients */ 468*0Sstevel@tonic-gate kcondvar_t thread_cv; /* event handling synchronization */ 469*0Sstevel@tonic-gate kcondvar_t caller_cv; /* event handling synchronization */ 470*0Sstevel@tonic-gate kcondvar_t reset_cv; /* for use after card RESET */ 471*0Sstevel@tonic-gate uint32_t events; /* socket events */ 472*0Sstevel@tonic-gate uint32_t event_mask; /* socket event mask */ 473*0Sstevel@tonic-gate ddi_softintr_t softint_id; /* soft interrupt handler ID */ 474*0Sstevel@tonic-gate timeout_id_t rdybsy_tmo_id; /* timer ID for READY/BUSY timer */ 475*0Sstevel@tonic-gate ddi_iblock_cookie_t *iblk; /* event iblk cookie */ 476*0Sstevel@tonic-gate ddi_idevice_cookie_t *idev; /* event idev cookie */ 477*0Sstevel@tonic-gate callb_cpr_t cprinfo_cs; /* CPR cookie for cs_event_thread */ 478*0Sstevel@tonic-gate callb_cpr_t cprinfo_ss; /* CPR cookie for cs_ss_thread */ 479*0Sstevel@tonic-gate /* client management */ 480*0Sstevel@tonic-gate client_t *client_list; /* clients on this socket */ 481*0Sstevel@tonic-gate unsigned next_cl_minor; /* next available client minor num */ 482*0Sstevel@tonic-gate kmutex_t client_lock; /* protects client list */ 483*0Sstevel@tonic-gate uint32_t num_clients; /* number of clients on this socket */ 484*0Sstevel@tonic-gate /* CIS support */ 485*0Sstevel@tonic-gate uint32_t cis_win_num; /* CIS window number */ 486*0Sstevel@tonic-gate unsigned cis_win_size; /* CIS window size */ 487*0Sstevel@tonic-gate uint32_t cis_flags; 488*0Sstevel@tonic-gate uint32_t nfuncs; /* number of functions */ 489*0Sstevel@tonic-gate cis_info_t cis[CS_MAX_CIS]; /* CIS information */ 490*0Sstevel@tonic-gate kmutex_t cis_lock; /* protects CIS */ 491*0Sstevel@tonic-gate #ifdef USE_IOMMAP_WINDOW 492*0Sstevel@tonic-gate /* memory mapped IO window support */ 493*0Sstevel@tonic-gate io_mmap_window_t *io_mmap_window; 494*0Sstevel@tonic-gate #endif /* USE_IOMMAP_WINDOW */ 495*0Sstevel@tonic-gate /* Socket Services work thread control and status */ 496*0Sstevel@tonic-gate kthread_t *ss_thread; /* SS work thread */ 497*0Sstevel@tonic-gate uint32_t ss_thread_state; /* SS work thread state */ 498*0Sstevel@tonic-gate kcondvar_t ss_thread_cv; /* SS work thread synchronization */ 499*0Sstevel@tonic-gate kcondvar_t ss_caller_cv; /* SS work thread synchronization */ 500*0Sstevel@tonic-gate kmutex_t ss_thread_lock; /* protects SS work thread state */ 501*0Sstevel@tonic-gate struct cs_socket_t *next; /* next socket in list */ 502*0Sstevel@tonic-gate } cs_socket_t; 503*0Sstevel@tonic-gate 504*0Sstevel@tonic-gate /* 505*0Sstevel@tonic-gate * cs_socket_t->flags flags 506*0Sstevel@tonic-gate */ 507*0Sstevel@tonic-gate #define SOCKET_CARD_INSERTED 0x00000001 /* card is inserted */ 508*0Sstevel@tonic-gate #define SOCKET_IS_IO 0x00000002 /* socket in IO mode */ 509*0Sstevel@tonic-gate #define SOCKET_UNLOAD_MODULE 0x00000004 /* want to unload CS */ 510*0Sstevel@tonic-gate #define SOCKET_NEEDS_THREAD 0x00000008 /* wake event thread */ 511*0Sstevel@tonic-gate #define SOCKET_IS_VALID 0x00000020 /* socket OK to use */ 512*0Sstevel@tonic-gate 513*0Sstevel@tonic-gate /* 514*0Sstevel@tonic-gate * cs_socket_t->thread_state and cs_socket_t->ss_thread_state flags 515*0Sstevel@tonic-gate */ 516*0Sstevel@tonic-gate 517*0Sstevel@tonic-gate /* generic for all threads */ 518*0Sstevel@tonic-gate #define SOCKET_THREAD_EXIT 0x00000001 /* exit event thread */ 519*0Sstevel@tonic-gate 520*0Sstevel@tonic-gate /* only used for per-socket event thread */ 521*0Sstevel@tonic-gate #define SOCKET_WAIT_FOR_READY 0x00001000 /* waiting for READY */ 522*0Sstevel@tonic-gate #define SOCKET_RESET_TIMER 0x00002000 /* RESET timer */ 523*0Sstevel@tonic-gate #define SOCKET_WAIT_SYNC 0x00004000 /* SYNC */ 524*0Sstevel@tonic-gate 525*0Sstevel@tonic-gate /* only used for Socket Services work thread */ 526*0Sstevel@tonic-gate #define SOCKET_THREAD_CSCISInit 0x00100000 /* call CSCISInit */ 527*0Sstevel@tonic-gate 528*0Sstevel@tonic-gate /* 529*0Sstevel@tonic-gate * cs_socket_t->cis_flags and cs_socket_t->cis_info_t->flags flags 530*0Sstevel@tonic-gate */ 531*0Sstevel@tonic-gate #define CW_VALID_CIS 0x00000001 /* valid CIS */ 532*0Sstevel@tonic-gate #define CW_MULTI_FUNCTION_CIS 0x00000002 /* multifunction card */ 533*0Sstevel@tonic-gate #define CW_LONGLINK_A_FOUND 0x00000004 /* CISTPL_LONGLINK_A */ 534*0Sstevel@tonic-gate #define CW_LONGLINK_C_FOUND 0x00000008 /* CISTP_LONGLINK_C */ 535*0Sstevel@tonic-gate #define CW_LONGLINK_MFC_FOUND 0x00000010 /* LONGLINK_MFC */ 536*0Sstevel@tonic-gate #define CW_CHECK_LINKTARGET 0x00000020 /* check linktarget */ 537*0Sstevel@tonic-gate #define CW_RET_ON_LINKTARGET_ERROR 0x00000040 /* linktarget invalid */ 538*0Sstevel@tonic-gate #define CW_CHECK_PRIMARY_CHAIN 0x00000080 /* check for primary */ 539*0Sstevel@tonic-gate /* chain tuples */ 540*0Sstevel@tonic-gate 541*0Sstevel@tonic-gate /* 542*0Sstevel@tonic-gate * CW_LONGLINK_FOUND - a combination of the various CW_LONGLINK_XXX_FOUND 543*0Sstevel@tonic-gate * flags used to make the code less dense. 544*0Sstevel@tonic-gate */ 545*0Sstevel@tonic-gate #define CW_LONGLINK_FOUND (CW_LONGLINK_A_FOUND | \ 546*0Sstevel@tonic-gate CW_LONGLINK_C_FOUND | \ 547*0Sstevel@tonic-gate CW_LONGLINK_MFC_FOUND) 548*0Sstevel@tonic-gate 549*0Sstevel@tonic-gate /* 550*0Sstevel@tonic-gate * macro to test for a valid CIS window on a socket 551*0Sstevel@tonic-gate */ 552*0Sstevel@tonic-gate #define SOCKET_HAS_CIS_WINDOW(sp) (sp->cis_win_num != PCMCIA_MAX_WINDOWS) 553*0Sstevel@tonic-gate 554*0Sstevel@tonic-gate /* 555*0Sstevel@tonic-gate * cs_socket_t->init_state flags - these flags are used to keep track of what 556*0Sstevel@tonic-gate * was allocated in cs_init so that things can be deallocated properly 557*0Sstevel@tonic-gate * in cs_deinit. 558*0Sstevel@tonic-gate */ 559*0Sstevel@tonic-gate #define SOCKET_INIT_STATE_MUTEX 0x00000001 /* mutexii are OK */ 560*0Sstevel@tonic-gate #define SOCKET_INIT_STATE_CV 0x00000002 /* cvii are OK */ 561*0Sstevel@tonic-gate #define SOCKET_INIT_STATE_THREAD 0x00000004 /* thread OK */ 562*0Sstevel@tonic-gate #define SOCKET_INIT_STATE_READY 0x00000008 /* socket OK */ 563*0Sstevel@tonic-gate #define SOCKET_INIT_STATE_SS_THREAD 0x00000010 /* SS thread OK */ 564*0Sstevel@tonic-gate /* 565*0Sstevel@tonic-gate * While this next flag doesn't really describe a per-socket resource, 566*0Sstevel@tonic-gate * we still set it for each socket. When the soft interrupt handler 567*0Sstevel@tonic-gate * finally gets removed in cs_deinit, this flag will get cleared. 568*0Sstevel@tonic-gate * The value of this flag should follow the previous SOCKET_INIT 569*0Sstevel@tonic-gate * flag values. 570*0Sstevel@tonic-gate */ 571*0Sstevel@tonic-gate #define SOCKET_INIT_STATE_SOFTINTR 0x00000020 /* softintr handler */ 572*0Sstevel@tonic-gate 573*0Sstevel@tonic-gate /* 574*0Sstevel@tonic-gate * Macro to create a socket event thread. 575*0Sstevel@tonic-gate */ 576*0Sstevel@tonic-gate #define CS_THREAD_PRIORITY (v.v_maxsyspri - 4) 577*0Sstevel@tonic-gate #define CREATE_SOCKET_EVENT_THREAD(eh, csp) \ 578*0Sstevel@tonic-gate thread_create(NULL, 0, eh, (void *)csp, \ 579*0Sstevel@tonic-gate 0, &p0, TS_RUN, CS_THREAD_PRIORITY) 580*0Sstevel@tonic-gate 581*0Sstevel@tonic-gate /* 582*0Sstevel@tonic-gate * The per-window structure. 583*0Sstevel@tonic-gate */ 584*0Sstevel@tonic-gate typedef struct cs_window_t { 585*0Sstevel@tonic-gate uint32_t window_num; /* window number */ 586*0Sstevel@tonic-gate window_handle_t window_handle; /* unique window handle */ 587*0Sstevel@tonic-gate client_handle_t client_handle; /* owner of this window */ 588*0Sstevel@tonic-gate unsigned socket_num; /* socket number */ 589*0Sstevel@tonic-gate unsigned state; /* window state flags */ 590*0Sstevel@tonic-gate struct cs_window_t *next; /* next window in list */ 591*0Sstevel@tonic-gate } cs_window_t; 592*0Sstevel@tonic-gate 593*0Sstevel@tonic-gate /* 594*0Sstevel@tonic-gate * Window structure state flags - if none of the bits in the 595*0Sstevel@tonic-gate * CW_WIN_IN_USE mask are set AND if CW_WINDOW_VALID is set, 596*0Sstevel@tonic-gate * it means that this window is available and not being used 597*0Sstevel@tonic-gate * by anyone. 598*0Sstevel@tonic-gate * Setting the CW_ALLOCATED will prevent the window from being found 599*0Sstevel@tonic-gate * as an available window for memory or IO; since memory windows 600*0Sstevel@tonic-gate * are not shared between clients, RequestWindow will always set 601*0Sstevel@tonic-gate * the CW_ALLOCATED flag when it has assigned a memory window to 602*0Sstevel@tonic-gate * a client. Since we can sometimes share IO windows, RequestIO 603*0Sstevel@tonic-gate * will only set the CW_ALLOCATED flag if it doesn't want the IO 604*0Sstevel@tonic-gate * window to be used by other calls to RequestIO. 605*0Sstevel@tonic-gate * When CW_WINDOW_VALID is set, it means that this is a valid window 606*0Sstevel@tonic-gate * that has been added by the framework and can be used. If this 607*0Sstevel@tonic-gate * bit is not set, this window can not be used at all. 608*0Sstevel@tonic-gate */ 609*0Sstevel@tonic-gate #define CW_ALLOCATED 0x00000001 /* window is allocated */ 610*0Sstevel@tonic-gate #define CW_CIS 0x00000002 /* window being used as CIS window */ 611*0Sstevel@tonic-gate #define CW_MEM 0x00000004 /* window being used as mem window */ 612*0Sstevel@tonic-gate #define CW_IO 0x00000008 /* window being used as IO window */ 613*0Sstevel@tonic-gate #define CW_WIN_IN_USE 0x0000ffff /* window in use mask */ 614*0Sstevel@tonic-gate #define CW_WINDOW_VALID 0x00010000 /* window is valid */ 615*0Sstevel@tonic-gate 616*0Sstevel@tonic-gate /* 617*0Sstevel@tonic-gate * window handle defines - the WINDOW_HANDLE_MASK implies the maximum number 618*0Sstevel@tonic-gate * of windows allowed 619*0Sstevel@tonic-gate */ 620*0Sstevel@tonic-gate #define WINDOW_HANDLE_MAGIC 0x574d0000 621*0Sstevel@tonic-gate #define WINDOW_HANDLE_MASK 0x0000ffff 622*0Sstevel@tonic-gate #define GET_WINDOW_NUMBER(wh) ((wh) & WINDOW_HANDLE_MASK) 623*0Sstevel@tonic-gate #define GET_WINDOW_MAGIC(wh) ((wh) & ~WINDOW_HANDLE_MASK) 624*0Sstevel@tonic-gate 625*0Sstevel@tonic-gate /* 626*0Sstevel@tonic-gate * The client type structures, used to sequence events to clients on a 627*0Sstevel@tonic-gate * socket. The "type" flags are the same as are used for the 628*0Sstevel@tonic-gate * RegisterClient function. 629*0Sstevel@tonic-gate */ 630*0Sstevel@tonic-gate typedef struct client_types_t { 631*0Sstevel@tonic-gate uint32_t type; 632*0Sstevel@tonic-gate uint32_t order; 633*0Sstevel@tonic-gate struct client_types_t *next; 634*0Sstevel@tonic-gate } client_types_t; 635*0Sstevel@tonic-gate 636*0Sstevel@tonic-gate /* 637*0Sstevel@tonic-gate * Flags that specify the order of client event notifications for the 638*0Sstevel@tonic-gate * client_types_t structure. 639*0Sstevel@tonic-gate */ 640*0Sstevel@tonic-gate #define CLIENT_EVENTS_LIFO 0x00000001 641*0Sstevel@tonic-gate #define CLIENT_EVENTS_FIFO 0x00000002 642*0Sstevel@tonic-gate 643*0Sstevel@tonic-gate /* 644*0Sstevel@tonic-gate * This is a structure that CS uses to keep track of items that are global 645*0Sstevel@tonic-gate * to all functions in the module. 646*0Sstevel@tonic-gate */ 647*0Sstevel@tonic-gate typedef struct cs_globals_t { 648*0Sstevel@tonic-gate cs_socket_t *sp; /* head of socket list */ 649*0Sstevel@tonic-gate cs_window_t *cw; /* head of window list */ 650*0Sstevel@tonic-gate kmutex_t global_lock; /* protects this struct */ 651*0Sstevel@tonic-gate kmutex_t window_lock; /* protects cs_windows */ 652*0Sstevel@tonic-gate ddi_softintr_t softint_id; /* soft interrupt handler id */ 653*0Sstevel@tonic-gate timeout_id_t sotfint_tmo; /* soft interrupt handler timeout id */ 654*0Sstevel@tonic-gate uint32_t init_state; /* flags set in cs_init */ 655*0Sstevel@tonic-gate uint32_t flags; /* general global flags */ 656*0Sstevel@tonic-gate uint32_t max_socket_num; /* highest socket number plus one */ 657*0Sstevel@tonic-gate uint32_t num_sockets; /* total number of sockets */ 658*0Sstevel@tonic-gate uint32_t num_windows; /* total number of windows */ 659*0Sstevel@tonic-gate struct sclient_list_t *sclient_list; 660*0Sstevel@tonic-gate } cs_globals_t; 661*0Sstevel@tonic-gate 662*0Sstevel@tonic-gate /* 663*0Sstevel@tonic-gate * Flags for cs_globals_t->init_state 664*0Sstevel@tonic-gate */ 665*0Sstevel@tonic-gate #define GLOBAL_INIT_STATE_SOFTINTR 0x00010000 /* softintr handler */ 666*0Sstevel@tonic-gate #define GLOBAL_INIT_STATE_MUTEX 0x00020000 /* global mutex init */ 667*0Sstevel@tonic-gate #define GLOBAL_INIT_STATE_NO_CLIENTS 0x00040000 /* no new clients */ 668*0Sstevel@tonic-gate #define GLOBAL_INIT_STATE_UNLOADING 0x00080000 /* cs_deinit running */ 669*0Sstevel@tonic-gate #define GLOBAL_INIT_STATE_SS_READY 0x00100000 /* SS ready for */ 670*0Sstevel@tonic-gate /* callbacks */ 671*0Sstevel@tonic-gate /* 672*0Sstevel@tonic-gate * Flags for cs_globals_t->flags 673*0Sstevel@tonic-gate */ 674*0Sstevel@tonic-gate #define GLOBAL_SUPER_CLIENT_REGISTERED 0x00000001 /* "super-client" reg */ 675*0Sstevel@tonic-gate #define GLOBAL_IN_SOFTINTR 0x00000002 /* in soft int code */ 676*0Sstevel@tonic-gate 677*0Sstevel@tonic-gate /* 678*0Sstevel@tonic-gate * sclient_reg_t struct for RegisterClient when a "super-client" is 679*0Sstevel@tonic-gate * registering. 680*0Sstevel@tonic-gate * This structure is actually hung off of the client_reg_t.private 681*0Sstevel@tonic-gate * structure member. Since we don't make public how to write 682*0Sstevel@tonic-gate * a "super-client", the actual structure that the client uses 683*0Sstevel@tonic-gate * is defined in this private header file. 684*0Sstevel@tonic-gate */ 685*0Sstevel@tonic-gate typedef struct sclient_reg_t { 686*0Sstevel@tonic-gate uint32_t max_socket_num; 687*0Sstevel@tonic-gate uint32_t num_sockets; 688*0Sstevel@tonic-gate uint32_t num_windows; 689*0Sstevel@tonic-gate uint32_t num_clients; 690*0Sstevel@tonic-gate struct sclient_list_t { 691*0Sstevel@tonic-gate client_handle_t client_handle; 692*0Sstevel@tonic-gate uint32_t error; 693*0Sstevel@tonic-gate } **sclient_list; 694*0Sstevel@tonic-gate } sclient_reg_t; 695*0Sstevel@tonic-gate 696*0Sstevel@tonic-gate /* 697*0Sstevel@tonic-gate * structure for event text used for cs_ss_event_text 698*0Sstevel@tonic-gate */ 699*0Sstevel@tonic-gate typedef struct cs_ss_event_text_t { 700*0Sstevel@tonic-gate event_t ss_event; /* SS event code */ 701*0Sstevel@tonic-gate event_t cs_event; /* CS event code */ 702*0Sstevel@tonic-gate char *text; 703*0Sstevel@tonic-gate } cs_ss_event_text_t; 704*0Sstevel@tonic-gate 705*0Sstevel@tonic-gate /* 706*0Sstevel@tonic-gate * Flags for cs_read_event_status 707*0Sstevel@tonic-gate */ 708*0Sstevel@tonic-gate #define CS_RES_IGNORE_NO_CARD 0x0001 /* don't check for card */ 709*0Sstevel@tonic-gate 710*0Sstevel@tonic-gate /* 711*0Sstevel@tonic-gate * cs_csfunc2text_strings_t structure used internally in Error2Text 712*0Sstevel@tonic-gate */ 713*0Sstevel@tonic-gate typedef struct cs_csfunc2text_strings_t { 714*0Sstevel@tonic-gate uint32_t item; 715*0Sstevel@tonic-gate char *text; 716*0Sstevel@tonic-gate } cs_csfunc2text_strings_t; 717*0Sstevel@tonic-gate 718*0Sstevel@tonic-gate /* 719*0Sstevel@tonic-gate * Flags for Error2Text - not used by clients; the struct is defined 720*0Sstevel@tonic-gate * in the cs.h header file. 721*0Sstevel@tonic-gate */ 722*0Sstevel@tonic-gate #define CSFUN2TEXT_FUNCTION 0x0001 /* return text of CS function code */ 723*0Sstevel@tonic-gate #define CSFUN2TEXT_RETURN 0x0002 /* return text of CS return code */ 724*0Sstevel@tonic-gate 725*0Sstevel@tonic-gate /* 726*0Sstevel@tonic-gate * Macros to walk the local linked CIS list. 727*0Sstevel@tonic-gate * 728*0Sstevel@tonic-gate * These macros can take any valid local list tuple pointer. They return 729*0Sstevel@tonic-gate * another tuple pointer or NULL if they fail. 730*0Sstevel@tonic-gate */ 731*0Sstevel@tonic-gate #define GET_NEXT_TUPLE(tp, f) CIS_PARSER(CISP_CIS_GET_LTUPLE, tp, \ 732*0Sstevel@tonic-gate NULL, GET_NEXT_LTUPLEF | \ 733*0Sstevel@tonic-gate (f & ~CIS_GET_LTUPLE_OPMASK)) 734*0Sstevel@tonic-gate #define GET_PREV_TUPLE(tp, f) CIS_PARSER(CISP_CIS_GET_LTUPLE, tp, \ 735*0Sstevel@tonic-gate NULL, GET_PREV_LTUPLEF | \ 736*0Sstevel@tonic-gate (f & ~CIS_GET_LTUPLE_OPMASK)) 737*0Sstevel@tonic-gate #define GET_FIRST_LTUPLE(tp, f) CIS_PARSER(CISP_CIS_GET_LTUPLE, tp, \ 738*0Sstevel@tonic-gate NULL, GET_FIRST_LTUPLEF | \ 739*0Sstevel@tonic-gate (f & ~CIS_GET_LTUPLE_OPMASK)) 740*0Sstevel@tonic-gate #define GET_LAST_LTUPLE(tp, f) CIS_PARSER(CISP_CIS_GET_LTUPLE, tp, \ 741*0Sstevel@tonic-gate NULL, GET_LAST_LTUPLEF | \ 742*0Sstevel@tonic-gate (f & ~CIS_GET_LTUPLE_OPMASK)) 743*0Sstevel@tonic-gate #define FIND_LTUPLE_FWD(tp, tu, f) CIS_PARSER(CISP_CIS_GET_LTUPLE, tp, \ 744*0Sstevel@tonic-gate tu, FIND_LTUPLE_FWDF | \ 745*0Sstevel@tonic-gate (f & ~CIS_GET_LTUPLE_OPMASK)) 746*0Sstevel@tonic-gate #define FIND_LTUPLE_BACK(tp, tu, f) CIS_PARSER(CISP_CIS_GET_LTUPLE, tp, \ 747*0Sstevel@tonic-gate tu, FIND_LTUPLE_BACKF | \ 748*0Sstevel@tonic-gate (f & ~CIS_GET_LTUPLE_OPMASK)) 749*0Sstevel@tonic-gate #define FIND_NEXT_LTUPLE(tp, tu, f) CIS_PARSER(CISP_CIS_GET_LTUPLE, tp, \ 750*0Sstevel@tonic-gate tu, FIND_NEXT_LTUPLEF | \ 751*0Sstevel@tonic-gate (f & ~CIS_GET_LTUPLE_OPMASK)) 752*0Sstevel@tonic-gate #define FIND_PREV_LTUPLE(tp, tu, f) CIS_PARSER(CISP_CIS_GET_LTUPLE, tp, \ 753*0Sstevel@tonic-gate tu, FIND_PREV_LTUPLEF | \ 754*0Sstevel@tonic-gate (f & ~CIS_GET_LTUPLE_OPMASK)) 755*0Sstevel@tonic-gate #define FIND_FIRST_LTUPLE(tp, tu, f) FIND_LTUPLE_FWD(GET_FIRST_LTUPLE(tp, \ 756*0Sstevel@tonic-gate f), tu, f) 757*0Sstevel@tonic-gate 758*0Sstevel@tonic-gate 759*0Sstevel@tonic-gate /* 760*0Sstevel@tonic-gate * Card Services hooks and general nexus prototypes 761*0Sstevel@tonic-gate */ 762*0Sstevel@tonic-gate int cs_init(void); 763*0Sstevel@tonic-gate uint32_t cs_event(event_t, uint32_t, uint32_t); 764*0Sstevel@tonic-gate int pcmcia_set_em_handler(int (*handler)(), caddr_t events, 765*0Sstevel@tonic-gate int elen, uint32_t id, void **cs, void **ss); 766*0Sstevel@tonic-gate 767*0Sstevel@tonic-gate extern csfunction_t *cs_socket_services; 768*0Sstevel@tonic-gate 769*0Sstevel@tonic-gate 770*0Sstevel@tonic-gate #ifdef __cplusplus 771*0Sstevel@tonic-gate } 772*0Sstevel@tonic-gate #endif 773*0Sstevel@tonic-gate 774*0Sstevel@tonic-gate #endif /* _CS_PRIV_H */ 775