1// SPDX-License-Identifier: GPL-3.0-or-later
2
3#pragma once
4
5#include <mos/types.h>
6
7#define PCI_OFFSET_VENDOR_ID 0x00
8#define PCI_OFFSET_DEVICE_ID 0x02
9#define PCI_OFFSET_PROG_IF 0x09
10#define PCI_OFFSET_SUB_CLASS 0x0A
11#define PCI_OFFSET_BASE_CLASS 0x0B
12#define PCI_OFFSET_HEADER_TYPE 0x0E
13
14#define PCI_HEADER_TYPE_MULTIFUNC 0x80
15
16typedef void (*pci_scan_callback_t)(u8 bus, u8 device, u8 function, u16 vendor_id, u16 device_id, u8 base_class, u8 sub_class, u8 prog_if);
17
18extern ptr_t mmio_base;
19
20void scan_pci(pci_scan_callback_t callback); // scan all buses
21
22void scan_bus(u8 bus, pci_scan_callback_t callback);
23void scan_device(u8 bus, u8 device, pci_scan_callback_t callback);
24void scan_function(u8 bus, u8 device, u8 function, pci_scan_callback_t callback);
25