Commit Graph

642 Commits

Author SHA1 Message Date
Guo Dong b9ad47848a Move SpiFlashLib into bootloader common package
Cleaned up SpiFlashLib in APL platform, and move it into
BootloaderCommonPkg, so that other platform could reuse
this SpiFlashLib

Signed-off-by: Guo Dong <guo.dong@intel.com>
2019-06-06 14:28:31 -07:00
Guo Dong 9b24273090 Add ACPI_ENABLED()
Add ACPI_ENABLED() to align with MEASURED_BOOT_ENABLED().
Update MEASURED_BOOT_ENABLED() by checking PcdMeasuredBootEnabled
firstly.
Update PlatformFeaturesInit () in stage1b to fix potential inconsistent.
Update other code for changes above.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2019-06-06 14:28:00 -07:00
Guo Dong 512062b1bd Clean up PCI MM address
Common MM_PCI_ADDRESS() provided PCI device BDF to PCIE MMIO base address.
So remove MmPciAddress() and MmPciBase () defined in platform and update
code to use MM_PCI_ADDRESS().
Add TO_PCI_LIB_ADDRESS() in common library.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2019-06-04 12:30:11 -07:00
James Gutbub 90b155b3e3 Enable EXT2/3 sub-directory filepath image loading
Currently when providing a filepath with sub-directories
the EXT2/3 library is not able to locate the file. The
code for traversing sub-directories is already present
but was not enabled. This change enables this support.
Ex: 'boot/iasimage.bin'

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-06-04 11:41:41 -07:00
Raghava Gudla c55eb04d03 Fix error during capsule generation
Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2019-05-24 15:58:43 -07:00
Aiden Park 497e66eadb [FileSystemLib] Added generic filesystem/file access APIs
FileSystemLib provides generic interfaces to access file system and
its files as a abstraction of FatLib/ExtLib.

- Added CloseFileSystem
  If there are opened files in a specific filesystem, those files
  will be de-allocated in CloseFileSystem.
- Added OpenFile/GetFileSize/ReadFile/CloseFile
  The ReadFile() does not allocate any memory for the file content.
  The caller of OpenFile() MUST allocate necessary memory before
  calling ReadFile().

Signed-off-by: Aiden Park <aiden.park@intel.com>
2019-05-23 15:53:03 -07:00
Raghava Gudla cd2f00fe2c Add Multiple firmware update capsule image support
This patch will add support for updating multiple firmwares
using a single capsule image.

Following modifications are made for existing firmware update flow

1) Gather and validate capsule image
2) State Machine will be set to capsule processing state.
3) Signature of the capsule image is now stored in reserved region
   During each reboot until the end of firmware update, stored signature
   will be compared against the capsule image signature to make sure
   capsule image is not modified until the end of firmware update.
4) Process Capsule image to gather firmware images
5) Each Firmware image information will be stored in reserved region
   using FW_UPDATE_COMP_STATUS. Update pending will be marked to
   update pending state indicating that this image is not processed.
6) Firmware update will use the reserved region comp structures starting
   with the first image with update pending state, update the comp update
   pending field to processing and applies the image. After the update, pending
   field will be updated to Done and updates the status of the update in the
   component structure and moves on to next image found.
7) After all the component structure in the reserved region updating pending
   field are set to Done. Firmware update mode is exited.

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2019-05-23 15:52:47 -07:00
Raghava Gudla f489425ba7 Package multiple firmware into single capsule
This patch will update GenCapsuleFirmware.py tool to package
multiple firmware update images into single capsule.

Example:

python GenCapsuleFirmware.py -p BIOS pld1.bin -p <GUID> pld2.bin
	   -p CSME Pld3.bin -p CSMD Pld4.bin -o img.bin -k  TestSigningPrivateKey.pem

The following are the changes made

1) Capsule header format is changed to align with
   EFI_FIRMWARE_MANAGEMENT_CAPSULE_HEADER
2) Each firmware image in the capsule will have
   EFI_FIRMWARE_MANAGEMENT_CAPSULE_IMAGE_HEADER
3) BIOS, CSME, CSME Update Driver (CSMD) and CFGData payloads
   can be passed to the tool using their names as suggested in
   example.
4) Unknown payloads can also be passed to the tool with associated
   guid as input.

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2019-05-23 15:35:24 -07:00
Aiden Park 51b69d447b
[PartitionLib] Added ClosePartitions to clean-up partition data (#167)
The FindPartitions() allocates memory for PART_BLOCK_DEVICE instance.
This allocated memory needs to be de-allocated if no more necessary
to avoid memory leak.

TBD: Current partition info needs to be cleared before going to next
boot option.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2019-05-22 09:03:41 -07:00
Aiden Park 592915c7e7
[MmcAccessLib] Fix SD card single block read failure (#165)
- CMD23(SET_BLOCK_COUNT) is for only MMC.
- CMD17(READ_SINGLE_BLOCK) must be used when reading a single block
  with SD card

Signed-off-by: Aiden Park <aiden.park@intel.com>
2019-05-20 09:48:32 -07:00
Maurice Ma ddbf479f53 Add warning if component is in CSME mapped flash region
On APL the last 256KB flash address space (4GB-256KB to 4GB) is
remapped to CSME SRAM read-only region. During stitching due to space
limitation, if a component gets pushed into this region, then direct
memory mapped access might not work since it will be decoded by CSME.
To access components within this region, SPI command based interfaces
has to be used instead of memory mapped interface.
This patch added warning message when this condition is detected in
the stitching process.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-05-17 16:26:45 -07:00
Maurice Ma 2309a8f5fc [APL] Fix firmware update failure
Firmware update with latest code broke on APL platform.
This patch fixed #162 by:
- Corrected the HECI command response flag check
- Always read FWU state machine using SPI command instead memory map

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-05-17 16:26:31 -07:00
Guo Dong f7bff6b6db Enable EISS for UEFI payload
Set SPI flash EISS and LE for UEFI payload in EndOfStages().
Some clean up on UPDs and create a common function for security check.
Set SMM_FLAGS_4KB_COMMUNICATION flag

Signed-off-by: Guo Dong <guo.dong@intel.com>
2019-05-17 11:11:40 -07:00
Maurice Ma 3bfd7f5cd9 [APL] Fix print message for firmware update
This patch fixed some minor debug message print issue.  It also added
some more debug prints to help identify potentical issue in firmware
update flow.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-05-17 10:50:10 -07:00
Guo Dong f8d361c2a3 Add MP hook point for platform CPU init
Some platform might need do some platform specific init
on all the threads. So add a MP hook using a PCD.
Np impact for the platform that doesn't need this hook.
This patch also enable InSMM bit for APL.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2019-05-17 09:47:43 -07:00
James Gutbub 7a325d18ea Add BaseMemoryLibSse2 library
Copying the MdePkg BaseMemoryLibSse2 library into
SBL for faster CopyMem and other routines to improve
boot performance every where except for Stage1A &
Stage1B due to 'movntdq' usage limitation in earlier
stages. Remove all of the X64 files since SBL is compiled
as 32-bit. Also patch PCI enumeration code to perform
manual memory copying (using SSE2 CopyMem gives some
issue as tested on APL).

The BaseMemoryLibSse2 folder was copied from EDK2
GitHub based on the following commit ID:

9344f0921518309295da89c221d10cbead8531aa

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-05-14 14:56:29 -07:00
James Gutbub c67e5e2955 Add HobListPtr to pre-OS payload param struct
It might be useful for the pre-OS payload/checker
to have a handle to the HOB list data for additional
support or data checking that the HOB list contains.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-05-14 12:00:39 -07:00
James Gutbub e75dd48e83 Enhance BMP image splashing
Current implementation of splashing a BMP image to the
display requires the allocation of a temporary buffer
to store the BMP image into a GOP Blt friendly format
that can then be used to splash the image to the display.
Instead of using a buffer for the whole image we can
allocate a smaller buffer to splash one line at a time
since splashing is already performed one line at a time.

Also fix a small print message regarding frame buffer
format.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-05-13 15:55:55 -07:00
Maurice Ma 9742830d0e Enhance GRUB config file parser
Current GRUB config parser can only handle UNIX EOL style. For DOS
EOL style config file, an extra '\r' will be left at the line end
which might cause failure for initrd file loading due to incorrect
file name string. This patch enhanced the GRUB config file parser
to handle both UNIX and DOS EOL style.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-05-09 17:47:35 -07:00
Maurice Ma f0b92d5890 [APL] Fix ConfigEditor error on changing Boot Option
To ensure ConfigEditor can handle the configuration data type properly,
the default value needs to be valid. For string type configuration item,
the value should start with single quote. The APL default values for OS
image name is set to number 0 instead of '' to indicate empty string.
This patch corrected this and fixed #151.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-05-08 08:17:02 -07:00
James Gutbub e19dbfbf84 Update the pre-OS payload/checker parameter
For the pre-OS payload/checker pass in a parameter
that contains additional information for heap space,
heap address, and additional CPU registers that may
need to be set before the pre-OS payload/checker
passes control to the OS.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-04-30 15:54:39 -07:00
Sai Talamudupula 0522b833df Add Smbios support
Initial Smbios support infrastructure

Signed-off-by: Sai Talamudupula <sai.kiran.talamudupula@intel.com>
2019-04-30 15:22:05 -07:00
Guo Dong 799a9051c8 Update SMM Information HOB
Update LDR_SMM_INFO on SMM control and enable info
Add comments to LDR_SMM_INFO HOB

Signed-off-by: Guo Dong <guo.dong@intel.com>
2019-04-26 08:04:44 -07:00
Maurice Ma 91728894e3 Fix MRC NVS data reading issue (#145)
An issue was reported on APL that MRC will start to do full training
after 119 boot cycles. APL MRC training data contains two parts. One
part will not change, and the other part will change for every boot.
To avoid frequently erasing flash, a rolling method was applied to
save this data into different slot for each boot. When all slots are
full, the whole block will be reclaimed. However, some boundary
condition was not handled properly which caused the NVS data cannot
be located when the slot is close to the end of the block.

This patch addressed this issue by:
 - Force the max slot number to be 8 aligned so that the map is always
   at byte boundary (1 bit for 1 slot in the slot map).
 - When all slots are marked with 0 (all slots are full), set default
   slot to be the last slot so that the last slot will be used to get
   the MRC NVS data.

It fixed #146.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-04-25 16:16:41 -07:00
Maurice Ma 02771f5fb9 Add payload binary file check in BuildUtility.py
This patch added the additional existence check for payload binary.
If the file does not exist, it will error out.  Also if the binary
is already under build FV folder, skip the unnecessary copy.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-04-23 11:11:46 -07:00
Maurice Ma 3c8f71a16c Enhance error message print for OsLoader
This patch added some additional error message print during the
boot media initializtion and file loading. It makes it easier to
identify issues in case of failure.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-04-19 10:43:44 -07:00
Maurice Ma 0d8fad8bbc Allow SATA boot option to boot from any AHCI port
For SATA boot option, the hardware partition is mapped into AHCI
port. Current implementation requires a specific AHCI port in order
to boot from that hard drive. This patch added support to boot
from the first detected AHCI port when the hardware partition is
set to 0xFF.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-04-19 10:43:10 -07:00
James Gutbub 91b9a15a5a Fix the GCC OS Loader FV build error
The GCC build is failing due to recent check-in for OS Loader FV
building. GCC5 is throwing an error that the required fv size
of 0x37718 is exceeding the set fv size of 0x37000. Bump up the FV
size to address this issue.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-04-17 10:31:29 -07:00
Maurice Ma 8255640056 [APL] Enhance Boot Guard check logic for IFWI image
This patch updated the logic to check if Boot Guard is enabled in
the base IFWI image.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-04-16 13:20:28 -07:00
James Gutbub 0721b7c3d4 Add pre-OS checker support
Some OSes may require a pre-OS checker executable
to run before actually jumping to the OS. Add
support for this pre-OS checker loading & execution
as part of the OS Loader payload when it is compiled
as an FV and when ENABLE_PRE_OS_CHECKER option is
enabled in BoardConfig.py (per the following command):

SblBuild.py build <plat> -p OsLoader.Fv:LLDR:Lz4

The pre-OS checker entry point takes in a single
parameter which provides the CPU boot state that
should be loaded once jumping into the OS for the
pre-OS checker to launch after it finishes execution
(e.g. pre-OS checker does not return to Slim Bootloader).

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-04-15 14:16:03 -07:00
Maurice Ma 872f046291 Fix help information for PatchFv.py
The usage information cannot be printed properly in PatchFv.py.
This patch fixed #136.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-04-12 10:59:19 -07:00
Maurice Ma ff2f614917 Allow searching payload file in build FV folder
When specify a payload file in the build command line, the current
searching folder is: PayloadPkg/PayloadBins, Platform/$(PlatformBoardPkg)
/Binaries. This patch added another searching folder in the Build FV
if the payload file cannot be found in the listed folders above. This
is useful when the payload image itself is generated from the build
process.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-04-12 10:44:21 -07:00
Maurice Ma 3dfcd913eb Fix incorrect image base for TE image
TE image has stripped header to reduce the image size. When calculating
the preferred base for TE image, the gap should be added back in order
to match the actual TE image base. This patch fixed #133.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-04-12 10:44:02 -07:00
Guo Dong ef4dbd9177 Fix debug message display issue
The message was displayed before the value was copied.
So adjust the sequence to correct it.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2019-04-10 12:18:06 -07:00
Maurice Ma 0980e74c12 Remove IPP 7z file from BootloaderCommonPkg
This patch removed the IPP 7z file from the BootloaderCommonPkg.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-04-10 10:26:59 -07:00
Guo Dong 5c041c0fe1 Clean up graphics HOBs
Removing the HOB defined by SBL to use generic HOBs from EDK2.
Update GraphicsLib for above HOB change.
Update osloader and multibootLib for hob change.
update APL and Qemu platform for hob change.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2019-04-10 10:23:58 -07:00
Maurice Ma fa55d1aa68 [APL] Add SMBUS access library
For APL, the board might need SMBUS communication to talk to some
devices, such as PMIC. This patch ported the SMBUS library from
open sourced EDK2 Minnowboard3. Basic test was done on LeafHill
CRB to read/write PMIC registers through SMBUS.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-04-08 12:53:26 -07:00
Maurice Ma 1253b19c14 [QEMU] Adjust SPI image layout to have fixed size
Current QEMU build will produce many different SPI layouts due to
different build feature flags, such as source level debug support.
Since QEMU is a virtual platform, it is better to relax the size
so as to have consistent SPI layout. It will make it easier for
debug. This patch produces fixed QEMU image size (2MB).

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-04-08 11:59:10 -07:00
Maurice Ma 12c634890b [APL] Fix ACPI FADT parameters to match SOC
This patch updated some parameters in APL ACPI FADT table so as to
match the actual SOC registers. It fixed #124 .

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-04-08 11:58:58 -07:00
Huang Jin beaadc624b Update README
Signed-off-by: Huang Jin <huang.jin@intel.com>
2019-04-03 15:52:20 -07:00
James Gutbub f022d093ba Add SBL logos for community usage
Slim Bootloader has its own set of approved logos. Add them to
the repo for community usage along with guidelines on logo usage.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-04-03 13:33:09 -07:00
Maurice Ma 98f687e692 [QEMU] Allow select UEFI payload from QEMU command line
Current SBL depends on GEN_CFG_DATA.PayloadId to determine which payload
to boot if multiple payloads exist. With this patch, when PayloadId is
set to "AUTO", QEMU will use the QEMU command line parameter
'-boot order' to determine which payload to boot.

For example, adding '-boot order=dba' in QEMU commadn line will boot to
UEFI payload. This provides a simple way to test different payloads using
the same SBL image.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-03-26 16:37:58 -07:00
Maurice Ma ca6b6d56c4 Update SBL to use the approved SBL logo
Slim Bootloader has its own approved logo. Updated the original logo
to use this new one.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-03-26 09:05:09 -07:00
Maurice Ma 1245809d20 [APL] Add full IFWI stitching python script
This script creates a new Apollo Lake Slim Bootloader IFWI image using
FIT tool and other ingredients. The FIT tool and some stitching
ingredients are not public available. Please contact your Intel
representative to get them.

This script can support both Linux and Windows environment.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-03-21 07:23:43 -07:00
Maurice Ma 9f3b9f2a3b Add command line loading CFGDATA support in ConfigEditor
This patch added support to load CFGDATA directly from command line
interface. Minor clean-up work is also done to remove unused and
duplicated functions.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-03-20 16:30:05 -07:00
Raghava Gudla f514ba35b7 Added support for FWST OEM ACPI table
This patch added support for FWST ACPI table. This table
contains generic address structure which has pointer to the
EFI System Resource Table.

ESRT table for now supports only system firmware. This table
will provide the operating system and tools knowledge of what
is the last attempt status and version of the system firmare
update.

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2019-03-20 16:03:57 -07:00
Raghava Gudla ed4f7d1aad This patch add code to handle fsp requested reset
after silicon init API call. Also added code after
memory init to differentitate warm and cold reset requests.

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2019-03-20 15:59:19 -07:00
Maurice Ma dcbe27a70a [APL] Update StitchLoader.py to check Boot Guard status
The APL StitchLoader.py script has its own limitation. For example,
if Boot Guard is enabled in the base image, the final stitched image
with this script might not boot due to security reason. It is better
to check this during stitching process so that it can error out earlier
to notify the user.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-03-19 08:07:27 -07:00
Maurice Ma f6c1b690c2 Disable deprecated EDKII API interfaces
This patch enabled DISABLE_NEW_DEPRECATED_INTERFACES build option by
default so that the deprecated APIs cannot be used in SBL source tree.
It is to enhance the coding for security.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-03-14 11:26:03 -07:00
Maurice Ma afe4dde4fb Remove UPT tool from BaseTools
This patch removed unused UPT tool from BaseTools. This UPT tool
also contains sqlite3.dll binary. It is not preferred in the source
repo.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-03-13 15:07:00 -07:00