Li-Ta Lo | 8152126 | 2004-07-08 17:18:27 +0000 | [diff] [blame] | 1 | #include "pci.h" |
| 2 | |
| 3 | typedef unsigned long pciaddr_t; |
| 4 | typedef u8 byte; |
| 5 | typedef u16 word; |
| 6 | |
| 7 | struct pci_dev { |
| 8 | struct pci_dev *next; /* Next device in the chain */ |
| 9 | word bus; /* Higher byte can select host bridges */ |
| 10 | byte dev, func; /* Device and function */ |
| 11 | |
| 12 | /* These fields are set by pci_fill_info() */ |
| 13 | int known_fields; /* Set of info fields already known */ |
| 14 | word vendor_id, device_id; /* Identity of the device */ |
| 15 | int irq; /* IRQ number */ |
| 16 | pciaddr_t base_addr[6]; /* Base addresses */ |
| 17 | pciaddr_t size[6]; /* Region sizes */ |
| 18 | pciaddr_t rom_base_addr; /* Expansion ROM base address */ |
| 19 | pciaddr_t rom_size; /* Expansion ROM size */ |
| 20 | |
| 21 | /* Fields used internally: */ |
| 22 | void *access; |
| 23 | void *methods; |
| 24 | byte *cache; /* Cached information */ |
| 25 | int cache_len; |
| 26 | int hdrtype; /* Direct methods: header type */ |
| 27 | void *aux; /* Auxillary data */ |
| 28 | }; |
| 29 | |
| 30 | |
| 31 | struct pci_filter { |
| 32 | int bus, slot, func; /* -1 = ANY */ |
| 33 | int vendor, device; |
| 34 | }; |
| 35 | |
| 36 | |
| 37 | #define PCITAG struct pci_filter * |
| 38 | #define pciVideoPtr struct pci_dev * |
| 39 | |
| 40 | extern int pciNumBuses; |
| 41 | |
| 42 | int pciInit(void); |
| 43 | int pciExit(void); |
| 44 | |
| 45 | |
| 46 | PCITAG findPci(unsigned short bx); |
| 47 | u32 pciSlotBX(pciVideoPtr pvp); |
| 48 | |
| 49 | void pciWriteLong(PCITAG tag, u32 idx, u32 data); |
| 50 | void pciWriteWord(PCITAG tag, u32 idx, u16 data); |
| 51 | void pciWriteByte(PCITAG tag, u32 idx, u8 data); |
| 52 | |
| 53 | u32 pciReadLong(PCITAG tag, u32 idx); |
| 54 | u16 pciReadWord(PCITAG tag, u32 idx); |
| 55 | u8 pciReadByte(PCITAG tag, u32 idx); |