dxe driver 之间也可以通过variable来通讯。
EFI_STATUS
ReadAndWriteVariable (
IN CHAR16
*Name,
IN EFI_GUID
*VendorGuid,
)
{
EFI_STATUS Status;
UINTN
BufferSize;
VOID
*Buffer;
Buffer = NULL;
BufferSize = 0;
Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize,
Buffer);
if (Status != EFI_BUFFER_TOO_SMALL) {
return Status;
}
Buffer = AllocateZeroPool (BufferSize);
ASSERT (Buffer != NULL);
Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize,
Buffer);
if (EFI_ERROR (Status)) {
BufferSize = 0;
}
Status = gRT->SetVariable (
Name,
VendorGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS |
EFI_VARIABLE_NON_VOLATILE,
BufferSize,
Buffer
);
ASSERT_EFI_ERROR (Status);
return EFI_SUCCESS;
}
例如这段sample code中通过调用gRT->GetVariable 来得到variable ,通过gRT->SetVariable 来写variable。其中的第一个参数name就是要读或者要写的变量,每个变量和一个guid对应.
GetVariable和SetVariable也是在mdemodulepkg/core/dxe/dxemian中赋值的
EFI_RUNTIME_SERVICES mEfiRuntimeServicesTableTemplate = {
(EFI_GET_VARIABLE) CoreEfiNotAvailableYetArg5, // GetVariable
(EFI_SET_VARIABLE) CoreEfiNotAvailableYetArg5, // SetVariable
};
dxe driver 之间也可以通过PCD 来通讯
例如 mLegacyModeMask = PcdGet16 (Pcd8259LegacyModeMask);
这些PcdGetxx 都是在pcdlib.h 中定义,而Pcd8259LegacyModeMask 一般都是在dsc文件中定义好的,例如下面在这段定义了PcdFirmwareVendor = “ARM Versatile Express”
[PcdsFixedAtBuild.common]
gArmPlatformTokenSpaceGuid.PcdFirmwareVendor|"ARM Versatile Express"
这样在c code中就可以通过下面的方式取得这个字符串
if (FixedPcdGetPtr(PcdFirmwareVendor) != NULL)
EFI_STATUS
ReadAndWriteVariable (
IN CHAR16
*Name,
IN EFI_GUID
*VendorGuid,
)
{
EFI_STATUS Status;
UINTN
BufferSize;
VOID
*Buffer;
Buffer = NULL;
BufferSize = 0;
Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize,
Buffer);
if (Status != EFI_BUFFER_TOO_SMALL) {
return Status;
}
Buffer = AllocateZeroPool (BufferSize);
ASSERT (Buffer != NULL);
Status = gRT->GetVariable (Name, VendorGuid, NULL, &BufferSize,
Buffer);
if (EFI_ERROR (Status)) {
BufferSize = 0;
}
Status = gRT->SetVariable (
Name,
VendorGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS |
EFI_VARIABLE_RUNTIME_ACCESS |
EFI_VARIABLE_NON_VOLATILE,
BufferSize,
Buffer
);
ASSERT_EFI_ERROR (Status);
return EFI_SUCCESS;
}
例如这段sample code中通过调用gRT->GetVariable 来得到variable ,通过gRT->SetVariable 来写variable。其中的第一个参数name就是要读或者要写的变量,每个变量和一个guid对应.
GetVariable和SetVariable也是在mdemodulepkg/core/dxe/dxemian中赋值的
EFI_RUNTIME_SERVICES mEfiRuntimeServicesTableTemplate = {
(EFI_GET_VARIABLE) CoreEfiNotAvailableYetArg5, // GetVariable
(EFI_SET_VARIABLE) CoreEfiNotAvailableYetArg5, // SetVariable
};
dxe driver 之间也可以通过PCD 来通讯
例如 mLegacyModeMask = PcdGet16 (Pcd8259LegacyModeMask);
这些PcdGetxx 都是在pcdlib.h 中定义,而Pcd8259LegacyModeMask 一般都是在dsc文件中定义好的,例如下面在这段定义了PcdFirmwareVendor = “ARM Versatile Express”
[PcdsFixedAtBuild.common]
gArmPlatformTokenSpaceGuid.PcdFirmwareVendor|"ARM Versatile Express"
这样在c code中就可以通过下面的方式取得这个字符串
if (FixedPcdGetPtr(PcdFirmwareVendor) != NULL)