io.h 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269
  1. /*
  2. * programmable interrupt vectors (for the 8259's)
  3. */
  4. enum
  5. {
  6. Bptvec= 3, /* breakpoints */
  7. Mathemuvec= 7, /* math coprocessor emulation interrupt */
  8. Mathovervec= 9, /* math coprocessor overrun interrupt */
  9. Matherr1vec= 16, /* math coprocessor error interrupt */
  10. Faultvec= 14, /* page fault */
  11. Syscallvec= 64,
  12. VectorPIC = 24, /* external [A]PIC interrupts */
  13. VectorCLOCK = VectorPIC+0,
  14. VectorKBD = VectorPIC+1,
  15. VectorUART1 = VectorPIC+3,
  16. VectorUART0 = VectorPIC+4,
  17. VectorPCMCIA = VectorPIC+5,
  18. VectorFLOPPY = VectorPIC+6,
  19. VectorLPT = VectorPIC+7,
  20. VectorIRQ7 = VectorPIC+7,
  21. VectorAUX = VectorPIC+12, /* PS/2 port */
  22. VectorIRQ13 = VectorPIC+13, /* coprocessor on x386 */
  23. VectorATA0 = VectorPIC+14,
  24. VectorATA1 = VectorPIC+15,
  25. MaxVectorPIC = VectorPIC+15,
  26. };
  27. enum {
  28. BusCBUS = 0, /* Corollary CBUS */
  29. BusCBUSII, /* Corollary CBUS II */
  30. BusEISA, /* Extended ISA */
  31. BusFUTURE, /* IEEE Futurebus */
  32. BusINTERN, /* Internal bus */
  33. BusISA, /* Industry Standard Architecture */
  34. BusMBI, /* Multibus I */
  35. BusMBII, /* Multibus II */
  36. BusMCA, /* Micro Channel Architecture */
  37. BusMPI, /* MPI */
  38. BusMPSA, /* MPSA */
  39. BusNUBUS, /* Apple Macintosh NuBus */
  40. BusPCI, /* Peripheral Component Interconnect */
  41. BusPCMCIA, /* PC Memory Card International Association */
  42. BusTC, /* DEC TurboChannel */
  43. BusVL, /* VESA Local bus */
  44. BusVME, /* VMEbus */
  45. BusXPRESS, /* Express System Bus */
  46. };
  47. #define MKBUS(t,b,d,f) (((t)<<24)|(((b)&0xFF)<<16)|(((d)&0x1F)<<11)|(((f)&0x07)<<8))
  48. #define BUSFNO(tbdf) (((tbdf)>>8)&0x07)
  49. #define BUSDNO(tbdf) (((tbdf)>>11)&0x1F)
  50. #define BUSBNO(tbdf) (((tbdf)>>16)&0xFF)
  51. #define BUSTYPE(tbdf) ((tbdf)>>24)
  52. #define BUSBDF(tbdf) ((tbdf)&0x00FFFF00)
  53. #define BUSUNKNOWN (-1)
  54. enum {
  55. MaxEISA = 16,
  56. CfgEISA = 0xC80,
  57. };
  58. /*
  59. * PCI support code.
  60. */
  61. enum { /* type 0 and type 1 pre-defined header */
  62. PciVID = 0x00, /* vendor ID */
  63. PciDID = 0x02, /* device ID */
  64. PciPCR = 0x04, /* command */
  65. PciPSR = 0x06, /* status */
  66. PciRID = 0x08, /* revision ID */
  67. PciCCRp = 0x09, /* programming interface class code */
  68. PciCCRu = 0x0A, /* sub-class code */
  69. PciCCRb = 0x0B, /* base class code */
  70. PciCLS = 0x0C, /* cache line size */
  71. PciLTR = 0x0D, /* latency timer */
  72. PciHDT = 0x0E, /* header type */
  73. PciBST = 0x0F, /* BIST */
  74. PciBAR0 = 0x10, /* base address */
  75. PciBAR1 = 0x14,
  76. PciINTL = 0x3C, /* interrupt line */
  77. PciINTP = 0x3D, /* interrupt pin */
  78. };
  79. enum { /* type 0 pre-defined header */
  80. PciBAR2 = 0x18,
  81. PciBAR3 = 0x1C,
  82. PciBAR4 = 0x20,
  83. PciBAR5 = 0x24,
  84. PciCIS = 0x28, /* cardbus CIS pointer */
  85. PciSVID = 0x2C, /* subsystem vendor ID */
  86. PciSID = 0x2E, /* cardbus CIS pointer */
  87. PciEBAR0 = 0x30, /* expansion ROM base address */
  88. PciMGNT = 0x3E, /* burst period length */
  89. PciMLT = 0x3F, /* maximum latency between bursts */
  90. };
  91. enum { /* type 1 pre-defined header */
  92. PciPBN = 0x18, /* primary bus number */
  93. PciSBN = 0x19, /* secondary bus number */
  94. PciUBN = 0x1A, /* subordinate bus number */
  95. PciSLTR = 0x1B, /* secondary latency timer */
  96. PciIBR = 0x1C, /* I/O base */
  97. PciILR = 0x1D, /* I/O limit */
  98. PciSPSR = 0x1E, /* secondary status */
  99. PciMBR = 0x20, /* memory base */
  100. PciMLR = 0x22, /* memory limit */
  101. PciPMBR = 0x24, /* prefetchable memory base */
  102. PciPMLR = 0x26, /* prefetchable memory limit */
  103. PciPUBR = 0x28, /* prefetchable base upper 32 bits */
  104. PciPULR = 0x2C, /* prefetchable limit upper 32 bits */
  105. PciIUBR = 0x30, /* I/O base upper 16 bits */
  106. PciIULR = 0x32, /* I/O limit upper 16 bits */
  107. PciEBAR1 = 0x28, /* expansion ROM base address */
  108. PciBCR = 0x3E, /* bridge control register */
  109. };
  110. enum { /* type 2 pre-defined header */
  111. PciCBExCA = 0x10,
  112. PciCBSPSR = 0x16,
  113. PciCBPBN = 0x18, /* primary bus number */
  114. PciCBSBN = 0x19, /* secondary bus number */
  115. PciCBUBN = 0x1A, /* subordinate bus number */
  116. PciCBSLTR = 0x1B, /* secondary latency timer */
  117. PciCBMBR0 = 0x1C,
  118. PciCBMLR0 = 0x20,
  119. PciCBMBR1 = 0x24,
  120. PciCBMLR1 = 0x28,
  121. PciCBIBR0 = 0x2C, /* I/O base */
  122. PciCBILR0 = 0x30, /* I/O limit */
  123. PciCBIBR1 = 0x34, /* I/O base */
  124. PciCBILR1 = 0x38, /* I/O limit */
  125. PciCBBCTL = 0x3E, /* Bridge control */
  126. PciCBSVID = 0x40, /* subsystem vendor ID */
  127. PciCBSID = 0x42, /* subsystem ID */
  128. PciCBLMBAR = 0x44, /* legacy mode base address */
  129. };
  130. typedef struct Pcisiz Pcisiz;
  131. struct Pcisiz
  132. {
  133. Pcidev* dev;
  134. int siz;
  135. int bar;
  136. };
  137. typedef struct Pcidev Pcidev;
  138. typedef struct Pcidev {
  139. int tbdf; /* type+bus+device+function */
  140. ushort vid; /* vendor ID */
  141. ushort did; /* device ID */
  142. ushort pcr;
  143. uchar rid;
  144. uchar ccrp;
  145. uchar ccru;
  146. uchar ccrb;
  147. uchar cls;
  148. uchar ltr;
  149. struct {
  150. ulong bar; /* base address */
  151. int size;
  152. } mem[6];
  153. struct {
  154. ulong bar;
  155. int size;
  156. } rom;
  157. uchar intl; /* interrupt line */
  158. Pcidev* list;
  159. Pcidev* link; /* next device on this bno */
  160. Pcidev* bridge; /* down a bus */
  161. struct {
  162. ulong bar;
  163. int size;
  164. } ioa, mema;
  165. int pmrb; /* power management register block */
  166. };
  167. #define PCIWINDOW 0
  168. #define PCIWADDR(va) (PADDR(va)+PCIWINDOW)
  169. #define ISAWINDOW 0
  170. #define ISAWADDR(va) (PADDR(va)+ISAWINDOW)
  171. /*
  172. * PCMCIA support code.
  173. */
  174. typedef struct PCMslot PCMslot;
  175. typedef struct PCMconftab PCMconftab;
  176. /*
  177. * Map between ISA memory space and PCMCIA card memory space.
  178. */
  179. struct PCMmap {
  180. ulong ca; /* card address */
  181. ulong cea; /* card end address */
  182. ulong isa; /* ISA address */
  183. int len; /* length of the ISA area */
  184. int attr; /* attribute memory */
  185. int ref;
  186. };
  187. /* configuration table entry */
  188. struct PCMconftab
  189. {
  190. int index;
  191. ushort irqs; /* legal irqs */
  192. uchar irqtype;
  193. uchar bit16; /* true for 16 bit access */
  194. struct {
  195. ulong start;
  196. ulong len;
  197. } io[16];
  198. int nio;
  199. uchar vpp1;
  200. uchar vpp2;
  201. uchar memwait;
  202. ulong maxwait;
  203. ulong readywait;
  204. ulong otherwait;
  205. };
  206. /* a card slot */
  207. struct PCMslot
  208. {
  209. Lock;
  210. int ref;
  211. void *cp; /* controller for this slot */
  212. long memlen; /* memory length */
  213. uchar base; /* index register base */
  214. uchar slotno; /* slot number */
  215. /* status */
  216. uchar special; /* in use for a special device */
  217. uchar already; /* already inited */
  218. uchar occupied;
  219. uchar battery;
  220. uchar wrprot;
  221. uchar powered;
  222. uchar configed;
  223. uchar enabled;
  224. uchar busy;
  225. /* cis info */
  226. ulong msec; /* time of last slotinfo call */
  227. char verstr[512]; /* version string */
  228. int ncfg; /* number of configurations */
  229. struct {
  230. ushort cpresent; /* config registers present */
  231. ulong caddr; /* relative address of config registers */
  232. } cfg[8];
  233. int nctab; /* number of config table entries */
  234. PCMconftab ctab[8];
  235. PCMconftab *def; /* default conftab */
  236. /* memory maps */
  237. Lock mlock; /* lock down the maps */
  238. int time;
  239. PCMmap mmap[4]; /* maps, last is always for the kernel */
  240. };