28 lines
1.1 KiB
C
28 lines
1.1 KiB
C
|
#pragma once
|
||
|
#include <stdint.h>
|
||
|
|
||
|
namespace PCI
|
||
|
{
|
||
|
struct DeviceID
|
||
|
{
|
||
|
uint16_t vendor;
|
||
|
uint16_t device;
|
||
|
};
|
||
|
struct DeviceType
|
||
|
{
|
||
|
uint8_t dev_class;
|
||
|
uint8_t dev_subclass;
|
||
|
uint8_t prog_if;
|
||
|
uint8_t revision;
|
||
|
};
|
||
|
uint32_t raw_address(uint32_t bus, uint32_t slot, uint32_t function, int32_t offset);
|
||
|
void raw_write8(uint32_t bus, uint32_t slot, uint32_t function, int32_t offset, uint8_t value);
|
||
|
void raw_write16(uint32_t bus, uint32_t slot, uint32_t function, int32_t offset, uint16_t value);
|
||
|
void raw_write32(uint32_t bus, uint32_t slot, uint32_t function, int32_t offset, uint32_t value);
|
||
|
uint8_t raw_read8(uint32_t bus, uint32_t slot, uint32_t function, int32_t offset);
|
||
|
uint16_t raw_read16(uint32_t bus, uint32_t slot, uint32_t function, int32_t offset);
|
||
|
uint32_t raw_read32(uint32_t bus, uint32_t slot, uint32_t function, int32_t offset);
|
||
|
DeviceID get_device_id(uint32_t bus, uint32_t slot, uint32_t function);
|
||
|
DeviceType get_device_type(uint32_t bus, uint32_t slot, uint32_t function);
|
||
|
void scan(void (*callback)(PCI::DeviceID&, PCI::DeviceType&));
|
||
|
}
|