mirror of https://github.com/acidanthera/audk.git
OvmfPkg/AmdSev: add Grub Firmware Volume Package
This is used to package up the grub bootloader into a firmware volume where it can be executed as a shell like the UEFI Shell. Grub itself is built as a minimal entity into a Fv and then added as a boot option. By default the UEFI shell isn't built but for debugging purposes it can be enabled and will then be presented as a boot option (This should never be allowed for secure boot in an external data centre but may be useful for local debugging). Finally all other boot options except grub and possibly the shell are stripped and the boot timeout forced to 0 so the system will not enter a setup menu and will only boot to grub. This is done by copying the Library/PlatformBootManagerLib into Library/PlatformBootManagerLibGrub and then customizing it. Boot failure is fatal to try to prevent secret theft. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3077 Signed-off-by: James Bottomley <jejb@linux.ibm.com> Message-Id: <20201130202819.3910-4-jejb@linux.ibm.com> Acked-by: Ard Biesheuvel <ard.biesheuvel@arm.com> [lersek@redhat.com: replace local variable initialization with assignment] Reviewed-by: Laszlo Ersek <lersek@redhat.com> [lersek@redhat.com: squash 'OvmfPkg: add "gGrubFileGuid=Grub" to GuidCheck.IgnoreDuplicates', reviewed stand-alone by Phil (msgid <e6eae551-8563-ccfb-5547-7a97da6d46e5@redhat.com>) and Ard (msgid <10aeda37-def6-d9a4-6e02-4c66c1492f57@arm.com>)]
This commit is contained in:
parent
30d277ed7a
commit
b261a30c90
|
@ -25,6 +25,7 @@
|
|||
BUILD_TARGETS = NOOPT|DEBUG|RELEASE
|
||||
SKUID_IDENTIFIER = DEFAULT
|
||||
FLASH_DEFINITION = OvmfPkg/AmdSev/AmdSevX64.fdf
|
||||
PREBUILD = sh OvmfPkg/AmdSev/Grub/grub.sh
|
||||
|
||||
#
|
||||
# Defines for default states. These can be changed on the command line.
|
||||
|
@ -34,6 +35,11 @@
|
|||
DEFINE TPM_ENABLE = FALSE
|
||||
DEFINE TPM_CONFIG_ENABLE = FALSE
|
||||
|
||||
#
|
||||
# Shell can be useful for debugging but should not be enabled for production
|
||||
#
|
||||
DEFINE BUILD_SHELL = FALSE
|
||||
|
||||
#
|
||||
# Device drivers
|
||||
#
|
||||
|
@ -149,7 +155,6 @@
|
|||
UefiDriverEntryPoint|MdePkg/Library/UefiDriverEntryPoint/UefiDriverEntryPoint.inf
|
||||
UefiApplicationEntryPoint|MdePkg/Library/UefiApplicationEntryPoint/UefiApplicationEntryPoint.inf
|
||||
DevicePathLib|MdePkg/Library/UefiDevicePathLibDevicePathProtocol/UefiDevicePathLibDevicePathProtocol.inf
|
||||
NvVarsFileLib|OvmfPkg/Library/NvVarsFileLib/NvVarsFileLib.inf
|
||||
FileHandleLib|MdePkg/Library/UefiFileHandleLib/UefiFileHandleLib.inf
|
||||
UefiCpuLib|UefiCpuPkg/Library/BaseUefiCpuLib/BaseUefiCpuLib.inf
|
||||
SecurityManagementLib|MdeModulePkg/Library/DxeSecurityManagementLib/DxeSecurityManagementLib.inf
|
||||
|
@ -184,9 +189,11 @@
|
|||
VariablePolicyLib|MdeModulePkg/Library/VariablePolicyLib/VariablePolicyLib.inf
|
||||
VariablePolicyHelperLib|MdeModulePkg/Library/VariablePolicyHelperLib/VariablePolicyHelperLib.inf
|
||||
|
||||
!if $(BUILD_SHELL) == TRUE
|
||||
ShellLib|ShellPkg/Library/UefiShellLib/UefiShellLib.inf
|
||||
ShellCEntryLib|ShellPkg/Library/UefiShellCEntryLib/UefiShellCEntryLib.inf
|
||||
S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf
|
||||
!endif
|
||||
|
||||
SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf
|
||||
OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf
|
||||
XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf
|
||||
|
@ -343,7 +350,7 @@
|
|||
!else
|
||||
DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
|
||||
!endif
|
||||
PlatformBootManagerLib|OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
|
||||
PlatformBootManagerLib|OvmfPkg/Library/PlatformBootManagerLibGrub/PlatformBootManagerLibGrub.inf
|
||||
PlatformBmPrintScLib|OvmfPkg/Library/PlatformBmPrintScLib/PlatformBmPrintScLib.inf
|
||||
QemuBootOrderLib|OvmfPkg/Library/QemuBootOrderLib/QemuBootOrderLib.inf
|
||||
CpuExceptionHandlerLib|UefiCpuPkg/Library/CpuExceptionHandlerLib/DxeCpuExceptionHandlerLib.inf
|
||||
|
@ -507,6 +514,7 @@
|
|||
# Point to the MdeModulePkg/Application/UiApp/UiApp.inf
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0x31 }
|
||||
|
||||
gEfiMdeModulePkgTokenSpaceGuid.PcdConInConnectOnDemand|TRUE
|
||||
################################################################################
|
||||
#
|
||||
# Pcd Dynamic Section - list of all EDK II PCD Entries defined by this Platform
|
||||
|
@ -751,8 +759,6 @@
|
|||
MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
|
||||
OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
|
||||
OvmfPkg/AcpiTables/AcpiTables.inf
|
||||
MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf
|
||||
MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
|
||||
MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
|
||||
|
||||
#
|
||||
|
@ -765,12 +771,14 @@
|
|||
MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
|
||||
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
|
||||
|
||||
!if $(TOOL_CHAIN_TAG) != "XCODE5"
|
||||
!if $(TOOL_CHAIN_TAG) != "XCODE5" && $(BUILD_SHELL) == TRUE
|
||||
OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf {
|
||||
<PcdsFixedAtBuild>
|
||||
gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
|
||||
}
|
||||
!endif
|
||||
OvmfPkg/AmdSev/Grub/Grub.inf
|
||||
!if $(BUILD_SHELL) == TRUE
|
||||
ShellPkg/Application/Shell/Shell.inf {
|
||||
<LibraryClasses>
|
||||
ShellCommandLib|ShellPkg/Library/UefiShellCommandLib/UefiShellCommandLib.inf
|
||||
|
@ -789,6 +797,7 @@
|
|||
gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
|
||||
gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize|8000
|
||||
}
|
||||
!endif
|
||||
|
||||
OvmfPkg/PlatformDxe/Platform.inf
|
||||
OvmfPkg/AmdSevDxe/AmdSevDxe.inf
|
||||
|
|
|
@ -257,17 +257,18 @@ INF OvmfPkg/SmbiosPlatformDxe/SmbiosPlatformDxe.inf
|
|||
INF MdeModulePkg/Universal/Acpi/AcpiTableDxe/AcpiTableDxe.inf
|
||||
INF OvmfPkg/AcpiPlatformDxe/AcpiPlatformDxe.inf
|
||||
INF RuleOverride=ACPITABLE OvmfPkg/AcpiTables/AcpiTables.inf
|
||||
INF MdeModulePkg/Universal/Acpi/S3SaveStateDxe/S3SaveStateDxe.inf
|
||||
INF MdeModulePkg/Universal/Acpi/BootScriptExecutorDxe/BootScriptExecutorDxe.inf
|
||||
INF MdeModulePkg/Universal/Acpi/BootGraphicsResourceTableDxe/BootGraphicsResourceTableDxe.inf
|
||||
|
||||
INF FatPkg/EnhancedFatDxe/Fat.inf
|
||||
INF MdeModulePkg/Universal/Disk/UdfDxe/UdfDxe.inf
|
||||
|
||||
!if $(TOOL_CHAIN_TAG) != "XCODE5"
|
||||
!if $(TOOL_CHAIN_TAG) != "XCODE5" && $(BUILD_SHELL) == TRUE
|
||||
INF OvmfPkg/LinuxInitrdDynamicShellCommand/LinuxInitrdDynamicShellCommand.inf
|
||||
!endif
|
||||
INF OvmfPkg/AmdSev/Grub/Grub.inf
|
||||
!if $(BUILD_SHELL) == TRUE
|
||||
INF ShellPkg/Application/Shell/Shell.inf
|
||||
!endif
|
||||
|
||||
INF MdeModulePkg/Logo/LogoDxe.inf
|
||||
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
grub.efi
|
|
@ -0,0 +1,39 @@
|
|||
## @file
|
||||
# Create a Firmware Volume based Grub Bootloader
|
||||
#
|
||||
# Copyright (C) 2020 James Bottomley, IBM Corporation.
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010006
|
||||
BASE_NAME = Grub
|
||||
# This is gGrubFileGuid
|
||||
FILE_GUID = b5ae312c-bc8a-43b1-9c62-ebb826dd5d07
|
||||
MODULE_TYPE = UEFI_APPLICATION
|
||||
VERSION_STRING = 1.0
|
||||
ENTRY_POINT = UefiMain
|
||||
|
||||
[Packages]
|
||||
OvmfPkg/OvmfPkg.dec
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by
|
||||
# the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = X64
|
||||
#
|
||||
|
||||
##
|
||||
# Note: The version of grub.efi this picks up can be generated by
|
||||
# grub.sh which must be specified as a PREBUILD in the .dsc file. If
|
||||
# grub.efi is newer than either grub.sh or grub.cfg then grub.sh will
|
||||
# exit with success meaning that if you move your own version of grub
|
||||
# in here (after checking out grub.sh and grub.cfg), PREBUILD won't
|
||||
# overwrite it.
|
||||
##
|
||||
[Binaries]
|
||||
PE32|grub.efi|*
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
## @file
|
||||
# Execute a script to recover the SEV supplied secret and use it to
|
||||
# decrypt a luks volume. For security, the kernel must be on an encrypted
|
||||
# volume so reboot if none are found.
|
||||
#
|
||||
# Copyright (C) 2020 James Bottomley, IBM Corporation.
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#
|
||||
##
|
||||
|
||||
echo "Entering grub config"
|
||||
sevsecret
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to locate anything in the SEV secret area, prompting for password"
|
||||
cryptomount -a
|
||||
else
|
||||
cryptomount -s
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Failed to mount root securely, retrying with password prompt"
|
||||
cryptomount -a
|
||||
fi
|
||||
fi
|
||||
set root=
|
||||
for f in (crypto*); do
|
||||
if [ -e $f/boot/grub/grub.cfg ]; then
|
||||
set root=$f
|
||||
set prefix=($root)/boot/grub
|
||||
break;
|
||||
fi
|
||||
done
|
||||
if [ x$root = x ]; then
|
||||
echo "Failed to find any grub configuration on the encrypted volume"
|
||||
sleep 5
|
||||
reboot
|
||||
fi
|
||||
# rest of modules to get boot to work
|
||||
set modules="
|
||||
boot
|
||||
loadenv
|
||||
"
|
||||
for f in $modules; do
|
||||
insmod $f
|
||||
done
|
||||
echo "Transferring to ${prefix}/grub.cfg"
|
||||
source $prefix/grub.cfg
|
|
@ -0,0 +1,93 @@
|
|||
## @file
|
||||
# Build a version of grub capable of decrypting a luks volume with a SEV
|
||||
# Supplied secret
|
||||
#
|
||||
# Copyright (C) 2020 James Bottomley, IBM Corporation.
|
||||
#
|
||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#
|
||||
##
|
||||
|
||||
set -e
|
||||
remove_efi=1
|
||||
|
||||
cleanup() {
|
||||
# remove the intermediates
|
||||
for f in disk.fat grub-bootstrap.cfg; do
|
||||
rm -f -- "${basedir}/$f"
|
||||
done
|
||||
if [ $remove_efi -eq 1 ]; then
|
||||
rm -f -- "${basedir}/grub.efi"
|
||||
fi
|
||||
}
|
||||
|
||||
trap cleanup EXIT
|
||||
|
||||
GRUB_MODULES="
|
||||
part_msdos
|
||||
part_gpt
|
||||
cryptodisk
|
||||
luks
|
||||
gcry_rijndael
|
||||
gcry_sha256
|
||||
ext2
|
||||
btrfs
|
||||
xfs
|
||||
fat
|
||||
configfile
|
||||
memdisk
|
||||
sleep
|
||||
normal
|
||||
echo
|
||||
test
|
||||
regexp
|
||||
linux
|
||||
linuxefi
|
||||
reboot
|
||||
sevsecret
|
||||
"
|
||||
basedir=$(dirname -- "$0")
|
||||
|
||||
# don't run a build if grub.efi exists and is newer than the config files
|
||||
if [ -e "${basedir}/grub.efi" ] && \
|
||||
[ "${basedir}/grub.efi" -nt "${basedir}/grub.cfg" ] && \
|
||||
[ "${basedir}/grub.efi" -nt "${basedir}/grub.sh" ]; then
|
||||
remove_efi=0
|
||||
echo "preserving existing grub.efi" >&2
|
||||
exit 0
|
||||
fi
|
||||
|
||||
##
|
||||
# different distributions have different names for grub-mkimage, so
|
||||
# search all the known ones
|
||||
##
|
||||
mkimage=
|
||||
for b in grub2-mkimage grub-mkimage; do
|
||||
if which "$b" > /dev/null 2>&1; then
|
||||
mkimage="$b"
|
||||
break
|
||||
fi
|
||||
done
|
||||
if [ -z "$mkimage" ]; then
|
||||
echo "Can't find grub mkimage" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# GRUB's rescue parser doesn't understand 'if'.
|
||||
echo 'normal (memdisk)/grub.cfg' > "${basedir}/grub-bootstrap.cfg"
|
||||
|
||||
# Now build a memdisk with the correct grub.cfg
|
||||
rm -f -- "${basedir}/disk.fat"
|
||||
mkfs.msdos -C -- "${basedir}/disk.fat" 64
|
||||
mcopy -i "${basedir}/disk.fat" -- "${basedir}/grub.cfg" ::grub.cfg
|
||||
|
||||
|
||||
${mkimage} -O x86_64-efi \
|
||||
-p '(crypto0)' \
|
||||
-c "${basedir}/grub-bootstrap.cfg" \
|
||||
-m "${basedir}/disk.fat" \
|
||||
-o "${basedir}/grub.efi" \
|
||||
${GRUB_MODULES}
|
||||
|
||||
remove_efi=0
|
||||
echo "grub.efi generated in ${basedir}"
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,175 @@
|
|||
/** @file
|
||||
Platform BDS customizations include file.
|
||||
|
||||
Copyright (C) 2020 James Bottomley, IBM Corporation.
|
||||
Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
Module Name:
|
||||
|
||||
BdsPlatform.h
|
||||
|
||||
Abstract:
|
||||
|
||||
Head file for BDS Platform specific code
|
||||
|
||||
**/
|
||||
|
||||
#ifndef _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
|
||||
#define _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
|
||||
|
||||
|
||||
#include <PiDxe.h>
|
||||
|
||||
#include <IndustryStandard/Pci.h>
|
||||
#include <IndustryStandard/Acpi.h>
|
||||
#include <IndustryStandard/SmBios.h>
|
||||
#include <IndustryStandard/PeImage.h>
|
||||
#include <IndustryStandard/Virtio095.h>
|
||||
|
||||
#include <Library/DebugLib.h>
|
||||
#include <Library/BaseMemoryLib.h>
|
||||
#include <Library/UefiBootServicesTableLib.h>
|
||||
#include <Library/UefiRuntimeServicesTableLib.h>
|
||||
#include <Library/MemoryAllocationLib.h>
|
||||
#include <Library/BaseLib.h>
|
||||
#include <Library/PcdLib.h>
|
||||
#include <Library/PciLib.h>
|
||||
#include <Library/UefiBootManagerLib.h>
|
||||
#include <Library/BootLogoLib.h>
|
||||
#include <Library/HobLib.h>
|
||||
#include <Library/UefiLib.h>
|
||||
#include <Library/DxeServicesTableLib.h>
|
||||
#include <Library/DevicePathLib.h>
|
||||
#include <Library/IoLib.h>
|
||||
|
||||
#include <Protocol/Decompress.h>
|
||||
#include <Protocol/PciIo.h>
|
||||
#include <Protocol/FirmwareVolume2.h>
|
||||
#include <Protocol/SimpleFileSystem.h>
|
||||
#include <Protocol/PciRootBridgeIo.h>
|
||||
#include <Protocol/DxeSmmReadyToLock.h>
|
||||
#include <Protocol/LoadedImage.h>
|
||||
|
||||
#include <Guid/Acpi.h>
|
||||
#include <Guid/SmBios.h>
|
||||
#include <Guid/HobList.h>
|
||||
#include <Guid/GlobalVariable.h>
|
||||
#include <Guid/EventGroup.h>
|
||||
#include <Guid/DebugAgentGuid.h>
|
||||
|
||||
#include <OvmfPlatforms.h>
|
||||
|
||||
extern EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[];
|
||||
extern ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode;
|
||||
extern ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode;
|
||||
extern UART_DEVICE_PATH gUartDeviceNode;
|
||||
extern VENDOR_DEVICE_PATH gTerminalTypeDeviceNode;
|
||||
|
||||
#define PCI_DEVICE_PATH_NODE(Func, Dev) \
|
||||
{ \
|
||||
{ \
|
||||
HARDWARE_DEVICE_PATH, \
|
||||
HW_PCI_DP, \
|
||||
{ \
|
||||
(UINT8) (sizeof (PCI_DEVICE_PATH)), \
|
||||
(UINT8) ((sizeof (PCI_DEVICE_PATH)) >> 8) \
|
||||
} \
|
||||
}, \
|
||||
(Func), \
|
||||
(Dev) \
|
||||
}
|
||||
|
||||
#define PNPID_DEVICE_PATH_NODE(PnpId) \
|
||||
{ \
|
||||
{ \
|
||||
ACPI_DEVICE_PATH, \
|
||||
ACPI_DP, \
|
||||
{ \
|
||||
(UINT8) (sizeof (ACPI_HID_DEVICE_PATH)), \
|
||||
(UINT8) ((sizeof (ACPI_HID_DEVICE_PATH)) >> 8) \
|
||||
}, \
|
||||
}, \
|
||||
EISA_PNP_ID((PnpId)), \
|
||||
0 \
|
||||
}
|
||||
|
||||
#define gPciIsaBridge \
|
||||
PCI_DEVICE_PATH_NODE(0, 0x1f)
|
||||
|
||||
#define gP2PBridge \
|
||||
PCI_DEVICE_PATH_NODE(0, 0x1e)
|
||||
|
||||
#define gPnpPs2Keyboard \
|
||||
PNPID_DEVICE_PATH_NODE(0x0303)
|
||||
|
||||
#define gPnp16550ComPort \
|
||||
PNPID_DEVICE_PATH_NODE(0x0501)
|
||||
|
||||
#define gUart \
|
||||
{ \
|
||||
{ \
|
||||
MESSAGING_DEVICE_PATH, \
|
||||
MSG_UART_DP, \
|
||||
{ \
|
||||
(UINT8) (sizeof (UART_DEVICE_PATH)), \
|
||||
(UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8) \
|
||||
} \
|
||||
}, \
|
||||
0, \
|
||||
115200, \
|
||||
8, \
|
||||
1, \
|
||||
1 \
|
||||
}
|
||||
|
||||
#define gPcAnsiTerminal \
|
||||
{ \
|
||||
{ \
|
||||
MESSAGING_DEVICE_PATH, \
|
||||
MSG_VENDOR_DP, \
|
||||
{ \
|
||||
(UINT8) (sizeof (VENDOR_DEVICE_PATH)), \
|
||||
(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8) \
|
||||
} \
|
||||
}, \
|
||||
DEVICE_PATH_MESSAGING_PC_ANSI \
|
||||
}
|
||||
|
||||
#define gEndEntire \
|
||||
{ \
|
||||
END_DEVICE_PATH_TYPE, \
|
||||
END_ENTIRE_DEVICE_PATH_SUBTYPE, \
|
||||
{ \
|
||||
END_DEVICE_PATH_LENGTH, \
|
||||
0 \
|
||||
} \
|
||||
}
|
||||
|
||||
#define PCI_CLASS_SCC 0x07
|
||||
#define PCI_SUBCLASS_SERIAL 0x00
|
||||
#define PCI_IF_16550 0x02
|
||||
#define IS_PCI_16550SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550)
|
||||
#define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)
|
||||
|
||||
typedef struct {
|
||||
EFI_DEVICE_PATH_PROTOCOL *DevicePath;
|
||||
UINTN ConnectType;
|
||||
} PLATFORM_CONSOLE_CONNECT_ENTRY;
|
||||
|
||||
#define CONSOLE_OUT BIT0
|
||||
#define CONSOLE_IN BIT1
|
||||
#define STD_ERROR BIT2
|
||||
extern PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[];
|
||||
extern PLATFORM_CONSOLE_CONNECT_ENTRY gXenPlatformConsole[];
|
||||
|
||||
//
|
||||
// Platform BDS Functions
|
||||
//
|
||||
|
||||
VOID
|
||||
PlatformInitializeConsole (
|
||||
IN PLATFORM_CONSOLE_CONNECT_ENTRY *PlatformConsole
|
||||
);
|
||||
|
||||
#endif // _PLATFORM_SPECIFIC_BDS_PLATFORM_H_
|
|
@ -0,0 +1,71 @@
|
|||
## @file
|
||||
# Platform BDS customizations library.
|
||||
#
|
||||
# Copyright (C) 2020 James Bottomley, IBM Corporation.
|
||||
# Copyright (c) 2007 - 2019, Intel Corporation. All rights reserved.<BR>
|
||||
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
#
|
||||
##
|
||||
|
||||
[Defines]
|
||||
INF_VERSION = 0x00010005
|
||||
BASE_NAME = PlatformBootManagerLibGrub
|
||||
FILE_GUID = 3a8f8431-f0c9-4c95-8a1d-04445c582d4e
|
||||
MODULE_TYPE = DXE_DRIVER
|
||||
VERSION_STRING = 1.0
|
||||
LIBRARY_CLASS = PlatformBootManagerLib|DXE_DRIVER
|
||||
|
||||
#
|
||||
# The following information is for reference only and not required by the build tools.
|
||||
#
|
||||
# VALID_ARCHITECTURES = X64
|
||||
#
|
||||
|
||||
[Sources]
|
||||
BdsPlatform.c
|
||||
PlatformData.c
|
||||
BdsPlatform.h
|
||||
|
||||
[Packages]
|
||||
MdePkg/MdePkg.dec
|
||||
MdeModulePkg/MdeModulePkg.dec
|
||||
SourceLevelDebugPkg/SourceLevelDebugPkg.dec
|
||||
OvmfPkg/OvmfPkg.dec
|
||||
SecurityPkg/SecurityPkg.dec
|
||||
ShellPkg/ShellPkg.dec
|
||||
|
||||
[LibraryClasses]
|
||||
BaseLib
|
||||
MemoryAllocationLib
|
||||
UefiBootServicesTableLib
|
||||
UefiRuntimeServicesTableLib
|
||||
BaseMemoryLib
|
||||
DebugLib
|
||||
PcdLib
|
||||
UefiBootManagerLib
|
||||
BootLogoLib
|
||||
DevicePathLib
|
||||
PciLib
|
||||
UefiLib
|
||||
PlatformBmPrintScLib
|
||||
Tcg2PhysicalPresenceLib
|
||||
|
||||
[Pcd]
|
||||
gUefiOvmfPkgTokenSpaceGuid.PcdOvmfHostBridgePciDevId
|
||||
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate ## CONSUMES
|
||||
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits ## CONSUMES
|
||||
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity ## CONSUMES
|
||||
gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits ## CONSUMES
|
||||
|
||||
[Protocols]
|
||||
gEfiPciRootBridgeIoProtocolGuid
|
||||
gEfiDxeSmmReadyToLockProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
|
||||
gEfiLoadedImageProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
|
||||
gEfiFirmwareVolume2ProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
|
||||
|
||||
[Guids]
|
||||
gEfiEndOfDxeEventGroupGuid
|
||||
gEfiGlobalVariableGuid
|
||||
gRootBridgesConnectedEventGroupGuid
|
||||
gUefiShellFileGuid
|
||||
gGrubFileGuid
|
|
@ -0,0 +1,214 @@
|
|||
/** @file
|
||||
Defined the platform specific device path which will be used by
|
||||
platform Bbd to perform the platform policy connect.
|
||||
|
||||
Copyright (C) 2020 James Bottomley, IBM Corporation.
|
||||
Copyright (c) 2004 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||
SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
**/
|
||||
|
||||
#include "BdsPlatform.h"
|
||||
#include <Guid/QemuRamfb.h>
|
||||
#include <Guid/SerialPortLibVendor.h>
|
||||
|
||||
//
|
||||
// Vendor UART Device Path structure
|
||||
//
|
||||
#pragma pack (1)
|
||||
typedef struct {
|
||||
VENDOR_DEVICE_PATH VendorHardware;
|
||||
UART_DEVICE_PATH Uart;
|
||||
VENDOR_DEVICE_PATH TerminalType;
|
||||
EFI_DEVICE_PATH_PROTOCOL End;
|
||||
} VENDOR_UART_DEVICE_PATH;
|
||||
#pragma pack ()
|
||||
|
||||
//
|
||||
// USB Keyboard Device Path structure
|
||||
//
|
||||
#pragma pack (1)
|
||||
typedef struct {
|
||||
USB_CLASS_DEVICE_PATH Keyboard;
|
||||
EFI_DEVICE_PATH_PROTOCOL End;
|
||||
} USB_KEYBOARD_DEVICE_PATH;
|
||||
#pragma pack ()
|
||||
|
||||
//
|
||||
// QemuRamfb Device Path structure
|
||||
//
|
||||
#pragma pack (1)
|
||||
typedef struct {
|
||||
VENDOR_DEVICE_PATH Vendor;
|
||||
ACPI_ADR_DEVICE_PATH AcpiAdr;
|
||||
EFI_DEVICE_PATH_PROTOCOL End;
|
||||
} VENDOR_RAMFB_DEVICE_PATH;
|
||||
#pragma pack ()
|
||||
|
||||
ACPI_HID_DEVICE_PATH gPnpPs2KeyboardDeviceNode = gPnpPs2Keyboard;
|
||||
ACPI_HID_DEVICE_PATH gPnp16550ComPortDeviceNode = gPnp16550ComPort;
|
||||
UART_DEVICE_PATH gUartDeviceNode = gUart;
|
||||
VENDOR_DEVICE_PATH gTerminalTypeDeviceNode = gPcAnsiTerminal;
|
||||
|
||||
//
|
||||
// Platform specific keyboard device path
|
||||
//
|
||||
|
||||
|
||||
//
|
||||
// Debug Agent UART Device Path
|
||||
//
|
||||
VENDOR_UART_DEVICE_PATH gDebugAgentUartDevicePath = {
|
||||
{
|
||||
{
|
||||
HARDWARE_DEVICE_PATH,
|
||||
HW_VENDOR_DP,
|
||||
{
|
||||
(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
|
||||
(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
|
||||
}
|
||||
},
|
||||
EFI_DEBUG_AGENT_GUID,
|
||||
},
|
||||
{
|
||||
{
|
||||
MESSAGING_DEVICE_PATH,
|
||||
MSG_UART_DP,
|
||||
{
|
||||
(UINT8) (sizeof (UART_DEVICE_PATH)),
|
||||
(UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8)
|
||||
}
|
||||
},
|
||||
0, // Reserved
|
||||
0, // BaudRate - Default
|
||||
0, // DataBits - Default
|
||||
0, // Parity - Default
|
||||
0, // StopBits - Default
|
||||
},
|
||||
gPcAnsiTerminal,
|
||||
gEndEntire
|
||||
};
|
||||
|
||||
STATIC USB_KEYBOARD_DEVICE_PATH gUsbKeyboardDevicePath = {
|
||||
{
|
||||
{
|
||||
MESSAGING_DEVICE_PATH,
|
||||
MSG_USB_CLASS_DP,
|
||||
{
|
||||
(UINT8)sizeof (USB_CLASS_DEVICE_PATH),
|
||||
(UINT8)(sizeof (USB_CLASS_DEVICE_PATH) >> 8)
|
||||
}
|
||||
},
|
||||
0xFFFF, // VendorId: any
|
||||
0xFFFF, // ProductId: any
|
||||
3, // DeviceClass: HID
|
||||
1, // DeviceSubClass: boot
|
||||
1 // DeviceProtocol: keyboard
|
||||
},
|
||||
gEndEntire
|
||||
};
|
||||
|
||||
STATIC VENDOR_RAMFB_DEVICE_PATH gQemuRamfbDevicePath = {
|
||||
{
|
||||
{
|
||||
HARDWARE_DEVICE_PATH,
|
||||
HW_VENDOR_DP,
|
||||
{
|
||||
(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
|
||||
(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
|
||||
}
|
||||
},
|
||||
QEMU_RAMFB_GUID,
|
||||
},
|
||||
{
|
||||
{
|
||||
ACPI_DEVICE_PATH,
|
||||
ACPI_ADR_DP,
|
||||
{
|
||||
(UINT8) (sizeof (ACPI_ADR_DEVICE_PATH)),
|
||||
(UINT8) ((sizeof (ACPI_ADR_DEVICE_PATH)) >> 8)
|
||||
}
|
||||
},
|
||||
ACPI_DISPLAY_ADR (
|
||||
1, // DeviceIdScheme
|
||||
0, // HeadId
|
||||
0, // NonVgaOutput
|
||||
1, // BiosCanDetect
|
||||
0, // VendorInfo
|
||||
ACPI_ADR_DISPLAY_TYPE_EXTERNAL_DIGITAL, // Type
|
||||
0, // Port
|
||||
0 // Index
|
||||
),
|
||||
},
|
||||
gEndEntire
|
||||
};
|
||||
|
||||
STATIC VENDOR_UART_DEVICE_PATH gXenConsoleDevicePath = {
|
||||
{
|
||||
{
|
||||
HARDWARE_DEVICE_PATH,
|
||||
HW_VENDOR_DP,
|
||||
{
|
||||
(UINT8) (sizeof (VENDOR_DEVICE_PATH)),
|
||||
(UINT8) ((sizeof (VENDOR_DEVICE_PATH)) >> 8)
|
||||
}
|
||||
},
|
||||
EDKII_SERIAL_PORT_LIB_VENDOR_GUID
|
||||
},
|
||||
{
|
||||
{
|
||||
MESSAGING_DEVICE_PATH,
|
||||
MSG_UART_DP,
|
||||
{
|
||||
(UINT8) (sizeof (UART_DEVICE_PATH)),
|
||||
(UINT8) ((sizeof (UART_DEVICE_PATH)) >> 8)
|
||||
}
|
||||
},
|
||||
0,
|
||||
FixedPcdGet64 (PcdUartDefaultBaudRate),
|
||||
FixedPcdGet8 (PcdUartDefaultDataBits),
|
||||
FixedPcdGet8 (PcdUartDefaultParity),
|
||||
FixedPcdGet8 (PcdUartDefaultStopBits),
|
||||
},
|
||||
gPcAnsiTerminal,
|
||||
gEndEntire
|
||||
};
|
||||
|
||||
//
|
||||
// Predefined platform default console device path
|
||||
//
|
||||
PLATFORM_CONSOLE_CONNECT_ENTRY gPlatformConsole[] = {
|
||||
{
|
||||
(EFI_DEVICE_PATH_PROTOCOL *) &gDebugAgentUartDevicePath,
|
||||
(CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
|
||||
},
|
||||
{
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&gUsbKeyboardDevicePath,
|
||||
CONSOLE_IN
|
||||
},
|
||||
{
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&gQemuRamfbDevicePath,
|
||||
CONSOLE_OUT
|
||||
},
|
||||
{
|
||||
NULL,
|
||||
0
|
||||
}
|
||||
};
|
||||
|
||||
PLATFORM_CONSOLE_CONNECT_ENTRY gXenPlatformConsole[] = {
|
||||
{
|
||||
(EFI_DEVICE_PATH_PROTOCOL *)&gXenConsoleDevicePath,
|
||||
(CONSOLE_OUT | CONSOLE_IN | STD_ERROR)
|
||||
},
|
||||
{
|
||||
NULL,
|
||||
0
|
||||
}
|
||||
};
|
||||
|
||||
//
|
||||
// Predefined platform connect sequence
|
||||
//
|
||||
EFI_DEVICE_PATH_PROTOCOL *gPlatformConnectSequence[] = { NULL };
|
||||
|
|
@ -79,7 +79,7 @@
|
|||
"IgnoreGuidName": ["ResetVector", "XenResetVector"], # Expected duplication for gEfiFirmwareVolumeTopFileGuid
|
||||
"IgnoreGuidValue": [],
|
||||
"IgnoreFoldersAndFiles": [],
|
||||
"IgnoreDuplicates": [],
|
||||
"IgnoreDuplicates": ["gGrubFileGuid=Grub"],
|
||||
},
|
||||
|
||||
## options defined .pytool/Plugin/LibraryClassCheck
|
||||
|
|
|
@ -116,6 +116,7 @@
|
|||
gEfiLegacyDevOrderVariableGuid = {0xa56074db, 0x65fe, 0x45f7, {0xbd, 0x21, 0x2d, 0x2b, 0xdd, 0x8e, 0x96, 0x52}}
|
||||
gLinuxEfiInitrdMediaGuid = {0x5568e427, 0x68fc, 0x4f3d, {0xac, 0x74, 0xca, 0x55, 0x52, 0x31, 0xcc, 0x68}}
|
||||
gQemuKernelLoaderFsMediaGuid = {0x1428f772, 0xb64a, 0x441e, {0xb8, 0xc3, 0x9e, 0xbd, 0xd7, 0xf8, 0x93, 0xc7}}
|
||||
gGrubFileGuid = {0xb5ae312c, 0xbc8a, 0x43b1, {0x9c, 0x62, 0xeb, 0xb8, 0x26, 0xdd, 0x5d, 0x07}}
|
||||
|
||||
[Ppis]
|
||||
# PPI whose presence in the PPI database signals that the TPM base address
|
||||
|
|
Loading…
Reference in New Issue