https://git.reactos.org/?p=reactos.git;a=commitdiff;h=8f04a09e748ce5c9f3e5779d5964aeffa8979eda

commit 8f04a09e748ce5c9f3e5779d5964aeffa8979eda
Author:     Hermès Bélusca-Maïto <[email protected]>
AuthorDate: Sun Jun 23 03:03:40 2019 +0200
Commit:     Hermès Bélusca-Maïto <[email protected]>
CommitDate: Sun Jun 23 03:07:19 2019 +0200

    [BOOTVID] Fixes for VgaIsPresent() and VidInitialize().
    
    - VgaIsPresent(): Re-select the memory mode register before playing
      around with the sequencer flag. Otherwise the VGA may not be detected
      correctly from time to time.
    
    - VidInitialize(): Simplify the initialization loop, reset AddressSpace
      to its "default" value of 1 when calling HalFindBusAddressTranslation()
      on 'NullAddress'.
---
 drivers/base/bootvid/i386/bootvid.c | 32 +++++++++++++++-----------------
 1 file changed, 15 insertions(+), 17 deletions(-)

diff --git a/drivers/base/bootvid/i386/bootvid.c 
b/drivers/base/bootvid/i386/bootvid.c
index 2909b6c4a93..89fc4f4a6ee 100644
--- a/drivers/base/bootvid/i386/bootvid.c
+++ b/drivers/base/bootvid/i386/bootvid.c
@@ -332,6 +332,9 @@ VgaIsPresent(VOID)
     /* Write null plane */
     __outpw(0x3C4, 0x100);
 
+    /* Select memory mode register */
+    __outpb(0x3C4, 4);
+
     /* Write sequencer flag */
     __outpb(0x3C5, SeqReg2 ^ 8);
 
@@ -365,24 +368,25 @@ VidInitialize(IN BOOLEAN SetMode)
     ULONG_PTR Context = 0;
     PHYSICAL_ADDRESS TranslatedAddress;
     PHYSICAL_ADDRESS NullAddress = {{0, 0}}, VgaAddress;
-    ULONG AddressSpace = 1;
+    ULONG AddressSpace;
     BOOLEAN Result;
     ULONG_PTR Base;
 
     /* Make sure that we have a bus translation function */
     if (!HalFindBusAddressTranslation) return FALSE;
 
-    /* Get the VGA Register address */
-    Result = HalFindBusAddressTranslation(NullAddress,
-                                          &AddressSpace,
-                                          &TranslatedAddress,
-                                          &Context,
-                                          TRUE);
-    if (!Result) return FALSE;
-
     /* Loop trying to find possible VGA base addresses */
     while (TRUE)
     {
+        /* Get the VGA Register address */
+        AddressSpace = 1;
+        Result = HalFindBusAddressTranslation(NullAddress,
+                                              &AddressSpace,
+                                              &TranslatedAddress,
+                                              &Context,
+                                              TRUE);
+        if (!Result) return FALSE;
+
         /* See if this is I/O Space, which we need to map */
         if (!AddressSpace)
         {
@@ -409,20 +413,14 @@ VidInitialize(IN BOOLEAN SetMode)
                                                   &Context,
                                                   FALSE);
             if (Result) break;
-            
-            /* Try to see if there's any other address */
-            Result = HalFindBusAddressTranslation(NullAddress,
-                                                  &AddressSpace,
-                                                  &TranslatedAddress,
-                                                  &Context,
-                                                  TRUE);
-            if (!Result) return FALSE;
         }
         else
         {
             /* It's not, so unmap the I/O space if we mapped it */
             if (!AddressSpace) MmUnmapIoSpace((PVOID)VgaRegisterBase, 0x400);
         }
+
+        /* Continue trying to see if there's any other address */
     }
 
     /* Success! See if this is I/O Space, which we need to map */

Reply via email to