1 /* $Id: mdl.c,v 1.11 2002/10/01 19:27:21 chorns Exp $
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
;
59 IoBuildPartialMdl(PMDL SourceMdl
,
64 PULONG TargetPages
= (PULONG
)(TargetMdl
+ 1);
65 PULONG SourcePages
= (PULONG
)(SourceMdl
+ 1);
67 ULONG Delta
= (PAGE_ROUND_DOWN(VirtualAddress
) - (ULONG
)SourceMdl
->StartVa
)/
70 for (Va
= 0; Va
< (PAGE_ROUND_UP(Length
)/PAGE_SIZE
); Va
++)
72 TargetPages
[Va
] = SourcePages
[Va
+Delta
];
79 MmUnmapLockedPages(MmGetSystemAddressForMdl(Mdl
), Mdl
);