+ /* Loop trying to find posssible VGA base addresses */
+ while (TRUE)
+ {
+ /* See if this is I/O Space, which we need to map */
+ if (!AddressSpace)
+ {
+ /* Map it */
+ Base = (ULONG_PTR)MmMapIoSpace(TranslatedAddress, 0x400, MmNonCached);
+ }
+ else
+ {
+ /* The base is the translated address, no need to map I/O space */
+ Base = TranslatedAddress.LowPart;
+ }
+
+ /* Try to see if this is VGA */
+ VgaRegisterBase = Base;
+ if (VgaIsPresent())
+ {
+ /* Translate the VGA Memory Address */
+ VgaAddress.LowPart = 0xA0000;
+ AddressSpace = 0;
+ Result = HalFindBusAddressTranslation(VgaAddress,
+ &AddressSpace,
+ &TranslatedAddress,
+ &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);
+ }
+ }
+
+ /* Success! See if this is I/O Space, which we need to map */