Fix bug of wrong stack16 stack for thunk call. This may cause Duet failed to enter graphic mode under Qemu simulator or some platforms.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7771 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
klu2 2009-03-02 15:03:37 +00:00
parent 71bd6db178
commit 237bb9d0be
2 changed files with 21 additions and 16 deletions

View File

@ -1043,6 +1043,7 @@ BiosVideoCheckForVbe (
VESA_BIOS_EXTENSIONS_VALID_EDID_TIMING ValidEdidTiming;
EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *GraphicsOutputMode;
DEBUG ((EFI_D_INFO, "Enter BiosVideoCheckForVbe()\n"));
//
// Allocate buffer under 1MB for VBE data structures
//
@ -1095,26 +1096,33 @@ BiosVideoCheckForVbe (
Regs.X.ES = EFI_SEGMENT ((UINTN) BiosVideoPrivate->VbeInformationBlock);
Regs.X.DI = EFI_OFFSET ((UINTN) BiosVideoPrivate->VbeInformationBlock);
DEBUG ((EFI_D_INFO, "Before VESA!\n"));
LegacyBiosInt86 (BiosVideoPrivate, 0x10, &Regs);
DEBUG ((EFI_D_INFO, "Call VESA! Return Status=0x%X\n", Regs.X.AX));
DEBUG ((EFI_D_INFO, "Call VESA! VESA Signature =0x%X\n", BiosVideoPrivate->VbeInformationBlock->VESASignature));
DEBUG ((EFI_D_INFO, "Call VESA! VESA Version =0x%X\n", BiosVideoPrivate->VbeInformationBlock->VESAVersion));
Status = EFI_DEVICE_ERROR;
//
// See if the VESA call succeeded
//
if (Regs.X.AX != VESA_BIOS_EXTENSIONS_STATUS_SUCCESS) {
DEBUG ((EFI_D_INFO, "Fail to call VESA! Status=0x%X\n", Regs.X.AX));
return Status;
}
//
// Check for 'VESA' signature
//
if (BiosVideoPrivate->VbeInformationBlock->VESASignature != VESA_BIOS_EXTENSIONS_VESA_SIGNATURE) {
DEBUG ((EFI_D_INFO, "Fail to check VESA signature!\n"));
return Status;
}
//
// Check to see if this is VBE 2.0 or higher
//
if (BiosVideoPrivate->VbeInformationBlock->VESAVersion < VESA_BIOS_EXTENSIONS_VERSION_2_0) {
DEBUG ((EFI_D_INFO, "VBE version is little than 2.0!\n"));
return Status;
}

View File

@ -146,17 +146,17 @@ LegacyBiosInt86 (
BOOLEAN Ret;
UINT16 *Stack16;
Regs->X.Flags.Reserved1 = 1;
Regs->X.Flags.Reserved2 = 0;
Regs->X.Flags.Reserved3 = 0;
Regs->X.Flags.Reserved4 = 0;
Regs->X.Flags.IOPL = 3;
Regs->X.Flags.NT = 0;
Regs->X.Flags.IF = 1;
Regs->X.Flags.TF = 0;
Regs->X.Flags.CF = 0;
ZeroMem (&ThunkRegSet, sizeof (ThunkRegSet));
ThunkRegSet.E.EFLAGS.Bits.Reserved_0 = 1;
ThunkRegSet.E.EFLAGS.Bits.Reserved_1 = 0;
ThunkRegSet.E.EFLAGS.Bits.Reserved_2 = 0;
ThunkRegSet.E.EFLAGS.Bits.Reserved_3 = 0;
ThunkRegSet.E.EFLAGS.Bits.IOPL = 3;
ThunkRegSet.E.EFLAGS.Bits.NT = 0;
ThunkRegSet.E.EFLAGS.Bits.IF = 1;
ThunkRegSet.E.EFLAGS.Bits.TF = 0;
ThunkRegSet.E.EFLAGS.Bits.CF = 0;
ThunkRegSet.E.EDI = Regs->E.EDI;
ThunkRegSet.E.ESI = Regs->E.ESI;
ThunkRegSet.E.EBP = Regs->E.EBP;
@ -167,8 +167,6 @@ LegacyBiosInt86 (
ThunkRegSet.E.DS = Regs->E.DS;
ThunkRegSet.E.ES = Regs->E.ES;
CopyMem (&(ThunkRegSet.E.EFLAGS), &(Regs->E.EFlags), sizeof (UINT32));
//
// The call to Legacy16 is a critical section to EFI
//
@ -184,16 +182,15 @@ LegacyBiosInt86 (
ASSERT_EFI_ERROR (Status);
Stack16 = (UINT16 *)((UINT8 *) BiosDev->ThunkContext->RealModeBuffer + BiosDev->ThunkContext->RealModeBufferSize - sizeof (UINT16));
Stack16 -= sizeof (ThunkRegSet.E.EFLAGS) / sizeof (UINT16);
CopyMem (Stack16, &ThunkRegSet.E.EFLAGS, sizeof (ThunkRegSet.E.EFLAGS));
ThunkRegSet.E.SS = (UINT16) (((UINTN) Stack16 >> 16) << 12);
ThunkRegSet.E.ESP = (UINT16) (UINTN) Stack16;
ThunkRegSet.E.Eip = (UINT16)((UINT32 *)NULL)[BiosInt];
ThunkRegSet.E.CS = (UINT16)(((UINT32 *)NULL)[BiosInt] >> 16);
BiosDev->ThunkContext->RealModeState = &ThunkRegSet;
AsmThunk16 (BiosDev->ThunkContext);
//
// Restore protected mode interrupt state
//