Figure 1 shows the PCMCIA PC card architecture.
To include the PC card device drivers in your configuration, define the macro INCLUDE_PCMCIA in config.h. When INCLUDE_PCMCIA is defined, pccardLib.c and pccardShow.c are included in sysLib.c. If INCLUDE_SHOW_ROUTINES is defined in config.h, the show routine for the PC card is included in pccardShow.c.
The PC card device driver consists of three components in addition to a standard VxWorks device driver: a resource table, an enabler, and a Card Status Change (CSC) interrupt handler.
The PC card device driver has its own resource structure. For the SRAM card the structure is called sramResource and for the Ethernet card it is eltResource; this structure resides in pccardLib.c. For the ATA card, the structure is called ataResource and is located in sysLib.c (see the VxWorks Programmer's Guide: Intel x86). For example, the resource table for an SRAM card, sramResources[ ] in pccardLib.c, is as follows:
typedef struct sramResource /* PCCARD SRAM resources */ { PCCARD_RESOURCE resource; /* must be the first member */ } SRAM_RESOURCE;
The first member of each entry in the PC card's resource table is a common resource structure for all PC cards, which is called PCCARD_RESOURCE. Resources such as memory addresses, I/O addresses, and IRQ are defined here. This structure is defined as follows:
typedef struct pccardResource { int vcc; /* 3, 5: Vcc */ int vpp; /* 5, 12: Vpp */ int ioStart[2]; /* start IO address */ int ioStop[2]; /* stop IO address */ int ioExtraws; /* 0-2: extra wait state */ int memStart; /* start host address */ int memStop; /* stop host address */ int memExtraws; /* 0-2: extra wait state */ int memOffset; /* offset card address */ int memLength; /* size of the memory */ } PCCARD_RESOURCE;
The enabler initializes the PC card. The enabler routine is in the enabler table, pcccardEnabler[ ]. The enabler checks the Card Information Structure (CIS) to determine what type of PC card is installed. If it finds a match, it allocates the resources defined for that card resource structure and initializes the card. If the card is a block device (an ATA, SRAM, or Flash PC card), it completes all initialization including creation of the block device. If the card is a network device (an Ethernet PC card), the enabler stores the parameters the eltattach( ) routine requires for completing initialization.
The CSC interrupt handler (supplied by the specific device driver) is called by pcmciaCscIntr( ) when a CSC event occurs. CSC events are hot insertion/removal, battery dead, battery warn, write protect, and ready. The CSC interrupt routine manages the resources allocated to the socket. If the CSC interrupt handler returns an error, pcmciaCscIntr( ) goes to the next socket without releasing the resources.