On Fri, Feb 03, 2023 at 03:14:42AM +0000, Ni, Ray wrote:
> Gerd,
> Can you please explain a bit more on the chunk idea?

> > > to introduce a generic and reusable concept of chunked HOBs, so you can
> > > add helper functions to HobLib for splitting and reassembling, with a
> > > struct along the lines of:
> > >
> > > typedef struct {
> > >   // offset and size of this particular chunk
> > >   UINT32  ChunkOffset;
> > >   UINT32  ChunkSize;
> > >
> > >   // number of chunks and size of all chunks combined.
> > >   UINT32  ChunkCount;
> > >   UINT32  TotalSize;
> > >
> > >   // chunk data
> > >   UINT8   Data[0];
> > > } EFI_HOB_CHUNK;

Reassembling would work like this:

  // once
  AssembledHob = malloc(HobChunk->TotalSize);

  // for each chunk
  memcpy(AssembledHob + HobChunk->ChunkOffset, HobChunk->Data, 
HobChunk->ChunkSize);

Possible shortcut:

  if (HobChunk->ChunkSize == HobChunk->TotalSize)
    // data is not splitted into multiple chunks
    AssembledHob = HobChunk->Data

Advantage: you avoid the allocation in case the data fits into a single
HOB.  Disadvantage: you need to track whenever AssembledHob is allocated
(and must eventually be freed) or not.

HobChunk->ChunkCount is not really needed but might be useful for sanity
checking.

take care,
  Gerd



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#99543): https://edk2.groups.io/g/devel/message/99543
Mute This Topic: https://groups.io/mt/96350760/21656
Group Owner: devel+ow...@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-


Reply via email to