00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef PCIREG_H_
00017 # define PCIREG_H_
00018
00019 #include <libc.h>
00020
00021 typedef u_int32_t pci_reg_t;
00022
00023
00024
00025
00026
00027 #define PCI_ID_REG 0x00
00028
00029 typedef u_int16_t pci_vendor_t;
00030 typedef u_int16_t pci_product_t;
00031
00032 #define PCI_VENDOR_SHIFT 0
00033 #define PCI_VENDOR_MASK 0xffff
00034 #define PCI_VENDOR(pci_id_reg) \
00035 (((pci_id_reg) >> PCI_VENDOR_SHIFT) & PCI_VENDOR_MASK)
00036
00037 #define PCI_PRODUCT_SHIFT 16
00038 #define PCI_PRODUCT_MASK 0xffff
00039 #define PCI_PRODUCT(pci_id_reg) \
00040 (((pci_id_reg) >> PCI_PRODUCT_SHIFT) & PCI_PRODUCT_MASK)
00041
00042
00043
00044
00045 #define PCI_COMMAND_STATUS_REG 0x04
00046
00047 #define PCI_COMMAND_SHIFT 0
00048 #define PCI_COMMAND_MASK 0xffff
00049 #define PCI_STATUS_SHIFT 16
00050 #define PCI_STATUS_MASK 0xffff
00051
00052 #define PCI_COMMAND_STATUS_CODE(command,status) \
00053 ((((command) & PCI_COMMAND_MASK) >> PCI_COMMAND_SHIFT) | \
00054 (((status) & PCI_STATUS_MASK) >> PCI_STATUS_SHIFT)) \
00055
00056 #define PCI_COMMAND_IO_ENABLE 0x00000001
00057 #define PCI_COMMAND_MEM_ENABLE 0x00000002
00058 #define PCI_COMMAND_MASTER_ENABLE 0x00000004
00059 #define PCI_COMMAND_SPECIAL_ENABLE 0x00000008
00060 #define PCI_COMMAND_INVALIDATE_ENABLE 0x00000010
00061 #define PCI_COMMAND_PALETTE_ENABLE 0x00000020
00062 #define PCI_COMMAND_PARITY_ENABLE 0x00000040
00063 #define PCI_COMMAND_STEPPING_ENABLE 0x00000080
00064 #define PCI_COMMAND_SERR_ENABLE 0x00000100
00065 #define PCI_COMMAND_BACKTOBACK_ENABLE 0x00000200
00066
00067 #define PCI_STATUS_CAPLIST_SUPPORT 0x00100000
00068 #define PCI_STATUS_66MHZ_SUPPORT 0x00200000
00069 #define PCI_STATUS_UDF_SUPPORT 0x00400000
00070 #define PCI_STATUS_BACKTOBACK_SUPPORT 0x00800000
00071 #define PCI_STATUS_PARITY_ERROR 0x01000000
00072 #define PCI_STATUS_DEVSEL_FAST 0x00000000
00073 #define PCI_STATUS_DEVSEL_MEDIUM 0x02000000
00074 #define PCI_STATUS_DEVSEL_SLOW 0x04000000
00075 #define PCI_STATUS_DEVSEL_MASK 0x06000000
00076 #define PCI_STATUS_TARGET_TARGET_ABORT 0x08000000
00077 #define PCI_STATUS_MASTER_TARGET_ABORT 0x10000000
00078 #define PCI_STATUS_MASTER_ABORT 0x20000000
00079 #define PCI_STATUS_SPECIAL_ERROR 0x40000000
00080 #define PCI_STATUS_PARITY_DETECT 0x80000000
00081
00082
00083
00084
00085 #define PCI_CLASS_REG 0x08
00086
00087 typedef u_int8_t pci_class_t;
00088 typedef u_int8_t pci_subclass_t;
00089 typedef u_int8_t pci_interface_t;
00090 typedef u_int8_t pci_revision_t;
00091
00092 #define PCI_CLASS_SHIFT 24
00093 #define PCI_CLASS_MASK 0xff
00094 #define PCI_CLASS(pci_class_reg) \
00095 (((pci_class_reg) >> PCI_CLASS_SHIFT) & PCI_CLASS_MASK)
00096
00097 #define PCI_SUBCLASS_SHIFT 16
00098 #define PCI_SUBCLASS_MASK 0xff
00099 #define PCI_SUBCLASS(pci_class_reg) \
00100 (((pci_class_reg) >> PCI_SUBCLASS_SHIFT) & PCI_SUBCLASS_MASK)
00101
00102 #define PCI_INTERFACE_SHIFT 8
00103 #define PCI_INTERFACE_MASK 0xff
00104 #define PCI_INTERFACE(pci_class_reg) \
00105 (((pci_class_reg) >> PCI_INTERFACE_SHIFT) & PCI_INTERFACE_MASK)
00106
00107 #define PCI_REVISION_SHIFT 0
00108 #define PCI_REVISION_MASK 0xff
00109 #define PCI_REVISION(pci_class_reg) \
00110 (((pci_class_reg) >> PCI_REVISION_SHIFT) & PCI_REVISION_MASK)
00111
00112
00113 #define PCI_CLASS_PREHISTORIC 0x00
00114 #define PCI_CLASS_MASS_STORAGE 0x01
00115 #define PCI_CLASS_NETWORK 0x02
00116 #define PCI_CLASS_DISPLAY 0x03
00117 #define PCI_CLASS_MULTIMEDIA 0x04
00118 #define PCI_CLASS_MEMORY 0x05
00119 #define PCI_CLASS_BRIDGE 0x06
00120 #define PCI_CLASS_COMMUNICATIONS 0x07
00121 #define PCI_CLASS_SYSTEM 0x08
00122 #define PCI_CLASS_INPUT 0x09
00123 #define PCI_CLASS_DOCK 0x0a
00124 #define PCI_CLASS_PROCESSOR 0x0b
00125 #define PCI_CLASS_SERIALBUS 0x0c
00126 #define PCI_CLASS_WIRELESS 0x0d
00127 #define PCI_CLASS_I2O 0x0e
00128 #define PCI_CLASS_SATCOM 0x0f
00129 #define PCI_CLASS_CRYPTO 0x10
00130 #define PCI_CLASS_DASP 0x11
00131 #define PCI_CLASS_UNDEFINED 0xff
00132
00133
00134 #define PCI_SUBCLASS_PREHISTORIC_MISC 0x00
00135 #define PCI_SUBCLASS_PREHISTORIC_VGA 0x01
00136
00137
00138 #define PCI_SUBCLASS_MASS_STORAGE_SCSI 0x00
00139 #define PCI_SUBCLASS_MASS_STORAGE_IDE 0x01
00140 #define PCI_SUBCLASS_MASS_STORAGE_FLOPPY 0x02
00141 #define PCI_SUBCLASS_MASS_STORAGE_IPI 0x03
00142 #define PCI_SUBCLASS_MASS_STORAGE_RAID 0x04
00143 #define PCI_SUBCLASS_MASS_STORAGE_ATA 0x05
00144 #define PCI_SUBCLASS_MASS_STORAGE_SATA 0x06
00145 #define PCI_SUBCLASS_MASS_STORAGE_MISC 0x80
00146
00147
00148 #define PCI_SUBCLASS_NETWORK_ETHERNET 0x00
00149 #define PCI_SUBCLASS_NETWORK_TOKENRING 0x01
00150 #define PCI_SUBCLASS_NETWORK_FDDI 0x02
00151 #define PCI_SUBCLASS_NETWORK_ATM 0x03
00152 #define PCI_SUBCLASS_NETWORK_ISDN 0x04
00153 #define PCI_SUBCLASS_NETWORK_WORLDFIP 0x05
00154 #define PCI_SUBCLASS_NETWORK_PCIMGMULTICOMP 0x06
00155 #define PCI_SUBCLASS_NETWORK_MISC 0x80
00156
00157
00158 #define PCI_SUBCLASS_DISPLAY_VGA 0x00
00159 #define PCI_SUBCLASS_DISPLAY_XGA 0x01
00160 #define PCI_SUBCLASS_DISPLAY_3D 0x02
00161 #define PCI_SUBCLASS_DISPLAY_MISC 0x80
00162
00163
00164 #define PCI_SUBCLASS_MULTIMEDIA_VIDEO 0x00
00165 #define PCI_SUBCLASS_MULTIMEDIA_AUDIO 0x01
00166 #define PCI_SUBCLASS_MULTIMEDIA_TELEPHONY 0x02
00167 #define PCI_SUBCLASS_MULTIMEDIA_MISC 0x80
00168
00169
00170 #define PCI_SUBCLASS_MEMORY_RAM 0x00
00171 #define PCI_SUBCLASS_MEMORY_FLASH 0x01
00172 #define PCI_SUBCLASS_MEMORY_MISC 0x80
00173
00174
00175 #define PCI_SUBCLASS_BRIDGE_HOST 0x00
00176 #define PCI_SUBCLASS_BRIDGE_ISA 0x01
00177 #define PCI_SUBCLASS_BRIDGE_EISA 0x02
00178 #define PCI_SUBCLASS_BRIDGE_MC 0x03
00179 #define PCI_SUBCLASS_BRIDGE_PCI 0x04
00180 #define PCI_SUBCLASS_BRIDGE_PCMCIA 0x05
00181 #define PCI_SUBCLASS_BRIDGE_NUBUS 0x06
00182 #define PCI_SUBCLASS_BRIDGE_CARDBUS 0x07
00183 #define PCI_SUBCLASS_BRIDGE_RACEWAY 0x08
00184 #define PCI_SUBCLASS_BRIDGE_STPCI 0x09
00185 #define PCI_SUBCLASS_BRIDGE_INFINIBAND 0x0a
00186 #define PCI_SUBCLASS_BRIDGE_MISC 0x80
00187
00188
00189 #define PCI_SUBCLASS_COMMUNICATIONS_SERIAL 0x00
00190 #define PCI_SUBCLASS_COMMUNICATIONS_PARALLEL 0x01
00191 #define PCI_SUBCLASS_COMMUNICATIONS_MPSERIAL 0x02
00192 #define PCI_SUBCLASS_COMMUNICATIONS_MODEM 0x03
00193 #define PCI_SUBCLASS_COMMUNICATIONS_GPIB 0x04
00194 #define PCI_SUBCLASS_COMMUNICATIONS_SMARTCARD 0x05
00195 #define PCI_SUBCLASS_COMMUNICATIONS_MISC 0x80
00196
00197
00198 #define PCI_SUBCLASS_SYSTEM_PIC 0x00
00199 #define PCI_SUBCLASS_SYSTEM_DMA 0x01
00200 #define PCI_SUBCLASS_SYSTEM_TIMER 0x02
00201 #define PCI_SUBCLASS_SYSTEM_RTC 0x03
00202 #define PCI_SUBCLASS_SYSTEM_PCIHOTPLUG 0x04
00203 #define PCI_SUBCLASS_SYSTEM_MISC 0x80
00204
00205
00206 #define PCI_SUBCLASS_INPUT_KEYBOARD 0x00
00207 #define PCI_SUBCLASS_INPUT_DIGITIZER 0x01
00208 #define PCI_SUBCLASS_INPUT_MOUSE 0x02
00209 #define PCI_SUBCLASS_INPUT_SCANNER 0x03
00210 #define PCI_SUBCLASS_INPUT_GAMEPORT 0x04
00211 #define PCI_SUBCLASS_INPUT_MISC 0x80
00212
00213
00214 #define PCI_SUBCLASS_DOCK_GENERIC 0x00
00215 #define PCI_SUBCLASS_DOCK_MISC 0x80
00216
00217
00218 #define PCI_SUBCLASS_PROCESSOR_386 0x00
00219 #define PCI_SUBCLASS_PROCESSOR_486 0x01
00220 #define PCI_SUBCLASS_PROCESSOR_PENTIUM 0x02
00221 #define PCI_SUBCLASS_PROCESSOR_ALPHA 0x10
00222 #define PCI_SUBCLASS_PROCESSOR_POWERPC 0x20
00223 #define PCI_SUBCLASS_PROCESSOR_MIPS 0x30
00224 #define PCI_SUBCLASS_PROCESSOR_COPROC 0x40
00225
00226
00227 #define PCI_SUBCLASS_SERIALBUS_FIREWIRE 0x00
00228 #define PCI_SUBCLASS_SERIALBUS_ACCESS 0x01
00229 #define PCI_SUBCLASS_SERIALBUS_SSA 0x02
00230 #define PCI_SUBCLASS_SERIALBUS_USB 0x03
00231 #define PCI_SUBCLASS_SERIALBUS_FIBER 0x04
00232 #define PCI_SUBCLASS_SERIALBUS_SMBUS 0x05
00233 #define PCI_SUBCLASS_SERIALBUS_INFINIBAND 0x06
00234 #define PCI_SUBCLASS_SERIALBUS_IPMI 0x07
00235 #define PCI_SUBCLASS_SERIALBUS_SERCOS 0x08
00236 #define PCI_SUBCLASS_SERIALBUS_CANBUS 0x09
00237
00238
00239 #define PCI_SUBCLASS_WIRELESS_IRDA 0x00
00240 #define PCI_SUBCLASS_WIRELESS_CONSUMERIR 0x01
00241 #define PCI_SUBCLASS_WIRELESS_RF 0x10
00242 #define PCI_SUBCLASS_WIRELESS_BLUETOOTH 0x11
00243 #define PCI_SUBCLASS_WIRELESS_BROADBAND 0x12
00244 #define PCI_SUBCLASS_WIRELESS_802_11A 0x20
00245 #define PCI_SUBCLASS_WIRELESS_802_11B 0x21
00246 #define PCI_SUBCLASS_WIRELESS_MISC 0x80
00247
00248
00249 #define PCI_SUBCLASS_I2O_STANDARD 0x00
00250
00251
00252
00253 #define PCI_SUBCLASS_SATCOM_TV 0x01
00254 #define PCI_SUBCLASS_SATCOM_AUDIO 0x02
00255 #define PCI_SUBCLASS_SATCOM_VOICE 0x03
00256 #define PCI_SUBCLASS_SATCOM_DATA 0x04
00257
00258
00259 #define PCI_SUBCLASS_CRYPTO_NETCOMP 0x00
00260 #define PCI_SUBCLASS_CRYPTO_ENTERTAINMENT 0x10
00261 #define PCI_SUBCLASS_CRYPTO_MISC 0x80
00262
00263
00264 #define PCI_SUBCLASS_DASP_DPIO 0x00
00265 #define PCI_SUBCLASS_DASP_TIMEFREQ 0x01
00266 #define PCI_SUBCLASS_DASP_SYNC 0x10
00267 #define PCI_SUBCLASS_DASP_MGMT 0x20
00268 #define PCI_SUBCLASS_DASP_MISC 0x80
00269
00270
00271
00272
00273 #define PCI_BHLC_REG 0x0c
00274
00275 #define PCI_BIST_SHIFT 24
00276 #define PCI_BIST_MASK 0xff
00277 #define PCI_BIST(pci_bhlc_reg) \
00278 (((pci_bhlc_reg) >> PCI_BIST_SHIFT) & PCI_BIST_MASK)
00279
00280 #define PCI_HDRTYPE_SHIFT 16
00281 #define PCI_HDRTYPE_MASK 0xff
00282 #define PCI_HDRTYPE(pci_bhlc_reg) \
00283 (((pci_bhlc_reg) >> PCI_HDRTYPE_SHIFT) & PCI_HDRTYPE_MASK)
00284
00285 #define PCI_HDRTYPE_TYPE(pci_bhlc_reg) \
00286 (PCI_HDRTYPE(pci_bhlc_reg) & 0x7f)
00287 #define PCI_HDRTYPE_MULTIFN(pci_bhlc_reg) \
00288 ((PCI_HDRTYPE(pci_bhlc_reg) & 0x80) != 0)
00289
00290 #define PCI_LATTIMER_SHIFT 8
00291 #define PCI_LATTIMER_MASK 0xff
00292 #define PCI_LATTIMER(pci_bhlc_reg) \
00293 (((pci_bhlc_reg) >> PCI_LATTIMER_SHIFT) & PCI_LATTIMER_MASK)
00294
00295 #define PCI_CACHELINE_SHIFT 0
00296 #define PCI_CACHELINE_MASK 0xff
00297 #define PCI_CACHELINE(pci_bhlc_reg) \
00298 (((pci_bhlc_reg) >> PCI_CACHELINE_SHIFT) & PCI_CACHELINE_MASK)
00299
00300 #define PCI_BHLC_CODE(bist,type,multi,latency,cacheline) \
00301 ((((bist) & PCI_BIST_MASK) << PCI_BIST_SHIFT) | \
00302 (((type) & PCI_HDRTYPE_MASK) << PCI_HDRTYPE_SHIFT) | \
00303 (((multi)?0x80:0) << PCI_HDRTYPE_SHIFT) | \
00304 (((latency) & PCI_LATTIMER_MASK) << PCI_LATTIMER_SHIFT) | \
00305 (((cacheline) & PCI_CACHELINE_MASK) << PCI_CACHELINE_SHIFT))
00306
00307 #define PCI_HDRTYPE_DEVICE 0
00308 #define PCI_HDRTYPE_PPB 1
00309 #define PCI_HDRTYPE_PCB 2
00310
00311
00312
00313
00314 #define PCI_MAPREG_START 0x10
00315 #define PCI_MAPREG_END 0x28
00316
00317 #define PCI_MAPREG_ROM 0x30
00318 #define PCI_MAPREG_PPB_END 0x18
00319 #define PCI_MAPREG_PCB_END 0x14
00320
00321 #define PCI_MAPREG_TYPE_MASK 0x00000001
00322 #define PCI_MAPREG_TYPE(pci_map_reg) \
00323 ((pci_map_reg) & PCI_MAPREG_TYPE_MASK)
00324
00325 #define PCI_MAPREG_TYPE_MEM 0x00000000
00326 #define PCI_MAPREG_TYPE_IO 0x00000001
00327 #define PCI_MAPREG_ROM_ENABLE 0x00000001
00328
00329 #define PCI_MAPREG_MEM_TYPE_MASK 0x00000006
00330 #define PCI_MAPREG_MEM_TYPE(pci_map_reg) \
00331 ((pci_map_reg) & PCI_MAPREG_MEM_TYPE_MASK)
00332
00333 #define PCI_MAPREG_MEM_TYPE_32BIT 0x00000000
00334 #define PCI_MAPREG_MEM_TYPE_32BIT_1M 0x00000002
00335 #define PCI_MAPREG_MEM_TYPE_64BIT 0x00000004
00336
00337 #define PCI_MAPREG_MEM_PREFETCHABLE_MASK 0x00000008
00338 #define PCI_MAPREG_MEM_PREFETCHABLE(pci_map_reg) \
00339 (((pci_map_reg) & PCI_MAPREG_MEM_PREFETCHABLE_MASK) != 0)
00340
00341 #define PCI_MAPREG_MEM_ADDR(pci_map_reg) \
00342 ((pci_map_reg) & PCI_MAPREG_MEM_ADDR_MASK)
00343 #define PCI_MAPREG_MEM_SIZE(pci_map_reg) \
00344 (PCI_MAPREG_MEM_ADDR(pci_map_reg) & -PCI_MAPREG_MEM_ADDR(pci_map_reg))
00345 #define PCI_MAPREG_MEM_ADDR_MASK 0xfffffff0
00346
00347 #define PCI_MAPREG_MEM64_ADDR(pci_map_reg) \
00348 ((pci_map_reg) & PCI_MAPREG_MEM64_ADDR_MASK)
00349 #define PCI_MAPREG_MEM64_SIZE(pci_map_reg) \
00350 (PCI_MAPREG_MEM64_ADDR(pci_map_reg) & -PCI_MAPREG_MEM64_ADDR(pci_map_reg))
00351 #define PCI_MAPREG_MEM64_ADDR_MASK 0xfffffffffffffff0ULL
00352
00353 #define PCI_MAPREG_IO_ADDR(pci_map_reg) \
00354 ((pci_map_reg) & PCI_MAPREG_IO_ADDR_MASK)
00355 #define PCI_MAPREG_IO_SIZE(pci_map_reg) \
00356 (PCI_MAPREG_IO_ADDR(pci_map_reg) & -PCI_MAPREG_IO_ADDR(pci_map_reg))
00357 #define PCI_MAPREG_IO_ADDR_MASK 0xfffffffc
00358
00359 #define PCI_MAPREG_SIZE_TO_MASK(size) \
00360 (-(size))
00361
00362 #define PCI_MAPREG_NUM(offset) \
00363 (((unsigned)(offset)-PCI_MAPREG_START)/4)
00364
00365
00366
00367
00368 #define PCI_CARDBUS_CIS_REG 0x28
00369
00370
00371
00372
00373
00374
00375 #define PCI_SUBSYS_ID_REG 0x2c
00376
00377
00378
00379
00380 #define PCI_INTERRUPT_REG 0x3c
00381
00382 typedef u_int8_t pci_intr_latency_t;
00383 typedef u_int8_t pci_intr_grant_t;
00384 typedef u_int8_t pci_intr_pin_t;
00385 typedef u_int8_t pci_intr_line_t;
00386
00387 #define PCI_MAX_LAT_SHIFT 24
00388 #define PCI_MAX_LAT_MASK 0xff
00389 #define PCI_MAX_LAT(icr) \
00390 (((icr) >> PCI_MAX_LAT_SHIFT) & PCI_MAX_LAT_MASK)
00391
00392 #define PCI_MIN_GNT_SHIFT 16
00393 #define PCI_MIN_GNT_MASK 0xff
00394 #define PCI_MIN_GNT(icr) \
00395 (((icr) >> PCI_MIN_GNT_SHIFT) & PCI_MIN_GNT_MASK)
00396
00397 #define PCI_INTERRUPT_GRANT_SHIFT 24
00398 #define PCI_INTERRUPT_GRANT_MASK 0xff
00399 #define PCI_INTERRUPT_GRANT(icr) \
00400 (((icr) >> PCI_INTERRUPT_GRANT_SHIFT) & PCI_INTERRUPT_GRANT_MASK)
00401
00402 #define PCI_INTERRUPT_LATENCY_SHIFT 16
00403 #define PCI_INTERRUPT_LATENCY_MASK 0xff
00404 #define PCI_INTERRUPT_LATENCY(icr) \
00405 (((icr) >> PCI_INTERRUPT_LATENCY_SHIFT) & PCI_INTERRUPT_LATENCY_MASK)
00406
00407 #define PCI_INTERRUPT_PIN_SHIFT 8
00408 #define PCI_INTERRUPT_PIN_MASK 0xff
00409 #define PCI_INTERRUPT_PIN(icr) \
00410 (((icr) >> PCI_INTERRUPT_PIN_SHIFT) & PCI_INTERRUPT_PIN_MASK)
00411
00412 #define PCI_INTERRUPT_LINE_SHIFT 0
00413 #define PCI_INTERRUPT_LINE_MASK 0xff
00414 #define PCI_INTERRUPT_LINE(icr) \
00415 (((icr) >> PCI_INTERRUPT_LINE_SHIFT) & PCI_INTERRUPT_LINE_MASK)
00416
00417 #define PCI_INTERRUPT_CODE(lat,gnt,pin,line) \
00418 ((((lat)&PCI_INTERRUPT_LATENCY_MASK)<<PCI_INTERRUPT_LATENCY_SHIFT)| \
00419 (((gnt)&PCI_INTERRUPT_GRANT_MASK) <<PCI_INTERRUPT_GRANT_SHIFT) | \
00420 (((pin)&PCI_INTERRUPT_PIN_MASK) <<PCI_INTERRUPT_PIN_SHIFT) | \
00421 (((line)&PCI_INTERRUPT_LINE_MASK) <<PCI_INTERRUPT_LINE_SHIFT))
00422
00423 #define PCI_INTERRUPT_PIN_NONE 0x00
00424 #define PCI_INTERRUPT_PIN_A 0x01
00425 #define PCI_INTERRUPT_PIN_B 0x02
00426 #define PCI_INTERRUPT_PIN_C 0x03
00427 #define PCI_INTERRUPT_PIN_D 0x04
00428 #define PCI_INTERRUPT_PIN_MAX 0x04
00429
00430 #endif