9dbf5c7dd9a810af950fbb1fe3b7593cae5f5c15
1 /* $Id: mdl.c,v 1.12 2003/07/10 15:47:00 royce 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 *****************************************************************/
30 IoAllocateMdl(PVOID VirtualAddress
,
32 BOOLEAN SecondaryBuffer
,
40 // Mdl = ExAllocatePoolWithQuota(NonPagedPool,
41 // MmSizeOfMdl(VirtualAddress,Length));
42 Mdl
= ExAllocatePoolWithTag(NonPagedPool
,
43 MmSizeOfMdl(VirtualAddress
,Length
),
48 Mdl
= ExAllocatePoolWithTag(NonPagedPool
,
49 MmSizeOfMdl(VirtualAddress
,Length
),
52 MmInitializeMdl(Mdl
,VirtualAddress
,Length
);
53 if (Irp
!=NULL
&& !SecondaryBuffer
)
55 Irp
->MdlAddress
= Mdl
;
65 IoBuildPartialMdl(PMDL SourceMdl
,
70 PULONG TargetPages
= (PULONG
)(TargetMdl
+ 1);
71 PULONG SourcePages
= (PULONG
)(SourceMdl
+ 1);
73 ULONG Delta
= (PAGE_ROUND_DOWN(VirtualAddress
) - (ULONG
)SourceMdl
->StartVa
)/
76 for (Va
= 0; Va
< (PAGE_ROUND_UP(Length
)/PAGE_SIZE
); Va
++)
78 TargetPages
[Va
] = SourcePages
[Va
+Delta
];
88 MmUnmapLockedPages(MmGetSystemAddressForMdl(Mdl
), Mdl
);