Commit Graph

199 Commits

Author SHA1 Message Date
Sai Talamudupula 709d7c1470 Support boot image from container
Add support to load the boot image from container.
Container must be signed using the same private key
as the key used to sign IAS (i.e. IAS_PRIVATE_KEY).

Signed-off-by: Sai Talamudupula <sai.kiran.talamudupula@intel.com>
2019-10-02 12:18:45 -07:00
Sai Talamudupula 1a7287881b Update ContainerLib
Add GetNextAvailableComponent() and authenticate the
components after registering them in CONTAINER_LIST.

Signed-off-by: Sai Talamudupula <sai.kiran.talamudupula@intel.com>
2019-09-27 14:13:01 -07:00
Sai Talamudupula d4d364045c Add DBG2 ACPI table infrastructure
This patch provides the basic infrastructure to add a
Debug Port Table  2 (DBG2) to specify one or more ports
for debugging purposes. More info reg DBG2 @ :
https://docs.microsoft.com/en-us/previous-versions/windows/hardware/design/dn639131(v=vs.85)?redirectedfrom=MSDN

If the platform wants to report a debug port to Windows,
it should patch the DBG2 template provided with the
corresponding debug port information. And this updated
DBG2 must be referenced in RSDT.

Signed-off-by: Sai Talamudupula <sai.kiran.talamudupula@intel.com>
2019-09-16 19:40:59 -07:00
Sai Talamudupula 9af34bca9a Remove Core pkg references from Common pkg
By design, BootloaderCommonPkg should not refer to
BootloaderCorePkg. Hence removed those references in
the .inf files in Common pkg.

Moving SmbiosInitLib to Core pkg as it is a core feature.

Signed-off-by: Sai Talamudupula <sai.kiran.talamudupula@intel.com>
2019-08-22 06:26:18 -07:00
Sai Talamudupula f0b5eaf43a Add UEFI Get Variable support
Users might want to have some parameters that can be set
from UEFI environment. UEFI NVRAM variables provide a way
to achieve this functionality. And they require these vars
to be read from bootloader.

This patch provides a library to get read access to the
UEFI variables stored in NV region. The driver was ported
from MdeModulePkg\Universal\Variable\Pei @ EDKII Open Source.

Signed-off-by: Sai Talamudupula <sai.kiran.talamudupula@intel.com>
2019-08-16 07:25:20 -07:00
Subash Lakkimsetti fa2124f91e [CFL] Add TPMType param to Loader Platform info HOB
Update TpmType to LoaderPlatform info hob based on
Type updated in Platform Info. LoaderPlatformInfo revision
is updated.

Signed-off-by: Subash Lakkimsetti <subashx.lakkimsetti@intel.com>
2019-08-14 14:44:23 -07:00
Maurice Ma 19a0890a54 Break Load Linux BzImage into more functions
This patch splitted LoadBzImage() into two functions.  One is just
for kernel loading.  The other one UpdateLinuxBootParams() is for
Linux boot parameter updates. It is required to do so because when
kernel loading in Stage2 is enabled the loading occurs before all
HOBs are finalized. The Linux boot parameters depend on HOBs to fill
correct information, such as frame buffer. With this patch, the boot
parameters can be updated at the very end.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-08-12 10:40:11 -07:00
Maurice Ma 4a5af4f8b0 Add Linux Kernel Boot Support in Stage2
OsLoader has the capability to boot a Linux kernel. However, to support
LinuxBoot type of payload, it is required to load kernel in Stage2. This
patch abstracts the standard Linux loading logic into common LinuxLib
class so that it can be linked in Stage2 or Payload such as OsLoader.
A new PcdLinuxPayloadEnabled is introduced to control if this feature
should be enabled or not.

To boot a Linux kernel from Stage2, it is required to put the command
line file and kernel image into the EPAYLOAD container during the build.
And the PayloadId CFGDATA needs to be set to 'LINX'.
For example:
  python BuildLoader.py build qemu
         -p OsLoader.efi::Lz4;vmlinuz:LINX:Dummy;cmdline.txt:CMDL:Dummy
vmlinuz and cmdkube.txt need to be copied to PayloadPkg/PayloadBins
folder. If kernel size cannot fit into EPAYLOAD, EPAYLOAD_SIZE in
BoardConfig.py needs to be adjusted accordingly.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-08-09 16:48:12 -07:00
Maurice Ma 944e5b8d2d Break down boot option CFGDATA
The current implementation used a huge array to represent boot options in
a single CFGDATA tag. With this approach, when a different board needs
to modify a single field, the whole array needs to be duplicated in the
CFGDATA. It is not efficient. A better approach is to break the options
into individual boot option CFGDATA tag. It will reduce the overall CFGDATA
in general. This patch implemented this mechanism. A library interface
FillBootOptionListFromCfgData() is provided to convert the CFGDATA into
the required OS_BOOT_OPTION_LIST.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-08-07 14:06:45 -07:00
Aiden Park 5103615bfb [ShellLib] Add ShellCommandRegister API
Currently, all shell commands are statically defined in header file.
Add shell command registration API to allow include/exclude shell
commands dynamically.
Later, some debug shell commands will be added according to build
mode or debug mask.
- TBD: Sorting shell commands by name

Signed-off-by: Aiden Park <aiden.park@intel.com>
2019-08-05 21:04:27 -07:00
Maurice Ma ef682b19c3 Switch to use container for EPAYLOAD
This patch enabled container use case for EPAYLOAD loading.
It also switched to use LoadComponent() API for Stage2 and
payload loading. It simplified the code flow. An example in
QEMU was added to demonstrate on how to add a container in
build and load it in Stage2 code.

To define a container layout, it is required to provide
GetContainerList() in BoardConfig.py. Then in stage or payload
code, LoadComponent() can be used to load a component from the
container.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-08-01 15:58:25 -07:00
James Gutbub d6a21287d4 Add initial support for Mender boot
Mender is an A/B partitioning scheme
for Linux OSes. Adding initial support
for specifying the root partition label
that should be used. Later on the root
partition label should be acquired based
on the value of the env files stored in
the EFI/FAT32 partition of the boot media.

Also fix misspellings.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-08-01 14:07:36 -07:00
James Gutbub 4623f82719 Replace HASH_INDEX_* with COMP_TYPE_*
Since HASH_INDEX_* is a 1:1 mapping with
COMP_TYPE_* we can remove HASH_INDEX_* and
replace with COMP_TYPE_*.

Also fix some misspellings.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-08-01 08:56:29 -07:00
James Gutbub 723672c5ca Add COMP_TYPE_PAYLOAD_DYNAMIC for DoHashVerify
Recent update to DoHashVerify routine is no longer
working for HASH_INDEX_PAYLOAD_DYNAMIC (ex. UEFI
Payload). Need to add COMP_TYPE_PAYLOAD_DYNAMIC
and increase COMP_TYPE_INVALID to resolve the
issue.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-07-31 15:11:43 -07:00
Maurice Ma 93b2e96d8e Add ContainerLib to support sub-region
This patch added a ContainerLib to support load and location a
component from a specified container. It copies the component
from flash to memory, authenticate it, and then decompress it if
required. It can also be used to support load component from flash
map in SBL stage2 or payload, such as payload or e-payload.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-07-31 09:32:00 -07:00
lsubash 8b00a77adb Update TPM Type to Loader Platform info HOB
TPM type as dTPM and fTPM is utilized in UEFI payload to
update TPM instance

Signed-off-by: Subash Lakkimsetti <subashx.lakkimsetti@intel.com>
2019-07-31 07:57:14 -07:00
Maurice Ma 626a8db20e Add temporary memory management for MemoryAllocationLib
There are cases where temporary memory is required in stages. Since
MemoryAllocationLib instance for stages has no de-allocation function,
it needs special handling. This patch added temporary memory management
into standard MemoryAllocatoinLib interface.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-07-29 14:44:02 -07:00
Guo Dong 214fd3de91 Add a platform flag for SPI flash SMM write disable
When writing flash in SMM mode, some platform need disable SMM write
protection. when this flag is set, it means this platform need disable
SMM write protection.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2019-07-29 14:42:19 -07:00
Aiden Park 0066eccdb3
Re-implement ElfLib for ELF32 format image (#193)
The previous implementation has a little confusion in license header.
To avoid further annoying, simply re-implement ElfLib.
- 32bits, little-endian, executable elf only supported
- elf32.h/elf_common.h from BaseTools/Source/C/GenFw
- LoadElfImage() interface changed

Signed-off-by: Aiden Park <aiden.park@intel.com>
2019-06-17 16:58:08 -07:00
Guo Dong 5e10bd1e07 Update BSD license to BSD+Patent license
To align with EDK2, update file license
to use BSD+Patent license

Signed-off-by: Guo Dong <guo.dong@intel.com>
2019-06-13 10:46:49 -07:00
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 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
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
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
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
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
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 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
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
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 a62bd10f63 Add framebuffer info into Multiboot table
Multiboot defined framebuffer structure.  However, it was not
implemented in SBL.  This patch added this support by filling in
the framebuffer information into the multiboot table.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-03-06 13:28:10 -08:00
Sai Talamudupula 5f09e82c10 Enhance SMMBASE_INFO communication structure
Match the strcture definition with payload

Signed-off-by: Sai Talamudupula <sai.kiran.talamudupula@intel.com>
2019-03-01 21:10:12 -08:00
Sai Talamudupula 14c3862005 Relocate SMM bases on S3 resume path
Smm bases for all the procs need to be relocated on the
S3 resume path (as payload is not run) for Windows boot.

Signed-off-by: Sai Talamudupula <sai.kiran.talamudupula@intel.com>
2019-02-26 11:23:29 -07:00
Subash Lakkimsetti 5e1174fc67 Security Flags updates to LOADER_PLATFORM_INFO
LOADER_GLOBAL_DATA.LdrFeatures is updated in early stages and
subsequent stages could use these flags.

LOADER_PLATFORM_INFO.LdrFeatures is used to for feature updates
and this need to be checked by loader and payloads.

LOADER_PLATFORM_INFO.HwState for Hw supported features as
Boot guard profiles.

Signed-off-by: Subash Lakkimsetti <subashx.lakkimsetti@intel.com>
2019-02-25 10:45:39 -07:00
Maurice Ma 7b37f56ff2 Refactor LiteFvLib/LitePeCoffLib implementation
This patch did some clean up for LiteFvLib and LitePeCoffLib.  It
also moved LoadFvImage() API from Stage2 core code into the LiteFvLib.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-01-31 14:06:36 -08:00
Guo Dong 095f281023 Enhance UEFI payload support
Previously SBL expects UEFI payload entrypoint and base at
hardcoded address of FV header. With this patch, SBL could
parse FV to get these info.

TEST=Tested on Leafhill and boot UEFI payload success.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2019-01-28 13:54:11 -08:00
Guo Dong ee4b3f812f Add SMM support to UEFI payload
Build a new SMM info HOB to payload to report SMM info.
Add UEFI payload variable region into flash map.

TEST=Tested on LeafHill with UEFI payload.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2019-01-22 17:11:54 -07:00
Guo Dong 501be46716 Update file system support
The patch gives the platform the configuration capability to only build
required file system into final image.
This helps to have a smaller image for fast boot.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2018-11-27 15:09:14 -07:00
Raghava Gudla 91c09cee79 Updated FwUpdate to get capsule info from cfg data
This patch updates firmware update code to get capsule location
information from configuration data instead of searching in all the
available boot media.

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2018-11-21 10:32:44 -07:00
Guo Dong cd9edfdd8b Add Device table
Update core code to support device table.
Updated boot option to consume device table.
Update firmware update to consume device table.
Update shell command on boot option changes.
Add device table for APL and Qemu.
Remove unnecessary code.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2018-11-12 09:38:59 -07:00
Aiden Park 76db3e9714 Support ELF format payload
In order to support ELF format payload in Stage2, ElfLib is separated
from MultibootLib.

Additionally,
- Load ONLY Executable/Loadable segments
- Keep LoadElfSymtab function for future use
- Mark ELF syms flag as 'not supported' in MultibootInfo

Change-Id: Iec1ca6770ffeff9222b71327216cc6176ea1e925
Signed-off-by: Aiden Park <aiden.park@intel.com>
2018-10-30 17:41:41 -07:00
Borgerson, Matthew A 47ffab52ab Add shell command to print contents of log buffer
This patch adds a new shell command `dmesg` to print out the contents of
the boot log buffer.

Signed-off-by: Borgerson, Matthew A <matthew.a.borgerson@intel.com>
2018-10-29 16:39:00 -07:00
Borgerson, Matthew A 2255bc10b0 Enable basic framebuffer text console output
This patch simplifies the GraphicsLib code and adds an abstraction layer
for printing to a virtual "console," through the familier
ConsoleWrite(buffer, len) style function call.

ConsoleWrite can be configured to output to either the serial port, or
the display framebuffer, or both. This primarily enables the command
shell to be used with a display and keyboard.

Signed-off-by: Borgerson, Matthew A <matthew.a.borgerson@intel.com>
2018-10-25 19:25:44 -07:00
Aiden Park b6697f12a8
Enable DebugAgentLib to support source level debug over serial (#18)
* Enable DebugAgentLib to support source level debug over serial

By default, source level debug is NOT enabled. ENABLE_SOURCE_DEBUG
needs to be set to 1 in BoardConfig.py of each Platforms.
- self.ENABLE_SOURCE_DEBUG  = 1

As an initial drop, there are some limitations on APL platform.
- Stage1A does not include DebugAgentLib due to Stage1A size
  limitation(32KB). Further optimization is required.
- DebugAgentLib supports ONLY POSTMEM debugging on APL currently.

Refer to EDKII Debugging:
- https://github.com/tianocore/tianocore.github.io/wiki/EDK-II-Debugging
- https://github.com/tianocore/tianocore.github.io/wiki/SourceLevelDebugPkg

Change-Id: Ia28c5470bc5755768f2b380cc1dabbcb8ee60f0d
Signed-off-by: Aiden Park <aiden.park@intel.com>

* Additional changes for DebugAgent

- Adjust stage size depending on ENABLE_SOURCE_DEBUG Pcd value
- Add PeCoffFindAndReportImageInfo
- Fix debugger hang at Shell

Change-Id: I11b41e5ad610fcb2999e9d43e5dd8f8899e8265a
Signed-off-by: Aiden Park <aiden.park@intel.com>

* Move PeCoffFindAndReportImageInfo() from LitePeCoffLib to DebugAgentLib

Change-Id: I2c4ab4f9561dfd0536da1820048f0e5f2660e2ab
Signed-off-by: Aiden Park <aiden.park@intel.com>
2018-10-15 10:45:23 -07:00
Maurice Ma 09f8270825 Add USB input console support
This patch implemented USB keyboard library and added it as an
input console device. It can be enabled by setting BIT1 in
self.CONSOLE_IN_DEVICE_MASK in BoardConfig.py. By default, it
will be disabled for performance and size consideration.

Test has been done on APL Leafhill board. USB keyboard can work
in Shell.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2018-10-09 12:56:58 -07:00
Maurice Ma bd1ea24cc1 Add ConsoleInLib to abstract console input (#13)
Current implementation assumes serial port is the only input console
device supported.  But other input console devices can be added later
on. This patch added a ConsoleInLib to abstract the input console
interfaces.  It also added PCDs to control enabled input console
devices.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2018-10-05 14:36:29 -07:00
Maurice Ma c6999f497a Initial check-in for Slim Bootloader source 2018-09-13 16:11:07 -07:00