public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Laszlo Ersek" <lersek@redhat.com>
To: sergestus@yandex.ru, devel@edk2.groups.io
Subject: Re: [edk2-devel] Saving data structure at Pre EFI Initialization phase in memory to use it at DXE phase by some UEFI application?
Date: Thu, 30 Jan 2020 15:18:44 +0100	[thread overview]
Message-ID: <55fabeb6-f7b6-0c65-2216-a212f6dc1171@redhat.com> (raw)
In-Reply-To: <14732.1580389052139587541@groups.io>

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


  reply	other threads:[~2020-01-30 14:18 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2020-01-30 15:09           ` sergestus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55fabeb6-f7b6-0c65-2216-a212f6dc1171@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox