Writing PCMCIA Device Drivers
只搜尋這本書
以 PDF 格式下載這本書

PCMCIA System Architecture

2

This chapter discusses the Solaris implementation of the PCMCIA system architecture. It describes the PCMCIA system framework and the relationship of the major components of the architecture.

Solaris PCMCIA System Architecture

The Solaris PCMCIA system architecture includes PC Card drivers, Solaris Card Services, PCMCIA bus adapter drivers, and a user events daemon. Solaris PCMCIA supports PC Card hardware, such as PC Card devices, and PCMCIA bus adapter hardware, which includes sockets and controllers.
Figure 2-1 illustrates the relationship among the components in the Solaris PCMCIA architecture. This architecture is described in more detail in the sections that follow.

PC Card Driver

A PC Card driver provides all the normal services associated with device drivers, such as standard open, close, read, and write entry points. In addition to its normal driver responsibilities, a PC Card driver calls the Card Services interface, which provides PCMCIA-specific functionality.

圖形

Figure 2-1

Because the PCMCIA framework provides interfaces that allow the PC Card driver to interact directly with Card Services, the PC Card driver is responsible for two important functions:
  • Configuring the PC Card - Through Card Services and the Card Information Structure, the PC Card driver determines an appropriate configuration for the PC Card.
  • Handling PC Card events - The PC Card driver responds to events such as card insertion and removal.
For a complete example of a PC Card driver, see Chapter 9, "PCMCIA Parallel Port Driver."

Card Services

Card Services provides operating system services to PC Card drivers, such as:
  • Resource management
  • Event notification
  • Card identification and configuration
  • Access to the Card Information Structure (CIS)
Card Services also manages access to PC Card hardware and system resources by multiple clients. Architecturally, Card Services is the layer between PC Card drivers and PCMCIA bus nexus adapter drivers, which interface directly with the operating system. For more information on Card Services, see Chapter 3, "Solaris Card Services".

PCMCIA Bus Nexus Adapter Drivers and Socket Services

PCMCIA adapters provide the physical slots or sockets for the PC Card(s) and a hardware interface between the PCMCIA bus and the system bus. The PC Card Standard specifies a standard interface to the adapter hardware called Socket Services. The Socket Services API is a hardware-independent interface between Card Services and the software layer that controls a particular adapter.
The PCMCIA Socket Services layer corresponds to a nexus driver in the Solaris architecture. In the Solaris system, bus nexus adapter drivers control all access to the hardware, with a separate nexus driver required for each different type of adapter hardware. Each PCMCIA bus nexus adapter driver is implemented as a private interface that encapsulates much of the standard PCMCIA Socket Services functionality. Functions similar to Socket Services are implemented as hardware-specific calls for each adapter supported by the platform.
Depending on the PCMCIA adapters on the platform, one or more of the bus nexus adapter drivers manage the interface between adapter hardware and (through Card Services) the PC Card drivers. This insulates the PC Card drivers from the specifics of the PCMCIA bus adapter hardware.
PCMCIA bus nexus adapter drivers are provided with the Solaris system, are platform dependent, and are configured in a manner that reflects the hardware configuration within the platform. Different bus nexus adapter drivers are available for different platforms supporting PC Cards, such as SPARC and x86.

Note - Although Card Services communicates to bus nexus adapter drivers through the PC Card Standard Socket Services interfaces, these interfaces are not exported to PC Card drivers or to any other system component.

Bus Nexus Adapter Driver Functionality

PCMCIA bus nexus adapter drivers support the following functions:
  • Status interrupt generation
  • Socket status reporting
  • PC Card interrupt handling
  • Memory and I/O mapping
In addition, the Solaris PCMCIA bus nexus adapter driver must:
  • Identify cards in sockets
  • Create device nodes if necessary
  • Provide an interface to the PCMCIA event management driver
The encapsulation of these functions by the bus nexus adapter driver makes it possible to implement all of Card Services and much of the remainder of the PCMCIA framework in an architecture-neutral way. Only the bus nexus adapter drivers need be different on different adapter hardware.
This encapsulation has the added benefit of allowing driver writers to concentrate on a relatively small number of standard function calls and data structures. The major benefits include a significant decrease in the overhead costs of driver development and an increase in portability of drivers.
The bus nexus adapter drivers provide the core framework functionality and perform PCMCIA functions at the request of the PC Card driver. For example, when the PC Card driver requests hardware services on behalf of its device hardware (such as requesting an IRQ), it calls Card Services, which in turn calls the bus nexus driver adapter driver interface to perform the operation.

Event Status Changes and Interrupts

During configuration, the bus nexus adapter driver is programmed by the PC Card driver (through Card Services) to recognize addresses that reside on the PC Card and map them into system memory. Subsequently, when a card insertion or removal event occurs, the bus nexus adapter driver detects the event and relays information by generating socket status change interrupts, which are sent by the adapter driver to Card Services.
Card Services then calls back the adapter driver to determine the type and source of the interrupt. After this has been determined, Card Services relays the information to the PC Card driver. The PC Card driver uses Card Services to instruct the bus nexus adapter driver on the appropriate action to take to service the interrupt. This process is illustrated in Figure 2-2.

圖形

Figure 2-2

PCMCIA Event Management (User) Daemon

The PCMCIA Event Management user daemon (pcmciad) is a system component that provides communication between the kernel and other user-level system components. It provides user-level hot plugging and volume management support for PC Cards. In addition, it provides services to the Solaris operating system to manage the device tree for all PC Cards in the system.
More specifically, the pcmciad Event Management daemon performs the following functions:
  • Handles PCMCIA framework and card events. For example, it loads and attaches a PC Card driver on card insertion.
  • Causes /devices entries to be created.
  • When a PC Card driver creates a minor node, the daemon creates /dev links by invoking the standard link generator commands such as the disks(1M) and devlinks(1M) commands.