1 /* $Id: mdl.c,v 1.4 2000/03/05 19:17:43 ea 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/mmhal.h>
17 #include <internal/debug.h>
19 /* FUNCTIONS *****************************************************************/
21 PMDL
IoAllocateMdl(PVOID VirtualAddress
,
23 BOOLEAN SecondaryBuffer
,
31 // Mdl = ExAllocatePoolWithQuota(NonPagedPool,
32 // MmSizeOfMdl(VirtualAddress,Length));
33 Mdl
= ExAllocatePool(NonPagedPool
,MmSizeOfMdl(VirtualAddress
,Length
));
37 Mdl
= ExAllocatePool(NonPagedPool
,MmSizeOfMdl(VirtualAddress
,Length
));
39 MmInitializeMdl(Mdl
,VirtualAddress
,Length
);
40 if (Irp
!=NULL
&& !SecondaryBuffer
)
42 Irp
->MdlAddress
= Mdl
;
47 VOID
IoBuildPartialMdl(PMDL SourceMdl
,
52 PULONG TargetPages
= (PULONG
)(TargetMdl
+ 1);
53 PULONG SourcePages
= (PULONG
)(SourceMdl
+ 1);
55 ULONG Delta
= (PAGE_ROUND_DOWN(VirtualAddress
) - (ULONG
)SourceMdl
->StartVa
)/
58 for (Va
= 0; Va
< (PAGE_ROUND_UP(Length
)/PAGESIZE
); Va
++)
60 TargetPages
[Va
] = SourcePages
[Va
+Delta
];
64 VOID
IoFreeMdl(PMDL Mdl
)
66 MmUnmapLockedPages(MmGetSystemAddressForMdl(Mdl
),Mdl
);