swissChili | 0d24883 | 2021-04-08 18:16:02 -0700 | [diff] [blame] | 1 | #pragma once |
| 2 | |
| 3 | #include <kint.h> |
swissChili | ca26848 | 2021-05-28 18:31:46 -0700 | [diff] [blame] | 4 | #include <dri/pci/vendors.h> |
swissChili | 0d24883 | 2021-04-08 18:16:02 -0700 | [diff] [blame] | 5 | |
swissChili | 7a6f5eb | 2021-04-13 16:46:02 -0700 | [diff] [blame] | 6 | enum |
| 7 | { |
| 8 | PCI_CONFIG_ADDRESS = 0xCF8, |
| 9 | PCI_CONFIG_DATA = 0xCFC, |
| 10 | }; |
| 11 | |
swissChili | 247cc56 | 2021-05-30 20:55:13 -0700 | [diff] [blame] | 12 | struct pci_device |
| 13 | { |
| 14 | struct pci_vendor *vendor; |
| 15 | uchar class, subclass, prog_if; |
| 16 | ushort device_id; |
| 17 | bool valid; |
| 18 | }; |
| 19 | |
swissChili | 5fe85a1 | 2021-05-31 08:10:27 -0700 | [diff] [blame] | 20 | struct pci_device_driver |
| 21 | { |
| 22 | bool (* supports)(struct pci_device *dev); |
| 23 | void (* init)(struct pci_device dev, uchar bus, uchar slot, uchar func); |
| 24 | char *generic_name; |
| 25 | uint loaded; // reserved |
| 26 | struct pci_device dev; // reserved |
| 27 | }; |
| 28 | |
| 29 | // Call this first |
| 30 | void pci_init(); |
| 31 | // Call this after registering drivers to load them |
| 32 | void pci_load(); |
| 33 | |
swissChili | 247cc56 | 2021-05-30 20:55:13 -0700 | [diff] [blame] | 34 | // offset is in dwords |
swissChili | 9321498 | 2021-05-28 21:32:26 -0700 | [diff] [blame] | 35 | uint pci_config_readd(uchar bus, uchar slot, uchar func, uchar offset); |
swissChili | 247cc56 | 2021-05-30 20:55:13 -0700 | [diff] [blame] | 36 | struct pci_device pci_check_device(uchar bus, uchar slot, uchar func); |
swissChili | 402a383 | 2021-05-29 21:41:31 -0700 | [diff] [blame] | 37 | void pci_print_devices(); |
swissChili | 5fe85a1 | 2021-05-31 08:10:27 -0700 | [diff] [blame] | 38 | void pci_register_device_driver(struct pci_device_driver driver); |
| 39 | void pci_print_drivers(); |