/* If Pages is 0, then NULL is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. */
VOID* EFIAPI AllocatePageTableMemory(IN UINTN Pages)
/* If Pages is 0, then NULL is returned. If there is not enough memory remaining to satisfy the request, then NULL is returned. */
VOID* EFIAPI AllocatePageTableMemory(IN UINTN Pages)
{
  VOID  *Buffer;
  if (Pages == 0) {
    return NULL;
  }
  if ((mPageTablePool == NULL) ||
      (Pages > mPageTablePool->FreePages))
  {
    if (!InitializePageTablePool (Pages)) {
      return NULL;
    }
  }
  Buffer = (UINT8 *)mPageTablePool + mPageTablePool->Offset;
  mPageTablePool->Offset    += EFI_PAGES_TO_SIZE (Pages);
  mPageTablePool->FreePages -= Pages;
  return Buffer;
}