From f8e01ca87b2cad5afb5fc9dc1af68390238e5361 Mon Sep 17 00:00:00 2001 From: klu2 Date: Tue, 13 Jan 2009 07:41:23 +0000 Subject: [PATCH] Fix bugs in decompress implement in EfiLdr, and enable FAT driver in FDF file. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7254 6f19259b-4bc3-4df7-8a09-765794883524 --- DuetPkg/DuetPkg.fdf | 29 +++++++--------- DuetPkg/EfiLdr/EfiLoader.c | 6 +++- DuetPkg/EfiLdr/TianoDecompress.c | 57 ++++++++++++++++++++++---------- 3 files changed, 57 insertions(+), 35 deletions(-) diff --git a/DuetPkg/DuetPkg.fdf b/DuetPkg/DuetPkg.fdf index 9072d98237..35d9a045f6 100644 --- a/DuetPkg/DuetPkg.fdf +++ b/DuetPkg/DuetPkg.fdf @@ -61,10 +61,6 @@ READ_STATUS = TRUE READ_LOCK_CAP = TRUE READ_LOCK_STATUS = TRUE -APRIORI DXE { - INF IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.inf - } - INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf INF MdeModulePkg/Universal/MonotonicCounterRuntimeDxe/MonotonicCounterRuntimeDxe.inf @@ -73,7 +69,6 @@ INF DuetPkg/FSVariable/FSVariable.inf INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf INF MdeModulePkg/Universal/MemoryTest/NullMemoryTestDxe/NullMemoryTestDxe.inf INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf -INF IntelFrameworkModulePkg/Universal/StatusCode/Dxe/DxeStatusCode.inf INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf INF MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf @@ -101,28 +96,28 @@ INF IntelFrameworkModulePkg/Bus/Pci/VgaMiniPortDxe/VgaMiniPortDxe.inf INF IntelFrameworkModulePkg/Universal/Console/VgaClassDxe/VgaClassDxe.inf # IDE Support - #IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf +#IntelFrameworkModulePkg/Bus/Pci/IdeBusDxe/IdeBusDxe.inf # Usb Support -INF MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf -INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf -INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf -INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf +#INF MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf +#INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf +#INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf +#INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf # ISA Support INF DuetPkg/IsaAcpiDxe/IsaAcpi.inf INF IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe/IsaBusDxe.inf INF IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe/IsaSerialDxe.inf -#INF IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf +INF IntelFrameworkModulePkg/Bus/Isa/Ps2KeyboardDxe/Ps2keyboardDxe.inf INF IntelFrameworkModulePkg/Bus/Isa/IsaFloppyDxe/IsaFloppyDxe.inf -#INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf -#INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf -#INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf +INF MdeModulePkg/Universal/Disk/DiskIoDxe/DiskIoDxe.inf +INF MdeModulePkg/Universal/Disk/UnicodeCollation/EnglishDxe/EnglishDxe.inf +INF MdeModulePkg/Universal/Disk/PartitionDxe/PartitionDxe.inf -#FILE DRIVER = 961578FE-B6B7-44c3-AF35-6BC705CD2B1F { -# SECTION PE32 = FatBinPkg/EnhancedFatDxe/Ia32/Fat.efi -# } +FILE DRIVER = 961578FE-B6B7-44c3-AF35-6BC705CD2B1F { + SECTION PE32 = FatBinPkg/EnhancedFatDxe/Ia32/Fat.efi + } [Rule.Common.PEI_CORE] FILE PEI_CORE = $(NAMED_GUID) { diff --git a/DuetPkg/EfiLdr/EfiLoader.c b/DuetPkg/EfiLdr/EfiLoader.c index 6f214d2930..f9804e7ffb 100644 --- a/DuetPkg/EfiLdr/EfiLoader.c +++ b/DuetPkg/EfiLdr/EfiLoader.c @@ -109,7 +109,11 @@ EfiLoader ( PrintString (PrintBuffer); SystemHang(); } - + + AsciiSPrint (PrintBuffer, 256, "BFV decompress: DestinationSize=0x%X, ScratchSize=0x%X!\n", + DestinationSize, ScratchSize); + PrintString (PrintBuffer); + Status = TianoDecompress ( (VOID *)(UINTN)(EFILDR_HEADER_ADDRESS + EFILDRImage->Offset), EFILDRImage->Length, diff --git a/DuetPkg/EfiLdr/TianoDecompress.c b/DuetPkg/EfiLdr/TianoDecompress.c index f2f37bd448..d326805c28 100644 --- a/DuetPkg/EfiLdr/TianoDecompress.c +++ b/DuetPkg/EfiLdr/TianoDecompress.c @@ -189,15 +189,19 @@ Returns: UINT16 Start[18]; UINT16 *Pointer; UINT16 Index3; - UINT16 Index; + volatile UINT16 Index; UINT16 Len; UINT16 Char; UINT16 JuBits; UINT16 Avail; UINT16 NextCode; UINT16 Mask; + UINT16 WordOfStart; + UINT16 WordOfCount; - SetMem (&Count[1], sizeof(UINT16) * 16, 0); + for (Index = 1; Index <= 16; Index++) { + Count[Index] = 0; + } for (Index = 0; Index < NumOfChar; Index++) { Count[BitLen[Index]]++; @@ -206,7 +210,9 @@ Returns: Start[1] = 0; for (Index = 1; Index <= 16; Index++) { - Start[Index + 1] = (UINT16) (Start[Index] + (Count[Index] << (16 - Index))); + WordOfStart = Start[Index]; + WordOfCount = Count[Index]; + Start[Index + 1] = (UINT16) (WordOfStart + (WordOfCount << (16 - Index))); } if (Start[17] != 0) { @@ -222,14 +228,17 @@ Returns: } while (Index <= 16) { - Weight[Index++] = (UINT16) (1U << (16 - Index)); + Weight[Index] = (UINT16) (1U << (16 - Index)); + Index++; } Index = (UINT16) (Start[TableBits + 1] >> JuBits); if (Index != 0) { Index3 = (UINT16) (1U << TableBits); - SetMem(&Table[Index], sizeof(UINT16) * (Index3 - Index + 1), 0); + while (Index != Index3) { + Table[Index++] = 0; + } } Avail = NumOfChar; @@ -366,7 +375,7 @@ Returns: { UINT16 Number; UINT16 CharC; - UINT16 Index; + volatile UINT16 Index; UINT32 Mask; Number = (UINT16) GetBits (Sd, nbit); @@ -378,7 +387,9 @@ Returns: Sd->mPTTable[Index] = CharC; } - SetMem ((VOID*) &Sd->mPTLen, nn * sizeof(UINT8), 0); + for (Index = 0; Index < nn; Index++) { + Sd->mPTLen[Index] = 0; + } return 0; } @@ -409,7 +420,10 @@ Returns: } } - SetMem ((VOID*) &Sd->mPTLen[Index], (nn - Index) * sizeof(UINT8), 0); + while (Index < nn) { + Sd->mPTLen[Index++] = 0; + } + return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable); } @@ -433,7 +447,7 @@ Returns: (VOID) { UINT16 Number; UINT16 CharC; - UINT16 Index; + volatile UINT16 Index; UINT32 Mask; Number = (UINT16) GetBits (Sd, CBIT); @@ -441,7 +455,9 @@ Returns: (VOID) if (Number == 0) { CharC = (UINT16) GetBits (Sd, CBIT); - SetMem ((VOID*)&Sd->mCLen, sizeof(UINT8) * NC, 0); + for (Index = 0; Index < NC; Index++) { + Sd->mCLen[Index] = 0; + } for (Index = 0; Index < 4096; Index++) { Sd->mCTable[Index] = CharC; @@ -495,7 +511,9 @@ Returns: (VOID) } } - SetMem ((VOID*) &Sd->mCLen[Index], sizeof(UINT8) * (NC - Index), 0); + while (Index < NC) { + Sd->mCLen[Index++] = 0; + } MakeTable (Sd, NC, Sd->mCLen, 12, Sd->mCTable); @@ -596,7 +614,7 @@ Returns: (VOID) for (;;) { CharC = DecodeC (Sd); if (Sd->mBadTableFlag != 0) { - return ; + goto Done ; } if (CharC < 256) { @@ -604,7 +622,7 @@ Returns: (VOID) // Process an Original character // if (Sd->mOutBuf >= Sd->mOrigSize) { - return ; + goto Done ; } else { Sd->mDstBase[Sd->mOutBuf++] = (UINT8) CharC; } @@ -623,7 +641,7 @@ Returns: (VOID) while ((INT16) (BytesRemain) >= 0) { Sd->mDstBase[Sd->mOutBuf++] = Sd->mDstBase[DataIdx++]; if (Sd->mOutBuf >= Sd->mOrigSize) { - return ; + goto Done ; } BytesRemain--; @@ -631,6 +649,8 @@ Returns: (VOID) } } +Done: + return ; } EFI_STATUS @@ -714,7 +734,8 @@ Returns: SCRATCH_DATA *Sd; UINT8 *Src; UINT8 *Dst; - + volatile UINT32 Index; + Status = EFI_SUCCESS; Src = Source; Dst = Destination; @@ -749,8 +770,10 @@ Returns: Src = Src + 8; - SetMem ((VOID*) Sd, sizeof(SCRATCH_DATA), 0); - + for (Index = 0; Index < sizeof (SCRATCH_DATA); Index++) { + ((UINT8 *) Sd)[Index] = 0; + } + // // The length of the field 'Position Set Code Length Array Size' in Block Header. // For EFI 1.1 de/compression algorithm(Version 1), mPBit = 4