Uefi编程 检查Pcie设备是否支持ASPM功能
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/IoLib.h>
#define AddressPort 0xCF8
#define DataPort 0xCFC
/**
Check pcie 0 1 1 device ASPM
**/
VOID
EFIAPI
CheckPcieAspm () {
UINT16 Vendor;
UINT32 Bus, Device, Function;
UINT32 PcieNumber;
UINT8 CapId, CapNextAddress;
UINT16 CapLink;
//Check whether the pcie 0 1 1 device exists
Bus = 0;
Device = 1;
Function = 1;
PcieNumber = 0x80000000 | Bus << 16 | Device << 11 | Function << 8 | 0;
IoWrite32 (AddressPort, PcieNumber);
Vendor = IoRead16 (DataPort);
if (0xffff != Vendor) {
Print (L\"pci 0 1 1 device exists\\n\");
}
//
//Get first capabilities address
//
PcieNumber = 0x80000000 | Bus << 16 | Device << 11 | Function