[edk2-devel] Saving data structure at Pre EFI Initialization phase in memory to use it at DXE phase by some UEFI application?

Laszlo Ersek lersek at redhat.com
Thu Jan 30 14:18:44 UTC 2020


On 01/30/20 13:57, sergestus at yandex.ru wrote:
> Thank you, may I just create a new GUID (sysHostGuid),

Right, just get your own GUID with "uuidgen".

> then call BuildGuidDataHob passing in it the sysHostGuid

Yes.

> and SYSHOST structure?

Well, not exactly. It depends.

If your SYSHOST structure is a few KB tops (up to 64-ish KB), then sure,
you can embed the SYSHOST structure right into the HOB.

Otherwise, you should
- make your PEI code dependent on gEfiPeiMemoryDiscoveredPpiGuid,
- call the AllocatePages() PEI service,
- populate the allocated area with the SYSHOST structure,
- take the 64-bit EFI_PHYSICAL_ADDRESS, output by AllocatePages(), as a
UINT64,
- call BuildGuidDataHob() on the *UINT64*. In other words, embed the
address of the structure, not the structure.

> Will I be able to find the structure in the DXE phase looking up by the sysHostGuid?

Yes, with GetFirstGuidHob().

If you embedded the structure in the HOB, then you can consume it right
from the HOB (at the address returned by GetFirstGuidHob()).

Otherwise, you should read the address (the UINT64 object) out of the
HOB. Then dereference it as a pointer, and that's where your struct will be.

The point is that memory allocated in the PEI phase with the
AllocatePages() PEI service, *after* permanent RAM has been installed
(i.e. after gEfiPeiMemoryDiscoveredPpiGuid is placed in the PPI
database), is stable. You can pass the address from PEI to DXE using a
GUID HOB.

Thanks
Laszlo


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#53582): https://edk2.groups.io/g/devel/message/53582
Mute This Topic: https://groups.io/mt/70267536/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list