c9ce6d72a11ade68d89a9a4762d5fcf814efd3f4
[reactos.git] / reactos / boot / environ / lib / mm / i386 / mmx86.c
1 /*
2 * COPYRIGHT: See COPYING.ARM in the top level directory
3 * PROJECT: ReactOS UEFI Boot Library
4 * FILE: boot/environ/lib/mm/i386/mmx86.c
5 * PURPOSE: Boot Library Memory Manager x86-Specific Code
6 * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8
9 /* INCLUDES ******************************************************************/
10
11 #include "bl.h"
12
13 /* DATA VARIABLES ************************************************************/
14
15 ULONG_PTR MmArchKsegBase;
16 ULONG_PTR MmArchKsegBias;
17 ULONG MmArchLargePageSize;
18 BL_ADDRESS_RANGE MmArchKsegAddressRange;
19 ULONG_PTR MmArchTopOfApplicationAddressSpace;
20 ULONG_PTR Mmx86SelfMapBase;
21
22 typedef VOID
23 (*PBL_MM_FLUSH_TLB) (
24 VOID
25 );
26
27 typedef VOID
28 (*PBL_MM_RELOCATE_SELF_MAP) (
29 VOID
30 );
31
32 PBL_MM_RELOCATE_SELF_MAP BlMmRelocateSelfMap;
33 PBL_MM_FLUSH_TLB BlMmFlushTlb;
34
35 ULONG MmDeferredMappingCount;
36
37 /* FUNCTIONS *****************************************************************/
38
39 VOID
40 MmArchNullFunction (
41 VOID
42 )
43 {
44 /* Nothing to do */
45 return;
46 }
47
48 NTSTATUS
49 Mmx86pMapMemoryRegions (
50 _In_ ULONG Phase,
51 _In_ PBL_MEMORY_DATA MemoryData
52 )
53 {
54 BOOLEAN DoDeferred;
55
56 /* In phase 1 we don't initialize deferred mappings*/
57 if (Phase == 1)
58 {
59 DoDeferred = 0;
60 }
61 else
62 {
63 /* Don't do anything if there's nothing to initialize */
64 if (!MmDeferredMappingCount)
65 {
66 return STATUS_SUCCESS;
67 }
68
69 DoDeferred = 1;
70 }
71
72 if (DoDeferred)
73 {
74 EfiPrintf(L"Deferred todo\r\n");
75 }
76
77 EfiPrintf(L"Phase 1 TODO\r\n");
78 return STATUS_NOT_IMPLEMENTED;
79 }
80
81 NTSTATUS
82 MmArchInitialize (
83 _In_ ULONG Phase,
84 _In_ PBL_MEMORY_DATA MemoryData,
85 _In_ BL_TRANSLATION_TYPE TranslationType,
86 _In_ BL_TRANSLATION_TYPE RequestedTranslationType
87 )
88 {
89 NTSTATUS Status;
90
91 /* For phase 2, just map deferred regions */
92 if (Phase != 1)
93 {
94 return Mmx86pMapMemoryRegions(2, MemoryData);
95 }
96
97 /* What translation type are we switching to? */
98 switch (RequestedTranslationType)
99 {
100 /* Physical memory */
101 case BlNone:
102
103 /* Initialize everything to default/null values */
104 MmArchLargePageSize = 1;
105 MmArchKsegBase = 0;
106 MmArchKsegBias = 0;
107 MmArchKsegAddressRange.Minimum = 0;
108 MmArchKsegAddressRange.Maximum = (ULONGLONG)~0;
109 MmArchTopOfApplicationAddressSpace = 0;
110 Mmx86SelfMapBase = 0;
111
112 /* Set stub functions */
113 BlMmRelocateSelfMap = MmArchNullFunction;
114 BlMmFlushTlb = MmArchNullFunction;
115
116 /* Set success */
117 Status = STATUS_SUCCESS;
118 break;
119
120 case BlVirtual:
121
122 Status = STATUS_NOT_IMPLEMENTED;
123 break;
124
125 case BlPae:
126
127 Status = STATUS_NOT_SUPPORTED;
128 break;
129
130 default:
131 Status = STATUS_INVALID_PARAMETER;
132 break;
133 }
134
135 return Status;
136
137 }