-#ifdef WHOLE_PAGE_ALLOCATIONS
-
-PVOID STDCALL
-ExAllocateWholePageBlock(ULONG Size)
-{
- PVOID Address;
- PFN_TYPE Page;
- ULONG i;
- ULONG NrPages;
- ULONG Base;
-
- NrPages = ROUND_UP(Size, PAGE_SIZE) / PAGE_SIZE;
-
- Base = RtlFindClearBitsAndSet(&NonPagedPoolAllocMap, NrPages + 1, NonPagedPoolAllocMapHint);
- if (Base == 0xffffffff)
- {
- DbgPrint("Out of non paged pool space.\n");
- KEBUGCHECK(0);
- }
- if (NonPagedPoolAllocMapHint == Base)
- {
- NonPagedPoolAllocMapHint += (NrPages + 1);
- }
-
- Address = MiNonPagedPoolStart + Base * PAGE_SIZE;
-
- for (i = 0; i < NrPages; i++)
- {
- Page = MmAllocPage(MC_NPPOOL, 0);
- if (Page == 0)
- {
- KEBUGCHECK(0);
- }
- MmCreateVirtualMapping(NULL,
- Address + (i * PAGE_SIZE),
- PAGE_READWRITE | PAGE_SYSTEM,
- &Page,
- TRUE);
- }
-
- MiCurrentNonPagedPoolLength = max(MiCurrentNonPagedPoolLength, (Base + NrPages) * PAGE_SIZE);
- Size = (Size + 7) & ~7;
- Address = ((PVOID)((PUCHAR)Address + (NrPages * PAGE_SIZE) - Size));
-
- DPRINT("WPALLOC: %x (%d)\n", Address, Size);
-
- return Address;
-}
-
-VOID STDCALL
-ExFreeWholePageBlock(PVOID Addr)
-{
- ULONG Base;
-
- if (Addr < MiNonPagedPoolStart ||
- Addr >= (MiNonPagedPoolStart + MiCurrentNonPagedPoolLength))
- {
- DbgPrint("Block %x found outside pool area\n", Addr);
- KEBUGCHECK(0);
- }
- Base = (Addr - MiNonPagedPoolStart) / PAGE_SIZE;
- NonPagedPoolAllocMapHint = min(NonPagedPoolAllocMapHint, Base);
- while (MmIsPagePresent(NULL, Addr))
- {
- MmDeleteVirtualMapping(NULL,
- Addr,
- TRUE,
- NULL,
- NULL);
- RtlClearBits(&NonPagedPoolAllocMap, Base, 1);
- Base++;
- Addr += PAGE_SIZE;
- }
-}
-
-#endif /* WHOLE_PAGE_ALLOCATIONS */
-
-/* Whole Page Allocations note:
- *
- * We need enough pages for these things:
- *
- * 1) bitmap buffer
- * 2) hdr
- * 3) actual pages
- *
- */