/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#ifndef _CS_PRIV_H
#define _CS_PRIV_H
#pragma ident "%Z%%M% %I% %E% SMI"
#ifdef __cplusplus
extern "C" {
#endif
/*
* PCMCIA Card Services private header file
*/
/*
* typedef for function pointers to quiet lint and cc -v
*/
/*
* Magic number we use when talking with Socket Services
*/
/*
* Make the calls to SocketServices and the CIS Parser look like
* function calls.
*/
/*
* CIS_DEFAULT_SPEED is the default speed to use to read the CIS
* in AM space. It is expressed in nS.
*/
/*
* This is the IO window speed.
*/
/*
* these must be within CIS_GET_LTUPLE_OPMASK which is defined
* in the cis.h file. Values outside this mask range are used
* internally by the CIS parser.
*/
/*
* Macros to manipulate bits - only does up to uint32_t size
*/
/*
* Minimum time to wait after socket reset before we are allowed to
* access the card. The PCMCIA specification says at least 20mS
* must elapse from the time that the card is reset until the
* first access of any kind can be made to the card. This time
* value is expressed in mS.
*/
/*
* Maximum time to wait for card ready after resetting the socket.
* We wait for card ready a maximum of 20 seconds after card
* reset before considering that we have an error condition.
* XXX - what does PCMCIA specify as the max time here??
*/
/*
* Time between periodically kicking the soft interrupt handler.
*/
/*
* Various delays are necessary when switching the card and socket
* between IO and memory modes. All delays are in mS.
*
* cs_request_configuration parameters:
* CS_RC1_DELAY - delay between writing COR and switching socket
* to IO mode
* CS_RC2_DELAY - delay after switching socket to IO mode
*
* cs_release_configuration parameters:
* CS_RQ_DELAY - amount of time that the RESET bit in the COR is
* held asserted
*/
/*
* Handy macro to do untimeout.
*/
if ((id)) { \
(id) = 0; \
}
/*
*/
if (acq) \
if (acq) \
/*
* cisregister_t structure is used to support the CISRegister
* and the CISUnregister function calls
*/
typedef struct cisregister_t {
/*
* These two defines are to support CISRegister and CISUnregister
*/
/*
* CS_MAX_CIS defines the number of CIS chains that we hang off the per-socket
* structure.
*
* CS_GLOBAL_CIS defines the index where the CIS parser puts the first CIS list
* for a single-function card or the global CIS list for a multi-function
* card.
*
* CS_MAX_CIS is one greater than CIS_MAX_FUNCTIONS since the CIS parser
* puts the global CIS chain on the CS_GLOBAL_CIS function index as
* follows:
*
* For single-function cards:
* sp->cis[0] - CIS chain
* sp->cis[1..(CIS_MAX_FUNCTIONS - 1)] - not used
* sp->cis[CS_GLOBAL_CIS] - not used
*
* For multi-function cards:
* sp->cis[0..(CIS_MAX_FUNCTIONS - 1)] - global CIS chain followed
* by per-function CIS chain
* sp->cis[CS_GLOBAL_CIS] - global CIS chain
*/
/*
* CS_SS_CLIENT_HANDLE is a special client handle that Socket Services gets
* when it registers with RegisterClient.
*/
/*
* Client handle, socket number, function number and socket pointer
* macros. The client handle encoding is private to Card Services,
* and external modules should not use these macros to manipulate
* client handles.
*
* The encoding of the client handle is:
*
* xxxxxfff | xsssssss | cccccccc | cccccccc
*
* f - function number bit
* s - socket number bit
* c - client number bit
* x - don't care bits
*/
(((s)&CS_MAX_SOCKETS_MASK)<<16) | \
((c)&CS_MAX_CLIENTS_MASK))
/*
* Socket number macros. These are used by Socket Services, CSI
* drivers and the "super-client" driver to specify which
* socket and function number on that socket they wish to
* manipulate. This socket number encoding is typically passed
* to various Card Services functions by these drivers.
*
* The encoding of the socket number is:
*
* xxxxxxxx | xxxxgfff | xxxxxxxx | xsssssss
*
* g - global CIS bit
* f - function number bit
* s - socket number bit
* x - don't care bits
*/
CIS_MAX_FUNCTIONS))<<16)
/*
* DIP2SOCKET_NUM(dip) - this macro gets the PCM_DEV_SOCKET property from
* the passed dip. If the property can't be found, then the default
* value of cs_globals.max_socket_num is returned.
*/
(DDI_PROP_CANSLEEP | \
DDI_PROP_NOTPROM), \
/*
* Range checking macros
*
* CHECK_SOCKET_NUM(socket_number, max_sockets) returns 1 if
* socket_number is in range
*/
/*
* window macros
*
* These all expect that the window has been validated as a valid
* window (i.e. CW_WINDOW_VALID is set in window state)
*
* Note that WINDOW_FOR_SOCKET expects a socket mask for the wsm
* parameter (this is a socket_enum_t type, and NOT just a
* plain old uint32_t)
*/
/*
* IO Base and NumPorts address frobnitz macros
*/
/*
* Structure that contains offsets to the card's configuration registers
* as well as copies of the data written to them in RequestConfiguration.
* We use an offset per register approach since not all cards have
* all registers implemented, and by specifying a NULL register offset,
* we know not to try to access that register.
*/
typedef struct config_regs_t {
/*
* Macro to make calling the client's event handler look like a function.
*/
&(cp)->event_callback_args)
/*
* Macro to return event in PRR - this also clears the changed bit if
* the event occured.
*/
}
/*
* io_alloc_t struct used to keep track of a client's IO window allocation
*/
typedef struct io_alloc_t {
} io_alloc_t;
/*
* irq_alloc_t structure used to keep track of a client's IRQ allocation
*/
typedef struct irq_alloc_t {
void *irq_handler_arg1;
void *irq_handler_arg2;
} irq_alloc_t;
/*
* The client data structure
*/
typedef struct client_t {
/* resource control */
/* event support */
/* config registers support */
/* DDI support */
/* list control */
} client_t;
/*
* Flags for client structure - note that we share the client_t->flags
* member with the definitions in cs.h that are used by the
* RegisterClient function.
*
* We can start our flags from 0x00001000 and on up.
*/
#ifdef USE_IOMMAP_WINDOW
/*
* io_mmap_window_t structure that describes the memory-mapped IO
* window on this socket
*/
typedef struct io_mmap_window_t {
#endif /* USE_IOMMAP_WINDOW */
/*
* cis_info_t structure used to hold per-socket CIS information
*/
typedef struct cis_info_t {
} cis_info_t;
/*
* cs_adapter_t structure used to hold per-socket
* adapter-specific info
*/
typedef struct cs_adapter_t {
} cs_adapter_t;
/*
* The per-socket structure.
*/
typedef struct cs_socket_t {
/* socket thread control and status */
/* client management */
/* CIS support */
#ifdef USE_IOMMAP_WINDOW
/* memory mapped IO window support */
#endif /* USE_IOMMAP_WINDOW */
/* Socket Services work thread control and status */
} cs_socket_t;
/*
* cs_socket_t->flags flags
*/
/*
* cs_socket_t->thread_state and cs_socket_t->ss_thread_state flags
*/
/* generic for all threads */
/* only used for per-socket event thread */
/* only used for Socket Services work thread */
/*
* cs_socket_t->cis_flags and cs_socket_t->cis_info_t->flags flags
*/
/* chain tuples */
/*
* CW_LONGLINK_FOUND - a combination of the various CW_LONGLINK_XXX_FOUND
* flags used to make the code less dense.
*/
/*
* macro to test for a valid CIS window on a socket
*/
/*
* cs_socket_t->init_state flags - these flags are used to keep track of what
* was allocated in cs_init so that things can be deallocated properly
* in cs_deinit.
*/
/*
* While this next flag doesn't really describe a per-socket resource,
* we still set it for each socket. When the soft interrupt handler
* finally gets removed in cs_deinit, this flag will get cleared.
* The value of this flag should follow the previous SOCKET_INIT
* flag values.
*/
/*
* Macro to create a socket event thread.
*/
/*
* The per-window structure.
*/
typedef struct cs_window_t {
} cs_window_t;
/*
* Window structure state flags - if none of the bits in the
* CW_WIN_IN_USE mask are set AND if CW_WINDOW_VALID is set,
* it means that this window is available and not being used
* by anyone.
* Setting the CW_ALLOCATED will prevent the window from being found
* as an available window for memory or IO; since memory windows
* are not shared between clients, RequestWindow will always set
* the CW_ALLOCATED flag when it has assigned a memory window to
* a client. Since we can sometimes share IO windows, RequestIO
* will only set the CW_ALLOCATED flag if it doesn't want the IO
* window to be used by other calls to RequestIO.
* When CW_WINDOW_VALID is set, it means that this is a valid window
* that has been added by the framework and can be used. If this
* bit is not set, this window can not be used at all.
*/
/*
* window handle defines - the WINDOW_HANDLE_MASK implies the maximum number
* of windows allowed
*/
/*
* The client type structures, used to sequence events to clients on a
* socket. The "type" flags are the same as are used for the
* RegisterClient function.
*/
typedef struct client_types_t {
/*
* Flags that specify the order of client event notifications for the
* client_types_t structure.
*/
/*
* This is a structure that CS uses to keep track of items that are global
* to all functions in the module.
*/
typedef struct cs_globals_t {
} cs_globals_t;
/*
* Flags for cs_globals_t->init_state
*/
/* callbacks */
/*
* Flags for cs_globals_t->flags
*/
/*
* sclient_reg_t struct for RegisterClient when a "super-client" is
* registering.
* This structure is actually hung off of the client_reg_t.private
* structure member. Since we don't make public how to write
* a "super-client", the actual structure that the client uses
* is defined in this private header file.
*/
typedef struct sclient_reg_t {
struct sclient_list_t {
} **sclient_list;
/*
* structure for event text used for cs_ss_event_text
*/
typedef struct cs_ss_event_text_t {
char *text;
/*
* Flags for cs_read_event_status
*/
/*
* cs_csfunc2text_strings_t structure used internally in Error2Text
*/
typedef struct cs_csfunc2text_strings_t {
char *text;
/*
* Flags for Error2Text - not used by clients; the struct is defined
* in the cs.h header file.
*/
/*
* Macros to walk the local linked CIS list.
*
* These macros can take any valid local list tuple pointer. They return
* another tuple pointer or NULL if they fail.
*/
NULL, GET_NEXT_LTUPLEF | \
(f & ~CIS_GET_LTUPLE_OPMASK))
NULL, GET_PREV_LTUPLEF | \
(f & ~CIS_GET_LTUPLE_OPMASK))
NULL, GET_FIRST_LTUPLEF | \
(f & ~CIS_GET_LTUPLE_OPMASK))
NULL, GET_LAST_LTUPLEF | \
(f & ~CIS_GET_LTUPLE_OPMASK))
tu, FIND_LTUPLE_FWDF | \
(f & ~CIS_GET_LTUPLE_OPMASK))
tu, FIND_LTUPLE_BACKF | \
(f & ~CIS_GET_LTUPLE_OPMASK))
tu, FIND_NEXT_LTUPLEF | \
(f & ~CIS_GET_LTUPLE_OPMASK))
tu, FIND_PREV_LTUPLEF | \
(f & ~CIS_GET_LTUPLE_OPMASK))
f), tu, f)
/*
* Card Services hooks and general nexus prototypes
*/
int cs_init(void);
extern csfunction_t *cs_socket_services;
#ifdef __cplusplus
}
#endif
#endif /* _CS_PRIV_H */