Extensible Firmware Interface Specification
42 12/12/00 Version 1.02
3.2 Memory Allocation Services
The functions that make up Memory Allocation Services are used during pre-boot to allocate and
free memory, and to obtain the systems memory map. See Table 3-4.
Table 3-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 systems memory map during
pre-boot, has three major consequences:
1. During pre-boot, 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(), and FreePool(). The
firmware dynamically maintains the memory map as these functions are called.
2. During pre-boot, 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
Section 3.2.1). Some of the types have a different usage before ExitBootServices() is called
than they do afterwards. Table 3-5 lists each type and its usage before the call; Table 3-6 lists each
type and its usage after the call.