Commit Graph

366 Commits

Author SHA1 Message Date
Stanley Chang e9ee58d8ce Add USB command timeout control
A USB disk behind a hub may take longer time to respond command.
Prior to the patch, a magic 2000 ms is set. This patch introduces
a python control (USB_CMD_TIMEOUT) for customizing the timeout if
need. The patch also extends the default timeout to 4196 ms.

This patch does not impact booting time when a platform boots with
a good-conditioning usb disk, because the timeout only takes effect
when a disk does not respond to a USB inquiry for a long time.

Verified: Ehl RVP

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2022-04-12 08:42:07 -07:00
Maurice Ma c4ac8e1939 Update loader serial port hob to support 64bit base
This patch added a new 64bit base field in the loader serial
port hob to support 64bit resource. The revision is updated
to 2. It is backward compatible with revision 1.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2022-03-03 12:45:00 -08:00
Maurice Ma fd6c9dedf3 Add FS load Shell command
This patch adds "fs load" command to SBL shell so that it can be
used to load a file from boot media into memory. It also supports
loading file at specified memory address.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2022-03-03 08:23:00 -08:00
Maurice Ma 6eb006beea Add MP service for payload
This patch adds a MpServiceLib for payload so that a payload
can utilize this library to run tasks on specified processor.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2022-03-02 09:04:08 -08:00
Maurice Ma b0269b62d0 Enhance SerialPortLib to handle debug output during PCI enumeration
If there is DEBUG output during PCI enumeration, it could cause SBL
hang due to invalid PCI bar resource. In this case, SBL will force
to return 0 for any serial port register read. And it might cause
dead loop because of LSR_TXRDY bit polling in SerialPortWrite().
To avoid this potential dead loop, it is required to set LSR_TXRDY
bit for LSR_OFFSET register read if the PCI resource is invalid.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2022-02-28 10:57:26 -08:00
Maurice Ma 76afeb000d Fix incorrect lspci behavior for multi-function PCI device
According to PCI spec, it is required to check the multi-function
support in PCI configuration header type before scanning next PCI
function. Current SBL does not follow this, and it caused duplicated
PCI devices listed in Shell command "lspci".  This patch fixed
this issue.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2022-02-28 10:55:16 -08:00
Maurice Ma 527e787477 Add LZ4 compress support
This patch extended the LZ4 library to support both compression and
decompression. It is useful for SBL to support runtime compression
in order to reduce data size. It is in sync with the LZ4 1.7.4 used
in the BaseTools.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2022-02-08 06:38:59 -08:00
Ong Kok Tong 2474323aa0 [Common] Fix CSME update build issue
There is unresolved external symbol build issue with
BUILD_CSME_UPDATE_DRIVER enabled in BoardConfig.
By adding the BootloaderCommonLib in BootloaderDebugLib
inf file will address this issue.

Signed-off-by: Ong Kok Tong <kok.tong.ong@intel.com>
2022-01-05 12:01:43 -08:00
Maurice Ma e3cc5cacac Update LZMA to match EDK2 LZMA SDK 19
This patch updated LZMA to LZMA SDK 19.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-12-13 14:08:25 -08:00
Maurice Ma 5b5edd2168 Fix EDK2 rebasing caused AzurePipeline build issue
This patch fixed several build issue reported by Azure Pipeline.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-12-13 14:08:25 -08:00
Subash Lakkimsetti 7a3bab7fa3
[TGL][EHL] Fix regression for Flash descriptor lock (#1425)
Add BootMediaWriteByType and use for flash descriptor
update.

Signed-off-by: Subash Lakkimsetti <subash.lakkimsetti@intel.com>
2021-12-01 22:25:11 -07:00
Mike Crowe 990e3e81e6 Use LF line endings in the repository
Convert the line endings stored for all text files in the repository to
LF. The majority previously used DOS-style CRLF line endings. Add a
.gitattributes file to enforce this and treat certain extensions as
never being text files.

Update PatchCheck.py to insist on LF line endings rather than CRLF.
However, its other checks fail on this commit due to lots of
pre-existing complaints that it only notices because the line endings
have changed.

Silicon/QemuSocPkg/FspBin/Patches/0001-Build-QEMU-FSP-2.0-binaries.patch
needs to be treated as binary since it contains a mixture of line
endings.

This change has implications depending on the client platform you are
using the repository from:

* Windows

The usual configuration for Git on Windows means that text files will
be checked out to the work tree with DOS-style CRLF line endings. If
that's not the case then you can configure Git to do so for the entire
machine with:

 git config --global core.autocrlf true

or for just the repository with:

 git config core.autocrlf true

Line endings will be normalised to LF when they are committed to the
repository. If you commit a text file with only LF line endings then it
will be converted to CRLF line endings in your work tree.

* Linux, MacOS and other Unices

The usual configuration for Git on such platforms is to check files out
of the repository with LF line endings. This is probably the right thing
for you. In the unlikely even that you are using Git on Unix but editing
or compiling on Windows for some reason then you may need to tweak your
configuration to force the use of CRLF line endings as described above.

* General

For more information see
https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings .

Fixes: https://github.com/slimbootloader/slimbootloader/issues/1400
Signed-off-by: Mike Crowe <mac@mcrowe.com>
2021-11-10 12:46:42 -08:00
Maurice Ma acfe51f382 Sync up MTRR for MP before boot
SBL might change MTRR to enable framebuffer cache. Current code
only handles BSP MTRR programming, and it is necessary to sync
up the MTRR programming for all APs as well. This patch added
a function to sync up MTRRs for all APs.

Please note, this MTRR sync up is a simplified version for SBL
case since SBL will only add new MTRRs for GFX framebuffer.
To do a full generic MTRRs sync up, it is required to flush cache,
reload TLB, etc. And it will come with some performance impacts.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-11-05 11:09:16 -07:00
Maurice Ma f4a184ef35 Enhance Ext2 filesystem library
For EXT2 filesystem revision 0, there are some fixed fields in the
super block structure according to the documentation. The code should
always use those fixed values for safe regardless of the value inside
the image.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-11-05 07:27:13 -07:00
Guo Dong 5d0195f962 Build SMM HOBs for universal payload
UEFI payload built from open sourced EDK2 supports SMM variable now.
So build the required HOBs to work with EDK2.
This patch just changed the common SBL code, so there is no platform
change required.
This patch also added a PCD PcdBuildSmmHobs for old SMM HOBs and new
SMM HOBs. Late old SMM HOBs might be dropped.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2021-11-04 11:50:00 -07:00
Maurice Ma de621184e8 Adjust debug message in USB libraries
This patch adjusted the following debug message for USB libraries:
  - For SBL, since mutli-TT is not utilized, it should not be
    classified as error message. It is changed to be DEBUG_INFO now.
  - Added DeInit debug print for USB so that it tells the USB
    resources are de-allocated.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-26 14:19:14 -07:00
Maurice Ma dfed4f59bc Add print for bootable USB device name
When multiple USB mass storage devices are connected to the
target, it is not clear to the end user which one is selected
for boot. This patch added code to print the USB mass storage
device manufacturer and product name string. In this way, it
is easier for the end user to identify specific USB device.

It can also be used to determine the HwPart field for USB boot
option. HwPart for USB boot option is mapped to the USB mass
storage device index detected on the platform. BTW, to allow
boot from multiple USB mass storage devices, the optoin
ENABLE_MULTI_USB_BOOT_DEV needs to be enabled. So this patch
enabled ENABLE_MULTI_USB_BOOT_DEV by default.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-26 12:11:51 -07:00
Maurice Ma b490824397 Append ACPI rsdp parameter only for old Linux boot protocol
Current SBL will always append "acpi_rsdp=" as part of the command
line for Linux boot. However, since acpi_rsdp_addr was added in
boot parameter for Linux boot protocol 2.14 and later, it is only
required to do this for old boot protocol. This patch implemented
this.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-21 10:14:30 -07:00
Maurice Ma 21917377c8 Change GetSerialPortBase() API to return 64bit address
When UART bar is alloaced to 64 bit address, the current SBL API
GetSerialPortBase() only returns the lower 32 bit address, which will
cause problem for UART access. This patch fixed this issue.

Please note the patch did not change the payload HOB interface for
UART info. That needs to be updated to 64bit base address too. But this
patch does not cover that.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-21 10:09:20 -07:00
Ong Kok Tong f70b13bf62 [Common] Filename prompt issue fix in OSL shell
When user disabled PRE_OS in bootflag with boot->idx
command in OSL shell but shell still prompt user to
enter PREOS image file path, This is due to the system
check the existing boot option list instead of the
boot option that user currently updating.

Signed-off-by: Ong Kok Tong <kok.tong.ong@intel.com>
2021-10-20 06:01:50 -07:00
James Gutbub 46dc0363ab Resolve VS2015x86 compile issue
When trying to build tgl target with
VS2015x86 there is some error reported:

TimeStampLib.lib: error LNK2001: unresolved external symbol __allmul
FirmwareUpdate.dll : fatal error LNK1120: 1 unresolved externals

This patch resolves the issue by removing
the UINT8 casting.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2021-10-18 08:18:11 -07:00
Maurice Ma 7392f16005 Move paging table build from OsLoader to Stage2
Current SBL will build full address paging table supported by CPU
only at the beginning of the OsLoader. It is better to move it to
Stage2 so that all payloads can have the full range address support
in x64 mode. It also allows Stage2 platform code to access 64bit
PCI resource.  This patch addressed this issue.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-18 08:17:30 -07:00
Maurice Ma 18ccc4115a Enhance GPT partition detection
Current SBL only looks into the primary GPT during partition detection.
If it is not valid, then MRB partition will be checked next. In some
case of the Ubuntu USB disk created, only the 2nd GPT is valid. SBL
should check both primary and secondary GPT table before moving to MBR
check. This patch added this fix.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-18 08:16:37 -07:00
Maurice Ma f453d57835 Clean up NVMe debug message
This patch cleaned up the NVMe library DEBUG message. Lots of the
DEBUG_INFO level were changed to DEBUG_VERBOSE to reduce normal
output.

It also removed the hardcoded device index 0 for NvmeReadBlocks,
NvmeWriteBlocks and NvmeGetMediaInfo APIs.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-18 08:15:30 -07:00
Maurice Ma 638679f87e Fix NVMe library media info
Current NVMe library reports hardcoded block size 512 and block num
512. It is incorrect. This patch fixed it.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-18 08:15:30 -07:00
Maurice Ma 2954034a06 Improve XHCI library timeout polling mechanism
Current XHCI library does a big loop to poll the status of a
USB command execution. In each loop it will delay 1us until
it completes or reachs the timeout. When the loop is very big,
the accumulated 1us delay together will be shifted far beyond
the original timeout requested. This is because of the inaccuracy
of the 1us delay provided by ACPI timer library. This patch
addressed this issue by checking the actual executed time rather
than looping with delay.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-14 11:05:29 -07:00
Maurice Ma 50e5c23594 Revert "Add cache flush on warm reset for SBL shell"
This reverts commit 24f5aa59b5.

There are cases that warm reset is requested before memory is
initialized. Doing WBINVD in this case can cause system hang.
A better approach is to let the caller to decide when to do
cache flush for a warm reset.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-13 14:58:35 -07:00
Maurice Ma 1f3de3399e Enable BIOS region update in single shot
Sometimes it is helpful if SBL can support firmware update from
SBL FW to UEFI FW, or update from incompatible SBL flash layout.
This will need SBL to write full BIOS region without using
redundant partition. To support this, a special capsule image
flag is added to indicate this special update. Please note, this
update might be very risky. This is only for development purpose.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-11 15:29:37 -07:00
Maurice Ma 24f5aa59b5 Add cache flush on warm reset for SBL shell
In some cases, the memory needs to keep consistent across a warm
reset. When warm reset is triggered, it might still have modified
cacheline that has not been flushed to memory yet. The patch added
WBINVD to flush cache before the warm reset.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-11 15:24:07 -07:00
James Gutbub 95482aa01a Resolve KW possible NULL refs in ElfLib
KW scan reported a couple errors regarding
Sec*Shdr value, need to check if they are
NULL before using these values.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2021-10-05 13:32:41 -07:00
Maurice Ma 8c85533285 Add accurate TSC frequency calculation support
Current SBL code uses MSR(0xce) to calculate the CPU TSC frequency.
However, it is not very accurate. A better way is to use CPUID to
calculate the TSC frequency. This patch added new API to get accurate
TSC frequency.  It also added APIs to allow conversion between time
and TSC ticks.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-04 13:16:51 -07:00
Maurice Ma 8d0b3467b5 [QEMU] Fix AUTO boot option index
On SBL, it can support boot option selection through QEMU command line
"-boot order" parameter. However, it does not work anymore. It was
because of the MAX_BOOT_OPTION_CFGDATA_ENTRY adjustment in other commit.
This patch decoupled internal boot option index with the CFGDATA boot
option index so that it does not have impacts on each other. With this
change, QEMU boot option can be altered through command line again.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-04 12:00:05 -07:00
Maurice Ma 9f31593b58 Add Universal Payload library support
Universal Payload uses ELF format. As a result, the ELF loading
library has been enhanced to handle more complicated cases. The
Universal Payload library added an abstract layer on top of
ELF lib to make it easer to use by SBL. OsLoader and Stage2 were
modified to work with the new library interfaces.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-04 11:59:55 -07:00
Maurice Ma 5c98b11ecd Add UniversalPayload header files
This patch added universal payload header files.  Thess files
were copied from EDK2 MdeModulePkg.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-09-30 18:19:13 -07:00
Maurice Ma 5507df44e5 Enhance 64bit to 32bit thunk code
In some cases the paging will be enabled after returning from the
thunked function. To ensure the paging table can be reloaded before
switching back to x64 mode, the paging needs to be in disabled
state. This patch ensures the CR0 bit31 paging bit is cleared.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-09-30 14:50:27 -07:00
Maurice Ma 2d3261bdc3 Add platform device type enum definitions
SBL defined SetDeviceAddr/GetDeviceAddr to abstract platform
device info. However, currently only boot media devices are
defined. It has cases that other platform device info is needed,
such as GFX device. This patch extended the concept to define
some other platform devices as an extenstion to
OS_BOOT_MEDIUM_TYPE. The enum values should not overlap with
the ones defined in OS_BOOT_MEDIUM_TYPE.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-09-30 10:59:20 -07:00
Ong Kok Tong 9aa615c01f [Common] Sync boot option print function
Synced the PrintBootOptions fucntions to print
Pre-OS and extra images.
Fixed bug -> if pre-os or extra images are not enabled
in boot flag and it still output in PrintBootOptions
function

Signed-off-by: Ong Kok Tong <kok.tong.ong@intel.com>
2021-09-28 09:21:23 -07:00
James Gutbub a6a0c317dd Resolve fs cmd KW issue
Currently the PLT_DEVICE_TABLE is limited
to only using OS_BOOT_MEDIUM_TYPE devices
but ideally should be capable of mapping
any system device into the table. For the
time being we will remove the OsBootDeviceGraphics
since it created some KW issue in the fs command.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2021-09-27 17:08:32 -07:00
Maurice Ma 4d83ea1126 Add BOCHS graphics init support
On Simics or QEMU, BOCHS graphics is used. This patch provides
library to initialize BOCHS graphics. It is useful when GFX
initiailzation is not provided by FSP. In this case, the native
code can be used to initialize graphics.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-09-23 09:15:13 -07:00
Maurice Ma 14166f2b37 Enforce FFS alignment in FvLib
When FV extended header exists, the first FFS pointer returned by
GetFirstFfsFileInFv() might not be 8-byte aligned. This patch
adjusted the pointer accordingly to ensure it is aligned per UEFI
spec.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-09-17 13:50:53 -07:00
James Gutbub 2bfdb8faac
Resolve KW issue in boot command (#1280)
Boot command may attempt to use an index which
exceeds the max image type. Check if the value
is larger than the max allowed value and return
if there is an error.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2021-08-31 14:12:08 -07:00
Ong Kok Tong f2b6d0e602 [COMMON] Fix Pre-OS and extra image bug in OSL shell
There is a bug when user use boot->idx command in OSL
shell to modify boot option which contained Pre-OS and extra images
(eg. POSC or RTCM etc.)

Current CmdBoot didnt cover for extra images in idx command.
This patch cover for extra images.

Signed-off-by: Ong Kok Tong <kok.tong.ong@intel.com>
2021-08-30 11:01:49 -07:00
Sai T 06acbc85a2 Fix UefiVarialbeLib KW issues
This patch addresses KW issues reported from UefiVarialbeLib.

Signed-off-by: Sai T <sai.kiran.talamudupula@intel.com>
2021-08-06 12:35:05 -07:00
stalamudupula d627d92c94
Fix UefiVarialbeLib KW issues (#1230)
This patch addresses KW issues reported from UefiVarialbeLib.

Signed-off-by: Sai T <stalamudupula@gmail.com>
2021-07-23 11:34:06 -07:00
stalamudupula ec20bf39e7
Fix security violation for IA32 build in VS2019 toolchain (#1225)
IA32 build from VS2019 toolchain has security violation
because Digest value from SHA512_384 is not matching the
value calculated and stored in hashstore during build.

Aligning the stack to 32-byte boundary during SHA_Update
fixes this error.

Signed-off-by: Talamudupula <stalamudupula@gmail.com>
2021-07-15 09:21:10 -07:00
Vincent Chen de2761170e
add missing UsbBlockIoLib in UsbInitLib.inf (#1216)
Resolve link error when using UsbInitLib
UsbInitLib invokes UsbDeInitBot() which is defined in UsbBlockIoLib

Signed-off-by: Vincent Chen <vincent.chen@intel.com>
2021-07-06 09:18:58 -07:00
Maurice Ma d8c0177fe9 Added mailbox debug port support
This patch allows to use a mailbox register (DWORD) to support debug
port. If CCA debug is connected, it is possible to access certain
SOC register through BSSB. Then this register can be used for debug
console input/output.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-07-01 11:22:16 -07:00
Maurice Ma 163458e32d Add GPIO bit bang debug port library
This patch adds DebugPortLib as a platform extention lib to add new
debug port support. It also adds a generic GpioDebugPortLib to allow
GPIO bit bang to emulate UART TX pin.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-07-01 11:22:16 -07:00
CSHur c7b8d5a848 Fix Linux build issue when adding UefiVariableLib
When adding UefiVariableLib, there is a build issue in Linux.
Fix the build issue.

Signed-off-by: CSHur <cs.hur@intel.com>
2021-06-29 18:23:14 -07:00
CSHur 1db0acf9ba Fix UefiVariableLib code
When adding UefiVariableLib code, there is build issue.
Fix the build issue.

Signed-off-by: CSHur <cs.hur@intel.com>
2021-06-25 06:38:23 -07:00