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