代码如下
Aspm.c文件
#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 << 8 | 0x34;
IoWrite32 (AddressPort, PcieNumber);
CapNextAddress = IoRead8 (DataPort);
if (CapNextAddress == 0x00) {
Print (L"pci 0 1 1 is not exists capabilities pointer\n");
return;
}
//
//The first capabilitiesId
//
PcieNumber = 0x80000000