90 lines
1.3 KiB
C

#pragma once
#include <lcrash/types.h>
/**
* bwaaaaaa, the many ways to touch PCI things
*/
struct [[gnu::packed]] PciConfigurationSpaceHeader {
u16 VendorID;
u16 DeviceID;
u16 Status;
u16 Command;
u8 RevisionID : 8;
u8 ProgIF;
u8 Subclass;
u8 Class;
u8 CacheLineSize;
u8 MasterLatencyTimer;
u8 HeaderType;
u8 BIST;
union {
struct {
u32 BAR0;
u32 BAR1;
u32 BAR2;
u32 BAR3;
u32 BAR4;
u32 BAR5;
u32 CIS;
u16 SubsystemVendor;
u16 Subsystem;
u32 ExpansionROM;
u8 Reserved[3];
};
u8 Reserved2[0x20];
};
u8 CapabilitiesPointer;
u8 Reserved3[7];
u8 InterruptLine;
u8 InterruptPin;
u8 Reserved4[2];
};
/**
* PCI Host Controller device for the system bus
*/
struct PciSBHostController {
u8 Bus;
u8 Device;
u8 OwnedBusCount;
u8 OwnedBusses[8];
};
/**
* PCI Host Controller device create arguments
*/
struct PciSBHostController_CreateArgs {
u8 Bus;
u8 Device;
u8 OwnedBusCount;
u8 OwnedBusses[8];
};
/**
* Unknown PCI device
*/
struct PciSBMiscDevice {
u8 Bus;
u8 Device;
u8 Class;
u8 Subclass;
u8 ProgInterface;
};
typedef struct PciSBMiscDevice PciSBMiscDevice_CreateArgs;
/**
* Initialize the PCI code.
*/
void PciInitialize();
/// PCI is usable
bool PciPresent();
/// PCIE is usable
bool PciePresent();