123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- #ifndef _GPXE_PCI_H
- #define _GPXE_PCI_H
-
-
-
-
-
- #include <stdint.h>
- #include <gpxe/device.h>
- #include <gpxe/tables.h>
- #include <pci_io.h>
- #include "pci_ids.h"
-
-
-
- #define PCI_COMMAND_IO 0x1
- #define PCI_COMMAND_MEM 0x2
- #define PCI_COMMAND_MASTER 0x4
-
- #define PCI_CACHE_LINE_SIZE 0x0c
- #define PCI_LATENCY_TIMER 0x0d
-
- #define PCI_COMMAND_SPECIAL 0x8
- #define PCI_COMMAND_INVALIDATE 0x10
- #define PCI_COMMAND_VGA_PALETTE 0x20
- #define PCI_COMMAND_PARITY 0x40
- #define PCI_COMMAND_WAIT 0x80
- #define PCI_COMMAND_SERR 0x100
- #define PCI_COMMAND_FAST_BACK 0x200
-
-
- #define PCI_VENDOR_ID 0x00
- #define PCI_DEVICE_ID 0x02
- #define PCI_COMMAND 0x04
-
- #define PCI_STATUS 0x06
- #define PCI_STATUS_CAP_LIST 0x10
- #define PCI_STATUS_66MHZ 0x20
- #define PCI_STATUS_UDF 0x40
- #define PCI_STATUS_FAST_BACK 0x80
- #define PCI_STATUS_PARITY 0x100
- #define PCI_STATUS_DEVSEL_MASK 0x600
- #define PCI_STATUS_DEVSEL_FAST 0x000
- #define PCI_STATUS_DEVSEL_MEDIUM 0x200
- #define PCI_STATUS_DEVSEL_SLOW 0x400
- #define PCI_STATUS_SIG_TARGET_ABORT 0x800
- #define PCI_STATUS_REC_TARGET_ABORT 0x1000
- #define PCI_STATUS_REC_MASTER_ABORT 0x2000
- #define PCI_STATUS_SIG_SYSTEM_ERROR 0x4000
- #define PCI_STATUS_DETECTED_PARITY 0x8000
-
- #define PCI_REVISION 0x08
- #define PCI_REVISION_ID 0x08
- #define PCI_CLASS_REVISION 0x08
- #define PCI_CLASS_CODE 0x0b
- #define PCI_SUBCLASS_CODE 0x0a
- #define PCI_HEADER_TYPE 0x0e
- #define PCI_HEADER_TYPE_NORMAL 0
- #define PCI_HEADER_TYPE_BRIDGE 1
- #define PCI_HEADER_TYPE_CARDBUS 2
-
-
-
- #define PCI_CARDBUS_CIS 0x28
- #define PCI_SUBSYSTEM_VENDOR_ID 0x2c
- #define PCI_SUBSYSTEM_ID 0x2e
-
- #define PCI_BASE_ADDRESS_0 0x10
- #define PCI_BASE_ADDRESS_1 0x14
- #define PCI_BASE_ADDRESS_2 0x18
- #define PCI_BASE_ADDRESS_3 0x1c
- #define PCI_BASE_ADDRESS_4 0x20
- #define PCI_BASE_ADDRESS_5 0x24
-
- #define PCI_BASE_ADDRESS_SPACE 0x01
- #define PCI_BASE_ADDRESS_SPACE_IO 0x01
- #define PCI_BASE_ADDRESS_SPACE_MEMORY 0x00
-
- #define PCI_BASE_ADDRESS_MEM_TYPE_MASK 0x06
- #define PCI_BASE_ADDRESS_MEM_TYPE_32 0x00
- #define PCI_BASE_ADDRESS_MEM_TYPE_1M 0x02
- #define PCI_BASE_ADDRESS_MEM_TYPE_64 0x04
- #define PCI_BASE_ADDRESS_MEM_MASK (~0x0f)
- #define PCI_BASE_ADDRESS_IO_MASK (~0x03)
- #define PCI_ROM_ADDRESS 0x30
- #define PCI_ROM_ADDRESS_ENABLE 0x01
-
-
- #define PCI_CAPABILITY_LIST 0x34
-
- #define PCI_INTERRUPT_LINE 0x3c
- #define PCI_INTERRUPT_PIN 0x3d
-
-
- #define PCI_PRIMARY_BUS 0x18
- #define PCI_SECONDARY_BUS 0x19
- #define PCI_SUBORDINATE_BUS 0x1a
- #define PCI_SEC_LATENCY_TIMER 0x1b
- #define PCI_IO_BASE 0x1c
- #define PCI_IO_LIMIT 0x1d
- #define PCI_IO_RANGE_TYPE_MASK 0x0f
- #define PCI_IO_RANGE_TYPE_16 0x00
- #define PCI_IO_RANGE_TYPE_32 0x01
- #define PCI_IO_RANGE_MASK ~0x0f
- #define PCI_SEC_STATUS 0x1e
- #define PCI_MEMORY_BASE 0x20
- #define PCI_MEMORY_LIMIT 0x22
- #define PCI_MEMORY_RANGE_TYPE_MASK 0x0f
- #define PCI_MEMORY_RANGE_MASK ~0x0f
- #define PCI_PREF_MEMORY_BASE 0x24
- #define PCI_PREF_MEMORY_LIMIT 0x26
- #define PCI_PREF_RANGE_TYPE_MASK 0x0f
- #define PCI_PREF_RANGE_TYPE_32 0x00
- #define PCI_PREF_RANGE_TYPE_64 0x01
- #define PCI_PREF_RANGE_MASK ~0x0f
- #define PCI_PREF_BASE_UPPER32 0x28
- #define PCI_PREF_LIMIT_UPPER32 0x2c
- #define PCI_IO_BASE_UPPER16 0x30
- #define PCI_IO_LIMIT_UPPER16 0x32
-
-
- #define PCI_ROM_ADDRESS1 0x38
-
- #define PCI_BRIDGE_CONTROL 0x3e
- #define PCI_BRIDGE_CTL_PARITY 0x01
- #define PCI_BRIDGE_CTL_SERR 0x02
- #define PCI_BRIDGE_CTL_NO_ISA 0x04
- #define PCI_BRIDGE_CTL_VGA 0x08
- #define PCI_BRIDGE_CTL_MASTER_ABORT 0x20
- #define PCI_BRIDGE_CTL_BUS_RESET 0x40
- #define PCI_BRIDGE_CTL_FAST_BACK 0x80
-
- #define PCI_CB_CAPABILITY_LIST 0x14
-
-
-
- #define PCI_CAP_LIST_ID 0
- #define PCI_CAP_ID_PM 0x01
- #define PCI_CAP_ID_AGP 0x02
- #define PCI_CAP_ID_VPD 0x03
- #define PCI_CAP_ID_SLOTID 0x04
- #define PCI_CAP_ID_MSI 0x05
- #define PCI_CAP_ID_CHSWP 0x06
- #define PCI_CAP_ID_EXP 0x10
- #define PCI_CAP_LIST_NEXT 1
- #define PCI_CAP_FLAGS 2
- #define PCI_CAP_SIZEOF 4
-
-
-
- #define PCI_PM_PMC 2
- #define PCI_PM_CAP_VER_MASK 0x0007
- #define PCI_PM_CAP_PME_CLOCK 0x0008
- #define PCI_PM_CAP_RESERVED 0x0010
- #define PCI_PM_CAP_DSI 0x0020
- #define PCI_PM_CAP_AUX_POWER 0x01C0
- #define PCI_PM_CAP_D1 0x0200
- #define PCI_PM_CAP_D2 0x0400
- #define PCI_PM_CAP_PME 0x0800
- #define PCI_PM_CAP_PME_MASK 0xF800
- #define PCI_PM_CAP_PME_D0 0x0800
- #define PCI_PM_CAP_PME_D1 0x1000
- #define PCI_PM_CAP_PME_D2 0x2000
- #define PCI_PM_CAP_PME_D3 0x4000
- #define PCI_PM_CAP_PME_D3cold 0x8000
- #define PCI_PM_CTRL 4
- #define PCI_PM_CTRL_STATE_MASK 0x0003
- #define PCI_PM_CTRL_PME_ENABLE 0x0100
- #define PCI_PM_CTRL_DATA_SEL_MASK 0x1e00
- #define PCI_PM_CTRL_DATA_SCALE_MASK 0x6000
- #define PCI_PM_CTRL_PME_STATUS 0x8000
- #define PCI_PM_PPB_EXTENSIONS 6
- #define PCI_PM_PPB_B2_B3 0x40
- #define PCI_PM_BPCC_ENABLE 0x80
- #define PCI_PM_DATA_REGISTER 7
- #define PCI_PM_SIZEOF 8
-
-
-
- #define PCI_AGP_VERSION 2
- #define PCI_AGP_RFU 3
- #define PCI_AGP_STATUS 4
- #define PCI_AGP_STATUS_RQ_MASK 0xff000000
- #define PCI_AGP_STATUS_SBA 0x0200
- #define PCI_AGP_STATUS_64BIT 0x0020
- #define PCI_AGP_STATUS_FW 0x0010
- #define PCI_AGP_STATUS_RATE4 0x0004
- #define PCI_AGP_STATUS_RATE2 0x0002
- #define PCI_AGP_STATUS_RATE1 0x0001
- #define PCI_AGP_COMMAND 8
- #define PCI_AGP_COMMAND_RQ_MASK 0xff000000
- #define PCI_AGP_COMMAND_SBA 0x0200
- #define PCI_AGP_COMMAND_AGP 0x0100
- #define PCI_AGP_COMMAND_64BIT 0x0020
- #define PCI_AGP_COMMAND_FW 0x0010
- #define PCI_AGP_COMMAND_RATE4 0x0004
- #define PCI_AGP_COMMAND_RATE2 0x0002
- #define PCI_AGP_COMMAND_RATE1 0x0001
- #define PCI_AGP_SIZEOF 12
-
-
-
- #define PCI_SID_ESR 2
- #define PCI_SID_ESR_NSLOTS 0x1f
- #define PCI_SID_ESR_FIC 0x20
- #define PCI_SID_CHASSIS_NR 3
-
-
-
- #define PCI_MSI_FLAGS 2
- #define PCI_MSI_FLAGS_64BIT 0x80
- #define PCI_MSI_FLAGS_QSIZE 0x70
- #define PCI_MSI_FLAGS_QMASK 0x0e
- #define PCI_MSI_FLAGS_ENABLE 0x01
- #define PCI_MSI_RFU 3
- #define PCI_MSI_ADDRESS_LO 4
- #define PCI_MSI_ADDRESS_HI 8
- #define PCI_MSI_DATA_32 8
- #define PCI_MSI_DATA_64 12
-
-
- struct pci_device_id {
-
- const char *name;
-
- uint16_t vendor;
-
- uint16_t device;
- };
-
-
- #define PCI_ANY_ID 0xffff
-
-
- struct pci_device {
-
- struct device dev;
-
-
- unsigned long membase;
-
-
- unsigned long ioaddr;
-
- uint16_t vendor;
-
- uint16_t device;
-
- uint32_t class;
-
- uint8_t irq;
-
- uint8_t bus;
-
- uint8_t devfn;
-
- struct pci_driver *driver;
-
-
- void *priv;
-
- const char *driver_name;
- };
-
-
- struct pci_driver {
-
- struct pci_device_id *ids;
-
- unsigned int id_count;
-
-
- int ( * probe ) ( struct pci_device *pci,
- const struct pci_device_id *id );
-
-
- void ( * remove ) ( struct pci_device *pci );
- };
-
-
- #define __pci_driver __table ( struct pci_driver, pci_drivers, 01 )
-
- #define PCI_DEVFN( slot, func ) ( ( (slot) << 3 ) | (func) )
- #define PCI_SLOT( devfn ) ( ( (devfn) >> 3 ) & 0x1f )
- #define PCI_FUNC( devfn ) ( (devfn) & 0x07 )
- #define PCI_BUSDEVFN( bus, devfn ) ( ( (bus) << 8 ) | (devfn) )
-
- #define PCI_BASE_CLASS( class ) ( (class) >> 16 )
- #define PCI_SUB_CLASS( class ) ( ( (class) >> 8 ) & 0xff )
- #define PCI_PROG_INTF( class ) ( (class) & 0xff )
-
-
- #define PCI_ROM( _vendor, _device, _name, _description ) { \
- .vendor = _vendor, \
- .device = _device, \
- .name = _name, \
- }
-
- extern void adjust_pci_device ( struct pci_device *pci );
- extern unsigned long pci_bar_start ( struct pci_device *pci,
- unsigned int reg );
- extern int pci_find_capability ( struct pci_device *pci, int capability );
- extern unsigned long pci_bar_size ( struct pci_device *pci, unsigned int reg );
-
-
- static inline void pci_set_drvdata ( struct pci_device *pci, void *priv ) {
- pci->priv = priv;
- }
-
-
- static inline void * pci_get_drvdata ( struct pci_device *pci ) {
- return pci->priv;
- }
-
- #endif
|