public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* Saving data structure at Pre EFI Initialization phase in memory to use it at DXE phase by some UEFI application?
@ 2020-01-30  9:51 sergestus
  2020-01-30 10:01 ` [edk2-devel] " Marvin Häuser
  0 siblings, 1 reply; 7+ messages in thread
From: sergestus @ 2020-01-30  9:51 UTC (permalink / raw)
  To: devel

[-- Attachment #1: Type: text/plain, Size: 144 bytes --]

Is it possible to save SYSHOST data structure at PEI phase in memory at some default location to use it at DXE phase by some UEFI application?

[-- Attachment #2: Type: text/html, Size: 188 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] Saving data structure at Pre EFI Initialization phase in memory to use it at DXE phase by some UEFI application?
  2020-01-30  9:51 Saving data structure at Pre EFI Initialization phase in memory to use it at DXE phase by some UEFI application? sergestus
@ 2020-01-30 10:01 ` Marvin Häuser
  2020-01-30 11:03   ` sergestus
  0 siblings, 1 reply; 7+ messages in thread
From: Marvin Häuser @ 2020-01-30 10:01 UTC (permalink / raw)
  To: devel@edk2.groups.io, sergestus@yandex.ru

Hey,

Are HOBs ("Hand-Off Blocks") what you are looking for? They are passed 
from PEI to DXE (see PI 1.6, 9.3 "Passing the Hand-Off Block (HOB) List").

Regards,
Marvin

Am 30.01.2020 um 10:51 schrieb sergestus@yandex.ru:
> Is it possible to save SYSHOST data structure at PEI phase in memory at 
> some default location to use it at DXE phase by some UEFI application?
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] Saving data structure at Pre EFI Initialization phase in memory to use it at DXE phase by some UEFI application?
  2020-01-30 10:01 ` [edk2-devel] " Marvin Häuser
@ 2020-01-30 11:03   ` sergestus
  2020-01-30 11:30     ` Laszlo Ersek
  0 siblings, 1 reply; 7+ messages in thread
From: sergestus @ 2020-01-30 11:03 UTC (permalink / raw)
  To: Marvin Häuser, devel

[-- Attachment #1: Type: text/plain, Size: 254 bytes --]

I need to use some code from PEIM driver in DXE phase. This code is using the SYSHOST structure and I think it not easy to restore it from HOBs becuase there are a lot of information. So I thought it easy to save the structure completely in the memory.

[-- Attachment #2: Type: text/html, Size: 254 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] Saving data structure at Pre EFI Initialization phase in memory to use it at DXE phase by some UEFI application?
  2020-01-30 11:03   ` sergestus
@ 2020-01-30 11:30     ` Laszlo Ersek
  2020-01-30 12:57       ` sergestus
  0 siblings, 1 reply; 7+ messages in thread
From: Laszlo Ersek @ 2020-01-30 11:30 UTC (permalink / raw)
  To: devel, sergestus, Marvin Häuser

On 01/30/20 12:03, sergestus@yandex.ru wrote:
> I need to use some code from PEIM driver in DXE phase. This code is
> using the SYSHOST structure and I think it not easy to restore it
> from HOBs becuase there are a lot of information. So I thought it
> easy to save the structure completely in the memory.

In the PEIM, assuming your code runs after permanent RAM has been
discovered, you can allocate memory for the SYSHOST structure with the
AllocatePages() PEI service. Stash the allocation address in a vendor
GUID HOB. In the DXE phase, look up the HOB by GUID.

Thanks
Laszlo


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] Saving data structure at Pre EFI Initialization phase in memory to use it at DXE phase by some UEFI application?
  2020-01-30 11:30     ` Laszlo Ersek
@ 2020-01-30 12:57       ` sergestus
  2020-01-30 14:18         ` Laszlo Ersek
  0 siblings, 1 reply; 7+ messages in thread
From: sergestus @ 2020-01-30 12:57 UTC (permalink / raw)
  To: Laszlo Ersek, devel

[-- Attachment #1: Type: text/plain, Size: 243 bytes --]

Thank you, may I just create a new GUID (sysHostGuid), then call BuildGuidDataHob passing in it the sysHostGuid and SYSHOST structure? Will I be able to find the structure in the DXE phase looking up by the sysHostGuid?

Thank you,
Sergey

[-- Attachment #2: Type: text/html, Size: 255 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] Saving data structure at Pre EFI Initialization phase in memory to use it at DXE phase by some UEFI application?
  2020-01-30 12:57       ` sergestus
@ 2020-01-30 14:18         ` Laszlo Ersek
  2020-01-30 15:09           ` sergestus
  0 siblings, 1 reply; 7+ messages in thread
From: Laszlo Ersek @ 2020-01-30 14:18 UTC (permalink / raw)
  To: sergestus, devel

On 01/30/20 13:57, sergestus@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


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [edk2-devel] Saving data structure at Pre EFI Initialization phase in memory to use it at DXE phase by some UEFI application?
  2020-01-30 14:18         ` Laszlo Ersek
@ 2020-01-30 15:09           ` sergestus
  0 siblings, 0 replies; 7+ messages in thread
From: sergestus @ 2020-01-30 15:09 UTC (permalink / raw)
  To: Laszlo Ersek, devel

[-- Attachment #1: Type: text/plain, Size: 40 bytes --]

I've understood, thanks a lot!
Sergey

[-- Attachment #2: Type: text/html, Size: 44 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2020-01-30 15:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-30  9:51 Saving data structure at Pre EFI Initialization phase in memory to use it at DXE phase by some UEFI application? sergestus
2020-01-30 10:01 ` [edk2-devel] " Marvin Häuser
2020-01-30 11:03   ` sergestus
2020-01-30 11:30     ` Laszlo Ersek
2020-01-30 12:57       ` sergestus
2020-01-30 14:18         ` Laszlo Ersek
2020-01-30 15:09           ` sergestus

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox