pci.h
上传用户:jlfgdled
上传日期:2013-04-10
资源大小:33168k
文件大小:7k
源码类别:

Linux/Unix编程

开发平台:

Unix_Linux

  1. /* PCI.h - PCI functions header file */
  2. /* Copyright - Galileo technology. */
  3. #ifndef  __INCpcih
  4. #define  __INCpcih
  5. /* includes */
  6. #include"core.h"
  7. /* defines */
  8. #define PCI0_MASTER_ENABLE(deviceNumber) pci0WriteConfigReg(                  
  9.           PCI_0STATUS_AND_COMMAND,deviceNumber,MASTER_ENABLE |                
  10.           pci0ReadConfigReg(PCI_0STATUS_AND_COMMAND,deviceNumber) )
  11. #define PCI0_MASTER_DISABLE(deviceNumber) pci0WriteConfigReg(                 
  12.           PCI_0STATUS_AND_COMMAND,deviceNumber,~MASTER_ENABLE &               
  13.           pci0ReadConfigReg(PCI_0STATUS_AND_COMMAND,deviceNumber) )
  14. #define PCI1_MASTER_ENABLE(deviceNumber) pci1WriteConfigReg(                  
  15.           PCI_0STATUS_AND_COMMAND,deviceNumber,MASTER_ENABLE |                
  16.           pci1ReadConfigReg(PCI_0STATUS_AND_COMMAND,deviceNumber) )
  17. #define PCI1_MASTER_DISABLE(deviceNumber) pci1WriteConfigReg(                 
  18.           PCI_0STATUS_AND_COMMAND,deviceNumber,~MASTER_ENABLE &               
  19.           pci1ReadConfigReg(PCI_0STATUS_AND_COMMAND,deviceNumber) )
  20. #define PCI0_MEMORY_ENABLE(deviceNumber) pci0WriteConfigReg(                  
  21.           PCI_0STATUS_AND_COMMAND,deviceNumber,MEMORY_ENABLE |                
  22.           pci0ReadConfigReg(PCI_0STATUS_AND_COMMAND,deviceNumber) )
  23. #define PCI1_MEMORY_ENABLE(deviceNumber) pci1WriteConfigReg(                  
  24.           PCI_0STATUS_AND_COMMAND,deviceNumber,MEMORY_ENABLE |                
  25.           pci1ReadConfigReg(PCI_0STATUS_AND_COMMAND,deviceNumber) )
  26. #define PCI0_IO_ENABLE(deviceNumber) pci0WriteConfigReg(                      
  27.           PCI_0STATUS_AND_COMMAND,deviceNumber,I_O_ENABLE |                   
  28.           pci0ReadConfigReg(PCI_0STATUS_AND_COMMAND,deviceNumber) )
  29. #define PCI1_IO_ENABLE(deviceNumber) pci1WriteConfigReg(                      
  30.           PCI_0STATUS_AND_COMMAND,deviceNumber,I_O_ENABLE |                   
  31.           pci1ReadConfigReg(PCI_0STATUS_AND_COMMAND,deviceNumber) )
  32. #define PCI0_SLAVE_ENABLE(deviceNumber) pci0WriteConfigReg(                   
  33.           PCI_0STATUS_AND_COMMAND,deviceNumber,MEMORY_ENABLE | I_O_ENABLE |   
  34.           pci0ReadConfigReg(PCI_0STATUS_AND_COMMAND,deviceNumber) )
  35. #define PCI1_SLAVE_ENABLE(deviceNumber) pci1WriteConfigReg(                   
  36.           PCI_0STATUS_AND_COMMAND,deviceNumber,MEMORY_ENABLE | I_O_ENABLE |   
  37.           pci1ReadConfigReg(PCI_0STATUS_AND_COMMAND,deviceNumber) )
  38. #define PCI0_DISABLE(deviceNumber) pci0WriteConfigReg(                        
  39.           PCI_0STATUS_AND_COMMAND,deviceNumber,0xfffffff8  &                  
  40.           pci0ReadConfigReg(PCI_0STATUS_AND_COMMAND,deviceNumber))
  41. #define PCI1_DISABLE(deviceNumber) pci1WriteConfigReg(                        
  42.           PCI_0STATUS_AND_COMMAND,deviceNumber,0xfffffff8  &                  
  43.           pci1ReadConfigReg(PCI_0STATUS_AND_COMMAND,deviceNumber))
  44. #define  MASTER_ENABLE BIT2
  45. #define MEMORY_ENABLE BIT1
  46. #define I_O_ENABLE   BIT0
  47. #define     SELF                    0
  48. /* Agent on the PCI bus may have up to 6 BARS. */
  49. #define     BAR0                    0x10
  50. #define     BAR1                    0x14
  51. #define     BAR2                    0x18
  52. #define     BAR3                    0x1c
  53. #define     BAR4                    0x20
  54. #define     BAR5                    0x24
  55. /* typedefs */
  56. typedef struct pciDevice
  57. {
  58.     char            type[20];
  59.     unsigned int    deviceNum;
  60.     unsigned int    venID;
  61.     unsigned int    deviceID;
  62.     unsigned int    bar0Base;
  63.     unsigned int    bar0Size;
  64.     unsigned int    bar0Type;
  65.     unsigned int    bar1Base;
  66.     unsigned int    bar1Size;
  67.     unsigned int    bar1Type;
  68.     unsigned int    bar2Base;
  69.     unsigned int    bar2Size;
  70.     unsigned int    bar2Type;
  71.     unsigned int    bar3Base;
  72.     unsigned int    bar3Size;
  73.     unsigned int    bar3Type;
  74.     unsigned int    bar4Base;
  75.     unsigned int    bar4Size;
  76.     unsigned int    bar4Type;
  77.     unsigned int    bar5Base;
  78.     unsigned int    bar5Size;
  79.     unsigned int    bar5Type;
  80. } PCI_DEVICE;
  81. void    pci0WriteConfigReg(unsigned int regOffset,unsigned int pciDevNum,
  82.                            unsigned int data);
  83. void    pci1WriteConfigReg(unsigned int regOffset,unsigned int pciDevNum,
  84.                            unsigned int data);
  85. void    pci0ScanDevices(PCI_DEVICE *pci0Detect,unsigned int numberOfElment);
  86. void    pci1ScanDevices(PCI_DEVICE *pci1Detect,unsigned int numberOfElment);
  87. unsigned int    pci0ReadConfigReg (unsigned int regOffset,
  88.                                    unsigned int pciDevNum);
  89. unsigned int    pci1ReadConfigReg (unsigned int regOffset,
  90.                                    unsigned int pciDevNum);
  91. /*      Master`s memory space   */
  92. void    pci0MapIOspace(unsigned int pci0IoBase,unsigned int pci0IoLength);
  93. void    pci0MapMemory0space(unsigned int pci0Mem0Base,
  94.                             unsigned int pci0Mem0Length);
  95. void    pci0MapMemory1space(unsigned int pci0Mem1Base,
  96.                             unsigned int pci0Mem1Length);
  97. void    pci1MapIOspace(unsigned int pci1IoBase,unsigned int pci1IoLength);
  98. void    pci1MapMemory0space(unsigned int pci1Mem0Base,
  99.                             unsigned int pci1Mem0Length);
  100. void    pci1MapMemory1space(unsigned int pci1Mem1Base,
  101.                             unsigned int pci1Mem1Length);
  102. unsigned int    pci0GetIOspaceBase(void);
  103. unsigned int    pci0GetIOspaceSize(void);
  104. unsigned int    pci0GetMemory0Base(void);
  105. unsigned int    pci0GetMemory0Size(void);
  106. unsigned int    pci0GetMemory1Base(void);
  107. unsigned int    pci0GetMemory1Size(void);
  108. unsigned int    pci1GetIOspaceBase(void);
  109. unsigned int    pci1GetIOspaceSize(void);
  110. unsigned int    pci1GetMemory0Base(void);
  111. unsigned int    pci1GetMemory0Size(void);
  112. unsigned int    pci1GetMemory1Base(void);
  113. unsigned int    pci1GetMemory1Size(void);
  114. /*      Slave`s memory space   */
  115. void    pci0MapInternalRegSpace(unsigned int pci0InternalBase);
  116. void    pci0MapInternalRegIOSpace(unsigned int pci0InternalBase);
  117. void    pci0MapMemoryBanks0_1(unsigned int pci0Dram0_1Base,
  118.                               unsigned int pci0Dram0_1Size);
  119. void    pci0MapMemoryBanks2_3(unsigned int pci0Dram2_3Base,
  120.                               unsigned int pci0Dram2_3Size);
  121. void    pci0MapDevices0_1and2MemorySpace(unsigned int pci0Dev012Base,
  122.                                          unsigned int pci0Dev012Length);
  123. void    pci0MapDevices3andBootMemorySpace(unsigned int pci0Dev3andBootBase,
  124.                                           unsigned int pci0Dev3andBootLength);
  125. void    pci1MapInternalRegSpace(unsigned int pci1InternalBase);
  126. void    pci1MapInternalRegIOSpace(unsigned int pci1InternalBase);
  127. void    pci1MapMemoryBanks0_1(unsigned int pci1Dram0_1Base,
  128.                               unsigned int pci1Dram0_1Size);
  129. void    pci1MapMemoryBanks2_3(unsigned int pci1Dram2_3Base,
  130.                               unsigned int pci1Dram2_3Size);
  131. void    pci1MapDevices0_1and2MemorySpace(unsigned int pci1Dev012Base,
  132.                                          unsigned int pci1Dev012Length);
  133. void    pci1MapDevices3andBootMemorySpace(unsigned int pci1Dev3andBootBase,
  134.                                           unsigned int pci1Dev3andBootLength);
  135. #endif  /* __INCpcih */