Compare commits

...

63 Commits

Author SHA1 Message Date
2dc1e51593 UefiPayloadPkg: Add Secure Boot support
Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Change-Id: I4f44e29bc967b7d2208193e21aeeef8b96afcc69
2022-06-03 09:03:42 -06:00
35dde2452d MdeModulePkg/FaultTolerantWriteDxe: Don't check for address alignment
WorkSpaceAddress and SpareAreaAddress point into MMIO, which isn't
always aligned. Remove the check for block alignment to avoid
false assertions.

Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Change-Id: Ia1c1f44b6a0e7f32cac0d7806e74d729e5d83a6d
2022-06-03 09:03:42 -06:00
0f49a3fc87 Ps2KbdCtrller: Make wait for SUCCESS after BAT non-fatal
Recent model Chromebooks only return ACK, but not
BAT_SUCCESS, which causes hanging and failed ps2k init.
To mitigate this, make the absence of BAT_SUCCESS reply
non-fatal, and reduce the no-reply timeout from 4s to 1s.

Tested on google/dracia and purism/librem_14

Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Change-Id: Ib644f6797eb50eb3bb75235ac48ddb6096a7bd6d
2022-06-03 09:03:42 -06:00
792844cb3b UefiPayloadPkg: Hook up RNG support
Hoop Up RNG from SecurityPkg.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Change-Id: I9fadc2f36b0601b8a2f5b8a9abc3f208e7987e6c
2022-06-03 09:03:42 -06:00
136138411f SecurityPkg: Add RNG support
Uses the RDRAND instruction if available and install EfiRngProtocol.
The protocol may be used by iPXE or the Linux kernel to gather entropy.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Guo Dong <guo.dong@intel.com>
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Change-Id: I0f74b64c6a7e8fc6fdd8ea8f2a416d8b7c0334f4
2022-06-03 09:03:42 -06:00
1f31c0e81e UefiPayloadPkg: Add support for Firmware Volume Block Protocol
This adds support for FVB in order to support a platform independent
and non-volatile variable store on UefiPayloadPkg. The variable store
makes use the SmmStoreLib to provide an unauthenticed variable store.

Since commit bc744f5893fc4d53275ed26dd8d968011c6a09c1 coreboot supports
the SMMSTORE v2 feature. It implements a SMI handler that is able to
write, read and erase pages in the boot media (SPI flash).
The communication is done using a fixed communication buffer that is
allocated in CBMEM. The existence of this optional feature is advertised
by a coreboot table.
When the SMMSTORE feature is not available the variable emulation is used
by setting PcdEmuVariableNvModeEnable to TRUE.

The DXE component provides runtime services and takes care of virtual to
physical mapping the communication buffers between SMM and OS.

The contents of the variable store can be accessed and modified by any
priviledged application. As authentication is done by runtime services
only the store shouldn't be used to store authenticated variables.

Tested on Linux and Windows 10 on real hardware.
Currently this cannot be tested on coreboot and qemu as it doesn't support
the SMMSTORE on qemu.

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Signed-off-by: Sean Rhodes <sean@starlabs.systems>
Change-Id: I79a234275e25961869edf959cfbf4f8d17df2383
2022-06-03 09:03:42 -06:00
dcdfb2f083 UefiPayloadPkg: Add SmmStoreLib
Implement all of the FVB protocol functions on top of the SmmStore
as a library. The library consumes the introduced gEfiSmmStoreInfoHobGuid.

The SMI handler uses a fixed communication buffer in reserved DRAM.
To initiate a transaction you must write to the I/O APM_CNT port.

Tests on Intel(R) Xeon(R) E-2288G CPU @ 3.70G showed that the SMI isn't
triggered with a probability of 1:40 of all cases when called in a tight
loop. The CPU continues running and the SMI is triggeres asynchronously
a few clock cycles later. coreboot only handels synchronous APM request
and does nothing on asynchronous APM triggers.

As there's no livesign from SMM it's impossible to tell if the handler
has run. Just wait a bit and try again to trigger a synchronous SMI.

Tests confirmed that out of 5 million tries the SMI is now always handled.

When a synchronous SMI happens with the correct write to the APM_CNT port,
the ebx register is checked first that it doesn't point to SMRAM.
If it doesn't it's used to read in the arguments that define a SmmStore
transaction.

The SMI handler will only operate on a predefined and memory mapped region in
the boot media.

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Change-Id: Id4182623e4198c6512d3fe6ec20adf6738586d9b
2022-06-03 09:03:42 -06:00
13dd54ae32 UefiPayloadPkg: Add SmmStoreInfoGuid
Add a new InfoHob that contains the SmmStore information passed from
coreboot tables when the SMMSTOREV2 feature is enabled.

This will be used to implement the FVB in top of the MM installed by
coreboot.

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Change-Id: Ia3f7eef27d4758768c1a6736afe1cb77ee6a2f8f
2022-06-03 09:03:42 -06:00
bb19b4bc30 UefiPayloadPkg/Include/Coreboot: Add headers for SMMSTOREv2 table
Since commit bc744f5893fc4d53275ed26dd8d968011c6a09c1 coreboot supports
the SMMSTORE v2 feature. It implements a SMI handler that is able to
write, read and erase pages in the boot media (SPI flash).
The existence of this optional feature is advertised by a coreboot table.

Add the tag and headers to parse the table.

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Change-Id: I02be3fa8d5d6ff47d56b81876590afef8f6c43c0
2022-06-03 09:03:42 -06:00
7693804ed1 UefiPayloadPkg: Increase FV size to 8MB
The following commits need additional space.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Change-Id: I6b757f73fe4e90282b4bfb84469545ab1af9d1bb
Reviewed-on: https://review.coreboot.org/c/edk2/+/58630
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Matt DeVillier <matt.devillier@gmail.com>
2022-06-03 09:03:42 -06:00
626f1a3273 UefiPayloadPkg: Add System76 Setup menu 2022-06-03 09:03:42 -06:00
0420529401 UefiPayloadPkg: Add Intel GOP driver 2022-06-03 09:03:42 -06:00
13e6178201 UefiPayloadPkg: Add Pop!_OS Recovery to boot text
Preserve existing UI and add the note about pressing Space to go to
the systemd-boot menu for Pop!_OS Recovery.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2022-06-03 09:03:42 -06:00
cbff8f0510 MdeModulePkg/BmBootDesciption: Remove device prefixes
Remove the device prefixes to match current System76 firmware UI in the
One Time Boot menu.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2022-06-03 09:03:42 -06:00
601bcb9ce2 MdeModulePkg/BM: Update boot options on device change
Register an event to trigger when a block device is added or removed
that will update the list of boot options. Use a refreshguid to force
the form to display the changes if it already open.
2022-06-03 09:03:42 -06:00
6468032370 MdeModulePkg/Core: Signal notify events on protocol removal
In order for BootManager to maintain a valid list of boot options, it
must know when the BlockIo protocol is also removed, not just added.
2022-06-03 09:03:42 -06:00
7b3153b1cb UiApp: Dynamically generated firmware configuration information page
Signed-off-by: Jeremy Soller <jeremy@system76.com>
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2022-06-03 09:03:42 -06:00
f2e99ad7b6 MdeModulePkg/BMM: Unregister F9 and F10 hotkeys 2022-06-03 09:03:42 -06:00
ae93abfcbf MdeModulePkg/BMM: Remove Commit/Discard buttons 2022-06-03 09:03:42 -06:00
de3e52e5d3 MdeModulePkg/BMM: Save BootOrder on list update 2022-06-03 09:03:42 -06:00
260b22ed3e MdeModulePkg/BMM: Add some debug logging 2022-06-03 09:03:42 -06:00
b79d3f9599 MdeModulePkg/UiApp: Add warning if no bootable options found 2022-06-03 09:03:42 -06:00
49dad2f15d MdeModulePkg/BootMaintenanceManagerUiLib: Make it look like current BMM 2022-06-03 09:03:42 -06:00
21bbc9ae0e MdeModulePkg/UiApp: Make it look like current FrontPage
Signed-off-by: Jeremy Soller <jeremy@system76.com>
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2022-06-03 09:03:42 -06:00
52d9ce76db MdeModulePkg/BM: Make it look like current BootMngr 2022-06-03 09:03:42 -06:00
0d209e3a81 UefiPayloadPkg: Disable EFI shell 2022-06-03 09:03:42 -06:00
c418d4eb9e UefiPayloadPkg: Add library for logging to EC
Make use of the SMFI command interface to forward logs from edk2 to
System76 EC.

Signed-off-by: Jeremy Soller <jeremy@system76.com>
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2022-06-03 09:03:42 -06:00
648620d59d UefiPayloadPkg: Scan for Option ROMs
Scanning for PCI Option ROMs on UEFI works with full PCI enumeration.
On platforms where the bootloader has done PCI enumeration a
platform specific driver needs to provide the Option ROMs.

As this is not specific to any platform, but rather to the UEFI as
payload concept, add the PCI platform driver to UefiPayloadPkg.

On coreboot the ROM BAR is part of the PCI bridge MMIO window and
can safely enabled if existing.

The Option ROMs are not passed in by bootloader in a HOB as:
- they might not fit into a HOB
- this is EDK2 specific and would just bloat the bootloader code
- would waste lot's of non reclaimable memory if placed in e820
  reserved DRAM space

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2022-06-03 09:03:42 -06:00
6284b7fe6f UefiPayloadPkg: Use new filesystem drivers
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2022-06-03 09:03:42 -06:00
e3ac04f774 Add filesystem drivers
Add EXT2/EXT4, exFAT, NTFS filesystem drivers.
Do not add ISO9115 drivers as it breaks El Torito boot.
2022-06-03 09:03:42 -06:00
5f7a6fe58b UefiPayloadPkg: Stall before connecting devices
USB devices are not being detected when booting. Pause a bit for them to
be initialized and detected by EfiBootManagerConnectAll().
2022-06-03 09:03:42 -06:00
4f9743107d MdeModulePkg/BdsDxe: Forward any key for booting
Pressing escape will bring a user to the boot manager. Pressing any
other key will continue booting, forwarding the key to systemd-boot.
2022-06-03 09:03:42 -06:00
f300ed8297 MdeModulePkg: Wait for input after boot failure
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2022-06-03 09:03:42 -06:00
1fd1cf3dfb UefiPayloadPkg: Clear screen on boot error 2022-06-03 09:03:42 -06:00
053e8aed4d UefiPayloadPkg: Copy PlatformBootManagerUnableToBoot() from OvmfPkg 2022-06-03 09:03:42 -06:00
b219d5c94f UefiPayloadPkg: Set ResetOnMemoryTypeInformationChange to FALSE
the default value, TRUE, causes reboots if a device boots to the
shell, exits, and then attempts to boot from another source.

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2022-06-03 09:03:42 -06:00
20a7334a96 MdeModulePkg/GraphicsConsole: don't draw cursor at 0,0
Prevents cursor from flashing on screen when
changing modes or clearing the screen.

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2022-06-03 09:03:42 -06:00
a8abddc10a MdeModulePkg/BmBootDesciption: Improve device descriptions
Add device type prefixes for USB, IDE, SATA, and NVMe drives.
Remove UEFI prefix, remove serial numbers.

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2022-06-03 09:03:42 -06:00
93688ae1e5 MdeModulePkg/BmBoot: skip secondary eMMC entries
Internal eMMC devices often show multiple entries, so skip
any after the initial entry.

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2022-06-03 09:03:42 -06:00
38a3b6f58d MdeModulePkg/Frontpage: get SMBIOS Data from table directly
rather than getting it from the EFI SMBIOS protocol

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2022-06-03 09:03:41 -06:00
85f616be1b UefiPayloadPkg: Disable Device Manager 2022-06-03 09:03:41 -06:00
1aed3a3e36 BmpSupportLib: fix BMP validation
BMP files by tools other than MS paint can have a
variable number of padding bytes, which results in
the DataSize being less than (ImageSize - HeaderSize).
Fix the check to be less stringent.

Test: use BMP created by/saved by Photoshop

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2022-06-03 09:03:41 -06:00
f8d5dcd99b MdeModulePkg: load boot logo into BGRT table
This is a shoehorned-in implementation of an ACPI BGRT
table, ported pretty much directly from the version used
under CorebootPayloadPkg.

EDK2 provides a facility to do this already, but it assumes
the ACPI tables already exist as EFI structures, so would need
to write code to populate those using the tables already in RAM
created by coreboot. This seemed like the easier option ATM.

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2022-06-03 09:03:41 -06:00
2046be8d5e MdeModulePkg/BootLogoLib: Center logo 38.2% from top of screen
Use Microsoft's recommended positioning [1] for the boot logo.

> We recommend that the logo is placed with its center at 38.2% from the
> screen's top edge. This positioning is based on the golden ratio's
> visual aesthetics and matches the Windows 10 design proportions.

[1]: https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/boot-screen-components#position-the-logo-during-post
2022-06-03 09:03:41 -06:00
57ed7e7151 MdeModulePkg/Logo: Use System76 boot logo 2022-06-03 09:03:41 -06:00
a8285c29d8 UefiPayloadPkg: Enable boot logo
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2022-06-03 09:03:41 -06:00
be10ebabba UefiPayloadPkg: Show boot message as progress text
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2022-06-03 09:03:41 -06:00
16779ede2d Removed prefix to match AsmRelocateApMailBoxLoopStart
This fixes a compilation issue.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Jehl Theo <theojehl76@gmail.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Rebecca Cran <quic_rcran@quicinc.com>
Tested-by: Rebecca Cran <quic_rcran@quicinc.com>
2022-05-26 09:59:43 +00:00
07c0c2eb0a OvmfPkg: fix PcdFSBClock
kvm FSB clock is 1GHz, not 100 MHz.  Timings are off by factor 10.
Fix all affected build configurations.  Not changed: Microvm and
Cloudhw (they have already have the correct value), and Xen (has
no fixed frequency, the PCD is configured at runtime by platform
initialization code).

Fixes: c37cbc030d ("OvmfPkg: Switch timer in build time for OvmfPkg")
Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
2022-05-25 13:34:26 +00:00
9c733f0b90 OvmfPkg: TdxDxe: Fix AsmRelocateApMailBoxLoop
In TDX, Application Processor busy-loops on Mailbox for OS to issue
MpProtectedModeWakeupCommandWakeup command to UEFI.  As the AP acking to
it, it clears the command member according to ACPI spec 6.4, 5.2.12.19
Multiprocessor Wakeup Structure: "The application processor need clear the
command to Noop(0) as the acknowledgement that the command is received."
However, AsmRelocateApMailBoxLoop wrongly clears WakeupVector.  Correctly
clear command instead of WakeupVector.

Without this patch, TD guest kernel fails to boot APs.

Fixes: fae5c1464d ("OvmfPkg: Add TdxDxe driver")

Cc: Min Xu <min.m.xu@intel.com>
Signed-off-by: Isaku Yamahata <isaku.yamahata@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Reviewed-by: Min Xu <min.m.xu@intel.com>
2022-05-25 12:34:46 +00:00
a21a3438f7 OvmfPkg: Make an Ia32/X64 hybrid build work with SEV
The BaseMemEncryptSevLib functionality was updated to rely on the use of
the OVMF/SEV workarea to check for SEV guests. However, this area is only
updated when running the X64 OVMF build, not the hybrid Ia32/X64 build.
Base SEV support is allowed under the Ia32/X64 build, but it now fails
to boot as a result of the change.

Update the ResetVector code to check for SEV features when built for
32-bit mode, not just 64-bit mode (requiring updates to both the Ia32
and Ia32X64 fdf files).

Fixes: f1d1c337e7
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Michael Roth <michael.roth@amd.com>
Cc: Min Xu <min.m.xu@intel.com>
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2022-05-20 06:29:34 +00:00
a72d552f19 OvmfPkg/OvmfPkgX64: Use different CcProbeLib when SMM is on or off
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3930

CcProbeLib is designed to check the vm guest type. The OvmfPkg/CcProbeLib
reads the OvmfWorkArea (0x80B000) to get the vm guest type which is
written by each guest (SEV or TDX guest). But in SMM drivers the access
to OvmfWorkArea is illegal. PiSmmCpuDxeSmm.inf is an example. It uses
IoLib which in OvmfPkgX64 BaseIoLibIntrinsicSev.inf is included. The
IoLib probes if the working guest is td guest by calling CcProbe().

So CcProbeLibNull will be included when SMM_REQUIRE is set. Currently
only TDVF uses CcProbe to check the guest type, and TDVF doesn't
support SMM, so this fix has no side-effect.

Cc: Andrew Fish <afish@apple.com>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Dann Frazier <dann.frazier@canonical.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Tested-by: dann frazier <dann.frazier@canonical.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
2022-05-20 01:18:26 +00:00
1f026ababf UefiPayloadPkg: Add VariableFlashInfoLib
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3479

Adds an instance of VariableFlashInfoLib to the platform build as
it is a new library class introduced in MdeModulePkg.

Cc: Guo Dong <guo.dong@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Benjamin You <benjamin.you@intel.com>
Cc: Sean Rhodes <sean@starlabs.systems>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Guo Dong <guo.dong@intel.com>
2022-05-19 06:11:20 +00:00
a7d3d4e7c4 OvmfPkg: Add VariableFlashInfoLib
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3479

Adds an instance of VariableFlashInfoLib to the platform build as
it is a new library class introduced in MdeModulePkg.

Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Julien Grall <julien@xen.org>
Cc: Min Xu <min.m.xu@intel.com>
Cc: Peter Grehan <grehan@freebsd.org>
Cc: Rebecca Cran <rebecca@bsdio.com>
Cc: Sebastien Boeuf <sebastien.boeuf@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Rebecca Cran <rebecca@bsdio.com>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
2022-05-19 06:11:20 +00:00
a69eac7578 EmulatorPkg: Add VariableFlashInfoLib
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3479

Adds an instance of VariableFlashInfoLib to the platform build as
it is a new library class introduced in MdeModulePkg.

Cc: Andrew Fish <afish@apple.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Abner Chang <abner.chang@hpe.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Abner Chang <abner.chang@hpe.com>
2022-05-19 06:11:20 +00:00
524a15c1fa ArmVirtPkg/ArmVirt.dsc.inc: Add VariableFlashInfoLib
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3479

Adds an instance of VariableFlashInfoLib to the platform build as
it is a new library class introduced in MdeModulePkg.

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Julien Grall <julien@xen.org>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2022-05-19 06:11:20 +00:00
8db39c60cd MdeModulePkg/FaultTolerantWrite: Consume Variable Flash Info
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3479

Adds support to the UEFI variable fault tolerant write (FTW) drivers
to receive FTW base and size information dynamically via the Variable
Flash Information library.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2022-05-19 06:11:20 +00:00
4dbebc2d10 MdeModulePkg/Variable: Consume Variable Flash Info
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3479

Updates VariableRuntimeDxe, VariableSmm, and VariableStandaloneMm
to acquire variable flash information from the Variable Flash
Information library.

Note: This introduces a dependency on VariableFlashInfoLib in these
modules. Therefore, a platform building the variable modules must
specify an instance of VariableFlashInfoLib in their platform build.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2022-05-19 06:11:20 +00:00
60b519456c MdeModulePkg/VariableFlashInfoLib: Add initial library
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3479

Adds a new library class VariableFlashInfoLib that abstracts access
to variable flash information. The instance provided first attempts
to retrieve information from the Variable Flash Info HOB. If that
HOB is not present, it falls back to the PCDs defined in
MdeModulePkg.

This fall back behavior provides backward compatibility for platforms
that only provide PCDs but also allows platforms that need to
dynamically provide the information using the Variable Flash Info HOB
to do so at runtime.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2022-05-19 06:11:20 +00:00
0903042b66 MdeModulePkg: Add Variable Flash Info HOB
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3479

Adds a new GUID that is used to identify a HOB that passes variable
flash information to UEFI variable drivers in HOB consumption phases
such as DXE, Traditional MM, and Standalone MM.

This information was previously passed directly with PCDs such
as EfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
and gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize.

However, the Standalone MM variable driver instance does not have
direct access to the PCD database. Therefore, this HOB will first
be considered as the source for variable flash information and
if platforms do not produce the HOB, reading the information from
the PCDs directly will be a backup to provide backward
compatibility.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2022-05-19 06:11:20 +00:00
2189c71026 .pytool/plugin/SpellCheck: Add more common words
Appends the word list to reduce the number of errors encountered
by individual packages.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
2022-05-19 03:02:14 +00:00
7b126978e1 .pytool/plugin/SpellCheck: Allow compound words
Sets "allowCompoundWords" to "true" to reduce the number of compound
word issues encountered in the future.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
2022-05-19 03:02:14 +00:00
2d1138a1a8 .azurepipelines: Fix cspell version to v5.20.0
The v5.21.0 update introduced a number of new issues that might
impact stable tag integration so this fixes the version to the
previous release.

Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>

This value can be revisited in the future to update the
2022-05-19 03:02:14 +00:00
138 changed files with 6853 additions and 1067 deletions

View File

@ -17,6 +17,6 @@ steps:
#checkLatest: false # Optional
condition: and(gt(variables.pkg_count, 0), succeeded())
- script: npm install -g cspell
- script: npm install -g cspell@5.20.0
displayName: 'Install cspell npm'
condition: and(gt(variables.pkg_count, 0), succeeded())

View File

@ -21,7 +21,7 @@
"*.jpg"
],
"minWordLength": 5,
"allowCompoundWords": false,
"allowCompoundWords": true,
"maxNumberOfProblems": 200,
"maxDuplicateProblems": 200,
"ignoreWords": [
@ -178,6 +178,117 @@
"vcruntimed",
"ucrtd",
"msvcrtd",
"XIPFLAGS"
"XIPFLAGS",
"bootflow",
"bootup",
"cacheability",
"cachetype",
"conout",
"deadloop",
"devicepath",
"hisilicon",
"littleendian",
"nonsecure",
"pagetable",
"postmem",
"premem",
"reglist",
"semihalf",
"subvendor",
"subhierarchy",
"targetlist",
"tmpname",
"watchdogtimer",
"writeback",
"langcode",
"langcodes",
"autoreload",
"bootable",
"endiannness",
"fvmain",
"prefetchable",
"multiboot",
"ramdisk",
"unbootable",
"setjump",
"bytecodes",
"bytelist",
"bytestream",
"countof",
"deregistering",
"devicetree",
"mainpage",
"mismanipulation",
"pytool",
"wbinvd",
"armltd",
"datacache",
"lastattemptstatus",
"lastattemptversion",
"lowestsupportedversion",
"updateable",
"pecoff",
"autodetect",
"harddisk",
"toctou",
"bugbug",
"depexes",
"fwvol",
"hoblist",
"imagehandle",
"schedulable",
"StandaloneMMCore",
"systemtable",
"uncacheable",
"devpath",
"testsuites",
"testcase",
"pxmldoc",
"pcxml",
"pclutf",
"pcunicode",
"ntxmltransformcharacter",
"ntxmlcomparestrings",
"pcxmldoc",
"ntxmlfetchcharacterdecoder",
"ntxml",
"ntxmlspecialstringcompare",
"rtlxmlcallback",
"xmlef",
"osruntime",
"readytoboot",
"hwerrrec",
"xformed",
"xform",
"undock",
"qrencoder",
"selawik",
"ntxmlrawnextcharacter",
"undocked",
"reprompt",
"yesno",
"okcancel",
"qrencoding",
"qrlevel",
"shiftn",
"unenroll",
"pcxmlstructure",
"pxmlstructure",
"pcencoder",
"pcvoid",
"nofailure",
"blockio",
"lockv",
"uefishelldebug",
"mtrrcap",
"drhds",
"rmrrs",
"creatorid",
"dxeipl",
"swmdialogs",
"unrecovered",
"cmocka",
"unenrolling",
"unconfigure"
]
}

View File

@ -176,6 +176,7 @@
AuthVariableLib|MdeModulePkg/Library/AuthVariableLibNull/AuthVariableLibNull.inf
!endif
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf

View File

@ -122,6 +122,7 @@
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLibRuntimeDxe.inf
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
SortLib|MdeModulePkg/Library/BaseSortLib/BaseSortLib.inf
ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf

View File

@ -0,0 +1,47 @@
Licensing for the filesystem drivers is complex. Three different licenses
apply to various parts of the code:
* Christoph Pfisterer's original file system wrapper (FSW) code is covered
by a BSD-style license. Many of the source files with names that take the
form fsw_*.[ch] are so licensed, but this is NOT generally true of
filesystem-specific files (e.g., fsw_ext2.c or fsw_btrfs.c).
* Certain filesystem drivers are licensed under the GPLv2, either because
they borrow code from the Linux kernel or because a developer (typically
Oracle) applied the GPLv2 license to them. This is true of the ext2fs,
ext4fs, ReiserFS, HFS+, and ISO-9660 drivers.
* At least one filesystem driver (Btrfs) uses code taken from GRUB, and so
uses the GPLv3 (or later) license.
Note that the GPLv2 and GPLv3 are, ironically, not compatible licenses.
Thus, code from GPLv2 and GPLv3 projects should not be mixed. The BSD
license used by Pfisterer's original code is compatible with both versions
of the GPL, so the fact that both GPLv2 and GPLv3 drivers is built upon it
is OK. If you intend to contribute to this project's drivers or use the
code yourself, please keep this fact in mind.
The below was written by Christoph Pfisterer with respect to his original
code:
File System Wrapper License
=============================
The various parts of the File System Wrapper source code come from
different sources and may carry different licenses. Here's a quick
account of the situation:
* The core code was written from scratch and is covered by a
BSD-style license.
* The EFI host driver was written from scratch, possibly using code
from the TianoCore project and Intel's EFI Application Toolkit. It
is covered by a BSD-style license.
* The ext2 and reiserfs file system drivers use definitions from the
Linux kernel source. The actual code was written from scratch,
using multiple sources for reference. These drivers are covered by
the GNU GPL.
For more details, see each file's boilerplate comment. The full text
of the GNU GPL is in the file LICENSE_GPL.txt.

View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

47
FSDrivers/X64/LICENSE.txt Normal file
View File

@ -0,0 +1,47 @@
Licensing for the filesystem drivers is complex. Three different licenses
apply to various parts of the code:
* Christoph Pfisterer's original file system wrapper (FSW) code is covered
by a BSD-style license. Many of the source files with names that take the
form fsw_*.[ch] are so licensed, but this is NOT generally true of
filesystem-specific files (e.g., fsw_ext2.c or fsw_btrfs.c).
* Certain filesystem drivers are licensed under the GPLv2, either because
they borrow code from the Linux kernel or because a developer (typically
Oracle) applied the GPLv2 license to them. This is true of the ext2fs,
ext4fs, ReiserFS, HFS+, and ISO-9660 drivers.
* At least one filesystem driver (Btrfs) uses code taken from GRUB, and so
uses the GPLv3 (or later) license.
Note that the GPLv2 and GPLv3 are, ironically, not compatible licenses.
Thus, code from GPLv2 and GPLv3 projects should not be mixed. The BSD
license used by Pfisterer's original code is compatible with both versions
of the GPL, so the fact that both GPLv2 and GPLv3 drivers is built upon it
is OK. If you intend to contribute to this project's drivers or use the
code yourself, please keep this fact in mind.
The below was written by Christoph Pfisterer with respect to his original
code:
File System Wrapper License
=============================
The various parts of the File System Wrapper source code come from
different sources and may carry different licenses. Here's a quick
account of the situation:
* The core code was written from scratch and is covered by a
BSD-style license.
* The EFI host driver was written from scratch, possibly using code
from the TianoCore project and Intel's EFI Application Toolkit. It
is covered by a BSD-style license.
* The ext2 and reiserfs file system drivers use definitions from the
Linux kernel source. The actual code was written from scratch,
using multiple sources for reference. These drivers are covered by
the GNU GPL.
For more details, see each file's boilerplate comment. The full text
of the GNU GPL is in the file LICENSE_GPL.txt.

View File

@ -0,0 +1,340 @@
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
<one line to give the program's name and a brief idea of what it does.>
Copyright (C) <year> <name of author>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
<signature of Ty Coon>, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.

Binary file not shown.

BIN
FSDrivers/X64/exfat_x64.efi Normal file

Binary file not shown.

BIN
FSDrivers/X64/ext2_x64.efi Normal file

Binary file not shown.

BIN
FSDrivers/X64/ext4_x64.efi Normal file

Binary file not shown.

BIN
FSDrivers/X64/ntfs_x64.efi Normal file

Binary file not shown.

27
FSDrivers/exfat.inf Normal file
View File

@ -0,0 +1,27 @@
# ReadOnly exFAT filesystem driver
# From https://efi.akeo.ie/ v1.5
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = exfat
FILE_GUID = CB683001-379F-48C7-B7B6-707D29454BF5
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
VALID_ARCHITECTURES = X64 IA32
[Binaries.X64]
PE32|X64/exfat_x64.efi|*
[Binaries.IA32]
PE32|IA32/exfat_ia32.efi|*

25
FSDrivers/ext2.inf Normal file
View File

@ -0,0 +1,25 @@
# EXT2 filesystem driver. See */LICENSE.txt for details.
# https://www.rodsbooks.com/refind/ v0.12
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = ext2
FILE_GUID = 8EC49C43-D1C4-4E6C-98BF-232CA5D89A1B
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
VALID_ARCHITECTURES = X64 IA32
[Binaries.X64]
PE32|X64/ext2_x64.efi|*
[Binaries.IA32]
PE32|IA32/ext2_ia32.efi|*

25
FSDrivers/ext4.inf Normal file
View File

@ -0,0 +1,25 @@
# EXT4 filesystem driver. See */LICENSE.txt for details.
# https://www.rodsbooks.com/refind/ v0.12
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = ext4
FILE_GUID = 9d380387-a15a-4053-ae19-ff3495b6d0d5
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
VALID_ARCHITECTURES = X64 IA32
[Binaries.X64]
PE32|X64/ext4_x64.efi|*
[Binaries.IA32]
PE32|IA32/ext4_ia32.efi|*

27
FSDrivers/ntfs.inf Normal file
View File

@ -0,0 +1,27 @@
# ReadOnly NTFS filesystem driver
# From https://efi.akeo.ie/ v1.5
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = ntfs
FILE_GUID = 2282efd0-678b-4753-8d06-200d5940285d
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 IPF EBC
#
VALID_ARCHITECTURES = X64 IA32
[Binaries.X64]
PE32|X64/ntfs_x64.efi|*
[Binaries.IA32]
PE32|IA32/ntfs_ia32.efi|*

View File

@ -7,6 +7,14 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <IndustryStandard/Pci.h>
#include <Protocol/PciIo.h>
#include <Protocol/PciRootBridgeIo.h>
#include <Protocol/UsbIo.h>
#include <Register/Amd/Cpuid.h>
#include <Register/Intel/Cpuid.h>
#include <Register/Intel/Msr.h>
#include "FrontPage.h"
#include "FrontPageCustomizedUi.h"
@ -17,7 +25,6 @@ EFI_GUID mFrontPageGuid = FRONT_PAGE_FORMSET_GUID;
BOOLEAN mResetRequired = FALSE;
EFI_FORM_BROWSER2_PROTOCOL *gFormBrowser2;
CHAR8 *mLanguageString;
BOOLEAN mModeInitialized = FALSE;
//
// Boot video resolution and text mode.
@ -34,11 +41,12 @@ UINT32 mSetupTextModeRow = 0;
UINT32 mSetupHorizontalResolution = 0;
UINT32 mSetupVerticalResolution = 0;
EFI_SYSTEM_TABLE * gSystemTable = NULL;
FRONT_PAGE_CALLBACK_DATA gFrontPagePrivate = {
FRONT_PAGE_CALLBACK_DATA_SIGNATURE,
NULL,
NULL,
NULL,
{
FakeExtractConfig,
FakeRouteConfig,
@ -371,10 +379,6 @@ FreeFrontPage (
// Publish our HII data
//
HiiRemovePackages (gFrontPagePrivate.HiiHandle);
if (gFrontPagePrivate.LanguageToken != NULL) {
FreePool (gFrontPagePrivate.LanguageToken);
gFrontPagePrivate.LanguageToken = NULL;
}
}
/**
@ -496,6 +500,463 @@ GetOptionalStringByIndex (
return EFI_SUCCESS;
}
UINT16 SmbiosTableLength (SMBIOS_STRUCTURE_POINTER SmbiosTableN)
{
CHAR8 *AChar;
UINT16 Length;
AChar = (CHAR8 *)(SmbiosTableN.Raw + SmbiosTableN.Hdr->Length);
while ((*AChar != 0) || (*(AChar + 1) != 0)) {
AChar ++; //stop at 00 - first 0
}
Length = (UINT16)((UINTN)AChar - (UINTN)SmbiosTableN.Raw + 2); //length includes 00
return Length;
}
SMBIOS_STRUCTURE_POINTER GetSmbiosTableFromType (
SMBIOS_TABLE_ENTRY_POINT *SmbiosPoint, UINT8 SmbiosType, UINTN IndexTable)
{
SMBIOS_STRUCTURE_POINTER SmbiosTableN;
UINTN SmbiosTypeIndex;
SmbiosTypeIndex = 0;
SmbiosTableN.Raw = (UINT8 *)((UINTN)SmbiosPoint->TableAddress);
if (SmbiosTableN.Raw == NULL) {
return SmbiosTableN;
}
while ((SmbiosTypeIndex != IndexTable) || (SmbiosTableN.Hdr->Type != SmbiosType)) {
if (SmbiosTableN.Hdr->Type == SMBIOS_TYPE_END_OF_TABLE) {
SmbiosTableN.Raw = NULL;
return SmbiosTableN;
}
if (SmbiosTableN.Hdr->Type == SmbiosType) {
SmbiosTypeIndex++;
}
SmbiosTableN.Raw = (UINT8 *)(SmbiosTableN.Raw + SmbiosTableLength (SmbiosTableN));
}
return SmbiosTableN;
}
STATIC
VOID
WarnNoBootableMedia (
VOID
)
{
CHAR16 *String;
EFI_STRING_ID Token;
EFI_BOOT_MANAGER_LOAD_OPTION *BootOption;
UINTN BootOptionCount;
UINTN Index;
UINTN Count = 0;
String = AllocateZeroPool (0x60);
BootOption = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
for (Index = 0; Index < BootOptionCount; Index++) {
//
// Don't count the hidden/inactive boot option
//
if (((BootOption[Index].Attributes & LOAD_OPTION_HIDDEN) != 0) || ((BootOption[Index].Attributes & LOAD_OPTION_ACTIVE) == 0)) {
continue;
}
Count++;
}
EfiBootManagerFreeLoadOptions (BootOption, BootOptionCount);
if (Count == 0) {
StrCatS (String, 0x60 / sizeof (CHAR16), L"Warning: No bootable media found");
} else {
StrCatS (String, 0x60 / sizeof (CHAR16), L"");
}
Token = STRING_TOKEN (STR_NO_BOOTABLE_MEDIA);
HiiSetString (gFrontPagePrivate.HiiHandle, Token, String, NULL);
FreePool(String);
}
BOOLEAN
StandardSignatureIsAuthenticAMD (
VOID
)
{
UINT32 RegEbx;
UINT32 RegEcx;
UINT32 RegEdx;
AsmCpuid (CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx);
return (RegEbx == CPUID_SIGNATURE_AUTHENTIC_AMD_EBX &&
RegEcx == CPUID_SIGNATURE_AUTHENTIC_AMD_ECX &&
RegEdx == CPUID_SIGNATURE_AUTHENTIC_AMD_EDX);
}
BOOLEAN
StandardSignatureIsGenuineIntel (
VOID
)
{
UINT32 RegEbx;
UINT32 RegEcx;
UINT32 RegEdx;
AsmCpuid (CPUID_SIGNATURE, NULL, &RegEbx, &RegEcx, &RegEdx);
return (RegEbx == CPUID_SIGNATURE_GENUINE_INTEL_EBX &&
RegEcx == CPUID_SIGNATURE_GENUINE_INTEL_ECX &&
RegEdx == CPUID_SIGNATURE_GENUINE_INTEL_EDX);
}
typedef struct {
CHAR8 Signature[8];
UINT8 Checksum;
CHAR8 OemId[6];
UINT8 Revision;
UINT32 RsdtAddress;
} ACPI_RSDP;
CHAR8 RSDP_SIGNATURE[8] = {'R', 'S', 'D', ' ', 'P', 'T', 'R', ' '};
typedef struct {
CHAR8 Signature[4];
UINT32 Length;
UINT8 Revision;
UINT8 Checksum;
CHAR8 OemId[6];
CHAR8 OemTableId[8];
UINT32 OemRevision;
UINT32 CreatorId;
UINT32 CreatorRevision;
} ACPI_SDT_HEADER;
CHAR8 RSDT_SIGNATURE[4] = {'R', 'S', 'D', 'T'};
STATIC ACPI_SDT_HEADER* FindAcpiTable(CHAR8 Name[4]) {
UINTN Index;
EFI_CONFIGURATION_TABLE* ConfigurationTable;
UINTN RsdpPtr;
ACPI_RSDP* Rsdp;
UINTN RsdtPtr;
ACPI_SDT_HEADER* Rsdt;
UINTN TablePtr;
ACPI_SDT_HEADER* Table;
DEBUG ((EFI_D_INFO, "FindAcpiTable: '%c%c%c%c'\n",
Name[0],
Name[1],
Name[2],
Name[3]
));
if (gSystemTable == NULL) {
DEBUG ((EFI_D_INFO, " System Table missing\n"));
return NULL;
}
// Search the table for an entry that matches the ACPI Table Guid
for (Index = 0; Index < gSystemTable->NumberOfTableEntries; Index++) {
if (CompareGuid (&gEfiAcpiTableGuid, &(gSystemTable->ConfigurationTable[Index].VendorGuid))) {
ConfigurationTable = &gSystemTable->ConfigurationTable[Index];
break;
}
}
if (ConfigurationTable == NULL) {
DEBUG ((EFI_D_INFO, " ACPI Configuration Table missing\n"));
return NULL;
}
RsdpPtr = (UINTN)ConfigurationTable->VendorTable;
DEBUG ((EFI_D_INFO, " RSDP 0x%x\n", RsdpPtr));
Rsdp = (ACPI_RSDP*)RsdpPtr;
DEBUG ((EFI_D_INFO, " Signature: '%c%c%c%c%c%c%c%c'\n",
Rsdp->Signature[0],
Rsdp->Signature[1],
Rsdp->Signature[2],
Rsdp->Signature[3],
Rsdp->Signature[4],
Rsdp->Signature[5],
Rsdp->Signature[6],
Rsdp->Signature[7]
));
if (CompareMem(Rsdp->Signature, RSDP_SIGNATURE, 8) != 0) {
DEBUG ((EFI_D_INFO, " RSDP invalid signature\n"));
return NULL;
}
DEBUG ((EFI_D_INFO, " Revision: 0x%x\n", Rsdp->Revision));
RsdtPtr = (UINTN)Rsdp->RsdtAddress;
DEBUG ((EFI_D_INFO, " RSDT 0x%x\n", RsdpPtr));
Rsdt = (ACPI_SDT_HEADER*)RsdtPtr;
DEBUG ((EFI_D_INFO, " Signature: '%c%c%c%c'\n",
Rsdt->Signature[0],
Rsdt->Signature[1],
Rsdt->Signature[2],
Rsdt->Signature[3]
));
if (CompareMem(Rsdt->Signature, RSDT_SIGNATURE, 4) != 0) {
DEBUG ((EFI_D_INFO, " RSDT invalid signature\n"));
return NULL;
}
DEBUG ((EFI_D_INFO, " Revision: 0x%x\n", Rsdt->Revision));
DEBUG ((EFI_D_INFO, " Length: 0x%x\n", Rsdt->Length));
for (Index = sizeof(ACPI_SDT_HEADER); Index < Rsdt->Length; Index += 4) {
TablePtr = (UINTN)(*(UINT32*)(RsdtPtr + Index));
DEBUG ((EFI_D_INFO, " Table %d: 0x%x\n", Index, TablePtr));
Table = (ACPI_SDT_HEADER*)TablePtr;
DEBUG ((EFI_D_INFO, " Signature: '%c%c%c%c'\n",
Table->Signature[0],
Table->Signature[1],
Table->Signature[2],
Table->Signature[3]
));
DEBUG ((EFI_D_INFO, " Revision: 0x%x\n", Table->Revision));
DEBUG ((EFI_D_INFO, " Length: 0x%x\n", Table->Length));
if (CompareMem(Table->Signature, Name, 4) == 0) {
DEBUG ((EFI_D_INFO, " Match found\n"));
return Table;
}
}
DEBUG ((EFI_D_INFO, " No match found\n"));
return NULL;
}
// From PciBusDxe
STATIC
EFI_STATUS
PciDevicePresent(
OUT PCI_TYPE00 *Pci,
IN UINT8 Bus,
IN UINT8 Device,
IN UINT8 Func
)
{
UINT64 Address = EFI_PCI_ADDRESS(Bus, Device, Func, 0);
EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo;
EFI_STATUS Status;
EFI_HANDLE *PciIoBuffer;
UINTN PciIoHandleCount = 0;
Status = gBS->LocateHandleBuffer(
ByProtocol,
&gEfiPciRootBridgeIoProtocolGuid,
NULL,
&PciIoHandleCount,
&PciIoBuffer
);
if (EFI_ERROR(Status)) {
DEBUG((EFI_D_INFO, "%a: Failed to get PciRootBridgeIo handles: %r\n", __FUNCTION__, Status));
return Status;
}
for (UINTN Index = 0; Index < PciIoHandleCount; Index++) {
Status = gBS->OpenProtocol(
PciIoBuffer[Index],
&gEfiPciRootBridgeIoProtocolGuid,
(VOID *)&PciRootBridgeIo,
NULL,
NULL,
EFI_OPEN_PROTOCOL_GET_PROTOCOL
);
if (EFI_ERROR(Status)) {
DEBUG((EFI_D_INFO, "%a: Failed to open PciRootBridgeIo protocol: %r\n", __FUNCTION__, Status));
continue;
}
// Read the Vendor ID register
Status = PciRootBridgeIo->Pci.Read(
PciRootBridgeIo,
EfiPciWidthUint32,
Address,
1,
Pci
);
if (EFI_ERROR(Status)) {
DEBUG((EFI_D_INFO, "%a: Failed to read vendor ID: %r\n", __FUNCTION__, Status));
continue;
}
// Read the entire config header for the device
Status = PciRootBridgeIo->Pci.Read(
PciRootBridgeIo,
EfiPciWidthUint32,
Address,
sizeof(PCI_TYPE00) / sizeof(UINT32),
Pci
);
FreePool(PciIoBuffer);
return Status;
}
FreePool(PciIoBuffer);
return EFI_NOT_FOUND;
}
/*
* Check for Intel device with class [0780] at 00:16.0.
*/
STATIC
BOOLEAN
HasCsmeDevice(VOID)
{
PCI_TYPE00 Pci;
if (!EFI_ERROR(PciDevicePresent(&Pci, 0x00, 0x16, 0x00))) {
DEBUG((EFI_D_INFO, "%a: vid=0x%04X, class=[%02X,%02X,%02X]\n", __FUNCTION__,
Pci.Hdr.VendorId, Pci.Hdr.ClassCode[0], Pci.Hdr.ClassCode[1], Pci.Hdr.ClassCode[2]));
return Pci.Hdr.VendorId == 0x8086 &&
Pci.Hdr.ClassCode[2] == PCI_CLASS_SCC &&
Pci.Hdr.ClassCode[1] == PCI_SUBCLASS_SCC_OTHER;
}
return FALSE;
}
STATIC VOID FirmwareConfigurationInformation(VOID) {
EFI_STRING_ID Token;
Token = STRING_TOKEN (STR_VIRTUALIZATION);
if (StandardSignatureIsGenuineIntel()) {
HiiSetString (gFrontPagePrivate.HiiHandle, Token, L"Intel Virtualization", NULL);
Token = STRING_TOKEN (STR_VIRTUALIZATION_STATUS);
CPUID_VERSION_INFO_ECX VersionInfoEcx;
AsmCpuid (CPUID_VERSION_INFO, NULL, NULL, &VersionInfoEcx.Uint32, NULL);
if (VersionInfoEcx.Bits.VMX) {
HiiSetString (gFrontPagePrivate.HiiHandle, Token, L"VT-x: Active", NULL);
} else {
HiiSetString (gFrontPagePrivate.HiiHandle, Token, L"VT-x: Deactivated", NULL);
}
Token = STRING_TOKEN (STR_IOMMU_STATUS);
CHAR8 TableName[4] = {'D', 'M', 'A', 'R'};
if (FindAcpiTable(TableName)) {
HiiSetString (gFrontPagePrivate.HiiHandle, Token, L"VT-d: Active", NULL);
} else {
HiiSetString (gFrontPagePrivate.HiiHandle, Token, L"VT-d: Deactivated", NULL);
}
Token = STRING_TOKEN(STR_ME_STATUS);
if (HasCsmeDevice()) {
HiiSetString (gFrontPagePrivate.HiiHandle, Token, L"The Intel Management Engine is enabled.", NULL);
} else {
HiiSetString (gFrontPagePrivate.HiiHandle, Token, L"The Intel Management Engine is disabled at runtime to increase security.", NULL);
}
} else if (StandardSignatureIsAuthenticAMD()) {
//TODO: verify AMD tests
HiiSetString (gFrontPagePrivate.HiiHandle, Token, L"AMD Virtualization", NULL);
Token = STRING_TOKEN (STR_VIRTUALIZATION_STATUS);
CPUID_AMD_EXTENDED_CPU_SIG_ECX AmdExtendedCpuSigEcx;
AsmCpuid (CPUID_EXTENDED_CPU_SIG, NULL, NULL, &AmdExtendedCpuSigEcx.Uint32, NULL);
if (AmdExtendedCpuSigEcx.Bits.SVM) {
HiiSetString (gFrontPagePrivate.HiiHandle, Token, L"AMD-V: Active", NULL);
} else {
HiiSetString (gFrontPagePrivate.HiiHandle, Token, L"AMD-V: Deactivated", NULL);
}
Token = STRING_TOKEN (STR_IOMMU_STATUS);
//TODO: proper test for AMD IOMMU
BOOLEAN iommu_active = FALSE;
if (iommu_active) {
HiiSetString (gFrontPagePrivate.HiiHandle, Token, L"AMD-Vi: Active", NULL);
} else {
HiiSetString (gFrontPagePrivate.HiiHandle, Token, L"AMD-Vi: Deactivated", NULL);
}
}
Token = STRING_TOKEN (STR_TPM_STATUS);
CHAR8 TableName[4] = {'T', 'P', 'M', '2'};
if (FindAcpiTable(TableName)) {
HiiSetString (gFrontPagePrivate.HiiHandle, Token, L"Trusted Platform Module: Active", NULL);
} else {
HiiSetString (gFrontPagePrivate.HiiHandle, Token, L"Trusted Platform Module: Deactivated", NULL);
}
}
VOID WebcamStatus(VOID) {
EFI_STATUS Status;
UINTN UsbIoHandleCount;
EFI_HANDLE *UsbIoBuffer;
UINTN Index;
EFI_USB_IO_PROTOCOL *UsbIo;
EFI_USB_DEVICE_DESCRIPTOR DevDesc;
EFI_USB_INTERFACE_DESCRIPTOR IntfDesc;
UINTN Webcams;
EFI_STRING_ID Token;
//
// Get all Usb IO handles in system
//
UsbIoHandleCount = 0;
Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiUsbIoProtocolGuid, NULL, &UsbIoHandleCount, &UsbIoBuffer);
if (EFI_ERROR(Status)) {
DEBUG ((EFI_D_INFO, "Failed to read UsbIo handles: 0x%x\n", Status));
return;
}
Webcams = 0;
for (Index = 0; Index < UsbIoHandleCount; Index++) {
DEBUG ((EFI_D_INFO, "UsbIo Handle %d\n", Index));
//
// Get the child Usb IO interface
//
Status = gBS->HandleProtocol(
UsbIoBuffer[Index],
&gEfiUsbIoProtocolGuid,
(VOID **) &UsbIo
);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_INFO, " Failed to find UsbIo protocol\n"));
continue;
}
Status = UsbIo->UsbGetDeviceDescriptor (UsbIo, &DevDesc);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_INFO, " Failed to get device descriptor\n"));
continue;
}
DEBUG ((EFI_D_INFO, " ID: 0x%04X:0x%04X\n", DevDesc.IdVendor, DevDesc.IdProduct));
DEBUG ((EFI_D_INFO, " DeviceClass: %d\n", DevDesc.DeviceClass));
DEBUG ((EFI_D_INFO, " DeviceSubClass: %d\n", DevDesc.DeviceSubClass));
DEBUG ((EFI_D_INFO, " DeviceProtocol: %d\n", DevDesc.DeviceProtocol));
Status = UsbIo->UsbGetInterfaceDescriptor (UsbIo, &IntfDesc);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_INFO, " Failed to get interface descriptor\n"));
continue;
}
DEBUG ((EFI_D_INFO, " Interface: %d\n", IntfDesc.InterfaceNumber));
DEBUG ((EFI_D_INFO, " InterfaceClass: %d\n", IntfDesc.InterfaceClass));
DEBUG ((EFI_D_INFO, " InterfaceSubClass: %d\n", IntfDesc.InterfaceSubClass));
DEBUG ((EFI_D_INFO, " InterfaceProtocol: %d\n", IntfDesc.InterfaceProtocol));
if (IntfDesc.InterfaceClass == 14 && IntfDesc.InterfaceSubClass == 1) {
DEBUG ((EFI_D_INFO, " Detected Video Control interface\n"));
Webcams++;
}
}
FreePool (UsbIoBuffer);
//TODO: logic for not showing the warning on desktops
Token = STRING_TOKEN (STR_WEBCAM_STATUS);
if (Webcams == 0) {
HiiSetString (gFrontPagePrivate.HiiHandle, Token, L"Info: Webcam Module Disconnected", NULL);
}
}
/**
Update the banner information for the Front Page based on Smbios information.
@ -506,160 +967,86 @@ UpdateFrontPageBannerStrings (
VOID
)
{
UINT8 StrIndex;
CHAR16 *NewString;
CHAR16 *FirmwareVersionString;
EFI_STATUS Status;
EFI_SMBIOS_HANDLE SmbiosHandle;
EFI_SMBIOS_PROTOCOL *Smbios;
SMBIOS_TABLE_TYPE0 *Type0Record;
SMBIOS_TABLE_TYPE1 *Type1Record;
SMBIOS_TABLE_TYPE4 *Type4Record;
SMBIOS_TABLE_TYPE19 *Type19Record;
EFI_SMBIOS_TABLE_HEADER *Record;
UINT64 InstalledMemory;
BOOLEAN FoundCpu;
EFI_STATUS Status;
EFI_STRING_ID TokenToUpdate;
EFI_PHYSICAL_ADDRESS *Table;
SMBIOS_TABLE_ENTRY_POINT *EntryPoint;
SMBIOS_STRUCTURE_POINTER SmbiosTable;
InstalledMemory = 0;
FoundCpu = 0;
//
// Update default banner string.
//
NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_LEFT), NULL);
UiCustomizeFrontPageBanner (4, TRUE, &NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_LEFT), NewString, NULL);
FreePool (NewString);
NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_RIGHT), NULL);
UiCustomizeFrontPageBanner (4, FALSE, &NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE4_RIGHT), NewString, NULL);
FreePool (NewString);
NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_LEFT), NULL);
UiCustomizeFrontPageBanner (5, TRUE, &NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_LEFT), NewString, NULL);
FreePool (NewString);
NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_RIGHT), NULL);
UiCustomizeFrontPageBanner (5, FALSE, &NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_CUSTOMIZE_BANNER_LINE5_RIGHT), NewString, NULL);
FreePool (NewString);
//
// Update Front Page banner strings base on SmBios Table.
//
Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID **)&Smbios);
if (EFI_ERROR (Status)) {
//
// Smbios protocol not found, get the default value.
//
NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL), NULL);
UiCustomizeFrontPageBanner (1, TRUE, &NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL), NewString, NULL);
FreePool (NewString);
NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL), NULL);
UiCustomizeFrontPageBanner (2, TRUE, &NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL), NewString, NULL);
FreePool (NewString);
NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), NULL);
UiCustomizeFrontPageBanner (2, FALSE, &NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), NewString, NULL);
FreePool (NewString);
NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NULL);
UiCustomizeFrontPageBanner (3, TRUE, &NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NewString, NULL);
FreePool (NewString);
NewString = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE), NULL);
UiCustomizeFrontPageBanner (3, FALSE, &NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE), NewString, NULL);
FreePool (NewString);
FirmwareConfigurationInformation();
WarnNoBootableMedia ();
WebcamStatus();
Status = EfiGetSystemConfigurationTable (&gEfiSmbiosTableGuid, (VOID **) &Table);
if (EFI_ERROR (Status) || Table == NULL) {
return;
}
SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
while (!EFI_ERROR (Status)) {
if (Record->Type == SMBIOS_TYPE_BIOS_INFORMATION) {
Type0Record = (SMBIOS_TABLE_TYPE0 *)Record;
StrIndex = Type0Record->BiosVersion;
GetOptionalStringByIndex ((CHAR8 *)((UINT8 *)Type0Record + Type0Record->Hdr.Length), StrIndex, &NewString);
EntryPoint = (SMBIOS_TABLE_ENTRY_POINT*)Table;
FirmwareVersionString = (CHAR16 *)PcdGetPtr (PcdFirmwareVersionString);
if (*FirmwareVersionString != 0x0000 ) {
FreePool (NewString);
NewString = (CHAR16 *)PcdGetPtr (PcdFirmwareVersionString);
UiCustomizeFrontPageBanner (3, TRUE, &NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NewString, NULL);
} else {
UiCustomizeFrontPageBanner (3, TRUE, &NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION), NewString, NULL);
FreePool (NewString);
}
}
SmbiosTable = GetSmbiosTableFromType (EntryPoint, EFI_SMBIOS_TYPE_BIOS_INFORMATION , 0);
if (SmbiosTable.Raw != NULL) {
CHAR16 *FwVersion;
CHAR16 *TmpBuffer;
UINT8 VersionIdx;
if (Record->Type == SMBIOS_TYPE_SYSTEM_INFORMATION) {
Type1Record = (SMBIOS_TABLE_TYPE1 *)Record;
StrIndex = Type1Record->ProductName;
GetOptionalStringByIndex ((CHAR8 *)((UINT8 *)Type1Record + Type1Record->Hdr.Length), StrIndex, &NewString);
UiCustomizeFrontPageBanner (1, TRUE, &NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL), NewString, NULL);
FreePool (NewString);
}
TmpBuffer = AllocateZeroPool (0x60);
if ((Record->Type == SMBIOS_TYPE_PROCESSOR_INFORMATION) && !FoundCpu) {
Type4Record = (SMBIOS_TABLE_TYPE4 *)Record;
//
// The information in the record should be only valid when the CPU Socket is populated.
//
if ((Type4Record->Status & SMBIOS_TYPE4_CPU_SOCKET_POPULATED) == SMBIOS_TYPE4_CPU_SOCKET_POPULATED) {
StrIndex = Type4Record->ProcessorVersion;
GetOptionalStringByIndex ((CHAR8 *)((UINT8 *)Type4Record + Type4Record->Hdr.Length), StrIndex, &NewString);
UiCustomizeFrontPageBanner (2, TRUE, &NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_MODEL), NewString, NULL);
FreePool (NewString);
VersionIdx = SmbiosTable.Type0->BiosVersion;
GetOptionalStringByIndex ((CHAR8*)((UINT8*)SmbiosTable.Raw + SmbiosTable.Hdr->Length), VersionIdx, &FwVersion);
ConvertProcessorToString (Type4Record->CurrentSpeed, 6, &NewString);
UiCustomizeFrontPageBanner (2, FALSE, &NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), NewString, NULL);
FreePool (NewString);
StrCatS (TmpBuffer, 0x60 / sizeof (CHAR16), L"Version: ");
StrCatS (TmpBuffer, 0x60 / sizeof (CHAR16), FwVersion);
FoundCpu = TRUE;
}
}
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, TmpBuffer, NULL);
if ( Record->Type == SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS ) {
Type19Record = (SMBIOS_TABLE_TYPE19 *)Record;
if (Type19Record->StartingAddress != 0xFFFFFFFF ) {
InstalledMemory += RShiftU64 (
Type19Record->EndingAddress -
Type19Record->StartingAddress + 1,
10
);
} else {
InstalledMemory += RShiftU64 (
Type19Record->ExtendedEndingAddress -
Type19Record->ExtendedStartingAddress + 1,
20
);
}
}
Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
FreePool (FwVersion);
FreePool (TmpBuffer);
}
//
// Now update the total installed RAM size
//
ConvertMemorySizeToString ((UINT32)InstalledMemory, &NewString);
UiCustomizeFrontPageBanner (3, FALSE, &NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_MEMORY_SIZE), NewString, NULL);
FreePool (NewString);
SmbiosTable = GetSmbiosTableFromType (EntryPoint, SMBIOS_TYPE_SYSTEM_INFORMATION , 0);
if (SmbiosTable.Raw != NULL) {
CHAR16 *Manufacturer;
CHAR16 *ProductName;
CHAR16 *ProductVersion;
CHAR16 *Title;
CHAR16 *Model;
UINT8 ModelIdx;
UINT8 ManIdx;
UINT8 VersionIdx;
Title = AllocateZeroPool (0x60);
Model = AllocateZeroPool (0x60);
ManIdx = SmbiosTable.Type1->Manufacturer;
ModelIdx = SmbiosTable.Type1->ProductName;
GetOptionalStringByIndex ((CHAR8*)((UINT8*)SmbiosTable.Raw + SmbiosTable.Hdr->Length), ModelIdx, &ProductName);
GetOptionalStringByIndex ((CHAR8*)((UINT8*)SmbiosTable.Raw + SmbiosTable.Hdr->Length), ManIdx, &Manufacturer);
StrCatS (Title, 0x60 / sizeof (CHAR16), Manufacturer);
StrCatS (Title, 0x60 / sizeof (CHAR16), L" ");
StrCatS (Title, 0x60 / sizeof (CHAR16), ProductName);
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_TITLE);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, Title, NULL);
VersionIdx = SmbiosTable.Type1->Version;
GetOptionalStringByIndex ((CHAR8*)((UINT8*)SmbiosTable.Raw + SmbiosTable.Hdr->Length), VersionIdx, &ProductVersion);
StrCatS (Model, 0x60 / sizeof (CHAR16), L"Model: ");
StrCatS (Model, 0x60 / sizeof (CHAR16), ProductVersion);
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_COMPUTER_MODEL);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, Model, NULL);
FreePool (Model);
FreePool (Title);
FreePool (ProductVersion);
FreePool (ProductName);
FreePool (Manufacturer);
}
}
/**
@ -907,6 +1294,8 @@ InitializeUserInterface (
UINTN BootTextColumn;
UINTN BootTextRow;
gSystemTable = SystemTable;
if (!mModeInitialized) {
//
// After the console is ready, get current video resolution
@ -1032,11 +1421,6 @@ UiEntry (
FreeFrontPage ();
if (mLanguageString != NULL) {
FreePool (mLanguageString);
mLanguageString = NULL;
}
//
// Will leave browser, check any reset required change is applied? if yes, reset system
//

View File

@ -31,7 +31,7 @@ extern EFI_FORM_BROWSER2_PROTOCOL *gFormBrowser2;
//
// These are defined as the same with vfr file
//
#define FRONT_PAGE_FORM_ID 0x1000
#define FRONT_PAGE_FORM_ID 0x7600
#define LABEL_FRONTPAGE_INFORMATION 0x1000
#define LABEL_END 0xffff
@ -51,7 +51,6 @@ typedef struct {
//
EFI_HII_HANDLE HiiHandle;
EFI_HANDLE DriverHandle;
EFI_STRING_ID *LanguageToken;
//
// Produced protocols

View File

@ -29,35 +29,15 @@ UiCustomizeFrontPage (
IN VOID *StartOpCodeHandle
)
{
//
// Create "Select Language" menu with Oneof opcode.
//
UiCreateLanguageMenu (HiiHandle, StartOpCodeHandle);
//
// Create empty line.
//
UiCreateEmptyLine (HiiHandle, StartOpCodeHandle);
//
// Find third party drivers which need to be shown in the front page.
//
UiListThirdPartyDrivers (HiiHandle, &gEfiIfrFrontPageGuid, NULL, StartOpCodeHandle);
//
// Create empty line.
//
UiCreateEmptyLine (HiiHandle, StartOpCodeHandle);
//
// Create "Continue" menu.
//
UiCreateContinueMenu (HiiHandle, StartOpCodeHandle);
//
// Create reset menu.
// Find third party drivers which need to be shown in the front page.
//
UiCreateResetMenu (HiiHandle, StartOpCodeHandle);
UiListThirdPartyDrivers (HiiHandle, &gEfiIfrFrontPageGuid, NULL, StartOpCodeHandle);
}
/**
@ -96,46 +76,3 @@ UiFrontPageCallbackHandler (
return EFI_UNSUPPORTED;
}
/**
Update the banner string in the front page.
Current layout for the banner string like below:
PS: Totally only 5 lines of banner supported.
Line 1: Left BannerStr RightBannerStr
Line 2: Left BannerStr RightBannerStr
Line 3: Left BannerStr RightBannerStr
Line 4: Left BannerStr RightBannerStr
Line 5: Left BannerStr RightBannerStr
<EmptyLine>
First menu in front page.
...
@param LineIndex The line index of the banner need to check.
@param LeftOrRight The left or right banner need to check.
@param BannerStr Banner string need to update.
Input the current string and user can update
it and return the new string.
**/
VOID
UiCustomizeFrontPageBanner (
IN UINTN LineIndex,
IN BOOLEAN LeftOrRight,
IN OUT EFI_STRING *BannerStr
)
{
if ((LineIndex == 5) && LeftOrRight) {
// Update STR_CUSTOMIZE_BANNER_LINE5_LEFT
if (PcdGetBool (PcdTestKeyUsed)) {
if (BannerStr != NULL) {
FreePool (*BannerStr);
}
*BannerStr = HiiGetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_TEST_KEY_USED), NULL);
}
}
return;
}

View File

@ -9,35 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#ifndef __FRONTPAGE_CUSTOMIZED_UI_H__
#define __FRONTPAGE_CUSTOMIZED_UI_H__
/**
Update the banner string in the front page.
Current layout for the banner string like below:
PS: Totally only 5 lines of banner supported.
Line 1: Left BannerStr RightBannerStr
Line 2: Left BannerStr RightBannerStr
Line 3: Left BannerStr RightBannerStr
Line 4: Left BannerStr RightBannerStr
Line 5: Left BannerStr RightBannerStr
<EmptyLine>
First menu in front page.
...
@param LineIndex The line index of the banner need to check.
@param LeftOrRight The left or right banner need to check.
@param BannerStr Banner string need to update.
Input the current string and user can update
it and return the new string.
**/
VOID
UiCustomizeFrontPageBanner (
IN UINTN LineIndex,
IN BOOLEAN LeftOrRight,
IN OUT EFI_STRING *BannerStr
);
/**
Customize menus in the page.

View File

@ -35,8 +35,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define UI_HII_DRIVER_LIST_SIZE 0x8
#define FRONT_PAGE_KEY_CONTINUE 0x1000
#define FRONT_PAGE_KEY_RESET 0x1001
#define FRONT_PAGE_KEY_LANGUAGE 0x1002
#define FRONT_PAGE_KEY_DRIVER 0x2000
typedef struct {
@ -47,112 +45,8 @@ typedef struct {
BOOLEAN EmptyLineAfter;
} UI_HII_DRIVER_INSTANCE;
CHAR8 *gLanguageString;
EFI_STRING_ID *gLanguageToken;
UI_HII_DRIVER_INSTANCE *gHiiDriverList;
extern EFI_HII_HANDLE gStringPackHandle;
UINT8 gCurrentLanguageIndex;
/**
Get next language from language code list (with separator ';').
If LangCode is NULL, then ASSERT.
If Lang is NULL, then ASSERT.
@param LangCode On input: point to first language in the list. On
output: point to next language in the list, or
NULL if no more language in the list.
@param Lang The first language in the list.
**/
VOID
GetNextLanguage (
IN OUT CHAR8 **LangCode,
OUT CHAR8 *Lang
)
{
UINTN Index;
CHAR8 *StringPtr;
ASSERT (LangCode != NULL);
ASSERT (*LangCode != NULL);
ASSERT (Lang != NULL);
Index = 0;
StringPtr = *LangCode;
while (StringPtr[Index] != 0 && StringPtr[Index] != ';') {
Index++;
}
CopyMem (Lang, StringPtr, Index);
Lang[Index] = 0;
if (StringPtr[Index] == ';') {
Index++;
}
*LangCode = StringPtr + Index;
}
/**
This function processes the language changes in configuration.
@param Value A pointer to the data being sent to the original exporting driver.
@retval TRUE The callback successfully handled the action.
@retval FALSE The callback not supported in this handler.
**/
EFI_STATUS
LanguageChangeHandler (
IN EFI_IFR_TYPE_VALUE *Value
)
{
CHAR8 *LangCode;
CHAR8 *Lang;
UINTN Index;
EFI_STATUS Status;
//
// Allocate working buffer for RFC 4646 language in supported LanguageString.
//
Lang = AllocatePool (AsciiStrSize (gLanguageString));
ASSERT (Lang != NULL);
Index = 0;
LangCode = gLanguageString;
while (*LangCode != 0) {
GetNextLanguage (&LangCode, Lang);
if (Index == Value->u8) {
gCurrentLanguageIndex = Value->u8;
break;
}
Index++;
}
if (Index == Value->u8) {
Status = gRT->SetVariable (
L"PlatformLang",
&gEfiGlobalVariableGuid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
AsciiStrSize (Lang),
Lang
);
if (EFI_ERROR (Status)) {
FreePool (Lang);
return EFI_DEVICE_ERROR;
}
} else {
ASSERT (FALSE);
}
FreePool (Lang);
return EFI_SUCCESS;
}
/**
This function processes the results of changes in configuration.
@ -182,21 +76,12 @@ UiSupportLibCallbackHandler (
OUT EFI_STATUS *Status
)
{
if ((QuestionId != FRONT_PAGE_KEY_CONTINUE) &&
(QuestionId != FRONT_PAGE_KEY_RESET) &&
(QuestionId != FRONT_PAGE_KEY_LANGUAGE))
{
if (QuestionId != FRONT_PAGE_KEY_CONTINUE) {
return FALSE;
}
if (Action == EFI_BROWSER_ACTION_RETRIEVE) {
if (QuestionId == FRONT_PAGE_KEY_LANGUAGE) {
Value->u8 = gCurrentLanguageIndex;
*Status = EFI_SUCCESS;
} else {
*Status = EFI_UNSUPPORTED;
}
*Status = EFI_UNSUPPORTED;
return TRUE;
}
@ -223,17 +108,6 @@ UiSupportLibCallbackHandler (
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;
break;
case FRONT_PAGE_KEY_LANGUAGE:
*Status = LanguageChangeHandler (Value);
break;
case FRONT_PAGE_KEY_RESET:
//
// Reset
//
gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
*Status = EFI_UNSUPPORTED;
default:
break;
}
@ -242,158 +116,6 @@ UiSupportLibCallbackHandler (
return TRUE;
}
/**
Create Select language menu in the front page with oneof opcode.
@param[in] HiiHandle The hii handle for the Uiapp driver.
@param[in] StartOpCodeHandle The opcode handle to save the new opcode.
**/
VOID
UiCreateLanguageMenu (
IN EFI_HII_HANDLE HiiHandle,
IN VOID *StartOpCodeHandle
)
{
CHAR8 *LangCode;
CHAR8 *Lang;
UINTN LangSize;
CHAR8 *CurrentLang;
UINTN OptionCount;
CHAR16 *StringBuffer;
VOID *OptionsOpCodeHandle;
UINTN StringSize;
EFI_STATUS Status;
EFI_HII_STRING_PROTOCOL *HiiString;
Lang = NULL;
StringBuffer = NULL;
//
// Init OpCode Handle and Allocate space for creation of UpdateData Buffer
//
OptionsOpCodeHandle = HiiAllocateOpCodeHandle ();
ASSERT (OptionsOpCodeHandle != NULL);
GetEfiGlobalVariable2 (L"PlatformLang", (VOID **)&CurrentLang, NULL);
//
// Get Support language list from variable.
//
GetEfiGlobalVariable2 (L"PlatformLangCodes", (VOID **)&gLanguageString, NULL);
if (gLanguageString == NULL) {
gLanguageString = AllocateCopyPool (
AsciiStrSize ((CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)),
(CHAR8 *)PcdGetPtr (PcdUefiVariableDefaultPlatformLangCodes)
);
ASSERT (gLanguageString != NULL);
}
if (gLanguageToken == NULL) {
//
// Count the language list number.
//
LangCode = gLanguageString;
Lang = AllocatePool (AsciiStrSize (gLanguageString));
ASSERT (Lang != NULL);
OptionCount = 0;
while (*LangCode != 0) {
GetNextLanguage (&LangCode, Lang);
OptionCount++;
}
//
// Allocate extra 1 as the end tag.
//
gLanguageToken = AllocateZeroPool ((OptionCount + 1) * sizeof (EFI_STRING_ID));
ASSERT (gLanguageToken != NULL);
Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, (VOID **)&HiiString);
ASSERT_EFI_ERROR (Status);
LangCode = gLanguageString;
OptionCount = 0;
while (*LangCode != 0) {
GetNextLanguage (&LangCode, Lang);
StringSize = 0;
Status = HiiString->GetString (HiiString, Lang, HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, StringBuffer, &StringSize, NULL);
if (Status == EFI_BUFFER_TOO_SMALL) {
StringBuffer = AllocateZeroPool (StringSize);
ASSERT (StringBuffer != NULL);
Status = HiiString->GetString (HiiString, Lang, HiiHandle, PRINTABLE_LANGUAGE_NAME_STRING_ID, StringBuffer, &StringSize, NULL);
ASSERT_EFI_ERROR (Status);
}
if (EFI_ERROR (Status)) {
LangSize = AsciiStrSize (Lang);
StringBuffer = AllocatePool (LangSize * sizeof (CHAR16));
ASSERT (StringBuffer != NULL);
AsciiStrToUnicodeStrS (Lang, StringBuffer, LangSize);
}
ASSERT (StringBuffer != NULL);
gLanguageToken[OptionCount] = HiiSetString (HiiHandle, 0, StringBuffer, NULL);
FreePool (StringBuffer);
OptionCount++;
}
}
ASSERT (gLanguageToken != NULL);
LangCode = gLanguageString;
OptionCount = 0;
if (Lang == NULL) {
Lang = AllocatePool (AsciiStrSize (gLanguageString));
ASSERT (Lang != NULL);
}
while (*LangCode != 0) {
GetNextLanguage (&LangCode, Lang);
if ((CurrentLang != NULL) && (AsciiStrCmp (Lang, CurrentLang) == 0)) {
HiiCreateOneOfOptionOpCode (
OptionsOpCodeHandle,
gLanguageToken[OptionCount],
EFI_IFR_OPTION_DEFAULT,
EFI_IFR_NUMERIC_SIZE_1,
(UINT8)OptionCount
);
gCurrentLanguageIndex = (UINT8)OptionCount;
} else {
HiiCreateOneOfOptionOpCode (
OptionsOpCodeHandle,
gLanguageToken[OptionCount],
0,
EFI_IFR_NUMERIC_SIZE_1,
(UINT8)OptionCount
);
}
OptionCount++;
}
if (CurrentLang != NULL) {
FreePool (CurrentLang);
}
FreePool (Lang);
HiiCreateOneOfOpCode (
StartOpCodeHandle,
FRONT_PAGE_KEY_LANGUAGE,
0,
0,
STRING_TOKEN (STR_LANGUAGE_SELECT),
STRING_TOKEN (STR_LANGUAGE_SELECT_HELP),
EFI_IFR_FLAG_CALLBACK,
EFI_IFR_NUMERIC_SIZE_1,
OptionsOpCodeHandle,
NULL
);
}
/**
Create continue menu in the front page.
@ -410,8 +132,8 @@ UiCreateContinueMenu (
HiiCreateActionOpCode (
StartOpCodeHandle,
FRONT_PAGE_KEY_CONTINUE,
STRING_TOKEN (STR_CONTINUE_PROMPT),
STRING_TOKEN (STR_CONTINUE_PROMPT),
STRING_TOKEN (STR_BOOT_DEFAULT_PROMPT),
STRING_TOKEN (STR_BOOT_DEFAULT_HELP),
EFI_IFR_FLAG_CALLBACK,
0
);
@ -430,30 +152,7 @@ UiCreateEmptyLine (
IN VOID *StartOpCodeHandle
)
{
HiiCreateSubTitleOpCode (StartOpCodeHandle, STRING_TOKEN (STR_NULL_STRING), 0, 0, 0);
}
/**
Create Reset menu in the front page.
@param[in] HiiHandle The hii handle for the Uiapp driver.
@param[in] StartOpCodeHandle The opcode handle to save the new opcode.
**/
VOID
UiCreateResetMenu (
IN EFI_HII_HANDLE HiiHandle,
IN VOID *StartOpCodeHandle
)
{
HiiCreateActionOpCode (
StartOpCodeHandle,
FRONT_PAGE_KEY_RESET,
STRING_TOKEN (STR_RESET_STRING),
STRING_TOKEN (STR_RESET_STRING),
EFI_IFR_FLAG_CALLBACK,
0
);
HiiCreateSubTitleOpCode (StartOpCodeHandle, STRING_TOKEN (STR_EMPTY_STRING), 0, 0, 0);
}
/**

View File

@ -35,32 +35,6 @@ UiCreateEmptyLine (
IN VOID *StartOpCodeHandle
);
/**
Create Select language menu in the front page with oneof opcode.
@param[in] HiiHandle The hii handle for the Uiapp driver.
@param[in] StartOpCodeHandle The opcode handle to save the new opcode.
**/
VOID
UiCreateLanguageMenu (
IN EFI_HII_HANDLE HiiHandle,
IN VOID *StartOpCodeHandle
);
/**
Create Reset menu.
@param[in] HiiHandle The hii handle for the Uiapp driver.
@param[in] StartOpCodeHandle The opcode handle to save the new opcode.
**/
VOID
UiCreateResetMenu (
IN EFI_HII_HANDLE HiiHandle,
IN VOID *StartOpCodeHandle
);
/**
Rename the driver name if necessary.

View File

@ -10,59 +10,19 @@
/=#
#langdef en-US "English"
#langdef fr-FR "Français"
#langdef en "Standard English"
#langdef fr "Standard Français"
#string STR_FRONT_PAGE_TITLE #language en-US "Front Page"
#language fr-FR "Front Page"
#string STR_FRONT_PAGE_COMPUTER_MODEL #language en-US ""
#language fr-FR ""
#string STR_FRONT_PAGE_CPU_MODEL #language en-US ""
#language fr-FR ""
#string STR_FRONT_PAGE_CPU_SPEED #language en-US ""
#language fr-FR ""
#string STR_FRONT_PAGE_MEMORY_SIZE #language en-US ""
#language fr-FR ""
#string STR_FRONT_PAGE_BIOS_VERSION #language en-US ""
#language fr-FR ""
#string STR_FRONT_PAGE_BANNER_0_LEFT #language en-US "Wonder Computer Model 1000Z Manufactured by Intel®"
#language fr-FR "Demander le Modèle d'Ordinateur 1000Z A Fabriqué par Intel®"
#string STR_FRONT_PAGE_BANNER_0_RIGHT #language en-US "OK"
#language fr-FR "Bon"
#string STR_FRONT_PAGE_BANNER_1_LEFT #language en-US "2 Pentium® X Xeon processors running at 800Thz"
#language fr-FR "2 processeurs Pentium® X Xeon tournants à 800Thz"
#string STR_FRONT_PAGE_BANNER_1_RIGHT #language en-US "24 TB System RAM"
#language fr-FR "24 TB RAM de Système"
#string STR_FRONT_PAGE_BANNER_2_LEFT #language en-US "ACME® EFI BIOS Version 13.5 Release 1039.92"
#language fr-FR "ACME® EFI BIOS Version 13.5 Release 1039.92"
#string STR_FRONT_PAGE_BANNER_3_LEFT #language en-US "Serial Number: 1Z123456789MARMAR (Need SMBIOS entries)"
#language fr-FR "Numéro de série: 1Z123456789MARMAR (Les entrées de SMBIOS de besoin)"
#string STR_CONTINUE_PROMPT #language en-US "Continue"
#language fr-FR "Continuer"
#string STR_CONTINUE_HELP #language en-US "This selection will direct the system to continue to booting process"
#language fr-FR "Cette sélection dirigera le système pour continuer au processus d'amorçage"
#string STR_LANGUAGE_SELECT #language en-US "Select Language"
#language fr-FR "Choisir la Langue"
#string STR_LANGUAGE_SELECT_HELP #language en-US "This is the option one adjusts to change the language for the current system"
#language fr-FR "Ceci est l'option qu'on ajuste pour changer la langue pour le système actuel"
#string STR_FRONT_PAGE_COMPUTER_MODEL #language en-US "<model>"
#string STR_FRONT_PAGE_BIOS_VERSION #language en-US "<bios>"
#string STR_FIRMWARE_INFO #language en-US "Firmware Configuration Information"
#string STR_BOOT_DEFAULT_PROMPT #language en-US "Boot Default"
#string STR_BOOT_DEFAULT_HELP #language en-US "Boot the default entry"
#string STR_MISSING_STRING #language en-US "Missing String"
#language fr-FR "Missing String"
#string STR_NO_BOOTABLE_MEDIA #language en-US ""
#string STR_WEBCAM_STATUS #language en-US ""
#string STR_EMPTY_STRING #language en-US ""
#language fr-FR ""
#string STR_RESET_STRING #language en-US "Reset"
#language fr-FR "Reset"
#string STR_RESET_STRING_HELP #language en-US "Reset the current setting."
#language fr-FR "Reset the current setting."
#string STR_CUSTOMIZE_BANNER_LINE4_LEFT #language en-US ""
#language fr-FR ""
#string STR_CUSTOMIZE_BANNER_LINE4_RIGHT #language en-US ""
#language fr-FR ""
#string STR_CUSTOMIZE_BANNER_LINE5_LEFT #language en-US ""
#language fr-FR ""
#string STR_CUSTOMIZE_BANNER_LINE5_RIGHT #language en-US ""
#language fr-FR ""
#string STR_TEST_KEY_USED #language en-US "WARNING: Test key detected."
#language fr-FR "WARNING: Test key detected."
#string STR_NULL_STRING #language en-US " "
#language fr-FR " "
#string STR_VIRTUALIZATION #language en-US ""
#string STR_VIRTUALIZATION_STATUS #language en-US ""
#string STR_IOMMU_STATUS #language en-US ""
#string STR_TPM_STATUS #language en-US ""
#string STR_ME_STATUS #language en-US ""

View File

@ -9,64 +9,24 @@
#define FORMSET_GUID { 0x9e0c30bc, 0x3f06, 0x4ba6, 0x82, 0x88, 0x9, 0x17, 0x9b, 0x85, 0x5d, 0xbe }
#define FRONT_PAGE_FORM_ID 0x1000
#define FRONT_PAGE_FORM_ID 0x7600
#define FIRMWARE_INFO_FORM_ID 0x7601
#define LABEL_FRONTPAGE_INFORMATION 0x1000
#define LABEL_END 0xffff
formset
guid = FORMSET_GUID,
title = STRING_TOKEN(STR_FRONT_PAGE_TITLE),
help = STRING_TOKEN(STR_EMPTY_STRING ),
guid = FORMSET_GUID,
title = STRING_TOKEN(STR_FRONT_PAGE_TITLE),
help = STRING_TOKEN(STR_EMPTY_STRING),
classguid = FORMSET_GUID,
form formid = FRONT_PAGE_FORM_ID,
title = STRING_TOKEN(STR_FRONT_PAGE_TITLE);
title = STRING_TOKEN(STR_FRONT_PAGE_TITLE);
banner
title = STRING_TOKEN(STR_FRONT_PAGE_COMPUTER_MODEL),
line 1,
align left;
banner
title = STRING_TOKEN(STR_FRONT_PAGE_CPU_MODEL),
line 2,
align left;
banner
title = STRING_TOKEN(STR_FRONT_PAGE_CPU_SPEED),
line 2,
align right;
banner
title = STRING_TOKEN(STR_FRONT_PAGE_BIOS_VERSION),
line 3,
align left;
banner
title = STRING_TOKEN(STR_FRONT_PAGE_MEMORY_SIZE),
line 3,
align right;
banner
title = STRING_TOKEN(STR_CUSTOMIZE_BANNER_LINE4_LEFT),
line 4,
align left;
banner
title = STRING_TOKEN(STR_CUSTOMIZE_BANNER_LINE4_RIGHT),
line 4,
align right;
banner
title = STRING_TOKEN(STR_CUSTOMIZE_BANNER_LINE5_LEFT),
line 5,
align left;
banner
title = STRING_TOKEN(STR_CUSTOMIZE_BANNER_LINE5_RIGHT),
line 5,
align right;
subtitle text = STRING_TOKEN(STR_FRONT_PAGE_COMPUTER_MODEL);
subtitle text = STRING_TOKEN(STR_FRONT_PAGE_BIOS_VERSION);
subtitle text = STRING_TOKEN(STR_EMPTY_STRING);
label LABEL_FRONTPAGE_INFORMATION;
//
@ -75,6 +35,27 @@ formset
//
label LABEL_END;
subtitle text = STRING_TOKEN(STR_EMPTY_STRING);
goto FIRMWARE_INFO_FORM_ID,
prompt = STRING_TOKEN(STR_FIRMWARE_INFO),
help = STRING_TOKEN(STR_EMPTY_STRING);
subtitle text = STRING_TOKEN(STR_EMPTY_STRING);
subtitle text = STRING_TOKEN(STR_NO_BOOTABLE_MEDIA);
subtitle text = STRING_TOKEN(STR_WEBCAM_STATUS);
endform;
form formid = FIRMWARE_INFO_FORM_ID,
title = STRING_TOKEN(STR_FIRMWARE_INFO);
subtitle text = STRING_TOKEN(STR_VIRTUALIZATION);
subtitle text = STRING_TOKEN(STR_VIRTUALIZATION_STATUS);
subtitle text = STRING_TOKEN(STR_IOMMU_STATUS);
subtitle text = STRING_TOKEN(STR_EMPTY_STRING);
subtitle text = STRING_TOKEN(STR_TPM_STATUS);
subtitle text = STRING_TOKEN(STR_EMPTY_STRING);
subtitle text = STRING_TOKEN(STR_ME_STATUS);
endform;
endformset;

View File

@ -56,8 +56,10 @@
UefiBootManagerLib
[Guids]
gEfiAcpiTableGuid ## CONSUMES ## GUID
gEfiIfrTianoGuid ## CONSUMES ## GUID (Extended IFR Guid Opcode)
gEfiIfrFrontPageGuid ## CONSUMES ## GUID
gEfiSmbiosTableGuid ## CONSUMES ## GUID
[Protocols]
gEfiSmbiosProtocolGuid ## CONSUMES

View File

@ -1733,11 +1733,7 @@ InitKeyboard (
//
mWaitForValueTimeOut = KEYBOARD_BAT_TIMEOUT;
Status = KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_BAT_SUCCESS);
if (EFI_ERROR (Status)) {
KeyboardError (ConsoleIn, L"Keyboard self test failed!\n\r");
goto Done;
}
KeyboardWaitForValue (ConsoleIn, KEYBOARD_8048_RETURN_8042_BAT_SUCCESS);
mWaitForValueTimeOut = KEYBOARD_WAITFORVALUE_TIMEOUT;

View File

@ -157,7 +157,7 @@ InstallPs2KeyboardDriver (
#define KEYBOARD_MAX_TRY 256 // 256
#define KEYBOARD_TIMEOUT 65536 // 0.07s
#define KEYBOARD_WAITFORVALUE_TIMEOUT 1000000 // 1s
#define KEYBOARD_BAT_TIMEOUT 4000000 // 4s
#define KEYBOARD_BAT_TIMEOUT 1000000 // 1s
#define KEYBOARD_TIMER_INTERVAL 200000 // 0.02s
#define SCANCODE_EXTENDED0 0xE0
#define SCANCODE_EXTENDED1 0xE1

View File

@ -67,6 +67,10 @@ CoreRemoveInterfaceFromProtocol (
for (Link = ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link = Link->ForwardLink) {
ProtNotify = CR (Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
// Signal notify events before removing the protocol too.
// XXX: What effect does this have on other code?
CoreSignalEvent (ProtNotify->Event);
if (ProtNotify->Position == &Prot->ByProtocol) {
ProtNotify->Position = Prot->ByProtocol.BackLink;
}

View File

@ -0,0 +1,111 @@
/** @file
This file defines the GUID and data structure used to pass information about
a variable store mapped on flash (i.e. a MMIO firmware volume) to the modules
that consume that information such as the DXE and MM UEFI variable drivers.
The HOB described in this file is currently optional. It is primarily provided
to allow a platform to dynamically describe the flash information to environments
such as Standalone MM that cannot access the prior method using dynamic PCDs.
Even for platforms that use Standalone MM, if the information is only stored
statically such as with FixedAtBuild PCDs, the HOB is not required.
Every point of consumption in this package that uses the PCDs will first check
for the HOB and use its value if present.
Early modules such as the PEI UEFI variable driver might also consume this
information. For modules such as these, that execute early in the boot flow,
at least two approaches are possible depending on platform design.
1. If the information in the HOB exactly matches the information in the PCDs,
(i.e. the HOB values are set using the PCD values), let the driver read
the information from the PCD and produce the HOB later in boot.
2. Produce the HOB very early in boot. For example, the earliest point the HOB
is currently consumed is in FaultTolerantWritePei. Note that FaultTolerantWritePei
produces gEdkiiFaultTolerantWriteGuid which is a dependency for VariablePei.
Therefore, attaching a NULL class library to FaultTolerantWritePei with a
constructor that produces the HOB will guarantee it is produced before the first
point of consumption as the constructor is executed before the module entry point.
Copyright (c) Microsoft Corporation.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef VARIABLE_FLASH_INFO_H_
#define VARIABLE_FLASH_INFO_H_
#define VARIABLE_FLASH_INFO_HOB_GUID \
{ 0x5d11c653, 0x8154, 0x4ac3, { 0xa8, 0xc2, 0xfb, 0xa2, 0x89, 0x20, 0xfc, 0x90 }}
#define VARIABLE_FLASH_INFO_HOB_VERSION 1
extern EFI_GUID gVariableFlashInfoHobGuid;
#pragma pack (push, 1)
///
/// This structure can be used to describe UEFI variable
/// flash information.
///
typedef struct {
///
/// Version of this structure.
///
/// Increment the value when the structure is modified.
///
UINT32 Version;
///
/// Reserved field.
///
/// Currently reserved for natural alignment.
///
UINT32 Reserved;
///
/// Base address of the non-volatile variable range in the flash device.
///
/// Note that this address should align with the block size requirements of the flash device.
///
EFI_PHYSICAL_ADDRESS NvVariableBaseAddress;
///
/// Size of the non-volatile variable range in the flash device.
///
/// Note that this value should be less than or equal to FtwSpareLength to support reclaim of
/// entire variable store area.
/// Note that this address should align with the block size requirements of the flash device.
///
UINT64 NvVariableLength;
///
/// Base address of the FTW spare block range in the flash device.
///
/// Note that this address should align with the block size requirements of the flash device.
///
EFI_PHYSICAL_ADDRESS FtwSpareBaseAddress;
///
/// Size of the FTW spare block range in the flash device.
///
/// Note that this value should be greater than or equal to NvVariableLength.
/// Note that this address should align with the block size requirements of the flash device.
///
UINT64 FtwSpareLength;
///
/// Base address of the FTW working block range in the flash device.
///
/// Note that if FtwWorkingLength is larger than on block size, this value should be block size aligned.
///
EFI_PHYSICAL_ADDRESS FtwWorkingBaseAddress;
///
/// Size of the FTW working block range in the flash device.
///
/// Note that if the value is less than on block size, the range should not span blocks.
/// Note that if the value is larger than one block size, this value should be block size aligned.
///
UINT64 FtwWorkingLength;
} VARIABLE_FLASH_INFO;
#pragma pack (pop)
#endif

View File

@ -60,4 +60,14 @@ BootLogoUpdateProgress (
IN UINTN PreviousValue
);
/**
Install Boot Logo into BGRT table
**/
VOID
AddBGRT (
VOID
);
#endif

View File

@ -0,0 +1,68 @@
/** @file
Variable Flash Information Library
Copyright (c) Microsoft Corporation<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef VARIABLE_FLASH_INFO_LIB_H_
#define VARIABLE_FLASH_INFO_LIB_H_
/**
Get the base address and size for the NV storage area used for UEFI variable storage.
@param[out] BaseAddress The NV storage base address.
@param[out] Length The NV storage length in bytes.
@retval EFI_SUCCESS NV storage information was found successfully.
@retval EFI_INVALID_PARAMETER A required pointer parameter is NULL.
@retval EFI_NOT_FOUND NV storage information could not be found.
**/
EFI_STATUS
EFIAPI
GetVariableFlashNvStorageInfo (
OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
OUT UINT64 *Length
);
/**
Get the base address and size for the fault tolerant write (FTW) spare
area used for UEFI variable storage.
@param[out] BaseAddress The FTW spare base address.
@param[out] Length The FTW spare length in bytes.
@retval EFI_SUCCESS FTW spare information was found successfully.
@retval EFI_INVALID_PARAMETER A required pointer parameter is NULL.
@retval EFI_NOT_FOUND FTW spare information could not be found.
**/
EFI_STATUS
EFIAPI
GetVariableFlashFtwSpareInfo (
OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
OUT UINT64 *Length
);
/**
Get the base address and size for the fault tolerant write (FTW) working
area used for UEFI variable storage.
@param[out] BaseAddress The FTW working area base address.
@param[out] Length The FTW working area length in bytes.
@retval EFI_SUCCESS FTW working information was found successfully.
@retval EFI_INVALID_PARAMETER A required pointer parameter is NULL.
@retval EFI_NOT_FOUND FTW working information could not be found.
**/
EFI_STATUS
EFIAPI
GetVariableFlashFtwWorkingInfo (
OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
OUT UINT64 *Length
);
#endif

View File

@ -216,7 +216,7 @@ TranslateBmpToGopBlt (
if ((BmpHeader->Size != BmpImageSize) ||
(BmpHeader->Size < BmpHeader->ImageOffset) ||
(BmpHeader->Size - BmpHeader->ImageOffset != DataSize))
(BmpHeader->Size - BmpHeader->ImageOffset < DataSize))
{
DEBUG ((DEBUG_ERROR, "TranslateBmpToGopBlt: invalid BmpImage... \n"));
DEBUG ((DEBUG_ERROR, " BmpHeader->Size: 0x%x\n", BmpHeader->Size));

View File

@ -0,0 +1,179 @@
/** @file
Variable Flash Information Library
Copyright (c) Microsoft Corporation<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Uefi.h>
#include <Pi/PiMultiPhase.h>
#include <Guid/VariableFlashInfo.h>
#include <Library/DebugLib.h>
#include <Library/HobLib.h>
#include <Library/VariableFlashInfoLib.h>
/**
Get the HOB that contains variable flash information.
@param[out] VariableFlashInfo Pointer to a pointer to set to the variable flash information structure.
@retval EFI_SUCCESS Variable flash information was found successfully.
@retval EFI_INVALID_PARAMETER The VariableFlashInfo pointer given is NULL.
@retval EFI_NOT_FOUND Variable flash information could not be found.
**/
STATIC
EFI_STATUS
GetVariableFlashInfoFromHob (
OUT VARIABLE_FLASH_INFO **VariableFlashInfo
)
{
EFI_HOB_GUID_TYPE *GuidHob;
if (VariableFlashInfo == NULL) {
return EFI_INVALID_PARAMETER;
}
GuidHob = GetFirstGuidHob (&gVariableFlashInfoHobGuid);
if (GuidHob == NULL) {
return EFI_NOT_FOUND;
}
*VariableFlashInfo = GET_GUID_HOB_DATA (GuidHob);
//
// Assert if more than one variable flash information HOB is present.
//
DEBUG_CODE (
if ((GetNextGuidHob (&gVariableFlashInfoHobGuid, GET_NEXT_HOB (GuidHob)) != NULL)) {
DEBUG ((DEBUG_ERROR, "ERROR: Found two variable flash information HOBs\n"));
ASSERT (FALSE);
}
);
return EFI_SUCCESS;
}
/**
Get the base address and size for the NV storage area used for UEFI variable storage.
@param[out] BaseAddress The NV storage base address.
@param[out] Length The NV storage length in bytes.
@retval EFI_SUCCESS NV storage information was found successfully.
@retval EFI_INVALID_PARAMETER A required pointer parameter is NULL.
**/
EFI_STATUS
EFIAPI
GetVariableFlashNvStorageInfo (
OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
OUT UINT64 *Length
)
{
EFI_STATUS Status;
VARIABLE_FLASH_INFO *VariableFlashInfo;
if ((BaseAddress == NULL) || (Length == NULL)) {
return EFI_INVALID_PARAMETER;
}
Status = GetVariableFlashInfoFromHob (&VariableFlashInfo);
if (!EFI_ERROR (Status)) {
*BaseAddress = VariableFlashInfo->NvVariableBaseAddress;
*Length = VariableFlashInfo->NvVariableLength;
} else {
*BaseAddress = (EFI_PHYSICAL_ADDRESS)(PcdGet64 (PcdFlashNvStorageVariableBase64) != 0 ?
PcdGet64 (PcdFlashNvStorageVariableBase64) :
PcdGet32 (PcdFlashNvStorageVariableBase)
);
*Length = (UINT64)PcdGet32 (PcdFlashNvStorageVariableSize);
}
return EFI_SUCCESS;
}
/**
Get the base address and size for the fault tolerant write (FTW) spare
area used for UEFI variable storage.
@param[out] BaseAddress The FTW spare base address.
@param[out] Length The FTW spare length in bytes.
@retval EFI_SUCCESS FTW spare information was found successfully.
@retval EFI_INVALID_PARAMETER A required pointer parameter is NULL.
@retval EFI_NOT_FOUND FTW spare information could not be found.
**/
EFI_STATUS
EFIAPI
GetVariableFlashFtwSpareInfo (
OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
OUT UINT64 *Length
)
{
EFI_STATUS Status;
VARIABLE_FLASH_INFO *VariableFlashInfo;
if ((BaseAddress == NULL) || (Length == NULL)) {
return EFI_INVALID_PARAMETER;
}
Status = GetVariableFlashInfoFromHob (&VariableFlashInfo);
if (!EFI_ERROR (Status)) {
*BaseAddress = VariableFlashInfo->FtwSpareBaseAddress;
*Length = VariableFlashInfo->FtwSpareLength;
} else {
*BaseAddress = (EFI_PHYSICAL_ADDRESS)(PcdGet64 (PcdFlashNvStorageFtwSpareBase64) != 0 ?
PcdGet64 (PcdFlashNvStorageFtwSpareBase64) :
PcdGet32 (PcdFlashNvStorageFtwSpareBase)
);
*Length = (UINT64)PcdGet32 (PcdFlashNvStorageFtwSpareSize);
}
return EFI_SUCCESS;
}
/**
Get the base address and size for the fault tolerant write (FTW) working
area used for UEFI variable storage.
@param[out] BaseAddress The FTW working area base address.
@param[out] Length The FTW working area length in bytes.
@retval EFI_SUCCESS FTW working information was found successfully.
@retval EFI_INVALID_PARAMETER A required pointer parameter is NULL.
@retval EFI_NOT_FOUND FTW working information could not be found.
**/
EFI_STATUS
EFIAPI
GetVariableFlashFtwWorkingInfo (
OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
OUT UINT64 *Length
)
{
EFI_STATUS Status;
VARIABLE_FLASH_INFO *VariableFlashInfo;
if ((BaseAddress == NULL) || (Length == NULL)) {
return EFI_INVALID_PARAMETER;
}
Status = GetVariableFlashInfoFromHob (&VariableFlashInfo);
if (!EFI_ERROR (Status)) {
*BaseAddress = VariableFlashInfo->FtwWorkingBaseAddress;
*Length = VariableFlashInfo->FtwWorkingLength;
} else {
*BaseAddress = (EFI_PHYSICAL_ADDRESS)(PcdGet64 (PcdFlashNvStorageFtwWorkingBase64) != 0 ?
PcdGet64 (PcdFlashNvStorageFtwWorkingBase64) :
PcdGet32 (PcdFlashNvStorageFtwWorkingBase)
);
*Length = (UINT64)PcdGet32 (PcdFlashNvStorageFtwWorkingSize);
}
return EFI_SUCCESS;
}

View File

@ -0,0 +1,48 @@
## @file
# Variable Flash Information Library
#
# Provides services to access UEFI variable flash information.
#
# Copyright (c) Microsoft Corporation<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BaseVariableFlashInfoLib
MODULE_UNI_FILE = BaseVariableFlashInfoLib.uni
FILE_GUID = DEC426C9-C92E-4BAD-8E93-3F61C261118B
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = VariableFlashInfoLib
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = ANY
#
[Sources]
BaseVariableFlashInfoLib.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
[LibraryClasses]
DebugLib
HobLib
[Guids]
gVariableFlashInfoHobGuid ## CONSUMES ## HOB
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64 ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize ## SOMETIMES_CONSUMES

View File

@ -0,0 +1,12 @@
// /** @file
// Variable Flash Information Library
//
// Copyright (c) Microsoft Corporation<BR>
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
// **/
#string STR_MODULE_ABSTRACT #language en-US "UEFI variable flash information library"
#string STR_MODULE_DESCRIPTION #language en-US "Provides services to access UEFI variable flash information."

View File

@ -0,0 +1,283 @@
#include <IndustryStandard/Acpi.h>
#include <IndustryStandard/Bmp.h>
#include <Library/BaseLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/BootLogoLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Protocol/FirmwareVolume2.h>
#include <Protocol/SimpleFileSystem.h>
/** RSDP (Root System Description Pointer) */
typedef struct {
CHAR8 signature[8];
UINT8 checksum;
CHAR8 oem_id[6];
UINT8 revision;
UINT32 rsdt_address;
UINT32 length;
UINT64 xsdt_address;
UINT8 extended_checksum;
UINT8 reserved[3];
} ACPI_20_RSDP;
/** SDT (System Description Table) entry header */
typedef struct {
CHAR8 signature[4];
UINT32 length;
UINT8 revision;
UINT8 checksum;
CHAR8 oem_id[6];
CHAR8 oem_table_id[8];
UINT32 oem_revision;
UINT32 asl_compiler_id;
UINT32 asl_compiler_revision;
} ACPI_SDT_HEADER;
/** BGRT structure */
typedef struct {
ACPI_SDT_HEADER header;
UINT16 version;
UINT8 status;
UINT8 image_type;
UINT64 image_address;
UINT32 image_offset_x;
UINT32 image_offset_y;
} ACPI_BGRT;
EFI_STATUS
EFIAPI
LoadBmp(
OUT EFI_PHYSICAL_ADDRESS *BmpAddress,
OUT UINT32 *BmpSize
)
{
EFI_STATUS Status;
UINTN FvProtocolCount;
EFI_HANDLE *FvHandles;
EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
UINTN Index;
UINT32 AuthenticationStatus;
UINT8 *Buffer;
UINTN BmpBufferSize;
Buffer = 0;
FvHandles = NULL;
Status = gBS->LocateHandleBuffer (
ByProtocol,
&gEfiFirmwareVolume2ProtocolGuid,
NULL,
&FvProtocolCount,
&FvHandles
);
if (!EFI_ERROR (Status)) {
for (Index = 0; Index < FvProtocolCount; Index++) {
Status = gBS->HandleProtocol (
FvHandles[Index],
&gEfiFirmwareVolume2ProtocolGuid,
(VOID **) &Fv
);
BmpBufferSize = 0;
Status = Fv->ReadSection (
Fv,
(EFI_GUID *)PcdGetPtr(PcdLogoFile),
EFI_SECTION_RAW,
0,
(void **)&Buffer,
&BmpBufferSize,
&AuthenticationStatus
);
if (!EFI_ERROR (Status)) {
*BmpAddress = (EFI_PHYSICAL_ADDRESS)(UINTN)Buffer;
*BmpSize = (UINT32)BmpBufferSize;
Status = EFI_SUCCESS;
break;
}
}
} else {
Status = EFI_NOT_FOUND;
}
if (FvHandles != NULL) {
gBS->FreePool (FvHandles);
FvHandles = NULL;
}
return Status;
}
UINT8 SumBytes(const UINT8* arr, UINTN size) {
UINT8 sum = 0;
UINTN i;
for (i = 0; i < size; ++i) {
sum += arr[i];
}
return sum;
}
int VerifyAcpiRsdp2Checksums(const void* data) {
const UINT8* arr = data;
UINTN size = *(const UINT32*)&arr[20];
return SumBytes(arr, 20) == 0 && SumBytes(arr, size) == 0;
}
void SetAcpiRsdp2Checksums(void* data) {
UINT8* arr = data;
UINTN size = *(const UINT32*)&arr[20];
arr[9] = 0;
arr[32] = 0;
arr[9] = -SumBytes(arr, 20);
arr[32] = -SumBytes(arr, size);
}
int VerifyAcpiSdtChecksum(const void* data) {
const UINT8* arr = data;
UINTN size = *(const UINT32*)&arr[4];
return SumBytes(arr, size) == 0;
}
void SetAcpiSdtChecksum(void* data) {
UINT8* arr = data;
UINTN size = *(const UINT32*)&arr[4];
arr[9] = 0;
arr[9] = -SumBytes(arr, size);
}
const CHAR16* TmpStr(CHAR8 *src, int length) {
static CHAR16 arr[4][16];
static int j;
CHAR16* dest = arr[j = (j+1) % 4];
int i;
for (i = 0; i < length && i < 16-1 && src[i]; ++i) {
dest[i] = src[i];
}
dest[i] = 0;
return dest;
}
static UINT32 min(UINT32 first, UINT32 second){
if (first < second)
return first;
return second;
}
ACPI_SDT_HEADER* CreateXsdt(ACPI_SDT_HEADER* xsdt0, UINTN entries) {
ACPI_SDT_HEADER* xsdt = 0;
UINT32 xsdt_len = (UINT32)(sizeof(ACPI_SDT_HEADER) + entries * sizeof(UINT64));
gBS->AllocatePool(EfiACPIReclaimMemory, xsdt_len, (void**)&xsdt);
if (!xsdt) {
DEBUG ((EFI_D_INFO, "HackBGRT: Failed to allocate memory for XSDT.\n"));
return 0;
}
ZeroMem(xsdt, xsdt_len);
CopyMem(xsdt, xsdt0, min(xsdt0->length, xsdt_len));
xsdt->length = xsdt_len;
SetAcpiSdtChecksum(xsdt);
return xsdt;
}
static ACPI_BGRT* HandleAcpiTables(ACPI_BGRT* bgrt) {
int i;
for (i = 0; i < gST->NumberOfTableEntries; i++) {
EFI_GUID* vendor_guid = &gST->ConfigurationTable[i].VendorGuid;
ACPI_20_RSDP *rsdp;
ACPI_SDT_HEADER *xsdt;
UINT64 *entry_arr;
UINT32 entry_arr_length;
if (!CompareGuid(vendor_guid, &gEfiAcpiTableGuid) && !CompareGuid(vendor_guid, &gEfiAcpi20TableGuid)) {
continue;
}
rsdp = (ACPI_20_RSDP *) gST->ConfigurationTable[i].VendorTable;
if (CompareMem(rsdp->signature, "RSD PTR ", 8) != 0 || rsdp->revision < 2 || !VerifyAcpiRsdp2Checksums(rsdp)) {
continue;
}
DEBUG ((EFI_D_INFO, "RSDP: revision = %d, OEM ID = %s\n", rsdp->revision, TmpStr(rsdp->oem_id, 6)));
xsdt = (ACPI_SDT_HEADER *) (UINTN) rsdp->xsdt_address;
if (!xsdt || CompareMem(xsdt->signature, "XSDT", 4) != 0 || !VerifyAcpiSdtChecksum(xsdt)) {
DEBUG ((EFI_D_INFO, "* XSDT: missing or invalid\n"));
continue;
}
entry_arr = (UINT64*)&xsdt[1];
entry_arr_length = (xsdt->length - sizeof(*xsdt)) / sizeof(UINT64);
DEBUG ((EFI_D_INFO, "* XSDT: OEM ID = %s, entry count = %d\n", TmpStr(xsdt->oem_id, 6), entry_arr_length));
if (bgrt) {
DEBUG ((EFI_D_INFO, " - Adding missing BGRT.\n"));
xsdt = CreateXsdt(xsdt, entry_arr_length + 1);
entry_arr = (UINT64*)&xsdt[1];
entry_arr[entry_arr_length++] = (UINTN) bgrt;
rsdp->xsdt_address = (UINTN) xsdt;
SetAcpiRsdp2Checksums(rsdp);
}
SetAcpiSdtChecksum(xsdt);
}
return bgrt;
}
VOID
AddBGRT (
VOID
)
{
EFI_STATUS Status;
ACPI_BGRT *bgrt;
EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
EFI_PHYSICAL_ADDRESS BmpAddress;
UINT32 BmpSize;
BMP_IMAGE_HEADER *BmpHeader;
const char data[0x38] =
"BGRT" "\x38\x00\x00\x00" "\x00" "\xd6" "INTEL " " EDK2"
"\x20\x17\x00\x00" "PTL " "\x02\x00\x00\x00"
"\x01\x00" "\x00" "\x00";
BmpAddress = 0;
DEBUG ((EFI_D_INFO, "HackBGRT Start\n"));
Status = gBS->HandleProtocol (
gST->ConsoleOutHandle,
&gEfiGraphicsOutputProtocolGuid,
(VOID**)&GraphicsOutput
);
// Replace missing = allocate new.
gBS->AllocatePool(EfiACPIReclaimMemory, sizeof(*bgrt), (void**)&bgrt);
if (!bgrt) {
DEBUG ((EFI_D_INFO, "HackBGRT MEM ERR\n"));
return;
}
DEBUG ((EFI_D_INFO, "HackBGRT Load Bmp\n"));
Status = LoadBmp(&BmpAddress, &BmpSize);
if (EFI_ERROR(Status)){
DEBUG ((EFI_D_INFO, "HackBGRT BMP Load ERR\n"));
return;
}
DEBUG ((EFI_D_INFO, "HackBGRT Set Table; BMP Size: %d\n", BmpSize));
// Clear the BGRT.
CopyMem(bgrt, data, sizeof(data));
if (GraphicsOutput != NULL && GraphicsOutput->Mode != NULL && GraphicsOutput->Mode->Info != NULL)
{
BmpHeader = (BMP_IMAGE_HEADER *)BmpAddress;
bgrt->image_address = (UINTN)BmpAddress;
bgrt->image_offset_x = (GraphicsOutput->Mode->Info->HorizontalResolution - BmpHeader->PixelWidth) / 2;
bgrt->image_offset_y = ((GraphicsOutput->Mode->Info->VerticalResolution * 382) / 1000) -
(BmpHeader->PixelHeight / 2);
DEBUG ((EFI_D_INFO, "HackBGRT Set checksum\n"));
SetAcpiSdtChecksum(bgrt);
DEBUG ((EFI_D_INFO, "HackBGRT Add Table\n"));
HandleAcpiTables(bgrt);
} else {
DEBUG ((EFI_D_INFO, "HackBGRT no display connected, skip adding table\n"));
}
}

View File

@ -176,7 +176,7 @@ BootLogoEnableLogo (
break;
case EdkiiPlatformLogoDisplayAttributeCenter:
DestX = (SizeOfX - Image.Width) / 2;
DestY = (SizeOfY - Image.Height) / 2;
DestY = (SizeOfY * 382) / 1000 - Image.Height / 2;
break;
case EdkiiPlatformLogoDisplayAttributeCenterRight:
DestX = SizeOfX - Image.Width;

View File

@ -24,6 +24,7 @@
#
[Sources]
Bgrt.c
BootLogoLib.c
[Packages]
@ -48,5 +49,12 @@
gEfiUserManagerProtocolGuid ## CONSUMES
gEdkiiPlatformLogoProtocolGuid ## CONSUMES
[Guids]
gEfiAcpiTableGuid ## CONSUMES ## GUID
gEfiAcpi20TableGuid ## CONSUMES ## GUID
[FeaturePcd]
gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport ## CONSUMES
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdLogoFile ## CONSUMES

View File

@ -733,6 +733,7 @@ BootMaintExtractConfig (
*Progress = Request + StrLen (Request);
}
DEBUG ((EFI_D_INFO, "%a complete: %r\n", __FUNCTION__, Status));
return Status;
}
@ -1059,6 +1060,7 @@ BootMaintRouteConfig (
//
CopyMem (OldBmmData, NewBmmData, sizeof (BMM_FAKE_NV_DATA));
DEBUG ((EFI_D_INFO, "%a complete: %r\n", __FUNCTION__, Status));
return EFI_SUCCESS;
Exit:
@ -1119,6 +1121,8 @@ BootMaintCallback (
Private = BMM_CALLBACK_DATA_FROM_THIS (This);
if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {
DEBUG ((EFI_D_INFO, "EFI_BROWSER_ACTION_FORM_OPEN: 0x%0X\n", QuestionId));
if (QuestionId == KEY_VALUE_TRIGGER_FORM_OPEN_ACTION) {
if (!mFirstEnterBMMForm) {
//
@ -1130,7 +1134,9 @@ BootMaintCallback (
// 1. Update the menus (including legacy munu) show in BootMiantenanceManager page.
// 2. Re-scan the BootOption menus (including the legacy boot option).
//
CustomizeMenus ();
//CustomizeMenus ();
UpdatePageId (Private, FORM_BOOT_CHG_ID);
UpdatePageBody (FORM_BOOT_CHG_ID, Private);
EfiBootManagerRefreshAllBootOption ();
BOpt_GetBootOptions (Private);
mFirstEnterBMMForm = TRUE;
@ -1146,6 +1152,8 @@ BootMaintCallback (
HiiGetBrowserData (&mBootMaintGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *)CurrentFakeNVMap);
if (Action == EFI_BROWSER_ACTION_CHANGING) {
DEBUG ((EFI_D_INFO, "EFI_BROWSER_ACTION_CHANGING: 0x%0X\n", QuestionId));
if (Value == NULL) {
return EFI_INVALID_PARAMETER;
}
@ -1231,6 +1239,8 @@ BootMaintCallback (
ChooseFile (NULL, L".efi", BootFromFile, &File);
}
} else if (Action == EFI_BROWSER_ACTION_CHANGED) {
DEBUG ((EFI_D_INFO, "EFI_BROWSER_ACTION_CHANGED: 0x%0X\n", QuestionId));
if ((Value == NULL) || (ActionRequest == NULL)) {
return EFI_INVALID_PARAMETER;
}
@ -1270,6 +1280,11 @@ BootMaintCallback (
CurrentFakeNVMap->DriverOptionChanged = TRUE;
}
if (QuestionId == BOOT_OPTION_ORDER_QUESTION_ID) {
// Save BootOrder on list update
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_FORM_APPLY;
}
if ((QuestionId >= BOOT_OPTION_DEL_QUESTION_ID) && (QuestionId < BOOT_OPTION_DEL_QUESTION_ID + MAX_MENU_NUMBER)) {
if (Value->b) {
//
@ -1336,6 +1351,7 @@ BootMaintCallback (
//
HiiSetBrowserData (&mBootMaintGuid, mBootMaintStorageName, sizeof (BMM_FAKE_NV_DATA), (UINT8 *)CurrentFakeNVMap, NULL);
DEBUG ((EFI_D_INFO, "%a complete: %r\n", __FUNCTION__, EFI_SUCCESS));
return EFI_SUCCESS;
}
@ -1665,6 +1681,28 @@ BmmInitialBootModeInfo (
mBmmModeInitialized = TRUE;
}
STATIC
EFI_STATUS
UnregisterHotKeys(VOID)
{
EFI_STATUS Status;
EFI_INPUT_KEY HotKey;
EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL *FormBrowserEx2;
Status = gBS->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid, NULL, (VOID **) &FormBrowserEx2);
if (!EFI_ERROR (Status)) {
HotKey.UnicodeChar = CHAR_NULL;
HotKey.ScanCode = SCAN_F9;
FormBrowserEx2->RegisterHotKey(&HotKey, BROWSER_ACTION_UNREGISTER, 0, NULL);
HotKey.ScanCode = SCAN_F10;
FormBrowserEx2->RegisterHotKey(&HotKey, BROWSER_ACTION_UNREGISTER, 0, NULL);
}
return Status;
}
/**
Install Boot Maintenance Manager Menu driver.
@ -1740,8 +1778,8 @@ BootMaintenanceManagerUiLibConstructor (
mBmmCallbackInfo->MenuEntry = (BM_MENU_ENTRY *)Ptr;
mBmmCallbackInfo->BmmPreviousPageId = FORM_MAIN_ID;
mBmmCallbackInfo->BmmCurrentPageId = FORM_MAIN_ID;
mBmmCallbackInfo->BmmPreviousPageId = FORM_BOOT_CHG_ID;
mBmmCallbackInfo->BmmCurrentPageId = FORM_BOOT_CHG_ID;
InitAllMenu (mBmmCallbackInfo);
@ -1753,6 +1791,11 @@ BootMaintenanceManagerUiLibConstructor (
BmmInitialBootModeInfo ();
//
// Remove the F9 and F10 hotkeys
//
UnregisterHotKeys();
return EFI_SUCCESS;
}

View File

@ -19,19 +19,28 @@ formset
name = BmmData,
guid = BOOT_MAINT_FORMSET_GUID;
form formid = FORM_BOOT_CHG_ID,
title = STRING_TOKEN(STR_FORM_BOOT_CHG_TITLE);
//
// Add this invisible text in order to indicate enter Boot Maintenance Manager form.
// To trigger the form open action.
//
suppressif TRUE;
text
help = STRING_TOKEN(STR_NONE),
text = STRING_TOKEN(STR_NONE),
flags = INTERACTIVE,
key = KEY_VALUE_TRIGGER_FORM_OPEN_ACTION;
endif;
label FORM_BOOT_CHG_ID;
label LABEL_END;
endform;
form formid = FORM_MAIN_ID,
title = STRING_TOKEN(STR_FORM_MAIN_TITLE);
//
// Add this invisible text in order to indicate enter Boot Maintenance Manager form.
// To trigger the form open action.
//
suppressif TRUE;
text
help = STRING_TOKEN(STR_NONE),
text = STRING_TOKEN(STR_NONE),
flags = INTERACTIVE,
key = KEY_VALUE_TRIGGER_FORM_OPEN_ACTION;
endif;
label LABEL_FORM_MAIN_START;
//
@ -148,14 +157,6 @@ formset
label LABEL_END;
endform;
form formid = FORM_BOOT_CHG_ID,
title = STRING_TOKEN(STR_FORM_BOOT_CHG_TITLE);
label FORM_BOOT_CHG_ID;
label LABEL_END;
endform;
form formid = FORM_DRV_ADD_ID,
title = STRING_TOKEN(STR_FORM_DRV_ADD_TITLE);

View File

@ -17,11 +17,11 @@
#language fr-FR "NONE"
#string STR_MISSING_STRING #language en-US "Missing String"
#language fr-FR "Missing String"
#string STR_FORM_MAIN_TITLE #language en-US "Boot Maintenance Manager"
#string STR_FORM_MAIN_TITLE #language en-US "Change Boot Order"
#language fr-FR "Boot Maintenance Manager"
#string STR_FORM_BOOT_SETUP_TITLE #language en-US "Boot Options"
#language fr-FR "Boot Options"
#string STR_BOOT_MAINT_MANAGER_HELP #language en-US "This selection will take you to the Boot Maintenance Manager"
#string STR_BOOT_MAINT_MANAGER_HELP #language en-US "Change the order of boot entries"
#language fr-FR "This selection will take you to the Boot Maintenance Manager"
#string STR_FORM_BOOT_SETUP_HELP #language en-US "Modify system boot options"
#language fr-FR "Modify system boot options"
@ -251,7 +251,7 @@
#language fr-FR "Boot system from a file or device"
#string STR_OPTIONAL_DATA #language en-US "Input Optional Data"
#language fr-FR "Input Optional Data"
#string STR_CHANGE_ORDER #language en-US "Change the order"
#string STR_CHANGE_ORDER #language en-US "Change Boot Order"
#language fr-FR "Change the order"
#string STR_BOOT_LEGACY #language en-US "Boot Legacy System"
#language fr-FR "Boot Legacy System"

View File

@ -111,40 +111,6 @@ UpdatePageEnd (
IN BMM_CALLBACK_DATA *CallbackData
)
{
//
// Create the "Apply changes" and "Discard changes" tags.
//
if (CallbackData->BmmAskSaveOrNot) {
HiiCreateSubTitleOpCode (
mStartOpCodeHandle,
STRING_TOKEN (STR_NULL_STRING),
0,
0,
0
);
HiiCreateActionOpCode (
mStartOpCodeHandle,
KEY_VALUE_SAVE_AND_EXIT,
STRING_TOKEN (STR_SAVE_AND_EXIT),
STRING_TOKEN (STR_NULL_STRING),
EFI_IFR_FLAG_CALLBACK,
0
);
}
//
// Ensure user can return to the main page.
//
HiiCreateActionOpCode (
mStartOpCodeHandle,
KEY_VALUE_NO_SAVE_AND_EXIT,
STRING_TOKEN (STR_NO_SAVE_AND_EXIT),
STRING_TOKEN (STR_NULL_STRING),
EFI_IFR_FLAG_CALLBACK,
0
);
HiiUpdateForm (
CallbackData->BmmHiiHandle,
&mBootMaintGuid,
@ -651,7 +617,7 @@ UpdateOrderPage (
VarOffset, // Offset in Buffer Storage
STRING_TOKEN (STR_CHANGE_ORDER), // Question prompt text
STRING_TOKEN (STR_CHANGE_ORDER), // Question help text
0, // Question flag
EFI_IFR_FLAG_CALLBACK, // Question flag
0, // Ordered list flag, e.g. EFI_IFR_UNIQUE_SET
EFI_IFR_TYPE_NUM_SIZE_32, // Data type of Question value
100, // Maximum container
@ -1155,9 +1121,4 @@ UpdatePageId (
} else if ((NewPageId >= TERMINAL_OPTION_OFFSET) && (NewPageId < CONSOLE_OPTION_OFFSET)) {
NewPageId = FORM_CON_COM_SETUP_ID;
}
if ((NewPageId > 0) && (NewPageId < MAXIMUM_FORM_ID)) {
Private->BmmPreviousPageId = Private->BmmCurrentPageId;
Private->BmmCurrentPageId = NewPageId;
}
}

View File

@ -633,6 +633,7 @@ Var_UpdateBootOrder (
BOpt_FreeMenu (&BootOptionMenu);
BOpt_GetBootOptions (CallbackData);
DEBUG ((EFI_D_INFO, "Updated BootOrder: %r\n", Status));
return Status;
}

View File

@ -8,6 +8,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "BootManager.h"
#include <Protocol/BlockIo.h>
UINT16 mKeyInput;
EFI_GUID mBootManagerGuid = BOOT_MANAGER_FORMSET_GUID;
//
@ -27,6 +29,10 @@ UINT32 mBmSetupVerticalResolution = 0;
BOOLEAN mBmModeInitialized = FALSE;
STATIC EFI_EVENT mBmRefreshEvent;
STATIC CONST EFI_GUID mBmRefreshGuid = BOOT_MANAGER_REFRESH_GUID;
STATIC VOID *mBlockIoRegistration; // Unused
CHAR16 *mDeviceTypeStr[] = {
L"Legacy BEV",
L"Legacy Floppy",
@ -493,22 +499,10 @@ UpdateBootManager (
BOOLEAN IsLegacyOption;
BOOLEAN NeedEndOp;
UINTN MaxLen;
UINTN OptionCount = 0;
DeviceType = (UINT16)-1;
//
// for better user experience
// 1. User changes HD configuration (e.g.: unplug HDD), here we have a chance to remove the HDD boot option
// 2. User enables/disables UEFI PXE, here we have a chance to add/remove EFI Network boot option
//
EfiBootManagerRefreshAllBootOption ();
//
// BdsDxe doesn't group the legacy boot options for the same device type
// It's UI's choice.
//
GroupMultipleLegacyBootOption4SameType ();
BootOption = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
HiiHandle = gBootManagerPrivate.HiiHandle;
@ -550,6 +544,8 @@ UpdateBootManager (
continue;
}
OptionCount++;
//
// Group the legacy boot option in the sub title created dynamically
//
@ -605,6 +601,10 @@ UpdateBootManager (
);
}
if (OptionCount == 0) {
HiiCreateSubTitleOpCode (StartOpCodeHandle, STRING_TOKEN (STR_NO_BOOTABLE_MEDIA), 0, 0, 0);
}
if (NeedEndOp) {
HiiCreateEndOpCode (StartOpCodeHandle);
}
@ -797,7 +797,6 @@ BootManagerCallback (
{
EFI_BOOT_MANAGER_LOAD_OPTION *BootOption;
UINTN BootOptionCount;
EFI_INPUT_KEY Key;
if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {
//
@ -842,19 +841,31 @@ BootManagerCallback (
EfiBootManagerBoot (&BootOption[QuestionId - 1]);
BmSetConsoleMode (TRUE);
if (EFI_ERROR (BootOption[QuestionId - 1].Status)) {
gST->ConOut->OutputString (
gST->ConOut,
HiiGetString (gBootManagerPrivate.HiiHandle, STRING_TOKEN (STR_ANY_KEY_CONTINUE), NULL)
);
gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
}
EfiBootManagerFreeLoadOptions (BootOption, BootOptionCount);
return EFI_SUCCESS;
}
STATIC
VOID
EFIAPI
RefreshBootOptions(
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_TPL OldTpl = gBS->RaiseTPL(TPL_CALLBACK);
EfiBootManagerRefreshAllBootOption();
// BdsDxe doesn't group the legacy boot options for the same device type. It's UI's choice.
GroupMultipleLegacyBootOption4SameType();
UpdateBootManager();
gBS->RestoreTPL (OldTpl);
}
/**
Install Boot Manager Menu driver.
@ -903,6 +914,23 @@ BootManagerUiLibConstructor (
BmInitialBootModeInfo ();
Status = gBS->CreateEventEx(
EVT_NOTIFY_SIGNAL,
TPL_CALLBACK,
RefreshBootOptions,
NULL,
&mBmRefreshGuid,
&mBmRefreshEvent
);
ASSERT_EFI_ERROR(Status);
Status = gBS->RegisterProtocolNotify (
&gEfiBlockIoProtocolGuid,
mBmRefreshEvent,
&mBlockIoRegistration
);
ASSERT_EFI_ERROR (Status);
return EFI_SUCCESS;
}
@ -923,6 +951,8 @@ BootManagerUiLibDestructor (
{
EFI_STATUS Status;
gBS->CloseEvent(mBmRefreshEvent);
Status = gBS->UninstallMultipleProtocolInterfaces (
gBootManagerPrivate.DriverHandle,
&gEfiDevicePathProtocolGuid,

View File

@ -46,7 +46,12 @@ typedef struct {
0x847bc3fe, 0xb974, 0x446d, {0x94, 0x49, 0x5a, 0xd5, 0x41, 0x2e, 0x99, 0x3b} \
}
#define BOOT_MANAGER_FORM_ID 0x1000
#define BOOT_MANAGER_REFRESH_GUID \
{ \
0x7648C827, 0xBE32, 0x44D2, { 0xA1, 0x33, 0xF1, 0x7F, 0x93, 0x76, 0xC7, 0x00 } \
}
#define BOOT_MANAGER_FORM_ID 0x1030
#define LABEL_BOOT_OPTION 0x00
#define LABEL_BOOT_OPTION_END 0x01

View File

@ -17,20 +17,9 @@
/=#
#langdef en-US "English"
#langdef fr-FR "Français"
#string STR_BM_BANNER #language en-US "Boot Manager"
#language fr-FR "Boot Manager"
#string STR_BOOT_MANAGER_HELP #language en-US "This selection will take you to the Boot Manager"
#language fr-FR "This selection will take you to the Boot Manager"
#string STR_HELP_FOOTER #language en-US "Use the <↑> and <↓> keys to choose a boot option, the <Enter> key to select a boot option, and the <Esc> key to exit the Boot Manager Menu."
#language fr-FR "<↑> pour <↓> changer l'option, <ENTRER> choisir une option, <ESC> pour sortir"
#string STR_AND #language en-US " and "
#language fr-FR " et "
#string STR_BOOT_OPTION_BANNER #language en-US "Boot Manager Menu"
#language fr-FR "le Menu d'Option de Botte"
#string STR_BM_BANNER #language en-US "One Time Boot"
#string STR_BOOT_MANAGER_HELP #language en-US "Boot an entry one time"
#string STR_ANY_KEY_CONTINUE #language en-US "Press any key to continue..."
#language fr-FR "Appuie n'importe quelle pour continuer..."
#string STR_LAST_STRING #language en-US ""
#language fr-FR ""
#string STR_NO_BOOTABLE_MEDIA #language en-US "No bootable media found"
#string STR_EMPTY_STRING #language en-US ""

View File

@ -51,6 +51,7 @@
gEfiHiiConfigAccessProtocolGuid ## CONSUMES
gEfiDevicePathToTextProtocolGuid ## CONSUMES
gEdkiiFormBrowserEx2ProtocolGuid ## CONSUMES
gEfiBlockIoProtocolGuid
[FeaturePcd]

View File

@ -7,8 +7,9 @@
//
//**/
#define FORMSET_GUID { 0x847bc3fe, 0xb974, 0x446d, 0x94, 0x49, 0x5a, 0xd5, 0x41, 0x2e, 0x99, 0x3b }
#define BOOT_MANAGER_REFRESH_GUID { 0x7648C827, 0xBE32, 0x44D2, { 0xA1, 0x33, 0xF1, 0x7F, 0x93, 0x76, 0xC7, 0x00 }}
#define BOOT_MANAGER_FORM_ID 0x1000
#define BOOT_MANAGER_FORM_ID 0x1030
#define LABEL_BOOT_OPTION 0x00
#define LABEL_BOOT_OPTION_END 0x01
@ -20,22 +21,19 @@ formset
classguid = gEfiIfrFrontPageGuid,
form formid = BOOT_MANAGER_FORM_ID,
title = STRING_TOKEN(STR_BM_BANNER);
subtitle text = STRING_TOKEN(STR_LAST_STRING);
subtitle text = STRING_TOKEN(STR_BOOT_OPTION_BANNER);
subtitle text = STRING_TOKEN(STR_LAST_STRING);
title = STRING_TOKEN(STR_BM_BANNER);
refreshguid = BOOT_MANAGER_REFRESH_GUID;
//
//Add this invisable text in order to indicate enter Boot Manager form.
//
suppressif TRUE;
text
help = STRING_TOKEN(STR_LAST_STRING ),
text = STRING_TOKEN(STR_LAST_STRING ),
flags = INTERACTIVE,
key = 0x1212;
endif;
text
help = STRING_TOKEN(STR_EMPTY_STRING),
text = STRING_TOKEN(STR_EMPTY_STRING),
flags = INTERACTIVE,
key = 0x1212;
endif;
//
// This is where we will dynamically add choices for the Boot Manager
@ -43,9 +41,6 @@ formset
label LABEL_BOOT_OPTION;
label LABEL_BOOT_OPTION_END;
subtitle text = STRING_TOKEN(STR_LAST_STRING);
subtitle text = STRING_TOKEN(STR_HELP_FOOTER);
endform;
endformset;

View File

@ -1831,6 +1831,8 @@ EfiBootManagerBoot (
UINTN FileSize;
EFI_BOOT_LOGO_PROTOCOL *BootLogo;
EFI_EVENT LegacyBootEvent;
EFI_INPUT_KEY Key;
UINTN Index;
if (BootOption == NULL) {
return;
@ -1971,6 +1973,23 @@ EfiBootManagerBoot (
//
BmReportLoadFailure (EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR, Status);
BootOption->Status = Status;
if (gST->ConOut != NULL) {
gST->ConOut->ClearScreen (gST->ConOut);
AsciiPrint (
"Booting from '%s' failed; verify it contains a 64-bit UEFI OS.\n"
"\nPress any key to continue booting...\n",
BootOption->Description);
}
if (gST->ConIn != NULL) {
Status = gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &Index);
ASSERT_EFI_ERROR (Status);
ASSERT (Index == 0);
while (!EFI_ERROR (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key))) {}
}
return;
}
}
@ -2175,12 +2194,14 @@ BmEnumerateBootOptions (
EFI_BLOCK_IO_PROTOCOL *BlkIo;
UINTN Removable;
UINTN Index;
UINTN EmmcCount;
CHAR16 *Description;
ASSERT (BootOptionCount != NULL);
*BootOptionCount = 0;
BootOptions = NULL;
EmmcCount = 0;
//
// Parse removable block io followed by fixed block io
@ -2219,6 +2240,17 @@ BmEnumerateBootOptions (
}
Description = BmGetBootDescription (Handles[Index]);
//
// Skip secondary entries for internal eMMC devices
//
if (StrCmp(Description, L"eMMC Device") == 0) {
EmmcCount++;
if (EmmcCount > 1) {
continue;
}
}
BootOptions = ReallocatePool (
sizeof (EFI_BOOT_MANAGER_LOAD_OPTION) * (*BootOptionCount),
sizeof (EFI_BOOT_MANAGER_LOAD_OPTION) * (*BootOptionCount + 1),

View File

@ -15,7 +15,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define PRODUCT_IDENTIFICATION_LENGTH 16
CONST UINT16 mBmUsbLangId = 0x0409; // English
CHAR16 mBmUefiPrefix[] = L"UEFI ";
LIST_ENTRY mPlatformBootDescriptionHandlers = INITIALIZE_LIST_HEAD_VARIABLE (mPlatformBootDescriptionHandlers);
@ -146,9 +145,8 @@ BmGetDescriptionFromDiskInfo (
EFI_ATAPI_IDENTIFY_DATA IdentifyData;
EFI_SCSI_INQUIRY_DATA InquiryData;
CHAR16 *Description;
UINTN Length;
CHAR16 *DescTemp;
CONST UINTN ModelNameLength = 40;
CONST UINTN SerialNumberLength = 20;
CHAR8 *StrPtr;
UINT8 Temp;
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
@ -174,26 +172,19 @@ BmGetDescriptionFromDiskInfo (
&BufferSize
);
if (!EFI_ERROR (Status)) {
Description = AllocateZeroPool ((ModelNameLength + SerialNumberLength + 2) * sizeof (CHAR16));
Description = AllocateZeroPool (ModelNameLength * sizeof (CHAR16));
ASSERT (Description != NULL);
for (Index = 0; Index + 1 < ModelNameLength; Index += 2) {
Description[Index] = (CHAR16)IdentifyData.ModelName[Index + 1];
Description[Index + 1] = (CHAR16)IdentifyData.ModelName[Index];
}
Length = Index;
Description[Length++] = L' ';
for (Index = 0; Index + 1 < SerialNumberLength; Index += 2) {
Description[Length + Index] = (CHAR16)IdentifyData.SerialNo[Index + 1];
Description[Length + Index + 1] = (CHAR16)IdentifyData.SerialNo[Index];
}
Length += Index;
Description[Length++] = L'\0';
ASSERT (Length == ModelNameLength + SerialNumberLength + 2);
Description[Index] = L'\0';
BmEliminateExtraSpaces (Description);
DescTemp = AllocateZeroPool (0x60);
StrCatS (DescTemp, 0x60 / sizeof (CHAR16), Description);
StrCpyS(Description, StrSize (DescTemp) / sizeof (CHAR16), DescTemp);
FreePool (DescTemp);
}
} else if (CompareGuid (&DiskInfo->Interface, &gEfiDiskInfoScsiInterfaceGuid)) {
BufferSize = sizeof (EFI_SCSI_INQUIRY_DATA);
@ -273,7 +264,6 @@ BmGetUsbDescription (
CHAR16 NullChar;
CHAR16 *Manufacturer;
CHAR16 *Product;
CHAR16 *SerialNumber;
CHAR16 *Description;
EFI_USB_DEVICE_DESCRIPTOR DevDesc;
UINTN DescMaxSize;
@ -314,25 +304,12 @@ BmGetUsbDescription (
Product = &NullChar;
}
Status = UsbIo->UsbGetStringDescriptor (
UsbIo,
mBmUsbLangId,
DevDesc.StrSerialNumber,
&SerialNumber
);
if (EFI_ERROR (Status)) {
SerialNumber = &NullChar;
}
if ((Manufacturer == &NullChar) &&
(Product == &NullChar) &&
(SerialNumber == &NullChar)
)
{
(Product == &NullChar)) {
return NULL;
}
DescMaxSize = StrSize (Manufacturer) + StrSize (Product) + StrSize (SerialNumber);
DescMaxSize = StrSize (Manufacturer) + StrSize (Product);
Description = AllocateZeroPool (DescMaxSize);
ASSERT (Description != NULL);
StrCatS (Description, DescMaxSize/sizeof (CHAR16), Manufacturer);
@ -341,8 +318,6 @@ BmGetUsbDescription (
StrCatS (Description, DescMaxSize/sizeof (CHAR16), Product);
StrCatS (Description, DescMaxSize/sizeof (CHAR16), L" ");
StrCatS (Description, DescMaxSize/sizeof (CHAR16), SerialNumber);
if (Manufacturer != &NullChar) {
FreePool (Manufacturer);
}
@ -351,10 +326,6 @@ BmGetUsbDescription (
FreePool (Product);
}
if (SerialNumber != &NullChar) {
FreePool (SerialNumber);
}
BmEliminateExtraSpaces (Description);
return Description;
@ -584,6 +555,7 @@ BmGetNvmeDescription (
EFI_NVM_EXPRESS_COMPLETION Completion;
NVME_ADMIN_CONTROLLER_DATA ControllerData;
CHAR16 *Description;
CHAR16 *DescTemp;
CHAR16 *Char;
UINTN Index;
@ -653,20 +625,11 @@ BmGetNvmeDescription (
*(Char++) = (CHAR16)ControllerData.Mn[Index];
}
*(Char++) = L' ';
for (Index = 0; Index < ARRAY_SIZE (ControllerData.Sn); Index++) {
*(Char++) = (CHAR16)ControllerData.Sn[Index];
}
*(Char++) = L' ';
UnicodeValueToStringS (
Char,
sizeof (CHAR16) * (MAXIMUM_VALUE_CHARACTERS + 1),
0,
DevicePath.NvmeNamespace->NamespaceId,
0
);
BmEliminateExtraSpaces (Description);
DescTemp = AllocateZeroPool (0x60);
StrCatS (DescTemp, 0x60 / sizeof (CHAR16), Description);
StrCpyS(Description, StrSize (DescTemp) / sizeof (CHAR16), DescTemp);
FreePool (DescTemp);
}
return Description;
@ -801,7 +764,6 @@ BmGetBootDescription (
BM_BOOT_DESCRIPTION_ENTRY *Entry;
CHAR16 *Description;
CHAR16 *DefaultDescription;
CHAR16 *Temp;
UINTN Index;
//
@ -811,16 +773,6 @@ BmGetBootDescription (
for (Index = 0; Index < ARRAY_SIZE (mBmBootDescriptionHandlers); Index++) {
DefaultDescription = mBmBootDescriptionHandlers[Index](Handle);
if (DefaultDescription != NULL) {
//
// Avoid description confusion between UEFI & Legacy boot option by adding "UEFI " prefix
// ONLY for core provided boot description handler.
//
Temp = AllocatePool (StrSize (DefaultDescription) + sizeof (mBmUefiPrefix));
ASSERT (Temp != NULL);
StrCpyS (Temp, (StrSize (DefaultDescription) + sizeof (mBmUefiPrefix)) / sizeof (CHAR16), mBmUefiPrefix);
StrCatS (Temp, (StrSize (DefaultDescription) + sizeof (mBmUefiPrefix)) / sizeof (CHAR16), DefaultDescription);
FreePool (DefaultDescription);
DefaultDescription = Temp;
break;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 315 KiB

View File

@ -154,6 +154,10 @@
#
VariablePolicyHelperLib|Include/Library/VariablePolicyHelperLib.h
## @libraryclass Provides services to access UEFI variable flash information.
#
VariableFlashInfoLib|Include/Library/VariableFlashInfoLib.h
[Guids]
## MdeModule package token space guid
# Include/Guid/MdeModulePkgTokenSpace.h
@ -226,6 +230,10 @@
# Include/Guid/SmmVariableCommon.h
gSmmVariableWriteGuid = { 0x93ba1826, 0xdffb, 0x45dd, { 0x82, 0xa7, 0xe7, 0xdc, 0xaa, 0x3b, 0xbd, 0xf3 }}
## Guid of the variable flash information HOB.
# Include/Guid/VariableFlashInfo.h
gVariableFlashInfoHobGuid = { 0x5d11c653, 0x8154, 0x4ac3, { 0xa8, 0xc2, 0xfb, 0xa2, 0x89, 0x20, 0xfc, 0x90 }}
## Performance protocol guid that also acts as the performance HOB guid and performance variable GUID
# Include/Guid/Performance.h
gPerformanceProtocolGuid = { 0x76B6BDFA, 0x2ACD, 0x4462, { 0x9E, 0x3F, 0xCB, 0x58, 0xC9, 0x69, 0xD9, 0x37 } }
@ -2167,3 +2175,8 @@
[UserExtensions.TianoCore."ExtraFiles"]
MdeModulePkgExtra.uni
[PcdsFixedAtBuild, PcdsPatchableInModule]
## FFS filename to find the default BMP Logo file.
# @Prompt FFS Name of Boot Logo File
gEfiMdeModulePkgTokenSpaceGuid.PcdLogoFile |{ 0x99, 0x8b, 0xB2, 0x7B, 0xBB, 0x61, 0xD5, 0x11, 0x9A, 0x5D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }|VOID*|0x40000003

View File

@ -103,6 +103,7 @@
DisplayUpdateProgressLib|MdeModulePkg/Library/DisplayUpdateProgressLibGraphics/DisplayUpdateProgressLibGraphics.inf
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
MmUnblockMemoryLib|MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibNull.inf
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
[LibraryClasses.EBC.PEIM]
IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf
@ -440,6 +441,7 @@
MdeModulePkg/Library/FmpAuthenticationLibNull/FmpAuthenticationLibNull.inf
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf
MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf
MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
[Components.IA32, Components.X64, Components.AARCH64]
MdeModulePkg/Universal/EbcDxe/EbcDxe.inf

View File

@ -330,7 +330,8 @@ BdsWait (
// Can be removed after all keyboard drivers invoke callback in timer callback.
if (HotkeyTriggered != NULL) {
Status = BdsWaitForSingleEvent (HotkeyTriggered, EFI_TIMER_PERIOD_SECONDS (1));
//Status = BdsWaitForSingleEvent (HotkeyTriggered, EFI_TIMER_PERIOD_SECONDS (1));
Status = BdsWaitForSingleEvent (gST->ConIn->WaitForKey, EFI_TIMER_PERIOD_SECONDS (1));
if (!EFI_ERROR (Status)) {
break;
}
@ -1044,7 +1045,7 @@ BdsEntry (
//
// BdsReadKeys() can be removed after all keyboard drivers invoke callback in timer callback.
//
BdsReadKeys ();
//BdsReadKeys ();
EfiBootManagerHotkeyBoot ();

View File

@ -1943,7 +1943,8 @@ FlushCursor (
CurrentMode = This->Mode;
if (!CurrentMode->CursorVisible) {
if (!CurrentMode->CursorVisible ||
(CurrentMode->CursorColumn == 0 && CurrentMode->CursorRow == 0 )) {
return EFI_SUCCESS;
}

View File

@ -26,6 +26,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/ReportStatusCodeLib.h>
#include <Library/SafeIntLib.h>
#include <Library/VariableFlashInfoLib.h>
//
// Flash erase polarity is 1
@ -708,10 +710,13 @@ InitFtwProtocol (
Since Signature and WriteQueueSize have been known, Crc can be calculated out,
then the work space header will be fixed.
@param[in] WorkSpaceLength Length in bytes of the FTW workspace area.
**/
VOID
InitializeLocalWorkSpaceHeader (
VOID
IN UINTN WorkSpaceLength
);
/**

View File

@ -46,6 +46,8 @@
UefiLib
PcdLib
ReportStatusCodeLib
SafeIntLib
VariableFlashInfoLib
[Guids]
#
@ -65,14 +67,6 @@
[FeaturePcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFullFtwServiceEnable ## CONSUMES
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64 ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize ## CONSUMES
#
# gBS->CalculateCrc32() is consumed in EntryPoint.
# PI spec said: When the DXE Foundation is notified that the EFI_RUNTIME_ARCH_PROTOCOL

View File

@ -52,6 +52,8 @@
ReportStatusCodeLib
SmmMemLib
BaseLib
SafeIntLib
VariableFlashInfoLib
[Guids]
#
@ -74,14 +76,6 @@
[FeaturePcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFullFtwServiceEnable ## CONSUMES
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64 ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize ## CONSUMES
#
# gBS->CalculateCrc32() is consumed in EntryPoint.
# PI spec said: When the DXE Foundation is notified that the EFI_RUNTIME_ARCH_PROTOCOL

View File

@ -50,7 +50,9 @@
MmServicesTableLib
PcdLib
ReportStatusCodeLib
SafeIntLib
StandaloneMmDriverEntryPoint
VariableFlashInfoLib
[Guids]
#
@ -73,13 +75,5 @@
[FeaturePcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFullFtwServiceEnable ## CONSUMES
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64 ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize ## CONSUMES
[Depex]
TRUE

View File

@ -987,22 +987,43 @@ InitFtwDevice (
OUT EFI_FTW_DEVICE **FtwData
)
{
EFI_FTW_DEVICE *FtwDevice;
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS WorkSpaceAddress;
UINT64 Size;
UINTN FtwWorkingSize;
EFI_FTW_DEVICE *FtwDevice;
FtwWorkingSize = 0;
Status = GetVariableFlashFtwWorkingInfo (&WorkSpaceAddress, &Size);
ASSERT_EFI_ERROR (Status);
Status = SafeUint64ToUintn (Size, &FtwWorkingSize);
// This driver currently assumes the size will be UINTN so assert the value is safe for now.
ASSERT_EFI_ERROR (Status);
//
// Allocate private data of this driver,
// Including the FtwWorkSpace[FTW_WORK_SPACE_SIZE].
//
FtwDevice = AllocateZeroPool (sizeof (EFI_FTW_DEVICE) + PcdGet32 (PcdFlashNvStorageFtwWorkingSize));
FtwDevice = AllocateZeroPool (sizeof (EFI_FTW_DEVICE) + FtwWorkingSize);
if (FtwDevice == NULL) {
return EFI_OUT_OF_RESOURCES;
}
FtwDevice->WorkSpaceAddress = WorkSpaceAddress;
FtwDevice->WorkSpaceLength = FtwWorkingSize;
Status = GetVariableFlashFtwSpareInfo (&FtwDevice->SpareAreaAddress, &Size);
ASSERT_EFI_ERROR (Status);
Status = SafeUint64ToUintn (Size, &FtwDevice->SpareAreaLength);
// This driver currently assumes the size will be UINTN so assert the value is safe for now.
ASSERT_EFI_ERROR (Status);
//
// Initialize other parameters, and set WorkSpace as FTW_ERASED_BYTE.
//
FtwDevice->WorkSpaceLength = (UINTN)PcdGet32 (PcdFlashNvStorageFtwWorkingSize);
FtwDevice->SpareAreaLength = (UINTN)PcdGet32 (PcdFlashNvStorageFtwSpareSize);
if ((FtwDevice->WorkSpaceLength == 0) || (FtwDevice->SpareAreaLength == 0)) {
DEBUG ((DEBUG_ERROR, "Ftw: Workspace or Spare block does not exist!\n"));
FreePool (FtwDevice);
@ -1015,16 +1036,6 @@ InitFtwDevice (
FtwDevice->FtwWorkSpaceLba = (EFI_LBA)(-1);
FtwDevice->FtwSpareLba = (EFI_LBA)(-1);
FtwDevice->WorkSpaceAddress = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdFlashNvStorageFtwWorkingBase64);
if (FtwDevice->WorkSpaceAddress == 0) {
FtwDevice->WorkSpaceAddress = (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFlashNvStorageFtwWorkingBase);
}
FtwDevice->SpareAreaAddress = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdFlashNvStorageFtwSpareBase64);
if (FtwDevice->SpareAreaAddress == 0) {
FtwDevice->SpareAreaAddress = (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFlashNvStorageFtwSpareBase);
}
*FtwData = FtwDevice;
return EFI_SUCCESS;
}
@ -1108,8 +1119,8 @@ FindFvbForFtw (
// To get the LBA of work space
//
for (LbaIndex = 1; LbaIndex <= NumberOfBlocks; LbaIndex += 1) {
if ( (FtwDevice->WorkSpaceAddress >= (FvbBaseAddress + BlockSize * (LbaIndex - 1)))
&& (FtwDevice->WorkSpaceAddress < (FvbBaseAddress + BlockSize * LbaIndex)))
if (FtwDevice->WorkSpaceAddress - FvbBaseAddress >= BlockSize * (LbaIndex - 1) &&
(FtwDevice->WorkSpaceAddress - FvbBaseAddress) / BlockSize >= LbaIndex - 1)
{
FtwDevice->FtwWorkSpaceLba = LbaIndex - 1;
//
@ -1121,12 +1132,10 @@ FindFvbForFtw (
FtwDevice->NumberOfWorkSpaceBlock = FTW_BLOCKS (FtwDevice->FtwWorkSpaceBase + FtwDevice->FtwWorkSpaceSize, FtwDevice->WorkBlockSize);
if (FtwDevice->FtwWorkSpaceSize >= FtwDevice->WorkBlockSize) {
//
// Check the alignment of work space address and length, they should be block size aligned when work space size is larger than one block size.
// Check the alignment of work space length, it should be block size aligned when work space size is larger than one block size.
//
if (((FtwDevice->WorkSpaceAddress & (FtwDevice->WorkBlockSize - 1)) != 0) ||
((FtwDevice->WorkSpaceLength & (FtwDevice->WorkBlockSize - 1)) != 0))
{
DEBUG ((DEBUG_ERROR, "Ftw: Work space address or length is not block size aligned when work space size is larger than one block size\n"));
if ((FtwDevice->WorkSpaceLength & (FtwDevice->WorkBlockSize - 1)) != 0) {
DEBUG ((EFI_D_ERROR, "Ftw: Work space length is not block size aligned when work space size is larger than one block size\n"));
FreePool (HandleBuffer);
ASSERT (FALSE);
return EFI_ABORTED;
@ -1171,12 +1180,10 @@ FindFvbForFtw (
}
//
// Check the alignment of spare area address and length, they should be block size aligned
// Check the alignment of spare area length, it should be block size aligned
//
if (((FtwDevice->SpareAreaAddress & (FtwDevice->SpareBlockSize - 1)) != 0) ||
((FtwDevice->SpareAreaLength & (FtwDevice->SpareBlockSize - 1)) != 0))
{
DEBUG ((DEBUG_ERROR, "Ftw: Spare area address or length is not block size aligned\n"));
if ((FtwDevice->SpareAreaLength & (FtwDevice->SpareBlockSize - 1)) != 0) {
DEBUG ((EFI_D_ERROR, "Ftw: Spare area address or length is not block size aligned\n"));
FreePool (HandleBuffer);
//
// Report Status Code EFI_SW_EC_ABORTED.
@ -1277,7 +1284,7 @@ InitFtwProtocol (
FtwDevice->FtwLastWriteHeader = NULL;
FtwDevice->FtwLastWriteRecord = NULL;
InitializeLocalWorkSpaceHeader ();
InitializeLocalWorkSpaceHeader (FtwDevice->WorkSpaceLength);
//
// Refresh the working space data from working block

View File

@ -16,10 +16,13 @@ EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER mWorkingBlockHeader = { ZERO_GUID, 0, 0
Since Signature and WriteQueueSize have been known, Crc can be calculated out,
then the work space header will be fixed.
@param[in] WorkSpaceLength Length in bytes of the FTW workspace area.
**/
VOID
InitializeLocalWorkSpaceHeader (
VOID
IN UINTN WorkSpaceLength
)
{
//
@ -46,7 +49,7 @@ InitializeLocalWorkSpaceHeader (
&gEdkiiWorkingBlockSignatureGuid,
sizeof (EFI_GUID)
);
mWorkingBlockHeader.WriteQueueSize = PcdGet32 (PcdFlashNvStorageFtwWorkingSize) - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER);
mWorkingBlockHeader.WriteQueueSize = WorkSpaceLength - sizeof (EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER);
//
// Crc is calculated with all the fields except Crc and STATE, so leave them as FTW_ERASED_BYTE.

View File

@ -16,6 +16,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/DebugLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/HobLib.h>
#include <Library/SafeIntLib.h>
#include <Library/VariableFlashInfoLib.h>
EFI_PEI_PPI_DESCRIPTOR mPpiListVariable = {
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
@ -212,25 +214,31 @@ PeimFaultTolerantWriteInitialize (
EFI_PHYSICAL_ADDRESS SpareAreaAddress;
UINTN SpareAreaLength;
EFI_PHYSICAL_ADDRESS WorkSpaceInSpareArea;
UINT64 Size;
FAULT_TOLERANT_WRITE_LAST_WRITE_DATA FtwLastWrite;
FtwWorkingBlockHeader = NULL;
FtwLastWriteHeader = NULL;
FtwLastWriteRecord = NULL;
WorkSpaceAddress = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdFlashNvStorageFtwWorkingBase64);
if (WorkSpaceAddress == 0) {
WorkSpaceAddress = (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFlashNvStorageFtwWorkingBase);
}
SpareAreaAddress = 0;
SpareAreaLength = 0;
WorkSpaceAddress = 0;
WorkSpaceLength = 0;
WorkSpaceLength = (UINTN)PcdGet32 (PcdFlashNvStorageFtwWorkingSize);
Status = GetVariableFlashFtwWorkingInfo (&WorkSpaceAddress, &Size);
ASSERT_EFI_ERROR (Status);
SpareAreaAddress = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdFlashNvStorageFtwSpareBase64);
if (SpareAreaAddress == 0) {
SpareAreaAddress = (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFlashNvStorageFtwSpareBase);
}
Status = SafeUint64ToUintn (Size, &WorkSpaceLength);
// This driver currently assumes the size will be UINTN so assert the value is safe for now.
ASSERT_EFI_ERROR (Status);
SpareAreaLength = (UINTN)PcdGet32 (PcdFlashNvStorageFtwSpareSize);
Status = GetVariableFlashFtwSpareInfo (&SpareAreaAddress, &Size);
ASSERT_EFI_ERROR (Status);
Status = SafeUint64ToUintn (Size, &SpareAreaLength);
// This driver currently assumes the size will be UINTN so assert the value is safe for now.
ASSERT_EFI_ERROR (Status);
//
// The address of FTW working base and spare base must not be 0.

View File

@ -39,6 +39,8 @@
HobLib
BaseMemoryLib
PcdLib
SafeIntLib
VariableFlashInfoLib
[Guids]
## SOMETIMES_PRODUCES ## HOB
@ -47,14 +49,6 @@
gEdkiiWorkingBlockSignatureGuid ## SOMETIMES_CONSUMES ## GUID
gEfiSystemNvDataFvGuid ## SOMETIMES_CONSUMES ## GUID
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase64 ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase64 ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize ## CONSUMES
[Depex]
TRUE

View File

@ -567,11 +567,13 @@ GetVariableStore (
OUT VARIABLE_STORE_INFO *StoreInfo
)
{
EFI_STATUS Status;
EFI_HOB_GUID_TYPE *GuidHob;
EFI_FIRMWARE_VOLUME_HEADER *FvHeader;
VARIABLE_STORE_HEADER *VariableStoreHeader;
EFI_PHYSICAL_ADDRESS NvStorageBase;
UINT32 NvStorageSize;
UINT64 NvStorageSize64;
FAULT_TOLERANT_WRITE_LAST_WRITE_DATA *FtwLastWriteData;
UINT32 BackUpOffset;
@ -591,11 +593,13 @@ GetVariableStore (
// Emulated non-volatile variable mode is not enabled.
//
NvStorageSize = PcdGet32 (PcdFlashNvStorageVariableSize);
NvStorageBase = (EFI_PHYSICAL_ADDRESS)(PcdGet64 (PcdFlashNvStorageVariableBase64) != 0 ?
PcdGet64 (PcdFlashNvStorageVariableBase64) :
PcdGet32 (PcdFlashNvStorageVariableBase)
);
Status = GetVariableFlashNvStorageInfo (&NvStorageBase, &NvStorageSize64);
ASSERT_EFI_ERROR (Status);
Status = SafeUint64ToUint32 (NvStorageSize64, &NvStorageSize);
// This driver currently assumes the size will be UINT32 so assert the value is safe for now.
ASSERT_EFI_ERROR (Status);
ASSERT (NvStorageBase != 0);
//

View File

@ -20,6 +20,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/BaseMemoryLib.h>
#include <Library/PeiServicesTablePointerLib.h>
#include <Library/PeiServicesLib.h>
#include <Library/SafeIntLib.h>
#include <Library/VariableFlashInfoLib.h>
#include <Guid/VariableFormat.h>
#include <Guid/VariableIndexTable.h>

View File

@ -39,6 +39,8 @@
DebugLib
PeiServicesTablePointerLib
PeiServicesLib
SafeIntLib
VariableFlashInfoLib
[Guids]
## CONSUMES ## GUID # Variable store header
@ -59,9 +61,6 @@
gEfiPeiReadOnlyVariable2PpiGuid ## PRODUCES
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvModeEnable ## SOMETIMES_CONSUMES
[Depex]

View File

@ -31,6 +31,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/MemoryAllocationLib.h>
#include <Library/AuthVariableLib.h>
#include <Library/VarCheckLib.h>
#include <Library/VariableFlashInfoLib.h>
#include <Library/SafeIntLib.h>
#include <Guid/GlobalVariable.h>
#include <Guid/EventGroup.h>
#include <Guid/VariableFormat.h>
@ -40,11 +42,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "PrivilegePolymorphic.h"
#define NV_STORAGE_VARIABLE_BASE (EFI_PHYSICAL_ADDRESS)\
(PcdGet64 (PcdFlashNvStorageVariableBase64) != 0 ? \
PcdGet64 (PcdFlashNvStorageVariableBase64) : \
PcdGet32 (PcdFlashNvStorageVariableBase))
#define EFI_VARIABLE_ATTRIBUTES_MASK (EFI_VARIABLE_NON_VOLATILE |\
EFI_VARIABLE_BOOTSERVICE_ACCESS | \
EFI_VARIABLE_RUNTIME_ACCESS | \

View File

@ -423,6 +423,8 @@ FtwNotificationEvent (
EFI_PHYSICAL_ADDRESS VariableStoreBase;
UINT64 VariableStoreLength;
UINTN FtwMaxBlockSize;
UINT32 NvStorageVariableSize;
UINT64 NvStorageVariableSize64;
//
// Ensure FTW protocol is installed.
@ -432,14 +434,20 @@ FtwNotificationEvent (
return;
}
Status = GetVariableFlashNvStorageInfo (&NvStorageVariableBase, &NvStorageVariableSize64);
ASSERT_EFI_ERROR (Status);
Status = SafeUint64ToUint32 (NvStorageVariableSize64, &NvStorageVariableSize);
// This driver currently assumes the size will be UINT32 so assert the value is safe for now.
ASSERT_EFI_ERROR (Status);
VariableStoreBase = NvStorageVariableBase + mNvFvHeaderCache->HeaderLength;
Status = FtwProtocol->GetMaxBlockSize (FtwProtocol, &FtwMaxBlockSize);
if (!EFI_ERROR (Status)) {
ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);
ASSERT (NvStorageVariableSize <= FtwMaxBlockSize);
}
NvStorageVariableBase = NV_STORAGE_VARIABLE_BASE;
VariableStoreBase = NvStorageVariableBase + mNvFvHeaderCache->HeaderLength;
//
// Let NonVolatileVariableBase point to flash variable store base directly after FTW ready.
//

View File

@ -142,6 +142,7 @@ InitRealNonVolatileVariableStore (
EFI_PHYSICAL_ADDRESS NvStorageBase;
UINT8 *NvStorageData;
UINT32 NvStorageSize;
UINT64 NvStorageSize64;
FAULT_TOLERANT_WRITE_LAST_WRITE_DATA *FtwLastWriteData;
UINT32 BackUpOffset;
UINT32 BackUpSize;
@ -153,19 +154,24 @@ InitRealNonVolatileVariableStore (
mVariableModuleGlobal->FvbInstance = NULL;
Status = GetVariableFlashNvStorageInfo (&NvStorageBase, &NvStorageSize64);
ASSERT_EFI_ERROR (Status);
Status = SafeUint64ToUint32 (NvStorageSize64, &NvStorageSize);
// This driver currently assumes the size will be UINT32 so assert the value is safe for now.
ASSERT_EFI_ERROR (Status);
ASSERT (NvStorageBase != 0);
//
// Allocate runtime memory used for a memory copy of the FLASH region.
// Keep the memory and the FLASH in sync as updates occur.
//
NvStorageSize = PcdGet32 (PcdFlashNvStorageVariableSize);
NvStorageData = AllocateRuntimeZeroPool (NvStorageSize);
if (NvStorageData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
NvStorageBase = NV_STORAGE_VARIABLE_BASE;
ASSERT (NvStorageBase != 0);
//
// Copy NV storage data to the memory buffer.
//

View File

@ -71,8 +71,10 @@
TpmMeasurementLib
AuthVariableLib
VarCheckLib
VariableFlashInfoLib
VariablePolicyLib
VariablePolicyHelperLib
SafeIntLib
[Protocols]
gEfiFirmwareVolumeBlockProtocolGuid ## CONSUMES
@ -125,9 +127,6 @@
gEfiImageSecurityDatabaseGuid
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVolatileVariableSize ## CONSUMES

View File

@ -1084,6 +1084,8 @@ SmmFtwNotificationEvent (
EFI_SMM_FAULT_TOLERANT_WRITE_PROTOCOL *FtwProtocol;
EFI_PHYSICAL_ADDRESS NvStorageVariableBase;
UINTN FtwMaxBlockSize;
UINT32 NvStorageVariableSize;
UINT64 NvStorageVariableSize64;
if (mVariableModuleGlobal->FvbInstance != NULL) {
return EFI_SUCCESS;
@ -1097,14 +1099,21 @@ SmmFtwNotificationEvent (
return Status;
}
Status = GetVariableFlashNvStorageInfo (&NvStorageVariableBase, &NvStorageVariableSize64);
ASSERT_EFI_ERROR (Status);
Status = SafeUint64ToUint32 (NvStorageVariableSize64, &NvStorageVariableSize);
// This driver currently assumes the size will be UINT32 so assert the value is safe for now.
ASSERT_EFI_ERROR (Status);
ASSERT (NvStorageVariableBase != 0);
VariableStoreBase = NvStorageVariableBase + mNvFvHeaderCache->HeaderLength;
Status = FtwProtocol->GetMaxBlockSize (FtwProtocol, &FtwMaxBlockSize);
if (!EFI_ERROR (Status)) {
ASSERT (PcdGet32 (PcdFlashNvStorageVariableSize) <= FtwMaxBlockSize);
ASSERT (NvStorageVariableSize <= FtwMaxBlockSize);
}
NvStorageVariableBase = NV_STORAGE_VARIABLE_BASE;
VariableStoreBase = NvStorageVariableBase + mNvFvHeaderCache->HeaderLength;
//
// Let NonVolatileVariableBase point to flash variable store base directly after FTW ready.
//

View File

@ -80,8 +80,10 @@
AuthVariableLib
VarCheckLib
UefiBootServicesTableLib
VariableFlashInfoLib
VariablePolicyLib
VariablePolicyHelperLib
SafeIntLib
[Protocols]
gEfiSmmFirmwareVolumeBlockProtocolGuid ## CONSUMES
@ -127,9 +129,6 @@
gEdkiiVarErrorFlagGuid
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVolatileVariableSize ## CONSUMES

View File

@ -73,9 +73,11 @@
HobLib
MemoryAllocationLib
MmServicesTableLib
SafeIntLib
StandaloneMmDriverEntryPoint
SynchronizationLib
VarCheckLib
VariableFlashInfoLib
VariablePolicyLib
VariablePolicyHelperLib
@ -120,9 +122,6 @@
gEdkiiVarErrorFlagGuid
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase ## SOMETIMES_CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVariableSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxAuthVariableSize ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxVolatileVariableSize ## CONSUMES

View File

@ -6239,9 +6239,13 @@ typedef union {
///
/// [Bit 11] Execute Disable Bit Enable: IA32_EFER.NXE (R/W).
///
UINT32 NXE : 1;
UINT32 Reserved3 : 20;
UINT32 Reserved4 : 32;
UINT32 NXE:1;
///
/// [ Bit 12] Secure Virtual Machine Enable (AMD only)
///
UINT32 SVME:1;
UINT32 Reserved3:19;
UINT32 Reserved4:32;
} Bits;
///
/// All bit fields as a 32-bit value

View File

@ -196,6 +196,7 @@
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
!if $(BUILD_SHELL) == TRUE
ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
@ -577,7 +578,7 @@
!include OvmfPkg/OvmfTpmPcds.dsc.inc
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|100000000
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|1000000000
[PcdsDynamicHii]
!include OvmfPkg/OvmfTpmPcdsHii.dsc.inc

View File

@ -206,6 +206,7 @@
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
#
# Network libraries

View File

@ -217,6 +217,7 @@
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
#

View File

@ -190,6 +190,7 @@
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf
@ -510,7 +511,7 @@
# Set ConfidentialComputing defaults
gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr|0
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|100000000
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|1000000000
################################################################################
#

View File

@ -207,6 +207,7 @@
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
#

View File

@ -214,6 +214,7 @@
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
#
@ -650,7 +651,7 @@
gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr|0
!if $(CSM_ENABLE) == FALSE
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|100000000
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|1000000000
!endif
[PcdsDynamicHii]

View File

@ -76,6 +76,9 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfLockBoxStorageBase|gUefiOvmfPkgTokenSpaceGuid.
0x007000|0x001000
gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress|gUefiOvmfPkgTokenSpaceGuid.PcdGuidedExtractHandlerTableSize
0x008000|0x001000
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaSize
0x010000|0x010000
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize
@ -87,6 +90,14 @@ FV = PEIFV
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
FV = DXEFV
##########################################################################################
# Set the SEV-ES specific work area PCDs (used for all forms of SEV since the
# the SEV STATUS MSR is now saved in the work area)
#
SET gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaBase = $(MEMFD_BASE_ADDRESS) + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfConfidentialComputingWorkAreaHeader
SET gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaSize = gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaSize - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfConfidentialComputingWorkAreaHeader
##########################################################################################
################################################################################
[FV.SECFV]

View File

@ -218,6 +218,7 @@
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
#
@ -658,7 +659,7 @@
gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr|0
!if $(CSM_ENABLE) == FALSE
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|100000000
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|1000000000
!endif
[PcdsDynamicDefault.X64]

View File

@ -90,6 +90,14 @@ FV = PEIFV
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize
FV = DXEFV
##########################################################################################
# Set the SEV-ES specific work area PCDs (used for all forms of SEV since the
# the SEV STATUS MSR is now saved in the work area)
#
SET gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaBase = $(MEMFD_BASE_ADDRESS) + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfConfidentialComputingWorkAreaHeader
SET gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaSize = gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaSize - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfConfidentialComputingWorkAreaHeader
##########################################################################################
################################################################################
[FV.SECFV]

View File

@ -171,7 +171,6 @@
PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf
PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.inf
PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf
CcProbeLib|OvmfPkg/Library/CcProbeLib/CcProbeLib.inf
IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsicSev.inf
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
SerialPortLib|PcAtChipsetPkg/Library/SerialIoLib/SerialIoLib.inf
@ -198,6 +197,9 @@
!if $(SMM_REQUIRE) == FALSE
LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
CcProbeLib|OvmfPkg/Library/CcProbeLib/CcProbeLib.inf
!else
CcProbeLib|MdePkg/Library/CcProbeLibNull/CcProbeLibNull.inf
!endif
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
FrameBufferBltLib|MdeModulePkg/Library/FrameBufferBltLib/FrameBufferBltLib.inf
@ -232,6 +234,7 @@
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
#
@ -681,7 +684,7 @@
gEfiMdePkgTokenSpaceGuid.PcdConfidentialComputingGuestAttr|0
!if $(CSM_ENABLE) == FALSE
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|100000000
gEfiMdePkgTokenSpaceGuid.PcdFSBClock|1000000000
!endif
[PcdsDynamicHii]

View File

@ -106,7 +106,8 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvm
FV = DXEFV
##########################################################################################
# Set the SEV-ES specific work area PCDs
# Set the SEV-ES specific work area PCDs (used for all forms of SEV since the
# the SEV STATUS MSR is now saved in the work area)
#
SET gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaBase = $(MEMFD_BASE_ADDRESS) + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfConfidentialComputingWorkAreaHeader
SET gUefiCpuPkgTokenSpaceGuid.PcdSevEsWorkAreaSize = gUefiOvmfPkgTokenSpaceGuid.PcdOvmfWorkAreaSize - gUefiOvmfPkgTokenSpaceGuid.PcdOvmfConfidentialComputingWorkAreaHeader

View File

@ -196,6 +196,7 @@
VarCheckLib|MdeModulePkg/Library/VarCheckLib/VarCheckLib.inf
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.inf
#

View File

@ -150,6 +150,8 @@ BITS 32
SevEsUnexpectedRespTerminate:
TerminateVmgExit TERM_UNEXPECTED_RESP_CODE
%ifdef ARCH_X64
; If SEV-ES is enabled then initialize and make the GHCB page shared
SevClearPageEncMaskForGhcbPage:
; Check if SEV is enabled
@ -209,6 +211,8 @@ GetSevCBitMaskAbove31:
GetSevCBitMaskAbove31Exit:
OneTimeCallRet GetSevCBitMaskAbove31
%endif
; Check if Secure Encrypted Virtualization (SEV) features are enabled.
;
; Register usage is tight in this routine, so multiple calls for the

View File

@ -75,6 +75,12 @@ SearchBfv:
%ifdef ARCH_IA32
;
; SEV support can be built and run using the Ia32/X64 split environment.
; Set the OVMF/SEV work area as appropriate.
;
OneTimeCall CheckSevFeatures
;
; Restore initial EAX value into the EAX register
;

View File

@ -47,7 +47,36 @@
%include "Ia32/SearchForBfvBase.asm"
%include "Ia32/SearchForSecEntry.asm"
%define WORK_AREA_GUEST_TYPE (FixedPcdGet32 (PcdOvmfWorkAreaBase))
%define WORK_AREA_GUEST_TYPE (FixedPcdGet32 (PcdOvmfWorkAreaBase))
%define PT_ADDR(Offset) (FixedPcdGet32 (PcdOvmfSecPageTablesBase) + (Offset))
%define GHCB_PT_ADDR (FixedPcdGet32 (PcdOvmfSecGhcbPageTableBase))
%define GHCB_BASE (FixedPcdGet32 (PcdOvmfSecGhcbBase))
%define GHCB_SIZE (FixedPcdGet32 (PcdOvmfSecGhcbSize))
%define SEV_ES_WORK_AREA (FixedPcdGet32 (PcdSevEsWorkAreaBase))
%define SEV_ES_WORK_AREA_SIZE 25
%define SEV_ES_WORK_AREA_STATUS_MSR (FixedPcdGet32 (PcdSevEsWorkAreaBase))
%define SEV_ES_WORK_AREA_RDRAND (FixedPcdGet32 (PcdSevEsWorkAreaBase) + 8)
%define SEV_ES_WORK_AREA_ENC_MASK (FixedPcdGet32 (PcdSevEsWorkAreaBase) + 16)
%define SEV_ES_WORK_AREA_RECEIVED_VC (FixedPcdGet32 (PcdSevEsWorkAreaBase) + 24)
%define SEV_ES_VC_TOP_OF_STACK (FixedPcdGet32 (PcdOvmfSecPeiTempRamBase) + FixedPcdGet32 (PcdOvmfSecPeiTempRamSize))
%define SEV_SNP_SECRETS_BASE (FixedPcdGet32 (PcdOvmfSnpSecretsBase))
%define SEV_SNP_SECRETS_SIZE (FixedPcdGet32 (PcdOvmfSnpSecretsSize))
%define CPUID_BASE (FixedPcdGet32 (PcdOvmfCpuidBase))
%define CPUID_SIZE (FixedPcdGet32 (PcdOvmfCpuidSize))
%define SNP_SEC_MEM_BASE_DESC_1 (FixedPcdGet32 (PcdOvmfSecPageTablesBase))
%define SNP_SEC_MEM_SIZE_DESC_1 (FixedPcdGet32 (PcdOvmfSecGhcbBase) - SNP_SEC_MEM_BASE_DESC_1)
;
; The PcdOvmfSecGhcbBase reserves two GHCB pages. The first page is used
; as GHCB shared page and second is used for bookkeeping to support the
; nested GHCB in SEC phase. The bookkeeping page is mapped private. The VMM
; does not need to validate the shared page but it need to validate the
; bookkeeping page.
;
%define SNP_SEC_MEM_BASE_DESC_2 (GHCB_BASE + 0x1000)
%define SNP_SEC_MEM_SIZE_DESC_2 (SEV_SNP_SECRETS_BASE - SNP_SEC_MEM_BASE_DESC_2)
%define SNP_SEC_MEM_BASE_DESC_3 (CPUID_BASE + CPUID_SIZE)
%define SNP_SEC_MEM_SIZE_DESC_3 (FixedPcdGet32 (PcdOvmfPeiMemFvBase) - SNP_SEC_MEM_BASE_DESC_3)
%ifdef ARCH_X64
#include <AutoGen.h>
@ -94,44 +123,15 @@
%define TDX_WORK_AREA_PGTBL_READY (FixedPcdGet32 (PcdOvmfWorkAreaBase) + 4)
%define TDX_WORK_AREA_GPAW (FixedPcdGet32 (PcdOvmfWorkAreaBase) + 8)
%define PT_ADDR(Offset) (FixedPcdGet32 (PcdOvmfSecPageTablesBase) + (Offset))
%define GHCB_PT_ADDR (FixedPcdGet32 (PcdOvmfSecGhcbPageTableBase))
%define GHCB_BASE (FixedPcdGet32 (PcdOvmfSecGhcbBase))
%define GHCB_SIZE (FixedPcdGet32 (PcdOvmfSecGhcbSize))
%define SEV_ES_WORK_AREA (FixedPcdGet32 (PcdSevEsWorkAreaBase))
%define SEV_ES_WORK_AREA_SIZE 25
%define SEV_ES_WORK_AREA_STATUS_MSR (FixedPcdGet32 (PcdSevEsWorkAreaBase))
%define SEV_ES_WORK_AREA_RDRAND (FixedPcdGet32 (PcdSevEsWorkAreaBase) + 8)
%define SEV_ES_WORK_AREA_ENC_MASK (FixedPcdGet32 (PcdSevEsWorkAreaBase) + 16)
%define SEV_ES_WORK_AREA_RECEIVED_VC (FixedPcdGet32 (PcdSevEsWorkAreaBase) + 24)
%define SEV_ES_VC_TOP_OF_STACK (FixedPcdGet32 (PcdOvmfSecPeiTempRamBase) + FixedPcdGet32 (PcdOvmfSecPeiTempRamSize))
%define SEV_SNP_SECRETS_BASE (FixedPcdGet32 (PcdOvmfSnpSecretsBase))
%define SEV_SNP_SECRETS_SIZE (FixedPcdGet32 (PcdOvmfSnpSecretsSize))
%define CPUID_BASE (FixedPcdGet32 (PcdOvmfCpuidBase))
%define CPUID_SIZE (FixedPcdGet32 (PcdOvmfCpuidSize))
%define SNP_SEC_MEM_BASE_DESC_1 (FixedPcdGet32 (PcdOvmfSecPageTablesBase))
%define SNP_SEC_MEM_SIZE_DESC_1 (FixedPcdGet32 (PcdOvmfSecGhcbBase) - SNP_SEC_MEM_BASE_DESC_1)
;
; The PcdOvmfSecGhcbBase reserves two GHCB pages. The first page is used
; as GHCB shared page and second is used for bookkeeping to support the
; nested GHCB in SEC phase. The bookkeeping page is mapped private. The VMM
; does not need to validate the shared page but it need to validate the
; bookkeeping page.
;
%define SNP_SEC_MEM_BASE_DESC_2 (GHCB_BASE + 0x1000)
%define SNP_SEC_MEM_SIZE_DESC_2 (SEV_SNP_SECRETS_BASE - SNP_SEC_MEM_BASE_DESC_2)
%define SNP_SEC_MEM_BASE_DESC_3 (CPUID_BASE + CPUID_SIZE)
%define SNP_SEC_MEM_SIZE_DESC_3 (FixedPcdGet32 (PcdOvmfPeiMemFvBase) - SNP_SEC_MEM_BASE_DESC_3)
%include "X64/IntelTdxMetadata.asm"
%include "Ia32/Flat32ToFlat64.asm"
%include "Ia32/AmdSev.asm"
%include "Ia32/PageTables64.asm"
%include "Ia32/IntelTdx.asm"
%include "X64/OvmfSevMetadata.asm"
%include "X64/IntelTdxMetadata.asm"
%include "Ia32/Flat32ToFlat64.asm"
%include "Ia32/PageTables64.asm"
%include "Ia32/IntelTdx.asm"
%include "X64/OvmfSevMetadata.asm"
%endif
%include "Ia32/AmdSev.asm"
%include "Ia16/Real16ToFlat32.asm"
%include "Ia16/Init16.asm"

View File

@ -69,7 +69,7 @@ MailBoxWakeUp:
mov rax, [rbx + WakeupVectorOffset]
; OS sends a wakeup command for a given APIC ID, firmware is supposed to reset
; the command field back to zero as acknowledgement.
mov qword [rbx + WakeupVectorOffset], 0
mov qword [rbx + CommandOffset], 0
jmp rax
MailBoxSleep:
jmp $
@ -83,7 +83,7 @@ AsmRelocateApMailBoxLoopEnd:
;-------------------------------------------------------------------------------------
global ASM_PFX(AsmGetRelocationMap)
ASM_PFX(AsmGetRelocationMap):
lea rax, [ASM_PFX(AsmRelocateApMailBoxLoopStart)]
lea rax, [AsmRelocateApMailBoxLoopStart]
mov qword [rcx], rax
mov qword [rcx + 8h], AsmRelocateApMailBoxLoopEnd - AsmRelocateApMailBoxLoopStart
ret

View File

@ -0,0 +1,199 @@
/** @file
Random number generator services that uses RdRand instruction access
to provide high-quality random numbers.
Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Register/Intel/Cpuid.h>
STATIC BOOLEAN mHasRdRand;
//
// Bit mask used to determine if RdRand instruction is supported.
//
#define RDRAND_MASK BIT30
//
// Limited retry number when valid random data is returned.
// Uses the recommended value defined in Section 7.3.17 of "Intel 64 and IA-32
// Architectures Software Developer's Mannual".
//
#define RDRAND_RETRY_LIMIT 10
/**
The constructor function checks whether or not RDRAND instruction is supported
by the host hardware.
The constructor function checks whether or not RDRAND instruction is supported.
It will always return RETURN_SUCCESS.
@retval RETURN_SUCCESS The constructor always returns EFI_SUCCESS.
**/
RETURN_STATUS
EFIAPI
BaseRngLibConstructor (
VOID
)
{
UINT32 RegEax;
UINT32 RegEcx;
AsmCpuid (CPUID_SIGNATURE, &RegEax, NULL, NULL, NULL);
if (RegEax < 1) {
mHasRdRand = FALSE;
return RETURN_SUCCESS;
}
//
// Determine RDRAND support by examining bit 30 of the ECX register returned by
// CPUID. A value of 1 indicates that processor support RDRAND instruction.
//
AsmCpuid (CPUID_VERSION_INFO, 0, 0, &RegEcx, 0);
mHasRdRand = ((RegEcx & RDRAND_MASK) == RDRAND_MASK);
return RETURN_SUCCESS;
}
/**
Generates a 16-bit random number.
if Rand is NULL, then ASSERT().
@param[out] Rand Buffer pointer to store the 16-bit random value.
@retval TRUE Random number generated successfully.
@retval FALSE Failed to generate the random number.
**/
BOOLEAN
EFIAPI
GetRandomNumber16 (
OUT UINT16 *Rand
)
{
UINT32 Index;
ASSERT (Rand != NULL);
if (mHasRdRand) {
//
// A loop to fetch a 16 bit random value with a retry count limit.
//
for (Index = 0; Index < RDRAND_RETRY_LIMIT; Index++) {
if (AsmRdRand16 (Rand)) {
return TRUE;
}
}
}
return FALSE;
}
/**
Generates a 32-bit random number.
if Rand is NULL, then ASSERT().
@param[out] Rand Buffer pointer to store the 32-bit random value.
@retval TRUE Random number generated successfully.
@retval FALSE Failed to generate the random number.
**/
BOOLEAN
EFIAPI
GetRandomNumber32 (
OUT UINT32 *Rand
)
{
UINT32 Index;
ASSERT (Rand != NULL);
if (mHasRdRand) {
//
// A loop to fetch a 32 bit random value with a retry count limit.
//
for (Index = 0; Index < RDRAND_RETRY_LIMIT; Index++) {
if (AsmRdRand32 (Rand)) {
return TRUE;
}
}
}
return FALSE;
}
/**
Generates a 64-bit random number.
if Rand is NULL, then ASSERT().
@param[out] Rand Buffer pointer to store the 64-bit random value.
@retval TRUE Random number generated successfully.
@retval FALSE Failed to generate the random number.
**/
BOOLEAN
EFIAPI
GetRandomNumber64 (
OUT UINT64 *Rand
)
{
UINT32 Index;
ASSERT (Rand != NULL);
if (mHasRdRand) {
//
// A loop to fetch a 64 bit random value with a retry count limit.
//
for (Index = 0; Index < RDRAND_RETRY_LIMIT; Index++) {
if (AsmRdRand64 (Rand)) {
return TRUE;
}
}
}
return FALSE;
}
/**
Generates a 128-bit random number.
if Rand is NULL, then ASSERT().
@param[out] Rand Buffer pointer to store the 128-bit random value.
@retval TRUE Random number generated successfully.
@retval FALSE Failed to generate the random number.
**/
BOOLEAN
EFIAPI
GetRandomNumber128 (
OUT UINT64 *Rand
)
{
ASSERT (Rand != NULL);
//
// Read first 64 bits
//
if (!GetRandomNumber64 (Rand)) {
return FALSE;
}
//
// Read second 64 bits
//
return GetRandomNumber64 (++Rand);
}

View File

@ -0,0 +1,32 @@
## @file
# Instance of RNG (Random Number Generator) Library.
#
# Copyright (c) 2020 9elements Agency GmbH.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BaseRngLib
MODULE_UNI_FILE = BaseRngLib.uni
FILE_GUID = 05C48431-DE18-4550-931A-3350E8551498
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = RngLib
CONSTRUCTOR = BaseRngLibConstructor
#
# VALID_ARCHITECTURES = IA32 X64
#
[Sources.Ia32, Sources.X64]
BaseRng.c
[Packages]
MdePkg/MdePkg.dec
[LibraryClasses]
BaseLib
DebugLib

View File

@ -0,0 +1,17 @@
// /** @file
// Instance of RNG (Random Number Generator) Library.
//
// BaseRng Library that uses CPU RdRand instruction access to provide
// high-quality random numbers.
//
// Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
//
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
// **/
#string STR_MODULE_ABSTRACT #language en-US "Instance of RNG Library"
#string STR_MODULE_DESCRIPTION #language en-US "BaseRng Library that uses CPU RdRand instruction access to provide high-quality random numbers"

View File

@ -19,6 +19,7 @@
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/SecureBootVariableLib.h>
#include <Library/SecureBootVariableProvisionLib.h>
#include <Library/DxeServicesLib.h>
/**
Enroll a key/certificate based on a default variable.
@ -117,6 +118,7 @@ SecureBootInitPKDefault (
}
if (EFI_ERROR (Status) && (Status != EFI_NOT_FOUND)) {
DEBUG ((DEBUG_INFO, "Variable %s read error.\n", EFI_PK_DEFAULT_VARIABLE_NAME));
return Status;
}
@ -264,10 +266,10 @@ SecureBootInitDbxDefault (
IN VOID
)
{
EFI_SIGNATURE_LIST *EfiSig;
UINTN SigListsSize;
UINTN Size;
EFI_STATUS Status;
UINT8 *Data;
UINT8 *Data;
VOID *Buffer;
UINTN DataSize;
//
@ -289,7 +291,13 @@ SecureBootInitDbxDefault (
//
DEBUG ((DEBUG_INFO, "Variable %s does not exist.\n", EFI_DBX_DEFAULT_VARIABLE_NAME));
Status = SecureBootFetchData (&gDefaultdbxFileGuid, &SigListsSize, &EfiSig);
Status = GetSectionFromAnyFv (
&gDefaultdbxFileGuid,
EFI_SECTION_RAW,
0,
&Buffer,
&Size
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "Content for %s not found\n", EFI_DBX_DEFAULT_VARIABLE_NAME));
return Status;
@ -299,15 +307,13 @@ SecureBootInitDbxDefault (
EFI_DBX_DEFAULT_VARIABLE_NAME,
&gEfiGlobalVariableGuid,
EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_BOOTSERVICE_ACCESS,
SigListsSize,
(VOID *)EfiSig
Size,
(VOID *)Buffer
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_INFO, "Failed to set %s\n", EFI_DBX_DEFAULT_VARIABLE_NAME));
}
FreePool (EfiSig);
return Status;
}

View File

@ -236,6 +236,19 @@ struct cb_cbmem_tab {
UINT64 cbmem_tab;
};
#define CB_TAG_SMMSTOREV2 0x0039
struct cb_smmstorev2 {
UINT32 tag;
UINT32 size;
UINT32 num_blocks; /* Number of writeable blocks in Smm */
UINT32 block_size; /* Size of a block in byte. Default: 64 KiB */
UINT32 mmap_addr; /* MMIO address of the store for read only access */
UINT32 com_buffer; /* Physical address of the communication buffer */
UINT32 com_buffer_size; /* Size of the communication buffer in byte */
UINT8 apm_cmd; /* The command byte to write to the APM I/O port */
UINT8 unused[3]; /* Set to zero */
};
/* Helpful macros */
#define MEM_RANGE_COUNT(_rec) \

Some files were not shown because too many files have changed in this diff Show More