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