Commit Graph

110 Commits

Author SHA1 Message Date
James Gutbub 4d7a8b58cf Remove global variable in boot cmd
The 'boot' command is making use of a global
variable declared in the OS Loader but it might
not always be available if the Shell lib is
used with other code. This patch removes the
dependency on the global variable.

Also fixes a small issue with not providing a
value at the prompt; instead prompt the user
with a error message when no valid value has
been provided.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-10-24 09:19:21 -07:00
Aiden Park 28c0039763
[OsLoader] OsLoader lifecycle change (#396)
This patch allows OsLoader to handle all Boot Options without restarting.

Currently, OsLoader restarts to handle next Boot Option from the beginning.
This behavior does not preserve allocated memories from Payload heap,
so it makes hardware/software states hard to be maintained.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2019-10-23 09:37:57 -07:00
Maurice Ma d74c294506 Add USB arrow key support
Since SBL shell added support for command line history. It is required
to support it from USB keyboard console as well. This patch added USB
keyboard arrow key handling to convert arrow key scan code into ANSI
escape sequence so that Shell can recognize the arrow key from keyboard.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-10-23 05:44:48 +08:00
Maurice Ma 03b466e8db Add Shell command line history support (#401)
This patch added command line history upport in SBL Shell. It makes
it easy to run a previous command using Up/Down arrow key.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-10-17 11:12:55 -07:00
Aiden Park 70b5afb6b3 [OsLoader] Clean-up PreOsChecker
Split PreOsChecker in a separate file and add minimum APIs
- IsPreOsCheckerLoaded ()
- LoadPreOsChecker ()
- StartPreOsChecker ()

Token space has been changed for PcdPreOsCheckerEnabled
- gPlatformModuleTokenSpaceGuid to gPlatformCommonLibTokenSpaceGuid
- Include/Excluded PreOsChecker according to FeaturePcd

Signed-off-by: Aiden Park <aiden.park@intel.com>
2019-10-16 16:45:53 -07:00
James Gutbub 3f3d48ba24 Remove boot option reset from boot cmd
The 'boot' command is resetting the current
boot option to be option zero any time the
command is invoked which conflicts with the
'c' command which allows a user to select the
next boot option that should be tried. Remove
the resetting to resolve the issue when doing
'c' sub-command in the 'boot' command.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-10-16 15:08:25 -07:00
James Gutbub 74d9af1e68 Add change current boot option to boot cmd
The 'boot' command has been updated to add
an option to update the current boot option
to be booted next, e.g. mCurrentBoot. To
change the current boot option just need to
run 'boot' and then select 'c' and the
index to change the current boot option to.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-10-15 19:42:16 -07:00
Maurice Ma 76e03f7d32 Add Shell CLS command to clear screen
This patch added "CLS" command support to SBL Shell. It can be used
to clear the console screen.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-10-15 15:50:06 -07:00
Maurice Ma f6f42702bc Implement clear screen for GFX console
Current GFX console provides no function to clear the screen. This
patch added this support using the standard ANSI escape sequence
in print string.
2019-10-15 15:50:06 -07:00
James Gutbub 7ebc3279c5 Provide default values to boot command
The OS Loader 'boot' shell command does
not allow a user to skip data entry for
a given input field which can be tedious.
To make it easier allow users to press
enter to re-use the current value for
the boot option being modified to skip
to the options that they actually want
to update.

Also remove the '-a' option, no one will
typically re-enter all of the boot options.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-10-15 15:35:06 -07:00
Maurice Ma 14ddaab0a7 Allow platform to degrade eMMC from HS400 to HS200
This patch allows platform to degrade eMMC HS400 to HS200 using
static configuration. To do this, please add the following into
BoardConfig.py:
  self.ENABLE_EMMC_HS400 = 0
This is useful when platform has hardware issue to run at eMMC
HS400 mode.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-10-15 08:23:31 -07:00
Raghava Gudla 7b222b6c5f Added CSME update driver
This patch added csme wrapper driver for csme update library.
following functionality is added in this patch

1. Boardconfig PCD option ENABLE_CSME_UPDATE is added to
   enable/disable csme update support
2. Boardconfig PCD option BUILD_CSME_UPDATE_DRIVER is added
   to enable/disable building csme update driver
3. If BUILD_CSME_UPDATE_DRIVER is 1, user need to create
   library that inludes csme update library
   this newly created library will get linked to csme update
   wrapper driver providing csme update driver
4. By default ENABLE_CSME_UPDATE is set to 0
5. Revision control for input and output data structure to
   update driver is not implemented and will be avaiable
   in further patches.

Signed-off-by: Raghava Gudla <raghava.gudla@intel.com>
2019-10-14 13:16:38 -07:00
Maurice Ma b0d5ef094c Add device deinit support
This patch added basic deinit support in the media DevInit() interface.
It uses a special DevDeinit phase to inform the media driver to do
device de-initialization. This de-initialization flow will be called
before OsLoader restarting and OS booting.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-10-14 10:10:11 -07:00
Maurice Ma 161271723b Adjust USB KB polling rate
When USB keybaord input console is enabled, current code will keep
sending interrupt transfers to poll the USB keyboard state. However,
according to USB spec, it needs to be polled at certain interval
returned by the device. If the polling rate is too high, sometime,
host will fail to schedule the SPLIT transfer. This patch adjusted
the polling rate to the required interval.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-10-14 10:06:07 -07:00
Maurice Ma d23d7e07f8 Fix AHCI memory de-allocation issue
This patch fixed the pointer check before de-allocating memory
previously allocated for AHCI controller.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-10-12 19:57:40 -07:00
James Gutbub 2a28a0d3df Clean up EXT library
The EXT library has some unused code that
we can remove to help reduce the size and
to clean things up some more. Also add a
routine for dumping the group descriptor
table which can be helpful for debugging
issues.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-10-09 11:56:09 -07:00
James Gutbub 5ca06f0d92 Support 64bit EXT FS & non-512 block sizes
EXT2/3 library has some limiatation to support
hardware block sizes larger than 512 (e.g. 4KB)
and also does not currently support the flag
INCOMPAT_64BIT which indicates larger group
descriptor sizes. This patch adds flexibility
to support 512 and 4KB block sizes as well as
64bit EXT file systems.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-10-08 17:23:59 -07:00
Aiden Park dce1bc359b
Remove Unnecessary SpiFlashLib from BootloaderCommonPkg (#357)
SpiFlashLib has been moved to Silicon/CommonSocPkg.
Remove unnecessary old SpiFlashLib

Signed-off-by: Aiden Park <aiden.park@intel.com>
2019-10-08 09:29:13 -07:00
Maurice Ma 3cdd48750d Use SerialPortLib in BootloaderCommonPkg
This patch switched to use SerialPortLib in BootloaderCommonPkg for
QEMU and CFL platforms.  For APL platform, it can also use this common
library. However, it has an optimized SerialPortLib with FIFO enabled.
So for APL, it still uses its SOC specific library.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-10-07 20:39:28 -07:00
Maurice Ma 01e302129d Re-implement common SerialPortLib
The common SerialPortLib in BootloaderCommonPkg is not used by anybody.
This patch re-implemented this library to align with the SOC specific
implementation. The intention is to use this common library to replace
SOC specific implementation.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-10-07 20:39:28 -07:00
Maurice Ma 328c862595 Add common interface for GetTimeStampFrequency
This patch added common API interface for GetTimeStampFrequency.
Since all current IA platforms have standard way to get the TSC
frequency, it is better to move it into common lib.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-10-07 16:08:33 -07:00
Maurice Ma 347cd9e952 Fix debug message output issue
The latest code has debug message output issue. It is caused by
the following CommitId: 56867c3bc6.
This patch provided proper fixes for this issue. The root cause
is due to incorrect string length.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-10-06 09:52:48 -07:00
Maurice Ma 3422b34208 Implement USB deinitialization flow
USB sub-system will have host controller scheduling frames on its
own once it is initialized and enabled. Leaving it running while
payload restarting or OS booting could potentially cause memory
corruption since the DMA might still be running on the background
targeting to previously allocated memory. The safer approach is
to stop the USB controller.

It also fixed #351.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-10-05 19:55:25 -07:00
Maurice Ma 7b2ca97b97 Rename UsbIoLib to UsbInitLib
This patch renamed UsbIoLib to UsbInitLib to better match its
actual functionality.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-10-05 19:55:25 -07:00
Maurice Ma 56867c3bc6 Fix double debug message output on serial port
SBL allows debug message to be redirected to output console besides
the serial port. However, serial port itself could be part of the
output console device as well. In this case the debug message will
be printed twice. This patch added check to this condition and skip
the redundant print.

It fixed #349.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-10-05 17:18:38 -07:00
Maurice Ma 5ec7be2c5d Enhance USB keyboard input experience
Current SBL USB keyboard driver cannot handle the key input nicely.
If typing is too fast, some chars will be missing. On the other side,
sometimes singe key press will generate multiple repeated chars.
This patch reimplemented the logic to detect key press/release using
similar flow as EDK2 UsbDxe driver. With this logic, USB keyboard
worked pretty well. It has been tested on APL platform.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-10-05 17:18:06 -07:00
Maurice Ma 88aa68ac1d Skip IAS image verification if VERIFIED_BOOT is disabled
Current SBL code will assert if HAVE_VERIFIED_BOOT is 0. This patch
added check for PcdVerifiedBootEnabled to decide if IAS verification
is required.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-10-05 17:17:43 -07:00
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
Aiden Park 12b4201543 Fix a compile error with gcc-4.8
gcc-4.8 reports an error - 'Count' may be used uninitialized

Signed-off-by: Aiden Park <aiden.park@intel.com>
2019-09-29 22:26:22 -07:00
Aiden Park b17c6c29b1 Fix compile errors when disabling compile optimization
- 'OpenFile may be used uninitialized' in ExtLib
- 'undefined reference to memcpy' in FatLib
- 'Lasa/Laml may be used uninitialized' in TpmLib
- 'Adjust may be used uninitialized' in Stage2Support

Signed-off-by: Aiden Park <aiden.park@intel.com>
2019-09-29 22:26:22 -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
Maurice Ma d2bd63df12 Allocate page aligned memory for component loading in container (#326)
To assist source level debug, it is better to always load PE/TE images
at page aligned memory address so that the script can locate the image
much easier. This patch changed the AllocatePool to AllocatePages for
component loading inside a container.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-09-23 09:19:27 -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
Maurice Ma 866493b926 Fix klocwork scanning issues in BootloaderCommonPkg
Fixed several issues reported by klockwork scanning.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-08-28 09:33:45 -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
James Gutbub b0e390f1d3 Fix ContainerLib flash bug
There is a small bug in the ContainerLib
where the check for whether the data is
stored in the flash needs to be adjusted.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2019-08-15 14:03:46 -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 de675ac5af Fix Linux framebuffer boot parameters
Current SBL code depends on PixelInformation to fill kernel
framebuffer parameters. However, this info is only valid if
PixelFormat is PixelBitMask type. Since FSP will only produce
8bit per pixel format, it is better to use PixelFormat to
determine the pixel bit size and position information. This
patch added this logic. It also fixed #260 .

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-08-12 08:33:42 -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
Maurice Ma bc8a817e59 Reinitialize Shell command list
Since OsLoader will restart from beginning and all memory will be
reclaimed, it is required for Shell library to re-initialize the
global varaibles, for example, command list. Otherwise, the old
memory pointer will be used and cause issues. This patch added the
link list re-initialization in Shell lib.  It fixed #253.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2019-08-07 13:37:05 -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
Aiden Park 13bd3d2d26 [Ext23Lib] Fix EXT filesystem booting failure
Currently, Ext23Lib accesses device index 0 only.
It must access proper hardware partition when reading blocks.
- Reproducible with QEMU which has SATA port 5

Signed-off-by: Aiden Park <aiden.park@intel.com>
2019-08-02 08:45:07 -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