[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'.
This commit is contained in:
Hermès Bélusca-Maïto 2019-06-23 03:03:40 +02:00
parent 025cfb108b
commit 8f04a09e74
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

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