summaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2017-11-15ShellPkg/Shell: Check the OpenVolume result in OpenRootByHandle()Hao Wu1-2/+7
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=779 For the API EfiShellOpenRootByHandle(): The return status of the call to SimpleFileSystem->OpenVolume should be checked. It is possible that there is a media change in the device (like CD/DVD ROM). In such case, the volume root opened and/or the device path opened previously (also within EfiShellOpenRootByHandle) may be invalid. This commit adds a check for the result of OpenVolume before subsequently calling functions like EfiShellGetMapFromDevicePath() & ConvertEfiFileProtocolToShellHandle(). Cc: Jaben Carsey <jaben.carsey@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
2017-11-15MdeModulePkg/PartitionDxe: Fix UDF fs access on certain CD/DVD mediasPaulo Alcantara1-53/+201
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=725 Historically many drives or medias do not correctly return their value for block N - which is also referred as last addressable/recorded block. When they do so, there is still a problem when relying on last recorded block number returned by SCSI commands READ CAPACITY and READ TRACK INFORMATION - that is, between block 0 and block N there may be unwritten blocks which are located outside any track. That said, the Partition driver was unable to find AVDP at block N on certain medias that do not either return or report their last recorded block number correctly. Apparently there is no official or correct way to find the correct block number, however tools like the Philips UDF Conformance Tool (udf_test) apply a correction by searching for an AVDP or VAT in blocks N through N-456 -- this can be observed by looking at the log reported by udf_test on those CD/DVD medias. So, if the AVDP or VAT is found, then it sets the last recorded block number to where AVDP or VAT was located. With the below setence in UDF 2.60, 6.13.2.2 Background Physical Formatting: "... the second AVDP must be recorded after the Background physical Formatting has been finished..." Implies that the last recorded block is the one where second AVDP was recorded. This patch implements a similar way to correct the last recorded block number by searching for last AVDP in blocks N-1 through N-512 on those certain medias, as well as ensure a minimum number of 2 AVDPs found as specified by ECMA 167 and UDF 2.60 specifications. Cc: Hao Wu <hao.a.wu@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Reported-by: Hao Wu <hao.a.wu@intel.com> Signed-off-by: Paulo Alcantara <pcacjr@zytor.com> Reviewed-by: Hao Wu <hao.a.wu@intel.com>
2017-11-14QuarkPlatformPkg/PlatformBootManagerLib: Update boot mode handlingMichael D Kinney1-18/+12
https://bugzilla.tianocore.org/show_bug.cgi?id=768 Update and simplify boot mode handling logic. This includes performing minimum connects for the following boot modes: BOOT_ASSUMING_NO_CONFIGURATION_CHANGES BOOT_WITH_MINIMAL_CONFIGURATION BOOT_ON_S4_RESUME Cc: Kelly Steele <kelly.steele@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Kelly Steele <kelly.steele@intel.com>
2017-11-14QuarkPlatformPkg/Readme.md: Fix markdown format issueMichael D Kinney1-2/+1
https://bugzilla.tianocore.org/show_bug.cgi?id=769 Remove extra carriage return that causes formatting issues. Cc: Kelly Steele <kelly.steele@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Kelly Steele <kelly.steele@intel.com>
2017-11-14MdeModulePkg/UsbMassStorageDxe: Fix USB Mass Storage detectionMichael D Kinney2-6/+14
https://bugzilla.tianocore.org/show_bug.cgi?id=766 Update logic to not return an error from UsbBootRequestSense() if a Request Sense command responds with no sense information. It is legal for a USB mass storage device to respond to a Request Sense command with a SenseKey of USB_BOOT_SENSE_NO_SENSE and an Additional Sense Code of USB_BOOT_ASC_NO_ADDITIONAL_SENSE_INFORMATION. This is described in Section 3.3 of the Universal Serial Bus Mass Storage Specification For Bootability: http://www.usb.org/developers/docs/devclass_docs/usb_msc_boot_1.0.pdf The previous logic returned an error of EFI_NO_RESPONSE and this caused USB mass storage devices such as a USB floppy drive to not be detected. Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2017-11-14ShellPkg: Fix MSFT C4255 warningSong, BinX3-0/+4
V2: Fix MSFT C4255 warning V1: Enable MSFT C4255 warning. From MSDN: Compiler Warning (level 4) C4255 function' : no function prototype given: converting '()' to '(void)' The compiler did not find an explicit list of arguments to a function. This warning is for the C compiler only. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bell Song <binx.song@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2017-11-14NetworkPkg: Fix MSFT C4255 warningSong, BinX1-0/+1
V2: Fix MSFT C4255 warning V1: Enable MSFT C4255 warning. From MSDN: Compiler Warning (level 4) C4255 function' : no function prototype given: converting '()' to '(void)' The compiler did not find an explicit list of arguments to a function. This warning is for the C compiler only. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bell Song <binx.song@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-11-14MdePkg: Fix MSFT C4255 warningSong, BinX3-2/+3
V2: Fix MSFT C4255 warning V1: Enable MSFT C4255 warning. From MSDN: Compiler Warning (level 4) C4255 function' : no function prototype given: converting '()' to '(void)' The compiler did not find an explicit list of arguments to a function. This warning is for the C compiler only. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bell Song <binx.song@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-11-14MdeModulePkg: Fix MSFT C4255 warningSong, BinX7-0/+8
V2: Fix MSFT C4255 warning V1: Enable MSFT C4255 warning. From MSDN: Compiler Warning (level 4) C4255 function' : no function prototype given: converting '()' to '(void)' The compiler did not find an explicit list of arguments to a function. This warning is for the C compiler only. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bell Song <binx.song@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-11-14IntelFrameworkModulePkg: Fix MSFT C4255 warningSong, BinX3-0/+3
V2: Fix MSFT C4255 warning V1: Enable MSFT C4255 warning. From MSDN: Compiler Warning (level 4) C4255 function' : no function prototype given: converting '()' to '(void)' The compiler did not find an explicit list of arguments to a function. This warning is for the C compiler only. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Bell Song <binx.song@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-11-14BaseTools: Fix the bug to re-build uni file for LibraryYonghong Zhu1-4/+6
The root cause is Module's self.CanSkip() is before LibraryAutoGen, then when a uni file of library is changed, Module's self.CanSkip() is still true which cause the library is not regenerated. This patch change Module's self.CanSkip() after LibraryAutoGen. Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=759 Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-11-13MdeModulePkg/Core/Dxe: Remove extra connects for UEFI ApplicationsMichael D Kinney1-2/+10
https://bugzilla.tianocore.org/show_bug.cgi?id=765 The UEFI Specification Boot Services chapter, StartImage() service, EFF 1.10 Extension requires extra calls to ConnectController() if a UEFI Driver produces handles. The DXE Core is performing these extra calls to ConnectController() without evaluating the ImageType. A filter is added to not make extra calls to ConnectController() if the ImageType is EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION. Without this filter, extra calls to ConnectController() may be performed by UEFI Applications or a UEFI Shell Applications that also call ConnectController(). Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2017-11-13MdeModulePkg/TerminalDxe: Fix PCANSI mapping for TRIANGLE and ARROWMichael D Kinney1-9/+9
https://bugzilla.tianocore.org/show_bug.cgi?id=761 When a TerminalType is set to PCANSI, characters in the range 0x00 to 0x1F are control characters. The mapping table for PCANSI maps TRIANGLE glyphs, ARROW_UP glyph, and ARROW_DOWN glyph into this control character range and that causes no characters to be displayed by PCANSI compatible terminal emulators. The mappings are updated so these glyphs are mapped to ANSI characters in the range 0x20 to 0x7E. GEOMETRICSHAPE_UP_TRIANGLE '^' GEOMETRICSHAPE_RIGHT_TRIANGLE '>' GEOMETRICSHAPE_DOWN_TRIANGLE 'v' GEOMETRICSHAPE_LEFT_TRIANGLE '<' ARROW_UP '^' ARROW_DOWN 'v' Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Ruiyu Ni <Ruiyu.ni@intel.com>
2017-11-13StdLib/BsdSocketLib: Remove unused variablesThiebaud Weksteen2-4/+8
TianoCore BZ#677 Remove unused variables and turn nsdispatch macro into a function. This is not what is recommended in the bug ticket but avoid heavier modification of the code (and deviation from upsteam). Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Thiebaud Weksteen <tweek@google.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2017-11-13ArmPlatformPkg/PL031RealTimeClockLib: ignore DST setting when timezone is setArd Biesheuvel1-8/+4
According to the UEFI spec, the timezone setting which the platform needs to record in addition to the actual date and time already reflects the current DST setting. In other words, moving the clock from standard time to daylight saving time also involves adding or subtracting 60 minutes from the timezone setting, as well as flicking the EFI_TIME_IN_DAYLIGHT bit in the DST setting. This means we need to disregard the DST setting if the timezone is specified, and only add or subtract the additional hour if we are on local time. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
2017-11-13ArmPlatformPkg/PL031RealTimeClockLib: remove validation and DST handlingArd Biesheuvel1-171/+15
This library, which is intended to encapsulate the hardware specifics of the ARM PL031 RTC, also implements its own input validation routines and record the timezone and DST settings in its own set of EFI variables. This functionality has recently been added to the core driver, so let's remove it here. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
2017-11-13EmbeddedPkg/RealTimeClockRuntimeDxe: move common functionality into coreArd Biesheuvel2-11/+171
RealTimeClockRuntimeDxe defers the hardware/platform specific handling of reading/setting the hardware clock to RealTimeClockLib, but for unknown reasons, it also defers common functionality such as input validation and recording the timezone and DST settings (which are informational only and not managed by hardware) This has led to a lot of duplication in implementations of RealTimeClockLib as well as TimeBaseLib, to the point where each library implementation has its own set of UEFI variables to record the timezone and DST settings. This makes little sense, and so let's update RealTimeClockRuntimeDxe now to allow future implementations to rely on the core driver to take care of these things. Note that reading the timezone and DST settings occurs before calling into the library, so we can phase out this behavior gradually from library implementations in EDK2, edk2-platforms or out of tree. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
2017-11-13MdeModulePkg: Update IP4 stack to support point-to-point link with 31-bit mask.Fu Siyuan3-27/+18
V2 update: Directly use NetIp4IsUnicast() to check station address in IP driver. This patch is to follow RFC3021 which allows to use 31-bit mask in point-to-point link. If a 31-bit subnet mask is assigned to a point-to-point link, it leaves the <Host-number> with only 1 bit. Consequently, only two possible addresses may result: {<Network-number>, 0} and {<Network-number>, -1} These addresses have historically been associated with network and broadcast addresses (see Section 2.2). In a point-to-point link with a 31-bit subnet mask, the two addresses above MUST be interpreted as host addresses. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Fu Siyuan <siyuan.fu@intel.com> Reviewed-by: Wu Jiaxin <jiaxin.wu@intel.com>
2017-11-13MdePkg: Add definitions for the SPI protocols introduced in PI 1.6.Marvin.Haeuser@outlook.com12-0/+1721
This commit adds header files for the SPI protocols introduced in the UEFI PI 1.6 specification, as well as their GUIDs to MdePkg.dec. EFI_SPI_TRANSACTION_TYPE assumes an enum with its members ordered the way they are listed in the specification, as there are no values given explicitely. EFI_LEGACY_SPI_CONTROLLER_GUID assumes the character 'l' used in the specification was meant to be '1'. V2: - Fixed LegacySpiFlash.h's header guard. - Fixed LegacySpiSmmController's GUID name. - Removed EFI_SPI_NOR_FLASH_PROTOCOL_LF_READ_DATA as it's unused. - Added the missing SpiSmmNorFlash header. - Fixed all file endings to be CRLF. - Removed trailing whitespaces. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marvin Haeuser <Marvin.Haeuser@outlook.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-11-09ArmPlatformPkg/PrePeiCore: seed temporary stack before entering PEI coreArd Biesheuvel5-0/+26
DEBUG builds of PEI code will print a diagnostic message regarding the utilization of temporary RAM before switching to permanent RAM. For example, Total temporary memory: 16352 bytes. temporary memory stack ever used: 4820 bytes. temporary memory heap used for HobList: 4720 bytes. Tracking stack utilization like this requires the stack to be seeded with a known magic value, and this needs to occur before entering C code, given that it uses the stack. Currently, only Nt32Pkg appears to implement this feature, but it is useful nonetheless, so let's wire it up for PrePeiCore. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Liming Gao <liming.gao@intel.com> Acked-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
2017-11-09MdePkg/NvdimmLabel.h: Add NVDIMM_LABEL protocol definitionRuiyu Ni2-0/+354
NVDIMM_LABEL protocol is defined in UEFI 2.7 spec, to provide services that allow management of labels contained in a Label Storage Area in NVDIMM. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-11-09MdePkg/Btt.h: Add Block Translation Table definitionsRuiyu Ni2-0/+234
BTT definitions are defined in UEFI spec 2.7, to defines a layout and set of rules for doing block I/O that provide powerfail write atomicity of a single block in NVDIMM. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-11-09MdeModulePkg SerialDxe: Handle Timeout change more robustlyStar Zeng1-3/+43
https://lists.01.org/pipermail/edk2-devel/2017-October/016479.html reported "Xen Console input very slow in recent UEFI" that appears after 4cf3f37c87ba1f9d58072444bd735e40e4779e70 "MdeModulePkg SerialDxe: Process timeout consistently in SerialRead". Julien did more debugging and find out the following is happening in TerminalConInTimerHandler (MdeModulePkg/Universal/Console/TerminalDxe) when a character is received: 1) GetControl will return EFI_SERIAL_INPUT_BUFFER_EMPTY unset => Entering in the loop to fetch character from the serial 2) GetOneKeyFromSerial() => Return directly with the character read 3) Looping as the fifo is not full and no error 4) GetOneKeyFromSerial() -> SerialRead() => No more character so SerialPortPoll() will return FALSE and loop until timeout => Return EFI_TIMEOUT 5) Exiting the loop from TerminalConInTimerHandler 6) Characters are printed After some investigation, I found it is related to the Timeout value. The Timeout is 1000000 (1s) by default to follow UEFI spec. And the Terminal driver will recalculate and set the Timeout value based on the properties of UART in TerminalDriverBindingStart()/ TerminalConInTimerHandler(). SerialInTimeOut = 0; if (Mode->BaudRate != 0) { // // According to BAUD rate to calculate the timeout value. // SerialInTimeOut = (1 + Mode->DataBits + Mode->StopBits) * 2 * 1000000 / (UINTN) Mode->BaudRate; } For example, based on the PCD values of PcdUartDefaultBaudRate, PcdUartDefaultDataBits and PcdUartDefaultStopBits, SerialInTimeOut = (1 + 8 + 1) * 2 * 1000000 / (UINTN) 115200 = 173 (us). When SerialDxe is used, TerminalDriverBindingStart()/TerminalConInTimerHandler() -> SerialIo->SetAttributes() -> SerialSetAttributes() -> SerialPortSetAttributes() Some implementations of SerialPortSetAttributes() could handle the input parameters and return RETURN_SUCCESS, for example BaseSerialPortLib16550, then Timeout value will be changed to 173 (us), no "slow down" will be observed. But some implementations of SerialPortSetAttributes() just return RETURN_UNSUPPORTED, for example XenConsoleSerialPortLib, then Timeout value will be not changed and kept 1000000 (1s), "slow down" will be observed. SerialPortLib instance can be enhanced to 1. Handle the input parameters and return status accordingly instead of just returning RETURN_UNSUPPORTED in SerialPortSetAttributes(). 2. Just return RETURN_SUCCESS instead of RETURN_UNSUPPORTED in SerialPortSetAttributes() if the instance does not care the input parameters at all. And SerialDxe can also be enhanced like this patch to be more robust to handle Timeout change. Cc: Julien Grall <julien.grall@linaro.org> Cc: Laszlo Ersek <lersek@redhat.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Compare against the original parameters Suggested-by: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Julien Grall <julien.grall@linaro.org>
2017-11-08IntelFsp2Pkg-Tools: GenCfgOpt.py shouldn't include specific UPD nameChasel, Chiu1-12/+0
PcdSerialIoUartDebugEnable UPD is platform specific and should not be included in generic GenCfgOpt.py script. Remove this and platform DSC should control the default value instead. Cc: Jiewen Yao <Jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Chasel Chiu <chasel.chiu@intel.com> Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
2017-11-08IntelFrameworkModulePkg: Fix misuses of AllocateCopyPoolJian J Wang1-5/+5
AllocateCopyPool(AllocationSize, *Buffer) will copy "AllocationSize" bytes of memory from old "Buffer" to new allocated one. If "AllocationSize" is bigger than size of "Buffer", heap memory overflow occurs during copy. One solution is to allocate pool first then copy the necessary bytes to new memory. Another is using ReallocatePool instead if old buffer will be freed on spot. Cc: Liming Gao <liming.gao@intel.com> Cc: Bi Dandan <dandan.bi@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Bi Dandan <dandan.bi@intel.com>
2017-11-08ShellPkg: Fix misuses of AllocateCopyPoolJian J Wang2-3/+8
AllocateCopyPool(AllocationSize, *Buffer) will copy "AllocationSize" bytes of memory from old "Buffer" to new allocated one. If "AllocationSize" is bigger than size of "Buffer", heap memory overflow occurs during copy. One solution is to allocate pool first then copy the necessary bytes to new memory. Another is using ReallocatePool instead if old buffer will be freed on spot. Cc: Jaben Carsey <jaben.carsey@intel.com> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Bi Dandan <dandan.bi@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>
2017-11-08MdeModulePkg: Fix misuses of AllocateCopyPoolJian J Wang6-17/+33
AllocateCopyPool(AllocationSize, *Buffer) will copy "AllocationSize" bytes of memory from old "Buffer" to new allocated one. If "AllocationSize" is bigger than size of "Buffer", heap memory overflow occurs during copy. One solution is to allocate pool first then copy the necessary bytes to new memory. Another is using ReallocatePool instead if old buffer will be freed on spot. Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Bi Dandan <dandan.bi@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Jian J Wang <jian.j.wang@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Bi Dandan <dandan.bi@intel.com>
2017-11-08ShellPkg/dh: Fix wrong output when dumping PciRootBridgeIoRuiyu Ni1-2/+2
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2017-11-08MdeModulePkg/NonDiscoverable: fix memory override bugHeyi Guo1-0/+5
For PciIoPciRead interface, memory prior to Buffer would be written with zeros if Offset was larger than sizeof (Dev->ConfigSpace), which would cause serious system exception. So we add a pre-check branch to avoid memory override. Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org> Cc: Ruiyu Ni <ruiyu.ni@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Heyi Guo <heyi.guo@linaro.org> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
2017-11-08MdePkg/PciExpress21.h: Fix typo in PCI_REG_PCIE_SLOT_CONTROLRuiyu Ni1-12/+12
PCI_REG_PCIE_SLOT_CONTROL contains a typo. It is defined as: typedef union { struct { UINT32 AttentionButtonPressed : 1; UINT32 ... ... } Bits; UINT16 Uint16; } PCI_REG_PCIE_SLOT_CONTROL; The bit field data type should be UINT16 instead of UINT32, results sizeof (PCI_REG_PCIE_SLOT_CONTROL) equals to 4 instead of 2. Because this structure is used in PCI_CAPABILITY_PCIEXP as below: typedef struct { ... PCI_REG_PCIE_SLOT_CONTROL SlotControl; PCI_REG_PCIE_SLOT_STATUS SlotStatus; } PCI_CAPABILITY_PCIEXP; It cause the OFFSET_OF (PCI_CAPABILITY_PCIEXP, SlotStatus) equal to a wrong value. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
2017-11-08PcAtChipsetPkg/IsaAcpiDxe: Restore PCI attributes correctlyRuiyu Ni2-24/+27
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=405 The original code enables some BITs in PCI attributes in Start(), but wrongly to disable these BITs in Stop(). The correct behavior is to save the original PCI attributes before enables some BITs in Start(), and restore to original value in Stop(). Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com>
2017-11-07EmbeddedPkg: Implement NorFlashInfoLibMarcin Wojtas4-0/+356
The SPI NOR flash drivers which base on ArmPlatformPkg's NorFlashDxe usually make use of static declarations of the flash instances with their type and parameters. As a result it implies hardcoding the exact way of flash handling, not to mention the code does not look very nice. Much better solution would be obtaining the flash ID and hence its description in runtime. JEDEC compliant SPI NOR devices allow to obtain their IDs with READ_ID command (0x9f), which should return the vendor ID byte, followed by 2 to 4 following device ID bytes. Use this capability for implementing a NorFlashInfoLib that gives an access to the NOR flash description data, such as name, page size, sector (block) size and others, of more than 50 different models. The new library user should pass an output array from issuing READ_ID command to the NorFlashGetInfo () routine - if the match is found, an allocated (optionally for RT) pool with the flash description copy will be returned. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Marcin Wojtas <mw@semihalf.com> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
2017-11-07SecurityPkg/AuthVariableLib: Use EFI_CERT_DATA to parse certificatechenc21-4/+8
The function Pkcs7GetSigners return certificate stack as binary buffer. Use EFI_CERT_DATA to parsing certificate stack more clearly, and access certificate by the field of EFI_CERT_DATA structure. Cc: Long Qin <qin.long@intel.com> Cc: Zhang Chao <chao.b.zhang@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: chenc2 <chen.a.chen@intel.com> Reviewed-by: Long Qin <qin.long@intel.com> Reviewed-by: Zhang Chao <chao.b.zhang@intel.com>
2017-11-07CryptoPkg/BaseCryptLib: Add C-structure to matching certificate stackchenc23-0/+39
The parameter CertStack of Pkcs7GetSigners will return all embedded X.509 certificate in one given PKCS7 signature. The format is: // // UINT8 CertNumber; // UINT32 Cert1Length; // UINT8 Cert1[]; // UINT32 Cert2Length; // UINT8 Cert2[]; // ... // UINT32 CertnLength; // UINT8 Certn[]; // Add EFI_CERT_STACK and EFI_CERT_DATA structure, these two C-structure are used for parsing CertStack more clearly. Cc: Long Qin <qin.long@intel.com> Cc: Zhang Chao <chao.b.zhang@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: chenc2 <chen.a.chen@intel.com> Reviewed-by: Long Qin <qin.long@intel.com> Reviewed-by: Zhang Chao <chao.b.zhang@intel.com>
2017-11-07ArmPkg/ArmMmuLib: Add new attribute WRITE_BACK_NONSHAREABLEPeicong Li2-0/+12
Flash region needs to be set as cacheable (write back) to increase performance, if PEI is still XIP on flash or DXE FV is decompressed from flash FV. However some ARM platforms do not support to set flash as inner shareable since flash is not normal DDR memory and it will not respond to cache snoop request, which will causes system hang after MMU is enabled. So we need a new ARM memory region attribute WRITE_BACK_NONSHAREABLE for flash region on these platforms specifically. This attribute will set the region as write back but not inner shared. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Peicong Li <lipeicong@huawei.com> Signed-off-by: Heyi Guo <heyi.guo@linaro.org> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
2017-11-07MdeModulePkg/PciBus: Disable BME of all devices when entering RTRuiyu Ni3-0/+91
The patch ensures all DMA transactions are blocked after ExitBootService. If a platform enables IOMMU before and needs disable IOMMU after ExitBootService, the IOMMU should be disabled after PCI bus driver disables BME. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Michael Turner <michael.turner@microsoft.com> Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> Cc: Jeff Fan <vanjeff_919@hotmail.com>
2017-11-07ShellPkg/HexEdit: Fix EBC build failureRuiyu Ni1-2/+2
EfiCpuIoWidthUint8 should be used in HMemImageRead and HMemImageSave. Because CpuIo protocol is now used for memory access. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
2017-11-07MdeModulePkg/VarCheckHii: Enhance VarCheckHiiLib to support bit checkDandan Bi5-130/+310
V3: (1) Reset QuestionStoredInBitField to FALSE at end opcode(EFI_IFR_END_OP) (2) Fix typo and format issues(line alignment for debug print message and value assignment...) V2: (1)Remove the VarOffsetBitLevel/StorageWidthBitLevel to reduce the final VarCheckBinSize and update the implementation accordingly. (2)Update the VAR_CHECK_HII_REVISION (3)Refine the Debug message and function comments,like update oneof", "checkbox", "numeric" to "OneOf", "CheckBox", "Numeric". VarCheckHiiLib check the value set to storage based on the possible value listed in the vfr file. Since we have enhanced vfr to support Question value stored in bit field, so now enhance VarCheckHiiLib to support bit field check. Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2017-11-07MdeModulePkg/VarCheckHiiLib: Replace EFI_D_INFO with DEBUG_INFODandan Bi4-126/+126
In patch 2, we will introduce DEBUG_INFO in VarCheckHiiLib,in order to keep consistence, replace all EFI_D_INFO with DEBUG_INFO firstly in this pacth. Cc: Star Zeng <star.zeng@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2017-11-07MdeModulePkg VarCheckHiiLib: Fix typo "0x02%x" to be "0x%02x"Star Zeng1-4/+4
Cc: Dandan Bi <dandan.bi@intel.com> Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Dandan Bi <dandan.bi@intel.com>
2017-11-06MdeModulePkg/SdMmcPciHcDxe: call SdMmcFreeTrb() to complete sync operationArd Biesheuvel1-7/+1
Currently, we complete a synchronous operation without unmapping the DMA mappings, and free the pages using FreePages () rather than calling EFI_PCI_IO_PROTOCOL::FreeBuffer. This is simply incorrect, but it also breaks non-coherent DMA as well as DMA protection and/or memory encryption so let's do it correctly and call SdMmcFreeTrb() instead. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
2017-11-06CryptoPkg/BaseCryptLib: Fix mismatched memory allocation/freeLong Qin5-20/+32
The malloc/free (instead of AllocatePool/FreePool) were used directly in some wrapper implementations, which was designed to leverage the light-weight memory management routines at Runtime phase. The malloc/free and AllocatePool/FreePool usages are required to be matched, after extra memory size info header was introduced in malloc wrapper. This patch corrects two memory allocation cases, which requires the caller to free the buffer with FreePool() outside the function call. And some comments were also added to clarify the correct memory release functions if it's the caller's responsibility to free the memory buffer. Cc: Laszlo Ersek <lersek@redhat.com> Cc: Ting Ye <ting.ye@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qin Long <qin.long@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
2017-11-06CryptoPkg/BaseCryptLib: Fix buffer overflow issue in realloc wrapperLong Qin1-7/+76
There is one long-standing problem in CRT realloc wrapper, which will cause the obvious buffer overflow issue when re-allocating one bigger memory block: void *realloc (void *ptr, size_t size) { // // BUG: hardcode OldSize == size! We have no any knowledge about // memory size of original pointer ptr. // return ReallocatePool ((UINTN) size, (UINTN) size, ptr); } This patch introduces one extra header to record the memory buffer size information when allocating memory block from malloc routine, and re-wrap the realloc() and free() routines to remove this BUG. Cc: Laszlo Ersek <lersek@redhat.com> Cc: Ting Ye <ting.ye@intel.com> Cc: Jian J Wang <jian.j.wang@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Qin Long <qin.long@intel.com> Reviewed-by: Jian J Wang <jian.j.wang@intel.com> Validated-by: Jian J Wang <jian.j.wang@intel.com>
2017-11-06IntelSiliconPkg IntelVTdDxe: Use ACPI table event to get DMAR tableStar Zeng4-30/+46
Use ACPI table event to get DMAR table instead of using ACPI SDT notification as ACPI SDT is optional and the default value of PcdInstallAcpiSdtProtocol is FALSE in MdeModulePkg.dec. Cc: Jiewen Yao <jiewen.yao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2017-11-05ArmPlatformPkg/PlatformPeim: allow PlatformPeiLib to set the boot modeArd Biesheuvel2-5/+8
The current interdepencies between the PrePeiCore SEC module, the platform PEIM and ArmPlatformLib is a bit awkward: due to the fact that ArmPlatformLib is also used by SEC modules, we cannot use PEI specific facilities in the implementation of ArmPlatformGetBootMode. However, given that we call that library function /after/ invoking PlatformPeiLib, there is no way for that library to set the boot mode other than resorting to tricks like notification callbacks on arbitrary unrelated events. ArmPlatformLib should probably be phased out anyway, given its quirky nature, but for now, let's fix this particular issue by deferring the call to PlatformPeim() to after the point where we set the boot mode by calling ArmPlatformGetBootMode (). While we're at it, clean up the code slightly by using PeiServicesLib instead of doing double pointer dereferencing. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
2017-11-05EmbeddedPkg: introduce GPIO PPIArd Biesheuvel2-0/+154
Introduce a PPI counterpart of the existing 'embedded GPIO' protocol, so we can manipulate GPIOs from PEI modules. This allows things like setting the boot mode based on a DIP switch setting. Note that the naming is slightly awkward, as there is nothing 'embedded' about a GPIO, but given that the DXE protocol already resides here and has the 'embedded' prefix, it makes sense to retain uniformity. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
2017-11-03Nt32Pkg: Update SecMain consumes PCD to get the init value in temp stackLiming Gao2-1/+2
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Star Zeng <star.zeng@intel.com>
2017-11-03MdeModulePkg: Update PeiCore consumes PCD to get the init value in temp stackLiming Gao2-6/+2
Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Reviewed-by: Star Zeng <star.zeng@intel.com>
2017-11-03MdeModulePkg: Add new PCD PcdInitValueInTempStackLiming Gao2-0/+12
https://bugzilla.tianocore.org/show_bug.cgi?id=740 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
2017-11-03BaseTools: parse map file generated by Xcode on MacYonghong Zhu2-1/+36
Add support to parse map file generated by Xcode on Mac to get variable offset and Patchable Pcd info in current EFI file. Cc: Liming Gao <liming.gao@intel.com> Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>