blob: b4c21f15c033af921aaa175741d8f26db07b7c14 [file] [log] [blame]
swissChili0d248832021-04-08 18:16:02 -07001#pragma once
2
3#include <kint.h>
swissChilica268482021-05-28 18:31:46 -07004#include <dri/pci/vendors.h>
swissChili0d248832021-04-08 18:16:02 -07005
swissChili7a6f5eb2021-04-13 16:46:02 -07006enum
7{
8 PCI_CONFIG_ADDRESS = 0xCF8,
9 PCI_CONFIG_DATA = 0xCFC,
10};
11
swissChili247cc562021-05-30 20:55:13 -070012struct pci_device
13{
14 struct pci_vendor *vendor;
15 uchar class, subclass, prog_if;
16 ushort device_id;
17 bool valid;
18};
19
swissChili5fe85a12021-05-31 08:10:27 -070020struct 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
30void pci_init();
31// Call this after registering drivers to load them
32void pci_load();
33
swissChili247cc562021-05-30 20:55:13 -070034// offset is in dwords
swissChili93214982021-05-28 21:32:26 -070035uint pci_config_readd(uchar bus, uchar slot, uchar func, uchar offset);
swissChili247cc562021-05-30 20:55:13 -070036struct pci_device pci_check_device(uchar bus, uchar slot, uchar func);
swissChili402a3832021-05-29 21:41:31 -070037void pci_print_devices();
swissChili5fe85a12021-05-31 08:10:27 -070038void pci_register_device_driver(struct pci_device_driver driver);
39void pci_print_drivers();