Intel Extensible Firmware Interface Network Router User Manual


  Open as PDF
of 1084
 
Extensible Firmware Interface Specification
5-18 12/01/02 Version 1.10
5.2 Memory Allocation Services
The functions that make up Memory Allocation Services are used during preboot to allocate and
free memory, and to obtain the system’s memory map. See Table 5-4.
Table 5-4. Memory Allocation Functions
Name Type Description
AllocatePages Boot Allocates pages of a particular type.
FreePages Boot Frees allocated pages.
GetMemoryMap Boot Returns the current boot services memory map and memory map key.
AllocatePool Boot Allocates a pool of a particular type.
FreePool Boot Frees allocated pool.
The way in which these functions are used is directly related to an important feature of EFI memory
design. This feature, which stipulates that EFI firmware owns the system’s memory map during
preboot, has three major consequences:
1. During preboot, all components (including executing EFI images) must cooperate with the
firmware by allocating and freeing memory from the system with the functions
AllocatePages()
, AllocatePool(), FreePages(),andFreePool().The
firmware dynamically maintains the memory map as these functions are called.
2. During preboot, an executing EFI Image must only use the memory it has allocated.
3. Before an executing EFI image exits and returns control to the firmware, it must free all
resources it has explicitly allocated. This includes all memory pages, pool allocations, open file
handles, etc. Memory allocated by the firmware to load an image is freed by the firmware
when the image is unloaded.
When EFI memory is allocated, it is “typed” according to the values in EFI_MEMORY_TYPE (see
the description for AllocatePages()). Some of the types have a different usage before
ExitBootServices()
is called than they do afterwards. Table 5-5 lists each type and its
usage before the call; Table 5-6 lists each type and its usage after the call. The system firmware
must follow the processor-specific rules outlined in sections 2.3.2 and 2.3.3 in the layout of the EFI
memory map to enable the OS to make the required virtual mappings.