X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=OvmfPkg%2FQemuVideoDxe%2FVbeShim.c;h=e45a08e8873f15cdf366b0b4a537e6b579460392;hp=6a569f62744938d2e38f6ae9239ce4a2a0058267;hb=947f3737abf65fda63f3ffd97fddfa6986986868;hpb=8c0b0b34f7875571ee9d3a2a1a28484cef36d969 diff --git a/OvmfPkg/QemuVideoDxe/VbeShim.c b/OvmfPkg/QemuVideoDxe/VbeShim.c index 6a569f6274..e45a08e887 100644 --- a/OvmfPkg/QemuVideoDxe/VbeShim.c +++ b/OvmfPkg/QemuVideoDxe/VbeShim.c @@ -25,6 +25,7 @@ #include #include #include +#include #include "Qemu.h" #include "VbeShim.h" @@ -63,7 +64,8 @@ InstallVbeShim ( EFI_PHYSICAL_ADDRESS Segment0, SegmentC, SegmentF; UINTN Segment0Pages; IVT_ENTRY *Int0x10; - EFI_STATUS Status; + EFI_STATUS Segment0AllocationStatus; + UINT16 HostBridgeDevId; UINTN Pam1Address; UINT8 Pam1; UINTN SegmentCPages; @@ -87,10 +89,14 @@ InstallVbeShim ( // Segment0Pages = 1; Int0x10 = (IVT_ENTRY *)(UINTN)Segment0 + 0x10; - Status = gBS->AllocatePages (AllocateAddress, EfiBootServicesCode, - Segment0Pages, &Segment0); - - if (EFI_ERROR (Status)) { + Segment0AllocationStatus = gBS->AllocatePages ( + AllocateAddress, + EfiBootServicesCode, + Segment0Pages, + &Segment0 + ); + + if (EFI_ERROR (Segment0AllocationStatus)) { EFI_PHYSICAL_ADDRESS Handler; // @@ -100,7 +106,7 @@ InstallVbeShim ( // Handler = (Int0x10->Segment << 4) + Int0x10->Offset; if (Handler >= SegmentC && Handler < SegmentF) { - DEBUG ((EFI_D_VERBOSE, "%a: Video BIOS handler found at %04x:%04x\n", + DEBUG ((EFI_D_INFO, "%a: Video BIOS handler found at %04x:%04x\n", __FUNCTION__, Int0x10->Segment, Int0x10->Offset)); return; } @@ -109,8 +115,12 @@ InstallVbeShim ( // Otherwise we'll overwrite the Int10h vector, even though we may not own // the page at zero. // - DEBUG ((EFI_D_VERBOSE, "%a: failed to allocate page at zero: %r\n", - __FUNCTION__, Status)); + DEBUG (( + DEBUG_INFO, + "%a: failed to allocate page at zero: %r\n", + __FUNCTION__, + Segment0AllocationStatus + )); } else { // // We managed to allocate the page at zero. SVN r14218 guarantees that it @@ -123,7 +133,30 @@ InstallVbeShim ( // // Put the shim in place first. // - Pam1Address = PCI_LIB_ADDRESS (0, 0, 0, 0x5A); + // Start by determining the address of the PAM1 register. + // + HostBridgeDevId = PcdGet16 (PcdOvmfHostBridgePciDevId); + switch (HostBridgeDevId) { + case INTEL_82441_DEVICE_ID: + Pam1Address = PMC_REGISTER_PIIX4 (PIIX4_PAM1); + break; + case INTEL_Q35_MCH_DEVICE_ID: + Pam1Address = DRAMC_REGISTER_Q35 (MCH_PAM1); + break; + default: + DEBUG (( + DEBUG_ERROR, + "%a: unknown host bridge device ID: 0x%04x\n", + __FUNCTION__, + HostBridgeDevId + )); + ASSERT (FALSE); + + if (!EFI_ERROR (Segment0AllocationStatus)) { + gBS->FreePages (Segment0, Segment0Pages); + } + return; + } // // low nibble covers 0xC0000 to 0xC3FFF // high nibble covers 0xC4000 to 0xC7FFF