09 PCMCIA Compact Flash GPRS GPS PCMCIA Personal Computer Memory Card International Association CF Compact Flash PCMCIA CF PCMCIA/CF PCMCIA WiFi Linux PCMCIA PCMCIA/CF 9-1 PCMCIA/CF PCMCIA 16 CF PCMCIA PCMCIA PDA CF 50 CF-to-PCMCIA 68 PCMCIA PCMCIA CF PCMCIA 32 CardBus PC PCMCIA CardBus CardBus PCI CardBus PCMCIA PCI PCMCIA ExpressCard PCI Express PCI PCI CardBus ExpressCard PC Type I 3.3mm Type II 5mm Type III.5mm 260
Linux PCMCIA PCMCIA PCMCIA PCMCIA PCI PCMCIA PCMCIA I/O PCMCIA 09-1 Processor North Bridge PCMCIA/ CardBus Controller South Bridge PCI Bus PCI Slot Socket PCI Slot PCMCIA Card 9.1 PCMCIA 9.1 PCMCIA 9.2 Embedded Controller CPU Core PCMCIA Controller Internal Local Bus LCD Controller PCMCIA/CF Socket PCMCIA Card 9.2 PCMCIA 261
09 9-2 Linux-PCMCIA Linux PCMCIA ARM MIPS PowerPC PCMCIA PCMCIA daemon Card Services 9.3 Linux-PCMCIA pcmciautils XX-Applications User Space Kernel Space PCMCIA Core CIS Routines Card Services sysfs/udev Interface pccardd Driver Services (ds) XX-Dependent Layers PCMCIA Compact Flash Kernel Space Hardware Host Controller Driver XX_cs CIS Space IRQ, I/O Mem Data XX PCMCIA/CardBus Host Controller Bridge PCMCIA Socket PCMCIA Card XX 9.3 Linux PCMCIA 262
Linux Linux-PCMCIA Linux-PCMCIA PCMCIA kernel 2.6. pcmciautils http://kernel.org/pub/linux/utils/kernel/pcmcia/howto. html pcmcia-cs http://pcmcia-cs.sourceforge.net user space cardmgr PCMCIA udev cardmgr http://kernel.org/pub/linux/utils/kernel/pcmcia/cardmgr-to-pcmciautils.html 9.3 PCMCIA PCMCIA socket PCMCIA 9.3 XX_cs Linux PCMCIA XX_cs PCMCIA 9.3 XX 9.3 PCMCIA IDE XX IDE XX_cs ide_cs XX XX XX_cs IRQ I/O XX PCMCIA XScale x86 CF driver services, ds 09-2 Linux-PCMCIA Tip 263
09 Pcmciautils pccardctl PCMCIA card-configuration 9.4 9.1 Linux PCMCIA PC Higher Layers/Applications PCMCIA Core Processor Host Controller Driver XX.ko Interrupts that monitor card status Device Interrupts Resources North Bridge South Bridge PCMCIA/ CardBus Controller PCI Bus PCI Slot Socket PCI Slot PCMCIA Card XX XX_cs.ko 9.4 PCMCIA PC PCMCIA Compact Flash Linux PCMCIA 9-7 PCMCIA WiFi 9-3 XX card function PCMCIA 264
Linux PCMCIA GPIO StrongARM drivers/pcmcia/sa10_assabet.c 9-4 PCMCIA PCMCIA PCMCIA pccardd PCMCIA pccardd Device Services PCMCIA Card Information Structure CIS CIS PCMCIA PCMCIA/CF attribute common CIS PCMCIA IDE CIS sector cylinder array PCMCIA pccard_get_first_tuple() pccard_get_next_tuple() pccard_parse_tuple() CIS 9.2 09-4 PCMCIA 9.2 PCMCIA PCMCIA sysfs udev CIS user space pccardctl pcmciautils sysfs udev sysfs udev 265
09 9-5 Driver Services pccardd PCMCIA CIS core Driver Services pcmcia_bus_type PCMCIA pcmcia_register_ driver() 9.1 9-6 client device driver 9.3 XX_cs PCMCIA CIS PCMCIA PCMCIA Compact Flash 9-6-1 PCMCIA 1. PCMCIA pcmcia_device_id include/ linux/mod_devicetable.h struct pcmcia_device_id { u16 manf_id; /* Manufacturer ID */ u16 card_id; /* Card ID */ u8 func_id; /* Function ID */ }; 266
Linux PCMCIA PCMCIA_DEVICE_MANF_CARD() ID pcmcia_device_id MODULE_DEVICE_ TABLE() module image pcmcia_device_ids PCMCIA CIS ID 4 I/O PCI USB 9.1 PCI USB PCMCIA PCI USB ID pcmcia_device_id pci_device_id usb_device_id ID PCMCIA_DEVICE_ PCI_DEVICE() USB_DEVICE() MANF_CARD() struct pcmcia_ struct pci_dev struct usb_device device struct pcmcia_driver struct pci_driver struct usb_driver probe() remove() probe() remove() probe() disconnect() pccardd kthread PCI-familydependent khubd kthread 9.1 PCMCIA PCI USB ID 09-6 manf_id card_id func_id PCMCIA ID ID ID 2. PCMCIA probe() remove() pcmcia_ device_id pcmcia_driver struct pcmcia_driver { int (*probe)(struct pcmcia_device *dev); /* Probe method */ void (*remove)(struct pcmcia_device *dev); /* Remove method */ struct pcmcia_device_id *id_table; /* Device ID table */ }; 267
09 3. pcmcia_device PCMCIA drivers/pcmcia/ds.h struct pcmcia_device { io_req_t io; /* I/O attributes*/ irq_req_t irq; /* IRQ settings */ config_req_t conf; /* Configuration */ struct device dev; /* Connection to device model */ }; 4. CIS tuple_t include/pcmcia/cistpl.h CIS CISTPL_LONGLINK_MFC tuple include/pcmcia/cistpl.h http:// pcmcia-cs.sourceforge.net/ftp/doc/pcmcia-prog.html typedef struct tuple_t { cisdata_t TupleCode; /* See include/pcmcia/cistpl.h */ cisdata_t DesiredTuple; /* Identity of the desired tuple */ cisdata_t *TupleData; /* Buffer space */ }; PCMCIA Compact Flash 5. CIS configuration include/pcmcia/cistpl.h cistpl_cftable_entry_t typedef struct cistpl_cftable_entry_t { cistpl_power_t vcc, vpp1, vpp2; /* Voltage level */ cistpl_io_t io; /* I/O attributes */ cistpl_irq_t irq; /* IRQ settings */ cistpl_mem_t mem; /* Memory window */ }; 6. cisparse_t include/pcmcia/cistpl.h PCMCIA 268
Linux cistpl_manfid_t manfid; /* Manf ID */ cistpl_cftable_entry_t cftable_entry; /* Configuration table entry */ } cisparse_t; 9-6-2 PCMCIA PCMCIA PCMCIA XX XX_cs PCMCIA probe() remove() 9.1 PCMCIA probe() remove() pcmcia_device_ id PCMCIA XX_probe() XX_remove() 9.1 #include <pcmcia/ds.h> /* Definition of struct pcmcia_device */ static struct pcmcia_driver XX_cs_driver = {.owner = THIS_MODULE,.drv = {.name = "XX_cs", /* Name */ },.probe = XX_probe, /* Probe */.remove = XX_remove, /* Release */.id_table = XX_ids, /* ID table */.suspend = XX_suspend, /* Power management */.resume = XX_resume, /* Power management */ }; 09-6 union cisparse_t { typedef #define XX_MANFUFACTURER_ID 0xABCD /* Device's manf_id */ #define XX_CARD_ID 0xCDEF /* Device's card_id */ 269
09 PCMCIA Compact Flash /* Identity of supported cards */ static struct pcmcia_device_id XX_ids[] = { PCMCIA_DEVICE_MANF_CARD(XX_MANFUFACTURER_ID, XX_CARD_ID), PCMCIA_DEVICE_NULL, }; MODULE_DEVICE_TABLE(pcmcia, XX_ids); /* For module autoload */ /* Initialization */ static int init init_xx_cs(void) { return pcmcia_register_driver(&xx_cs_driver); } /* Probe Method */ static int XX_probe(struct pcmcia_device *link) { /* Populate the pcmcia_device structure allotted for this card by the core. First fill in general information */ /* Fill in attributes related to I/O windows and interrupt levels */ XX_config(link); /* See Listing 9.2 */ } 9.2 I/O XX PCMCIA XX PCMCIA XX 9.2 drivers/net/wireless/airo_cs.c Cisco Aironet 4500 4800 PCMCIA WiFi PCMCIA PCMCIA CIS PCMCIA I/O 270
Linux 9.2 #include <pcmcia/cistpl.h> #include <pcmcia/ds.h> #include <pcmcia/cs.h> #include <pcmcia/cisreg.h> /* This makes the XX device available to the system. XX_config() is based on airo_config(), defined in drivers/net/wireless/airo_cs.c */ static int XX_config(struct pcmcia_device *link) { tuple_t tuple; cisparse_t parse; u_char buf[64]; /* Populate a tuple_t structure with the identity of the desired tuple. In this case, we're looking for a configuration table entry */ tuple.desiredtuple = CISTPL_CFTABLE_ENTRY; tuple.attributes = 0; tuple.tupledata = buf; tuple.tupledatamax = sizeof(buf); /* Walk the CIS for a matching tuple and glean card configuration information such as I/O window base addresses */ /* Get first tuple */ CS_CHECK(GetFirstTuple, pcmcia_get_first_tuple(link, &tuple)); while (1){ cistpl_cftable_entry_t dflt = {0}; cistpl_cftable_entry_t *cfg = &(parse.cftable_entry); 09-6 XX /* Read a configuration tuple from the card's CIS space */ if (pcmcia_get_tuple_data(link, &tuple)!= 0 pcmcia_parse_tuple(link, &tuple, &parse)!= 0) { goto next_entry; } /* We have a matching tuple! */ /* Configure power settings in the pcmcia_device based on what was found in the parsed tuple entry */ 271
09 PCMCIA Compact Flash if (cfg->vpp1.present & (1<<CISTPL_POWER_VNOM)) link->conf.vpp = cfg->vpp1.param[cistpl_power_vnom]/000; /* Configure I/O window settings in the pcmcia_device based on what was found in the parsed tuple entry */ if ((cfg->io.nwin > 0) (dflt.io.nwin > 0)) { cistpl_io_t *io = (cfg->io.nwin)? &cfg->io : &dflt.io; if (!(io->flags & CISTPL_IO_8BIT)) { link->io.attributes1 = IO_DATA_PATH_WIDTH_16; } link->io.baseport1 = io->win[0].base; } break; next_entry: CS_CHECK(GetNextTuple, pcmcia_get_next_tuple(link, &tuple); } /* Allocate IRQ */ if (link->conf.attributes & CONF_ENABLE_IRQ) { CS_CHECK(RequestIRQ, pcmcia_request_irq(link, &link->irq)); } /* Invoke init_xx_card(), which is part of the generic XX driver (so, not shown in this listing), and pass the I/O base and IRQ information obtained above */ init_xx_card(link->irq.assignedirq, link->io.baseport1, 1, &handle_to_dev(link)); /* The chip-specific (form factor independent) driver is ready to take responsibility of this card from now on! */ } 272
Linux 9.3 PCMCIA PCMCIA PCMCIA Cisco Aironet PCMCIA 82365 PCMCIA 1. PCMCIA drivers/pcmcia/yenta_socket.c 2. Pccardd PCMCIACard Services drivers/pcmcia/cs.c 1 3. Card Services Driver Services drivers/pcmcia/ds.c Driver Services 4. Driver Services CIS ID ID drivers/net/ wireless/airo_cs.c MODULE_DEVICE_TABLE() 5. 9.1 4 airo_cs.c pcmcia_ register_driver() pcmcia_bus_type PCMCIA probe() remove() Driver Services ds.c 6. 5 Driver Services probe() 5 probe() airo_probe() probe() I/O drivers/net/wireless/airo.c 9.2 7. airo.c ethx PCMCIA PCI ethx 09-7 9-7 273
09 9-8 PCMCIA PCMCIA/CF storage GB IDE Micro drive IDE spin-up IDECard Services ide_cs IDE IDE memory card flash memory IDE IDECard Services ide_cs flash memory IDE memory_cscard Services memory_cs PCMCIA PCMCIA Compact Flash 9-9 PCMCIA GPRS GSM GPS PCMCIA PCMCIA/CF GPRS GSM 16 Linux serial_cs PCMCIA/CF /dev/ttysx PCMCIA serial_cs GPRS GSM GPS PCMCIA/ CF HCI Host Control Interface 274
Linux 9.5 serial_cs Phone Dialers, Networking Apps (WEP Browsing..) 09-9 User Space Bluetooth Networking GPRS/GSM Setup GPS Applications Kernel Space BlueZ Bluetooth Stack PPP Stack HCI Line Discipline PPP Line Discipline PCMCIA Core Bluetooth GPRS/GSM GPS Serial Driver IRQ, I/O Windows serial_cs Kernel Space Hardware CIS Space PCMCIA/CardBus Host Controller Bridge PCMCIA PCMCIA Socket Serial PCMCIA Card 9.5 PCMCIA/CF PPP Point-to-Point Protocol TCP/IP link 9.5 PPP TCP/IP GPRS GSM PPP pppd serial_cs pppd PPP ppp_generic ppp_async slhc pppd bash> pppd ttysx call connection-script 275
09 connection-script pppd connection-script GPRS connection-script GSM 16-4-1 GPRS connection-script 9- PCMCIA/CF PCMCIA CONFIG_PCMCIA_DEBUG Bus options PCCARD support Enable PCCARD debugging pcmcia_core.pc_debug pc_debug PC /proc/bus/pccard/drivers /sys/ bus/pcmcia/devices/* ID PCI-to-PCMCIA /proc/bus/pci/ PCMCIA /proc/interrupts IRQ PCMCIA PCMCIA Compact Flash Linux-PCMCIA http://lists.infradead.org/mailman/listinfo/linux-pcmcia 9- Linux drivers/pcmcia/ drivers/pcmcia/yenta_socket.c x86 include/pcmcia/ PCMCIA 276
PCMCIA Compact Flash
Linux drivers/net/pcmcia/ PCMCIA IDE PCMCIA drivers/ide/legacy/ ide-cs.c PCMCIA drivers/serial/serial_cs.c 9.2 9.3 pcmcia_device_id i n c l u d e / l i n u x / m o d _ PCMCIA devicetable.h pcmcia_device include/pcmcia/ds.h PCMCIA pcmcia_driver include/pcmcia/ds.h PCMCIA tuple_t include/pcmcia/cistpl.h CIS tuple_t cistpl_cftable_entry_t include/pcmcia/cistpl.h CIS cisparse_t include/pcmcia/cistpl.h 9.2 09- pcmcia_register_driver() drivers/pcmcia/ds.c PCMCIA pcmcia_unregister_driver() drivers/pcmcia/ds.c PCMCIA pcmcia_get_first_tuple() pcmcia_get_tuple_data() pcmcia_parse_tuple() pcmcia_request_irq() include/pcmcia/cistpl.h drivers/pcmcia/cistpl.c drivers/pcmcia/pcmcia_ resource.c CIS PCMCIA IRQ 9.3 277