Compare commits

...

122 Commits

Author SHA1 Message Date
Tim Crawford
2b549700ac UefiPayloadPkg: Enable ESRT
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2024-05-29 14:29:10 -06:00
Gerd Hoffmann
88f5720e16 MdeModulePkg/UsbBusDxe: fix NOOPT build error
gcc-11 (fedora 35):

/home/kraxel/projects/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c: In function ?UsbIoBulkTransfer?:
/home/kraxel/projects/edk2/MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBus.c:277:12: error: ?UsbHcBulkTransfer? accessing 80 bytes in a region of size 8 [-Werror=stringop-overflow=]

Upstream commit ae8272ef78

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
2024-02-21 09:11:18 -07:00
Tim Crawford
27585e73da Update DBX to 2023-05-09
Ref: https://uefi.org/revocationlistfile
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-06-27 08:16:14 -06:00
Tim Crawford
42a443d5cd SecurityPkg: Fix debug build
For some reason only DEBUG builds fail because of the unused variable.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-06-22 13:41:43 -06:00
Tim Crawford
c466cc2ca5 Add System76 Secure Boot keys
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-03-07 18:10:00 -07:00
Tim Crawford
5c49aca613 Update DBX to 2022-09-07
Ref: https://uefi.org/revocationlistfile
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-03-07 18:10:00 -07:00
Tim Crawford
99891bd41e SecureBootConfig: Remove blank line
Remove the blank between "Delete..." and "Restore...".

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-03-07 10:10:35 -07:00
Tim Crawford
3485d55709 SecureBootConfig: Split long strings
firmware-setup does not wrap long lines, so manually split long strings.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-03-07 10:10:35 -07:00
Tim Crawford
c1a7127e01 SecureBootConfig: Clear PK and reset
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-03-07 10:10:35 -07:00
Tim Crawford
2f21eddfb8 SecureBootConfig: Restore keys and reset
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-03-07 10:10:35 -07:00
Tim Crawford
860c29c923 SecureBootConfig: Update variable and perform reset
Update the `SecureBootEnable` variable and perform a platform reset when
the enable/disable button is pressed.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-03-07 10:10:35 -07:00
Tim Crawford
8cfead2839 SecureBootConfig: Add text key to perform the actions
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-03-07 10:10:35 -07:00
Tim Crawford
30f6b2f3c7 SecureBootConfig: Modify UI
Rewrite the UI based on feedback from enabling the module.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-03-07 10:10:35 -07:00
Tim Crawford
4de32568fa UiApp: Link to SecureBootConfig
Shoehorn in logic from Device Manager to show only the Secure Boot
Config entry under the firmware config form.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2023-03-07 10:10:35 -07:00
Jeremy Soller
ff91020528 Notify System76 security callback prior to loading boot options 2023-03-06 15:01:34 -07:00
Feng, Bob C
943773983d BaseTools: Fix DevicePath tool build failure issue
Fix the DevicePath tool build failure that was introduced by
the fixes: 22130dcd98 ("Basetools: turn off gcc12 warning").
Failure cases are:
1. clang 13.1.6 on macOS
2. gcc5.4

Reported-by: Rebecca Cran <rebecca@bsdio.com>
Reported-by: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Cc: Rebecca Cran <rebecca@bsdio.com>
Reviewed-by: Yuwei Chen <yuwei.chen@intel.com>
2022-08-17 11:40:12 -06:00
Gerd Hoffmann
e91ea5561d Basetools: turn off gcc12 warning
In function ?SetDevicePathEndNode?,
    inlined from ?FileDevicePath? at DevicePathUtilities.c:857:5:
DevicePathUtilities.c:321:3: error: writing 4 bytes into a region of size 1 [-Werror=stringop-overflow=]
  321 |   memcpy (Node, &mUefiDevicePathLibEndDevicePath, sizeof (mUefiDevicePathLibEndDevicePath));
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from UefiDevicePathLib.h:22,
                 from DevicePathUtilities.c:16:
../Include/Protocol/DevicePath.h: In function ?FileDevicePath?:
../Include/Protocol/DevicePath.h:51:9: note: destination object ?Type? of size 1
   51 |   UINT8 Type;       ///< 0x01 Hardware Device Path.
      |         ^~~~

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
2022-08-17 11:40:12 -06:00
Gerd Hoffmann
5e86b202de BaseTools: fix gcc12 warning
Sdk/C/LzmaEnc.c: In function ?LzmaEnc_CodeOneMemBlock?:
Sdk/C/LzmaEnc.c:2828:19: error: storing the address of local variable ?outStream? in ?*p.rc.outStream? [-Werror=dangling-pointer=]
 2828 |   p->rc.outStream = &outStream.vt;
      |   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
Sdk/C/LzmaEnc.c:2811:28: note: ?outStream? declared here
 2811 |   CLzmaEnc_SeqOutStreamBuf outStream;
      |                            ^~~~~~~~~
Sdk/C/LzmaEnc.c:2811:28: note: ?pp? declared here
Sdk/C/LzmaEnc.c:2828:19: error: storing the address of local variable ?outStream? in ?*(CLzmaEnc *)pp.rc.outStream? [-Werror=dangling-pointer=]
 2828 |   p->rc.outStream = &outStream.vt;
      |   ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~
Sdk/C/LzmaEnc.c:2811:28: note: ?outStream? declared here
 2811 |   CLzmaEnc_SeqOutStreamBuf outStream;
      |                            ^~~~~~~~~
Sdk/C/LzmaEnc.c:2811:28: note: ?pp? declared here
cc1: all warnings being treated as errors

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
2022-08-17 11:40:12 -06:00
Gerd Hoffmann
b764882195 BaseTools: fix gcc12 warning
GenFfs.c:545:5: error: pointer ?InFileHandle? used after ?fclose? [-Werror=use-after-free]
  545 |     Error(NULL, 0, 4001, "Resource", "memory cannot be allocated  of %s", InFileHandle);
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
GenFfs.c:544:5: note: call to ?fclose? here
  544 |     fclose (InFileHandle);
      |     ^~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Bob Feng <bob.c.feng@intel.com>
2022-08-17 11:40:12 -06:00
Tim Crawford
a2abc5e15f 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>
2021-12-21 15:25:08 -07:00
Tim Crawford
a618e43977 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>
2021-11-16 10:10:20 -07:00
Tim Crawford
bbc04972bc UefiPayloadPkg: Add PCI support from DuetPkg
In coreboot, we mark GPU prefmem above 4GB, because NVIDIA wants a lot
(16GB region on the 30 series), otherwise coreboot will obviously fail
to allocate the resources.

In EDK2, we then end up hitting this assert:

    InitRootBridge: populated root bus 0, with room for 36 subordinate bus(es)
    RootBridge: PciRoot(0x0)
      Support/Attr: 7001F / 7001F
        DmaAbove4G: No
    NoExtConfSpace: No
         AllocAttr: 0 ()
               Bus: 0 - 24 Translation=0
                Io: 1000 - EFFF Translation=0
               Mem: 80400000 - 1001FFFFFF Translation=0
        MemAbove4G: FFFFFFFFFFFFFFFF - 0 Translation=0
              PMem: FFFFFFFFFFFFFFFF - 0 Translation=0
       PMemAbove4G: FFFFFFFFFFFFFFFF - 0 Translation=0
    ASSERT [PciHostBridgeDxe] .../edk2/MdeModulePkg/Bus/Pci/PciHostBridgeDxe/PciRootBridgeIo.c(120): Bridge->Mem.Limit < 0x0000000100000000ULL

So, bring back Pci*NoEnumerationDxe from the deleted DuetPkg, which
doesn't check anything and let's us boot.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
2021-11-11 17:49:07 -07:00
Jeremy Soller
61a7f360d9 UefiPayloadPkg: Add Intel GOP driver 2021-11-11 17:49:07 -07:00
Jeremy Soller
fc1c47ccad UefiPayloadPkg: Add System76 Setup menu 2021-11-11 17:49:07 -07:00
Tim Crawford
fec64b04eb Update brotli to fix compiling with GCC 11 2021-11-11 17:49:07 -07:00
Tim Crawford
05aa27ef23 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.
2021-11-11 17:49:07 -07:00
Tim Crawford
06cc698885 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.
2021-11-11 17:49:07 -07:00
Jeremy Soller
cb870a1ce9 UiApp: Dynamically generated firmware configuration information page
Signed-off-by: Jeremy Soller <jeremy@system76.com>
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2021-11-11 17:49:07 -07:00
Tim Crawford
90e04a7e31 MdeModulePkg/BMM: Unregister F9 and F10 hotkeys 2021-11-11 17:49:07 -07:00
Tim Crawford
1d01d2a9a7 MdeModulePkg/BMM: Remove Commit/Discard buttons 2021-11-11 17:49:07 -07:00
Tim Crawford
70e9b22f5c MdeModulePkg/BMM: Save BootOrder on list update 2021-11-11 17:49:07 -07:00
Tim Crawford
e9d6369050 MdeModulePkg/BMM: Add some debug logging 2021-11-11 17:49:07 -07:00
Tim Crawford
58d6aae969 MdeModulePkg/UiApp: Add warning if no bootable options found 2021-11-11 17:49:07 -07:00
Tim Crawford
4e0fcaba18 MdeModulePkg/BootMaintenanceManagerUiLib: Make it look like current BMM 2021-11-11 17:49:07 -07:00
Tim Crawford
2d04a62512 MdeModulePkg/UiApp: Make it look like current FrontPage
Signed-off-by: Jeremy Soller <jeremy@system76.com>
Signed-off-by: Tim Crawford <tcrawford@system76.com>
2021-11-11 17:49:07 -07:00
Tim Crawford
8a0955dfa8 MdeModulePkg/BM: Make it look like current BootMngr 2021-11-11 17:49:07 -07:00
Tim Crawford
06f4583ea5 UefiPayloadPkg: Disable EFI shell 2021-11-02 19:24:49 -06:00
Jeremy Soller
9daa69a59e 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>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
9030464a1b fix secureboot
TODO: Proper integration
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
bcfe7a54aa UefiPayloadPkg/Include/Coreboot.h: Remove __packed
The keyword is not defined and will end as public variable beeing declared
in every source that includes the header.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
600c565eb2 Revert "UefiPayloadPkg: Add FV Guid for DXEFV and PLDFV"
This reverts commit 4bac086e8e.
Breaks coreboot integration.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
aae506ce44 UefiPayloadPkg/BlSMMStoreDxe: Support Secureboot
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
bf2ca74bb6 UefiPayloadPkg: Update APRIORI
Make sure that:
* FaultTolerantDxe is started before VariableRuntimeDxe
  This ensures that FailedTolerantPei is not required and faults when writing
  the variable store are discovered
* SMBUSConfigLoader is started right after VariableRuntimeDxe
  This ensured that the board specific variables are updated as soon as possible
* Start SmbiosDxe and BlSupportDxeSmbios early to install board specific NULL protocols
* Start SecureBootConfigDxe right after VariableRuntimeDxe to update SecureBootKeys before
  Tcg2Dxe starts

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
654e5958cd Fix TPM detection
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
9657bbe08f MdeModulePkg: Be more verbose about SecureBoot and the reason why the boot failed
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
10cbbe06d3 [HACK]UefiPayloadPkg: Fix TPM2 support without PEI
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Christian Walter
802391f1fe UefiPayloadPkg/SecureBootEnrollDefaultKeys: Make SecureBoot configurable
Signed-off-by: Christian Walter <christian.walter@9elements.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
db04386fd9 UefiPayloadPkg: Check TPM PPI requests in PlatformBootManager
Test if the user need to confirm TPM Physical presence commands.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
7d5abcd016 UefiPayloadPkg: Parse coreboot's TPM PPI handoff buffer
Read the coreboot table containing the TPM PPI handoff buffer and
place it in gEfiTcgPhysicalPresenceInfoHob.

coreboot uses the same PPI interface as QEMU does and installs the
corresponding ACPI code to provide a full PPI interface to the OS.
The OS must reboot in order to execute the requests.

The corresponding coreboot patch can be found here:
https://review.coreboot.org/c/coreboot/+/45568

In a follow up commit the OvmfPkg PhysicalPresence library will be used
to confirm TPM PPI request. This is necessary as coreboot doesn't have
input drivers or a graphical UI that could be used.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
d296a36cc4 OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu: Add timeout
Instead of waiting and infinite time, abort the TPM PPI request after
3 minutes. This allow to boot headless platforms where no keyboard is
attached or the user didn't made it in time.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
bdb15bf9ba OvmfPkg: Introduce Tcg2PhysicalPresencePlatformLib
Put the PPI configuration retriveal into an own library.
That will allow to reuse the code in the UefipayloadPkg, where the
firmware provides the ACPI tables, like QEMU does on OvmfPkg.

However one major difference is that the PPI interface in UefiPayloadPkg
is not backed by a MMIO device, but resides in DRAM and is shared with ACPI code.

Add an additional parameter to provide the location of the PPI and
test if the memory region has the correct attributes.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Christian Walter
25af751320 UefiPayloadPkg: Add TPM support
* Add support for TPM1.2 and TPM2.

This adds measured boot support and will be extended with Secureboot.

Signed-off-by: Christian Walter <christian.walter@9elements.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
7f99fae217 UefiPayloadPkg: Advertise TPM support in BlSupportDxe
In BlSupportDxe read the AcpiBoardInfo and set PcdTpmInstanceGuid
to indicate that a TPM is likely present as TPM tables had been installed
by the bootloader.

The Tcg*Dxes will probe for the TPM, so no need to do it here as well.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
c134065066 UefiPayloadPkg: Check more ACPI tables
Probe for ACPI tables
* TPM2
* TCPA
and store the result in AcpiBoardInfo.

Will be used to determine if a TPM1.2 or TPM2.0 is present.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
eec38fd383 UefiPayloadPkg: Add Secureboot support
Must use RuntimeVariableDxe instead of EmuVariableDxe.
Currently doesn't boot on qemu.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
b9564773f1 UefiPayloadPkg: Scan for Option ROMs
Install the gPciPlatformProtocol to scan for Option ROMs.

For every device we probe the Option ROM and provide a pointer
to the activated BAR if found.

It's safe to assume that all ROM bars have been enumerated,
reserved in the bridge resources and are disabled by default.
This is made a mandatory bootloader requirement in the next commit.

Enabling them and leaving them enabled will do no harm.

This can easily be tested on qemu, where it will start finding Option ROMs
for VGA and network cards.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
Signed-off-by: Marcello Sylvester Bauer <marcello.bauer@9elements.com>
Cc: Patrick Rudolph <patrick.rudolph@9elements.com>
Cc: Christian Walter <christian.walter@9elements.com>
Cc: Maurice Ma <maurice.ma@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
2021-11-02 19:24:49 -06:00
Matt DeVillier
8c767bb014 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

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2021-11-02 19:24:49 -06:00
Matt DeVillier
7386ad5ae3 UefiPayloadPkg: don't set PcdDebugPropertyMask for release builds
Don't set PcdDebugPropertyMask for release builds, and properly set it
for debug builds based on SOURCE_DEBUG_ENABLE.

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2021-11-02 19:24:49 -06:00
Matt DeVillier
e727453a97 SdMmcPciDxe: Reduce timeout for SD card reset
Previous 1s timeout causeed stalls on boot splash with no benefit.
Reduced to 100ms and no interruptions to boot when no SD card inserted.

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2021-11-02 19:24:49 -06:00
Matt DeVillier
553bda4d8e BaseTools: array.fromstring and array.tostring removed in python 3.9
array.fromstring and array.tostring deprecated, and alias for
array.frombytes and array.tobytes. Deprecated since version 3.2,
have been removed in version python 3.9.

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Yunhua Feng <fengyunhua@byosoft.com.cn>
2021-11-02 19:24:49 -06:00
Matt DeVillier
3e7febc83c BlSMMStoreDxe: make error msgs unique
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2021-11-02 19:24:49 -06:00
Matt DeVillier
b664a5352c UefiPayloadPkg: Allow boot timeout to be set via cmd line
Allows for devices w/o internal display to set a longer timeout
via coreboot Kconfig

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2021-11-02 19:24:49 -06:00
Matt DeVillier
b376a7d60f ShellPkg: disable startup script, show welcome banner
Startup script does nothing other than confuse users.
Show a welcome banner and tell users how to exit.

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
3fb944f925 UefiPayloadPkg: Update APRIORI
Make sure that:
* FaultTolerantDxe is started before VariableRuntimeDxe
  This ensures that FailedTolerantPei is not required and faults when writing
  the variable store are discovered
* Start BlSupportDxeSmbios early to install board specific NULL protocols

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
1d70aa7a9b UefiCpuPkg: Disable MTRR programming for UefiPayloadPkg
The MTRRs have already been programmed by FSB.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
0bef9ccd43 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. It is required for
non-volatile variable support, TPM support, Secureboot support and more.

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.

Add a library for SMMStore to be used in DXE.

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

Make use of the APRIORI DXE to initialize an empty store on the first boot
and set the PCDs to sane values before the variable driver is loaded.

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.

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.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
d3b38ea28a UefiPayloadPkg/Library/PlatformBootManagerLib: Remove broken VGA detection
This fixes an issue where the framebuffer provided by coreboot or
slimbootloader will only work on the primary VGA device. If the
framebuffer corresponds to a different device the screen will stay black.
In addition, the code doesn't work for multiple graphic cards, has
reference to non existing functions, and is a duplication of common code.

Call EfiBootManagerConnectVideoController on every display device found,
not only the legacy VGA device. This is the same as OvmfPkg does.

Allows to display output on the framebuffer set up by firmware, which might
not be the VGA device.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
69ae47ba5d UefiPayloadPkg: 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.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Patrick Rudolph
95c492569f UefiPayloadPkg: Use new filesystem drivers
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
CoolStar
d996a4bc9f Add filesystem drivers
Add EXT2/EXT4, exFAT, NTFS filesystem drivers.
Do not add ISO9115 drivers as it breaks El Torito boot.
2021-11-02 19:24:49 -06:00
Matt DeVillier
9f528fb4c0 MdeModulePkg/Usb/Keyboard.c: don't request protocol before setting
No need to check the interface protocol then conditionally setting,
just set it to BOOT_PROTOCOL and check for error.

This is what Linux does for HID devices as some don't follow the USB spec.
One example is the Aspeed BMC HID keyboard device, which adds a massive
boot delay without this patch as it doesn't respond to 'GetProtocolRequest'.

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-11-02 19:24:49 -06:00
Matt DeVillier
bbab5b95b4 MdeModulePkg/Usb/Keyboard.c: remove Get/SetConfig calls
SetConfig is already called during device enumeration,
no need to do it again here.

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2021-11-02 19:24:49 -06:00
Tim Crawford
5e84cc0714 UefiPayloadPkg: Reduce timeout to 2s
Current firmware does not honor PcdPlatformBootTimeOut and hard-codes a
timeout of 2s.
2021-11-02 19:24:48 -06:00
Tim Crawford
2af54dd5bd 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().
2021-11-02 19:24:48 -06:00
Tim Crawford
00283317d8 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.
2021-11-02 19:24:48 -06:00
Matt DeVillier
232f661f99 MdeModulePkg: Wait for input after boot failure
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2021-11-02 19:24:48 -06:00
Tim Crawford
552ca5cc88 UefiPayloadPkg: Clear screen on boot error 2021-11-02 19:24:48 -06:00
Tim Crawford
94e7cfc7e7 UefiPayloadPkg: Copy PlatformBootManagerUnableToBoot() from OvmfPkg 2021-11-02 19:24:48 -06:00
Matt DeVillier
de7030ed26 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>
2021-11-02 19:24:48 -06:00
Matt DeVillier
587653cd8b MdeModulePkg/SdMmcPciHcDxe: add Bayhub support
Add support for Bayhub eMMC controller found on AMD
Stoneyridge Chromebooks.

Test: build/boot various google/kahlee-based devices

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2021-11-02 19:24:48 -06:00
Matt DeVillier
e167ed1a3d 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>
2021-11-02 19:24:48 -06:00
Matt DeVillier
003534f8f0 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>
2021-11-02 19:24:48 -06:00
Matt DeVillier
a363907bc9 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>
2021-11-02 19:24:48 -06:00
Matt DeVillier
530cc53f96 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>
2021-11-02 19:24:48 -06:00
Matt DeVillier
112268c70d MdeModulePkg/GraphicsConsole: Don't re-set video output mode
Fixes display resolution issues with booting OS X

Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2021-11-02 19:24:48 -06:00
Tim Crawford
726280b214 UefiPayloadPkg: Disable Device Manager 2021-11-02 19:24:48 -06:00
Matt DeVillier
b1ab82d4c8 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>
2021-11-02 19:24:48 -06:00
Matt DeVillier
2e16857f3d 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>
2021-11-02 19:24:48 -06:00
Tim Crawford
308f9a49b0 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
2021-11-02 19:24:48 -06:00
Tim Crawford
7ab09015b1 MdeModulePkg/Logo: Use System76 boot logo 2021-11-02 19:24:48 -06:00
Tim Crawford
d1c0828262 UefiPayloadPkg: Enable boot logo 2021-11-02 19:24:48 -06:00
Tim Crawford
b4dd94c217 UefiPayloadPkg: Show boot message as progress text
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
2021-11-02 19:24:48 -06:00
Matt DeVillier
f428f538b6 UefiPayloadPkg: Map ESC to Boot Manager
Change menu key from F2 to ESC, remove extranous text
2021-11-02 19:24:48 -06:00
Tim Crawford
75b91c0b9f UefiPayloadPkg: Enable PS2 keyboard by default 2021-10-21 21:32:54 -06:00
Tim Crawford
9f1dd0acb1 UefiPayloadPkg: Default to coreboot 2021-10-21 21:32:54 -06:00
Patrick Rudolph
6db1a5555a UefiPayloadPkg: Increase FV size
The following commits need additional space.

Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
2021-10-21 21:24:56 -06:00
duntan
72f8b9d80b UefiPayloadPkg: Fix the build error when enable Core ci for UefiPayloadPkg
V1: Add quotes when using $(ARCH) in .dsc and .fdf file.
The quotes are added due to the way by which Core ci parse the .dsc file.
Add UINTN in Hob.c to fix cast from pointer to integer of different size error.
V2: Delete lines which reference ShellBinPkg.The pkg doesn't exist in edk2.

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: DunTan <dun.tan@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Signed-off-by: Matt DeVillier <matt.devillier@gmail.com>
Change-Id: I18c2027f57a4fbf291925a11226ed620b808a970
2021-10-21 21:24:48 -06:00
Stewart, Chris (SW Architect) via groups.io
7b4a99be8a CryptoPkg: BaseCryptLib fix incorrect param order
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3550

Function ConvertAsn1TimeToEfiTime initializes timestamp to zeroes with
SetMem, but the actual parameters are out of order. The result is
the SetMem operation has no effect. The fix is to put the actual
parameters in the correct order.

Signed-off-by: Chris Stewart <chris.stewart@hp.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Jiewen Yao <Jiewen.yao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Xiaoyu Lu <xiaoyux.lu@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
2021-08-24 00:35:06 +00:00
Jason
8dd4fc5be6 UefiCpuPkg/CpuCacheInfoLib: Correct logical for identifying cache type
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3265

Correct the logical for identifying "Direct mapped" cache type.

Signed-off-by: Jason Lou <yun.lou@intel.com>
Reviewed-by: Ray Ni <ray.ni@intel.com>
Cc: Eric Dong <eric.dong@intel.com>
Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
2021-08-23 07:49:17 +00:00
Jeremy Linton
ef56f55d19 EmbeddedPkg/NonCoherentDmaLib: Avoid dereferencing unset Map field
Map->Operation is used to select whether a DMA region that
is being bounced has the source buffer copied to it. Except
Map->Operation isn't yet set, so the behavior is somewhat
random. Instead use the passed in Operation parameter.

Signed-off-by: Jeremy Linton <jeremy.linton@arm.com>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2021-08-17 14:01:19 +00:00
Yeh, GregX
6fdd1c13a7 MdeModulePkg PCD: Reinstall PCD service PPIS when memory available
https://bugzilla.tianocore.org/show_bug.cgi?id=3525

After PciSegmentLib using Dynamic PCD for Pcie base address such
long delay found in FSP. The root cause is some of the PCD service
PPIs not shadowed to memory and flash cache may have been disabled
in NotifyPhase stage. Solution is to shadow all PCD service PPIs
to memory.

Signed-off-by: GregX Yeh <gregx.yeh@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Jian J Wang <jian.j.wang@intel.com>
2021-08-13 01:44:41 +00:00
Wenyi Xie
ac826886c9 MdeModulePkg/UefiSortLib:Add UefiSortLib unit test
Adding two unit test case for UefiSortLib. One is a test on
sorting an array of UINT32 by using PerformQuickSort, another
is a test on comparing the same buffer by using StringCompare.
Add 'main' function name to ECC exception list to avoid ECC
error.

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao A Wu <hao.a.wu@intel.com>
Signed-off-by: Wenyi Xie <xiewenyi2@huawei.com>
Reviewed-by: Hao A Wu <hao.a.wu@intel.com>
2021-08-12 08:34:04 +00:00
Etienne Carriere
a776bbabd9 StandaloneMmPkg: build for 32bit arm machines
This change allows to build StandaloneMmPkg components for 32bit Arm
StandaloneMm firmware.

This change mainly moves AArch64/ source files to Arm/ side directory
for several components:  StandaloneMmCpu, StandaloneMmCoreEntryPoint
and StandaloneMmMemLib. The source file is built for both 32b and 64b
Arm targets.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2021-08-11 11:32:32 +00:00
Etienne Carriere
b7f0226a46 StandaloneMmPkg: fix pointer/int casts against 32bit architectures
Use intermediate (UINTN) cast when casting int from/to pointer. This
is needed as UINT64 values cast from/to 32bit pointer for 32bit
architectures.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Jiewen Yao <Jiewen.yao@intel.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-08-11 11:32:32 +00:00
Etienne Carriere
ca1773878d GenFv: Arm: support images entered in Thumb mode
Change GenFv for Arm architecture to generate a specific jump
instruction as image entry instruction, when the target entry label
is assembled with Thumb instruction set. This is possible since
SecCoreEntryAddress value fetched from the PE32 has its LSBit set when
the entry instruction executes in Thumb mode.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Acked-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-08-11 11:32:32 +00:00
Etienne Carriere
aee0098faf ArmPkg: prepare 32bit ARM build of StandaloneMmPkg
Changes in ArmPkg to prepare building StandaloneMm firmware for
32bit Arm architectures.

Adds ArmmmuStandaloneMmLib library to the list of the standard
components build for ArmPkg on when ARM architectures.

Changes path of source file AArch64/ArmMmuStandaloneMmLib.c
and compile it for both 32bit and 64bit architectures.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Ard Biesheuvel <ardb@kernel.org>
2021-08-11 11:32:32 +00:00
Etienne Carriere
03e19e6bc8 ArmPkg/IndustryStandard: 32b/64b agnostic FF-A, Mm SVC and Std SMC IDs
Defines ARM_SVC_ID_FFA_* and ARM_SVC_ID_SP_* identifiers for 32bit
function IDs as per SMCCC specification. Defines also generic ARM
SVC identifier macros to wrap 32bit or 64bit identifiers upon target
built architecture.

Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-08-11 11:32:32 +00:00
Abner Chang
7311e96417 RedfishPkg/RefishCrtLib: Public RefishCrtLib
Public the header file, move RefishCrtLib.h from PrivateInclude/
to Include/.
RefishCrtLib.lib will be public later. (Moved out from PrivateLibrary/)

Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Reviewed-by: Nickle Wang <nickle.wang@hpe.com>
2021-08-11 05:03:31 +00:00
Chris Jones
3d359ff905 MdePkg: Fix broken coding style in Acpi64.h
Bugzilla: 3516 (https://bugzilla.tianocore.org/show_bug.cgi?id=3516)

Fix a coding style issue raised by EccCheck. This issue (error code
7008) has been fixed by moving a nested union out of its structure.

Also add Acpi64.h to the "IgnoreFiles" list to stop the CI flagging
naming errors present prior to ACPI 64.

Signed-off-by: Chris Jones <christopher.jones@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-08-11 01:53:28 +00:00
Chris Jones
605c4a1ff2 MdePkg: Add Cache ID to PPTT
Bugzilla: 3516 (https://bugzilla.tianocore.org/show_bug.cgi?id=3516)

Make changes to ACPI 6.4 header according to the latest specification:
- ACPI 6.4 January 2021, Table 5.137, Table 5.140, Table 5.141
- Mantis ID 2138 (https://mantis.uefi.org/mantis/view.php?id=2138)

Signed-off-by: Chris Jones <christopher.jones@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-08-11 01:53:28 +00:00
Chris Jones
1803757a9b MdePkg: Add Secure Access Components in the SDEV table
Bugzilla: 3516 (https://bugzilla.tianocore.org/show_bug.cgi?id=3516)

Make changes to ACPI 6.4 header according to the latest specification:
- ACPI 6.4 January 2021, Section 5.2.26.1.1
- Mantis ID 2111 (https://mantis.uefi.org/mantis/view.php?id=2111)

Signed-off-by: Chris Jones <christopher.jones@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-08-11 01:53:28 +00:00
Chris Jones
75c4a8e10d MdePkg: Add the Platform Health Assessment Table (PHAT)
Bugzilla: 3516 (https://bugzilla.tianocore.org/show_bug.cgi?id=3516)

Make changes to ACPI 6.4 header according to the latest specification:
- ACPI 6.4 January 2021, Table 5.5, Section 5.2.30
- Mantis ID 2094 (https://mantis.uefi.org/mantis/view.php?id=2094)

Signed-off-by: Chris Jones <christopher.jones@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-08-11 01:53:28 +00:00
Chris Jones
0938f9235c MdePkg: Add Multiprocessor Wakeup structure
Bugzilla: 3516 (https://bugzilla.tianocore.org/show_bug.cgi?id=3516)

Make changes to ACPI 6.4 header according to the latest specification:
- ACPI 6.4 January 2021, Table 5.21, Section 5.2.12.19
- Mantis ID 2087 (https://mantis.uefi.org/mantis/view.php?id=2087)

Signed-off-by: Chris Jones <christopher.jones@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-08-11 01:53:28 +00:00
Chris Jones
7b17bcd9a0 MdePkg: Add 'Type 5' PCC structure
Bugzilla: 3516 (https://bugzilla.tianocore.org/show_bug.cgi?id=3516)

Make changes to ACPI 6.4 header according to the latest specification:
- ACPI 6.4 January 2021, Section 14.1.7, Section 14.4
- Mantis ID 2010 (https://mantis.uefi.org/mantis/view.php?id=2010)

Signed-off-by: Chris Jones <christopher.jones@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-08-11 01:53:28 +00:00
Chris Jones
357383bc4f MdePkg: Add flags and MinTransferSize to Generic Initiator
Bugzilla: 3516 (https://bugzilla.tianocore.org/show_bug.cgi?id=3516)

Make changes to ACPI 6.4 header according to the latest specification:
- ACPI 6.4 January 2021, Table 5.59, Section 5.2.27.1 & Section 5.2.27.4
- Mantis ID 1991 (https://mantis.uefi.org/mantis/view.php?id=1991)

Signed-off-by: Chris Jones <christopher.jones@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-08-11 01:53:28 +00:00
Chris Jones
c82d6dd4a3 MdePkg: Remove DPPT table
Bugzilla: 3516 (https://bugzilla.tianocore.org/show_bug.cgi?id=3516)

Make changes to ACPI 6.4 header according to the latest specification:
- ACPI 6.4 January 2021, Table 5.5
- Mantis ID 2133 (https://mantis.uefi.org/mantis/view.php?id=2133)

Signed-off-by: Chris Jones <christopher.jones@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-08-11 01:53:28 +00:00
Chris Jones
ced4cb7609 MdePkg: Add SPA Location Cookie field to SPA Range structure
Bugzilla: 3516 (https://bugzilla.tianocore.org/show_bug.cgi?id=3516)

Make changes to ACPI 6.4 header according to the latest specification:
- ACPI 6.4 January 2021, Section 5.2.25.2 System Physical Address (SPA)
  Range Structure, Table 5.109
- Mantis ID 1988 (https://mantis.uefi.org/mantis/view.php?id=1988)

Also added a blank line between #defines and structure definitions to
improve readability.

Signed-off-by: Chris Jones <christopher.jones@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-08-11 01:53:28 +00:00
Chris Jones
ad3dea9861 MdePkg: Update PMTT to ACPI 6.4
Bugzilla: 3516 (https://bugzilla.tianocore.org/show_bug.cgi?id=3516)

Make changes to ACPI 6.4 header according to the latest specification:
- ACPI 6.4 January 2021, Section 5.2.21.12
- Mantis ID 1975 (https://mantis.uefi.org/mantis/view.php?id=1975)

Signed-off-by: Chris Jones <christopher.jones@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-08-11 01:53:28 +00:00
Chris Jones
d910e83299 MdePkg: Rename SBSA Generic Watchdog to Arm Generic Watchdog
Bugzilla: 3516 (https://bugzilla.tianocore.org/show_bug.cgi?id=3516)

Make changes to ACPI 6.4 header according to the latest specification:
- ACPI 6.4 January 2021, Section 5.2.24, Table 5.100 & Section 5.2.24.2
- Mantis ID 2126 (https://mantis.uefi.org/mantis/view.php?id=2126)

Signed-off-by: Chris Jones <christopher.jones@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-08-11 01:53:28 +00:00
Chris Jones
4d7137f261 MdePkg: Increment FADT version
Bugzilla: 3516 (https://bugzilla.tianocore.org/show_bug.cgi?id=3516)

Make changes to ACPI 6.4 header according to the latest specification:
- ACPI 6.4 January 2021, Table 5-9
- Mantis ID 2105 (https://mantis.uefi.org/mantis/view.php?id=2105)

Signed-off-by: Chris Jones <christopher.jones@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-08-11 01:53:28 +00:00
Chris Jones
5963ce5d28 MdePkg: Add ACPI 6.4 header file
Bugzilla: 3516 (https://bugzilla.tianocore.org/show_bug.cgi?id=3516)

This patch introduces a header file for the ACPI specification version
6.4. Currently it is based on the Acpi63.h header file however makes
six changes:

1. Replace all occurences of "6_3"/"6.3" with "6_4/6.4".
2. Remove the trailing underscore from the header guard in accordance
   with the EDK2 coding standards, section 5.3.5.
3. Make Acpi64.h the latest ACPI definition included by Acpi.h.
4. Fix the BGRT Status field comment to match the ACPI 6.3A spec.
5. Fix several typos where definitions were named "PMMT" when it should
   be "PMTT".
6. Fix a typo: "PPTT Platform Communication Channel" should be "PDTT
   Platform Communication Channel".

Signed-off-by: Chris Jones <christopher.jones@arm.com>
Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
2021-08-11 01:53:28 +00:00
Abner Chang
a7ddc7847c RedfishPkg/JsonLib: Add more JsonLib functions
Signed-off-by: Abner Chang <abner.chang@hpe.com>
Cc: Nickle Wang <nickle.wang@hpe.com>
Reviewed-by: Nickle Wang <nickle.wang@hpe.com>
2021-08-10 09:59:05 -07:00
219 changed files with 24336 additions and 2005 deletions

View File

@@ -137,7 +137,7 @@
# hardware coherency (i.e., no virtualization or cache coherent DMA)
gArmTokenSpaceGuid.PcdNormalMemoryNonshareableOverride|FALSE|BOOLEAN|0x00000043
[PcdsFeatureFlag.AARCH64]
[PcdsFeatureFlag.AARCH64, PcdsFeatureFlag.ARM]
## Used to select method for requesting services from S-EL1.<BR><BR>
# TRUE - Selects FF-A calls for communication between S-EL0 and SPMC.<BR>
# FALSE - Selects SVC calls for communication between S-EL0 and SPMC.<BR>

View File

@@ -161,4 +161,6 @@
[Components.AARCH64]
ArmPkg/Drivers/MmCommunicationDxe/MmCommunication.inf
ArmPkg/Library/ArmMmuLib/ArmMmuPeiLib.inf
[Components.AARCH64, Components.ARM]
ArmPkg/Library/StandaloneMmMmuLib/ArmMmuStandaloneMmLib.inf

View File

@@ -17,9 +17,21 @@
#define ARM_FFA_SVC_H_
#define ARM_SVC_ID_FFA_VERSION_AARCH32 0x84000063
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH32 0x8400006F
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH32 0x84000070
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH64 0xC400006F
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH64 0xC4000070
/* Generic IDs when using AArch32 or AArch64 execution state */
#ifdef MDE_CPU_AARCH64
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH64
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH64
#endif
#ifdef MDE_CPU_ARM
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH32
#define ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH32
#endif
#define SPM_MAJOR_VERSION_FFA 1
#define SPM_MINOR_VERSION_FFA 0

View File

@@ -15,10 +15,25 @@
* privileged operations on its behalf.
*/
#define ARM_SVC_ID_SPM_VERSION_AARCH32 0x84000060
#define ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH32 0x84000061
#define ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_AARCH32 0x84000064
#define ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES_AARCH32 0x84000065
#define ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64 0xC4000061
#define ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_AARCH64 0xC4000064
#define ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES_AARCH64 0xC4000065
/* Generic IDs when using AArch32 or AArch64 execution state */
#ifdef MDE_CPU_AARCH64
#define ARM_SVC_ID_SP_EVENT_COMPLETE ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH64
#define ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_AARCH64
#define ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES_AARCH64
#endif
#ifdef MDE_CPU_ARM
#define ARM_SVC_ID_SP_EVENT_COMPLETE ARM_SVC_ID_SP_EVENT_COMPLETE_AARCH32
#define ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_AARCH32
#define ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES_AARCH32
#endif
#define SET_MEM_ATTR_DATA_PERM_MASK 0x3
#define SET_MEM_ATTR_DATA_PERM_SHIFT 0
#define SET_MEM_ATTR_DATA_PERM_NO_ACCESS 0

View File

@@ -49,6 +49,14 @@
#define ARM_SMC_ID_MM_COMMUNICATE_AARCH32 0x84000041
#define ARM_SMC_ID_MM_COMMUNICATE_AARCH64 0xC4000041
/* Generic ID when using AArch32 or AArch64 execution state */
#ifdef MDE_CPU_AARCH64
#define ARM_SMC_ID_MM_COMMUNICATE ARM_SMC_ID_MM_COMMUNICATE_AARCH64
#endif
#ifdef MDE_CPU_ARM
#define ARM_SMC_ID_MM_COMMUNICATE ARM_SMC_ID_MM_COMMUNICATE_AARCH32
#endif
/* MM return error codes */
#define ARM_SMC_MM_RET_SUCCESS 0
#define ARM_SMC_MM_RET_NOT_SUPPORTED -1

View File

@@ -2,6 +2,7 @@
File managing the MMU for ARMv8 architecture in S-EL0
Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.<BR>
Copyright (c) 2021, Linaro Limited
SPDX-License-Identifier: BSD-2-Clause-Patent
@par Reference(s):
@@ -62,7 +63,7 @@ SendMemoryPermissionRequest (
// for other Direct Request calls which are not atomic
// We therefore check only for Direct Response by the
// callee.
if (SvcArgs->Arg0 == ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP_AARCH64) {
if (SvcArgs->Arg0 == ARM_SVC_ID_FFA_MSG_SEND_DIRECT_RESP) {
// A Direct Response means FF-A success
// Now check the payload for errors
// The callee sends back the return value
@@ -164,13 +165,13 @@ GetMemoryPermissions (
ZeroMem (&SvcArgs, sizeof (ARM_SVC_ARGS));
if (FeaturePcdGet (PcdFfaEnable)) {
// See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ.
SvcArgs.Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH64;
SvcArgs.Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ;
SvcArgs.Arg1 = ARM_FFA_DESTINATION_ENDPOINT_ID;
SvcArgs.Arg2 = 0;
SvcArgs.Arg3 = ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_AARCH64;
SvcArgs.Arg3 = ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES;
SvcArgs.Arg4 = BaseAddress;
} else {
SvcArgs.Arg0 = ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES_AARCH64;
SvcArgs.Arg0 = ARM_SVC_ID_SP_GET_MEM_ATTRIBUTES;
SvcArgs.Arg1 = BaseAddress;
SvcArgs.Arg2 = 0;
SvcArgs.Arg3 = 0;
@@ -219,15 +220,15 @@ RequestMemoryPermissionChange (
ZeroMem (&SvcArgs, sizeof (ARM_SVC_ARGS));
if (FeaturePcdGet (PcdFfaEnable)) {
// See [2], Section 10.2 FFA_MSG_SEND_DIRECT_REQ.
SvcArgs.Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ_AARCH64;
SvcArgs.Arg0 = ARM_SVC_ID_FFA_MSG_SEND_DIRECT_REQ;
SvcArgs.Arg1 = ARM_FFA_DESTINATION_ENDPOINT_ID;
SvcArgs.Arg2 = 0;
SvcArgs.Arg3 = ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES_AARCH64;
SvcArgs.Arg3 = ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES;
SvcArgs.Arg4 = BaseAddress;
SvcArgs.Arg5 = EFI_SIZE_TO_PAGES (Length);
SvcArgs.Arg6 = Permissions;
} else {
SvcArgs.Arg0 = ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES_AARCH64;
SvcArgs.Arg0 = ARM_SVC_ID_SP_SET_MEM_ATTRIBUTES;
SvcArgs.Arg1 = BaseAddress;
SvcArgs.Arg2 = EFI_SIZE_TO_PAGES (Length);
SvcArgs.Arg3 = Permissions;

View File

@@ -16,14 +16,14 @@
LIBRARY_CLASS = StandaloneMmMmuLib
PI_SPECIFICATION_VERSION = 0x00010032
[Sources.AARCH64]
AArch64/ArmMmuStandaloneMmLib.c
[Sources]
ArmMmuStandaloneMmLib.c
[Packages]
ArmPkg/ArmPkg.dec
MdePkg/MdePkg.dec
[FeaturePcd.AARCH64]
[FeaturePcd.ARM, FeaturePcd.AARCH64]
gArmTokenSpaceGuid.PcdFfaEnable
[LibraryClasses]

View File

@@ -13,6 +13,14 @@ OBJECTS = DevicePath.o UefiDevicePathLib.o DevicePathFromText.o DevicePathUtili
include $(MAKEROOT)/Makefiles/app.makefile
GCCVERSION = $(shell gcc -dumpversion | awk -F'.' '{print $$1}')
ifneq ("$(GCCVERSION)", "5")
ifneq ($(CXX), llvm)
# gcc 12 trips over device path handling
BUILD_CFLAGS += -Wno-error=stringop-overflow
endif
endif
LIBS = -lCommon
ifeq ($(CYGWIN), CYGWIN)
LIBS += -L/lib/e2fsprogs -luuid

View File

@@ -542,7 +542,7 @@ GetAlignmentFromFile(char *InFile, UINT32 *Alignment)
PeFileBuffer = (UINT8 *) malloc (PeFileSize);
if (PeFileBuffer == NULL) {
fclose (InFileHandle);
Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of %s", InFileHandle);
Error(NULL, 0, 4001, "Resource", "memory cannot be allocated for %s", InFile);
return EFI_OUT_OF_RESOURCES;
}
fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle);

View File

@@ -34,9 +34,27 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include "FvLib.h"
#include "PeCoffLib.h"
#define ARMT_UNCONDITIONAL_JUMP_INSTRUCTION 0xEB000000
#define ARM64_UNCONDITIONAL_JUMP_INSTRUCTION 0x14000000
/*
* Arm instruction to jump to Fv entry instruction in Arm or Thumb mode.
* From ARM Arch Ref Manual versions b/c/d, section A8.8.25 BL, BLX (immediate)
* BLX (encoding A2) branches to offset in Thumb instruction set mode.
* BL (encoding A1) branches to offset in Arm instruction set mode.
*/
#define ARM_JUMP_OFFSET_MAX 0xffffff
#define ARM_JUMP_TO_ARM(Offset) (0xeb000000 | ((Offset - 8) >> 2))
#define _ARM_JUMP_TO_THUMB(Imm32) (0xfa000000 | \
(((Imm32) & (1 << 1)) << (24 - 1)) | \
(((Imm32) >> 2) & 0x7fffff))
#define ARM_JUMP_TO_THUMB(Offset) _ARM_JUMP_TO_THUMB((Offset) - 8)
/*
* Arm instruction to return from exception (MOVS PC, LR)
*/
#define ARM_RETURN_FROM_EXCEPTION 0xE1B0F07E
BOOLEAN mArm = FALSE;
BOOLEAN mRiscV = FALSE;
STATIC UINT32 MaxFfsAlignment = 0;
@@ -2203,23 +2221,25 @@ Returns:
// if we found an SEC core entry point then generate a branch instruction
// to it and populate a debugger SWI entry as well
if (UpdateVectorSec) {
UINT32 EntryOffset;
VerboseMsg("UpdateArmResetVectorIfNeeded updating ARM SEC vector");
// B SecEntryPoint - signed_immed_24 part +/-32MB offset
// on ARM, the PC is always 8 ahead, so we're not really jumping from the base address, but from base address + 8
ResetVector[0] = (INT32)(SecCoreEntryAddress - FvInfo->BaseAddress - 8) >> 2;
EntryOffset = (INT32)(SecCoreEntryAddress - FvInfo->BaseAddress);
if (ResetVector[0] > 0x00FFFFFF) {
Error(NULL, 0, 3000, "Invalid", "SEC Entry point must be within 32MB of the start of the FV");
if (EntryOffset > ARM_JUMP_OFFSET_MAX) {
Error(NULL, 0, 3000, "Invalid", "SEC Entry point offset above 1MB of the start of the FV");
return EFI_ABORTED;
}
// Add opcode for an unconditional branch with no link. i.e.: " B SecEntryPoint"
ResetVector[0] |= ARMT_UNCONDITIONAL_JUMP_INSTRUCTION;
if ((SecCoreEntryAddress & 1) != 0) {
ResetVector[0] = ARM_JUMP_TO_THUMB(EntryOffset);
} else {
ResetVector[0] = ARM_JUMP_TO_ARM(EntryOffset);
}
// SWI handler movs pc,lr. Just in case a debugger uses SWI
ResetVector[2] = 0xE1B0F07E;
ResetVector[2] = ARM_RETURN_FROM_EXCEPTION;
// Place holder to support a common interrupt handler from ROM.
// Currently not supported. For this to be used the reset vector would not be in this FV

View File

@@ -1062,7 +1062,7 @@ GetAlignmentFromFile(char *InFile, UINT32 *Alignment)
PeFileBuffer = (UINT8 *) malloc (PeFileSize);
if (PeFileBuffer == NULL) {
fclose (InFileHandle);
Error(NULL, 0, 4001, "Resource", "memory cannot be allocated of %s", InFileHandle);
Error(NULL, 0, 4001, "Resource", "memory cannot be allocated for %s", InFile);
return EFI_OUT_OF_RESOURCES;
}
fread (PeFileBuffer, sizeof (UINT8), PeFileSize, InFileHandle);

View File

@@ -2825,12 +2825,13 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, BoolInt reInit,
nowPos64 = p->nowPos64;
RangeEnc_Init(&p->rc);
p->rc.outStream = &outStream.vt;
if (desiredPackSize == 0)
return SZ_ERROR_OUTPUT_EOF;
p->rc.outStream = &outStream.vt;
res = LzmaEnc_CodeOneBlock(p, desiredPackSize, *unpackSize);
p->rc.outStream = NULL;
*unpackSize = (UInt32)(p->nowPos64 - nowPos64);
*destLen -= outStream.rem;

View File

@@ -152,11 +152,11 @@ class CompressedImage(Image):
try:
TmpData = DeCompress('Efi', self[self._HEADER_SIZE_:])
DecData = array('B')
DecData.fromstring(TmpData)
DecData.frombytes(TmpData)
except:
TmpData = DeCompress('Framework', self[self._HEADER_SIZE_:])
DecData = array('B')
DecData.fromstring(TmpData)
DecData.frombytes(TmpData)
SectionList = []
Offset = 0
@@ -196,7 +196,7 @@ class Ui(Image):
return len(self)
def _GetUiString(self):
return codecs.utf_16_decode(self[0:-2].tostring())[0]
return codecs.utf_16_decode(self[0:-2].tobytes())[0]
String = property(_GetUiString)
@@ -738,7 +738,7 @@ class GuidDefinedImage(Image):
Offset = self.DataOffset - 4
TmpData = DeCompress('Framework', self[self.Offset:])
DecData = array('B')
DecData.fromstring(TmpData)
DecData.frombytes(TmpData)
Offset = 0
while Offset < len(DecData):
Sec = Section()
@@ -759,7 +759,7 @@ class GuidDefinedImage(Image):
TmpData = DeCompress('Lzma', self[self.Offset:])
DecData = array('B')
DecData.fromstring(TmpData)
DecData.frombytes(TmpData)
Offset = 0
while Offset < len(DecData):
Sec = Section()

View File

@@ -155,7 +155,7 @@ ConvertAsn1TimeToEfiTime (
}
Str = (CONST CHAR8*)Asn1Time->data;
SetMem (EfiTime, 0, sizeof (EFI_TIME));
SetMem (EfiTime, sizeof (EFI_TIME), 0);
Index = 0;
if (Asn1Time->type == V_ASN1_UTCTIME) { /* two digit year */

View File

@@ -224,7 +224,7 @@ DmaMap (
goto FreeMapInfo;
}
if (Map->Operation == MapOperationBusMasterRead) {
if (Operation == MapOperationBusMasterRead) {
CopyMem (Map->BufferAddress, (VOID *)(UINTN)HostAddress, *NumberOfBytes);
}
mCpu->FlushDataCache (mCpu, (UINTN)Map->BufferAddress, AllocSize,

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,
@@ -211,7 +219,7 @@ UpdateFrontPageForm (
//
StartGuidLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
StartGuidLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
StartGuidLabel->Number = LABEL_FRANTPAGE_INFORMATION;
StartGuidLabel->Number = LABEL_FRONTPAGE_INFORMATION;
//
// Create Hii Extend Label OpCode as the end opcode
//
@@ -239,6 +247,124 @@ UpdateFrontPageForm (
HiiFreeOpCodeHandle (EndOpCodeHandle);
}
// FIXME: Copied from Device Manager; clean up
void ShowSecureBootConfig(void)
{
void *StartHandle;
void *EndHandle;
EFI_IFR_GUID_LABEL *StartLabel;
EFI_IFR_GUID_LABEL *EndLabel;
EFI_HII_HANDLE *HiiHandles;
EFI_HII_HANDLE HiiHandle = gFrontPagePrivate.HiiHandle;
UINTN Index;
EFI_STRING String;
EFI_STRING_ID Token;
EFI_STRING_ID TokenHelp;
EFI_IFR_FORM_SET *Buffer = NULL;
UINTN BufferSize = 0;
UINT8 ClassGuidNum;
EFI_GUID *ClassGuid;
UINTN TempSize = 0;
UINT8 *Ptr;
EFI_STATUS Status;
// XXX: Copied from SecureBootConfigDxe
EFI_GUID SecureBootConfigGuid = { 0x5daf50a5, 0xea81, 0x4de2, {0x8f, 0x9b, 0xca, 0xbd, 0xa9, 0xcf, 0x5c, 0x14}};
StartHandle = HiiAllocateOpCodeHandle();
ASSERT(StartHandle != NULL);
EndHandle = HiiAllocateOpCodeHandle();
ASSERT(EndHandle != NULL);
StartLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode(StartHandle, &gEfiIfrTianoGuid, NULL, sizeof(*StartLabel));
StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
StartLabel->Number = LABEL_DEVICES_LIST;
EndLabel = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode(EndHandle, &gEfiIfrTianoGuid, NULL, sizeof(*EndLabel));
EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
EndLabel->Number = LABEL_END;
// Get SecureBootConfig handle
HiiHandles = HiiGetHiiHandles(&SecureBootConfigGuid);
ASSERT(HiiHandles != NULL);
// Search for formset of each class type
for (Index = 0; HiiHandles[Index] != NULL; Index++) {
Status = HiiGetFormSetFromHiiHandle(HiiHandles[Index], &Buffer, &BufferSize);
if (EFI_ERROR(Status)) {
continue;
}
Ptr = (UINT8 *)Buffer;
while (TempSize < BufferSize) {
TempSize += ((EFI_IFR_OP_HEADER *)Ptr)->Length;
if (((EFI_IFR_OP_HEADER *)Ptr)->Length <= OFFSET_OF (EFI_IFR_FORM_SET, Flags)) {
Ptr += ((EFI_IFR_OP_HEADER *)Ptr)->Length;
continue;
}
ClassGuidNum = (UINT8)(((EFI_IFR_FORM_SET *)Ptr)->Flags & 0x3);
ClassGuid = (EFI_GUID *)(VOID *)(Ptr + sizeof(EFI_IFR_FORM_SET));
while (ClassGuidNum-- > 0) {
if (CompareGuid(&gEfiHiiPlatformSetupFormsetGuid, ClassGuid) == 0) {
ClassGuid++;
continue;
}
String = HiiGetString(HiiHandles[Index], ((EFI_IFR_FORM_SET *)Ptr)->FormSetTitle, NULL);
if (String == NULL) {
String = HiiGetString(HiiHandle, STRING_TOKEN (STR_MISSING_STRING), NULL);
ASSERT (String != NULL);
}
Token = HiiSetString(HiiHandle, 0, String, NULL);
FreePool(String);
String = HiiGetString(HiiHandles[Index], ((EFI_IFR_FORM_SET *)Ptr)->Help, NULL);
if (String == NULL) {
String = HiiGetString(HiiHandle, STRING_TOKEN (STR_MISSING_STRING), NULL);
ASSERT(String != NULL);
}
TokenHelp = HiiSetString(HiiHandle, 0, String, NULL);
FreePool(String);
HiiCreateGotoExOpCode(
StartHandle,
0,
Token,
TokenHelp,
0,
0,
0,
&SecureBootConfigGuid,
0
);
break;
}
Ptr += ((EFI_IFR_OP_HEADER *)Ptr)->Length;
}
FreePool (Buffer);
Buffer = NULL;
TempSize = 0;
BufferSize = 0;
}
HiiUpdateForm(
HiiHandle,
&mFrontPageGuid,
FRONT_PAGE_FORM_ID,
StartHandle,
EndHandle
);
HiiFreeOpCodeHandle(StartHandle);
HiiFreeOpCodeHandle(EndHandle);
}
/**
Initialize HII information for the FrontPage
@@ -297,6 +423,8 @@ InitializeFrontPage (
//
UpdateFrontPageForm();
ShowSecureBootConfig();
return Status;
}
@@ -367,10 +495,6 @@ FreeFrontPage(
// Publish our HII data
//
HiiRemovePackages (gFrontPagePrivate.HiiHandle);
if (gFrontPagePrivate.LanguageToken != NULL) {
FreePool (gFrontPagePrivate.LanguageToken);
gFrontPagePrivate.LanguageToken = NULL;
}
}
/**
@@ -492,6 +616,462 @@ 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);
}
}
/**
@@ -503,154 +1083,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_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;
TmpBuffer = AllocateZeroPool (0x60);
VersionIdx = SmbiosTable.Type0->BiosVersion;
GetOptionalStringByIndex ((CHAR8*)((UINT8*)SmbiosTable.Raw + SmbiosTable.Hdr->Length), VersionIdx, &FwVersion);
StrCatS (TmpBuffer, 0x60 / sizeof (CHAR16), L"Version: ");
StrCatS (TmpBuffer, 0x60 / sizeof (CHAR16), FwVersion);
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_BIOS_VERSION);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, TmpBuffer, NULL);
FreePool (FwVersion);
FreePool (TmpBuffer);
}
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);
}
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;
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);
Title = AllocateZeroPool (0x60);
Model = AllocateZeroPool (0x60);
ConvertProcessorToString(Type4Record->CurrentSpeed, 6, &NewString);
UiCustomizeFrontPageBanner (2, FALSE, &NewString);
HiiSetString (gFrontPagePrivate.HiiHandle, STRING_TOKEN (STR_FRONT_PAGE_CPU_SPEED), NewString, NULL);
FreePool (NewString);
ManIdx = SmbiosTable.Type1->Manufacturer;
ModelIdx = SmbiosTable.Type1->ProductName;
FoundCpu = TRUE;
}
}
GetOptionalStringByIndex ((CHAR8*)((UINT8*)SmbiosTable.Raw + SmbiosTable.Hdr->Length), ModelIdx, &ProductName);
GetOptionalStringByIndex ((CHAR8*)((UINT8*)SmbiosTable.Raw + SmbiosTable.Hdr->Length), ManIdx, &Manufacturer);
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);
}
}
StrCatS (Title, 0x60 / sizeof (CHAR16), Manufacturer);
StrCatS (Title, 0x60 / sizeof (CHAR16), L" ");
StrCatS (Title, 0x60 / sizeof (CHAR16), ProductName);
Status = Smbios->GetNext (Smbios, &SmbiosHandle, NULL, &Record, NULL);
}
TokenToUpdate = STRING_TOKEN (STR_FRONT_PAGE_TITLE);
HiiSetString (gFrontPagePrivate.HiiHandle, TokenToUpdate, Title, NULL);
//
// 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);
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);
}
}
/**
@@ -892,6 +1404,8 @@ InitializeUserInterface (
UINTN BootTextColumn;
UINTN BootTextRow;
gSystemTable = SystemTable;
if (!mModeInitialized) {
//
// After the console is ready, get current video resolution
@@ -1017,11 +1531,6 @@ UiEntry (
FreeFrontPage ();
if (mLanguageString != NULL) {
FreePool (mLanguageString);
mLanguageString = NULL;
}
//
//Will leave browser, check any reset required change is applied? if yes, reset system
//
@@ -1034,10 +1543,6 @@ UiEntry (
// user change any option setting which needs a reset to be effective, and the reset will be applied according to the user selection.
//
/**
Record the info that a reset is required.
A module boolean variable is used to record whether a reset is required.
@@ -1052,10 +1557,6 @@ EnableResetRequired (
mResetRequired = TRUE;
}
/**
Check if user changed any option setting which needs a system reset to be effective.
@@ -1110,4 +1611,3 @@ SetupResetReminder (
gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
}
}

View File

@@ -32,9 +32,11 @@ 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 FIRMWARE_INFO_FORM_ID 0x7601
#define LABEL_FRANTPAGE_INFORMATION 0x1000
#define LABEL_FRONTPAGE_INFORMATION 0x1000
#define LABEL_DEVICES_LIST 0x2000
#define LABEL_END 0xffff
#define FRONT_PAGE_FORMSET_GUID \
@@ -52,7 +54,6 @@ typedef struct {
//
EFI_HII_HANDLE HiiHandle;
EFI_HANDLE DriverHandle;
EFI_STRING_ID *LanguageToken;
//
// Produced protocols
@@ -210,4 +211,3 @@ ExtractDevicePathFromHiiHandle (
);
#endif // _FRONT_PAGE_H_

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,44 +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,10 @@ 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.
@@ -181,19 +77,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;
}
return TRUE;
}
@@ -220,17 +109,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;
}
@@ -239,156 +117,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.
@@ -405,8 +133,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
);
@@ -425,30 +153,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,9 +9,11 @@
#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_FRANTPAGE_INFORMATION 0x1000
#define LABEL_FRONTPAGE_INFORMATION 0x1000
#define LABEL_DEVICES_LIST 0x2000
#define LABEL_END 0xffff
formset
@@ -23,58 +25,45 @@ formset
form formid = FRONT_PAGE_FORM_ID,
title = STRING_TOKEN(STR_FRONT_PAGE_TITLE);
banner
title = STRING_TOKEN(STR_FRONT_PAGE_COMPUTER_MODEL),
line 1,
align left;
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);
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;
label LABEL_FRANTPAGE_INFORMATION;
label LABEL_FRONTPAGE_INFORMATION;
//
// This is where we will dynamically add a Action type op-code to show
// the platform information.
//
label LABEL_END;
subtitle text = STRING_TOKEN(STR_EMPTY_STRING);
label LABEL_DEVICES_LIST;
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);
subtitle text = STRING_TOKEN(STR_EMPTY_STRING);
endform;
endformset;

View File

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

View File

@@ -1709,13 +1709,7 @@ InitKeyboard (
//
// wait for BAT completion code
//
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

@@ -521,16 +521,35 @@ EmmcTuningClkForHs200 (
if (EFI_ERROR (Status)) {
return Status;
}
if(BhtHostPciSupport(PciIo)) {
//set data transfer with 4bit
Status = SdMmcHcSetBusWidth (PciIo, Slot, 4);
//enable hardware tuning
HostCtrl2 = (UINT8)(~0x10);
Status = SdMmcHcAndMmio (PciIo, Slot, 0x110,sizeof (HostCtrl2), &HostCtrl2);
Status = EmmcSendTuningBlk (PassThru, Slot, 4);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "EmmcTuningClkForHs200: Send tuning block fails with %r\n", Status));
return Status;
}
}
//
// Ask the device to send a sequence of tuning blocks till the tuning procedure is done.
//
Retry = 0;
do {
if(!BhtHostPciSupport(PciIo)) {
Status = EmmcSendTuningBlk (PassThru, Slot, BusWidth);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "EmmcTuningClkForHs200: Send tuning block fails with %r\n", Status));
return Status;
}
} else {
gBS->Stall(5000);
}
Status = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, TRUE, sizeof (HostCtrl2), &HostCtrl2);
if (EFI_ERROR (Status)) {
@@ -542,6 +561,10 @@ EmmcTuningClkForHs200 (
}
if ((HostCtrl2 & (BIT6 | BIT7)) == BIT7) {
if(BhtHostPciSupport(PciIo)) {
//set data transfer with default
Status = SdMmcHcSetBusWidth (PciIo, Slot, BusWidth);
}
return EFI_SUCCESS;
}
} while (++Retry < 40);
@@ -874,10 +897,54 @@ EmmcSwitchToHS200 (
return Status;
}
if (BhtHostPciSupport(PciIo)){
BusMode->BusTiming = SdMmcMmcHs200;
Status = EmmcSwitchBusTiming (PciIo, PassThru, Slot, Rca, BusMode->DriverStrength,
BusMode->BusTiming, BusMode->ClockFreq);
if (EFI_ERROR (Status)) {
return Status;
}
Status = SdMmcHcWaitMmioSet (
PciIo,
Slot,
0x1cc,
sizeof (Rca),
BIT14,
BIT14,
SD_MMC_HC_GENERIC_TIMEOUT
);
if (EFI_ERROR (Status)) {
return Status;
}
//Wait 2nd Card Detect debounce Finished by wait twice of debounce max time
UINT32 value32;
while (1) {
Status = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_PRESENT_STATE, TRUE, sizeof(value32), &value32);
if (((value32 >> 18) & 0x01) == ((value32 >> 16) & 0x01)) {
break;
}
}
Status = SdMmcHcWaitMmioSet (
PciIo,
Slot,
0x1cc,
sizeof (Rca),
BIT11,
BIT11,
SD_MMC_CLOCK_STABLE_TIMEOUT
);
if (EFI_ERROR(Status)) {
return Status;
}
} else {
Status = EmmcSwitchBusTiming (PciIo, PassThru, Slot, Rca, BusMode->DriverStrength, BusMode->BusTiming, BusMode->ClockFreq);
if (EFI_ERROR (Status)) {
return Status;
}
}
Status = EmmcTuningClkForHs200 (PciIo, PassThru, Slot, BusMode->BusWidth);
@@ -1263,10 +1330,89 @@ EmmcSetBusMode (
DEBUG ((DEBUG_INFO, "EmmcSetBusMode: Target bus mode: timing = %d, width = %d, clock freq = %d, driver strength = %d\n",
BusMode.BusTiming, BusMode.BusWidth, BusMode.ClockFreq, BusMode.DriverStrength.Emmc));
if (BhtHostPciSupport(PciIo)) {
UINT8 EmmcVar;
UINTN EmmcVarSize;
Status = gRT->GetVariable (
L"EMMC_FORCE_CARD_MODE",
&gEfiGenericVariableGuid,
NULL,
&EmmcVarSize,
&EmmcVar
);
if (!EFI_ERROR(Status) && EmmcVar <= 2) {
if (EmmcVar == 2) {
BusMode.BusTiming = SdMmcMmcHs200;
BusMode.ClockFreq = 200;
} else if (EmmcVar == 1) {
BusMode.BusTiming = SdMmcMmcHs200;
BusMode.ClockFreq = 100;
} else {
BusMode.BusTiming = SdMmcMmcHsSdr;
BusMode.ClockFreq = 52;
}
} else {
BusMode.BusTiming = SdMmcMmcHsSdr;
BusMode.ClockFreq = 52;
}
}
if (BusMode.BusTiming == SdMmcMmcHs400) {
//
// Execute HS400 timing switch procedure
//
Status = EmmcSwitchToHS400 (PciIo, PassThru, Slot, Rca, &BusMode);
} else if (BusMode.BusTiming == SdMmcMmcHs200) {
//
// Execute HS200 timing switch procedure
//
Status = EmmcSwitchToHS200 (PciIo, PassThru, Slot, Rca, &BusMode);
if (EFI_ERROR(Status)) {
if (BhtHostPciSupport(PciIo)) {
UINT32 val32;
UINT16 EmmcVar;
UINTN EmmcVarSize;
#if !defined(HS100_ALLPASS_PHASE) || HS100_ALLPASS_PHASE > 10 || HS100_ALLPASS_PHASE < 0
#error "HS100_ALLPASS_PHASE is undefined or value is invalid"
#else
val32 = PciBhtRead32(PciIo, 0x300);
val32 &= 0xFF0FFFFF;
EmmcVarSize = sizeof(EmmcVar);
Status = gRT->GetVariable (
L"EMMC_HS100_ALLPASS_PHASE",
&gEfiGenericVariableGuid,
NULL,
&EmmcVarSize,
&EmmcVar
);
if (EFI_ERROR(Status) || EmmcVar > 10)
EmmcVar = HS100_ALLPASS_PHASE;
val32 |= (EmmcVar << 20);
PciBhtWrite32(PciIo, 0x300, 0x21000033 | val32);
#endif
BusMode.ClockFreq = 100;
SdMmcHcRwMmio (PciIo, Slot, 0x3C, TRUE, sizeof(val32), &val32);
val32 &= ~BIT22;
SdMmcHcRwMmio (PciIo, Slot, 0x3C, FALSE, sizeof(val32), &val32);
val32 = (BIT26 | BIT25);
SdMmcHcOrMmio (PciIo, Slot, 0x2C, sizeof(val32), &val32);
Status = EmmcSwitchToHS200 (PciIo, PassThru, Slot, Rca, &BusMode);
if (EFI_ERROR(Status)) {
if (((ExtCsd.DeviceType & BIT1) != 0) && (Private->Capability[Slot].HighSpeed != 0)) {
BusMode.BusTiming = SdMmcMmcHsSdr;
BusMode.ClockFreq = 52;
Status = EmmcSwitchToHighSpeed (PciIo, PassThru, Slot, Rca, &BusMode);
} else if (((ExtCsd.DeviceType & BIT0) != 0) && (Private->Capability[Slot].HighSpeed != 0)) {
BusMode.BusTiming = SdMmcMmcHsSdr;
BusMode.ClockFreq = 26;
Status = EmmcSwitchToHighSpeed (PciIo, PassThru, Slot, Rca, &BusMode);
}
}
}
}
} else {
//
// Note that EmmcSwitchToHighSpeed is also called for SdMmcMmcLegacy

View File

@@ -305,6 +305,13 @@ SdMmcPciHcEnumerateDevice (
continue;
}
if (BhtHostPciSupport(Private->PciIo)) {
Status = SdMmcHcGetCapability (Private->PciIo, Slot, &Private->Capability[Slot]);
if (EFI_ERROR (Status)) {
continue;
}
}
Private->Slot[Slot].MediaPresent = TRUE;
Private->Slot[Slot].Initialized = TRUE;
RoutineNum = sizeof (mCardTypeDetectRoutineTable) / sizeof (CARD_TYPE_DETECT_ROUTINE);
@@ -321,6 +328,7 @@ SdMmcPciHcEnumerateDevice (
// This card doesn't get initialized correctly.
//
if (Index == RoutineNum) {
DEBUG ((DEBUG_INFO, "Load driver failure\n"));
Private->Slot[Slot].Initialized = FALSE;
}
@@ -541,6 +549,8 @@ SdMmcPciHcDriverBindingStart (
UINT32 RoutineNum;
BOOLEAN MediaPresent;
BOOLEAN Support64BitDma;
UINT16 IntStatus;
UINT32 value;
DEBUG ((DEBUG_INFO, "SdMmcPciHcDriverBindingStart: Start\n"));
@@ -735,6 +745,13 @@ SdMmcPciHcDriverBindingStart (
continue;
}
if (BhtHostPciSupport(PciIo)) {
Status = SdMmcHcGetCapability (PciIo, Slot, &Private->Capability[Slot]);
if (EFI_ERROR (Status)) {
continue;
}
}
Private->Slot[Slot].MediaPresent = TRUE;
Private->Slot[Slot].Initialized = TRUE;
RoutineNum = sizeof (mCardTypeDetectRoutineTable) / sizeof (CARD_TYPE_DETECT_ROUTINE);
@@ -751,9 +768,25 @@ SdMmcPciHcDriverBindingStart (
// This card doesn't get initialized correctly.
//
if (Index == RoutineNum) {
DEBUG ((DEBUG_INFO, "Load driver failure\n"));
Private->Slot[Slot].Initialized = FALSE;
}
}
if (BhtHostPciSupport(Private->PciIo)) {
SdMmcHcRwMmio (Private->PciIo,0,0x110,TRUE,sizeof (value),&value);
SdMmcHcRwMmio (Private->PciIo,0,0x114,TRUE,sizeof (value),&value);
SdMmcHcRwMmio (Private->PciIo,0,0x1a8,TRUE,sizeof (value),&value);
SdMmcHcRwMmio (Private->PciIo,0,0x1ac,TRUE,sizeof (value),&value);
SdMmcHcRwMmio (Private->PciIo,0,0x1B0,TRUE,sizeof (value),&value);
SdMmcHcRwMmio (Private->PciIo,0,0x1CC,TRUE,sizeof (value),&value);
SdMmcHcRwMmio (Private->PciIo,0,0x040,TRUE,sizeof (value),&value);
SdMmcHcRwMmio (Private->PciIo,0,SD_MMC_HC_PRESENT_STATE,TRUE,sizeof (value),&value);
SdMmcHcRwMmio (Private->PciIo,0,SD_MMC_HC_HOST_CTRL1,TRUE,sizeof (IntStatus),&IntStatus);
SdMmcHcRwMmio (Private->PciIo,0,SD_MMC_HC_CLOCK_CTRL,TRUE,sizeof (IntStatus),&IntStatus);
SdMmcHcRwMmio (Private->PciIo,0,SD_MMC_HC_TIMEOUT_CTRL,TRUE,sizeof (IntStatus),&IntStatus);
SdMmcHcRwMmio (Private->PciIo,0,SD_MMC_HC_NOR_INT_STS,TRUE,sizeof (value),&value);
SdMmcHcRwMmio (Private->PciIo,0,SD_MMC_HC_HOST_CTRL2,TRUE,sizeof (IntStatus),&IntStatus);
}
//
// Enable 64-bit DMA support in the PCI layer if this controller

View File

@@ -20,6 +20,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/UefiDriverEntryPoint.h>
#include <Library/DebugLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiLib.h>
@@ -33,6 +34,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Protocol/SdMmcOverride.h>
#include <Protocol/SdMmcPassThru.h>
#include <Guid/DebugMask.h>
#include "SdMmcPciHci.h"
extern EFI_COMPONENT_NAME_PROTOCOL gSdMmcPciHcComponentName;
@@ -46,10 +49,16 @@ extern EDKII_SD_MMC_OVERRIDE *mOverride;
#define SD_MMC_HC_PRIVATE_FROM_THIS(a) \
CR(a, SD_MMC_HC_PRIVATE_DATA, PassThru, SD_MMC_HC_PRIVATE_SIGNATURE)
#define HOST_CLK_DRIVE_STRENGTH 2
#define HOST_DAT_DRIVE_STRENGTH 2
#define HS200_ALLPASS_PHASE 0
#define HS100_ALLPASS_PHASE 6
//
// Generic time out value, 1 microsecond as unit.
//
#define SD_MMC_HC_GENERIC_TIMEOUT 1 * 1000 * 1000
#define SD_MMC_HC_GENERIC_TIMEOUT 1 * 1000 * 100
#define SD_MMC_CLOCK_STABLE_TIMEOUT 3 * 1000
//
// SD/MMC async transfer timer interval, set by experience.

View File

@@ -14,12 +14,12 @@
##
[Defines]
INF_VERSION = 0x00010005
INF_VERSION = 0x00010007
BASE_NAME = SdMmcPciHcDxe
MODULE_UNI_FILE = SdMmcPciHcDxe.uni
FILE_GUID = 8E325979-3FE1-4927-AAE2-8F5C4BD2AF0D
MODULE_TYPE = UEFI_DRIVER
VERSION_STRING = 1.0
VERSION_STRING = 1.5.4
ENTRY_POINT = InitializeSdMmcPciHcDxe
#
@@ -63,6 +63,9 @@
gEfiPciIoProtocolGuid ## TO_START
gEfiSdMmcPassThruProtocolGuid ## BY_START
[Guids]
gEfiGenericVariableGuid
# [Event]
# EVENT_TYPE_PERIODIC_TIMER ## SOMETIMES_CONSUMES

View File

@@ -14,6 +14,9 @@
#include "SdMmcPciHcDxe.h"
int g_deviceId = 0;
/**
Dump the content of SD/MMC host controller's Capability Register.
@@ -1145,6 +1148,15 @@ SdMmcHcInitPowerVoltage (
// Set SD Bus Voltage Select and SD Bus Power fields in Power Control Register
//
Status = SdMmcHcPowerControl (PciIo, Slot, MaxVoltage);
if (BhtHostPciSupport(PciIo)){
// 1.8V signaling enable
HostCtrl2 = BIT3;
Status = SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_HOST_CTRL2, sizeof (HostCtrl2), &HostCtrl2);
gBS->Stall (5000);
if (EFI_ERROR (Status)) {
return Status;
}
}
return Status;
}
@@ -1196,6 +1208,7 @@ SdMmcHcInitHost (
EFI_STATUS Status;
EFI_PCI_IO_PROTOCOL *PciIo;
SD_MMC_HC_SLOT_CAP Capability;
UINT32 value32;
//
// Notify the SD/MMC override protocol that we are about to initialize
@@ -1218,10 +1231,192 @@ SdMmcHcInitHost (
PciIo = Private->PciIo;
Capability = Private->Capability[Slot];
if (BhtHostPciSupport(PciIo)){
UINT8 CardMode;
UINT16 EmmcVar;
UINTN EmmcVarSize;
UINT64 Cap;
//unlock PCR write protect
#ifdef DISABLE_L1_2
PciBhtAnd32(PciIo, 0xd0, ~(BIT31));
PciBhtAnd32(PciIo, 0x90, ~(BIT1 | BIT0));
value32 = PciBhtRead32(PciIo, 0xe0);
value32 &= ~(BIT31 | BIT30 | BIT29 | BIT28);
value32 |= (BIT29 | BIT28);
PciBhtWrite32(PciIo, 0xe0, value32);
value32 = PciBhtRead32(PciIo, 0xfc);
value32 &= ~(BIT19 | BIT18 | BIT17 | BIT16);
value32 |= (BIT19);
PciBhtWrite32(PciIo, 0xfc, value32);
value32 = PciBhtRead32(PciIo, 0x3f4);
value32 &= ~(BIT3 | BIT2 | BIT1 | BIT0);
value32 |= (BIT3 | BIT1);
PciBhtWrite32(PciIo, 0x3f4, value32);
value32 = PciBhtRead32(PciIo, 0x248);
value32 &= ~(BIT3 | BIT2 | BIT1 | BIT0);
value32 |= (BIT3 | BIT1);
PciBhtWrite32(PciIo, 0x248, value32);
value32 = PciBhtRead32(PciIo, 0x90);
value32 &= ~(BIT1 | BIT0);
value32 |= (BIT1);
PciBhtWrite32(PciIo, 0x90, value32);
#endif
/* FET on */
PciBhtOr32(PciIo, 0xEC, 0x3);
/* Led on */
//PciBhtAnd32(PciIo, 0x334, (UINT32)~BIT13);
PciBhtOr32(PciIo, 0xD4, BIT6);
/* Set 1.8v emmc signaling flag */
PciBhtOr32(PciIo, 0x308, BIT4);
/* Set 200MBaseClock */
value32 = PciBhtRead32(PciIo, 0x304);
value32 &= 0x0000FFFF;
value32 |= 0x25100000;
#if !defined(HOST_CLK_DRIVE_STRENGTH) || HOST_CLK_DRIVE_STRENGTH > 7 || HOST_CLK_DRIVE_STRENGTH < 0
#error "HOST_CMD_DRIVE_STRENGTH is undefined or value is invalid"
#else
EmmcVarSize = sizeof(EmmcVar);
Status = gRT->GetVariable (
L"EMMC_CLK_DRIVER_STRENGTH",
&gEfiGenericVariableGuid,
NULL,
&EmmcVarSize,
&EmmcVar
);
if (EFI_ERROR(Status)) {
EmmcVar = HOST_CLK_DRIVE_STRENGTH;
}
value32 &= 0xFFFFFF8F;
value32 |= ((EmmcVar & 0x7) << 4);
#endif
#if !defined(HOST_DAT_DRIVE_STRENGTH) || HOST_DAT_DRIVE_STRENGTH > 7 || HOST_DAT_DRIVE_STRENGTH < 0
#error "HOST_DATA_DRIVE_STRENGTH is undefined or value is invalid"
#else
EmmcVarSize = sizeof(EmmcVar);
Status = gRT->GetVariable (
L"EMMC_DATA_DRIVER_STRENGTH",
&gEfiGenericVariableGuid,
NULL,
&EmmcVarSize,
&EmmcVar
);
if (EFI_ERROR(Status)) {
EmmcVar = HOST_DAT_DRIVE_STRENGTH;
}
value32 &= 0xFFFFFFF1;
value32 |= ((EmmcVar & 0x7) << 1);
#endif
PciBhtWrite32(PciIo, 0x304, value32);
PciBhtOr32(PciIo, 0x3E4, BIT22);
EmmcVarSize = sizeof(CardMode);
Status = gRT->GetVariable (
L"EMMC_FORCE_CARD_MODE",
&gEfiGenericVariableGuid,
NULL,
&EmmcVarSize,
&CardMode
);
if (EFI_ERROR(Status) || CardMode > 2) {
CardMode = 0;
}
if (CardMode == 1) {
#if !defined(HS100_ALLPASS_PHASE) || HS100_ALLPASS_PHASE > 10 || HS100_ALLPASS_PHASE < 0
#error "HS200_ALLPASS_PHASE is undefined or value is invalid"
#else
EmmcVarSize = sizeof(EmmcVar);
Status = gRT->GetVariable (
L"EMMC_HS100_ALLPASS_PHASE",
&gEfiGenericVariableGuid,
NULL,
&EmmcVarSize,
&EmmcVar
);
if (EFI_ERROR(Status) || EmmcVar > 10) {
EmmcVar = HS100_ALLPASS_PHASE;
}
#endif
} else if (CardMode == 2) {
#if !defined(HS200_ALLPASS_PHASE) || HS200_ALLPASS_PHASE > 10 || HS200_ALLPASS_PHASE < 0
#error "HS200_ALLPASS_PHASE is undefined or value is invalid"
#else
EmmcVarSize = sizeof(EmmcVar);
Status = gRT->GetVariable (
L"EMMC_HS200_ALLPASS_PHASE",
&gEfiGenericVariableGuid,
NULL,
&EmmcVarSize,
&EmmcVar
);
if (EFI_ERROR(Status) || EmmcVar > 10) {
EmmcVar = HS200_ALLPASS_PHASE;
}
#endif
}
value32 = 0x21000033 | (EmmcVar << 20);
PciBhtWrite32(PciIo, 0x300, value32);
//enable internal clk
value32 = BIT0;
Status = SdMmcHcOrMmio (PciIo, Slot, SD_MMC_HC_CLOCK_CTRL,sizeof(value32), &value32);
//reset pll start
Status = SdMmcHcRwMmio (PciIo, Slot, 0x1CC, TRUE, sizeof(value32), &value32);
value32 |= BIT12;
Status = SdMmcHcRwMmio (PciIo, Slot, 0x1CC, FALSE, sizeof(value32), &value32);
gBS->Stall(1);
//reset pll end
Status = SdMmcHcRwMmio (PciIo, Slot, 0x1CC, TRUE,sizeof(value32), &value32);
value32 &= ~BIT12;
value32 |= BIT18;
Status = SdMmcHcRwMmio (PciIo, Slot, 0x1CC, FALSE, sizeof(value32), &value32);
//wait BaseClk stable 0x1CC bit14
Status = SdMmcHcRwMmio (PciIo, Slot, 0x1CC, TRUE, sizeof(value32), &value32);
while(!(value32&BIT14)){
gBS->Stall(100);
Status = SdMmcHcRwMmio (PciIo, Slot, 0x1CC, TRUE, sizeof(value32), &value32);
}
if (value32 & BIT18) {
//Wait 2nd Card Detect debounce Finished by wait twice of debounce max time
while (1) {
Status = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_PRESENT_STATE, TRUE, sizeof(value32), &value32);
if (((value32 >> 16) & 0x01) == ((value32 >> 18) & 0x01))
break;
}
//force pll active end
Status = SdMmcHcRwMmio (PciIo, Slot, 0x1CC, TRUE, sizeof(value32), &value32);
value32 &= ~BIT18;
Status = SdMmcHcRwMmio (PciIo, Slot, 0x1CC, FALSE, sizeof(value32), &value32);
}
Status = SdMmcHcRwMmio (PciIo, Slot, SD_MMC_HC_CAP, TRUE, sizeof (Cap), &Cap);
if (EFI_ERROR (Status)) {
return Status;
}
CopyMem (&Capability, &Cap, sizeof (Cap));
Status = SdMmcHcInitPowerVoltage (PciIo, Slot, Capability);
if (EFI_ERROR (Status)) {
return Status;
}
} else {
Status = SdMmcHcInitV4Enhancements (PciIo, Slot, Capability, Private->ControllerVersion[Slot]);
if (EFI_ERROR (Status)) {
return Status;
}
}
//
// Perform first time clock setup with 400 KHz frequency.
@@ -1235,10 +1430,12 @@ SdMmcHcInitHost (
return Status;
}
if (!BhtHostPciSupport(PciIo)){
Status = SdMmcHcInitPowerVoltage (PciIo, Slot, Capability);
if (EFI_ERROR (Status)) {
return Status;
}
}
Status = SdMmcHcInitTimeoutCtrl (PciIo, Slot);
if (EFI_ERROR (Status)) {
@@ -2836,3 +3033,279 @@ SdMmcWaitTrbResult (
return EFI_TIMEOUT;
}
BOOLEAN BhtHostPciSupport(EFI_PCI_IO_PROTOCOL *PciIo)
{
PCI_TYPE00 Pci;
PciIo->Pci.Read (PciIo, EfiPciIoWidthUint32,
0, sizeof Pci / sizeof (UINT32), &Pci);
DEBUG ((DEBUG_INFO, "check device %04x:%04x\n", Pci.Hdr.VendorId, Pci.Hdr.DeviceId));
if (Pci.Hdr.VendorId != 0x1217)
goto end;
switch (Pci.Hdr.DeviceId)
{
case 0x8420: //PCI_DEV_ID_SDS0
case 0x8421: //PCI_DEV_ID_SDS1
case 0x8520: //PCI_DEV_ID_FJ2
case 0x8620: //PCI_DEV_ID_SB0
case 0x8621: //PCI_DEV_ID_SB1
g_deviceId = Pci.Hdr.DeviceId;
return 1;
default:
break;
}
end:
return 0;
}
void DbgNull(IN CONST CHAR16 * fmt, ...)
{
}
UINT32 bht_readl(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 offset)
{
UINT32 arg;
PciIo->Mem.Read(PciIo,EfiPciIoWidthUint32,1,offset,1,&arg);
return arg;
}
void bht_writel(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 offset, UINT32 value)
{
PciIo->Mem.Write(PciIo,EfiPciIoWidthUint32,1,offset,1,&value);
}
UINT32 PciBhtRead32(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 offset)
{
UINT32 i = 0;
UINT32 tmp[3] = {0};
if((g_deviceId == PCI_DEV_ID_SDS0) ||
(g_deviceId == PCI_DEV_ID_SDS1) ||
(g_deviceId == PCI_DEV_ID_FJ2) ||
(g_deviceId == PCI_DEV_ID_SB0) ||
(g_deviceId == PCI_DEV_ID_SB1))
{
// For Sandstorm, HW implement a mapping method by memory space reg to access PCI reg.
// Enable mapping
// Check function conflict
if((g_deviceId == PCI_DEV_ID_SDS0) ||
(g_deviceId == PCI_DEV_ID_FJ2) ||
(g_deviceId == PCI_DEV_ID_SB0) ||
(g_deviceId == PCI_DEV_ID_SB1))
{
i = 0;
bht_writel(PciIo, BHT_PCIRMappingEn, 0x40000000);
while((bht_readl(PciIo, BHT_PCIRMappingEn) & 0x40000000) == 0)
{
if(i == 5)
{
goto RD_DIS_MAPPING;
}
gBS->Stall(1000);
i++;
bht_writel(PciIo, BHT_PCIRMappingEn, 0x40000000);
}
}
else if(g_deviceId == PCI_DEV_ID_SDS1)
{
i = 0;
bht_writel(PciIo, BHT_PCIRMappingEn, 0x20000000);
while((bht_readl(PciIo, BHT_PCIRMappingEn) & 0x20000000) == 0)
{
if(i == 5)
{
//DbgErr((DRIVERNAME " - %s() function 1 can't lock!\n", __FUNCTION__));
goto RD_DIS_MAPPING;
}
gBS->Stall(1000);
i++;
bht_writel(PciIo, BHT_PCIRMappingEn, 0x20000000);
}
}
// Check last operation is complete
i = 0;
while(bht_readl(PciIo, BHT_PCIRMappingCtl) & 0xc0000000)
{
if(i == 5)
{
//DbgErr((DRIVERNAME " - [204] = 0x%x\n", RegisterRead32(ELN_dPCIRMappingCtl)));
//DbgErr((DRIVERNAME " - [208] = 0x%x\n", RegisterRead32(ELN_dPCIRMappingEn)));
//DbgErr((DRIVERNAME " - %s() check last operation complete timeout!!!\n", __FUNCTION__));
goto RD_DIS_MAPPING;
}
gBS->Stall(1000);
i += 1;
}
// Set register address
tmp[0] |= 0x40000000;
tmp[0] |= offset;
bht_writel(PciIo, BHT_PCIRMappingCtl, tmp[0]);
// Check read is complete
i = 0;
while(bht_readl(PciIo, BHT_PCIRMappingCtl) & 0x40000000)
{
if(i == 5)
{
//DbgErr((DRIVERNAME " - %s() check read operation complete timeout!!!\n", __FUNCTION__));
goto RD_DIS_MAPPING;
}
gBS->Stall(1000);
i += 1;
}
// Get PCIR value
tmp[1] = bht_readl(PciIo, BHT_PCIRMappingVal);
RD_DIS_MAPPING:
// Disable mapping
bht_writel(PciIo, BHT_PCIRMappingEn, 0x80000000);
//DbgDebug(L"%s offset=%x Value:%x\n", __FUNCTION__, offset, tmp[1]);
return tmp[1];
}
//DbgDebug(L"%s offset=%x Value:%x\n", __FUNCTION__, offset, tmp[0]);
return tmp[0];
}
void PciBhtWrite32(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 offset, UINT32 value)
{
UINT32 tmp = 0;
UINT32 i = 0;
if((g_deviceId == PCI_DEV_ID_SDS0) ||
(g_deviceId == PCI_DEV_ID_SDS1) ||
(g_deviceId == PCI_DEV_ID_FJ2) ||
(g_deviceId == PCI_DEV_ID_SB0) ||
(g_deviceId == PCI_DEV_ID_SB1))
{
// For Sandstorm, HW implement a mapping method by memory space reg to access PCI reg.
// Upper caller doesn't need to set 0xD0.
// Enable mapping
// Check function conflict
if((g_deviceId == PCI_DEV_ID_SDS0) ||
(g_deviceId == PCI_DEV_ID_FJ2) ||
(g_deviceId == PCI_DEV_ID_SB0) ||
(g_deviceId == PCI_DEV_ID_SB1))
{
i = 0;
bht_writel(PciIo, BHT_PCIRMappingEn, 0x40000000);
while((bht_readl(PciIo, BHT_PCIRMappingEn) & 0x40000000) == 0)
{
if(i == 5)
{
//DbgErr((DRIVERNAME " - %s() function 0 can't lock!\n", __FUNCTION__));
goto WR_DIS_MAPPING;
}
gBS->Stall(1000);
i++;
bht_writel(PciIo, BHT_PCIRMappingEn, 0x40000000);
}
}
else if(g_deviceId == PCI_DEV_ID_SDS1)
{
i = 0;
bht_writel(PciIo, BHT_PCIRMappingEn, 0x20000000);
while((bht_readl(PciIo, BHT_PCIRMappingEn) & 0x20000000) == 0)
{
if(i == 5)
{
//DbgErr((DRIVERNAME " - %s() function 0 can't lock!\n", __FUNCTION__));
goto WR_DIS_MAPPING;
}
gBS->Stall(1000);
i++;
bht_writel(PciIo, BHT_PCIRMappingEn, 0x20000000);
}
}
// Enable MEM access
bht_writel(PciIo, BHT_PCIRMappingVal, 0x80000000);
bht_writel(PciIo, BHT_PCIRMappingCtl, 0x800000D0);
// Check last operation is complete
i = 0;
while(bht_readl(PciIo, BHT_PCIRMappingCtl) & 0xc0000000)
{
if(i == 5)
{
//DbgErr((DRIVERNAME " - %s() check last operation complete timeout!!!\n", __FUNCTION__));
goto WR_DIS_MAPPING;
}
gBS->Stall(1000);
i += 1;
}
// Set write value
bht_writel(PciIo, BHT_PCIRMappingVal, value);
// Set register address
tmp |= 0x80000000;
tmp |= offset;
bht_writel(PciIo, BHT_PCIRMappingCtl, tmp);
// Check write is complete
i = 0;
while(bht_readl(PciIo, BHT_PCIRMappingCtl) & 0x80000000)
{
if(i == 5)
{
//DbgErr((DRIVERNAME " - %s() check write operation complete timeout!!!\n", __FUNCTION__));
goto WR_DIS_MAPPING;
}
gBS->Stall(1000);
i += 1;
}
WR_DIS_MAPPING:
// Disable MEM access
bht_writel(PciIo, BHT_PCIRMappingVal, 0x80000001);
bht_writel(PciIo, BHT_PCIRMappingCtl, 0x800000D0);
// Check last operation is complete
i = 0;
while(bht_readl(PciIo, BHT_PCIRMappingCtl) & 0xc0000000)
{
if(i == 5)
{
//DbgErr((DRIVERNAME " - %s() check last operation complete timeout!!!\n", __FUNCTION__));
break;
}
gBS->Stall(1000);
i += 1;
}
// Disable function conflict
// Disable mapping
bht_writel(PciIo, BHT_PCIRMappingEn, 0x80000000);
}
}
void PciBhtOr32(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 offset, UINT32 value)
{
UINT32 arg;
arg = PciBhtRead32(PciIo, offset);
PciBhtWrite32(PciIo, offset, value | arg);
}
void PciBhtAnd32(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 offset, UINT32 value)
{
UINT32 arg;
arg = PciBhtRead32(PciIo, offset);
PciBhtWrite32(PciIo, offset, value & arg);
}

View File

@@ -607,4 +607,33 @@ SdMmcSetDriverStrength (
IN SD_DRIVER_STRENGTH_TYPE DriverStrength
);
BOOLEAN
BhtHostPciSupport(EFI_PCI_IO_PROTOCOL *PciIo);
UINT32
PciBhtRead32(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 offset);
void
PciBhtWrite32(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 offset, UINT32 value);
void
PciBhtOr32(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 offset, UINT32 value);
void
PciBhtAnd32(EFI_PCI_IO_PROTOCOL *PciIo, UINT32 offset, UINT32 value);
extern void
DbgNull(IN CONST CHAR16 * fmt, ...);
#define PCI_DEV_ID_RJ 0x8320
#define PCI_DEV_ID_SDS0 0x8420
#define PCI_DEV_ID_SDS1 0x8421
#define PCI_DEV_ID_FJ2 0x8520
#define PCI_DEV_ID_SB0 0x8620
#define PCI_DEV_ID_SB1 0x8621
// O2/BHT add BAR1 for PCIR mapping registers
// These registers is defined by O2/BHT, but we may follow name definition rule.
#define BHT_PCIRMappingVal (0x200) /* PCI CFG Space Register Mapping Value Register */
#define BHT_PCIRMappingCtl (0x204) /* PCI CFG Space Register Mapping Control Register */
#define BHT_PCIRMappingEn (0x208) /* PCI CFG Space Register Mapping Enable Register */
#define BHT_GPIOCTL (0x210) /* GPIO control register*/
#endif

View File

@@ -285,7 +285,7 @@ UsbHcBulkTransfer (
IN UINT8 DevSpeed,
IN UINTN MaxPacket,
IN UINT8 BufferNum,
IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM],
IN OUT VOID *Data[],
IN OUT UINTN *DataLength,
IN OUT UINT8 *DataToggle,
IN UINTN TimeOut,

View File

@@ -149,7 +149,7 @@ UsbHcBulkTransfer (
IN UINT8 DevSpeed,
IN UINTN MaxPacket,
IN UINT8 BufferNum,
IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM],
IN OUT VOID *Data[],
IN OUT UINTN *DataLength,
IN OUT UINT8 *DataToggle,
IN UINTN TimeOut,

View File

@@ -801,10 +801,7 @@ InitUSBKeyboard (
IN OUT USB_KB_DEV *UsbKeyboardDevice
)
{
UINT16 ConfigValue;
UINT8 Protocol;
EFI_STATUS Status;
UINT32 TransferResult;
REPORT_STATUS_CODE_WITH_DEVICE_PATH (
EFI_PROGRESS_CODE,
@@ -817,27 +814,17 @@ InitUSBKeyboard (
InitQueue (&UsbKeyboardDevice->EfiKeyQueueForNotify, sizeof (EFI_KEY_DATA));
//
// Use the config out of the descriptor
// Assumed the first config is the correct one and this is not always the case
// Set boot protocol for the USB Keyboard.
// This driver only supports boot protocol.
//
Status = UsbGetConfiguration (
Status = UsbSetProtocolRequest (
UsbKeyboardDevice->UsbIo,
&ConfigValue,
&TransferResult
);
if (EFI_ERROR (Status)) {
ConfigValue = 0x01;
//
// Uses default configuration to configure the USB Keyboard device.
//
Status = UsbSetConfiguration (
UsbKeyboardDevice->UsbIo,
ConfigValue,
&TransferResult
UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber,
BOOT_PROTOCOL
);
if (EFI_ERROR (Status)) {
//
// If configuration could not be set here, it means
// If protocol could not be set here, it means
// the keyboard interface has some errors and could
// not be initialized
//
@@ -849,24 +836,6 @@ InitUSBKeyboard (
return EFI_DEVICE_ERROR;
}
}
UsbGetProtocolRequest (
UsbKeyboardDevice->UsbIo,
UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber,
&Protocol
);
//
// Set boot protocol for the USB Keyboard.
// This driver only supports boot protocol.
//
if (Protocol != BOOT_PROTOCOL) {
UsbSetProtocolRequest (
UsbKeyboardDevice->UsbIo,
UsbKeyboardDevice->InterfaceDescriptor.InterfaceNumber,
BOOT_PROTOCOL
);
}
UsbKeyboardDevice->CtrlOn = FALSE;
UsbKeyboardDevice->AltOn = FALSE;

View File

@@ -70,6 +70,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

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

View File

@@ -213,7 +213,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,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

@@ -175,7 +175,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

@@ -722,6 +722,7 @@ BootMaintExtractConfig (
*Progress = Request + StrLen (Request);
}
DEBUG ((EFI_D_INFO, "%a complete: %r\n", __FUNCTION__, Status));
return Status;
}
@@ -1033,6 +1034,7 @@ BootMaintRouteConfig (
//
CopyMem (OldBmmData, NewBmmData, sizeof (BMM_FAKE_NV_DATA));
DEBUG ((EFI_D_INFO, "%a complete: %r\n", __FUNCTION__, Status));
return EFI_SUCCESS;
Exit:
@@ -1093,6 +1095,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) {
//
@@ -1104,7 +1108,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;
@@ -1119,6 +1125,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;
}
@@ -1204,6 +1212,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;
}
@@ -1243,6 +1253,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){
//
@@ -1306,6 +1321,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;
}
@@ -1630,6 +1646,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.
@@ -1705,8 +1743,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);
@@ -1718,6 +1756,11 @@ BootMaintenanceManagerUiLibConstructor (
BmmInitialBootModeInfo();
//
// Remove the F9 and F10 hotkeys
//
UnregisterHotKeys();
return EFI_SUCCESS;
}

View File

@@ -19,8 +19,9 @@ formset
name = BmmData,
guid = BOOT_MAINT_FORMSET_GUID;
form formid = FORM_MAIN_ID,
title = STRING_TOKEN(STR_FORM_MAIN_TITLE);
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.
@@ -33,6 +34,14 @@ formset
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);
label LABEL_FORM_MAIN_START;
//
// This is where we will dynamically add a Action type op-code to show
@@ -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

@@ -112,40 +112,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,
@@ -642,7 +608,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
@@ -1143,8 +1109,8 @@ UpdatePageId (
NewPageId = FORM_CON_COM_SETUP_ID;
}
if ((NewPageId > 0) && (NewPageId < MAXIMUM_FORM_ID)) {
Private->BmmPreviousPageId = Private->BmmCurrentPageId;
Private->BmmCurrentPageId = NewPageId;
}
//if ((NewPageId > 0) && (NewPageId < MAXIMUM_FORM_ID)) {
// Private->BmmPreviousPageId = Private->BmmCurrentPageId;
// Private->BmmCurrentPageId = NewPageId;
//}
}

View File

@@ -631,6 +631,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",
@@ -484,22 +490,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;
@@ -526,6 +520,7 @@ UpdateBootManager (
EndLabel = (EFI_IFR_GUID_LABEL *) HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
EndLabel->Number = LABEL_BOOT_OPTION_END;
mKeyInput = 0;
NeedEndOp = FALSE;
for (Index = 0; Index < BootOptionCount; Index++) {
@@ -541,6 +536,8 @@ UpdateBootManager (
continue;
}
OptionCount++;
//
// Group the legacy boot option in the sub title created dynamically
//
@@ -596,6 +593,10 @@ UpdateBootManager (
);
}
if (OptionCount == 0) {
HiiCreateSubTitleOpCode (StartOpCodeHandle, STRING_TOKEN (STR_NO_BOOTABLE_MEDIA), 0, 0, 0);
}
if (NeedEndOp) {
HiiCreateEndOpCode (StartOpCodeHandle);
}
@@ -787,7 +788,6 @@ BootManagerCallback (
{
EFI_BOOT_MANAGER_LOAD_OPTION *BootOption;
UINTN BootOptionCount;
EFI_INPUT_KEY Key;
if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {
//
@@ -831,19 +831,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.
@@ -892,6 +904,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;
}
@@ -912,6 +941,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
@@ -21,18 +22,15 @@ formset
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);
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 ),
help = STRING_TOKEN(STR_EMPTY_STRING),
text = STRING_TOKEN(STR_EMPTY_STRING),
flags = INTERACTIVE,
key = 0x1212;
endif;
@@ -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

@@ -1779,6 +1779,9 @@ EfiBootManagerBoot (
UINTN FileSize;
EFI_BOOT_LOGO_PROTOCOL *BootLogo;
EFI_EVENT LegacyBootEvent;
EFI_INPUT_KEY Key;
UINTN Index;
UINT8 *SecureBoot;
if (BootOption == NULL) {
return;
@@ -1914,6 +1917,38 @@ EfiBootManagerBoot (
//
BmReportLoadFailure (EFI_SW_DXE_BS_EC_BOOT_OPTION_LOAD_ERROR, Status);
BootOption->Status = Status;
if (gST->ConOut != NULL) {
gST->ConOut->ClearScreen (gST->ConOut);
//
// When UEFI Secure Boot is enabled, unsigned modules won't load.
//
SecureBoot = NULL;
GetEfiGlobalVariable2 (EFI_SECURE_BOOT_MODE_NAME, (VOID**)&SecureBoot, NULL);
if ((SecureBoot != NULL) && (*SecureBoot == SECURE_BOOT_MODE_ENABLE)) {
AsciiPrint ("SecureBoot is enabled.\n");
} else {
AsciiPrint ("SecureBoot is disabled.\n");
}
if (SecureBoot != NULL) {
FreePool (SecureBoot);
}
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;
}
}
@@ -2116,12 +2151,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
@@ -2160,6 +2197,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);
@@ -144,9 +143,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;
@@ -171,25 +169,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);
@@ -268,7 +260,6 @@ BmGetUsbDescription (
CHAR16 NullChar;
CHAR16 *Manufacturer;
CHAR16 *Product;
CHAR16 *SerialNumber;
CHAR16 *Description;
EFI_USB_DEVICE_DESCRIPTOR DevDesc;
UINTN DescMaxSize;
@@ -309,24 +300,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);
@@ -335,17 +314,12 @@ BmGetUsbDescription (
StrCatS (Description, DescMaxSize/sizeof(CHAR16), Product);
StrCatS (Description, DescMaxSize/sizeof(CHAR16), L" ");
StrCatS (Description, DescMaxSize/sizeof(CHAR16), SerialNumber);
if (Manufacturer != &NullChar) {
FreePool (Manufacturer);
}
if (Product != &NullChar) {
FreePool (Product);
}
if (SerialNumber != &NullChar) {
FreePool (SerialNumber);
}
BmEliminateExtraSpaces (Description);
@@ -564,6 +538,7 @@ BmGetNvmeDescription (
EFI_NVM_EXPRESS_COMPLETION Completion;
NVME_ADMIN_CONTROLLER_DATA ControllerData;
CHAR16 *Description;
CHAR16 *DescTemp;
CHAR16 *Char;
UINTN Index;
@@ -630,16 +605,11 @@ BmGetNvmeDescription (
for (Index = 0; Index < ARRAY_SIZE (ControllerData.Mn); Index++) {
*(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;
@@ -771,7 +741,6 @@ BmGetBootDescription (
BM_BOOT_DESCRIPTION_ENTRY *Entry;
CHAR16 *Description;
CHAR16 *DefaultDescription;
CHAR16 *Temp;
UINTN Index;
//
@@ -781,16 +750,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;
}
}

View File

@@ -44,6 +44,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Protocol/DeferredImageLoad.h>
#include <Protocol/PlatformBootManager.h>
#include <Guid/ImageAuthentication.h>
#include <Guid/MemoryTypeInformation.h>
#include <Guid/FileInfo.h>
#include <Guid/GlobalVariable.h>

View File

@@ -0,0 +1,207 @@
/** @file
Unit tests of the UefiSortLib
Copyright (C) Huawei Technologies Co., Ltd. All rights reserved
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <Uefi.h>
#include <Library/BaseLib.h>
#include <Library/DebugLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/UnitTestLib.h>
#include <Library/SortLib.h>
#define UNIT_TEST_APP_NAME "UefiSortLib Unit Tests"
#define UNIT_TEST_APP_VERSION "1.0"
#define TEST_ARRAY_SIZE_9 9
/**
The function is called by PerformQuickSort to compare int values.
@param[in] Left The pointer to first buffer.
@param[in] Right The pointer to second buffer.
@retval 0 Buffer1 equal to Buffer2.
@return <0 Buffer1 is less than Buffer2.
@return >0 Buffer1 is greater than Buffer2.
**/
INTN
EFIAPI
TestCompareFunction (
IN CONST VOID *Left,
IN CONST VOID *Right
)
{
if (*(UINT32*)Right > *(UINT32*)Left) {
return 1;
} else if (*(UINT32*)Right < *(UINT32*)Left) {
return -1;
}
return 0;
}
/**
Unit test for PerformQuickSort () API of the UefiSortLib.
@param[in] Context [Optional] An optional parameter that enables:
1) test-case reuse with varied parameters and
2) test-case re-entry for Target tests that need a
reboot. This parameter is a VOID* and it is the
responsibility of the test author to ensure that the
contents are well understood by all test cases that may
consume it.
@retval UNIT_TEST_PASSED The Unit test has completed and the test
case was successful.
@retval UNIT_TEST_ERROR_TEST_FAILED A test case assertion has failed.
**/
UNIT_TEST_STATUS
EFIAPI
SortUINT32ArrayShouldSucceed (
IN UNIT_TEST_CONTEXT Context
)
{
UINTN TestCount;
UINT32 Index;
UINT32 TestBuffer[TEST_ARRAY_SIZE_9];
UINT32 TestResult[TEST_ARRAY_SIZE_9];
TestCount = TEST_ARRAY_SIZE_9;
for (Index = 0; Index < TEST_ARRAY_SIZE_9; Index++) {
TestBuffer[Index] = Index + 1;
TestResult[Index] = TEST_ARRAY_SIZE_9 - Index;
}
PerformQuickSort (TestBuffer, TestCount, sizeof (UINT32), (SORT_COMPARE)TestCompareFunction);
UT_ASSERT_MEM_EQUAL (TestBuffer, TestResult, sizeof (UINT32) * TEST_ARRAY_SIZE_9);
return UNIT_TEST_PASSED;
}
/**
Unit test for StringCompare () API of the UefiSortLib.
@param[in] Context [Optional] An optional parameter that enables:
1) test-case reuse with varied parameters and
2) test-case re-entry for Target tests that need a
reboot. This parameter is a VOID* and it is the
responsibility of the test author to ensure that the
contents are well understood by all test cases that may
consume it.
@retval UNIT_TEST_PASSED The Unit test has completed and the test
case was successful.
@retval UNIT_TEST_ERROR_TEST_FAILED A test case assertion has failed.
**/
UNIT_TEST_STATUS
EFIAPI
CompareSameBufferShouldSucceed (
IN UNIT_TEST_CONTEXT Context
)
{
INTN retval;
CONST CHAR16* TestBuffer[] = { L"abcdefg" };
retval = StringCompare (TestBuffer, TestBuffer);
UT_ASSERT_TRUE (retval == 0);
return UNIT_TEST_PASSED;
}
/**
Initialze the unit test framework, suite, and unit tests for the
UefiSortLib and run the UefiSortLib unit test.
@retval EFI_SUCCESS All test cases were dispatched.
@retval EFI_OUT_OF_RESOURCES There are not enough resources available to
initialize the unit tests.
**/
STATIC
EFI_STATUS
EFIAPI
UnitTestingEntry (
VOID
)
{
EFI_STATUS Status;
UNIT_TEST_FRAMEWORK_HANDLE Framework;
UNIT_TEST_SUITE_HANDLE SortTests;
Framework = NULL;
DEBUG(( DEBUG_INFO, "%a v%a\n", UNIT_TEST_APP_NAME, UNIT_TEST_APP_VERSION ));
//
// Start setting up the test framework for running the tests.
//
Status = InitUnitTestFramework (&Framework, UNIT_TEST_APP_NAME, gEfiCallerBaseName, UNIT_TEST_APP_VERSION);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Failed in InitUnitTestFramework. Status = %r\n", Status));
goto EXIT;
}
//
// Populate the UefiSortLib Unit Test Suite.
//
Status = CreateUnitTestSuite (&SortTests, Framework, "UefiSortLib Sort Tests", "UefiSortLib.SortLib", NULL, NULL);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Failed in CreateUnitTestSuite for UefiSortLib API Tests\n"));
Status = EFI_OUT_OF_RESOURCES;
goto EXIT;
}
//
// --------------Suite--------Description------------Name--------------Function----------------Pre---Post---Context-----------
//
AddTestCase (SortTests, "Sort the Array", "Sort", SortUINT32ArrayShouldSucceed, NULL, NULL, NULL);
AddTestCase (SortTests, "Compare the Buffer", "Compare", CompareSameBufferShouldSucceed, NULL, NULL, NULL);
//
// Execute the tests.
//
Status = RunAllTestSuites (Framework);
EXIT:
if (Framework) {
FreeUnitTestFramework (Framework);
}
return Status;
}
///
/// Avoid ECC error for function name that starts with lower case letter
///
#define UefiSortLibUnitTestMain main
/**
Standard POSIX C entry point for host based unit test execution.
@param[in] Argc Number of arguments
@param[in] Argv Array of pointers to arguments
@retval 0 Success
@retval other Error
**/
INT32
UefiSortLibUnitTestMain (
IN INT32 Argc,
IN CHAR8 *Argv[]
)
{
UnitTestingEntry ();
return 0;
}

View File

@@ -0,0 +1,32 @@
## @file
# This is a unit test for the UefiSortLib.
#
# Copyright (C) Huawei Technologies Co., Ltd. All rights reserved
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
[Defines]
INF_VERSION = 0x00010017
BASE_NAME = UefiSortLibUnitTest
FILE_GUID = 271337A3-0D79-BA3E-BC03-714E518E3B1B
VERSION_STRING = 1.0
MODULE_TYPE = HOST_APPLICATION
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64
#
[Sources]
UefiSortLibUnitTest.c
[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec
UnitTestFrameworkPkg/UnitTestFrameworkPkg.dec
[LibraryClasses]
UnitTestLib
DebugLib
UefiSortLib

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 315 KiB

View File

@@ -19,6 +19,7 @@
"ExceptionList": [
"8005", "UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE.UID",
"8005", "UNIVERSAL_PAYLOAD_PCI_ROOT_BRIDGE.HID",
"8001", "UefiSortLibUnitTestMain",
],
## Both file path and directory path are accepted.
"IgnoreFiles": [

View File

@@ -2159,3 +2159,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

@@ -41,3 +41,9 @@
<PcdsFixedAtBuild>
gEfiMdeModulePkgTokenSpaceGuid.PcdAllowVariablePolicyEnforcementDisable|TRUE
}
MdeModulePkg/Library/UefiSortLib/UnitTest/UefiSortLibUnitTest.inf {
<LibraryClasses>
UefiSortLib|MdeModulePkg/Library/UefiSortLib/UefiSortLib.inf
DevicePathLib|MdePkg/Library/UefiDevicePathLib/UefiDevicePathLib.inf
}

View File

@@ -326,7 +326,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;
}
@@ -1024,7 +1025,7 @@ BdsEntry (
//
// BdsReadKeys() can be removed after all keyboard drivers invoke callback in timer callback.
//
BdsReadKeys ();
//BdsReadKeys ();
EfiBootManagerHotkeyBoot ();

View File

@@ -499,19 +499,6 @@ GraphicsConsoleControllerDriverStart (
}
}
}
if (ModeNumber != Private->GraphicsOutput->Mode->Mode) {
//
// Current graphics mode is not set or is not set to the mode which we have found,
// set the new graphic mode.
//
Status = Private->GraphicsOutput->SetMode (Private->GraphicsOutput, ModeNumber);
if (EFI_ERROR (Status)) {
//
// The mode set operation failed
//
goto Error;
}
}
} else if (FeaturePcdGet (PcdUgaConsumeSupport)) {
//
// At first try to set user-defined resolution
@@ -780,23 +767,6 @@ CheckModeSupported (
&Info
);
if (!EFI_ERROR (Status)) {
if ((Info->HorizontalResolution == HorizontalResolution) &&
(Info->VerticalResolution == VerticalResolution)) {
if ((GraphicsOutput->Mode->Info->HorizontalResolution == HorizontalResolution) &&
(GraphicsOutput->Mode->Info->VerticalResolution == VerticalResolution)) {
//
// If video device has been set to this mode, we do not need to SetMode again
//
FreePool (Info);
break;
} else {
Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);
if (!EFI_ERROR (Status)) {
FreePool (Info);
break;
}
}
}
FreePool (Info);
}
}
@@ -1922,7 +1892,8 @@ FlushCursor (
CurrentMode = This->Mode;
if (!CurrentMode->CursorVisible) {
if (!CurrentMode->CursorVisible ||
(CurrentMode->CursorColumn == 0 && CurrentMode->CursorRow == 0 )) {
return EFI_SUCCESS;
}

View File

@@ -1,7 +1,7 @@
/** @file
All Pcd Ppi services are implemented here.
Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2006 - 2021, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -339,6 +339,75 @@ PcdPeimInit (
{
EFI_STATUS Status;
Status = PeiServicesRegisterForShadow (FileHandle);
if (Status == EFI_ALREADY_STARTED) {
//
// This is now starting in memory, the second time starting.
//
EFI_PEI_PPI_DESCRIPTOR *OldPpiList;
EFI_PEI_PPI_DESCRIPTOR *OldPpiList2;
VOID *Ppi;
VOID *Ppi2;
OldPpiList = NULL;
Status = PeiServicesLocatePpi (
&gPcdPpiGuid,
0,
&OldPpiList,
&Ppi
);
ASSERT_EFI_ERROR (Status);
if (OldPpiList != NULL) {
Status = PeiServicesReInstallPpi (OldPpiList, &mPpiList[0]);
ASSERT_EFI_ERROR (Status);
}
OldPpiList2 = NULL;
Status = PeiServicesLocatePpi (
&gGetPcdInfoPpiGuid,
0,
&OldPpiList2,
&Ppi2
);
ASSERT_EFI_ERROR (Status);
if (OldPpiList2 != NULL) {
Status = PeiServicesReInstallPpi (OldPpiList2, &mPpiList2[0]);
ASSERT_EFI_ERROR (Status);
}
OldPpiList = NULL;
Status = PeiServicesLocatePpi (
&gEfiPeiPcdPpiGuid,
0,
&OldPpiList,
&Ppi
);
ASSERT_EFI_ERROR (Status);
if (OldPpiList != NULL) {
Status = PeiServicesReInstallPpi (OldPpiList, &mPpiList[1]);
ASSERT_EFI_ERROR (Status);
}
OldPpiList2 = NULL;
Status = PeiServicesLocatePpi (
&gEfiGetPcdInfoPpiGuid,
0,
&OldPpiList2,
&Ppi2
);
ASSERT_EFI_ERROR (Status);
if (OldPpiList2 != NULL) {
Status = PeiServicesReInstallPpi (OldPpiList2, &mPpiList2[1]);
ASSERT_EFI_ERROR (Status);
}
return Status;
}
BuildPcdDatabase (FileHandle);
//

View File

@@ -3,7 +3,7 @@
consumed by drivers that do not care about ACPI versions.
Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2019, ARM Ltd. All rights reserved.<BR>
Copyright (c) 2019 - 2021, ARM Ltd. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -11,6 +11,6 @@
#ifndef _ACPI_H_
#define _ACPI_H_
#include <IndustryStandard/Acpi63.h>
#include <IndustryStandard/Acpi64.h>
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -6378,7 +6378,11 @@ typedef union {
/// [Bit 11] Execute Disable Bit Enable: IA32_EFER.NXE (R/W).
///
UINT32 NXE:1;
UINT32 Reserved3:20;
///
/// [ Bit 12] Secure Virtual Machine Enable (AMD only)
///
UINT32 SVME:1;
UINT32 Reserved3:19;
UINT32 Reserved4:32;
} Bits;
///

View File

@@ -3,6 +3,7 @@
#
# Copyright (c) Microsoft Corporation
# Copyright (c) 2020, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2021, Arm Limited. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
##
{
@@ -19,6 +20,7 @@
],
## Both file path and directory path are accepted.
"IgnoreFiles": [
"Include/IndustryStandard/Acpi64.h"
]
},
## options defined ci/Plugin/CompilerPlugin

View File

@@ -0,0 +1,29 @@
/** @file
Returns the platform specific Physical Presence configuration.
Copyright (C) 2020 9elements GmbH
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#ifndef __TCG2_PHYSICAL_PRESENCE_PLATFORM_LIB_H__
#define __TCG2_PHYSICAL_PRESENCE_PLATFORM_LIB_H__
#include <IndustryStandard/QemuTpm.h>
/**
Reads the platform specific Physical Presence configuration.
@param[out] The Config structure to read to.
@param[out] The PPIinMMIO is True when the PPI is in MMIO memory space
@retval EFI_SUCCESS Operation completed successfully.
@retval EFI_PROTOCOL_ERROR Invalid fw_cfg entry size.
**/
EFI_STATUS
TpmPPIPlatformReadConfig (
OUT QEMU_FWCFG_TPM_CONFIG *Config,
OUT BOOLEAN *PPIinMMIO
);
#endif

View File

@@ -27,8 +27,8 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/HobLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/PrintLib.h>
#include <Library/QemuFwCfgLib.h>
#include <Library/Tpm2CommandLib.h>
#include <Library/Tcg2PhysicalPresencePlatformLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
@@ -37,46 +37,15 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define CONFIRM_BUFFER_SIZE 4096
/* Wait 3 minutes for user input */
#define TIMEOUT (1000 * 1000 * 60 * 3)
EFI_HII_HANDLE mTcg2PpStringPackHandle;
#define TPM_PPI_FLAGS (QEMU_TPM_PPI_FUNC_ALLOWED_USR_REQ)
STATIC volatile QEMU_TPM_PPI *mPpi;
/**
Reads QEMU PPI config from fw_cfg.
@param[out] The Config structure to read to.
@retval EFI_SUCCESS Operation completed successfully.
@retval EFI_PROTOCOL_ERROR Invalid fw_cfg entry size.
**/
STATIC
EFI_STATUS
QemuTpmReadConfig (
OUT QEMU_FWCFG_TPM_CONFIG *Config
)
{
EFI_STATUS Status;
FIRMWARE_CONFIG_ITEM FwCfgItem;
UINTN FwCfgSize;
Status = QemuFwCfgFindFile ("etc/tpm/config", &FwCfgItem, &FwCfgSize);
if (EFI_ERROR (Status)) {
return Status;
}
if (FwCfgSize != sizeof (*Config)) {
return EFI_PROTOCOL_ERROR;
}
QemuFwCfgSelectItem (FwCfgItem);
QemuFwCfgReadBytes (sizeof (*Config), Config);
return EFI_SUCCESS;
}
/**
Initializes QEMU PPI memory region.
@@ -91,6 +60,7 @@ QemuTpmInitPPI (
{
EFI_STATUS Status;
QEMU_FWCFG_TPM_CONFIG Config;
BOOLEAN PPIinMMIO;
EFI_PHYSICAL_ADDRESS PpiAddress64;
EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;
UINTN Idx;
@@ -99,7 +69,7 @@ QemuTpmInitPPI (
return EFI_SUCCESS;
}
Status = QemuTpmReadConfig (&Config);
Status = TpmPPIPlatformReadConfig (&Config, &PPIinMMIO);
if (EFI_ERROR (Status)) {
return Status;
}
@@ -123,12 +93,22 @@ QemuTpmInitPPI (
ASSERT_EFI_ERROR (Status);
goto InvalidPpiAddress;
}
if (PPIinMMIO) {
if (!EFI_ERROR (Status) &&
(Descriptor.GcdMemoryType != EfiGcdMemoryTypeMemoryMappedIo &&
Descriptor.GcdMemoryType != EfiGcdMemoryTypeNonExistent)) {
DEBUG ((DEBUG_ERROR, "[TPM2PP] mPpi has an invalid memory type\n"));
goto InvalidPpiAddress;
}
} else {
if (!EFI_ERROR (Status) &&
(Descriptor.GcdMemoryType != EfiGcdMemoryTypeReserved &&
Descriptor.GcdMemoryType != EfiGcdMemoryTypeSystemMemory)) {
DEBUG ((DEBUG_ERROR, "[TPM2PP] mPpi has an invalid memory type\n"));
goto InvalidPpiAddress;
}
}
for (Idx = 0; Idx < ARRAY_SIZE (mPpi->Func); Idx++) {
mPpi->Func[Idx] = 0;
@@ -360,12 +340,16 @@ Tcg2ExecutePhysicalPresence (
STATIC
BOOLEAN
Tcg2ReadUserKey (
IN BOOLEAN CautionKey
IN BOOLEAN CautionKey,
IN UINTN Timeout
)
{
EFI_STATUS Status;
EFI_INPUT_KEY Key;
UINT16 InputKey;
UINTN Delay;
Delay = Timeout / 50;
InputKey = 0;
do {
@@ -382,7 +366,13 @@ Tcg2ReadUserKey (
InputKey = Key.ScanCode;
}
}
} while (InputKey == 0);
gBS->Stall (50);
Delay--;
} while (InputKey == 0 && Delay > 0);
if (Delay == 0) {
return FALSE;
}
if (InputKey != SCAN_ESC) {
return TRUE;
@@ -638,7 +628,7 @@ Tcg2UserConfirm (
FreePool (ConfirmText);
HiiRemovePackages (mTcg2PpStringPackHandle);
if (Tcg2ReadUserKey (CautionKey)) {
if (Tcg2ReadUserKey (CautionKey, TIMEOUT)) {
return TRUE;
}

View File

@@ -57,11 +57,11 @@
HobLib
MemoryAllocationLib
PrintLib
QemuFwCfgLib
Tpm2CommandLib
UefiBootServicesTableLib
UefiLib
UefiRuntimeServicesTableLib
Tcg2PhysicalPresencePlatformLib
[Protocols]
gEfiTcg2ProtocolGuid ## SOMETIMES_CONSUMES

View File

@@ -0,0 +1,56 @@
/** @file
Returns the platform specific configuration for the QEMU PPI.
Caution: This module requires additional review when modified.
This driver will have external input - variable.
This external input must be validated carefully to avoid security issue.
Copyright (C) 2018, Red Hat, Inc.
Copyright (c) 2018, IBM Corporation. All rights reserved.<BR>
Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <PiDxe.h>
#include <IndustryStandard/QemuTpm.h>
#include <Library/QemuFwCfgLib.h>
#include <Library/Tcg2PhysicalPresencePlatformLib.h>
/**
Reads QEMU PPI config from fw_cfg.
@param[out] The Config structure to read to.
@param[out] The PPIinMMIO is True when the PPI is in MMIO memory space
@retval EFI_SUCCESS Operation completed successfully.
@retval EFI_PROTOCOL_ERROR Invalid fw_cfg entry size.
**/
EFI_STATUS
TpmPPIPlatformReadConfig (
OUT QEMU_FWCFG_TPM_CONFIG *Config,
OUT BOOLEAN *PPIinMMIO
)
{
EFI_STATUS Status;
FIRMWARE_CONFIG_ITEM FwCfgItem;
UINTN FwCfgSize;
Status = QemuFwCfgFindFile ("etc/tpm/config", &FwCfgItem, &FwCfgSize);
if (EFI_ERROR (Status)) {
return Status;
}
if (FwCfgSize != sizeof (*Config)) {
return EFI_PROTOCOL_ERROR;
}
QemuFwCfgSelectItem (FwCfgItem);
QemuFwCfgReadBytes (sizeof (*Config), Config);
*PPIinMMIO = TRUE;
return EFI_SUCCESS;
}

View File

@@ -0,0 +1,36 @@
## @file
# Returns the platform specific configuration for the QEMU PPI.
#
# Caution: This module requires additional review when modified.
# This driver will have external input - variable.
# This external input must be validated carefully to avoid security issue.
#
# Copyright (C) 2018, Red Hat, Inc.
# Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##
[Defines]
INF_VERSION = 0x00010005
BASE_NAME = Tcg2PhysicalPresencePlatformLibQemu
FILE_GUID = 9336E7F0-6CA1-4E6D-A0E9-DFE5F077AA02
MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
LIBRARY_CLASS = Tcg2PhysicalPresencePlatformLib|DXE_DRIVER DXE_RUNTIME_DRIVER UEFI_APPLICATION UEFI_DRIVER
#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64 EBC
#
[Sources]
DxeTcg2PhysicalPresencePlatformLib.c
[Packages]
OvmfPkg/OvmfPkg.dec
MdePkg/MdePkg.dec
[LibraryClasses]
QemuFwCfgLib

View File

@@ -233,6 +233,7 @@
Tpm12CommandLib|SecurityPkg/Library/Tpm12CommandLib/Tpm12CommandLib.inf
Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.inf
Tcg2PhysicalPresencePlatformLib|OvmfPkg/Library/Tcg2PhysicalPresencePlatformLibQemu/DxeTcg2PhysicalPresencePlatformLib.inf
Tcg2PpVendorLib|SecurityPkg/Library/Tcg2PpVendorLibNull/Tcg2PpVendorLibNull.inf
TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
!else

View File

@@ -237,6 +237,7 @@
Tpm12CommandLib|SecurityPkg/Library/Tpm12CommandLib/Tpm12CommandLib.inf
Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.inf
Tcg2PhysicalPresencePlatformLib|OvmfPkg/Library/Tcg2PhysicalPresencePlatformLibQemu/DxeTcg2PhysicalPresencePlatformLib.inf
Tcg2PpVendorLib|SecurityPkg/Library/Tcg2PpVendorLibNull/Tcg2PpVendorLibNull.inf
TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
!else

View File

@@ -237,6 +237,7 @@
Tpm12CommandLib|SecurityPkg/Library/Tpm12CommandLib/Tpm12CommandLib.inf
Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibQemu/DxeTcg2PhysicalPresenceLib.inf
Tcg2PhysicalPresencePlatformLib|OvmfPkg/Library/Tcg2PhysicalPresencePlatformLibQemu/DxeTcg2PhysicalPresencePlatformLib.inf
Tcg2PpVendorLib|SecurityPkg/Library/Tcg2PpVendorLibNull/Tcg2PpVendorLibNull.inf
TpmMeasurementLib|SecurityPkg/Library/DxeTpmMeasurementLib/DxeTpmMeasurementLib.inf
!else

View File

@@ -2,7 +2,7 @@
APIs for JSON operations.
Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
(C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -53,6 +53,13 @@ typedef INT64 EDKII_JSON_INT_T; // #JSON_INTEGER_IS_LONG_LONG is set to 1
Index < JsonArrayCount(Array) && (Value = JsonArrayGetValue(Array, Index)); \
Index++)
#define EDKII_JSON_OBJECT_FOREACH_SAFE(Object, N, Key, Value) \
for (Key = JsonObjectIteratorKey(JsonObjectIterator(Object)), \
N = JsonObjectIteratorNext(Object, JsonObjectKeyToIterator(Key)); \
Key && (Value = JsonObjectIteratorValue(JsonObjectKeyToIterator(Key))); \
Key = JsonObjectIteratorKey(N), \
N = JsonObjectIteratorNext(Object, JsonObjectKeyToIterator(Key)))
///
/// Map to the json_error_t in jansson.h
///
@@ -177,12 +184,12 @@ JsonValueInitUnicodeString (
@param[in] Value The integer to initialize to JSON value
@retval The created JSON value which contains a JSON number or NULL.
@retval The created JSON value which contains a JSON integer or NULL.
**/
EDKII_JSON_VALUE
EFIAPI
JsonValueInitNumber (
JsonValueInitInteger (
IN INT64 Value
);
@@ -218,6 +225,36 @@ JsonValueInitNull (
VOID
);
/**
The function is used to initialize a JSON value which contains a TRUE JSON value,
or NULL on error.
NULL JSON value is kept as static value, and no need to do any cleanup work.
@retval The created JSON TRUE value.
**/
EDKII_JSON_VALUE
EFIAPI
JsonValueInitTrue (
VOID
);
/**
The function is used to initialize a JSON value which contains a FALSE JSON value,
or NULL on error.
NULL JSON value is kept as static value, and no need to do any cleanup work.
@retval The created JSON FALSE value.
**/
EDKII_JSON_VALUE
EFIAPI
JsonValueInitFalse (
VOID
);
/**
The function is used to decrease the reference count of a JSON value by one, and once
this reference count drops to zero, the value is destroyed and it can no longer be used.
@@ -313,6 +350,21 @@ JsonValueIsString (
IN EDKII_JSON_VALUE Json
);
/**
The function is used to return if the provided JSON value contains a JSON integer.
@param[in] Json The provided JSON value.
@retval TRUE The JSON value is contains JSON integer.
@retval FALSE The JSON value doesn't contain a JSON integer.
**/
BOOLEAN
EFIAPI
JsonValueIsInteger (
IN EDKII_JSON_VALUE Json
);
/**
The function is used to return if the provided JSON value contains a JSON number.
@@ -343,6 +395,36 @@ JsonValueIsBoolean (
IN EDKII_JSON_VALUE Json
);
/**
The function is used to return if the provided JSON value contains a TRUE value.
@param[in] Json The provided JSON value.
@retval TRUE The JSON value contains a TRUE value.
@retval FALSE The JSON value doesn't contain a TRUE value.
**/
BOOLEAN
EFIAPI
JsonValueIsTrue (
IN EDKII_JSON_VALUE Json
);
/**
The function is used to return if the provided JSON value contains a FALSE value.
@param[in] Json The provided JSON value.
@retval TRUE The JSON value contains a FALSE value.
@retval FALSE The JSON value doesn't contain a FALSE value.
**/
BOOLEAN
EFIAPI
JsonValueIsFalse (
IN EDKII_JSON_VALUE Json
);
/**
The function is used to return if the provided JSON value contains a JSON NULL.
@@ -424,19 +506,19 @@ JsonValueGetUnicodeString (
);
/**
The function is used to retrieve the associated integer in a number type JSON value.
The function is used to retrieve the associated integer in a integer type JSON value.
The input JSON value should not be NULL or contain no JSON number, otherwise it will
The input JSON value should not be NULL or contain no JSON Integer, otherwise it will
ASSERT() and return 0.
@param[in] Json The provided JSON value.
@retval Return the associated number in JSON value.
@retval Return the associated Integer in JSON value.
**/
INT64
EFIAPI
JsonValueGetNumber (
JsonValueGetInteger (
IN EDKII_JSON_VALUE Json
);
@@ -675,6 +757,8 @@ JsonDumpString (
Caller needs to cleanup the root value by calling JsonValueFree().
@param[in] String The NULL terminated CHAR8 string to convert.
@param[in] Flags Flags for loading JSON string.
@param[in] Error Returned error status.
@retval Array JSON value or object JSON value, or NULL when any error occurs.
@@ -682,7 +766,9 @@ JsonDumpString (
EDKII_JSON_VALUE
EFIAPI
JsonLoadString (
IN CONST CHAR8* String
IN CONST CHAR8* String,
IN UINT64 Flags,
IN EDKII_JSON_ERROR *Error
);
/**
@@ -781,11 +867,36 @@ JsonObjectIteratorValue (
@retval Iterator pointer
**/
VOID *
EFIAPI
JsonObjectIteratorNext (
IN EDKII_JSON_VALUE JsonValue,
IN VOID *Iterator
);
/**
Returns the key of iterator pointing
@param[in] Iterator Iterator pointer
@retval Key
**/
CHAR8 *
EFIAPI
JsonObjectIteratorKey (
IN VOID *Iterator
);
/**
Returns the pointer of iterator by key.
@param[in] Key The key of interator pointer.
@retval Pointer to interator
**/
VOID *
EFIAPI
JsonObjectKeyToIterator (
IN CHAR8 *Key
);
/**
Returns the json type of this json value

View File

@@ -2,7 +2,7 @@
Redfish CRT wrapper functions.
Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
(C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

View File

@@ -5,7 +5,7 @@
https://jansson.readthedocs.io/en/2.13/apiref.html
Copyright (c) 2018 - 2019, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2020 Hewlett Packard Enterprise Development LP<BR>
(C) Copyright 2021 Hewlett Packard Enterprise Development LP<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
@@ -154,12 +154,12 @@ JsonValueInitUnicodeString (
@param[in] Value The integer to initialize to JSON value
@retval The created JSON value which contains a JSON number or NULL.
@retval The created JSON value which contains a JSON integer or NULL.
**/
EDKII_JSON_VALUE
EFIAPI
JsonValueInitNumber (
JsonValueInitInteger (
IN INT64 Value
)
{
@@ -186,6 +186,42 @@ JsonValueInitBoolean (
return (EDKII_JSON_VALUE)json_boolean (Value);
}
/**
The function is used to initialize a JSON value which contains a TRUE JSON value,
or NULL on error.
NULL JSON value is kept as static value, and no need to do any cleanup work.
@retval The created JSON TRUE value.
**/
EDKII_JSON_VALUE
EFIAPI
JsonValueInitTrue (
VOID
)
{
return (EDKII_JSON_VALUE)json_true();
}
/**
The function is used to initialize a JSON value which contains a FALSE JSON value,
or NULL on error.
NULL JSON value is kept as static value, and no need to do any cleanup work.
@retval The created JSON FALSE value.
**/
EDKII_JSON_VALUE
EFIAPI
JsonValueInitFalse (
VOID
)
{
return (EDKII_JSON_VALUE)json_false();
}
/**
The function is used to initialize a JSON value which contains a new JSON NULL,
or NULL on error.
@@ -314,6 +350,24 @@ JsonValueIsString (
return json_is_string ((json_t *) Json);
}
/**
The function is used to return if the provided JSON value contains a JSON integer.
@param[in] Json The provided JSON value.
@retval TRUE The JSON value is contains JSON integer.
@retval FALSE The JSON value doesn't contain a JSON integer.
**/
BOOLEAN
EFIAPI
JsonValueIsInteger (
IN EDKII_JSON_VALUE Json
)
{
return json_is_integer ((json_t *) Json);
}
/**
The function is used to return if the provided JSON value contains a JSON number.
@@ -329,7 +383,7 @@ JsonValueIsNumber (
IN EDKII_JSON_VALUE Json
)
{
return json_is_integer ((json_t *) Json);
return json_is_number ((json_t *) Json);
}
/**
@@ -350,6 +404,47 @@ JsonValueIsBoolean (
return json_is_boolean ((json_t *) Json);
}
/**
The function is used to return if the provided JSON value contains a TRUE value.
@param[in] Json The provided JSON value.
@retval TRUE The JSON value contains a TRUE value.
@retval FALSE The JSON value doesn't contain a TRUE value.
**/
BOOLEAN
EFIAPI
JsonValueIsTrue (
IN EDKII_JSON_VALUE Json
)
{
if (json_is_true ((json_t *)Json)) {
return TRUE;
}
return FALSE;
}
/**
The function is used to return if the provided JSON value contains a FALSE value.
@param[in] Json The provided JSON value.
@retval TRUE The JSON value contains a FALSE value.
@retval FALSE The JSON value doesn't contain a FALSE value.
**/
BOOLEAN
EFIAPI
JsonValueIsFalse (
IN EDKII_JSON_VALUE Json
)
{
if (json_is_false ((json_t *)Json)) {
return TRUE;
}
return FALSE;
}
/**
The function is used to return if the provided JSON value contains a JSON NULL.
@@ -485,24 +580,24 @@ JsonValueGetUnicodeString (
}
/**
The function is used to retrieve the associated integer in a number type JSON value.
The function is used to retrieve the associated integer in a integer type JSON value.
The input JSON value should not be NULL or contain no JSON number, otherwise it will
The input JSON value should not be NULL or contain no JSON integer, otherwise it will
ASSERT() and return 0.
@param[in] Json The provided JSON value.
@retval Return the associated number in JSON value.
@retval Return the associated integer in JSON value.
**/
INT64
EFIAPI
JsonValueGetNumber (
JsonValueGetInteger (
IN EDKII_JSON_VALUE Json
)
{
ASSERT (Json != NULL && JsonValueIsNumber (Json));
if (Json == NULL || !JsonValueIsNumber (Json)) {
ASSERT (Json != NULL && JsonValueIsInteger (Json));
if (Json == NULL || !JsonValueIsInteger (Json)) {
return 0;
}
@@ -830,6 +925,8 @@ JsonDumpString (
Caller needs to cleanup the root value by calling JsonValueFree().
@param[in] String The NULL terminated CHAR8 string to convert.
@param[in] Flags Flags for loading JSON string.
@param[in] Error Returned error status.
@retval Array JSON value or object JSON value, or NULL when any error occurs.
@@ -837,12 +934,12 @@ JsonDumpString (
EDKII_JSON_VALUE
EFIAPI
JsonLoadString (
IN CONST CHAR8* String
IN CONST CHAR8* String,
IN UINT64 Flags,
IN EDKII_JSON_ERROR *Error
)
{
json_error_t JsonError;
return (EDKII_JSON_VALUE) json_loads ((const char *)String, 0, &JsonError);
return (EDKII_JSON_VALUE) json_loads ((const char *)String, Flags, (json_error_t *)Error);
}
/**
@@ -959,6 +1056,7 @@ JsonObjectIteratorValue (
@retval Iterator pointer
**/
VOID *
EFIAPI
JsonObjectIteratorNext (
IN EDKII_JSON_VALUE JsonValue,
IN VOID *Iterator
@@ -967,6 +1065,36 @@ JsonObjectIteratorNext (
return json_object_iter_next(JsonValue, Iterator);
}
/**
Returns the key of iterator pointing.
@param[in] Iterator Iterator pointer
@retval Key
**/
CHAR8 *
EFIAPI
JsonObjectIteratorKey (
IN VOID *Iterator
)
{
return (CHAR8 *)json_object_iter_key(Iterator);
}
/**
Returns the pointer of iterator by key.
@param[in] Key The key of interator pointer.
@retval Pointer to interator
**/
VOID *
EFIAPI
JsonObjectKeyToIterator (
IN CHAR8 *Key
)
{
return json_object_key_to_iter(Key);
}
/**
Returns the json type of this json value.

View File

@@ -17,7 +17,7 @@
#ifndef LIBREDFISH_REDFISH_PAYLOAD_H_
#define LIBREDFISH_REDFISH_PAYLOAD_H_
#include <PrivateInclude/Library/RedfishCrtLib.h>
#include <Include/Library/RedfishCrtLib.h>
#include <jansson.h>
#include <redfishService.h>

View File

@@ -30,7 +30,7 @@
#include <Library/UefiRuntimeServicesTableLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <PrivateInclude/Library/RedfishCrtLib.h>
#include <Include/Library/RedfishCrtLib.h>
#include <Protocol/EdkIIRedfishConfigHandler.h>
#include <Protocol/RestEx.h>

View File

@@ -17,7 +17,7 @@
#ifndef LIBREDFISH_REDPATH_H_
#define LIBREDFISH_REDPATH_H_
#include <PrivateInclude/Library/RedfishCrtLib.h>
#include <Include/Library/RedfishCrtLib.h>
#include <jansson.h>

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