Author: ion
Date: Sun Feb  5 22:34:47 2017
New Revision: 73721

URL: http://svn.reactos.org/svn/reactos?rev=73721&view=rev
Log:
[BOOTLIB]: Implement MmArchTranslateVirtualAddress for non-paging mode. Stub 
Mmx86TranslateVirtualAddress.
[BOOTLIB]: Support EfiPrintf in Protected mode.
[BOOTLIB]: Support EfiGetMemoryMap in Protected Mode.

Modified:
    trunk/reactos/boot/environ/include/bl.h
    trunk/reactos/boot/environ/lib/firmware/efi/firmware.c
    trunk/reactos/boot/environ/lib/mm/i386/mmx86.c
    trunk/reactos/boot/environ/lib/mm/mm.c
    trunk/reactos/boot/environ/lib/mm/pagealloc.c

Modified: trunk/reactos/boot/environ/include/bl.h
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/include/bl.h?rev=73721&r1=73720&r2=73721&view=diff
==============================================================================
--- trunk/reactos/boot/environ/include/bl.h     [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/include/bl.h     [iso-8859-1] Sun Feb  5 
22:34:47 2017
@@ -2173,6 +2173,13 @@
 BlMmTranslateVirtualAddress (
     _In_ PVOID VirtualAddress,
     _Out_ PPHYSICAL_ADDRESS PhysicalAddress
+    );
+
+BOOLEAN
+MmArchTranslateVirtualAddress (
+    _In_ PVOID VirtualAddress,
+    _Out_opt_ PPHYSICAL_ADDRESS PhysicalAddress,
+    _Out_opt_ PULONG CachingFlags
     );
 
 /* BLOCK ALLOCATOR ROUTINES **************************************************/

Modified: trunk/reactos/boot/environ/lib/firmware/efi/firmware.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/firmware/efi/firmware.c?rev=73721&r1=73720&r2=73721&view=diff
==============================================================================
--- trunk/reactos/boot/environ/lib/firmware/efi/firmware.c      [iso-8859-1] 
(original)
+++ trunk/reactos/boot/environ/lib/firmware/efi/firmware.c      [iso-8859-1] 
Sun Feb  5 22:34:47 2017
@@ -143,12 +143,17 @@
     }
     else
     {
-        /* FIXME: @TODO: Not yet supported */
-        // FIXME: Hack while we are in early rosload mode
+        /* Switch to real mode */
+        BlpArchSwitchContext(BlRealMode);
+
+        /* Call EFI directly */
         if (EfiConOut != NULL)
         {
             EfiConOut->OutputString(EfiConOut, BlScratchBuffer);
         }
+
+        /* Switch back to protected mode */
+        BlpArchSwitchContext(BlProtectedMode);
     }
 
     /* All done */
@@ -559,13 +564,27 @@
 {
     BL_ARCH_MODE OldMode;
     EFI_STATUS EfiStatus;
-
-    /* Are we in protected mode? */
-    OldMode = CurrentExecutionContext->Mode;
-    if (OldMode != BlRealMode)
-    {
-        /* FIXME: Not yet implemented */
-        return STATUS_NOT_IMPLEMENTED;
+    PHYSICAL_ADDRESS MemoryMapSizePhysical, MemoryMapPhysical, MapKeyPhysical;
+    PHYSICAL_ADDRESS DescriptorSizePhysical, DescriptorVersionPhysical;
+
+    /* Are we in protected mode? */
+    OldMode = CurrentExecutionContext->Mode;
+    if (OldMode != BlRealMode)
+    {
+        /* Convert all of the addresses to physical */
+        BlMmTranslateVirtualAddress(MemoryMapSize, &MemoryMapSizePhysical);
+        MemoryMapSize = (UINTN*)MemoryMapSizePhysical.LowPart;
+        BlMmTranslateVirtualAddress(MemoryMap, &MemoryMapPhysical);
+        MemoryMap = (EFI_MEMORY_DESCRIPTOR*)MemoryMapPhysical.LowPart;
+        BlMmTranslateVirtualAddress(MapKey, &MapKeyPhysical);
+        MapKey = (UINTN*)MapKeyPhysical.LowPart;
+        BlMmTranslateVirtualAddress(DescriptorSize, &DescriptorSizePhysical);
+        DescriptorSize = (UINTN*)DescriptorSizePhysical.LowPart;
+        BlMmTranslateVirtualAddress(DescriptorVersion, 
&DescriptorVersionPhysical);
+        DescriptorVersion = (UINTN*)DescriptorVersionPhysical.LowPart;
+
+        /* Switch to real mode */
+        BlpArchSwitchContext(BlProtectedMode);
     }
 
     /* Make the EFI call */

Modified: trunk/reactos/boot/environ/lib/mm/i386/mmx86.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/i386/mmx86.c?rev=73721&r1=73720&r2=73721&view=diff
==============================================================================
--- trunk/reactos/boot/environ/lib/mm/i386/mmx86.c      [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/lib/mm/i386/mmx86.c      [iso-8859-1] Sun Feb  5 
22:34:47 2017
@@ -78,6 +78,59 @@
     return STATUS_NOT_IMPLEMENTED;
 }
 
+BOOLEAN
+Mmx86TranslateVirtualAddress (
+    _In_ PVOID VirtualAddress,
+    _Out_opt_ PPHYSICAL_ADDRESS PhysicalAddress,
+    _Out_opt_ PULONG CachingFlags
+    )
+{
+    EfiPrintf(L"paging  TODO\r\n");
+    return FALSE;
+}
+
+BOOLEAN
+MmArchTranslateVirtualAddress (
+    _In_ PVOID VirtualAddress, 
+    _Out_opt_ PPHYSICAL_ADDRESS PhysicalAddress, 
+    _Out_opt_ PULONG CachingFlags
+    )
+{
+    PBL_MEMORY_DESCRIPTOR Descriptor;
+
+    /* Check if paging is on */
+    if ((CurrentExecutionContext) &&
+        (CurrentExecutionContext->ContextFlags & BL_CONTEXT_PAGING_ON))
+    {
+        /* Yes -- we have to translate this from virtual */
+        return Mmx86TranslateVirtualAddress(VirtualAddress,
+                                            PhysicalAddress,
+                                            CachingFlags);
+    }
+
+    /* Look in all descriptors except truncated and firmware ones */
+    Descriptor = MmMdFindDescriptor(BL_MM_INCLUDE_NO_FIRMWARE_MEMORY &
+                                    ~BL_MM_INCLUDE_TRUNCATED_MEMORY,
+                                    BL_MM_REMOVE_PHYSICAL_REGION_FLAG,
+                                    (ULONG_PTR)VirtualAddress >> PAGE_SHIFT);
+
+    /* Return the virtual address as the physical address */
+    if (PhysicalAddress)
+    {
+        PhysicalAddress->HighPart = 0;
+        PhysicalAddress->LowPart = (ULONG_PTR)VirtualAddress;
+    }
+
+    /* There's no caching on physical memory */
+    if (CachingFlags)
+    {
+        *CachingFlags = 0;
+    }
+
+    /* Success is if we found a descriptor */
+    return Descriptor != NULL;
+}
+
 NTSTATUS
 MmArchInitialize (
     _In_ ULONG Phase,

Modified: trunk/reactos/boot/environ/lib/mm/mm.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/mm.c?rev=73721&r1=73720&r2=73721&view=diff
==============================================================================
--- trunk/reactos/boot/environ/lib/mm/mm.c      [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/lib/mm/mm.c      [iso-8859-1] Sun Feb  5 
22:34:47 2017
@@ -312,9 +312,8 @@
         return FALSE;
     }
 
-    EfiPrintf(L"Unhandled virtual path\r\n");
-    return FALSE;
-    //return MmArchTranslateVirtualAddress(VirtualAddress, PhysicalAddress, 
NULL);
+    /* Do the architecture-specific translation */
+    return MmArchTranslateVirtualAddress(VirtualAddress, PhysicalAddress, 
NULL);
 }
 
 NTSTATUS

Modified: trunk/reactos/boot/environ/lib/mm/pagealloc.c
URL: 
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/environ/lib/mm/pagealloc.c?rev=73721&r1=73720&r2=73721&view=diff
==============================================================================
--- trunk/reactos/boot/environ/lib/mm/pagealloc.c       [iso-8859-1] (original)
+++ trunk/reactos/boot/environ/lib/mm/pagealloc.c       [iso-8859-1] Sun Feb  5 
22:34:47 2017
@@ -888,8 +888,9 @@
             /* Free the previous entries, if any */
             MmMdFreeList(&FirmwareMdList);
 
-            /* Get the firmware map */
-            Status = MmFwGetMemoryMap(&FirmwareMdList, 2);
+            /* Get the firmware map, coalesced */
+            Status = MmFwGetMemoryMap(&FirmwareMdList,
+                                      BL_MM_FLAG_REQUEST_COALESCING);
             if (!NT_SUCCESS(Status))
             {
                 goto Quickie;
@@ -905,7 +906,7 @@
             /* Free the previous entries, if any */
             MmMdFreeList(&FirmwareMdList);
 
-            /* Get the firmware map */
+            /* Get the firmware map, uncoalesced */
             Status = MmFwGetMemoryMap(&FirmwareMdList, 0);
             if (!NT_SUCCESS(Status))
             {


Reply via email to