Commit Graph

131 Commits

Author SHA1 Message Date
Maurice Ma ae8a416449 Add SMBIOS type 19 - memory array mapped address
This patch reworked the previous reverted commit. The UEFI payload
debug version assertion was resolved. Checked in Windows, the SMBIOS
info looks good.

Current UEFI payload showed 0 KB RAM size in setup screen because
of missing SMBIOS memory type information. This patch added SMBIOS
type 19 to provide memory array mapped address information. With
this change, UEFI setup screen can show correct memory size.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-25 16:45:00 -07:00
Maurice Ma c62e24eb8c Add PCD to let platform control the ACPI processor ID base
This patch added PcdAcpiProcessorIdBase to allow platform to
customize the processor ID start base within MADT APIC entry.
Current EHL and TGL declared PR00 processor object in ACPI
with unique ID value 0, but other projects used vlaue 1
instead. This patch will help fix this issue.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-25 16:43:20 -07:00
Aiden Park 18d16d44ff Profile Max Used Heap size at runtime
This records the maximum usage of heap at runtime. The Stage1/2 heap
sometimes reaches OUT OF RESOURCE even if it looks there is enough
usable space in the heap. This is because AllocateTemporaryMemory()
sometime exceeds the heap boundary. ex) IppCryptoLib
This would help identify proper heap size required in each stages.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2021-10-25 09:48:22 -07:00
Maurice Ma 449309ff75 Revert "Add SMBIOS type 19 - memory array mapped address"
This reverts commit b87d67c1fc.
In the testing, it caused debug UEFI payload assertion issue.
Roll it back for now.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-21 19:27:19 -07:00
Maurice Ma b87d67c1fc Add SMBIOS type 19 - memory array mapped address
Current UEFI payload showed 0 KB RAM size in setup screen because
of missing SMBIOS memory type information. This patch added SMBIOS
type 19 to provide memory array mapped address information. With
this change, UEFI setup screen can show correct memory size.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-21 18:09:04 -07:00
Maurice Ma c03faf59c3 Enhance PCI enumeration policy for resource downgrade
On TGL platform, when enable SR_IOV for PCI enumeration, system
hung due to insufficient PCI resource. GFX VF needs lots of MMIO
resource and it cannot be satisfied by SBL in 32 bit mode.

To address this issue, this patch extends the bus 0 downgrade
policy to further allow downgrading PCI bus 0 devices except for
GFX. Now the DowngradeBus0 policy has following values:
  0: Do not downgrade PCI devices on bus 0
  1: Downgrade all PCI devices on bus 0
  2: Downgrade all PCI devices on bus 0 but GFX
  3: Reserved
By default, it has the same behavior as before. If platform needs
to download bus 0 devices but GFX, the new value 2 can be used.

This has been tested on TGL, and it worked as expected.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-18 09:14:52 -07:00
Maurice Ma 02c407aac5 Enable UEFI Universal Payload boot
This patch enabled ELF UEFI Universal Payload boot for SBL. It was
tested with EDK2 commit 22873f58c40c496d59a0553bee1c720192ac35c9.

To build UEFI Universal Payload, please run script from EDK2 repo:
  edksetup.bat
  python UefiPayloadPkg\UniversalPayloadBuild.py -b DEBUG -t VS2019
The generated payload binary will be located at:
  Build\UefiPayloadPkgX64\UniversalPayload.elf

This patch was tested on QEMU, and it worked as expected.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-10-04 11:59:55 -07:00
Maurice Ma 22447f0618 Adjust PCI resource check condition
Current PciBus lib expects the root bridge resource base should not be
greater than limit. It is true for normal case. However, to mark the
source is unavailable, the base could be less than the limit in some
case. PCI bus lib should only validate the resource that does have a
request.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-09-27 08:58:05 -07:00
Stanley Chang b78cb1d534 [TGL] Read boot Tjunctions
The patch adds a feature to read Dts at boot. The feature
is analogous to UEFI BIOS:

  Thermal Conf -> Platform Thermal Conf -> Boot DTS Read

Specifically, the feature reads Tjunctions of PCH and CPU
and stores them as Smbios Type-28 entries.

The patch also fixes AppendSmbiosType in SmbiosInitLib:
  A newly added structure should inherit the Handle from
  previous Type-127 (end-of-table) structure.

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2021-08-24 08:56:51 -07:00
Stanley Chang 02a10d7452 fix TSeg full during warn reset
This patch fixes TSeg region full problem after multiple
warn reset. Each time of warm reset, except S3 resume, the
TSeg region should be clear.

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2021-08-19 07:59:32 -07:00
Aiden Park 81f7712846 [CorePkg] Add additional APIs to access LoaderGlobalData
This adds additional APIs to make Platform code use APIs to access
LoaderGlobalData instead of accessing variables directly.
- GetS3DataPtr()
- SetFeatureCfg()
- ClearFspHob()
- GetVerInfoPtr()

Signed-off-by: Aiden Park <aiden.park@intel.com>
2021-08-06 12:34:36 -07:00
Aiden Park 49a3a54e6c
[CorePkg] Add GetTempRamInfo() API (#1245)
Some platforms need TempRam Base & Size information to calculate
FspmArchUpd StackBase & Size at runtime.
The TempRam Base & Size info will be only valid until TempRamExit.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2021-08-04 09:56:31 -07:00
stanley 748aeb0eaf
[TGL] Fix RTC S3 wake hang (#1232)
This patch clears RTC Alarm when RTC is the S3 wake-up source.
Without clearing it, SMI# will be triggered once SMI_EN is set
by RestoreS3RegInfo, but no handler to clear it which results
in hang.

This patch also refactors RegRead/RegWrite in RestoreS3RegInfo
to avoid the misalingment of function pointers and coding
convention.

Signed-off-by: Stanley Chang <stanley.chang@intel.com>
2021-07-28 09:56:56 -07:00
Guo Dong 791d7a0beb
Fix SMM rebase S3 issue (#1224)
Currently it will return a valid SMMBASE_INFO if SMMBASE_INFO_COMM_ID
is found in SMM S3 resume memory. It will cause issue in S3 path if there
is no one fill correct data when MpInit uses it to rebase SMM.
This patch adds a check to SMMBASE_INFO to avoid this issue.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2021-07-14 19:33:04 -07:00
stalamudupula f1b98384a2
Add a Pci Enum Hook function (#1185)
This patch adds a platform hook function ability
in Pci Enum Lib to enable platform to perform
PCI Enum specific work-around routines.

Signed-off-by: Talamudupula <stalamudupula@gmail.com>
2021-06-09 15:53:26 -07:00
Vincent Chen 8bb52daaca [QEMU] Fix compiler error for NOOPT build in Windows
- fix __aullshr link error due to compiler intrinsics functions
  for NOOPT build in Windows
- adjust Stage1A/TopSwap/OsLoader FD size for NOOPT target
- adjust Stage2 size for NOOPT target when DEBUG FSP is used

Signed-off-by: Vincent Chen <vincent.chen@intel.com>
2021-05-25 21:20:38 -07:00
James Gutbub 810a0b1c54 Resolve issue with MpInitLib VS2015 compiling
Need to add some typecasting to resolve a build
issue with MpInitLib when using VS2015 compiler.

Signed-off-by: James Gutbub <james.gutbub@intel.com>
2021-04-19 16:49:38 -07:00
Maurice Ma cf5293c55c Restruct MpInit NASM code
This patch restructed MP init library so that more code can be
common between 32bit and 64bit. It is much easier to maintain the
code after the restructure.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-04-19 08:53:55 -07:00
Maurice Ma fb1e05a51c Enable QEMU SMM rebasing
This patch enables QEMU SMM TSEG programming in FSP. And it also
enables SBL QEMU SMM rebasing. It can be used to test many SMM
related flow.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-04-19 08:53:55 -07:00
Talamudupula 85826d40f2 Fix buffer overflow for copy in S3SaveRestore lib
For appending Save/Restore structs in TSEG area,
bootloader should reserve space for TotalSize and
for certain structs, only header info should be
actually populated. Rest should be all Zeros.

Signed-off-by: Talamudupula <stalamudupula@gmail.com>
2021-04-14 11:16:13 -07:00
Maurice Ma 8659c29ac0 Enhance SMM rebase check condition
Current SBL SMM rebasing check is only performed when PcdSmmRebaseMode
is enabled. It does not cover the case to boot UEFI payload. This patch
enhaced the check to cover UEFI payload S3 path as well.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-04-13 16:00:32 -07:00
Maurice Ma a73d37fa91 Delay SMRR enabling
When SMRR is enabled too early, it blocked TSEG access in Stage2.
And it caused S3 related issues. This patch delays the SMRR enabling
to be after PrePayloadLoading BoardInit().

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-04-12 16:52:46 -07:00
Maurice Ma 94d22382bd [APL/CFL] Enable SMM rebase for mon UEFI payload
For non UEFI payload, SBL will install dummy SMI handler for
security concern. For UEFI payload, SMM rebasing is expected
to be done itself. This patch enabled this feature for APL and
CFL platform.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-04-10 15:28:07 -07:00
Maurice Ma af807ee2d0 Enable SMRR programming in SMM rebasing flow
In normal UEFI payload case, the UEFI will handle SMM rebasing.
If SMM rebasing is handled by SBL, SBL will put a dummy SMI handler
at the new SMBASE to prevent SMM hang.  Beyond SMM rebasing, it
is also required to program SMRR registers. This patch added this
support for core code. It also added TSEG PCD init for CFL.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-04-10 15:28:07 -07:00
Aiden Park 209a159176 [PCI] Disable PCI devices bus master by default
This will disable all PCI bus master by default, and enable it only if
- the original bus master was enabled before PCI enumeration
- Or the device is PCI Bridge

Signed-off-by: Aiden Park <aiden.park@intel.com>
2021-04-06 13:30:59 -07:00
Maurice Ma 41ccfcca7c Clean up release build debug output
Current SBL release debug output has more than what is expected.
This patch reset some of the debug message to proper level to limit
debug message for release build.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-04-04 07:59:03 -07:00
Maurice Ma 3b849acccf Allow platform to create ACPI table dynamically
This patch implemented a common method for platform to create ACPI
table dynamically. Platform can provide ACPI tempalte array through
PCD PcdAcpiTableTemplatePtr. If provided, ACPI core code will try to
call platform code to patch the table, and then install the table to
ACPI RSDT/XSDT.
It also added sample code implementation in QEMU to show case how to
do it from platform code.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-03-28 21:24:27 -07:00
Guo Dong 39004cc938 Update MP lib to fix CPU task
Need initialize global variable mSysCpuTask.CpuCount to actual
CPU count.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2021-03-26 17:07:17 -07:00
Maurice Ma fc9f1cee6f Fix stack alignment issue in x64 build
GCC x64 build requires stack to be aligned at 16 bytes. In MpInit
nasm file, SBL set the initial stack to be 16-byte aligned. However,
later on unbalanced push/pop breaks the 16-byte alignment. This
patch removed extra stack pop so that the stack will always stay at
the original initial value.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-03-24 06:15:43 -07:00
Talamudupula a005a5772c Program BAR0/1 for PPB
Current PCI Enum Lib scopes for only Apperture resources
for a PPB. But some OSes (like ESXi) expect BAR0 & BAR1
(Offset 0x10/0x14) to be allocated resources accordingly.
Otherwise, PPB enumeration doesnt happen correctly and
devices behind PPB are not registered at all.

This patch adds the functionality to assign valid resources
to BAR0(0x10) and BAR1(0x14) for a PPB also.

Signed-off-by: Talamudupula <stalamudupula@gmail.com>
2021-03-02 20:28:07 -08:00
Maurice Ma bcfba7a847 Move X2APIC enabling to common function
This patch removed duplicated X2APIC enabling code. Instead, it
enables X2APIC in a common function. By doing so, the very first
waking up will be done in APIC mode. Afterwards, it will be using
X2APIC mode if enabled by PCD.
This patch also fixed an X2APIC ACPI MADT issue.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-02-20 06:52:08 -08:00
Maurice Ma 04b162e75e Add CPU X2APIC support
This patch added X2APIC support. It is to enable the case when
APIC ID is greater than 255. This patch only handle core wakeup
portion. Platform still needs to handle ACPI related changes for
X2APIC.

X2APIC lib is backward compatible with XAPIC lib. So there is no
need to use XAPIC lib anymore.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-02-12 17:20:57 -08:00
Guo Dong 234bf55561
Fix the MP hang issue (#1013)
The ApDataPtr->CProcedure was wrongly updated in previous patch.
This patch fixed it and CPU task name from CProcedure to TaskFunc
to avoid confusion.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2021-02-10 09:29:54 -08:00
Aiden Park 2aade4dddb
Fix new Klocwork scanning issues (#1012)
This patch addresses new reported klocwork scanning issues.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2021-02-10 08:55:00 -08:00
Guo Dong 45be2a8daa Build MP CPU TASK info hob
With this hob, user could run a task from AP in Osloader.

Signed-off-by: Guo Dong <guo.dong@intel.com>
2021-02-08 09:31:08 -07:00
Maurice Ma fd436737a6
Delay MP init done for OsLoader payload (#1003)
There is request to utilize MP in OsLoader. To support it, it is
desired to delay MP init done signal to the end of the OsLoader.
This patch moved the MP init done signal into board ReadyToBoot
notification so that MP is still alive in OsLoader phase.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-02-05 16:15:23 -08:00
Aiden Park 680cab980b [PCI] Add an option to allocate PCI PMEM resource first
This introduces an additional PCI Enumeration option.
- self._PCI_ENUM_FLAG_ALLOC_PMEM_FIRST

By deafult, the option will allocate PCI resource by ascending order
(MEM32->PMEM32->MEM64->PMEM64). If it's set to 1, by reversed order.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2021-02-03 17:14:51 -08:00
Maurice Ma f68a5dce1b Add FSP HOB print function
This patch will display FSP HOBs. It will help the debug when FSP
produce incomplete HOBs.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-02-02 19:48:39 -08:00
Maurice Ma 1771e3a35e
Change PCI resource PCD to patchable type (#979)
Current PCI resource PCD bases are defined as fixed type. It
makes it impossible to dynamically adjust the base at runtime.
This patch changed it to be module patchable so that platform
can update when required.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-01-25 09:54:32 -08:00
Maurice Ma a85f327ad8 Enhance BGRT BMP support for logo display
BGRT can be used by bootloader to pass logo to OS. But BGRT can
only support 24bit or 32bit BMP format. If the bootloader uses
other bit format or indexed color format, the image has to be
converted before passing it to BGRT. This patch added support
to convert other BMP image format into 32bit format required by
BGRT.

This has been tested with Windows on Leafhill board. The SBL
logo was dispalyed properly while booting Windows.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2021-01-14 09:52:36 -08:00
Talamudupula c62c995e49 Update correct BarType field for VF Bar program
ProgramBar() routine uses 'OrgBarType' field to
determine BarType. So, if a BarType is valid, copy
it to OrgBarType for VF also.

Signed-off-by: Talamudupula <stalamudupula@gmail.com>
2021-01-07 20:22:54 -08:00
Aiden Park eabaac12ad Add PCI Resource Allocation Table
This introduces a new PCD 'PcdPciResAllocTableBase' to allow a platform
to provide its specific PCI resource allocation pool at runtime.
PCI Enumerator will allocate required resources in the range.
If the PCD is not provided, a default range will be used.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-12-15 14:05:25 -08:00
Maurice Ma 6117ebaa7c Enable ACPI BGRT table support
This patch enabled ACPI BGRT support. It is used to pass splash
display information from bootloader to payload and OS.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-12-02 12:40:18 -08:00
Singh Nitin G 7011ce1bf0 Fix HeciGetFwCapsSkuMsg api to update MBP
Made changes to ensure the ME BIOS data information
is correctly reported.

Signed-off-by: Divneil Rai Wadhawan <divneil.r.wadhawan@intel.com>
2020-11-24 15:40:54 -08:00
Maurice Ma bd07c6504c
Add legacy EF segment memory config (#904)
Current SBL code will build pointers in E/F segment for ACPI
and SMBIOS table. On some platforms, E/F segment is not supported.
So a new configuration ENABLE_LEGACY_EF_SEG is added.  When
it is enabled, SBL will not use legacy E/F segment memory.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-11-22 21:06:38 -08:00
Aiden Park 2d7c2b920f Add PCI resource downgrade option for all Bus-0 devices
In 64-bit operation, some PCI devices have high mmio BARs,
but 32-bit FSP can only access 32-bit memory space.
This introduces and additional PCI resource downgrade option
to downgrade all PCI devices under Bus-0.
- self._PCI_ENUM_DOWNGRADE_BUS0 = 1
  Force to have 32-bit BAR for all Bus-0 devices

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-11-02 10:57:15 -08:00
Maurice Ma 9a4407018d [QEMU] Fix NOOPT build failure
This patch fixed NOOPT build failure for QEMU.
It fixed #871.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-10-12 13:00:44 -07:00
Maurice Ma dd8fe22046 Add MultiBoot support for X64 build
During X64 enabling, there was a pending task to enable 32bit
MultiBoot support. It is not implemented.  This patch added the
support to allow X64 SBL to boot a 32bit MB image through thunking.
As part of this patch, the ThunkLib is separated from the FspApiLib
so that it can be shared by other component.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-10-07 14:20:50 -07:00
Aiden Park 21e9d1a51e Check PPB decode space and assign BAR accordingly
All child devices under a PPB must be in scope of its PPB's decode space.
Therefore, all PPB checks the decode capability and downgrades its child
devices' resources accordingly.

Signed-off-by: Aiden Park <aiden.park@intel.com>
2020-08-12 17:18:04 -07:00
Maurice Ma 1ed701be11 Fix P2P bridge alignement issue
The following commit 9fcb3a6be1
caused a regression on PCI bridge resource allocation. At minimum
the PCI bridge needs to have IO apperture aligned at 4KB and MMIO
apperture aligned at 1MB. The new code did not adjust the
alignment for P2P bridge following this rule.  This patch fixed
this issue.

Signed-off-by: Maurice Ma <maurice.ma@intel.com>
2020-08-10 17:19:51 -07:00