Hi Gerd,

I get it, I will refactor the code as soon as I can, it looks like there's still some work and will take some time. I will try to send the V3 tonight if possible.


Thanks,
Chao
On 2024/4/25 17:02, Gerd Hoffmann wrote:
On Thu, Apr 25, 2024 at 04:06:13PM +0800, Chao Li wrote:
Hi Gerd,


Thanks,
Chao
On 2024/4/25 15:53, Gerd Hoffmann wrote:
   Hi,

+UINTN  mFwCfgSelectorAddress;
+UINTN  mFwCfgDataAddress;
+UINTN  mFwCfgDmaAddress;
Hmm, global variables for PEI?  I think the point of storing these in
the HOB is to avoid the need for global variables?  Also does that work
when running PEI in-place from flash?
I think it would be useful if some platforms(not LoongArch) could use the
global variables in PEI, because the global variables are faster.
Performance isn't my main concern here, I very much prefer code which is
easy to maintain.  Taking the same code path on all platforms is good
for that.  It's less code and it also makes testing easier.  The risk of
breaking loongarch when changing something for riscv or arm is much
lower if all platforms work the same way.

I'd suggest to first refactor the existing DXE code to use a HOB instead
of global variables.  Have a helper function which looks up the HOB and
returns a pointer to the configuration struct.  That helper function can
be slightly different for DXE/PEI, the DXE variant can cache the pointer
to the struct in a global variable so it needs to do the lookup only
once.

+  UINT64        FwCfgDataSize;
+  UINT64        FwCfgDmaAddress;
+  UINT64        FwCfgDmaSize;
First thing this function should do is check whenever the HOB already
exists.  Should that be the case there is no need to parse the device
tree.
This is a constructor in PEI, that has to parse the device tree and then
build the HOBs.
This is a library, so it can be linked into multiple PEI and DXE
modules.  So it must be prepared to run multiple times.  On the
second and all following runs the HOB will already exist.

The DXE variant will need the check for sure.  I'd strongly suggest to
add it to the PEI variant too, even though it might not be needed right
now because PlatformPei is the only PEI module using the library.

take care,
  Gerd





_._,_._,_

Groups.io Links:

You receive all messages sent to this group.

View/Reply Online (#118283) | | Mute This Topic | New Topic
Your Subscription | Contact Group Owner | Unsubscribe [rebecca@openfw.io]

_._,_._,_