3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * FILE: ntoskrnl/io/mdl.c
6 * PURPOSE: Io manager mdl functions
7 * PROGRAMMER: David Welch (welch@mcmail.com)
12 /* INCLUDES *****************************************************************/
14 #include <ddk/ntddk.h>
15 #include <internal/pool.h>
17 #include <internal/debug.h>
19 /* GLOBALS *******************************************************************/
21 #define TAG_MDL TAG('M', 'D', 'L', ' ')
23 /* FUNCTIONS *****************************************************************/
27 IoAllocateMdl(PVOID VirtualAddress,
29 BOOLEAN SecondaryBuffer,
37 // Mdl = ExAllocatePoolWithQuota(NonPagedPool,
38 // MmSizeOfMdl(VirtualAddress,Length));
39 Mdl = ExAllocatePoolWithTag(NonPagedPool,
40 MmSizeOfMdl(VirtualAddress,Length),
45 Mdl = ExAllocatePoolWithTag(NonPagedPool,
46 MmSizeOfMdl(VirtualAddress,Length),
49 MmInitializeMdl(Mdl,VirtualAddress,Length);
50 if (Irp!=NULL && !SecondaryBuffer)
52 Irp->MdlAddress = Mdl;
61 IoBuildPartialMdl(PMDL SourceMdl,
66 PULONG TargetPages = (PULONG)(TargetMdl + 1);
67 PULONG SourcePages = (PULONG)(SourceMdl + 1);
69 ULONG Delta = (PAGE_ROUND_DOWN(VirtualAddress) - (ULONG)SourceMdl->StartVa)/
72 for (Va = 0; Va < (PAGE_ROUND_UP(Length)/PAGE_SIZE); Va++)
74 TargetPages[Va] = SourcePages[Va+Delta];
78 #endif /* LIBCAPTIVE */
83 MmUnmapLockedPages(MmGetSystemAddressForMdl(Mdl), Mdl);