LECTURE 11 PCI ¥Ç¥Ð¥¤¥¹¤Î¾ðÊó¤ò¼èÆÀ¤¹¤ë

¡û ¤Ï¤¸¤á¤Ë

º£¤Î PC ¤Ë¤Ï¡¢PCI ¥«¡¼¥É¤È¤¤¤¦·Á¤ÇÍÍ¡¹¤Ê¥Ç¥Ð¥¤¥¹ ( ¥Í¥Ã¥È¥ï¡¼¥¯¥«¡¼¥É¤ä¥°¥é¥Õ¥£¥Ã¥¯¥«¡¼¥É¡¢¥µ¥¦¥ó¥É¥«¡¼¥ÉÅù ) ¤¬Àܳ¤µ¤ì¤Æ¤¤¤Þ¤¹¡£¥·¥ê¥¢¥ë¥Ý¡¼¥È¤ä¥Ñ¥é¥ì¥ë¥Ý¡¼¥È¤òÅëºÜ¤·¤¿ PC ¤¬¤É¤ó¤É¤ó¸º¤Ã¤ÆÍè¤ë¤È¡¢ USB ¤ä PCI ¤Î¥Ç¥Ð¥¤¥¹¤òÀ©¸æ¤·¤¿¤¤¤³¤È¤¬Áý¤¨¤ÆÍè¤ë¤È»×¤¤¤Þ¤¹¡£

PCI ¤Î¥Ç¥Ð¥¤¥¹¤òÀ©¸æ¤¹¤ë¾ì¹ç¤â¡¢I/O ¥¢¥É¥ì¥¹¤È³ä¤ê¹þ¤ßÈֹ椬ʬ¤«¤ì¤Ð¡¢¸å¤Ï¤É¤³¤Ë¤É¤ó¤ÊÃͤò½ñ¤­¹þ¤á¤Ð¤¤¤¤¤Î¤«¥Þ¥Ë¥å¥¢¥ë¤ò¸«¤ì¤ÐÀ©¸æ¤Ç¤­¤Þ¤¹¡£¤Þ¤¿¡¢¥Ç¥Ð¥¤¥¹¼«¿È¤Î¸¡º÷¤â¥Ù¥ó¥À¡¼ ID ¤È¥Ç¥Ð¥¤¥¹ ID ¤ò»È¤Ã¤Æ¸¡º÷¤¹¤ë¤³¤È¤¬¤Ç¤­¤Þ¤¹¡£¤³¤ì¤é¤ÎÃͤ⡢Ä̾ï¤Ï¥Þ¥Ë¥å¥¢¥ë¤ËºÜ¤Ã¤Æ¤¤¤Þ¤¹¡£

¤³¤³¤Ç¤Ï¡¢¥Ç¥Ð¥¤¥¹¤Î¸¡º÷¤ä I/O ¥¢¥É¥ì¥¹¤ä³ä¤ê¹þ¤ßÈÖ¹æ¤È¤¤¤Ã¤¿´ðËܾðÊó¤ò¼èÆÀ¤¹¤ë¤¿¤á¤ÎÊýË¡¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Þ¤¹¡£

¡û ÀßÄê¥ì¥¸¥¹¥¿

PCI ¥Ç¥Ð¥¤¥¹¤Ë¤Ï¡¢256 ¥Ð¥¤¥È¤ÎÀßÄê¥ì¥¸¥¹¥¿¤¬¤¢¤ê¤Þ¤¹¡£¤³¤Î¤¦¤Á¡¢ÀèƬ¤«¤é 64 ¥Ð¥¤¥È¤Ï PCI µ¬³Ê¤Çɸ½à²½¤µ¤ì¤Æ¤¤¤Æ¡¢°Ê²¼¤ÎÍͤˤʤäƤ¤¤Þ¤¹¡£¤³¤ÎÀßÄê¥ì¥¸¥¹¥¿¤ÎÆâÍƤò¥«¡¼¥Í¥ë¤Î´Ø¿ô¤ò»È¤Ã¤ÆÆɤ߹þ¤à¤³¤È¤Ç¡¢É¬ÍפʾðÊó¤ò¼èÆÀ¤¹¤ë¤³¤È¤Ë¤Ê¤ê¤Þ¤¹¡£

¥Ð¥¤¥È¿ô ¹àÌÜ̾ ´Êñ¤ÊÀâÌÀ ( Ëͤ¬ÃΤäƤ¤¤ë½ê¤À¤±½ñ¤­¤Þ¤¹ m(__)m )
2 ¥Ù¥ó¥À ID ¥Ï¡¼¥É¥¦¥§¥¢¥á¡¼¥«¡¼¤Î¼±Ê̻ҡ£ PCI Special Interest Group ¤Ë¤è¤Ã¤Æ´ÉÍý¤µ¤ì¤Æ¤¤¤ë¡£Linux® ¥«¡¼¥Í¥ë¥½¡¼¥¹¥³¡¼¥É¤Î drivers/pci/devlist.h ¤ò¸«¤ë¤È¡¢¥Ù¥ó¥À ID ¤ª¤è¤Ó¥Ç¥Ð¥¤¥¹ ID ¤ÎÁȤ¬ ¥Þ¥Ã¥Ô¥ó¥°¤µ¤ì¤ë¥Ç¥Ð¥¤¥¹¤Î̾¾Î¤¬Ê¬¤«¤ê¤Þ¤¹ ( Á´¤Æ¤Ç¤Ï¤Ê¤¤¤È»×¤¤¤Þ¤¹¤¬ )
2 ¥Ç¥Ð¥¤¥¹ ID ¥á¡¼¥«¡¼¤¬¥Ç¥Ð¥¤¥¹¤Ë¸ÇÍ­¤ËÉÕ¤±¤ë ID
2 ¥³¥Þ¥ó¥É¥ì¥¸¥¹¥¿ -
2 ¥¹¥Æ¡¼¥¿¥¹¥ì¥¸¥¹¥¿ -
1 ¥ê¥Ó¥¸¥ç¥ó ID -
3 ¥¯¥é¥¹¥³¡¼¥É ¥Ç¥Ð¥¤¥¹¤Î¼ïÎà¤òɽ¤¹ÃÍ¡£¸å¤í¤Î 2 ¥Ð¥¤¥È¤¬¥Ù¡¼¥¹¥¯¥é¥¹¤È¥µ¥Ö¥¯¥é¥¹¤È¤¤¤¦ 2 ¼ïÎà¤ÎÃͤòɽ¤·¤Æ¤¤¤Æ¡¢¤³¤ÎÁȤǥǥХ¤¥¹¤Î¼ïÎब·èÄꤵ¤ì¤ë¡£ ¥¯¥é¥¹Ãͤâ PCI Special Interest Group ¤¬´ÉÍý¤·¤Æ¤¤¤ëÍͤǤ¢¤ë¡£Linux ¥«¡¼¥Í¥ë¥½¡¼¥¹¥³¡¼¥É¤Î drivers/pci/classlist.h ¤ò¸«¤ë¤È¡¢2 ¥Ð¥¤¥È¤ÎÁȤ¬¤É¤¦¤¤¤¦¥Ç¥Ð¥¤¥¹¤È¤·¤Æ ÄêµÁ¤µ¤ì¤Æ¤¤¤ë¤«Ê¬¤«¤ê¤Þ¤¹ ( Á´¤Æ¤Ç¤Ï¤Ê¤¤¤È»×¤¤¤Þ¤¹¤¬ )¡£ ºÇ½é¤Î 1 ¥Ð¥¤¥È¤ÏÎɤ¯Ê¬¤«¤ê¤Þ¤»¤ó
1 ¥­¥ã¥Ã¥·¥å¥é¥¤¥ó -
1 ¥ì¥¤¥Æ¥ó¥·¥¿¥¤¥Þ -
1 ¥Ø¥Ã¥À¥¿¥¤¥× -
1 BIST ( Built In Self Test ) -
4 ¥Ù¡¼¥¹¥¢¥É¥ì¥¹ 0 ºÇ½é¤Î I/O Îΰè¾ðÊó
4 ¥Ù¡¼¥¹¥¢¥É¥ì¥¹ 1 2 ÈÖÌܤΠI/O Îΰè¾ðÊó
4 ¥Ù¡¼¥¹¥¢¥É¥ì¥¹ 2 3 ÈÖÌܤΠI/O Îΰè¾ðÊó
4 ¥Ù¡¼¥¹¥¢¥É¥ì¥¹ 3 4 ÈÖÌܤΠI/O Îΰè¾ðÊó
4 ¥Ù¡¼¥¹¥¢¥É¥ì¥¹ 4 5 ÈÖÌܤΠI/O Îΰè¾ðÊó
4 ¥Ù¡¼¥¹¥¢¥É¥ì¥¹ 5 6 ÈÖÌܤΠI/O Îΰè¾ðÊó
4 CardBus CIS pointer -
2 ¥µ¥Ö¥·¥¹¥Æ¥à¥Ù¥ó¥À ID -
2 ¥µ¥Ö¥·¥¹¥Æ¥à¥Ç¥Ð¥¤¥¹ ID -
4 ³ÈÄ¥ ROM ¥Ù¡¼¥¹¥¢¥É¥ì¥¹ -
8 ͽÌó ¾­Íè¤Î¤¿¤á¤ËͽÌ󤵤ì¤Æ¤¤¤ëÎΰè
1 IRQ ÈÖ¹æ ³ä¤ê¹þ¤ßÈÖ¹æ
1 IRQ ¥Ô¥óÈÖ¹æ ³ä¤ê¹þ¤ß¿®¹æ¤Ë»È¤ï¤ì¤Æ¤¤¤ë¥Ô¥óÈÖ¹æ
1 Min_Gnt -
1 Max_Lat -

¡û ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à

PCI ¥Ç¥Ð¥¤¥¹¤Î¾ðÊó¤ò¼èÆÀ¤·¤Æ¡¢¥«¡¼¥Í¥ë¥í¥°¤Ë½ÐÎϤ¹¤ë¥µ¥ó¥×¥ë¥×¥í¥°¥é¥àpci.c ¤Ç¤¹¡£ ¤Ï¤¸¤á¤Ë ¤Î¥Ú¡¼¥¸¤«¤é¡¢Á´¤Æ¤Î¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ò ¸Ç¤á¤¿ tar ¥Ü¡¼¥ë¤ò¥À¥¦¥ó¥í¡¼¥É¤¹¤ë¤³¤È¤â¤Ç¤­¤Þ¤¹¡£

insmod ¤ÇÁȤ߹þ¤à¤È¥¨¥é¡¼½ªÎ»¤·¤Þ¤¹¤¬¡¢¤³¤ì¤Ï init_module ¤Ç¤ï¤¶¤È 0 °Ê³°¤òÊÖ¤·¤Æ¤¤¤ë¤«¤é¤Ç¤¹¡£PCI ¥Ç¥Ð¥¤¥¹¾ðÊó¤òɽ¼¨¤·¤¿¸å¤ËÁȤ߹þ¤Þ¤ì¤Æ¤¤¤ëɬÍפ¬Ìµ¤¤¤Î¤Ç¡¢¤³¤ÎÍͤˤ·¤Æ¤¤¤Þ¤¹¡£

¥«¡¼¥Í¥ë¥í¥°¤ò¸«¤ë¤È¡¢°Ê²¼¤ÎÍͤʴ¶¤¸¤Ç PCI ¥Ç¥Ð¥¤¥¹¤Î¾ðÊ󤬽ÐÎϤµ¤ì¤Æ¤¤¤ë¤È»×¤¤¤Þ¤¹¡Ê¼ÂºÝ¤Îɽ¼¨¤Ï¡¢Àܳ¤µ¤ì¤Æ¤¤¤ë¥Ç¥Ð¥¤¥¹¤Ë¤è¤Ã¤Æ°Û¤Ê¤ê¤Þ¤¹¡Ë¡£

<6>module [pci.o] : loaded  into kernel
<6>module [pci.o] : vendor id = 32902, device id = 29072
<6>module [pci.o] : class = 1536
<6>module [pci.o] : subsystem
<6>module [pci.o] :   vendor id = 0, device id = 0
<6>module [pci.o] : IRQ = 0
<6>module [pci.o] : Base address 0xe0000000 - 0xe3ffffff
<6>module [pci.o] :   Memory
<6>module [pci.o] :   Prefetchable
<6>module [pci.o] : 
<6>module [pci.o] : 
<6>module [pci.o] : vendor id = 32902, device id = 29073
<6>module [pci.o] : class = 1540
<6>module [pci.o] : subsystem
<6>module [pci.o] :   vendor id = 0, device id = 0
<6>module [pci.o] : IRQ = 0
<6>module [pci.o] : 
<6>module [pci.o] : vendor id = 32902, device id = 28944
<6>module [pci.o] : class = 1537
<6>module [pci.o] : subsystem
<6>module [pci.o] :   vendor id = 0, device id = 0
<6>module [pci.o] : IRQ = 0
<6>module [pci.o] : 
<6>module [pci.o] : vendor id = 32902, device id = 28945
<6>module [pci.o] : class = 257
<6>module [pci.o] : subsystem
<6>module [pci.o] :   vendor id = 0, device id = 0
<6>module [pci.o] : IRQ = 0
<6>module [pci.o] : Base address 0xf000 - 0xf00f
<6>module [pci.o] :   I/O port
<6>module [pci.o] : 
<6>module [pci.o] : 
<6>module [pci.o] : vendor id = 32902, device id = 28946
<6>module [pci.o] : class = 3075
<6>module [pci.o] : subsystem
<6>module [pci.o] :   vendor id = 0, device id = 0
<6>module [pci.o] : IRQ = 10
<6>module [pci.o] : Base address 0xe000 - 0xe01f
<6>module [pci.o] :   I/O port
<6>module [pci.o] : 
<6>module [pci.o] : 
<6>module [pci.o] : vendor id = 32902, device id = 28947
<6>module [pci.o] : class = 1664
<6>module [pci.o] : subsystem
<6>module [pci.o] :   vendor id = 0, device id = 0
<6>module [pci.o] : IRQ = 0
<6>module [pci.o] : 
<6>module [pci.o] : vendor id = 4358, device id = 12355
<6>module [pci.o] : class = 512
<6>module [pci.o] : subsystem
<6>module [pci.o] :   vendor id = 4697, device id = 41221
<6>module [pci.o] : IRQ = 5
<6>module [pci.o] : Base address 0xe400 - 0xe47f
<6>module [pci.o] :   I/O port
<6>module [pci.o] : 
<6>module [pci.o] : Base address 0xeb000000 - 0xeb00007f
<6>module [pci.o] :   Memory
<6>module [pci.o] : 
<6>module [pci.o] : 
<6>module [pci.o] : vendor id = 4354, device id = 2
<6>module [pci.o] : class = 1025
<6>module [pci.o] : subsystem
<6>module [pci.o] :   vendor id = 4354, device id = 32
<6>module [pci.o] : IRQ = 12
<6>module [pci.o] : Base address 0xe800 - 0xe81f
<6>module [pci.o] :   I/O port
<6>module [pci.o] : 
<6>module [pci.o] : 
<6>module [pci.o] : vendor id = 4354, device id = 28674
<6>module [pci.o] : class = 2432
<6>module [pci.o] : subsystem
<6>module [pci.o] :   vendor id = 4354, device id = 32
<6>module [pci.o] : IRQ = 0
<6>module [pci.o] : Base address 0xec00 - 0xec07
<6>module [pci.o] :   I/O port
<6>module [pci.o] : 
<6>module [pci.o] : 
<6>module [pci.o] : vendor id = 4139, device id = 1317
<6>module [pci.o] : class = 768
<6>module [pci.o] : subsystem
<6>module [pci.o] :   vendor id = 4139, device id = 6648
<6>module [pci.o] : IRQ = 11
<6>module [pci.o] : Base address 0xe8000000 - 0xe9ffffff
<6>module [pci.o] :   Memory
<6>module [pci.o] :   Prefetchable
<6>module [pci.o] : 
<6>module [pci.o] : Base address 0xe4000000 - 0xe4003fff
<6>module [pci.o] :   Memory
<6>module [pci.o] : 
<6>module [pci.o] : Base address 0xe5000000 - 0xe57fffff
<6>module [pci.o] :   Memory
<6>module [pci.o] : 
<6>module [pci.o] : 

--- pci.c ---

    1    #include <asm/types.h>    /* u8, ... */
    2    #include <linux/errno.h>
    3    #include <linux/ioport.h> /* IORESOURCE_IO, ... */
    4    #include <linux/module.h> /* module ºîÀ®¤Ë¤Ïɬ¿Ü */
    5    #include <linux/kernel.h> /* printk */
    6    #include <linux/pci.h>
    7    
    8    
    9    MODULE_LICENSE( "GPL" );
   10    
   11    static char* msg = "module [pci.o]";
   12    
   13    
   14    /*
   15     * PCI ¥Ð¥¹¤ËÀܳ¤µ¤ì¤Æ¤¤¤ë¥Ç¥Ð¥¤¥¹¤Î¾ðÊó¤òɽ¼¨¤¹¤ë¡£
   16     */
   17    static void 
   18    print_pci_information( void )
   19    {
   20        struct pci_dev* device = NULL;
   21    
   22        while ( 1 ) {
   23            /*
   24             * vendor id ¤ª¤è¤Ó device id ¤Ë PCI_ANY_ID ¤ò»ØÄꤹ¤ë¤³¤È¤Ç
   25             * Àܳ¤µ¤ì¤Æ¤¤¤ëÁ´¤Æ¤Î PCI ¥Ç¥Ð¥¤¥¹¤òÂоݤȤ·¤Æ¤¤¤ë¡£
   26             */
   27            device = pci_find_device( PCI_ANY_ID, PCI_ANY_ID, device );
   28    
   29            if ( device == NULL )
   30                break;
   31    
   32    
   33            {
   34                #define BASE_ADDRESS_NUM 6
   35    
   36                u16 vendor_id;
   37                u16 device_id;
   38                u16 class;
   39                u16 sub_vendor_id;
   40                u16 sub_device_id;
   41                u8  irq;
   42    
   43                unsigned long resource_start;
   44                unsigned long resource_end;
   45                unsigned long resource_flag;
   46    
   47                int i;
   48    
   49    
   50                pci_read_config_word( device, PCI_VENDOR_ID,           &vendor_id );
   51                pci_read_config_word( device, PCI_DEVICE_ID,           &device_id );
   52                pci_read_config_word( device, PCI_CLASS_DEVICE,        &class );
   53                pci_read_config_word( device, PCI_SUBSYSTEM_VENDOR_ID, &sub_vendor_id );
   54                pci_read_config_word( device, PCI_SUBSYSTEM_ID,        &sub_device_id );
   55                pci_read_config_byte( device, PCI_INTERRUPT_LINE,      &irq );
   56    
   57    
   58                printk( KERN_INFO "%s : vendor id = %i, device id = %i\n",
   59                    msg, vendor_id, device_id );
   60    
   61                printk( KERN_INFO "%s : class = %i\n", msg, class );
   62                printk( KERN_INFO "%s : subsystem\n", msg );
   63    
   64                printk( KERN_INFO "%s :   vendor id = %i, device id = %i\n",
   65                    msg, sub_vendor_id, sub_device_id );
   66    
   67                printk( KERN_INFO "%s : IRQ = %i\n", msg, irq );
   68    
   69    
   70                for ( i = 0; i < BASE_ADDRESS_NUM; i ++ ) {
   71                    resource_start = pci_resource_start( device, i );
   72                    resource_end   = pci_resource_end( device, i );
   73                    resource_flag  = pci_resource_flags( device, i );
   74    
   75                    if ( resource_start != 0 || resource_end != 0 ) {
   76                        printk( KERN_INFO "%s : Base address 0x%0x - 0x%0x\n", 
   77                            msg, resource_start, resource_end );
   78    
   79                        if ( resource_flag & IORESOURCE_IO )
   80                            printk( KERN_INFO "%s :   I/O port\n", msg );
   81    
   82                        if ( resource_flag & IORESOURCE_MEM )
   83                            printk( KERN_INFO "%s :   Memory\n", msg );
   84    
   85                        if ( resource_flag & IORESOURCE_PREFETCH )
   86                            printk( KERN_INFO "%s :   Prefetchable\n", msg );
   87    
   88                        if ( resource_flag & IORESOURCE_READONLY )
   89                            printk( KERN_INFO "%s :   Read Only\n", msg );
   90    
   91                        printk( KERN_INFO "%s : \n", msg );
   92                    }
   93                }
   94    
   95                printk( KERN_INFO "%s : \n", msg );
   96            }
   97        }
   98    }
   99    
  100    
  101    /*
  102     * ¥â¥¸¥å¡¼¥ë¤Î½é´ü½èÍý
  103     * insmod »þ¤Ë¸Æ¤Ð¤ì¤ë
  104     */
  105    int 
  106    init_module( void )
  107    {
  108        printk( KERN_INFO "%s : loaded  into kernel\n", msg );
  109    
  110        print_pci_information();
  111    
  112        /* ÁȤ߹þ¤Þ¤ì¤ë°ÕÌ£¤¬Ìµ¤¤¤Î¤Ç¡¢¾ï¤Ë¥¨¥é¡¼¤òÊÖ¤¹¤³¤È¤Ç
  113           ÁȤ߹þ¤Þ¤ì¤Ê¤¤Íͤˤ·¤Æ¤¤¤ë */
  114    
  115        return -ENODEV;
  116    }
  117    
  118    
  119    /*
  120     * ¥â¥¸¥å¡¼¥ë¤Î²òÊü½èÍý
  121     * ¥â¥¸¥å¡¼¥ë¤Î»²¾È¿ô¤¬ 0 ¤Ç¤¢¤ì¤Ð¡¢rmmod »þ¤Ë¸Æ¤Ð¤ì¤ë
  122     */
  123    void 
  124    cleanup_module( void )
  125    {
  126        printk( KERN_INFO "%s : removed from kernel\n", msg );
  127    }
  128    
  129    
  130    /* End of pci.c */

¡û ¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤ÎÀâÌÀ

¤Ç¤Ï¡¢¥µ¥ó¥×¥ë¥×¥í¥°¥é¥à¤Ë¤Ä¤¤¤ÆÀâÌÀ¤·¤Æ¤¤¤­¤Þ¤¹¡£

  • 1 ¡Á 6 ¹ÔÌÜ

    ɬÍפʥإåÀ¥Õ¥¡¥¤¥ë¤ò¥¤¥ó¥¯¥ë¡¼¥É¤·¤Æ¤¤¤Þ¤¹¡£asm/types.h ¤Ï¡¢ u8 ¤ä u16 Åù¤Î·¿¤ò»È¤¦¤¿¤á¤ËɬÍפǤ¹¡£¤Þ¤¿¡¢PCI ´ØÏ¢¤Î´Ø¿ô¤ò»È¤¦¤¿¤á¤Ë linux/pci.h ¤ò¥¤¥ó¥¯¥ë¡¼¥É¤·¤Æ¤¤¤Þ¤¹¡£

  • 14 ¡Á 98 ¹ÔÌÜ ( print_pci_information )

    pci.c ¤Î¥á¥¤¥ó¤È¸À¤¨¤ë´Ø¿ô¤Ç¤¹¡£ init_module Æâ¤Ç¤³¤Î´Ø¿ô¤ò¼Â¹Ô¤·¤Æ¡¢PCI ¾ðÊó¤òɽ¼¨¤µ¤»¤Æ¤¤¤Þ¤¹¡£ while ¥ë¡¼¥×¤ÇÁ´¤Æ¤Î PCI ¥Ç¥Ð¥¤¥¹¾ðÊó¤ò¼èÆÀ¤·¡¢É½¼¨¤·¤Æ¤¤¤Þ¤¹¡£

    • 23 ¡Á 30 ¹ÔÌÜ

      pci_find_device ´Ø¿ô¤ò»È¤Ã¤Æ¡¢PCI ¥Ç¥Ð¥¤¥¹¾ðÊó¤ò¸¡º÷¤·¤Æ¤¤¤Þ¤¹¡£

      #include <linux/pci.h>
      struct pci_dev* 
      pci_find_device( 
        unsigned int vendor, unsigned int device, const struct pci_dev* from );
      
      

      pci_find_device ¤Ï¡¢¥Ù¥ó¥À ID ¤È¥Ç¥Ð¥¤¥¹ ID ¤ò»ØÄꤷ¤Æ³ºÅö¤¹¤ë PCI ¥Ç¥Ð¥¤¥¹¾ðÊó¤ò¸¡º÷¤¹¤ë¤¿¤á¤Î´Ø¿ô¤Ç¤¹¡£³ºÅö¤¹¤ë PCI ¥Ç¥Ð¥¤¥¹¤¬Â¸ºß¤·¤Ê¤¤¾ì¹ç¤Ï NULL ¤òÊÖ¤·¤Þ¤¹¡£from ¤Ë NULL ¤ò»ØÄꤹ¤ë¤È¡¢PCI ¥Ç¥Ð¥¤¥¹¥ê¥¹¥È¤ÎÀèƬ¤«¤é ¸¡º÷¤¬¼Â¹Ô¤µ¤ì¡¢ºÇ½é¤Ë³ºÅö¤·¤¿¥Ç¥Ð¥¤¥¹¾ðÊó¤¬ÊÖ¤ê¤Þ¤¹¡£¼èÆÀ¤·¤¿ struct pci_dev ¤Ø¤Î¥Ý¥¤¥ó¥¿¤ò from ¤Ë»ØÄꤹ¤ë¤È¡¢PCI ¥Ç¥Ð¥¤¥¹¥ê¥¹¥ÈÃæ¤Î¼¡¤Î¥Ç¥Ð¥¤¥¹¤«¤é ¸¡º÷¤¬¼Â¹Ô¤µ¤ì¤Þ¤¹¡£

      ¤³¤³¤Ç¤Ï PCI_ANY_ID ¤È¤¤¤¦ÆÃÄê¤Î ID ¤ò»ØÄꤷ¤Ê¤¤¤¿¤á¤Î ID ¤ò»ÈÍѤ·¤Æ¤¤¤ë¤¿¤á¡¢ ¥Ù¥ó¥À ID ¤È¥Ç¥Ð¥¤¥¹ ID ¤Ë´Ø·¸¤Ê¤¯Àܳ¤µ¤ì¤Æ¤¤¤ë¥Ç¥Ð¥¤¥¹¾ðÊ󤬽ç¤ËÊÖ¤ê¤Þ¤¹¤¬¡¢ PCI ¥Ç¥Ð¥¤¥¹¤òÀ©¸æ¤¹¤ë¾ì¹ç¤Ï¡¢Ä̾ï¤Ï¥Þ¥Ë¥å¥¢¥ëÅù¤Ç¥Ù¥ó¥À ID ¤È¥Ç¥Ð¥¤¥¹ ID ¤ò»ØÄꤷ¤Æ¥Ç¥Ð¥¤¥¹¾ðÊó¤ò¸¡º÷¤·¤Þ¤¹¡£ ¤Þ¤¿¡¢À©¸æ¤¹¤ëºÝ¤Ë¤Ï¼èÆÀ¤·¤¿ struct pci_dev ¤ËÂФ·¤Æ¡¢pci_enable_device ¤ò¼Â¹Ô¤·¤Æ¥Ç¥Ð¥¤¥¹¤òÍ­¸ú²½¤·¤Æ¤¯¤À¤µ¤¤¡£

      #include <linux/pci.h>
      int pci_enable_device( struct pci_dev* dev );
      
      

      pci_enable_device ¤ÏÀ®¸ù¤¹¤ë¤È 0 ¤¬¡¢¼ºÇÔ¤¹¤ë¤È¤½¤ì°Ê³°¤¬ÊÖ¤ê¤Þ¤¹¡£

      ¤Ê¤ª¡¢»²¹Í¤Þ¤Ç¤Ë¥Ç¥Ð¥¤¥¹¥¯¥é¥¹¤ò»ØÄꤷ¤Æ PCI ¥Ç¥Ð¥¤¥¹¾ðÊó¤ò¼èÆÀ¤¹¤ë¤¿¤á¤Ë¤Ï¡¢ pci_find_class ¤ò»È¤¤¤Þ¤¹¡£

      #include <linux/pci.h>
      struct pci_dev* pci_find_class( unsigned int class, const struct pci_dev* from );
      
      

      class ¤Ï¡¢¥Ù¡¼¥¹¥¯¥é¥¹¤È¥µ¥Ö¥¯¥é¥¹¤òɽ¤¹ 16 ¥Ó¥Ã¥ÈÃͤò»ØÄꤷ¤Þ¤¹¡£

    • 33 ¡Á 96 ¹ÔÌÜ

      ¼èÆÀ¤·¤¿ PCI ¥Ç¥Ð¥¤¥¹¾ðÊó¤ò»È¤Ã¤Æ¡¢ÀßÄê¥ì¥¸¥¹¥¿¤ÎÆâÍƤòÆɤ߹þ¤ß ¥«¡¼¥Í¥ë¥í¥°¤Ë½ÐÎϤ·¤Æ¤¤¤Þ¤¹¡£

      ¥Ù¥ó¥À ID / ¥Ç¥Ð¥¤¥¹ ID / ¥¯¥é¥¹ / ¥µ¥Ö¥·¥¹¥Æ¥à¥Ù¥ó¥À ID / ¥µ¥Ö¥·¥¹¥Æ¥à ID / ³ä¤ê¹þ¤ßÈÖ¹æ¤òÀßÄê¥ì¥¸¥¹¥¿¤«¤éÆɤ߹þ¤ß¤¿¤á¤Ë¡¢ pci_read_config_byte / pci_read_config_word ¤ò»ÈÍѤ·¤Æ¤¤¤Þ¤¹¡£

      #include <linux/pci.h>
      int pci_read_config_byte( struct pci_dev* dev, int where, u8* ptr );
      int pci_read_config_word( struct pci_dev* dev, int where, u16* ptr );
      int pci_read_config_dword( struct pci_dev* dev, int where, u32* ptr );
      
      

      where ¤Ë¡¢ÀßÄê¥ì¥¸¥¹¥¿Ãæ¤ÎÆɤߤ¿¤¤¾ì½ê¤òɽ¤¹¥Þ¥¯¥í¤ò»ØÄꤷ¡¢ ptr ¤ËÃͤò³ÊǼ¤¹¤ëÎΰè¤Ø¤Î¥Ý¥¤¥ó¥¿¤ò»ØÄꤷ¤Þ¤¹¡£Ê£¿ô¥Ð¥¤¥È¤ÎÃͤˤĤ¤¤Æ¤Ï¡¢ ´Ø¿ôÆâ¤Ç¥¨¥ó¥Ç¥£¥¢¥ó¤ÎÊÑ´¹¤¬¹Ô¤ï¤ì¤ë¤Î¤Çµ¤¤Ë¤¹¤ëɬÍפϤ¢¤ê¤Þ¤»¤ó ( ÀßÄê¥ì¥¸¥¹¥¿Æâ¤Ï¥ê¥È¥ë¥¨¥ó¥Ç¥£¥¢¥ó )¡£¤Ê¤ª¡¢¥Þ¥¯¥í¤Ï linux/pci.h ¤ÇÄêµÁ¤µ¤ì¤Æ¤¤¤Þ¤¹¤Î¤Ç¡¢ÀßÄê¥ì¥¸¥¹¥¿¤ÎÆâÍƤȸ«Èæ¤Ù¤Ê¤¬¤é»È¤Ã¤Æ¤ß¤Æ¤¯¤À¤µ¤¤¡£

      ¤Ê¤ª¡¢ÀßÄê¥ì¥¸¥¹¥¿¤ËÂФ·¤Æ½ñ¤­¹þ¤ß¤ò¹Ô¤¦¾ì¹ç ( ¥³¥Þ¥ó¥É¥ì¥¸¥¹¥¿¤Ø¤Î½ñ¤­¹þ¤ßÅù ) ¤Ï¡¢pci_write_config_xxxx ¤ò»È¤¤¤Þ¤¹¡£

      #include <linux/pci.h>
      int pci_write_config_byte( struct pci_dev* dev, int where, u8 val );
      int pci_write_config_word( struct pci_dev* dev, int where, u16 val );
      int pci_write_config_dword8 struct pci_dev* dev, int where, u32 val );
      
      

      ½ñ¤­¹þ¤ß¤ò¹Ô¤¦Á°¤Ë¡¢pci_enable_device ¤Ç¥Ç¥Ð¥¤¥¹¤òÍ­¸ú²½¤¹¤ë¤Î¤ò ˺¤ì¤Ê¤¤¤Ç¤¯¤À¤µ¤¤¡£

    • 70 ¡Á 93 ¹ÔÌÜ

      6 ¤Ä¤Î¥Ù¡¼¥¹¥¢¥É¥ì¥¹¤ËÂФ·¤Æ¡¢ I/O Îΰè¤ÎÀèƬ¥¢¥É¥ì¥¹ / ºÇ¸å¤Î¥¢¥É¥ì¥¹ / I/O Îΰè¤Î¼ïÎà ¤ò¼èÆÀ¤·¤Æɽ¼¨¤·¤Æ¤¤¤Þ¤¹¡£¤³¤ì¤é¤Ï¤½¤ì¤¾¤ì°Ê²¼¤Î´Ø¿ô¤Ç¼èÆÀ¤·¤Þ¤¹¡£

      #include <linux/pci.h>
      unsigned long pci_resource_start( struct pci_dev* dev, int bar );
      unsigned long pci_resource_end( struct pci_dev* dev, int bar );
      unsigned long pci_resource_flags( struct pci_dev* dev, int bar );
      
      

      bar ¤Ë 0 - 5 ¤ò»ØÄꤹ¤ë¤³¤È¤Ç¡¢¥Ù¡¼¥¹¥¢¥É¥ì¥¹ 0 - 5 ¤òÁªÂò¤·¤Þ¤¹¡£ pci_resource_start ¤È pci_resource_end ¤Ï¡¢¥Ù¡¼¥¹¥¢¥É¥ì¥¹¤¬¥Þ¥Ã¥Ô¥ó¥° ¤µ¤ì¤Æ¤¤¤Ê¤¤¡ÊÍפ¹¤ë¤Ë PCI ¥Ç¥Ð¥¤¥¹¾å¤Ë¸ºß¤·¤Ê¤¤ I/O Îΰè¤Ç¤¢¤ë ) ¾ì¹ç¤Ï 0 ¤òÊÖ¤¹ÍͤǤ¹¡£

      pci_resource_flags ¤Ï¡¢I/O Îΰè¤Ë´Ø¤¹¤ë¾ðÊó¤òÏÀÍýϤÇÊÖ¤·¤Þ¤¹¡£ linux/ioport.h ¤ËÄêµÁ¤µ¤ì¤Æ¤¤¤ëÄê¿ô¤ÎÏÀÍýϤȤʤäƤ¤¤Þ¤¹¤¬¡¢ pci.c ¤ÇȽÄꤷ¤Æ¤¤¤ëÄê¿ô¤Ï°Ê²¼¤ÎÄ̤ê¤Ç¤¹¡£

      Äê¿ô̾ ÆâÍÆ
      IORESOURCE_IO I/O Îΰè¤Ï I/O ¥Ý¡¼¥È¤Ç¤¢¤ë
      IORESOURCE_MEM I/O Îΰè¤Ï¥á¥â¥êÎΰè (¥á¥â¥ê¥Þ¥Ã¥Ô¥ó¥°¤µ¤ì¤Æ¤¤¤ë) ¤Ç¤¢¤ë
      IORESOURCE_PREFETCH ¥á¥â¥êÎΰ褬¥×¥ê¥Õ¥§¥Ã¥Á¤Ç¤­¤ë¤«¤É¤¦¤« ( ¥¢¥¯¥»¥¹¤Ë¤è¤ëÉûºîÍѤ¬Ìµ¤¯¡¢CPU ¤¬¥­¥ã¥Ã¥·¥å¤Ç¤­¤ë¤«¤É¤¦¤« )

°Ê¾å¤Ç pci.c ¤Î²òÀâ¤Ï½ª¤ï¤ê¤Ç¤¹¡£¤³¤³¤Þ¤Ç¤ÎÆâÍÆ¤Ç I/O Îΰè¤Î¥¢¥É¥ì¥¹¤È³ä¤ê¹þ¤ßÈÖ¹æ¤ò¼èÆÀ¤¹¤ë¤³¤È¤¬¤Ç¤­¤¿¤Î¤Ç¡¢¥Þ¥Ë¥å¥¢¥ë¤Ç¥Ç¥Ð¥¤¥¹¤ÎÀ©¸æÊýË¡¤ò¤¸¤Ã¤¯¤êÆɤá¤Ð PCI ¥«¡¼¥É¤òÀ©¸æ¤¹¤ë¤¿¤á¤Î¥Ç¥Ð¥¤¥¹¥É¥é¥¤¥Ð¤ò½ñ¤¯¤Î¤Ï´Êñ¤Ç¤¹¤Í¡ª