pci.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. enum {
  2. BusCBUS = 0, /* Corollary CBUS */
  3. BusCBUSII, /* Corollary CBUS II */
  4. BusEISA, /* Extended ISA */
  5. BusFUTURE, /* IEEE Futurebus */
  6. BusINTERN, /* Internal bus */
  7. BusISA, /* Industry Standard Architecture */
  8. BusMBI, /* Multibus I */
  9. BusMBII, /* Multibus II */
  10. BusMCA, /* Micro Channel Architecture */
  11. BusMPI, /* MPI */
  12. BusMPSA, /* MPSA */
  13. BusNUBUS, /* Apple Macintosh NuBus */
  14. BusPCI, /* Peripheral Component Interconnect */
  15. BusPCMCIA, /* PC Memory Card International Association */
  16. BusTC, /* DEC TurboChannel */
  17. BusVL, /* VESA Local bus */
  18. BusVME, /* VMEbus */
  19. BusXPRESS, /* Express System Bus */
  20. };
  21. #define MKBUS(t,b,d,f) (((t)<<24)|(((b)&0xFF)<<16)|(((d)&0x1F)<<11)|(((f)&0x07)<<8))
  22. #define BUSFNO(tbdf) (((tbdf)>>8)&0x07)
  23. #define BUSDNO(tbdf) (((tbdf)>>11)&0x1F)
  24. #define BUSBNO(tbdf) (((tbdf)>>16)&0xFF)
  25. #define BUSTYPE(tbdf) ((tbdf)>>24)
  26. #define BUSBDF(tbdf) ((tbdf)&0x00FFFF00)
  27. #define BUSUNKNOWN (-1)
  28. /*
  29. * PCI support code.
  30. */
  31. enum { /* type 0 and type 1 pre-defined header */
  32. PciVID = 0x00, /* vendor ID */
  33. PciDID = 0x02, /* device ID */
  34. PciPCR = 0x04, /* command */
  35. PciPSR = 0x06, /* status */
  36. PciRID = 0x08, /* revision ID */
  37. PciCCRp = 0x09, /* programming interface class code */
  38. PciCCRu = 0x0A, /* sub-class code */
  39. PciCCRb = 0x0B, /* base class code */
  40. PciCLS = 0x0C, /* cache line size */
  41. PciLTR = 0x0D, /* latency timer */
  42. PciHDT = 0x0E, /* header type */
  43. PciBST = 0x0F, /* BIST */
  44. PciBAR0 = 0x10, /* base address */
  45. PciBAR1 = 0x14,
  46. PciINTL = 0x3C, /* interrupt line */
  47. PciINTP = 0x3D, /* interrupt pin */
  48. };
  49. enum { /* type 0 pre-defined header */
  50. PciBAR2 = 0x18,
  51. PciBAR3 = 0x1C,
  52. PciBAR4 = 0x20,
  53. PciBAR5 = 0x24,
  54. PciCIS = 0x28, /* cardbus CIS pointer */
  55. PciSVID = 0x2C, /* subsystem vendor ID */
  56. PciSID = 0x2E, /* cardbus CIS pointer */
  57. PciEBAR0 = 0x30, /* expansion ROM base address */
  58. PciMGNT = 0x3E, /* burst period length */
  59. PciMLT = 0x3F, /* maximum latency between bursts */
  60. };
  61. enum { /* type 1 pre-defined header */
  62. PciPBN = 0x18, /* primary bus number */
  63. PciSBN = 0x19, /* secondary bus number */
  64. PciUBN = 0x1A, /* subordinate bus number */
  65. PciSLTR = 0x1B, /* secondary latency timer */
  66. PciIBR = 0x1C, /* I/O base */
  67. PciILR = 0x1D, /* I/O limit */
  68. PciSPSR = 0x1E, /* secondary status */
  69. PciMBR = 0x20, /* memory base */
  70. PciMLR = 0x22, /* memory limit */
  71. PciPMBR = 0x24, /* prefetchable memory base */
  72. PciPMLR = 0x26, /* prefetchable memory limit */
  73. PciPUBR = 0x28, /* prefetchable base upper 32 bits */
  74. PciPULR = 0x2C, /* prefetchable limit upper 32 bits */
  75. PciIUBR = 0x30, /* I/O base upper 16 bits */
  76. PciIULR = 0x32, /* I/O limit upper 16 bits */
  77. PciEBAR1 = 0x28, /* expansion ROM base address */
  78. PciBCR = 0x3E, /* bridge control register */
  79. };
  80. typedef struct Pcidev Pcidev;
  81. typedef struct Pcidev {
  82. int tbdf; /* type+bus+device+function */
  83. ushort vid; /* vendor ID */
  84. ushort did; /* device ID */
  85. uchar rid; /* revision ID */
  86. struct {
  87. ulong bar; /* base address */
  88. int size;
  89. } mem[6];
  90. uchar intl; /* interrupt line */
  91. ushort ccru;
  92. Pcidev* list;
  93. Pcidev* bridge; /* down a bus */
  94. Pcidev* link; /* next device on this bno */
  95. };