NTOSKRNL.FSRtl MDL stubs added.
[reactos.git] / reactos / ntoskrnl / io / mdl.c
1 /* $Id: mdl.c,v 1.4 2000/03/05 19:17:43 ea Exp $
2 *
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)
8 * UPDATE HISTORY:
9 * Created 22/05/98
10 */
11
12 /* INCLUDES *****************************************************************/
13
14 #include <ddk/ntddk.h>
15 #include <internal/mmhal.h>
16
17 #include <internal/debug.h>
18
19 /* FUNCTIONS *****************************************************************/
20
21 PMDL IoAllocateMdl(PVOID VirtualAddress,
22 ULONG Length,
23 BOOLEAN SecondaryBuffer,
24 BOOLEAN ChargeQuota,
25 PIRP Irp)
26 {
27 PMDL Mdl;
28
29 if (ChargeQuota)
30 {
31 // Mdl = ExAllocatePoolWithQuota(NonPagedPool,
32 // MmSizeOfMdl(VirtualAddress,Length));
33 Mdl = ExAllocatePool(NonPagedPool,MmSizeOfMdl(VirtualAddress,Length));
34 }
35 else
36 {
37 Mdl = ExAllocatePool(NonPagedPool,MmSizeOfMdl(VirtualAddress,Length));
38 }
39 MmInitializeMdl(Mdl,VirtualAddress,Length);
40 if (Irp!=NULL && !SecondaryBuffer)
41 {
42 Irp->MdlAddress = Mdl;
43 }
44 return(Mdl);
45 }
46
47 VOID IoBuildPartialMdl(PMDL SourceMdl,
48 PMDL TargetMdl,
49 PVOID VirtualAddress,
50 ULONG Length)
51 {
52 PULONG TargetPages = (PULONG)(TargetMdl + 1);
53 PULONG SourcePages = (PULONG)(SourceMdl + 1);
54 ULONG Va;
55 ULONG Delta = (PAGE_ROUND_DOWN(VirtualAddress) - (ULONG)SourceMdl->StartVa)/
56 PAGESIZE;
57
58 for (Va = 0; Va < (PAGE_ROUND_UP(Length)/PAGESIZE); Va++)
59 {
60 TargetPages[Va] = SourcePages[Va+Delta];
61 }
62 }
63
64 VOID IoFreeMdl(PMDL Mdl)
65 {
66 MmUnmapLockedPages(MmGetSystemAddressForMdl(Mdl),Mdl);
67 MmUnlockPages(Mdl);
68 ExFreePool(Mdl);
69 }
70
71
72 /* EOF */