pciLocalBus.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:10k
源码类别:

VxWorks

开发平台:

C/C++

  1. /* pciLocalBus.h - pci bus configuration header */
  2. /* Copyright 1984-2001 Wind River Systems, Inc. */
  3. /*
  4. modification history
  5. --------------------
  6. 01j,02nov01,tor  add class info
  7. 01i,27oct01,dat  Adding warnings about obsolete drivers
  8. 01h,05mar97,mas  made file C++ compliant (SPR 8117).
  9. 01g,21feb97,mas  PCI_DEV_IDSEL_MAX conditionally defined here so it can be
  10.  specified in config.h; NUM_PCI_DEVS_MAX set to 6 always
  11.  (SPR 8026).
  12. 01f,08nov96,mas  fixed NUM_PCI_DEVS_MAX and PCI_NUM_BAR for MV1300 (SPR 7446).
  13. 01e,14aug96,dat  changed PCI_READ macro to include address
  14. 01d,02aug96,dat  rewritten for portability, sprs 6490 and 6594
  15. 01c,24jul96,dds  SPR 6819: The PCI_CNFG_HDR structure has been 
  16.                  modified for BIG_ENDIAN architectures.
  17. 01b,02feb95,vin  cleaned up.
  18. 01a,11nov94,vin  created.
  19. */
  20. /*
  21. This file contains type declarations for the PCI Header and the 
  22. macros in regards to the PCI BUS. This header has been designed
  23. with respect to PCI LOCAL BUS SPECIFICATION REVISION 2.1. Every
  24. device on the PCI BUS has to support 256 byte of configuration
  25. space of which the first 64 bytes is a predefined header portion
  26. defined by the PCI commitee. 64 to 255 bytes is dedicated to the
  27. device specific registers. PCI bus is inherently little endian. 
  28. If a big endian processor is being interfaced with a PCI bus then
  29. all the configuration registers have to be swapped and written.
  30. */
  31. #ifndef INCpciLocalBush
  32. #define INCpciLocalBush
  33. /*
  34. WARNING: The pciLocalBus driver is no longer supported. Please switch
  35. all BSPs to use the pciConfigLib driver instead.
  36. */
  37. #warning "h/drv/pci/pciLocalBus.h is being obsoleted, please use pciConfigLib"
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. #if (_BYTE_ORDER == _BIG_ENDIAN)
  42. #define PSWAP(x) LONGSWAP(x) /* swap the long word */
  43. #else
  44. #define PSWAP(x) (x) /* pass it as is */
  45. #endif /* _BYTE_ORDER == _BIG_ENDIAN */
  46. /* given a pci base address and longword index, return local address */
  47. #ifndef PCI_ADDR
  48. # define PCI_ADDR(base,index) (&((ULONG *)(base))[index])
  49. #endif
  50. /* Perform a longword pci read cycle */
  51. #ifndef PCI_READ
  52. #   define PCI_READ(base,index,addr) 
  53.     (*(ULONG *)addr = PSWAP(*PCI_ADDR(base,index)))
  54. #endif
  55. /* perform a longword pci write cycle */
  56. #ifndef PCI_WRITE
  57. #   define PCI_WRITE(base,index,data) (*PCI_ADDR(base,index) = PSWAP(data))
  58. #endif
  59. /*
  60.  * Configuration space header offsets, all 32 bit accesses
  61.  * Always use PSWAP() on the data value.  Use macros to
  62.  * isolate sub fields within the 32 bit values.
  63.  */
  64. #define PCI_IDX_DEV_VNDR 0x0 /* dev id, vendor id */
  65. #define PCI_IDX_ST_CMD 0x1 /* status, command */
  66. #define PCI_IDX_CLS_REV 0x2 /* class, revision */
  67. #define PCI_IDX_B_H_L_C 0x3 /* bist,hdr,lat,line_sz */
  68. #define PCI_IDX_BAR_0 0x4 /* base addr reg 0 */
  69. #define PCI_IDX_BAR_1 0x5 /* base addr reg 1 */
  70. #define PCI_IDX_BAR_2 0x6 /* base addr reg 2 */
  71. #define PCI_IDX_BAR_3 0x7 /* base addr reg 3 */
  72. #define PCI_IDX_BAR_4 0x8 /* base addr reg 4 */
  73. #define PCI_IDX_BAR_5 0x9 /* base addr reg 5 */
  74. #define PCI_IDX_CIS_PTR 0xA /* cardbus CIS ptr */
  75. #define PCI_IDX_SUB_SVID 0xB /* sub id, sub vendor id */
  76. #define PCI_IDX_EXP_ROM 0xC /* exp ROM Base Addr */
  77. #define PCI_IDX_RES_1 0xD /* reserved #1 */
  78. #define PCI_IDX_RES_2 0xE /* reserved #2 */
  79. #define PCI_IDX_L_G_I_I 0xF /* lat, grant, pin, lvl */
  80. /* Macros to isolate Byte, word fields */
  81. #define PCI_DEVICE_ID(x) (MSW(x))
  82. #define PCI_VENDOR_ID(x) (LSW(x))
  83. #define PCI_STATUS(x) (MSW(x))
  84. #define PCI_COMMAND(x) (LSW(x))
  85. #define PCI_CLASS(x) ((x)>>8)
  86. #define PCI_REVISION(x) (LLSB(x))
  87. #define PCI_BIST(x) (LMSB(x))
  88. #define PCI_HDR(x) (LNMSB(x))
  89. #define PCI_LAT_TMR(x) (LNLSB(x))
  90. #define PCI_CACHE_LN_SZ(x) (LLSB(x))
  91. #define PCI_MULTI_FUNC_HDR(x) ((x) & 0x00800000) /* if multi-func device */
  92. #define PCI_SUB_ID(x) (MSW(x))
  93. #define PCI_SUB_VDR_ID(x) (LSW(x))
  94. #define PCI_MAX_LAT(x) (LMSB(x))
  95. #define PCI_MIN_GNT(x) (LNMSB(x))
  96. #define PCI_INT_PIN(x) (LNLSB(x))
  97. #define PCI_INT_LINE(x) (LLSB(x))
  98. /* misc defines */
  99. #define PCI_CNFG_HDR_SIZE 0x40
  100. #define PCI_CNFG_HDR_LONGS 0x40 /* nbr of longs in header */
  101. /* define for ID_SEL of first PCI device on the PCI bus */
  102. #define PCI_DEV_IDSEL (1 << 11)
  103. #ifndef PCI_DEV_IDSEL_MAX
  104. #define PCI_DEV_IDSEL_MAX (31 - 10) /* max # of idsel lines */
  105. #endif  /* PCI_DEV_IDSEL_MAX */
  106. # define NUM_PCI_DEVS_MAX (6) /* #of dev idsel lines (slots)*/
  107. #define PCI_NUM_BAR NUM_PCI_DEVS_MAX /* nbr of base addr reg's */
  108. /* defines for configuration header */
  109. #define INVALID_VENDOR_ID 0xffff /* invalid vendor ID */
  110. /* device class definitions */
  111. /* device built before class code definitions were finalized */
  112. #define CLASS_BEFORE_STD 0x00
  113. #define CLASS_MASS_STORAGE 0x01 /* Mass storage controller */
  114. #define CLASS_NET_CNTLR 0x02 /* Network controller */
  115. #define CLASS_DISP_CNTLR 0x03 /* Display controller */
  116. #define CLASS_MULTI_MEDIA 0x04 /* multimedia device */
  117. #define CLASS_MEM_CNTLR 0x05 /* memory controller */
  118. #define CLASS_BRIDGE_DEV 0x06 /* bridge device */
  119. #define CLASS_COMM 0x07 /* simple communication controller */
  120. #define CLASS_PERIPH 0x08 /* base system peripherals */
  121. #define CLASS_INPUT 0x09 /* input devices */
  122. #define CLASS_DOCK 0x0a /* docking stations */
  123. #define CLASS_PROCESSOR 0x0b /* processors */
  124. #define CLASS_SERIAL_BUS 0x0c /* serial bus controllers */
  125. #define CLASS_WIRELESS 0x0d /* wireless controllers */
  126. #define CLASS_INTELLIGENT_IO 0x0e /* intelligent I/O controllers */
  127. #define CLASS_SATELLITE 0x0f /* satellite communications controllers */
  128. #define CLASS_ENCRYPT 0x10 /* encryption/decryption controllers */
  129. #define CLASS_DATA_ACQ 0x11 /* data acquisition controllers */
  130. #define CLASS_UNDEFINED 0xff /* not in any defined class */
  131. /* device sub classes */
  132. #define SUBCLASS_SCSI_CNTLR 0x00 /* SCSI bus controller */
  133. #define SUBCLASS_IDE_CNTLR 0x01 /* IDE controller */
  134. #define SUBCLASS_FLOPPY_CNTLR 0x02 /* Floppy disk Controller */
  135. #define SUBCLASS_IPI_CNTLR 0x03 /* IPI bus controller */
  136. #define SUBCLASS_ETHR_CNTLR 0x00 /* ethernet controller */
  137. #define SUBCLASS_TRNG_CNTLR 0x01 /* token ring controller */
  138. #define SUBCLASS_FDDI_CNTLR 0x02 /* FDDI controller */
  139. #define SUBCLASS_VGA_CNTLR 0x00 /* VGA compatible controller */
  140. #define SUBCLASS_XGA_CNTLR 0x01 /* XGA compatible controller */
  141. #define SUBCLASS_VIDEO 0x00 /* video */
  142. #define SUBCLASS_AUDIO 0x01 /* audio */
  143. #define SUBCLASS_RAM 0x00 /* ram device */
  144. #define SUBCLASS_FLASH 0x01 /* flash device */
  145. #define SUBCLASS_HST_BRDG 0x00 /* host bridge */
  146. #define SUBCLASS_ISA_BRDG 0x01 /* ISA bridge */
  147. #define SUBCLASS_EISA_BRDG 0x02 /* EISA bridge */
  148. #define SUBCLASS_MC_BRDG 0x03 /* MC bridge */
  149. #define SUBCLASS_PCI_PCI_BRDG 0x04 /* PCI to PCI bridge */
  150. #define SUBCLASS_PCMCIA_BRDG 0x05 /* PCMCIA bridge */
  151. #define SUBCLASS_PCI_NUBUS_BRDG 0x06 /* NUBus bridge */
  152. #define SUBCLASS_CARDBUS_BRDG 0x07 /* CardBus bridge */
  153. #define SUBCLASS_OTHER 0x80 /* other devices */
  154. /* command and status register layout, bits 10 - 22 are reserved */
  155. #define CSR_IO_EN 0x00000001 /* I/O address space enable */
  156. #define CSR_MEM_EN 0x00000002 /* memory space enable */
  157. #define CSR_BM_EN 0x00000004 /* bus master enable */
  158. #define CSR_SP_CYCLS_EN 0x00000008 /* special cycles enable */
  159. #define CSR_MEM_WRT_INV_EN 0x00000010 /* memry write & invalidate */
  160. #define CSR_VGA_PLT_SN_EN 0x00000020 /* VGA Pallette snoop */
  161. #define CSR_PARITY_EN 0x00000040 /* parity error response */
  162. #define CSR_WAIT_EN 0x00000080 /* wait cycle control */
  163. #define CSR_SERR_EN 0x00000100 /* SERR# enable */
  164. #define CSR_FST_BTOB_EN 0x00000200 /* Fast back to back Enable */
  165. /* status register layout */
  166. /* writing a 1 to any bit will reset that bit, writing 0 has no effect */
  167. #define CSR_66MHZ_CAP 0x00200000 /* 66 Mhz Capable */
  168. #define CSR_UDF_SUPP 0x00400000 /* UDF supported */
  169. #define CSR_FST_BTOB 0x00800000 /* Fast bk to bk Capable */
  170. #define CSR_DATA_PTY_DTD 0x01000000 /* Data parity detected */
  171. #define CSR_DEVSEL_FAST 0x00000000 /* DEVSEL timing fast */
  172. #define CSR_DEVSEL_MED 0x02000000 /* DEVSEL timing medium */
  173. #define CSR_DEVSEL_SLOW 0x04000000 /* DEVSEL timing slow */
  174. #define CSR_SGD_TGT_ABRT  0x08000000 /* signaled target abort */
  175. #define CSR_RCV_TGT_ABRT  0x10000000 /* received target abort */
  176. #define CSR_RCV_MST_ABRT  0x20000000 /* received master abort */
  177. #define CSR_SGD_SYS_ERR 0x40000000 /* signaled system error */
  178. #define CSR_DTD_PERR 0x80000000 /* detected parity error */
  179. /* BIST register layout */
  180. #define BIST_REG_BIST_CAPABLE 0x80 /* device supports BIST */
  181. #define BIST_REG_BIST_START 0x40 /* start built in self test */
  182. /* base address register for Memory */
  183. #define INDEX_IO 0x00
  184. #define INDEX_MEM 0x01
  185. #define BASE_ADDR_IO_MASK 0xfffffffc /* mask for IO base addrs */
  186. #define BASE_ADDR_MEM_MASK 0xfffffff0 /* mask for mem base addrs */
  187. #define BASE_ADDR_REG_IO_SPACE 0x00000001 /* device mapped in I/O */
  188. #define BASE_ADDR_REG_MEM_SPACE 0x00000000 /* device mapped in mem */
  189. #define BASE_ADDR_REG_MEM_4GIG 0x00000000 /* mapped in A32 space */
  190. #define BASE_ADDR_REG_MEM_1MEG 0x00000002 /* mapped in lower 1 Meg */
  191. #define BASE_ADDR_REG_MEM_ANY 0x00000004 /* mapped in A64 space */
  192. #define BASE_ADDR_REG_MEM_PFTCH 0x00000008 /* prefetechable bit */
  193. /* pci function declerations */
  194. #if defined(__STDC__) || defined(__cplusplus)
  195. IMPORT STATUS sysPciDevConfig (
  196. ULONG devPciCnfgAdrs,
  197. ULONG devIoBaseAdrs,
  198. ULONG devMemBaseAdrs,
  199. ULONG command,
  200. FUNCPTR devPciRoutine,
  201. ULONG devPciArg1,
  202. ULONG devPCiArg2
  203. );
  204. IMPORT STATUS sysPciDevProbe (ULONG, ULONG, ULONG *);
  205. IMPORT STATUS sysPciDevShow (ULONG *);
  206. #else
  207. IMPORT STATUS sysPciDevConfig ();
  208. IMPORT STATUS sysPciDevProbe ();
  209. IMPORT STATUS sysPciDevShow ();
  210. #endif /* __STDC__ */
  211. #ifdef __cplusplus
  212. }
  213. #endif
  214. #endif /* INCpciLocalBush */