UEFI drivers should not use this service because UEFI drivers should not depend upon the physical memory map of the platform. The
AllocatePages()services allow a UEFI driver to allocate system memory. The
FreePages()services allow an UEFI driver to free previously allocated memory.
If there are limitations on the memory areas that a specific device may use, then those limitations should be managed by a parent I/O abstraction that understands the details of the platform hardware.
For example, PCI device drivers should use the services of the PCI I/O Protocol to manage DMA buffers. The PCI I/O Protocol is produced by the PCI bus driver that uses the services if the PCI Root Bridge I/O Protocol to manage DMA buffers. The PCI Root Bridge I/O Protocol is chipset and platform specific, so the component that produces the PCI Root Bridge I/O Protocol understands what memory regions can be used for DMA operations. By pushing the responsibility into the chipset- and platform-specific components, the PCI device drivers and PCI bus drivers are easier to implement and are portable across a wide variety of platforms.
This service is typically used by a UEFI OS Loader to retrieve the memory map just before the OS takes control of the platform by calling
ExitBootServices(). It may also be used by UEFI applications, such as diagnostics or debug utilities, to show how platform memory has been allocated.