[BOOTLIB]: Clarify some attributes now that their meaning is clearer.
[reactos.git] / reactos / boot / environ / lib / mm / mm.c
index b3a25dd..63814db 100644 (file)
@@ -128,74 +128,6 @@ BlMmRemoveBadMemory (
     return STATUS_SUCCESS;
 }
 
-NTSTATUS
-MmSelectMappingAddress (
-    _Out_ PVOID* MappingAddress,
-    _In_ ULONGLONG Size,
-    _In_ ULONG AllocationAttributes,
-    _In_ ULONG Flags,
-    _In_ PHYSICAL_ADDRESS PhysicalAddress
-    )
-{
-    /* Are we in physical mode? */
-    if (MmTranslationType == BlNone)
-    {
-        /* Just return the physical address as the mapping address */
-        *MappingAddress = (PVOID)PhysicalAddress.LowPart;
-        return STATUS_SUCCESS;
-    }
-
-    /* We don't support virtual memory yet @TODO */
-#ifdef _MSC_VER // Fuck gcc.
-    EfiPrintf(L"not yet implemented in " __FUNCTION__ "\r\n");
-    EfiStall(1000000);
-#endif
-    return STATUS_NOT_IMPLEMENTED;
-}
-
-NTSTATUS
-MmMapPhysicalAddress (
-    _Inout_ PPHYSICAL_ADDRESS PhysicalAddress,
-    _Out_ PVOID VirtualAddress,
-    _Inout_ PULONGLONG Size,
-    _In_ ULONG CacheAttributes
-    )
-{
-    ULONGLONG MappingSize;
-
-    /* Fail if any parameters are missing */
-    if (!(PhysicalAddress) || !(VirtualAddress) || !(Size))
-    {
-        return STATUS_INVALID_PARAMETER;
-    }
-
-    /* Fail if the size is over 32-bits */
-    MappingSize = *Size;
-    if (MappingSize > 0xFFFFFFFF)
-    {
-        return STATUS_INVALID_PARAMETER;
-    }
-
-    /* Nothing to do if we're in physical mode */
-    if (MmTranslationType == BlNone)
-    {
-        return STATUS_SUCCESS;
-    }
-
-    /* Can't use virtual memory in real mode */
-    if (CurrentExecutionContext->Mode == BlRealMode)
-    {
-        return STATUS_UNSUCCESSFUL;
-    }
-
-    /* We don't support virtual memory yet @TODO */
-#ifdef _MSC_VER // Fuck gcc.
-    EfiPrintf(L"not yet implemented in " __FUNCTION__ "\r\n");
-    EfiStall(1000000);
-#endif
-    return STATUS_NOT_IMPLEMENTED;
-}
-
 NTSTATUS
 BlMmMapPhysicalAddressEx (
     _In_ PVOID* VirtualAddress,
@@ -232,7 +164,7 @@ BlMmMapPhysicalAddressEx (
 
     /* Check for invalid requirement flag, if one is present */
     if (((Flags & BlMemoryValidAllocationAttributes) != BlMemoryFixed) &&
-        ((Flags & BlMemoryValidAllocationAttributes) != BlMemoryNonFixed) &&
+        ((Flags & BlMemoryValidAllocationAttributes) != BlMemoryKernelRange) &&
         (Flags & BlMemoryValidAllocationAttributes))
     {
         Status = STATUS_INVALID_PARAMETER;
@@ -249,6 +181,7 @@ BlMmMapPhysicalAddressEx (
 
     /* Select an address to map this at */
     Status = MmSelectMappingAddress(&MappingAddress,
+                                    *VirtualAddress,
                                     Size,
                                     Flags & BlMemoryValidAllocationAttributes,
                                     Flags,
@@ -263,6 +196,7 @@ BlMmMapPhysicalAddressEx (
     MapSize = Size;
     CacheAttributes = ((Flags & BlMemoryValidCacheAttributeMask) != 0x20) ?
                       (Flags & BlMemoryValidCacheAttributeMask) : 0;
+    EfiPrintf(L"Selected address: %p for %lx\r\n", MappingAddress, MappedAddress.LowPart);
     Status = MmMapPhysicalAddress(&MappedAddress,
                                   &MappingAddress,
                                   &MapSize,
@@ -281,10 +215,8 @@ BlMmMapPhysicalAddressEx (
     if (MmTranslationType != BlNone)
     {
         /* We don't support virtual memory yet @TODO */
-#ifdef _MSC_VER // Fuck gcc.
-        EfiPrintf(L"not yet implemented in " __FUNCTION__ "\r\n");
+        EfiPrintf(L"not yet implemented in %S\r\n", __FUNCTION__);
         EfiStall(1000000);
-#endif
         Status = STATUS_NOT_IMPLEMENTED;
         goto Quickie;
     }
@@ -319,10 +251,8 @@ MmUnmapVirtualAddress (
         else
         {
             /* We don't support virtual memory yet @TODO */
-#ifdef _MSC_VER // Fuck gcc.
-            EfiPrintf(L"not yet implemented in " __FUNCTION__ "\r\n");
+            EfiPrintf(L"not yet implemented in %S\r\n", __FUNCTION__);
             EfiStall(1000000);
-#endif
             Status = STATUS_NOT_IMPLEMENTED;
         }
     }
@@ -357,10 +287,8 @@ BlMmUnmapVirtualAddressEx (
         if ((NT_SUCCESS(Status)) && (MmTranslationType != BlNone))
         {
             /* We don't support virtual memory yet @TODO */
-#ifdef _MSC_VER // Fuck gcc.
-            EfiPrintf(L"not yet implemented in " __FUNCTION__ "\r\n");
+            EfiPrintf(L"not yet implemented in %S\r\n", __FUNCTION__);
             EfiStall(1000000);
-#endif
             Status = STATUS_NOT_IMPLEMENTED;
         }
     }