4. HOB Design Discussion
4.1. Explanation of HOB Terms
Because HOBs are the key architectural mechanism that is used to hand off system information in the early preboot stages and because not all implementations of the PI Architecture will use the Pre-EFI Initialization (PEI) and Driver Execution Environment (DXE) phases, this specification refrains from using the PEI and DXE nomenclature used in other PI specifications.
Instead, this specification uses the following terms to refer to the phases that deal with HOBs:
HOB producer phase
HOB consumer phase
The HOB producer phase is the preboot phase in which HOBs and the HOB list are created. The HOB consumer phase is the preboot phase to which the HOB list is passed and then consumed.
If the PI Architecture implementation incorporates the PEI and DXE, the HOB producer phase is the PEI phase and the HOB consumer phase is the DXE phase. The producer and consumer can change, however, depending on the implementation.
The following table translates the terminology used in this specification with that used in other PI specifications.
Term Used in the HOB Specification |
Term Used in Other PI Specifications |
---|---|
HOB producer phase |
PEI phase |
HOB consumer phase |
DXE phase |
executable content in the HOB producer phase |
Pre EFI Initialization Module (PEIM) |
hand-off into the HOB consumer phase |
DXE Initial Program Load (IPL) PEIM or DXE IPL PEIM to PEIM Interface (PPI) |
platform boot policy phase |
Boot Device Selection (BDS) phase |
4.2. HOB Overview
The HOB producer phase provides a simple mechanism to allocate memory for data storage during the phase’s execution. The data store is architecturally defined and described by HOBs. This data store is also passed to the HOB producer phase when it is invoked from the HOB producer phase.
The basic container of data storage is named a Hand-Off Block, or HOB. HOBs are allocated sequentially in memory that is available to executable content in the HOB producer phase. There are a series of services that facilitate HOB manipulation. The sequential list of HOBs in memory will be referred to as the HOB list.
For definitions of the various HOB types, see HOB Code Definitions below. The construction semantics are described in Constructing the HOB List below.
4.3. Example HOB Producer Phase Memory Map and Usage
Example HOB Producer Phase Memory Map and Usage shows an example of the HOB producer phase memory map and its usage. This map is a possible means by which to subdivide the region.
4.4. HOB List
The first HOB in the HOB list must be the Phase Handoff Information Table (PHIT) HOB. The last HOB in the HOB list must be the End of HOB List HOB.
Only HOB producer phase components are allowed to make additions or changes to HOBs. Once the HOB list is passed into the HOB consumer phase, it is effectively read only. The ramification of a read-only HOB list is that handoff information, such as boot mode, must be handled in a distinguished fashion. For example, if the HOB consumer phase were to engender a recovery condition, it would not update the boot mode but instead would implement the action using a special type of reset call. The HOB list contains system state data at the time of HOB producer-to-HOB producer handoff and does not represent the current system state during the HOB consumer phase.
4.5. Constructing the HOB List
4.5.1. Constructing the Initial HOB List
The HOB list is initially built by the HOB producer phase. The HOB list is created in memory that is present, initialized, and tested. Once the initial HOB list has been created, the physical memory cannot be remapped, interleaved, or otherwise moved by a subsequent software agent.
The HOB producer phase must build the following three HOBs in the initial HOB list before exposing the list to other modules:
The PHIT HOB
A memory allocation HOB describing where the boot-strap processor (BSP) stack for permanent memory is located
or
A memory allocation HOB describing where the BSP store for permanent memory is located (Itanium® processor family only)
A resource descriptor HOB that describes a physical memory range encompassing the HOB producer phase memory range with its attributes set as present, initialized, and tested
The HOB list creator may build more HOBs into the initial HOB list, such as additional HOBs to describe other physical memory ranges. There can also be additional modules, which might include a HOB producer phase-specific HOB to record memory errors discovered during initialization.
When the HOB producer phase completes its list creation, it exposes a pointer to the PHIT HOB to other modules.
4.5.2. HOB Construction Rules
HOB construction must obey the following rules:
All HOBs must start with a HOB generic header. This requirement allows users to locate the HOBs in which they are interested while skipping the rest. See the
EFI_HOB_GENERIC_HEADER
definition.HOBs may contain boot services data that is available during the HOB producer and consumer phases only until the HOB consumer phase is terminated.
HOBs may be relocated in system memory by the HOB consumer phase. HOBs must not contain pointers to other data in the HOB list, including that in other HOBs. The table must be able to be copied without requiring internal pointer adjustment.
All HOBs must be multiples of 8 bytes in length. This requirement meets the alignment restrictions of the Itanium ® processor family.
The PHIT HOB must always begin on an 8-byte boundary. Due to this requirement and requirement #4 in this list, all HOBs will begin on an 8-byte boundry
HOBs are added to the end of the HOB list. HOBs can only be added to the HOB list during the HOB producer phase, not the HOB consumer phase.
HOBs cannot be deleted. The generic HOB header of each HOB must describe the length of the HOB so that the next HOB can be found. A private GUIDed HOB may provide a mechanism to mark some or its entire contents invalid; however, this mechanism is beyond the scope of this document.
Note: The HOB list must be valid (i.e., no HOBs “under construction”) when any HOB producer phase service is invoked. Another HOB producer phase component’s function might walk the HOB list, and if a HOB header contains invalid data, it might cause unreliable operation.
4.5.3. Adding to the HOB List
To add a HOB to the HOB list, HOB consumer phase software must obtain a pointer to the PHIT HOB (start of the HOB list) and follow these steps:
Determine
NewHobSize
, whereNewHobSize
is the size in bytes of the HOB to be created.Check free memory to ensure that there is enough free memory to allocate the new HOB. This test is performed by checking that
NewHobSize
<= PHIT->EfiFreeMemoryTop
- PHIT->EfiFreeMemoryBottom
).Construct the HOB at PHIT->
EfiFreeMemoryBottom
.Set PHIT->
EfiFreeMemoryBottom
= PHIT->EfiFreeMemoryBottom
+NewHobSize
.