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>)]
176 lines
4.2 KiB
C
176 lines
4.2 KiB
C
/** @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_
|