高通启用UEFI架构的bootloader,有些时候有些状态值,需要ABL阶段获取.
上层思维总是以属性来开端,实际上android 的setproperty和getproperty属性对于uefi启动流程是不可取的.
自己在修改这块内容的举例来简单记录下,
XBL setSetVariable 设置标志位
include <Library/UefiRuntimeServicesTableLib.h>//导入头文件
...
...
Boolean EpStatus;
EpStatus = TRUE;
gRT->SetVariable (L"ModuleState", &gQcomTokenSpaceGuid,
EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_NON_VOLATILE,
(UINTN)sizeof(EpStatus), &EpStatus);
ABL代码端获取值
include <Library/UefiRuntimeServicesTableLib.h>//导入头文件
...
BOOLEAN EpStatus;
UINTN VarSize = sizeof(BOOLEAN);
Status = gRT->GetVariable (L"ModuleState", &gQcomTokenSpaceGuid,
NULL, &VarSize, (UINT8*)&EpStatus);
EFI_RUNTIME_SERVICES 是关键,当然,我这边使用的高通这个GUID有一个发现就是,这个值我猜测是存入了EMMC的rpmb分区,因为直接刷机此值得状态还是存在的,这个地方还需要继续验证一下,也许日后能用到.
bootable\bootloader\edk2\MdePkg\Include\Library\UefiRuntimeServicesTableLib.h
ifndef UEFI_RUNTIME_SERVICES_TABLE_LIB_H
define UEFI_RUNTIME_SERVICES_TABLE_LIB_H
///
/// Cached copy of the EFI Runtime Services Table
///
extern EFI_RUNTIME_SERVICES *gRT;
endif
编译xbl和abl,打印串口即可get到EpStatus的值.
这里需要提到的是,我这边用了QcomTokenSpace这个Protocol,
ABL的QcomModulePkg.dec和XBL的中均添加了相应的Protocol
[Guids.common]
gQcomTokenSpaceGuid = { 0x882f8c2b, 0x9646, 0x435f, { 0x8d, 0xe5, 0xf2, 0x08, 0xff, 0x80, 0xc1, 0xbd } }
更多的Uefi SetVariable和GetVariable函数的用法,可以参考
[https://edk2-docs.gitbook.io/edk-ii-uefi-driver-writer-s-guide/5_uefi_services/readme.2/525_getvariable_and_setvariable]
UEFI架构的理解还需要进一步的探究,目前只是皮毛的去解决问题.
标签:读取,EFI,ABL,XBL,EpStatus,SERVICES,UEFI From: https://www.cnblogs.com/yyy8/p/18393700