2021-11-02 20:03:11 +00:00
|
|
|
#pragma once
|
|
|
|
#include <stdint.h>
|
2021-12-27 14:26:32 +00:00
|
|
|
#include "../io.h"
|
|
|
|
#include "../../../tty/kterm.h"
|
|
|
|
#include "../../../pci/pciDevice.h"
|
2021-11-28 15:46:16 +00:00
|
|
|
|
2021-11-02 20:03:11 +00:00
|
|
|
// Configuration Space Access Mechanism #1
|
|
|
|
#define CONFIG_ADDRESS 0xCF8 // Configuration adress that is to be accessed
|
|
|
|
#define CONFIG_DATA 0xCFC // Will do the actual configuration operation
|
|
|
|
|
2021-11-28 15:46:16 +00:00
|
|
|
extern const char* ClassCodeTable [0x13];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Note: this could be used to make the api for receiving PCI class codes a bit
|
|
|
|
// nicer.
|
|
|
|
struct ClassCodes {
|
|
|
|
uint8_t ClassCode;
|
|
|
|
uint8_t DeviceClass;
|
|
|
|
}__attribute__((packed));
|
|
|
|
|
2021-11-25 21:05:16 +00:00
|
|
|
uint32_t ConfigReadWord (uint8_t bus, uint8_t device, uint8_t func, uint8_t offset);
|
2021-11-28 15:46:16 +00:00
|
|
|
uint32_t ConfigReadWord ( PCIBusAddress& PCIDeviceAddress , uint8_t offset);
|
|
|
|
|
|
|
|
inline uint64_t GetDevice (int bus, int device, int function ){
|
|
|
|
return ConfigReadWord(bus, device, function,0x0);
|
|
|
|
}
|
2021-11-02 20:03:11 +00:00
|
|
|
|
2021-11-28 15:46:16 +00:00
|
|
|
uint8_t GetHeaderType( PCIBusAddress& PCIDeviceAddress );
|
2021-11-02 20:03:11 +00:00
|
|
|
|
2021-11-28 15:46:16 +00:00
|
|
|
uint16_t GetClassCodes( PCIBusAddress& PICDeviceAddress );
|
|
|
|
const char* getVendor( uint64_t VendorID);
|
|
|
|
const char* GetClassCodeName (uint64_t ClassCode );
|
2021-11-02 20:03:11 +00:00
|
|
|
|
2021-11-29 19:00:28 +00:00
|
|
|
uint8_t GetProgIF (PCIBusAddress& PCIDeviceAddress);
|
|
|
|
void PCI_Enumerate();
|
|
|
|
|
|
|
|
uint32_t ReadBAR ( PCIBusAddress& PCIDeviceAddress, int bar_number);
|