参考:高通文档
How to use SMEM in ABL?
For previous platform, Android LK was used for bootloader, while in recent platforms
UEFI is used to replace the old Android LK bootloader.
There are two parts of UEFI modules, one is in boot_images which is called UEFI core;
another is in Linux Android open-source code which is called ABL. ABL is an application
of UEFI, so the protocols defined in UEFI core from ABL can be used directly to access
hardware information such as: DAL, SDCC, and so on.
Follow the following steps to get the information from SMEM set by XBLLoader:
Copy header file from boot_images to LA
boot_images/QcomPkg/SDM845Pkg/Include/smem_type.h ->
bootable/bootloader/edk2/ QcomModulePkg/Include/smem_type.h
boot_images/QcomPkg/Include/EFISmem.h ->
bootable/bootloader/edk2/QcomModulePkg/Include/ Protocol/EFISmem.h
Copy gEfiSMEMProtocolGuid from boot_images/QcomPkg/QcomPkg.dec to
bootable/bootloader/ edk2/QcomModulePkg/QcomModulePkg.dec
Shared Memory
gEfiSMEMProtocolGuid = { 0xf4e5c7d0, 0xd239, 0x47cb, { 0xaa, 0xcd, 0x7f,
0x66, 0xef, 0x76, 0x32, 0x38 } }
Use EFI_SMEM_PROTOCOL in ABL
#include <Protocol/EFISmem.h>
#include <smem_type.h>
STATIC UINT8 AccessSmem(UINT32 *Args){
EFI_SMEM_PROTOCOL *smemProtocol;
UINT32 *vendor0;
UINT32 size; EFI_STATUS Status;
Status = gBS->LocateProtocol(&gEfiSMEMProtocolGuid, NULL, (VOID **)
&smemProtocol); if (Status != EFI_SUCCESS){
DEBUG((EFI_D_ERROR, “Error locating the smem protocol\n”)); return
Status;}
status = smem_protocol->SmemGetAddr(SMEM_ID_VENDOR0, &size, (void
**)&vendor0); if(status != EFI_SUCCESS){
DEBUG((EFI_D_ERROR, “SmemGetAddr(SMEM_ID_VENDOR0) returned %d\n”,
status)); return status;}
return Status;}