[NTOS:MM] Use inline functions to acquire/release the PFN lock.
[reactos.git] / ntoskrnl / mm / ARM3 / dynamic.c
1 /*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: BSD - See COPYING.ARM in the top level directory
4 * FILE: ntoskrnl/mm/ARM3/dynamic.c
5 * PURPOSE: ARM Memory Manager Dynamic Physical Memory Support
6 * PROGRAMMERS: ReactOS Portable Systems Group
7 */
8
9 /* INCLUDES *******************************************************************/
10
11 #include <ntoskrnl.h>
12 #define NDEBUG
13 #include <debug.h>
14
15 #define MODULE_INVOLVED_IN_ARM3
16 #include <mm/ARM3/miarm.h>
17
18 /* FUNCTIONS *****************************************************************/
19
20 /*
21 * @unimplemented
22 */
23 NTSTATUS
24 NTAPI
25 MmAddPhysicalMemory (IN PPHYSICAL_ADDRESS StartAddress,
26 IN OUT PLARGE_INTEGER NumberOfBytes)
27 {
28 UNIMPLEMENTED;
29 return STATUS_NOT_IMPLEMENTED;
30 }
31
32 /*
33 * @unimplemented
34 */
35 NTSTATUS
36 NTAPI
37 MmMarkPhysicalMemoryAsBad(IN PPHYSICAL_ADDRESS StartAddress,
38 IN OUT PLARGE_INTEGER NumberOfBytes)
39 {
40 UNIMPLEMENTED;
41 return STATUS_NOT_IMPLEMENTED;
42 }
43
44 /*
45 * @unimplemented
46 */
47 NTSTATUS
48 NTAPI
49 MmMarkPhysicalMemoryAsGood(IN PPHYSICAL_ADDRESS StartAddress,
50 IN OUT PLARGE_INTEGER NumberOfBytes)
51 {
52 UNIMPLEMENTED;
53 return STATUS_NOT_IMPLEMENTED;
54 }
55
56 /*
57 * @unimplemented
58 */
59 NTSTATUS
60 NTAPI
61 MmRemovePhysicalMemory(IN PPHYSICAL_ADDRESS StartAddress,
62 IN OUT PLARGE_INTEGER NumberOfBytes)
63 {
64 UNIMPLEMENTED;
65 return STATUS_NOT_IMPLEMENTED;
66 }
67
68 /*
69 * @implemented
70 */
71 PPHYSICAL_MEMORY_RANGE
72 NTAPI
73 MmGetPhysicalMemoryRanges(VOID)
74 {
75 ULONG Size, i;
76 PPHYSICAL_MEMORY_RANGE Entry, Buffer;
77 KIRQL OldIrql;
78 ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
79
80 //
81 // Calculate how much memory we'll need
82 //
83 Size = sizeof(PHYSICAL_MEMORY_RANGE) * (MmPhysicalMemoryBlock->NumberOfRuns + 1);
84
85 //
86 // Allocate a copy
87 //
88 Entry = Buffer = ExAllocatePoolWithTag(NonPagedPool, Size, 'hPmM');
89 if (!Buffer) return NULL;
90
91 //
92 // Lock the PFN database
93 //
94 OldIrql = MiAcquirePfnLock();
95
96 //
97 // Make sure it hasn't changed before we had acquired the lock
98 //
99 ASSERT(Size == (sizeof(PHYSICAL_MEMORY_RANGE) *
100 (MmPhysicalMemoryBlock->NumberOfRuns + 1)));
101
102 //
103 // Now loop our block
104 //
105 for (i = 0; i < MmPhysicalMemoryBlock->NumberOfRuns; i++)
106 {
107 //
108 // Copy the data, but format it into bytes
109 //
110 Entry->BaseAddress.QuadPart = MmPhysicalMemoryBlock->Run[i].BasePage << PAGE_SHIFT;
111 Entry->NumberOfBytes.QuadPart = MmPhysicalMemoryBlock->Run[i].PageCount << PAGE_SHIFT;
112 Entry++;
113 }
114
115 //
116 // Last entry is empty
117 //
118 Entry->BaseAddress.QuadPart = 0;
119 Entry->NumberOfBytes.QuadPart = 0;
120
121 //
122 // Release the lock and return
123 //
124 MiReleasePfnLock(OldIrql);
125 return Buffer;
126 }