summaryrefslogtreecommitdiff
path: root/Platform/RaspberryPi/RPi3
diff options
context:
space:
mode:
authorPete Batard <pete@akeo.ie>2019-10-21 12:25:06 +0100
committerLeif Lindholm <leif.lindholm@linaro.org>2019-10-21 15:32:32 +0100
commit03f36b8fcfb7dee4c1c8fe8af7633854afc16916 (patch)
tree394c9d4c1e5a5fdcca2d7af9d56c8d95d3193fbe /Platform/RaspberryPi/RPi3
parent6c9506aa44f09f47dfe7c4f0ba43c32a919205bc (diff)
Platforms/RPi3: Restructure platform in preparation for Pi 4
In preparation for adding Raspberry Pi 4 support, the Pi 3 platform is restructured by factorizing all the drivers and libraries that are going to be commonly used by the two platforms. Because much of the Pi 4 SoC is an extension of the Pi 3 one this means that almost everything, except the ACPI tables, is moved up into a new common RaspberryPi/ subdirectory that will serve both platforms. The .dec is also moved to this directory, under a new RaspberryPi.dec name, and existing references to it are updated. This commit requires the edk2-non-osi in use to contain commit 243e55f622ea in order to build. Signed-off-by: Pete Batard <pete@akeo.ie> Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com> Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Diffstat (limited to 'Platform/RaspberryPi/RPi3')
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c717
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.h44
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.inf47
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c357
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf73
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeFormSetGuid.h17
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni107
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr365
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/ComponentName.c216
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.c639
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.h36
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.inf66
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/Screenshot.c369
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/ComponentName.c219
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DriverBinding.c268
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c1635
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.h156
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf55
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwcHw.h782
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c579
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.inf50
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/ComponentName.c177
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/GraphicsConsole.c1831
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/GraphicsConsole.h585
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/GraphicsConsoleDxe.inf68
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/GraphicsConsoleDxe.uni12
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/GraphicsConsoleDxeExtra.uni12
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/NewFont.c281
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/MmcDxe/ComponentName.c157
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/MmcDxe/Diagnostics.c257
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/MmcDxe/Mmc.c454
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/MmcDxe/Mmc.h527
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcBlockIo.c463
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcDebug.c164
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcDxe.inf53
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcIdentification.c974
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c944
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf52
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c1241
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf44
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/SdHostDxe/SdHostDxe.c781
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/SdHostDxe/SdHostDxe.inf49
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/FileIo.c190
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/FvbInfo.c109
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockService.c965
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockService.h211
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c325
-rw-r--r--Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf87
-rw-r--r--Platform/RaspberryPi/RPi3/Include/IndustryStandard/RpiMbox.h84
-rw-r--r--Platform/RaspberryPi/RPi3/Include/Protocol/DwUsb.h47
-rw-r--r--Platform/RaspberryPi/RPi3/Include/Protocol/ExtendedTextOut.h30
-rw-r--r--Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h154
-rw-r--r--Platform/RaspberryPi/RPi3/Include/Protocol/RpiMmcHost.h200
-rw-r--r--Platform/RaspberryPi/RPi3/Library/MemoryInitPeiLib/MemoryInitPeiLib.c156
-rw-r--r--Platform/RaspberryPi/RPi3/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf45
-rw-r--r--Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.c788
-rw-r--r--Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.h54
-rw-r--r--Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf84
-rw-r--r--Platform/RaspberryPi/RPi3/Library/PlatformLib/AArch64/RaspberryPiHelper.S101
-rw-r--r--Platform/RaspberryPi/RPi3/Library/PlatformLib/PlatformLib.inf59
-rw-r--r--Platform/RaspberryPi/RPi3/Library/PlatformLib/RaspberryPi.c93
-rw-r--r--Platform/RaspberryPi/RPi3/Library/PlatformLib/RaspberryPiMem.c154
-rw-r--r--Platform/RaspberryPi/RPi3/Library/PlatformUiAppLib/PlatformUiAppLib.c114
-rw-r--r--Platform/RaspberryPi/RPi3/Library/PlatformUiAppLib/PlatformUiAppLib.inf42
-rw-r--r--Platform/RaspberryPi/RPi3/Library/ResetLib/ResetLib.c98
-rw-r--r--Platform/RaspberryPi/RPi3/Library/ResetLib/ResetLib.inf40
-rw-r--r--Platform/RaspberryPi/RPi3/RPi3.dec58
-rw-r--r--Platform/RaspberryPi/RPi3/RPi3.dsc34
-rw-r--r--Platform/RaspberryPi/RPi3/RPi3.fdf24
69 files changed, 29 insertions, 20240 deletions
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c b/Platform/RaspberryPi/RPi3/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c
deleted file mode 100644
index 6d706af6..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.c
+++ /dev/null
@@ -1,717 +0,0 @@
-/** @file
- *
- * Copyright (c) 2017, Andrei Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) Microsoft Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include "ArasanMmcHostDxe.h"
-
-#define DEBUG_MMCHOST_SD DEBUG_VERBOSE
-
-BOOLEAN PreviousIsCardPresent = FALSE;
-UINT32 LastExecutedCommand = (UINT32) -1;
-
-STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol;
-
-/**
- These SD commands are optional, according to the SD Spec
-**/
-BOOLEAN
-IgnoreCommand (
- UINT32 Command
- )
-{
- switch (Command) {
- case MMC_CMD20:
- return TRUE;
- default:
- return FALSE;
- }
-}
-
-/**
- Translates a generic SD command into the format used by the Arasan SD Host Controller
-**/
-UINT32
-TranslateCommand (
- UINT32 Command,
- UINT32 Argument
- )
-{
- UINT32 Translation = 0xffffffff;
-
- if (LastExecutedCommand == CMD55) {
- switch (Command) {
- case MMC_CMD6:
- Translation = ACMD6;
- DEBUG ((DEBUG_MMCHOST_SD, "ACMD6\n"));
- break;
- case MMC_ACMD22:
- Translation = ACMD22;
- DEBUG ((DEBUG_MMCHOST_SD, "ACMD22\n"));
- break;
- case MMC_ACMD41:
- Translation = ACMD41;
- DEBUG ((DEBUG_MMCHOST_SD, "ACMD41\n"));
- break;
- case MMC_ACMD51:
- Translation = ACMD51;
- DEBUG ((DEBUG_MMCHOST_SD, "ACMD51\n"));
- break;
- default:
- DEBUG ((DEBUG_ERROR, "ArasanMMCHost: TranslateCommand(): Unrecognized App command: %d\n", Command));
- }
- } else {
- switch (Command) {
- case MMC_CMD0:
- Translation = CMD0;
- break;
- case MMC_CMD1:
- Translation = CMD1;
- break;
- case MMC_CMD2:
- Translation = CMD2;
- break;
- case MMC_CMD3:
- Translation = CMD3;
- break;
- case MMC_CMD5:
- Translation = CMD5;
- break;
- case MMC_CMD6:
- Translation = CMD6;
- break;
- case MMC_CMD7:
- Translation = CMD7;
- break;
- case MMC_CMD8: {
- if (Argument == CMD8_SD_ARG) {
- Translation = CMD8_SD;
- DEBUG ((DEBUG_MMCHOST_SD, "Sending SD CMD8 variant\n"));
- } else {
- ASSERT (Argument == CMD8_MMC_ARG);
- Translation = CMD8_MMC;
- DEBUG ((DEBUG_MMCHOST_SD, "Sending MMC CMD8 variant\n"));
- }
- break;
- }
- case MMC_CMD9:
- Translation = CMD9;
- break;
- case MMC_CMD11:
- Translation = CMD11;
- break;
- case MMC_CMD12:
- Translation = CMD12;
- break;
- case MMC_CMD13:
- Translation = CMD13;
- break;
- case MMC_CMD16:
- Translation = CMD16;
- break;
- case MMC_CMD17:
- Translation = CMD17;
- break;
- case MMC_CMD18:
- Translation = CMD18;
- break;
- case MMC_CMD23:
- Translation = CMD23;
- break;
- case MMC_CMD24:
- Translation = CMD24;
- break;
- case MMC_CMD25:
- Translation = CMD25;
- break;
- case MMC_CMD55:
- Translation = CMD55;
- break;
- default:
- DEBUG ((DEBUG_ERROR, "ArasanMMCHost: TranslateCommand(): Unrecognized Command: %d\n", Command));
- }
- }
-
- return Translation;
-}
-
-/**
- Repeatedly polls a register until its value becomes correct, or until MAX_RETRY_COUNT polls is reached
-**/
-EFI_STATUS
-PollRegisterWithMask (
- IN UINTN Register,
- IN UINTN Mask,
- IN UINTN ExpectedValue
- )
-{
- UINTN RetryCount = 0;
-
- while (RetryCount < MAX_RETRY_COUNT) {
- if ((MmioRead32 (Register) & Mask) != ExpectedValue) {
- RetryCount++;
- gBS->Stall (STALL_AFTER_RETRY_US);
- } else {
- break;
- }
- }
-
- if (RetryCount == MAX_RETRY_COUNT) {
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-SoftReset (
- IN UINT32 Mask
- )
-{
- MmioOr32 (MMCHS_SYSCTL, Mask);
- if (PollRegisterWithMask (MMCHS_SYSCTL, Mask, 0) == EFI_TIMEOUT) {
- DEBUG ((DEBUG_ERROR, "Failed to SoftReset with mask 0x%x\n", Mask));
- return EFI_TIMEOUT;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Calculate the clock divisor
-**/
-EFI_STATUS
-CalculateClockFrequencyDivisor (
- IN UINTN TargetFrequency,
- OUT UINT32 *DivisorValue,
- OUT UINTN *ActualFrequency
- )
-{
- EFI_STATUS Status;
- UINT32 Divisor;
- UINT32 BaseFrequency = 0;
-
- Status = mFwProtocol->GetClockRate (RPI_MBOX_CLOCK_RATE_EMMC, &BaseFrequency);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Couldn't get RPI_MBOX_CLOCK_RATE_EMMC\n"));
- return Status;
- }
-
- ASSERT (BaseFrequency != 0);
- Divisor = BaseFrequency / TargetFrequency;
-
- // Arasan controller is based on 3.0 spec so the div is multiple of 2
- // Actual Frequency = BaseFequency/(Div*2)
- Divisor /= 2;
-
- if ((TargetFrequency < BaseFrequency) &&
- (TargetFrequency * 2 * Divisor != BaseFrequency)) {
- Divisor += 1;
- }
-
- if (Divisor > MAX_DIVISOR_VALUE) {
- Divisor = MAX_DIVISOR_VALUE;
- }
-
- DEBUG ((DEBUG_MMCHOST_SD, "ArasanMMCHost: BaseFrequency 0x%x Divisor 0x%x\n", BaseFrequency, Divisor));
-
- *DivisorValue = (Divisor & 0xFF) << 8;
- Divisor >>= 8;
- *DivisorValue |= (Divisor & 0x03) << 6;
-
- if (ActualFrequency) {
- if (Divisor == 0) {
- *ActualFrequency = BaseFrequency;
- } else {
- *ActualFrequency = BaseFrequency / Divisor;
- *ActualFrequency >>= 1;
- }
- DEBUG ((DEBUG_MMCHOST_SD, "ArasanMMCHost: *ActualFrequency 0x%x\n", *ActualFrequency));
- }
-
- DEBUG ((DEBUG_MMCHOST_SD, "ArasanMMCHost: *DivisorValue 0x%x\n", *DivisorValue));
-
- return EFI_SUCCESS;
-}
-
-BOOLEAN
-MMCIsCardPresent (
- IN EFI_MMC_HOST_PROTOCOL *This
-)
-{
- return TRUE;
-}
-
-BOOLEAN
-MMCIsReadOnly (
- IN EFI_MMC_HOST_PROTOCOL *This
- )
-{
- BOOLEAN IsReadOnly = !((MmioRead32 (MMCHS_PRES_STATE) & WRITE_PROTECT_OFF) == WRITE_PROTECT_OFF);
- DEBUG ((DEBUG_MMCHOST_SD, "ArasanMMCHost: MMCIsReadOnly(): %d\n", IsReadOnly));
- return IsReadOnly;
-}
-
-EFI_STATUS
-MMCBuildDevicePath (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN EFI_DEVICE_PATH_PROTOCOL **DevicePath
- )
-{
- EFI_DEVICE_PATH_PROTOCOL *NewDevicePathNode;
- EFI_GUID DevicePathGuid = EFI_CALLER_ID_GUID;
-
- DEBUG ((DEBUG_MMCHOST_SD, "ArasanMMCHost: MMCBuildDevicePath()\n"));
-
- NewDevicePathNode = CreateDeviceNode (HARDWARE_DEVICE_PATH, HW_VENDOR_DP, sizeof (VENDOR_DEVICE_PATH));
- CopyGuid (&((VENDOR_DEVICE_PATH*) NewDevicePathNode)->Guid, &DevicePathGuid);
- *DevicePath = NewDevicePathNode;
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-MMCSendCommand (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN MMC_CMD MmcCmd,
- IN UINT32 Argument
- )
-{
- UINTN MmcStatus;
- UINTN RetryCount = 0;
- UINTN CmdSendOKMask;
- EFI_STATUS Status = EFI_SUCCESS;
- BOOLEAN IsAppCmd = (LastExecutedCommand == CMD55);
- BOOLEAN IsDATCmd = FALSE;
- BOOLEAN IsADTCCmd = FALSE;
-
- DEBUG ((DEBUG_MMCHOST_SD, "ArasanMMCHost: MMCSendCommand(MmcCmd: %08x, Argument: %08x)\n", MmcCmd, Argument));
-
- if (IgnoreCommand (MmcCmd)) {
- return EFI_SUCCESS;
- }
-
- MmcCmd = TranslateCommand (MmcCmd, Argument);
- if (MmcCmd == 0xffffffff) {
- return EFI_UNSUPPORTED;
- }
-
- if ((MmcCmd & CMD_R1_ADTC) == CMD_R1_ADTC) {
- IsADTCCmd = TRUE;
- }
- if (((MmcCmd & CMD_R1B) == CMD_R1B &&
- /*
- * Abort commands don't get inhibited by DAT.
- */
- (MmcCmd & TYPE (CMD_TYPE_ABORT)) != TYPE (CMD_TYPE_ABORT)) ||
- IsADTCCmd ||
- /*
- * We want to detect BRR/BWR change.
- */
- MmcCmd == CMD_SEND_STATUS) {
- IsDATCmd = TRUE;
- }
-
- CmdSendOKMask = CMDI_MASK;
- if (IsDATCmd) {
- CmdSendOKMask |= DATI_MASK;
- }
-
- if (PollRegisterWithMask (MMCHS_PRES_STATE,
- CmdSendOKMask, 0) == EFI_TIMEOUT) {
- DEBUG ((DEBUG_ERROR, "%a(%u): not ready for MMC_CMD%u PresState 0x%x MmcStatus 0x%x\n",
- __FUNCTION__, __LINE__, MMC_CMD_NUM (MmcCmd),
- MmioRead32 (MMCHS_PRES_STATE), MmioRead32 (MMCHS_INT_STAT)));
- Status = EFI_TIMEOUT;
- goto Exit;
- }
-
- if (IsAppCmd && MmcCmd == ACMD22) {
- MmioWrite32 (MMCHS_BLK, 4);
- } else if (IsAppCmd && MmcCmd == ACMD51) {
- MmioWrite32 (MMCHS_BLK, 8);
- } else if (!IsAppCmd && MmcCmd == CMD6) {
- MmioWrite32 (MMCHS_BLK, 64);
- } else if (IsADTCCmd) {
- MmioWrite32 (MMCHS_BLK, BLEN_512BYTES);
- }
-
- // Set Data timeout counter value to max value.
- MmioAndThenOr32 (MMCHS_SYSCTL, (UINT32) ~DTO_MASK, DTO_VAL);
-
- //
- // Clear Interrupt Status Register, but not the Card Inserted bit
- // to avoid messing with card detection logic.
- //
- MmioWrite32 (MMCHS_INT_STAT, ALL_EN & ~(CARD_INS));
-
- // Set command argument register
- MmioWrite32 (MMCHS_ARG, Argument);
-
- // Send the command
- MmioWrite32 (MMCHS_CMD, MmcCmd);
-
- // Check for the command status.
- while (RetryCount < MAX_RETRY_COUNT) {
- MmcStatus = MmioRead32 (MMCHS_INT_STAT);
-
- // Read status of command response
- if ((MmcStatus & ERRI) != 0) {
- //
- // CMD5 (CMD_IO_SEND_OP_COND) is only valid for SDIO
- // cards and thus expected to fail.
- //
- if (MmcCmd != CMD_IO_SEND_OP_COND) {
- DEBUG ((DEBUG_ERROR, "%a(%u): MMC_CMD%u ERRI MmcStatus 0x%x\n",
- __FUNCTION__, __LINE__, MMC_CMD_NUM (MmcCmd), MmcStatus));
- }
-
- SoftReset (SRC);
-
- Status = EFI_DEVICE_ERROR;
- goto Exit;
- }
-
- // Check if command is completed.
- if ((MmcStatus & CC) == CC) {
- MmioWrite32 (MMCHS_INT_STAT, CC);
- break;
- }
-
- RetryCount++;
- gBS->Stall (STALL_AFTER_RETRY_US);
- }
-
- gBS->Stall (STALL_AFTER_SEND_CMD_US);
-
- if (RetryCount == MAX_RETRY_COUNT) {
- DEBUG ((DEBUG_ERROR, "%a(%u): MMC_CMD%u completion TIMEOUT PresState 0x%x MmcStatus 0x%x\n",
- __FUNCTION__, __LINE__, MMC_CMD_NUM (MmcCmd),
- MmioRead32 (MMCHS_PRES_STATE), MmcStatus));
- Status = EFI_TIMEOUT;
- goto Exit;
- }
-
-Exit:
- if (EFI_ERROR (Status)) {
- LastExecutedCommand = (UINT32) -1;
- } else {
- LastExecutedCommand = MmcCmd;
- }
- return Status;
-}
-
-EFI_STATUS
-MMCNotifyState (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN MMC_STATE State
- )
-{
- EFI_STATUS Status;
- UINTN ClockFrequency;
- UINT32 Divisor;
-
- DEBUG ((DEBUG_MMCHOST_SD, "ArasanMMCHost: MMCNotifyState(State: %d)\n", State));
-
- switch (State) {
- case MmcHwInitializationState:
- {
- EFI_STATUS Status;
- UINT32 Divisor;
-
- Status = SoftReset (SRA);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- // Attempt to set the clock to 400Khz which is the expected initialization speed
- Status = CalculateClockFrequencyDivisor (400000, &Divisor, NULL);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "ArasanMMCHost: MMCNotifyState(): Fail to initialize SD clock\n"));
- return Status;
- }
-
- // Set Data Timeout Counter value, set clock frequency, enable internal clock
- MmioOr32 (MMCHS_SYSCTL, DTO_VAL | Divisor | CEN | ICS | ICE);
-
- // Enable interrupts
- MmioWrite32 (MMCHS_IE, ALL_EN);
- }
- break;
- case MmcIdleState:
- break;
- case MmcReadyState:
- break;
- case MmcIdentificationState:
- break;
- case MmcStandByState:
- ClockFrequency = 25000000;
-
- // First turn off the clock
- MmioAnd32 (MMCHS_SYSCTL, ~CEN);
-
- Status = CalculateClockFrequencyDivisor (ClockFrequency, &Divisor, NULL);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "ArasanMMCHost: MmcStandByState(): Fail to initialize SD clock to %u Hz\n",
- ClockFrequency));
- return Status;
- }
-
- // Setup new divisor
- MmioAndThenOr32 (MMCHS_SYSCTL, (UINT32) ~CLKD_MASK, Divisor);
-
- // Wait for the clock to stabilise
- while ((MmioRead32 (MMCHS_SYSCTL) & ICS_MASK) != ICS);
-
- // Set Data Timeout Counter value, set clock frequency, enable internal clock
- MmioOr32 (MMCHS_SYSCTL, CEN);
- break;
- case MmcTransferState:
- break;
- case MmcSendingDataState:
- break;
- case MmcReceiveDataState:
- break;
- case MmcProgrammingState:
- break;
- case MmcDisconnectState:
- case MmcInvalidState:
- default:
- DEBUG ((DEBUG_ERROR, "ArasanMMCHost: MMCNotifyState(): Invalid State: %d\n", State));
- ASSERT (0);
- }
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-MMCReceiveResponse (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN MMC_RESPONSE_TYPE Type,
- IN UINT32* Buffer
- )
-{
- ASSERT (Buffer != NULL);
-
- if (Type == MMC_RESPONSE_TYPE_R2) {
-
- // 16-byte response
- Buffer[0] = MmioRead32 (MMCHS_RSP10);
- Buffer[1] = MmioRead32 (MMCHS_RSP32);
- Buffer[2] = MmioRead32 (MMCHS_RSP54);
- Buffer[3] = MmioRead32 (MMCHS_RSP76);
-
- Buffer[3] <<= 8;
- Buffer[3] |= (Buffer[2] >> 24) & 0xFF;
- Buffer[2] <<= 8;
- Buffer[2] |= (Buffer[1] >> 24) & 0xFF;
- Buffer[1] <<= 8;
- Buffer[1] |= (Buffer[0] >> 24) & 0xFF;
- Buffer[0] <<= 8;
-
- DEBUG ((DEBUG_MMCHOST_SD,
- "ArasanMMCHost: MMCReceiveResponse(Type: %x), Buffer[0-3]: %08x, %08x, %08x, %08x\n",
- Type, Buffer[0], Buffer[1], Buffer[2], Buffer[3]));
- } else {
- // 4-byte response
- Buffer[0] = MmioRead32 (MMCHS_RSP10);
- DEBUG ((DEBUG_MMCHOST_SD, "ArasanMMCHost: MMCReceiveResponse(Type: %08x), Buffer[0]: %08x\n", Type, Buffer[0]));
- }
-
- gBS->Stall (STALL_AFTER_REC_RESP_US);
- if (LastExecutedCommand == CMD_STOP_TRANSMISSION) {
- DEBUG ((DEBUG_MMCHOST_SD, "ArasanMMCHost: soft-resetting after CMD12\n"));
- return SoftReset (SRC | SRD);
- }
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-MMCReadBlockData (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN EFI_LBA Lba,
- IN UINTN Length,
- IN UINT32* Buffer
- )
-{
- UINTN MmcStatus;
- UINTN RemLength;
- UINTN Count;
-
- DEBUG ((DEBUG_VERBOSE, "%a(%u): LBA: 0x%x, Length: 0x%x, Buffer: 0x%x)\n",
- __FUNCTION__, __LINE__, Lba, Length, Buffer));
-
- if (Buffer == NULL) {
- DEBUG ((DEBUG_ERROR, "%a(%u): NULL Buffer\n", __FUNCTION__, __LINE__));
- return EFI_INVALID_PARAMETER;
- }
-
- if (Length % sizeof (UINT32) != 0) {
- DEBUG ((DEBUG_ERROR, "%a(%u): bad Length %u\n", __FUNCTION__, __LINE__, Length));
- return EFI_INVALID_PARAMETER;
- }
-
- RemLength = Length;
- while (RemLength != 0) {
- UINTN RetryCount = 0;
- UINT32 BlockLen = MIN (RemLength, BLEN_512BYTES);
-
- while (RetryCount < MAX_RETRY_COUNT) {
- MmcStatus = MmioRead32 (MMCHS_INT_STAT);
- if ((MmcStatus & BRR) != 0) {
- MmioWrite32 (MMCHS_INT_STAT, BRR);
- /*
- * Data is ready.
- */
- mFwProtocol->SetLed (TRUE);
- for (Count = 0; Count < BlockLen; Count += 4, Buffer++) {
- *Buffer = MmioRead32 (MMCHS_DATA);
- }
-
- mFwProtocol->SetLed (FALSE);
- break;
- }
-
- gBS->Stall (STALL_AFTER_RETRY_US);
- RetryCount++;
- }
-
- if (RetryCount == MAX_RETRY_COUNT) {
- DEBUG ((DEBUG_ERROR, "%a(%u): %lu/%lu MMCHS_INT_STAT: %08x\n",
- __FUNCTION__, __LINE__, Length - RemLength, Length, MmcStatus));
- return EFI_TIMEOUT;
- }
-
- RemLength -= BlockLen;
- gBS->Stall (STALL_AFTER_READ_US);
- }
-
- MmioWrite32 (MMCHS_INT_STAT, BRR);
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-MMCWriteBlockData (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN EFI_LBA Lba,
- IN UINTN Length,
- IN UINT32* Buffer
- )
-{
- UINTN MmcStatus;
- UINTN RemLength;
- UINTN Count;
-
- DEBUG ((DEBUG_VERBOSE, "%a(%u): LBA: 0x%x, Length: 0x%x, Buffer: 0x%x)\n",
- __FUNCTION__, __LINE__, Lba, Length, Buffer));
-
- if (Buffer == NULL) {
- DEBUG ((DEBUG_ERROR, "%a(%u): NULL Buffer\n", __FUNCTION__, __LINE__));
- return EFI_INVALID_PARAMETER;
- }
-
- if (Length % sizeof (UINT32) != 0) {
- DEBUG ((DEBUG_ERROR, "%a(%u): bad Length %u\n", __FUNCTION__, __LINE__, Length));
- return EFI_INVALID_PARAMETER;
- }
-
- RemLength = Length;
- while (RemLength != 0) {
- UINTN RetryCount = 0;
- UINT32 BlockLen = MIN (RemLength, BLEN_512BYTES);
-
- while (RetryCount < MAX_RETRY_COUNT) {
- MmcStatus = MmioRead32 (MMCHS_INT_STAT);
- if ((MmcStatus & BWR) != 0) {
- MmioWrite32 (MMCHS_INT_STAT, BWR);
- /*
- * Can write data.
- */
- mFwProtocol->SetLed (TRUE);
- for (Count = 0; Count < BlockLen; Count += 4, Buffer++) {
- MmioWrite32 (MMCHS_DATA, *Buffer);
- }
-
- mFwProtocol->SetLed (FALSE);
- break;
- }
-
- gBS->Stall (STALL_AFTER_RETRY_US);
- RetryCount++;
- }
-
- if (RetryCount == MAX_RETRY_COUNT) {
- DEBUG ((DEBUG_ERROR, "%a(%u): %lu/%lu MMCHS_INT_STAT: %08x\n",
- __FUNCTION__, __LINE__, Length - RemLength, Length, MmcStatus));
- return EFI_TIMEOUT;
- }
-
- RemLength -= BlockLen;
- gBS->Stall (STALL_AFTER_WRITE_US);
- }
-
- MmioWrite32 (MMCHS_INT_STAT, BWR);
- return EFI_SUCCESS;
-}
-
-BOOLEAN
-MMCIsMultiBlock (
- IN EFI_MMC_HOST_PROTOCOL *This
- )
-{
- return TRUE;
-}
-
-EFI_MMC_HOST_PROTOCOL gMMCHost =
-{
- MMC_HOST_PROTOCOL_REVISION,
- MMCIsCardPresent,
- MMCIsReadOnly,
- MMCBuildDevicePath,
- MMCNotifyState,
- MMCSendCommand,
- MMCReceiveResponse,
- MMCReadBlockData,
- MMCWriteBlockData,
- NULL,
- MMCIsMultiBlock
-};
-
-EFI_STATUS
-MMCInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE Handle = NULL;
-
- DEBUG ((DEBUG_MMCHOST_SD, "ArasanMMCHost: MMCInitialize()\n"));
-
- if (!PcdGet32 (PcdSdIsArasan)) {
- DEBUG ((DEBUG_INFO, "SD is not routed to Arasan\n"));
- return EFI_REQUEST_UNLOAD_IMAGE;
- }
-
- Status = gBS->LocateProtocol (&gRaspberryPiFirmwareProtocolGuid, NULL,
- (VOID**)&mFwProtocol);
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Handle,
- &gRaspberryPiMmcHostProtocolGuid,
- &gMMCHost,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
-
- return Status;
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.h b/Platform/RaspberryPi/RPi3/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.h
deleted file mode 100644
index 6cd600f7..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.h
+++ /dev/null
@@ -1,44 +0,0 @@
-/** @file
- *
- * Copyright (c) Microsoft Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#ifndef _MMC_HOST_DXE_H_
-#define _MMC_HOST_DXE_H_
-
-#include <Uefi.h>
-
-#include <Library/BaseLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DebugLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/IoLib.h>
-#include <Library/PcdLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DmaLib.h>
-
-#include <Protocol/EmbeddedExternalDevice.h>
-#include <Protocol/BlockIo.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/RpiMmcHost.h>
-#include <Protocol/RpiFirmware.h>
-
-#include <IndustryStandard/Bcm2836.h>
-#include <IndustryStandard/Bcm2836Sdio.h>
-#include <IndustryStandard/RpiMbox.h>
-
-#define MAX_RETRY_COUNT (1000 * 20)
-
-#define STALL_AFTER_SEND_CMD_US (200) // in microseconds
-#define STALL_AFTER_REC_RESP_US (50)
-#define STALL_AFTER_WRITE_US (200)
-#define STALL_AFTER_READ_US (20)
-#define STALL_AFTER_RETRY_US (20)
-
-#define MAX_DIVISOR_VALUE 1023
-
-#endif
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.inf b/Platform/RaspberryPi/RPi3/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.inf
deleted file mode 100644
index 487b7e35..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.inf
+++ /dev/null
@@ -1,47 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2017, Andrei Warkentin <andrey.warkentin@gmail.com>
-# Copyright (c) Microsoft Corporation. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x0001001A
- BASE_NAME = ArasanMMCHost
- FILE_GUID = 100c2cfa-b586-4198-9b4c-1683d195b1da
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = MMCInitialize
-
-[Sources.common]
- ArasanMmcHostDxe.h
- ArasanMmcHostDxe.c
-
-[Packages]
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- Silicon/Broadcom/Bcm283x/Bcm283x.dec
- Platform/RaspberryPi/RPi3/RPi3.dec
-
-[LibraryClasses]
- PcdLib
- UefiLib
- UefiDriverEntryPoint
- MemoryAllocationLib
- IoLib
- DmaLib
- CacheMaintenanceLib
-
-[Guids]
-
-[Protocols]
- gRaspberryPiMmcHostProtocolGuid ## PRODUCES
- gRaspberryPiFirmwareProtocolGuid ## CONSUMES
-
-[Pcd]
- gRaspberryPiTokenSpaceGuid.PcdSdIsArasan
-
-[Depex]
- gRaspberryPiFirmwareProtocolGuid AND gRaspberryPiConfigAppliedProtocolGuid
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
deleted file mode 100644
index 98e58a56..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.c
+++ /dev/null
@@ -1,357 +0,0 @@
-/** @file
- *
- * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <Uefi.h>
-#include <Library/HiiLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/DevicePathLib.h>
-#include <IndustryStandard/RpiMbox.h>
-#include <IndustryStandard/Bcm2836Gpio.h>
-#include <Library/GpioLib.h>
-#include <Protocol/RpiFirmware.h>
-#include "ConfigDxeFormSetGuid.h"
-
-extern UINT8 ConfigDxeHiiBin[];
-extern UINT8 ConfigDxeStrings[];
-
-STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol;
-
-typedef struct {
- VENDOR_DEVICE_PATH VendorDevicePath;
- EFI_DEVICE_PATH_PROTOCOL End;
-} HII_VENDOR_DEVICE_PATH;
-
-STATIC HII_VENDOR_DEVICE_PATH mVendorDevicePath = {
- {
- {
- HARDWARE_DEVICE_PATH,
- HW_VENDOR_DP,
- {
- (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
- (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8)
- }
- },
- CONFIGDXE_FORM_SET_GUID
- },
- {
- END_DEVICE_PATH_TYPE,
- END_ENTIRE_DEVICE_PATH_SUBTYPE,
- {
- (UINT8)(END_DEVICE_PATH_LENGTH),
- (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
- }
- }
-};
-
-
-STATIC EFI_STATUS
-InstallHiiPages (
- VOID
- )
-{
- EFI_STATUS Status;
- EFI_HII_HANDLE HiiHandle;
- EFI_HANDLE DriverHandle;
-
- DriverHandle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (&DriverHandle,
- &gEfiDevicePathProtocolGuid,
- &mVendorDevicePath,
- NULL);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- HiiHandle = HiiAddPackages (&gConfigDxeFormSetGuid,
- DriverHandle,
- ConfigDxeStrings,
- ConfigDxeHiiBin,
- NULL);
-
- if (HiiHandle == NULL) {
- gBS->UninstallMultipleProtocolInterfaces (DriverHandle,
- &gEfiDevicePathProtocolGuid,
- &mVendorDevicePath,
- NULL);
- return EFI_OUT_OF_RESOURCES;
- }
- return EFI_SUCCESS;
-}
-
-
-STATIC EFI_STATUS
-SetupVariables (
- VOID
- )
-{
- UINTN Size;
- UINT8 Var8;
- UINT32 Var32;
- EFI_STATUS Status;
-
- /*
- * Create the vars with default value.
- * If we don't, forms won't be able to update.
- */
-
- Size = sizeof (UINT32);
- Status = gRT->GetVariable (L"CpuClock",
- &gConfigDxeFormSetGuid,
- NULL, &Size, &Var32);
- if (EFI_ERROR (Status)) {
- PcdSet32 (PcdCpuClock, PcdGet32 (PcdCpuClock));
- }
-
- Size = sizeof (UINT32);
- Status = gRT->GetVariable(L"CustomCpuClock",
- &gConfigDxeFormSetGuid,
- NULL, &Size, &Var32);
- if (EFI_ERROR (Status)) {
- PcdSet32 (PcdCustomCpuClock, PcdGet32 (PcdCustomCpuClock));
- }
-
- Size = sizeof (UINT32);
- Status = gRT->GetVariable (L"SdIsArasan",
- &gConfigDxeFormSetGuid,
- NULL, &Size, &Var32);
- if (EFI_ERROR (Status)) {
- PcdSet32 (PcdSdIsArasan, PcdGet32 (PcdSdIsArasan));
- }
-
- Size = sizeof (UINT32);
- Status = gRT->GetVariable (L"MmcDisableMulti",
- &gConfigDxeFormSetGuid,
- NULL, &Size, &Var32);
- if (EFI_ERROR (Status)) {
- PcdSet32 (PcdMmcDisableMulti, PcdGet32 (PcdMmcDisableMulti));
- }
-
- Size = sizeof (UINT32);
- Status = gRT->GetVariable (L"MmcForce1Bit",
- &gConfigDxeFormSetGuid,
- NULL, &Size, &Var32);
- if (EFI_ERROR (Status)) {
- PcdSet32 (PcdMmcForce1Bit, PcdGet32 (PcdMmcForce1Bit));
- }
-
- Size = sizeof (UINT32);
- Status = gRT->GetVariable (L"MmcForceDefaultSpeed",
- &gConfigDxeFormSetGuid,
- NULL, &Size, &Var32);
- if (EFI_ERROR (Status)) {
- PcdSet32 (PcdMmcForceDefaultSpeed, PcdGet32 (PcdMmcForceDefaultSpeed));
- }
-
- Size = sizeof (UINT32);
- Status = gRT->GetVariable (L"MmcSdDefaultSpeedMHz",
- &gConfigDxeFormSetGuid,
- NULL, &Size, &Var32);
- if (EFI_ERROR (Status)) {
- PcdSet32 (PcdMmcSdDefaultSpeedMHz, PcdGet32 (PcdMmcSdDefaultSpeedMHz));
- }
-
- Size = sizeof (UINT32);
- Status = gRT->GetVariable (L"MmcSdHighSpeedMHz",
- &gConfigDxeFormSetGuid,
- NULL, &Size, &Var32);
- if (EFI_ERROR (Status)) {
- PcdSet32 (PcdMmcSdHighSpeedMHz, PcdGet32 (PcdMmcSdHighSpeedMHz));
- }
-
- Size = sizeof (UINT32);
- Status = gRT->GetVariable (L"DebugEnableJTAG",
- &gConfigDxeFormSetGuid,
- NULL, &Size, &Var32);
- if (EFI_ERROR (Status)) {
- PcdSet32 (PcdDebugEnableJTAG, PcdGet32 (PcdDebugEnableJTAG));
- }
-
- Size = sizeof (UINT32);
- Status = gRT->GetVariable (L"DebugShowUEFIExit",
- &gConfigDxeFormSetGuid,
- NULL, &Size, &Var32);
- if (EFI_ERROR (Status)) {
- PcdSet32 (PcdDebugShowUEFIExit, PcdGet32 (PcdDebugShowUEFIExit));
- }
-
- Size = sizeof (UINT8);
- Status = gRT->GetVariable (L"DisplayEnableScaledVModes",
- &gConfigDxeFormSetGuid,
- NULL, &Size, &Var8);
- if (EFI_ERROR (Status)) {
- PcdSet8 (PcdDisplayEnableScaledVModes, PcdGet8 (PcdDisplayEnableScaledVModes));
- }
-
- Size = sizeof (UINT32);
- Status = gRT->GetVariable (L"DisplayEnableSShot",
- &gConfigDxeFormSetGuid,
- NULL, &Size, &Var32);
- if (EFI_ERROR (Status)) {
- PcdSet32 (PcdDisplayEnableSShot, PcdGet32 (PcdDisplayEnableSShot));
- }
-
- return EFI_SUCCESS;
-}
-
-
-STATIC VOID
-ApplyVariables (
- VOID
- )
-{
- UINTN Gpio34Group;
- UINTN Gpio48Group;
- EFI_STATUS Status;
- UINT32 CpuClock = PcdGet32 (PcdCpuClock);
- UINT32 CustomCpuClock = PcdGet32 (PcdCustomCpuClock);
- UINT32 Rate = 0;
-
- if (CpuClock != 0) {
- if (CpuClock == 2) {
- /*
- * Maximum: 1.2GHz on RPi 3, 1.4GHz on RPi 3B+, unless
- * overridden with arm_freq=xxx in config.txt.
- */
- Status = mFwProtocol->GetMaxClockRate (RPI_MBOX_CLOCK_RATE_ARM, &Rate);
- if (Status != EFI_SUCCESS) {
- DEBUG ((DEBUG_ERROR, "Couldn't get the max CPU speed, leaving as is: %r\n", Status));
- }
- } else if (CpuClock == 3) {
- Rate = CustomCpuClock * 1000000;
- } else {
- Rate = 600 * 1000000;
- }
- }
-
- if (Rate != 0) {
- DEBUG ((DEBUG_INFO, "Setting CPU speed to %uHz\n", Rate));
- Status = mFwProtocol->SetClockRate (RPI_MBOX_CLOCK_RATE_ARM, Rate, 1);
- if (Status != EFI_SUCCESS) {
- DEBUG ((DEBUG_ERROR, "Couldn't set the CPU speed: %r\n", Status));
- }
- }
-
- Status = mFwProtocol->GetClockRate (RPI_MBOX_CLOCK_RATE_ARM, &Rate);
- if (Status != EFI_SUCCESS) {
- DEBUG ((DEBUG_ERROR, "Couldn't get the CPU speed: %r\n", Status));
- } else {
- DEBUG ((DEBUG_INFO, "Current CPU speed is %uHz\n", Rate));
- }
-
- /*
- * Switching two groups around, so disable both first.
- *
- * No, I've not seen a problem, but having a group be
- * routed to two sets of pins seems like asking for trouble.
- */
- GpioPinFuncSet (34, GPIO_FSEL_INPUT);
- GpioPinFuncSet (35, GPIO_FSEL_INPUT);
- GpioPinFuncSet (36, GPIO_FSEL_INPUT);
- GpioPinFuncSet (37, GPIO_FSEL_INPUT);
- GpioPinFuncSet (38, GPIO_FSEL_INPUT);
- GpioPinFuncSet (39, GPIO_FSEL_INPUT);
- GpioPinFuncSet (48, GPIO_FSEL_INPUT);
- GpioPinFuncSet (49, GPIO_FSEL_INPUT);
- GpioPinFuncSet (50, GPIO_FSEL_INPUT);
- GpioPinFuncSet (51, GPIO_FSEL_INPUT);
- GpioPinFuncSet (52, GPIO_FSEL_INPUT);
- GpioPinFuncSet (53, GPIO_FSEL_INPUT);
- if (PcdGet32 (PcdSdIsArasan)) {
- DEBUG ((DEBUG_INFO, "Routing SD to Arasan\n"));
- Gpio48Group = GPIO_FSEL_ALT3;
- /*
- * Route SDIO to SdHost.
- */
- Gpio34Group = GPIO_FSEL_ALT0;
- } else {
- DEBUG ((DEBUG_INFO, "Routing SD to SdHost\n"));
- Gpio48Group = GPIO_FSEL_ALT0;
- /*
- * Route SDIO to Arasan.
- */
- Gpio34Group = GPIO_FSEL_ALT3;
- }
- GpioPinFuncSet (34, Gpio34Group);
- GpioPinFuncSet (35, Gpio34Group);
- GpioPinFuncSet (36, Gpio34Group);
- GpioPinFuncSet (37, Gpio34Group);
- GpioPinFuncSet (38, Gpio34Group);
- GpioPinFuncSet (39, Gpio34Group);
- GpioPinFuncSet (48, Gpio48Group);
- GpioPinFuncSet (49, Gpio48Group);
- GpioPinFuncSet (50, Gpio48Group);
- GpioPinFuncSet (51, Gpio48Group);
- GpioPinFuncSet (52, Gpio48Group);
- GpioPinFuncSet (53, Gpio48Group);
-
- /*
- * JTAG pin JTAG sig GPIO Mode Header pin
- * 1 VREF N/A 1
- * 3 nTRST GPIO22 ALT4 15
- * 4 GND N/A 9
- * 5 TDI GPIO4 ALT5 7
- * 7 TMS GPIO27 ALT4 13
- * 9 TCK GPIO25 ALT4 22
- * 11 RTCK GPIO23 ALT4 16
- * 13 TDO GPIO24 ALT4 18
- */
- if (PcdGet32 (PcdDebugEnableJTAG)) {
- GpioPinFuncSet (22, GPIO_FSEL_ALT4);
- GpioPinFuncSet (4, GPIO_FSEL_ALT5);
- GpioPinFuncSet (27, GPIO_FSEL_ALT4);
- GpioPinFuncSet (25, GPIO_FSEL_ALT4);
- GpioPinFuncSet (23, GPIO_FSEL_ALT4);
- GpioPinFuncSet (24, GPIO_FSEL_ALT4);
- } else {
- GpioPinFuncSet (22, GPIO_FSEL_INPUT);
- GpioPinFuncSet (4, GPIO_FSEL_INPUT);
- GpioPinFuncSet (27, GPIO_FSEL_INPUT);
- GpioPinFuncSet (25, GPIO_FSEL_INPUT);
- GpioPinFuncSet (23, GPIO_FSEL_INPUT);
- GpioPinFuncSet (24, GPIO_FSEL_INPUT);
- }
-}
-
-
-EFI_STATUS
-EFIAPI
-ConfigInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- Status = gBS->LocateProtocol (&gRaspberryPiFirmwareProtocolGuid,
- NULL, (VOID**)&mFwProtocol);
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = SetupVariables ();
- if (Status != EFI_SUCCESS) {
- DEBUG ((DEBUG_ERROR, "Couldn't not setup NV vars: %r\n", Status));
- }
-
- ApplyVariables ();
- Status = gBS->InstallProtocolInterface (&ImageHandle,
- &gRaspberryPiConfigAppliedProtocolGuid,
- EFI_NATIVE_INTERFACE,
- NULL);
- ASSERT_EFI_ERROR (Status);
-
- Status = InstallHiiPages ();
- if (Status != EFI_SUCCESS) {
- DEBUG ((DEBUG_ERROR, "Couldn't install ConfigDxe configuration pages: %r\n", Status));
- }
-
- return EFI_SUCCESS;
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
deleted file mode 100644
index 24112d51..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxe.inf
+++ /dev/null
@@ -1,73 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x0001001A
- BASE_NAME = ConfigDxe
- FILE_GUID = 755cbac2-b23f-4b92-bc8e-fb01ce5907b7
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = ConfigInitialize
-
-#
-# The following information is for reference only and not required by the build
-# tools.
-#
-# VALID_ARCHITECTURES = AARCH64
-#
-
-[Sources]
- ConfigDxe.c
- ConfigDxeFormSetGuid.h
- ConfigDxeHii.vfr
- ConfigDxeHii.uni
-
-[Packages]
- ArmPkg/ArmPkg.dec
- ArmPlatformPkg/ArmPlatformPkg.dec
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- Silicon/Broadcom/Bcm283x/Bcm283x.dec
- Platform/RaspberryPi/RPi3/RPi3.dec
-
-[LibraryClasses]
- BaseLib
- DebugLib
- DxeServicesTableLib
- PcdLib
- UefiBootServicesTableLib
- UefiRuntimeServicesTableLib
- UefiDriverEntryPoint
- HiiLib
- GpioLib
-
-[Guids]
- gConfigDxeFormSetGuid
-
-[Protocols]
- gRaspberryPiFirmwareProtocolGuid ## CONSUMES
- gRaspberryPiConfigAppliedProtocolGuid ## PRODUCES
-
-[Pcd]
- gRaspberryPiTokenSpaceGuid.PcdCpuClock
- gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock
- gRaspberryPiTokenSpaceGuid.PcdSdIsArasan
- gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit
- gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed
- gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz
- gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz
- gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti
- gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG
- gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit
- gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes
- gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot
-
-[FeaturePcd]
-
-[Depex]
- gPcdProtocolGuid AND gRaspberryPiFirmwareProtocolGuid
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeFormSetGuid.h b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeFormSetGuid.h
deleted file mode 100644
index 30f9b905..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeFormSetGuid.h
+++ /dev/null
@@ -1,17 +0,0 @@
-/** @file
- *
- * Copyright (c) 2018 Andrei Warkentin <andrey.warkentin@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#ifndef CONFIGDXE_FORM_SET_GUID_H
-#define CONFIGDXE_FORM_SET_GUID_H
-
-#define CONFIGDXE_FORM_SET_GUID \
- {0xCD7CC258, 0x31DB, 0x22E6, {0x9F, 0x22, 0x63, 0xB0, 0xB8, 0xEE, 0xD6, 0xB5}}
-
-extern EFI_GUID gConfigDxeFormSetGuid;
-
-#endif /* CONFIGDXE_FORM_SET_GUID_H */
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
deleted file mode 100644
index 9b407663..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.uni
+++ /dev/null
@@ -1,107 +0,0 @@
-/** @file
- *
- * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#langdef en-US "English"
-
-#string STR_NULL_STRING #language en-US ""
-
-#string STR_FORM_SET_TITLE #language en-US "Raspberry Pi Configuration"
-#string STR_FORM_SET_TITLE_HELP #language en-US "Press <Enter> to configure system settings."
-
-/*
- * Chipset config.
- */
-
-#string STR_CHIPSET_FORM_TITLE #language en-US "Chipset Configuration"
-#string STR_CHIPSET_FORM_SUBTITLE #language en-US "Note: OS may override settings when booted."
-
-#string STR_CHIPSET_CLOCK_CPU_PROMPT #language en-US "CPU Clock"
-#string STR_CHIPSET_CLOCK_CPU_HELP #language en-US "CPU Speed"
-#string STR_CHIPSET_CLOCK_CPU_NA #language en-US "Don't Override"
-#string STR_CHIPSET_CLOCK_CPU_600MHZ #language en-US "Min (600MHz)"
-#string STR_CHIPSET_CLOCK_CPU_MAX #language en-US "Max"
-#string STR_CHIPSET_CLOCK_CPU_CUSTOM #language en-US "Custom"
-
-#string STR_CHIPSET_CUSTOM_CPU_CLOCK_PROMPT #language en-US "CPU Clock Rate (MHz)"
-#string STR_CHIPSET_CUSTOM_CPU_CLOCK_HELP #language en-US "Adjust the CPU speed.\nMin value: 100 MHz\nMax value: 1600 MHz\n\nWarning: Overclocking can make the system unbootable!"
-
-#string STR_CHIPSET_SD_PROMPT #language en-US "uSD Routing"
-#string STR_CHIPSET_SD_HELP #language en-US "Choose host controller to drive uSD slot"
-#string STR_CHIPSET_SD_SDHOST #language en-US "Broadcom SDHOST"
-#string STR_CHIPSET_SD_ARASAN #language en-US "Arasan SDHCI"
-
-/*
- * MMC/SD configuration.
- */
-
-#string STR_MMC_FORM_TITLE #language en-US "SD/MMC Tweaks"
-#string STR_MMC_FORM_SUBTITLE #language en-US "Note: UEFI only, OS will override settings when booted."
-
-#string STR_MMC_DISMULTI_PROMPT #language en-US "Multi-Block Support"
-#string STR_MMC_DISMULTI_HELP #language en-US "Use CMD18/CMD25 for transfers when possible"
-#string STR_MMC_DISMULTI_N #language en-US "Multi-block transfers"
-#string STR_MMC_DISMULTI_Y #language en-US "Single-block transfers"
-
-#string STR_MMC_FORCE1BIT_PROMPT #language en-US "uSD Max Bus Width"
-#string STR_MMC_FORCE1BIT_HELP #language en-US "Tweak for bad media"
-#string STR_MMC_FORCE1BIT_Y #language en-US "1 Bit Mode"
-#string STR_MMC_FORCE1BIT_N #language en-US "4 Bit Mode"
-
-#string STR_MMC_FORCEDS_PROMPT #language en-US "uSD Force Default Speed"
-#string STR_MMC_FORCEDS_HELP #language en-US "Tweak for bad media"
-#string STR_MMC_FORCEDS_Y #language en-US "Force Default Speed"
-#string STR_MMC_FORCEDS_N #language en-US "Allow High Speed"
-
-#string STR_MMC_SD_DS_PROMPT #language en-US "SD Default Speed (MHz)"
-#string STR_MMC_SD_DS_HELP #language en-US "Override default 25Mhz"
-
-#string STR_MMC_SD_HS_PROMPT #language en-US "SD High Speed (MHz)"
-#string STR_MMC_SD_HS_HELP #language en-US "Override default 50Mhz"
-
-
-/*
- * Display settings.
- */
-
-#string STR_DISPLAY_FORM_TITLE #language en-US "Display"
-#string STR_DISPLAY_FORM_SUBTITLE #language en-US "UEFI video driver settings"
-
-#string STR_DISPLAY_VMODES_640_PROMPT #language en-US "Virtual 640x480"
-#string STR_DISPLAY_VMODES_640_HELP #language en-US "Enable scaled 640x480 mode"
-#string STR_DISPLAY_VMODES_800_PROMPT #language en-US "Virtual 800x600"
-#string STR_DISPLAY_VMODES_800_HELP #language en-US "Enable scaled 800x600 mode"
-#string STR_DISPLAY_VMODES_1024_PROMPT #language en-US "Virtual 1024x768"
-#string STR_DISPLAY_VMODES_1024_HELP #language en-US "Enable scaled 1024x768 mode"
-#string STR_DISPLAY_VMODES_720_PROMPT #language en-US "Virtual 720p"
-#string STR_DISPLAY_VMODES_720_HELP #language en-US "Enable scaled 720p mode"
-#string STR_DISPLAY_VMODES_1080_PROMPT #language en-US "Virtual 1080p"
-#string STR_DISPLAY_VMODES_1080_HELP #language en-US "Enable scaled 1080p mode"
-
-#string STR_DISPLAY_VMODES_REAL_PROMPT #language en-US "Native resolution"
-#string STR_DISPLAY_VMODES_REAL_HELP #language en-US "Native resolution"
-
-#string STR_DISPLAY_SSHOT_PROMPT #language en-US "Screenshot Support"
-#string STR_DISPLAY_SSHOT_HELP #language en-US "Save screen capture as a BMP on the first writable file system found"
-#string STR_DISPLAY_SSHOT_ENABLE #language en-US "Control-Alt-F12"
-#string STR_DISPLAY_SSHOT_DISABLE #language en-US "Not Enabled"
-
-/*
- * Debugging settings go here.
- */
-#string STR_DEBUG_FORM_TITLE #language en-US "Debugging"
-#string STR_DEBUG_FORM_SUBTITLE #language en-US "For UEFI/OS Developers"
-
-#string STR_DEBUG_JTAG_PROMPT #language en-US "JTAG Routing"
-#string STR_DEBUG_JTAG_HELP #language en-US "Signals (nTRST, TDI, TMS, TCK, RTCK, TDO) -> Header pins (15, 7, 13, 22, 16, 18)"
-#string STR_DEBUG_JTAG_ENABLE #language en-US "Enable JTAG via GPIO"
-#string STR_DEBUG_JTAG_DISABLE #language en-US "Disable JTAG"
-
-#string STR_DEBUG_EXIT_SHOW_PROMPT #language en-US "Verbose ExitBootServices"
-#string STR_DEBUG_EXIT_SHOW_HELP #language en-US "Show message when UEFI hands off to OS"
-#string STR_DEBUG_EXIT_SHOW_NO #language en-US "Do nothing"
-#string STR_DEBUG_EXIT_SHOW_YES #language en-US "Show farewell message"
diff --git a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr b/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr
deleted file mode 100644
index 60bfdbd4..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/ConfigDxe/ConfigDxeHii.vfr
+++ /dev/null
@@ -1,365 +0,0 @@
-/** @file
- *
- * Copyright (c) 2018 Andrei Warkentin <andrey.warkentin@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <Guid/HiiPlatformSetupFormset.h>
-#include "ConfigDxeFormSetGuid.h"
-
-#pragma pack(1)
-typedef struct {
- /*
- * One bit for each scaled resolution supported,
- * these are ordered exactly like mGopModeData
- * in DisplayDxe.
- *
- * 800x600, 640x480, 1024x768, 720p, 1080p, native.
- */
- UINT8 v640 : 1;
- UINT8 v800 : 1;
- UINT8 v1024 : 1;
- UINT8 v720p : 1;
- UINT8 v1080p : 1;
- UINT8 Physical : 1;
-} DISPLAY_ENABLE_SCALED_VMODES_VARSTORE_DATA;
-#pragma pack()
-
-typedef struct {
- /*
- * 0 - No screenshot support.
- * 1 - Screenshot support via hotkey.
- */
- UINT32 Enable;
-} DISPLAY_ENABLE_SSHOT_VARSTORE_DATA;
-
-typedef struct {
- /*
- * 0 - No JTAG.
- * 1 - JTAG mode.
- */
- UINT32 Enable;
-} DEBUG_ENABLE_JTAG_VARSTORE_DATA;
-
-typedef struct {
- /*
- * 0 - Don't show UEFI exit message.
- * 1 - Show UEFI exit message.
- */
- UINT32 Show;
-} DEBUG_SHOW_UEFI_EXIT_VARSTORE_DATA;
-
-typedef struct {
- /*
- * 0 - don't change the clock rate.
- * 1 - 600MHz.
- * 2 - maximum.
- * 3 - custom.
- */
- UINT32 Clock;
-} CHIPSET_CPU_CLOCK_VARSTORE_DATA;
-
-typedef struct {
- UINT32 Clock;
-} CHIPSET_CUSTOM_CPU_CLOCK_VARSTORE_DATA;
-
-typedef struct {
- /*
- * 0 - uSD slot routed to Broadcom SDHOST.
- * 1 - uSD slot routed to Arasan SDHCI.
- */
- UINT32 Routing;
-} CHIPSET_SD_VARSTORE_DATA;
-
-typedef struct {
- /*
- * 0 - Don't disable multi-block.
- * 1 - Disable multi-block commands.
- */
- UINT32 DisableMulti;
-} MMC_DISMULTI_VARSTORE_DATA;
-
-typedef struct {
- /*
- * 0 - Don't force 1 bit mode.
- * 1 - Force 1 bit mode.
- */
- UINT32 Force1Bit;
-} MMC_FORCE1BIT_VARSTORE_DATA;
-
-typedef struct {
- /*
- * 0 - Don't force default speed.
- * 1 - Force default speed.
- */
- UINT32 ForceDS;
-} MMC_FORCEDS_VARSTORE_DATA;
-
-typedef struct {
- /*
- * Default Speed MHz override (25MHz default).
- */
- UINT32 MHz;
-} MMC_SD_DS_MHZ_VARSTORE_DATA;
-
-typedef struct {
- /*
- * High Speed MHz override (50MHz default).
- */
- UINT32 MHz;
-} MMC_SD_HS_MHZ_VARSTORE_DATA;
-
-//
-// EFI Variable attributes
-//
-#define EFI_VARIABLE_NON_VOLATILE 0x00000001
-#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
-#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
-#define EFI_VARIABLE_READ_ONLY 0x00000008
-
-formset
- guid = CONFIGDXE_FORM_SET_GUID,
- title = STRING_TOKEN(STR_FORM_SET_TITLE),
- help = STRING_TOKEN(STR_FORM_SET_TITLE_HELP),
- classguid = EFI_HII_PLATFORM_SETUP_FORMSET_GUID,
-
- efivarstore CHIPSET_CPU_CLOCK_VARSTORE_DATA,
- attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- name = CpuClock,
- guid = CONFIGDXE_FORM_SET_GUID;
-
- efivarstore CHIPSET_CUSTOM_CPU_CLOCK_VARSTORE_DATA,
- attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- name = CustomCpuClock,
- guid = CONFIGDXE_FORM_SET_GUID;
-
- efivarstore CHIPSET_SD_VARSTORE_DATA,
- attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- name = SdIsArasan,
- guid = CONFIGDXE_FORM_SET_GUID;
-
- efivarstore MMC_DISMULTI_VARSTORE_DATA,
- attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- name = MmcDisableMulti,
- guid = CONFIGDXE_FORM_SET_GUID;
-
- efivarstore MMC_FORCE1BIT_VARSTORE_DATA,
- attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- name = MmcForce1Bit,
- guid = CONFIGDXE_FORM_SET_GUID;
-
- efivarstore MMC_FORCEDS_VARSTORE_DATA,
- attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- name = MmcForceDefaultSpeed,
- guid = CONFIGDXE_FORM_SET_GUID;
-
- efivarstore MMC_SD_DS_MHZ_VARSTORE_DATA,
- attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- name = MmcSdDefaultSpeedMHz,
- guid = CONFIGDXE_FORM_SET_GUID;
-
- efivarstore MMC_SD_HS_MHZ_VARSTORE_DATA,
- attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- name = MmcSdHighSpeedMHz,
- guid = CONFIGDXE_FORM_SET_GUID;
-
- efivarstore DEBUG_ENABLE_JTAG_VARSTORE_DATA,
- attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- name = DebugEnableJTAG,
- guid = CONFIGDXE_FORM_SET_GUID;
-
- efivarstore DEBUG_SHOW_UEFI_EXIT_VARSTORE_DATA,
- attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- name = DebugShowUEFIExit,
- guid = CONFIGDXE_FORM_SET_GUID;
-
- efivarstore DISPLAY_ENABLE_SCALED_VMODES_VARSTORE_DATA,
- attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- name = DisplayEnableScaledVModes,
- guid = CONFIGDXE_FORM_SET_GUID;
-
- efivarstore DISPLAY_ENABLE_SSHOT_VARSTORE_DATA,
- attribute = EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE,
- name = DisplayEnableSShot,
- guid = CONFIGDXE_FORM_SET_GUID;
-
- form formid = 1,
- title = STRING_TOKEN(STR_FORM_SET_TITLE);
- subtitle text = STRING_TOKEN(STR_NULL_STRING);
-
- goto 0x1002,
- prompt = STRING_TOKEN(STR_CHIPSET_FORM_TITLE),
- help = STRING_TOKEN(STR_NULL_STRING);
-
- goto 0x1003,
- prompt = STRING_TOKEN(STR_MMC_FORM_TITLE),
- help = STRING_TOKEN(STR_NULL_STRING);
-
- goto 0x1004,
- prompt = STRING_TOKEN(STR_DISPLAY_FORM_TITLE),
- help = STRING_TOKEN(STR_NULL_STRING);
-
- goto 0x1005,
- prompt = STRING_TOKEN(STR_DEBUG_FORM_TITLE),
- help = STRING_TOKEN(STR_NULL_STRING);
- endform;
-
- form formid = 0x1002,
- title = STRING_TOKEN(STR_CHIPSET_FORM_TITLE);
- subtitle text = STRING_TOKEN(STR_CHIPSET_FORM_SUBTITLE);
-
- oneof varid = CpuClock.Clock,
- prompt = STRING_TOKEN(STR_CHIPSET_CLOCK_CPU_PROMPT),
- help = STRING_TOKEN(STR_CHIPSET_CLOCK_CPU_HELP),
- flags = NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,
- option text = STRING_TOKEN(STR_CHIPSET_CLOCK_CPU_NA), value = 0, flags = DEFAULT;
- option text = STRING_TOKEN(STR_CHIPSET_CLOCK_CPU_600MHZ), value = 1, flags = 0;
- option text = STRING_TOKEN(STR_CHIPSET_CLOCK_CPU_MAX), value = 2, flags = 0;
- option text = STRING_TOKEN(STR_CHIPSET_CLOCK_CPU_CUSTOM), value = 3, flags = 0;
- endoneof;
-
- grayoutif NOT ideqval CpuClock.Clock == 3;
- numeric varid = CustomCpuClock.Clock,
- prompt = STRING_TOKEN(STR_CHIPSET_CUSTOM_CPU_CLOCK_PROMPT),
- help = STRING_TOKEN(STR_CHIPSET_CUSTOM_CPU_CLOCK_HELP),
- flags = DISPLAY_UINT_DEC | NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,
- minimum = 100,
- maximum = 1600,
- default = 600,
- endnumeric;
- endif;
-
- oneof varid = SdIsArasan.Routing,
- prompt = STRING_TOKEN(STR_CHIPSET_SD_PROMPT),
- help = STRING_TOKEN(STR_CHIPSET_SD_HELP),
- flags = NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,
- option text = STRING_TOKEN(STR_CHIPSET_SD_ARASAN), value = 1, flags = 0;
- option text = STRING_TOKEN(STR_CHIPSET_SD_SDHOST), value = 0, flags = DEFAULT;
- endoneof;
- endform;
-
- form formid = 0x1003,
- title = STRING_TOKEN(STR_MMC_FORM_TITLE);
- subtitle text = STRING_TOKEN(STR_MMC_FORM_SUBTITLE);
-
- oneof varid = MmcDisableMulti.DisableMulti,
- prompt = STRING_TOKEN(STR_MMC_DISMULTI_PROMPT),
- help = STRING_TOKEN(STR_MMC_DISMULTI_HELP),
- flags = NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,
- option text = STRING_TOKEN(STR_MMC_DISMULTI_N), value = 0, flags = DEFAULT;
- option text = STRING_TOKEN(STR_MMC_DISMULTI_Y), value = 1, flags = 0;
- endoneof;
-
- oneof varid = MmcForce1Bit.Force1Bit,
- prompt = STRING_TOKEN(STR_MMC_FORCE1BIT_PROMPT),
- help = STRING_TOKEN(STR_MMC_FORCE1BIT_HELP),
- flags = NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,
- option text = STRING_TOKEN(STR_MMC_FORCE1BIT_N), value = 0, flags = DEFAULT;
- option text = STRING_TOKEN(STR_MMC_FORCE1BIT_Y), value = 1, flags = 0;
- endoneof;
-
- oneof varid = MmcForceDefaultSpeed.ForceDS,
- prompt = STRING_TOKEN(STR_MMC_FORCEDS_PROMPT),
- help = STRING_TOKEN(STR_MMC_FORCEDS_HELP),
- flags = NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,
- option text = STRING_TOKEN(STR_MMC_FORCEDS_N), value = 0, flags = DEFAULT;
- option text = STRING_TOKEN(STR_MMC_FORCEDS_Y), value = 1, flags = 0;
- endoneof;
-
- numeric varid = MmcSdDefaultSpeedMHz.MHz,
- prompt = STRING_TOKEN(STR_MMC_SD_DS_PROMPT),
- help = STRING_TOKEN(STR_MMC_SD_DS_HELP),
- flags = DISPLAY_UINT_DEC | NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,
- minimum = 25,
- maximum = 100,
- default = 25,
- endnumeric;
-
- numeric varid = MmcSdHighSpeedMHz.MHz,
- prompt = STRING_TOKEN(STR_MMC_SD_HS_PROMPT),
- help = STRING_TOKEN(STR_MMC_SD_HS_HELP),
- flags = DISPLAY_UINT_DEC | NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,
- minimum = 50,
- maximum = 100,
- default = 50,
- endnumeric;
- endform;
-
- form formid = 0x1004,
- title = STRING_TOKEN(STR_DISPLAY_FORM_TITLE);
- subtitle text = STRING_TOKEN(STR_DISPLAY_FORM_SUBTITLE);
-
- checkbox varid = DisplayEnableScaledVModes.v640,
- prompt = STRING_TOKEN(STR_DISPLAY_VMODES_640_PROMPT),
- help = STRING_TOKEN(STR_DISPLAY_VMODES_640_HELP),
- flags = CHECKBOX_DEFAULT | CHECKBOX_DEFAULT_MFG | RESET_REQUIRED,
- default = TRUE,
- endcheckbox;
-
- checkbox varid = DisplayEnableScaledVModes.v800,
- prompt = STRING_TOKEN(STR_DISPLAY_VMODES_800_PROMPT),
- help = STRING_TOKEN(STR_DISPLAY_VMODES_800_HELP),
- flags = CHECKBOX_DEFAULT | CHECKBOX_DEFAULT_MFG | RESET_REQUIRED,
- default = TRUE,
- endcheckbox;
-
- checkbox varid = DisplayEnableScaledVModes.v1024,
- prompt = STRING_TOKEN(STR_DISPLAY_VMODES_1024_PROMPT),
- help = STRING_TOKEN(STR_DISPLAY_VMODES_1024_HELP),
- flags = CHECKBOX_DEFAULT | CHECKBOX_DEFAULT_MFG | RESET_REQUIRED,
- default = TRUE,
- endcheckbox;
-
- checkbox varid = DisplayEnableScaledVModes.v720p,
- prompt = STRING_TOKEN(STR_DISPLAY_VMODES_720_PROMPT),
- help = STRING_TOKEN(STR_DISPLAY_VMODES_720_HELP),
- flags = CHECKBOX_DEFAULT | CHECKBOX_DEFAULT_MFG | RESET_REQUIRED,
- default = TRUE,
- endcheckbox;
-
- checkbox varid = DisplayEnableScaledVModes.v1080p,
- prompt = STRING_TOKEN(STR_DISPLAY_VMODES_1080_PROMPT),
- help = STRING_TOKEN(STR_DISPLAY_VMODES_1080_HELP),
- flags = CHECKBOX_DEFAULT | CHECKBOX_DEFAULT_MFG | RESET_REQUIRED,
- default = TRUE,
- endcheckbox;
-
- checkbox varid = DisplayEnableScaledVModes.Physical,
- prompt = STRING_TOKEN(STR_DISPLAY_VMODES_REAL_PROMPT),
- help = STRING_TOKEN(STR_DISPLAY_VMODES_REAL_HELP),
- flags = CHECKBOX_DEFAULT | CHECKBOX_DEFAULT_MFG | RESET_REQUIRED,
- default = TRUE,
- endcheckbox;
-
- oneof varid = DisplayEnableSShot.Enable,
- prompt = STRING_TOKEN(STR_DISPLAY_SSHOT_PROMPT),
- help = STRING_TOKEN(STR_DISPLAY_SSHOT_HELP),
- flags = NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,
- option text = STRING_TOKEN(STR_DISPLAY_SSHOT_ENABLE), value = 1, flags = DEFAULT;
- option text = STRING_TOKEN(STR_DISPLAY_SSHOT_DISABLE), value = 0, flags = 0;
- endoneof;
- endform;
-
- form formid = 0x1005,
- title = STRING_TOKEN(STR_DEBUG_FORM_TITLE);
- subtitle text = STRING_TOKEN(STR_DEBUG_FORM_SUBTITLE);
-
- oneof varid = DebugEnableJTAG.Enable,
- prompt = STRING_TOKEN(STR_DEBUG_JTAG_PROMPT),
- help = STRING_TOKEN(STR_DEBUG_JTAG_HELP),
- flags = NUMERIC_SIZE_4 | INTERACTIVE | RESET_REQUIRED,
- option text = STRING_TOKEN(STR_DEBUG_JTAG_ENABLE), value = 1, flags = 0;
- option text = STRING_TOKEN(STR_DEBUG_JTAG_DISABLE), value = 0, flags = DEFAULT;
- endoneof;
-
- oneof varid = DebugShowUEFIExit.Show,
- prompt = STRING_TOKEN(STR_DEBUG_EXIT_SHOW_PROMPT),
- help = STRING_TOKEN(STR_DEBUG_EXIT_SHOW_HELP),
- flags = NUMERIC_SIZE_4 | INTERACTIVE,
- option text = STRING_TOKEN(STR_DEBUG_EXIT_SHOW_NO), value = 0, flags = DEFAULT;
- option text = STRING_TOKEN(STR_DEBUG_EXIT_SHOW_YES), value = 1, flags = 0;
- endoneof;
- endform;
-endformset;
diff --git a/Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/ComponentName.c b/Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/ComponentName.c
deleted file mode 100644
index 092230cd..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/ComponentName.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/** @file
- *
- * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2006-2016, Intel Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include "DisplayDxe.h"
-
-STATIC
-EFI_STATUS
-EFIAPI
-ComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- );
-
-STATIC
-EFI_STATUS
-EFIAPI
-ComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- );
-
-//
-// EFI Component Name Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gComponentName = {
- ComponentNameGetDriverName,
- ComponentNameGetControllerName,
- "eng"
-};
-
-//
-// EFI Component Name 2 Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)ComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)ComponentNameGetControllerName,
- "en"
-};
-
-
-STATIC EFI_UNICODE_STRING_TABLE mDriverName[] = {
- {
- "eng;en",
- (CHAR16*)L"Raspberry Pi Display Driver"
- },
- {
- NULL,
- NULL
- }
-};
-
-STATIC EFI_UNICODE_STRING_TABLE mDeviceName[] = {
- {
- "eng;en",
- (CHAR16*)L"Raspberry Pi Framebuffer"
- },
- {
- NULL,
- NULL
- }
-};
-
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-STATIC
-EFI_STATUS
-EFIAPI
-ComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mDriverName,
- DriverName,
- (BOOLEAN)(This == &gComponentName)
- );
-}
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-STATIC
-EFI_STATUS
-EFIAPI
-ComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mDeviceName,
- ControllerName,
- (BOOLEAN)(This == &gComponentName)
- );
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.c b/Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.c
deleted file mode 100644
index b880ca82..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.c
+++ /dev/null
@@ -1,639 +0,0 @@
-/** @file
- *
- * Copyright (c) 2017-2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) Microsoft Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <Base.h>
-#include "DisplayDxe.h"
-
-#define MODE_800_ENABLED BIT0
-#define MODE_640_ENABLED BIT1
-#define MODE_1024_ENABLED BIT2
-#define MODE_720P_ENABLED BIT3
-#define MODE_1080P_ENABLED BIT4
-#define MODE_NATIVE_ENABLED BIT5
-#define JUST_NATIVE_ENABLED MODE_NATIVE_ENABLED
-#define ALL_MODES (BIT6 - 1)
-#define POS_TO_FB(posX, posY) ((UINT8*) \
- ((UINTN)This->Mode->FrameBufferBase + \
- (posY) * This->Mode->Info->PixelsPerScanLine * \
- PI3_BYTES_PER_PIXEL + \
- (posX) * PI3_BYTES_PER_PIXEL))
-
-STATIC
-EFI_STATUS
-EFIAPI
-DriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-STATIC
-EFI_STATUS
-EFIAPI
-DriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-STATIC
-EFI_STATUS
-EFIAPI
-DriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- );
-
-STATIC
-EFI_STATUS
-EFIAPI
-DisplayQueryMode (
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
- IN UINT32 ModeNumber,
- OUT UINTN *SizeOfInfo,
- OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
- );
-
-STATIC
-EFI_STATUS
-EFIAPI
-DisplaySetMode (
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
- IN UINT32 ModeNumber
- );
-
-STATIC
-EFI_STATUS
-EFIAPI
-DisplayBlt (
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL
- IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
- IN UINTN SourceX,
- IN UINTN SourceY,
- IN UINTN DestinationX,
- IN UINTN DestinationY,
- IN UINTN Width,
- IN UINTN Height,
- IN UINTN Delta OPTIONAL
- );
-
-STATIC EFI_DRIVER_BINDING_PROTOCOL mDriverBinding = {
- DriverSupported,
- DriverStart,
- DriverStop,
- 0xa,
- NULL,
- NULL
-};
-
-typedef struct {
- VENDOR_DEVICE_PATH DisplayDevicePath;
- EFI_DEVICE_PATH EndDevicePath;
-} DISPLAY_DEVICE_PATH;
-
-typedef struct {
- UINT32 Width;
- UINT32 Height;
-} GOP_MODE_DATA;
-
-STATIC UINT32 mBootWidth;
-STATIC UINT32 mBootHeight;
-STATIC EFI_HANDLE mDevice;
-STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol;
-STATIC EFI_CPU_ARCH_PROTOCOL *mCpu;
-
-STATIC UINTN mLastMode;
-STATIC GOP_MODE_DATA mGopModeTemplate[] = {
- { 800, 600 }, /* Legacy */
- { 640, 480 }, /* Legacy */
- { 1024, 768 }, /* Legacy */
- { 1280, 720 }, /* 720p */
- { 1920, 1080 }, /* 1080p */
- { 0, 0 }, /* Physical */
-};
-
-STATIC UINTN mLastMode;
-STATIC GOP_MODE_DATA mGopModeData[ARRAY_SIZE (mGopModeTemplate)];
-
-STATIC DISPLAY_DEVICE_PATH mDisplayProtoDevicePath =
-{
- {
- {
- HARDWARE_DEVICE_PATH,
- HW_VENDOR_DP,
- {
- (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
- (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8),
- }
- },
- EFI_CALLER_ID_GUID,
- },
- {
- END_DEVICE_PATH_TYPE,
- END_ENTIRE_DEVICE_PATH_SUBTYPE,
- {
- sizeof (EFI_DEVICE_PATH_PROTOCOL),
- 0
- }
- }
-};
-
-#define PI3_BITS_PER_PIXEL (32)
-#define PI3_BYTES_PER_PIXEL (PI3_BITS_PER_PIXEL / 8)
-
-EFI_GRAPHICS_OUTPUT_PROTOCOL gDisplayProto = {
- DisplayQueryMode,
- DisplaySetMode,
- DisplayBlt,
- NULL
-};
-
-STATIC
-EFI_STATUS
-EFIAPI
-DisplayQueryMode (
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
- IN UINT32 ModeNumber,
- OUT UINTN *SizeOfInfo,
- OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
- )
-{
- EFI_STATUS Status;
- GOP_MODE_DATA *Mode;
-
- if (ModeNumber > mLastMode) {
- return EFI_INVALID_PARAMETER;
- }
-
- Status = gBS->AllocatePool (
- EfiBootServicesData,
- sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION),
- (VOID**)Info
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Mode = &mGopModeData[ModeNumber];
-
- *SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
- (*Info)->Version = This->Mode->Info->Version;
- (*Info)->HorizontalResolution = Mode->Width;
- (*Info)->VerticalResolution = Mode->Height;
- (*Info)->PixelFormat = This->Mode->Info->PixelFormat;
- (*Info)->PixelsPerScanLine = Mode->Width;
-
- return EFI_SUCCESS;
-}
-
-STATIC
-VOID
-ClearScreen (
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This
- )
-{
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL Fill;
-
- Fill.Red = 0x00;
- Fill.Green = 0x00;
- Fill.Blue = 0x00;
- This->Blt (This, &Fill, EfiBltVideoFill,
- 0, 0, 0, 0, This->Mode->Info->HorizontalResolution,
- This->Mode->Info->VerticalResolution,
- This->Mode->Info->HorizontalResolution *
- sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-DisplaySetMode (
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
- IN UINT32 ModeNumber
- )
-{
- UINTN FbSize;
- UINTN FbPitch;
- EFI_STATUS Status;
- EFI_PHYSICAL_ADDRESS FbBase;
- GOP_MODE_DATA *Mode = &mGopModeData[ModeNumber];
-
- if (ModeNumber > mLastMode) {
- return EFI_UNSUPPORTED;
- }
-
- DEBUG ((DEBUG_INFO, "Setting mode %u from %u: %u x %u\n",
- ModeNumber, This->Mode->Mode, Mode->Width, Mode->Height));
- Status = mFwProtocol->GetFB (Mode->Width, Mode->Height,
- PI3_BITS_PER_PIXEL, &FbBase,
- &FbSize, &FbPitch);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Could not set mode %u\n", ModeNumber));
- return EFI_DEVICE_ERROR;
- }
-
- DEBUG ((DEBUG_INFO, "Mode %u: %u x %u framebuffer is %u bytes at %p\n",
- ModeNumber, Mode->Width, Mode->Height, FbSize, FbBase));
-
- if (FbPitch / PI3_BYTES_PER_PIXEL != Mode->Width) {
- DEBUG ((DEBUG_ERROR, "Error: Expected width %u, got width %u\n",
- Mode->Width, FbPitch / PI3_BYTES_PER_PIXEL));
- return EFI_DEVICE_ERROR;
- }
-
- /*
- * WT, because certain OS loaders access the frame buffer directly
- * and we don't want to see corruption due to missing WB cache
- * maintenance. Performance with WT is good.
- */
- Status = mCpu->SetMemoryAttributes (mCpu, FbBase,
- ALIGN_VALUE (FbSize, EFI_PAGE_SIZE),
- EFI_MEMORY_WT);
- if (Status != EFI_SUCCESS) {
- DEBUG ((DEBUG_ERROR, "Couldn't set framebuffer attributes: %r\n", Status));
- return Status;
- }
-
- This->Mode->Mode = ModeNumber;
- This->Mode->Info->Version = 0;
- This->Mode->Info->HorizontalResolution = Mode->Width;
- This->Mode->Info->VerticalResolution = Mode->Height;
- /*
- * NOTE: Windows REQUIRES BGR in 32 or 24 bit format.
- */
- This->Mode->Info->PixelFormat = PixelBlueGreenRedReserved8BitPerColor;
- This->Mode->Info->PixelsPerScanLine = Mode->Width;
- This->Mode->SizeOfInfo = sizeof (*This->Mode->Info);
- This->Mode->FrameBufferBase = FbBase;
- This->Mode->FrameBufferSize = FbSize;
-
- ClearScreen (This);
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-DisplayBlt (
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
- IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer, OPTIONAL
- IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
- IN UINTN SourceX,
- IN UINTN SourceY,
- IN UINTN DestinationX,
- IN UINTN DestinationY,
- IN UINTN Width,
- IN UINTN Height,
- IN UINTN Delta OPTIONAL
- )
-{
- UINT8 *VidBuf, *BltBuf, *VidBuf1;
- UINTN i;
-
- switch (BltOperation) {
- case EfiBltVideoFill:
- BltBuf = (UINT8*)BltBuffer;
-
- for (i = 0; i < Height; i++) {
- VidBuf = POS_TO_FB (DestinationX, DestinationY + i);
-
- SetMem32 (VidBuf, Width * PI3_BYTES_PER_PIXEL, *(UINT32*)BltBuf);
- }
- break;
-
- case EfiBltVideoToBltBuffer:
- if (Delta == 0) {
- Delta = Width * PI3_BYTES_PER_PIXEL;
- }
-
- for (i = 0; i < Height; i++) {
- VidBuf = POS_TO_FB (SourceX, SourceY + i);
-
- BltBuf = (UINT8*)((UINTN)BltBuffer + (DestinationY + i) * Delta +
- DestinationX * PI3_BYTES_PER_PIXEL);
-
- gBS->CopyMem ((VOID*)BltBuf, (VOID*)VidBuf, PI3_BYTES_PER_PIXEL * Width);
- }
- break;
-
- case EfiBltBufferToVideo:
- if (Delta == 0) {
- Delta = Width * PI3_BYTES_PER_PIXEL;
- }
-
- for (i = 0; i < Height; i++) {
- VidBuf = POS_TO_FB (DestinationX, DestinationY + i);
- BltBuf = (UINT8*)((UINTN)BltBuffer + (SourceY + i) * Delta +
- SourceX * PI3_BYTES_PER_PIXEL);
-
- gBS->CopyMem ((VOID*)VidBuf, (VOID*)BltBuf, Width * PI3_BYTES_PER_PIXEL);
- }
- break;
-
- case EfiBltVideoToVideo:
- for (i = 0; i < Height; i++) {
- VidBuf = POS_TO_FB (SourceX, SourceY + i);
- VidBuf1 = POS_TO_FB (DestinationX, DestinationY + i);
-
- gBS->CopyMem ((VOID*)VidBuf1, (VOID*)VidBuf, Width * PI3_BYTES_PER_PIXEL);
- }
- break;
-
- default:
- ASSERT_EFI_ERROR (EFI_SUCCESS);
- break;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Initialize the state information for the Display Dxe
-
- @param ImageHandle of the loaded driver
- @param SystemTable Pointer to the System Table
-
- @retval EFI_SUCCESS Protocol registered
- @retval EFI_OUT_OF_RESOURCES Cannot allocate protocol data structure
- @retval EFI_DEVICE_ERROR Hardware problems
-
-**/
-EFI_STATUS
-EFIAPI
-DisplayDxeInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- Status = gBS->LocateProtocol (&gRaspberryPiFirmwareProtocolGuid, NULL,
- (VOID**)&mFwProtocol);
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL,
- (VOID**)&mCpu);
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- // Query the current display resolution from mailbox
- Status = mFwProtocol->GetFBSize (&mBootWidth, &mBootHeight);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- DEBUG ((DEBUG_INFO, "Display boot mode is %u x %u\n",
- mBootWidth, mBootHeight));
-
- Status = gBS->InstallMultipleProtocolInterfaces (
- &mDevice, &gEfiDevicePathProtocolGuid,
- &mDisplayProtoDevicePath, &gEfiCallerIdGuid,
- NULL, NULL);
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &mDriverBinding,
- ImageHandle,
- &gComponentName,
- &gComponentName2
- );
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- return Status;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-DriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- VOID *Temp;
-
- if (Controller != mDevice) {
- return EFI_UNSUPPORTED;
- }
-
- if (gBS->HandleProtocol (Controller, &gEfiGraphicsOutputProtocolGuid,
- (VOID**)&Temp) == EFI_SUCCESS) {
- return EFI_ALREADY_STARTED;
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-DriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- UINTN Index;
- UINTN TempIndex;
- EFI_STATUS Status;
- VOID *Dummy;
-
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiCallerIdGuid,
- (VOID**)&Dummy,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- gDisplayProto.Mode = AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE));
- if (gDisplayProto.Mode == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Done;
- }
-
- gDisplayProto.Mode->Info = AllocateZeroPool (sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION));
- if (gDisplayProto.Mode->Info == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- goto Done;
- }
-
- PcdSet8 (PcdDisplayEnableScaledVModes,
- PcdGet8 (PcdDisplayEnableScaledVModes) & ALL_MODES);
-
- if (PcdGet8 (PcdDisplayEnableScaledVModes) == 0) {
- PcdSet8 (PcdDisplayEnableScaledVModes, JUST_NATIVE_ENABLED);
- }
-
- mLastMode = 0;
- for (TempIndex = 0, Index = 0;
- TempIndex < ARRAY_SIZE (mGopModeTemplate); TempIndex++) {
- if ((PcdGet8 (PcdDisplayEnableScaledVModes) & (1 << TempIndex)) != 0) {
- DEBUG ((DEBUG_ERROR, "Mode %u: %u x %u present\n",
- TempIndex, mGopModeTemplate[TempIndex].Width,
- mGopModeTemplate[TempIndex].Height));
-
- CopyMem (&mGopModeData[Index], &mGopModeTemplate[TempIndex],
- sizeof (GOP_MODE_DATA));
- mLastMode = Index;
- Index++;
- }
- }
-
- if (PcdGet8 (PcdDisplayEnableScaledVModes) == JUST_NATIVE_ENABLED) {
- /*
- * mBootWidth x mBootHeight may not be sensible,
- * so clean it up, since we won't be adding
- * any other extra vmodes.
- */
- if (mBootWidth < 640 || mBootHeight < 480) {
- mBootWidth = 640;
- mBootHeight = 480;
- } else if (mBootWidth == 800 && mBootHeight == 480) {
- /* The Pi 7" screen is close to 800x600, just pretend it is. */
- mBootHeight = 600;
- }
- }
-
- if ((PcdGet8(PcdDisplayEnableScaledVModes) & MODE_NATIVE_ENABLED) != 0) {
- /*
- * Adjust actual native res only if native res is enabled
- * (so last mode is native res).
- */
- mGopModeData[mLastMode].Width = mBootWidth;
- mGopModeData[mLastMode].Height = mBootHeight;
- }
-
- for (Index = 0; Index <= mLastMode; Index++) {
- UINTN FbSize;
- UINTN FbPitch;
- EFI_PHYSICAL_ADDRESS FbBase;
-
- GOP_MODE_DATA *Mode = &mGopModeData[Index];
-
- Status = mFwProtocol->GetFB (Mode->Width, Mode->Height,
- PI3_BITS_PER_PIXEL, &FbBase,
- &FbSize, &FbPitch);
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- //
- // There is no way to communicate pitch back to OS. OS and even UEFI
- // expect a fully linear frame buffer. So the width should
- // be based on the frame buffer's pitch value. In some cases VC
- // firmware would allocate ao frame buffer with some padding
- // presumably to be 8 byte align.
- //
- Mode->Width = FbPitch / PI3_BYTES_PER_PIXEL;
-
- DEBUG ((DEBUG_INFO, "Mode %u: %u x %u framebuffer is %u bytes at %p\n",
- Index, Mode->Width, Mode->Height, FbSize, FbBase));
-
- ASSERT (FbPitch != 0);
- ASSERT (FbBase != 0);
- ASSERT (FbSize != 0);
- }
-
- // Both set the mode and initialize current mode information.
- gDisplayProto.Mode->MaxMode = mLastMode + 1;
- DisplaySetMode (&gDisplayProto, 0);
-
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Controller, &gEfiGraphicsOutputProtocolGuid,
- &gDisplayProto, NULL);
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- if (PcdGet32 (PcdDisplayEnableSShot)) {
- RegisterScreenshotHandlers ();
- } else {
- DEBUG ((DEBUG_INFO, "Screenshot capture disabled\n"));
- }
-
-Done:
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Could not start DisplayDxe: %r\n", Status));
- if (gDisplayProto.Mode->Info != NULL) {
- FreePool (gDisplayProto.Mode->Info);
- gDisplayProto.Mode->Info = NULL;
- }
-
- if (gDisplayProto.Mode != NULL) {
- FreePool (gDisplayProto.Mode);
- gDisplayProto.Mode = NULL;
- }
-
- gBS->CloseProtocol (
- Controller,
- &gEfiCallerIdGuid,
- This->DriverBindingHandle,
- Controller
- );
- }
- return Status;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-DriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
-{
- EFI_STATUS Status;
-
- ClearScreen (&gDisplayProto);
-
- Status = gBS->UninstallMultipleProtocolInterfaces (
- Controller, &gEfiGraphicsOutputProtocolGuid,
- &gDisplayProto, NULL);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- FreePool (gDisplayProto.Mode->Info);
- gDisplayProto.Mode->Info = NULL;
- FreePool (gDisplayProto.Mode);
- gDisplayProto.Mode = NULL;
-
- gBS->CloseProtocol (
- Controller,
- &gEfiCallerIdGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- return Status;
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.h b/Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.h
deleted file mode 100644
index bfbe9e86..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/** @file
- *
- * Copyright (c) 2017-2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) Microsoft Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#ifndef _DISPLAY_H_
-#define _DISPLAY_H_
-
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-#include <Library/PcdLib.h>
-#include <Library/IoLib.h>
-#include <Library/TimerLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Protocol/Cpu.h>
-#include <Protocol/GraphicsOutput.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/RpiFirmware.h>
-
-extern EFI_GRAPHICS_OUTPUT_PROTOCOL gDisplayProto;
-extern EFI_COMPONENT_NAME_PROTOCOL gComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gComponentName2;
-
-VOID
-RegisterScreenshotHandlers (
- VOID
- );
-
-#endif /* _DISPLAY_H_ */
diff --git a/Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.inf b/Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.inf
deleted file mode 100644
index 31da2090..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/DisplayDxe.inf
+++ /dev/null
@@ -1,66 +0,0 @@
-#/** @file
-#
-# Component description file for Graphics Output module
-#
-# Copyright (c) 2017, Andrei Warkentin <andrey.warkentin@gmail.com>
-# Copyright (c) Microsoft Corporation. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x0001001A
- BASE_NAME = DisplayDxe
- FILE_GUID = c5deae31-fad2-4030-841b-cfc9644d2c5b
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = DisplayDxeInitialize
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# DRIVER_BINDING = gGraphicsConsoleDriverBinding
-# COMPONENT_NAME = gGraphicsConsoleComponentName
-# COMPONENT_NAME2 = gGraphicsConsoleComponentName2
-#
-
-[Sources]
- DisplayDxe.h
- DisplayDxe.c
- Screenshot.c
- ComponentName.c
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- ArmPkg/ArmPkg.dec
- Platform/RaspberryPi/RPi3/RPi3.dec
-
-[LibraryClasses]
- BaseLib
- UefiLib
- MemoryAllocationLib
- UefiDriverEntryPoint
- IoLib
- TimerLib
- BmpSupportLib
- UefiRuntimeServicesTableLib
-
-[Protocols]
- gEfiLoadedImageProtocolGuid
- gEfiDevicePathProtocolGuid
- gEfiGraphicsOutputProtocolGuid
- gEfiCpuArchProtocolGuid
- gEfiSimpleFileSystemProtocolGuid
- gEfiSimpleTextInputExProtocolGuid
- gRaspberryPiFirmwareProtocolGuid
-
-[Pcd]
- gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes
- gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot
-
-[Guids]
-
-[Depex]
- gEfiCpuArchProtocolGuid AND gRaspberryPiFirmwareProtocolGuid
diff --git a/Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/Screenshot.c b/Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/Screenshot.c
deleted file mode 100644
index 5f31c64b..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/DisplayDxe/Screenshot.c
+++ /dev/null
@@ -1,369 +0,0 @@
-/** @file
- *
- * Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
- * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-/*
- * Loosely based on CrScreenShotDxe (https://github.com/LongSoft/CrScreenshotDxe).
- *
- * Copyright (c) 2016, Nikolaj Schlej, All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * - Redistributions of source code must retain the above copyright notice,
- * this list of conditions and the following disclaimer.
- * - Redistributions in binary form must reproduce the above copyright notice,
- * this list of conditions and the following disclaimer in the documentation
- * and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
- * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "DisplayDxe.h"
-#include <Protocol/SimpleFileSystem.h>
-#include <Library/PrintLib.h>
-#include <Library/BmpSupportLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-
-/*
- * ShowStatus defs.
- */
-#define STATUS_SQUARE_SIDE 5
-#define STATUS_YELLOW 0xff, 0xff, 0x00
-#define STATUS_GREEN 0x00, 0xff, 0x00
-#define STATUS_BLUE 0x00, 0x00, 0xff
-#define STATUS_RED 0xff, 0x00, 0x00
-
-EFI_STATUS
-ShowStatus (
- IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,
- IN UINT8 Red,
- IN UINT8 Green,
- IN UINT8 Blue
- )
-{
- UINTN Index;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL Square[STATUS_SQUARE_SIDE * STATUS_SQUARE_SIDE];
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL Backup[STATUS_SQUARE_SIDE * STATUS_SQUARE_SIDE];
-
- for (Index = 0; Index < STATUS_SQUARE_SIDE * STATUS_SQUARE_SIDE; Index++) {
- Square[Index].Blue = Blue;
- Square[Index].Green = Green;
- Square[Index].Red = Red;
- Square[Index].Reserved = 0x00;
- }
-
- // Backup current image.
- GraphicsOutput->Blt (GraphicsOutput, Backup,
- EfiBltVideoToBltBuffer, 0, 0, 0, 0,
- STATUS_SQUARE_SIDE, STATUS_SQUARE_SIDE, 0);
-
- // Draw the status square.
- GraphicsOutput->Blt (GraphicsOutput, Square,
- EfiBltBufferToVideo, 0, 0, 0, 0,
- STATUS_SQUARE_SIDE, STATUS_SQUARE_SIDE, 0);
-
- // Wait 500ms.
- gBS->Stall (500 * 1000);
-
- // Restore the backup.
- GraphicsOutput->Blt (GraphicsOutput, Backup,
- EfiBltBufferToVideo, 0, 0, 0, 0,
- STATUS_SQUARE_SIDE, STATUS_SQUARE_SIDE, 0);
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-FindWritableFs (
- OUT EFI_FILE_PROTOCOL **WritableFs
- )
-{
- EFI_FILE_PROTOCOL *Fs = NULL;
- EFI_HANDLE *HandleBuffer = NULL;
- UINTN HandleCount;
- UINTN Index;
-
- EFI_STATUS Status = gBS->LocateHandleBuffer (ByProtocol,
- &gEfiSimpleFileSystemProtocolGuid,
- NULL, &HandleCount, &HandleBuffer);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- for (Index = 0; Index < HandleCount; Index++) {
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *SimpleFs = NULL;
- EFI_FILE_PROTOCOL *File = NULL;
-
- Status = gBS->HandleProtocol (HandleBuffer[Index],
- &gEfiSimpleFileSystemProtocolGuid,
- (VOID**)&SimpleFs);
- if (EFI_ERROR (Status)) {
- ASSERT_EFI_ERROR (Status);
- /*
- * Not supposed to happen.
- */
- continue;
- }
-
- Status = SimpleFs->OpenVolume (SimpleFs, &Fs);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a OpenVolume[%u] returned %r\n", __FUNCTION__, Index, Status));
- continue;
- }
-
- Status = Fs->Open (Fs, &File, L"--------.---",
- EFI_FILE_MODE_CREATE | EFI_FILE_MODE_READ |
- EFI_FILE_MODE_WRITE, 0);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a Open[%u] returned %r\n", __FUNCTION__, Index, Status));
- continue;
- }
-
- /*
- * Okay, we have a writable filesystem!
- */
- Fs->Delete (File);
- *WritableFs = Fs;
- Status = EFI_SUCCESS;
- break;
- }
-
- if (HandleBuffer) {
- FreePool (HandleBuffer);
- }
-
- return Status;
-}
-
-STATIC
-VOID
-TakeScreenshot (
- VOID
- )
-{
- VOID *BmpImage = NULL;
- EFI_FILE_PROTOCOL *Fs = NULL;
- EFI_FILE_PROTOCOL *File = NULL;
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput = &gDisplayProto;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Image = NULL;
- EFI_STATUS Status;
- CHAR16 FileName[8 + 1 + 3 + 1];
- UINT32 ScreenWidth;
- UINT32 ScreenHeight;
- UINTN ImageSize;
- UINTN BmpSize;
- UINTN Index;
- EFI_TIME Time;
-
- Status = FindWritableFs (&Fs);
- if (EFI_ERROR (Status)) {
- ShowStatus (GraphicsOutput, STATUS_YELLOW);
- }
-
- ScreenWidth = GraphicsOutput->Mode->Info->HorizontalResolution;
- ScreenHeight = GraphicsOutput->Mode->Info->VerticalResolution;
- ImageSize = ScreenWidth * ScreenHeight;
-
- Status = gRT->GetTime (&Time, NULL);
- if (!EFI_ERROR (Status)) {
- UnicodeSPrint (FileName, sizeof (FileName), L"%02d%02d%02d%02d.bmp",
- Time.Day, Time.Hour, Time.Minute, Time.Second);
- } else {
- UnicodeSPrint (FileName, sizeof (FileName), L"scrnshot.bmp");
- }
-
- Image = AllocatePool (ImageSize * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
- if (Image == NULL) {
- Status = EFI_OUT_OF_RESOURCES;
- ShowStatus (GraphicsOutput, STATUS_RED);
- goto Done;
- }
-
- Status = GraphicsOutput->Blt (GraphicsOutput, Image,
- EfiBltVideoToBltBuffer, 0, 0, 0, 0,
- ScreenWidth, ScreenHeight, 0);
- if (EFI_ERROR (Status)) {
- ShowStatus (GraphicsOutput, STATUS_RED);
- goto Done;
- }
-
- for (Index = 0; Index < ImageSize; Index++) {
- if (Image[Index].Red != 0x00 ||
- Image[Index].Green != 0x00 ||
- Image[Index].Blue != 0x00) {
- break;
- }
- }
-
- if (Index == ImageSize) {
- ShowStatus (GraphicsOutput, STATUS_BLUE);
- goto Done;
- }
-
- Status = TranslateGopBltToBmp (Image, ScreenHeight, ScreenWidth,
- &BmpImage, (UINT32*)&BmpSize);
- if (EFI_ERROR (Status)) {
- ShowStatus (GraphicsOutput, STATUS_RED);
- goto Done;
- }
-
- Status = Fs->Open (Fs, &File, FileName, EFI_FILE_MODE_CREATE |
- EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE, 0);
- if (EFI_ERROR (Status)) {
- ShowStatus (GraphicsOutput, STATUS_RED);
- goto Done;
- }
-
- Status = File->Write (File, &BmpSize, BmpImage);
- File->Close (File);
- if (EFI_ERROR (Status)) {
- ShowStatus (GraphicsOutput, STATUS_RED);
- goto Done;
- }
-
- ShowStatus (GraphicsOutput, STATUS_GREEN);
-
-Done:
- if (BmpImage != NULL) {
- FreePool (BmpImage);
- }
-
- if (Image != NULL) {
- FreePool (Image);
- }
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-ScreenshotKeyHandler (
- IN EFI_KEY_DATA *KeyData
- )
-{
- TakeScreenshot ();
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-ProcessScreenshotHandler (
- IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *SimpleTextInEx
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE Handle;
- EFI_KEY_DATA ScreenshotKey;
-
- /*
- * LCtrl+LAlt+F12
- */
- ScreenshotKey.Key.ScanCode = SCAN_F12;
- ScreenshotKey.Key.UnicodeChar = 0;
- ScreenshotKey.KeyState.KeyShiftState = EFI_SHIFT_STATE_VALID |
- EFI_LEFT_CONTROL_PRESSED | EFI_LEFT_ALT_PRESSED;
- ScreenshotKey.KeyState.KeyToggleState = 0;
-
- Status = SimpleTextInEx->RegisterKeyNotify (
- SimpleTextInEx,
- &ScreenshotKey,
- ScreenshotKeyHandler,
- &Handle
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: couldn't register key notification: %r\n", __FUNCTION__, Status));
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC
-VOID
-ProcessScreenshotHandlers (
- VOID
- )
-{
- UINTN Index;
- EFI_STATUS Status;
- UINTN HandleCount;
- EFI_HANDLE *HandleBuffer;
- EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *SimpleTextInEx;
-
- Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiSimpleTextInputExProtocolGuid,
- NULL, &HandleCount, &HandleBuffer);
- if (EFI_ERROR (Status)) {
- return;
- }
-
- for (Index = 0; Index < HandleCount; Index++) {
- Status = gBS->HandleProtocol (HandleBuffer[Index],
- &gEfiSimpleTextInputExProtocolGuid,
- (VOID**)&SimpleTextInEx);
- if (EFI_ERROR (Status)) {
- ASSERT_EFI_ERROR (Status);
- /*
- * Not supposed to happen.
- */
- continue;
- }
-
- Status = ProcessScreenshotHandler (SimpleTextInEx);
- if (EFI_ERROR (Status)) {
- continue;
- }
- }
-}
-
-STATIC
-VOID
-EFIAPI
-OnTextInExInstall (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- ProcessScreenshotHandlers ();
-}
-
-VOID
-RegisterScreenshotHandlers (
- VOID
-)
-{
- EFI_STATUS Status;
- EFI_EVENT TextInExInstallEvent;
- VOID *TextInExInstallRegistration;
-
- ProcessScreenshotHandlers ();
-
- Status = gBS->CreateEvent (EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
- OnTextInExInstall, NULL,
- &TextInExInstallEvent);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: couldn't create protocol install event: %r\n", __FUNCTION__, Status));
- return;
- }
-
- Status = gBS->RegisterProtocolNotify (&gEfiSimpleTextInputExProtocolGuid,
- TextInExInstallEvent,
- &TextInExInstallRegistration);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: couldn't register protocol install notify: %r\n", __FUNCTION__, Status));
- return;
- }
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/ComponentName.c b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/ComponentName.c
deleted file mode 100644
index 2f3c5332..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/ComponentName.c
+++ /dev/null
@@ -1,219 +0,0 @@
-/** @file
- *
- * Copyright (c) 2018, Andrey Warkentin <andrey.warkentin@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include "DwUsbHostDxe.h"
-
-STATIC
-EFI_STATUS
-EFIAPI
-ComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- );
-
-STATIC
-EFI_STATUS
-EFIAPI
-ComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- );
-
-//
-// EFI Component Name Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gComponentName = {
- ComponentNameGetDriverName,
- ComponentNameGetControllerName,
- "eng"
-};
-
-//
-// EFI Component Name 2 Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)ComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)ComponentNameGetControllerName,
- "en"
-};
-
-
-STATIC EFI_UNICODE_STRING_TABLE mDriverName[] = {
- {
- "eng;en",
- (CHAR16*)L"Raspberry Pi USB Host Driver"
- },
- {
- NULL,
- NULL
- }
-};
-
-STATIC EFI_UNICODE_STRING_TABLE mDeviceName[] = {
- {
- "eng;en",
- (CHAR16*)L"Raspberry Pi USB Host"
- },
- {
- NULL,
- NULL
- }
-};
-
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-STATIC
-EFI_STATUS
-EFIAPI
-ComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mDriverName,
- DriverName,
- (BOOLEAN)(This == &gComponentName)
- );
-}
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-STATIC
-EFI_STATUS
-EFIAPI
-ComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-{
- if (ChildHandle != NULL) {
- return EFI_UNSUPPORTED;
- }
-
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mDeviceName,
- ControllerName,
- (BOOLEAN)(This == &gComponentName)
- );
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DriverBinding.c b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DriverBinding.c
deleted file mode 100644
index 7f78179d..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DriverBinding.c
+++ /dev/null
@@ -1,268 +0,0 @@
-/** @file
- *
- * Copyright (c) 2018, Andrey Warkentin <andrey.warkentin@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include "DwUsbHostDxe.h"
-
-STATIC
-EFI_STATUS
-EFIAPI
-DriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-STATIC
-EFI_STATUS
-EFIAPI
-DriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-STATIC
-EFI_STATUS
-EFIAPI
-DriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- );
-
-STATIC EFI_DRIVER_BINDING_PROTOCOL mDriverBinding = {
- DriverSupported,
- DriverStart,
- DriverStop,
- 0xa,
- NULL,
- NULL
-};
-
-STATIC EFI_DW_DEVICE_PATH mDevicePath = {
- {
- {
- HARDWARE_DEVICE_PATH,
- HW_VENDOR_DP,
- {
- (UINT8)(sizeof (VENDOR_DEVICE_PATH)),
- (UINT8)((sizeof (VENDOR_DEVICE_PATH)) >> 8),
- }
- },
- EFI_CALLER_ID_GUID
- },
- {
- END_DEVICE_PATH_TYPE,
- END_ENTIRE_DEVICE_PATH_SUBTYPE,
- {
- sizeof (EFI_DEVICE_PATH_PROTOCOL),
- 0
- }
- }
-};
-
-STATIC EFI_HANDLE mDevice;
-STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol;
-
-STATIC
-EFI_STATUS
-EFIAPI
-DriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- VOID *Temp;
- EFI_STATUS Status;
-
- if (Controller != mDevice) {
- return EFI_UNSUPPORTED;
- }
-
- Status = gBS->LocateProtocol (&gRaspberryPiFirmwareProtocolGuid, NULL,
- (VOID**)&mFwProtocol);
- if (EFI_ERROR (Status)) {
- return EFI_NOT_READY;
- }
-
- if (gBS->HandleProtocol (Controller, &gEfiUsb2HcProtocolGuid,
- (VOID**)&Temp) == EFI_SUCCESS) {
- return EFI_ALREADY_STARTED;
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-DriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- VOID *Dummy;
- EFI_STATUS Status;
- DWUSB_OTGHC_DEV *DwHc = NULL;
-
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiCallerIdGuid,
- (VOID**)&Dummy,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = mFwProtocol->SetPowerState (RPI_MBOX_POWER_STATE_USB_HCD, TRUE, TRUE);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Couldn't power on USB: %r\n", Status));
- return Status;
- }
-
- Status = CreateDwUsbHc (&DwHc);
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
-
- /*
- * UsbBusDxe as of b4e96b82b4e2e47e95014b51787ba5b43abac784 expects
- * the HCD to do this. There is no agent invoking DwHcReset anymore.
- */
- DwHcReset (&DwHc->DwUsbOtgHc, 0);
- DwHcSetState (&DwHc->DwUsbOtgHc, EfiUsbHcStateOperational);
-
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Controller,
- &gEfiUsb2HcProtocolGuid, &DwHc->DwUsbOtgHc,
- NULL
- );
-
-Exit:
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Could not start DwUsbHostDxe: %r\n", Status));
-
- DestroyDwUsbHc (DwHc);
-
- mFwProtocol->SetPowerState (RPI_MBOX_POWER_STATE_USB_HCD, FALSE, FALSE);
-
- gBS->CloseProtocol (
- Controller,
- &gEfiCallerIdGuid,
- This->DriverBindingHandle,
- Controller
- );
- }
- return Status;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-DriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
-{
- EFI_STATUS Status;
- DWUSB_OTGHC_DEV *DwHc;
- EFI_USB2_HC_PROTOCOL *HcProtocol;
-
- Status = gBS->HandleProtocol (
- Controller,
- &gEfiUsb2HcProtocolGuid,
- (VOID**)&HcProtocol
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "DriverStop: HandleProtocol: %r\n", Status));
- return Status;
- }
-
- DwHc = DWHC_FROM_THIS (HcProtocol);
-
- Status = gBS->UninstallMultipleProtocolInterfaces (
- Controller,
- &gEfiUsb2HcProtocolGuid, &DwHc->DwUsbOtgHc,
- NULL);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "DriverStop: UninstallMultipleProtocolInterfaces: %r\n",
- Status));
- return Status;
- }
-
- DwHcQuiesce (DwHc);
- DestroyDwUsbHc (DwHc);
-
- gBS->CloseProtocol (
- Controller,
- &gEfiCallerIdGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- return EFI_SUCCESS;
-}
-
-/**
- UEFI Driver Entry Point API
-
- @param ImageHandle EFI_HANDLE.
- @param SystemTable EFI_SYSTEM_TABLE.
-
- @return EFI_SUCCESS Success.
- EFI_DEVICE_ERROR Fail.
-**/
-
-EFI_STATUS
-EFIAPI
-DwUsbHostEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- Status = gBS->InstallMultipleProtocolInterfaces (
- &mDevice,
- &gEfiDevicePathProtocolGuid, &mDevicePath,
- &gEfiCallerIdGuid, NULL,
- NULL);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "InstallMultipleProtocolInterfaces: %r\n", Status));
- return Status;
- }
-
- Status = EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &mDriverBinding,
- ImageHandle,
- &gComponentName,
- &gComponentName2
- );
-
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "EfiLibInstallDriverBindingComponentName2: %r\n", Status));
- gBS->UninstallMultipleProtocolInterfaces (
- mDevice,
- &gEfiDevicePathProtocolGuid, &mDevicePath,
- &gEfiCallerIdGuid, NULL,
- NULL
- );
- }
-
- return Status;
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
deleted file mode 100644
index 37ebf503..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.c
+++ /dev/null
@@ -1,1635 +0,0 @@
-/** @file
- *
- * Copyright (c) 2017-2018, Andrey Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2015-2016, Linaro Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include "DwUsbHostDxe.h"
-#include "DwcHw.h"
-
-/*
- * Excessive (10s) timeout for reset.
- */
-#define DW_HC_RESET_TIMEOUT_MS (10000)
-
- /*
- * TimerPeriodic to account for timeout processing
- * within DwHcTransfer.
- */
-#define TimerForTransfer TimerRelative
-
-/*
- * https://www.quicklogic.com/assets/pdf/data-sheets/QL-Hi-Speed-USB-2.0-OTG-Controller-Data-Sheet.pdf
- */
-
-typedef enum {
- XFER_NOT_HALTED,
- XFER_ERROR,
- XFER_CSPLIT,
- XFER_NAK,
- XFER_STALL,
- XFER_FRMOVRUN,
- XFER_DONE
-} CHANNEL_HALT_REASON;
-
-typedef struct {
- BOOLEAN Splitting;
- BOOLEAN SplitStart;
- UINT32 Tries;
-} SPLIT_CONTROL;
-
-EFI_STATUS
-DwHcInit (
- IN DWUSB_OTGHC_DEV *DwHc,
- IN EFI_EVENT Timeout
- );
-
-EFI_STATUS
-DwCoreInit (
- IN DWUSB_OTGHC_DEV *DwHc,
- IN EFI_EVENT Timeout
- );
-
-EFI_STATUS
-Wait4Bit (
- IN EFI_EVENT Timeout,
- IN UINT32 Reg,
- IN UINT32 Mask,
- IN BOOLEAN Set
- )
-{
- UINT32 Value;
-
- do {
- Value = MmioRead32 (Reg);
- if (!Set) {
- Value = ~Value;
- }
-
- if ((Value & Mask) == Mask) {
- return EFI_SUCCESS;
- }
- } while (EFI_ERROR (gBS->CheckEvent (Timeout)));
-
- return EFI_TIMEOUT;
-}
-
-CHANNEL_HALT_REASON
-Wait4Chhltd (
- IN DWUSB_OTGHC_DEV *DwHc,
- IN EFI_EVENT Timeout,
- IN UINT32 Channel,
- IN UINT32 *Sub,
- IN UINT32 *Toggle,
- IN BOOLEAN IgnoreAck,
- IN SPLIT_CONTROL *Split
- )
-{
- EFI_STATUS Status;
- UINT32 Hcint, Hctsiz;
- UINT32 HcintCompHltAck = DWC2_HCINT_XFERCOMP;
-
- MicroSecondDelay (100);
- Status = Wait4Bit (Timeout, DwHc->DwUsbBase + HCINT (Channel),
- DWC2_HCINT_CHHLTD, 1);
- if (EFI_ERROR (Status)) {
- return XFER_NOT_HALTED;
- }
-
- MicroSecondDelay (100);
- Hcint = MmioRead32 (DwHc->DwUsbBase + HCINT (Channel));
-
- ASSERT ((Hcint & DWC2_HCINT_CHHLTD) != 0);
- Hcint &= ~DWC2_HCINT_CHHLTD;
-
- if (!IgnoreAck ||
- (Split->Splitting && Split->SplitStart)) {
- HcintCompHltAck |= DWC2_HCINT_ACK;
- } else {
- Hcint &= ~DWC2_HCINT_ACK;
- }
-
- if ((Hcint & DWC2_HCINT_XACTERR) != 0) {
- return XFER_ERROR;
- }
-
- if ((Hcint & DWC2_HCINT_NYET) != 0) {
- return XFER_CSPLIT;
- }
-
- if ((Hcint & DWC2_HCINT_NAK) != 0) {
- return XFER_NAK;
- }
-
- if ((Hcint & DWC2_HCINT_STALL) != 0) {
- return XFER_STALL;
- }
-
- if ((Hcint & DWC2_HCINT_FRMOVRUN) != 0) {
- return XFER_FRMOVRUN;
- }
-
- if (Split->Splitting &&
- Split->SplitStart &&
- ((Hcint & DWC2_HCINT_ACK) != 0)) {
- Split->SplitStart = FALSE;
- Split->Tries = 0;
- return XFER_CSPLIT;
- }
-
- if (Hcint != HcintCompHltAck) {
- DEBUG ((DEBUG_ERROR, "Wait4Chhltd: Channel %u HCINT 0x%x %a%a\n",
- Channel, Hcint,
- IgnoreAck ? "IgnoreAck " : "",
- Split->SplitStart ? "split start" :
- (Split->Splitting ? "split complete" : "")));
- return XFER_ERROR;
- }
-
- Hctsiz = MmioRead32 (DwHc->DwUsbBase + HCTSIZ (Channel));
- *Sub = (Hctsiz & DWC2_HCTSIZ_XFERSIZE_MASK) >> DWC2_HCTSIZ_XFERSIZE_OFFSET;
- *Toggle = (Hctsiz & DWC2_HCTSIZ_PID_MASK) >> DWC2_HCTSIZ_PID_OFFSET;
-
- return XFER_DONE;
-}
-
-VOID
-DwOtgHcInit (
- IN DWUSB_OTGHC_DEV *DwHc,
- IN UINT8 HcNum,
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
- IN UINT8 DeviceSpeed,
- IN UINT8 DevAddr,
- IN UINT8 Endpoint,
- IN UINT8 EpDir,
- IN UINT8 EpType,
- IN UINT16 MaxPacket,
- IN SPLIT_CONTROL *SplitControl
- )
-{
- UINT32 Split = 0;
- UINT32 Hcchar = (DevAddr << DWC2_HCCHAR_DEVADDR_OFFSET) |
- (Endpoint << DWC2_HCCHAR_EPNUM_OFFSET) |
- (EpDir << DWC2_HCCHAR_EPDIR_OFFSET) |
- (EpType << DWC2_HCCHAR_EPTYPE_OFFSET) |
- (MaxPacket << DWC2_HCCHAR_MPS_OFFSET) |
- ((DeviceSpeed == EFI_USB_SPEED_LOW) ? DWC2_HCCHAR_LSPDDEV : 0);
-
- MmioWrite32 (DwHc->DwUsbBase + HCINT (HcNum), 0x3FFF);
-
- MmioWrite32 (DwHc->DwUsbBase + HCCHAR (HcNum), Hcchar);
-
- if (SplitControl->Splitting) {
- Split = DWC2_HCSPLT_SPLTENA |
- ((Translator->TranslatorPortNumber) << DWC2_HCSPLT_PRTADDR_OFFSET) |
- ((Translator->TranslatorHubAddress) << DWC2_HCSPLT_HUBADDR_OFFSET);
-
- if (!SplitControl->SplitStart) {
- Split |= DWC2_HCSPLT_COMPSPLT;
- }
- }
-
- MmioWrite32 (DwHc->DwUsbBase + HCSPLT (HcNum), Split);
-}
-
-EFI_STATUS
-DwCoreReset (
- IN DWUSB_OTGHC_DEV *DwHc,
- IN EFI_EVENT Timeout
- )
-{
- EFI_STATUS Status;
-
- Status = Wait4Bit (Timeout, DwHc->DwUsbBase + GRSTCTL, DWC2_GRSTCTL_AHBIDLE, 1);
- if (Status) {
- DEBUG ((DEBUG_ERROR, "DwCoreReset: AHBIDLE Timeout!\n"));
- return Status;
- }
-
- MmioWrite32 (DwHc->DwUsbBase + GRSTCTL, DWC2_GRSTCTL_CSFTRST);
-
- Status = Wait4Bit (Timeout, DwHc->DwUsbBase + GRSTCTL, DWC2_GRSTCTL_CSFTRST, 0);
- if (Status) {
- DEBUG ((DEBUG_ERROR, "DwCoreReset: CSFTRST Timeout!\n"));
- return Status;
- }
-
- MicroSecondDelay (100000);
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-DwHcTransfer (
- IN DWUSB_OTGHC_DEV *DwHc,
- IN EFI_EVENT Timeout,
- IN UINT32 Channel,
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
- IN UINT8 DeviceSpeed,
- IN UINT8 DeviceAddress,
- IN UINTN MaximumPacketLength,
- IN OUT UINT32 *Pid,
- IN UINT32 TransferDirection,
- IN OUT VOID *Data,
- IN OUT UINTN *DataLength,
- IN UINT32 EpAddress,
- IN UINT32 EpType,
- OUT UINT32 *TransferResult,
- IN BOOLEAN IgnoreAck
- )
-{
- UINT32 TxferLen;
- UINT32 Done = 0;
- UINT32 NumPackets;
- UINT32 Sub;
- UINT32 Ret = 0;
- UINT32 StopTransfer = 0;
- EFI_STATUS Status = EFI_SUCCESS;
- SPLIT_CONTROL Split = { 0 };
-
- EFI_TPL Tpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- *TransferResult = EFI_USB_NOERROR;
-
- do {
- RestartXfer:
- if (DeviceSpeed == EFI_USB_SPEED_LOW ||
- DeviceSpeed == EFI_USB_SPEED_FULL) {
- Split.Splitting = TRUE;
- Split.SplitStart = TRUE;
- Split.Tries = 0;
- }
-
- TxferLen = *DataLength - Done;
-
- if (TxferLen > DWC2_MAX_TRANSFER_SIZE) {
- TxferLen = DWC2_MAX_TRANSFER_SIZE - MaximumPacketLength + 1;
- }
-
- if (TxferLen > DWC2_DATA_BUF_SIZE) {
- TxferLen = DWC2_DATA_BUF_SIZE - MaximumPacketLength + 1;
- }
-
- if (Split.Splitting || TxferLen == 0) {
- NumPackets = 1;
- } else {
- NumPackets = (TxferLen + MaximumPacketLength - 1) / MaximumPacketLength;
- if (NumPackets > DWC2_MAX_PACKET_COUNT) {
- NumPackets = DWC2_MAX_PACKET_COUNT;
- TxferLen = NumPackets * MaximumPacketLength;
- }
- }
-
- if (TransferDirection) { // in
- TxferLen = NumPackets * MaximumPacketLength;
- } else {
- CopyMem (DwHc->AlignedBuffer, Data + Done, TxferLen);
- ArmDataSynchronizationBarrier ();
- }
-
- RestartChannel:
- MmioWrite32 (DwHc->DwUsbBase + HCDMA (Channel),
- (UINTN)DwHc->AlignedBufferBusAddress);
-
- DwOtgHcInit (DwHc, Channel, Translator, DeviceSpeed,
- DeviceAddress, EpAddress,
- TransferDirection, EpType,
- MaximumPacketLength, &Split);
-
- MmioWrite32 (DwHc->DwUsbBase + HCTSIZ (Channel),
- (TxferLen << DWC2_HCTSIZ_XFERSIZE_OFFSET) |
- (NumPackets << DWC2_HCTSIZ_PKTCNT_OFFSET) |
- (*Pid << DWC2_HCTSIZ_PID_OFFSET));
-
- MmioAndThenOr32 (DwHc->DwUsbBase + HCCHAR (Channel),
- ~(DWC2_HCCHAR_MULTICNT_MASK |
- DWC2_HCCHAR_CHEN |
- DWC2_HCCHAR_CHDIS),
- ((1 << DWC2_HCCHAR_MULTICNT_OFFSET) |
- DWC2_HCCHAR_CHEN));
-
- Ret = Wait4Chhltd (DwHc, Timeout, Channel, &Sub, Pid, IgnoreAck, &Split);
-
- if (Ret == XFER_NOT_HALTED) {
- *TransferResult = EFI_USB_ERR_TIMEOUT;
- MmioOr32 (DwHc->DwUsbBase + HCCHAR (Channel), DWC2_HCCHAR_CHDIS);
- Status = gBS->SetTimer (Timeout, TimerRelative,
- EFI_TIMER_PERIOD_MILLISECONDS (1));
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- break;
- }
- Status = Wait4Bit (Timeout, DwHc->DwUsbBase + HCINT (Channel),
- DWC2_HCINT_CHHLTD, 1);
- if (Status == EFI_SUCCESS) {
- Status = EFI_TIMEOUT;
- } else {
- DEBUG ((DEBUG_ERROR, "Channel %u did not halt\n", Channel));
- Status = EFI_DEVICE_ERROR;
- }
- break;
- } else if (Ret == XFER_STALL) {
- *TransferResult = EFI_USB_ERR_STALL;
- Status = EFI_DEVICE_ERROR;
- break;
- } else if (Ret == XFER_CSPLIT) {
- ASSERT (Split.Splitting);
-
- if (Split.Tries++ < 3) {
- goto RestartChannel;
- }
-
- goto RestartXfer;
- } else if (Ret == XFER_ERROR) {
- *TransferResult =
- EFI_USB_ERR_CRC |
- EFI_USB_ERR_TIMEOUT |
- EFI_USB_ERR_BITSTUFF |
- EFI_USB_ERR_SYSTEM;
- Status = EFI_DEVICE_ERROR;
- break;
- } else if (Ret == XFER_FRMOVRUN) {
- goto RestartChannel;
- } else if (Ret == XFER_NAK) {
- if (Split.Splitting &&
- (EpType == DWC2_HCCHAR_EPTYPE_CONTROL)) {
- goto RestartXfer;
- }
-
- *TransferResult = EFI_USB_ERR_NAK;
- Status = EFI_DEVICE_ERROR;
- break;
- }
-
- if (TransferDirection) { // in
- ArmDataSynchronizationBarrier ();
- TxferLen -= Sub;
- CopyMem (Data + Done, DwHc->AlignedBuffer, TxferLen);
- if (Sub) {
- StopTransfer = 1;
- }
- }
-
- Done += TxferLen;
- } while (Done < *DataLength && !StopTransfer);
-
- MmioWrite32 (DwHc->DwUsbBase + HCINTMSK (Channel), 0);
- MmioWrite32 (DwHc->DwUsbBase + HCINT (Channel), 0xFFFFFFFF);
-
- *DataLength = Done;
-
- gBS->RestoreTPL (Tpl);
-
- ASSERT (!EFI_ERROR (Status) || *TransferResult != EFI_USB_NOERROR);
-
- return Status;
-}
-
-STATIC
-DWUSB_DEFERRED_REQ *
-DwHcFindDeferredTransfer (
- IN DWUSB_OTGHC_DEV *DwHc,
- IN UINT8 DeviceAddress,
- IN UINT8 EndPointAddress
- )
-{
- LIST_ENTRY *Entry;
-
- EFI_LIST_FOR_EACH (Entry, &DwHc->DeferredList) {
- DWUSB_DEFERRED_REQ *Req = EFI_LIST_CONTAINER (Entry, DWUSB_DEFERRED_REQ, List);
-
- if (Req->DeviceAddress == DeviceAddress &&
- Req->EpAddress == (EndPointAddress & 0xF) &&
- Req->TransferDirection == ((EndPointAddress >> 7) & 0x01)) {
- return Req;
- }
- }
-
- return NULL;
-}
-
-STATIC
-VOID
-DwHcDeferredTransfer (
- IN DWUSB_DEFERRED_REQ *Req
- )
-{
- EFI_STATUS Status;
- EFI_EVENT TimeoutEvt = NULL;
-
- Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimeoutEvt);
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
-
- Status = gBS->SetTimer (TimeoutEvt, TimerForTransfer,
- EFI_TIMER_PERIOD_MILLISECONDS (Req->TimeOut));
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
-
- Req->TransferResult = EFI_USB_NOERROR;
- Status = DwHcTransfer (Req->DwHc, TimeoutEvt,
- Req->Channel, Req->Translator,
- Req->DeviceSpeed, Req->DeviceAddress,
- Req->MaximumPacketLength, &Req->Pid,
- Req->TransferDirection, Req->Data, &Req->DataLength,
- Req->EpAddress, Req->EpType, &Req->TransferResult,
- Req->IgnoreAck);
-
- if (Req->EpType == DWC2_HCCHAR_EPTYPE_INTR &&
- Status == EFI_DEVICE_ERROR &&
- Req->TransferResult == EFI_USB_ERR_NAK) {
- /*
- * Swallow the NAK, the upper layer expects us to resubmit automatically.
- */
- goto Exit;
- }
-
- Req->CallbackFunction (Req->Data, Req->DataLength,
- Req->CallbackContext,
- Req->TransferResult);
-Exit:
- if (TimeoutEvt != NULL) {
- gBS->CloseEvent (TimeoutEvt);
- }
-}
-
-/**
- EFI_USB2_HC_PROTOCOL APIs
-**/
-
-EFI_STATUS
-EFIAPI
-DwHcGetCapability (
- IN EFI_USB2_HC_PROTOCOL *This,
- OUT UINT8 *MaxSpeed,
- OUT UINT8 *PortNumber,
- OUT UINT8 *Is64BitCapable
- )
-{
- if ((MaxSpeed == NULL) || (PortNumber == NULL) || (Is64BitCapable == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- *MaxSpeed = EFI_USB_SPEED_HIGH;
- *PortNumber = 1;
- *Is64BitCapable = 1;
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-DwHcReset (
- IN EFI_USB2_HC_PROTOCOL *This,
- IN UINT16 Attributes
- )
-{
- EFI_STATUS Status;
- EFI_EVENT TimeoutEvt = NULL;
-
- DWUSB_OTGHC_DEV *DwHc;
- DwHc = DWHC_FROM_THIS (This);
-
- Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimeoutEvt);
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
-
- Status = gBS->SetTimer (TimeoutEvt, TimerRelative,
- EFI_TIMER_PERIOD_MILLISECONDS (DW_HC_RESET_TIMEOUT_MS));
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
-
- Status = DwCoreInit (DwHc, TimeoutEvt);
- if (Status != EFI_SUCCESS) {
- DEBUG ((DEBUG_ERROR, "DwCoreInit failed\n"));
- goto Exit;
- }
-
- Status = DwHcInit (DwHc, TimeoutEvt);
- if (Status != EFI_SUCCESS) {
- DEBUG ((DEBUG_ERROR, "DwHcInit failed\n"));
- goto Exit;
- }
-
- MmioAndThenOr32 (DwHc->DwUsbBase + HPRT0,
- ~(DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET |
- DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG),
- DWC2_HPRT0_PRTRST);
-
- MicroSecondDelay (50000);
-
- MmioAnd32 (DwHc->DwUsbBase + HPRT0, ~(DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET |
- DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG |
- DWC2_HPRT0_PRTRST));
-
-Exit:
- if (TimeoutEvt != NULL) {
- gBS->CloseEvent (TimeoutEvt);
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-DwHcGetState (
- IN EFI_USB2_HC_PROTOCOL *This,
- OUT EFI_USB_HC_STATE *State
- )
-{
- DWUSB_OTGHC_DEV *DwHc;
-
- DwHc = DWHC_FROM_THIS (This);
-
- *State = DwHc->DwHcState;
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-DwHcSetState (
- IN EFI_USB2_HC_PROTOCOL *This,
- IN EFI_USB_HC_STATE State
- )
-{
- DWUSB_OTGHC_DEV *DwHc;
-
- DwHc = DWHC_FROM_THIS (This);
-
- DwHc->DwHcState = State;
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-DwHcGetRootHubPortStatus (
- IN EFI_USB2_HC_PROTOCOL *This,
- IN UINT8 PortNumber,
- OUT EFI_USB_PORT_STATUS *PortStatus
- )
-{
- DWUSB_OTGHC_DEV *DwHc;
- UINT32 Hprt0;
-
- if (PortNumber > DWC2_HC_PORT) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (PortStatus == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- DwHc = DWHC_FROM_THIS (This);
-
- PortStatus->PortStatus = 0;
- PortStatus->PortChangeStatus = 0;
- Hprt0 = MmioRead32 (DwHc->DwUsbBase + HPRT0);
-
- if (Hprt0 & DWC2_HPRT0_PRTCONNSTS) {
- PortStatus->PortStatus |= USB_PORT_STAT_CONNECTION;
- }
-
- if (Hprt0 & DWC2_HPRT0_PRTENA) {
- PortStatus->PortStatus |= USB_PORT_STAT_ENABLE;
- }
-
- if (Hprt0 & DWC2_HPRT0_PRTSUSP) {
- PortStatus->PortStatus |= USB_PORT_STAT_SUSPEND;
- }
-
- if (Hprt0 & DWC2_HPRT0_PRTOVRCURRACT) {
- PortStatus->PortStatus |= USB_PORT_STAT_OVERCURRENT;
- }
-
- if (Hprt0 & DWC2_HPRT0_PRTRST) {
- PortStatus->PortStatus |= USB_PORT_STAT_RESET;
- }
-
- if (Hprt0 & DWC2_HPRT0_PRTPWR) {
- PortStatus->PortStatus |= USB_PORT_STAT_POWER;
- }
-
- PortStatus->PortStatus |= USB_PORT_STAT_HIGH_SPEED;
-
- if (Hprt0 & DWC2_HPRT0_PRTENCHNG) {
- // PortStatus->PortChangeStatus |= USB_PORT_STAT_C_ENABLE;
- }
-
- if (Hprt0 & DWC2_HPRT0_PRTCONNDET) {
- PortStatus->PortChangeStatus |= USB_PORT_STAT_C_CONNECTION;
- }
-
- if (Hprt0 & DWC2_HPRT0_PRTOVRCURRCHNG) {
- PortStatus->PortChangeStatus |= USB_PORT_STAT_C_OVERCURRENT;
- }
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-DwHcSetRootHubPortFeature (
- IN EFI_USB2_HC_PROTOCOL *This,
- IN UINT8 PortNumber,
- IN EFI_USB_PORT_FEATURE PortFeature
- )
-{
- DWUSB_OTGHC_DEV *DwHc;
- UINT32 Hprt0;
- EFI_STATUS Status = EFI_SUCCESS;
-
- if (PortNumber > DWC2_HC_PORT) {
- Status = EFI_INVALID_PARAMETER;
- goto Exit;
- }
-
- DwHc = DWHC_FROM_THIS (This);
-
- switch (PortFeature) {
- case EfiUsbPortEnable:
- break;
- case EfiUsbPortSuspend:
- Hprt0 = MmioRead32 (DwHc->DwUsbBase + HPRT0);
- Hprt0 &= ~(DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET |
- DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG);
- Hprt0 |= DWC2_HPRT0_PRTSUSP;
- MmioWrite32 (DwHc->DwUsbBase + HPRT0, Hprt0);
- break;
- case EfiUsbPortReset:
- MmioAndThenOr32 (DwHc->DwUsbBase + HPRT0,
- ~(DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET |
- DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG),
- DWC2_HPRT0_PRTRST);
- MicroSecondDelay (50000);
- MmioAnd32 (DwHc->DwUsbBase + HPRT0, ~DWC2_HPRT0_PRTRST);
- break;
- case EfiUsbPortPower:
- Hprt0 = MmioRead32 (DwHc->DwUsbBase + HPRT0);
- Hprt0 &= ~(DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET |
- DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG);
- Hprt0 |= DWC2_HPRT0_PRTPWR;
- MmioWrite32 (DwHc->DwUsbBase + HPRT0, Hprt0);
- break;
- case EfiUsbPortOwner:
- break;
- default:
- Status = EFI_INVALID_PARAMETER;
- break;
- }
-
-Exit:
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-DwHcClearRootHubPortFeature (
- IN EFI_USB2_HC_PROTOCOL *This,
- IN UINT8 PortNumber,
- IN EFI_USB_PORT_FEATURE PortFeature
- )
-{
- DWUSB_OTGHC_DEV *DwHc;
- UINT32 Hprt0;
- EFI_STATUS Status = EFI_SUCCESS;
-
- if (PortNumber > DWC2_HC_PORT) {
- Status = EFI_INVALID_PARAMETER;
- goto Exit;
- }
-
- DwHc = DWHC_FROM_THIS (This);
-
- switch (PortFeature) {
- case EfiUsbPortEnable:
- Hprt0 = MmioRead32 (DwHc->DwUsbBase + HPRT0);
- Hprt0 &= ~(DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET |
- DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG);
- Hprt0 |= DWC2_HPRT0_PRTENA;
- MmioWrite32 (DwHc->DwUsbBase + HPRT0, Hprt0);
- break;
- case EfiUsbPortReset:
- MmioAndThenOr32 (DwHc->DwUsbBase + HPRT0,
- ~(DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET |
- DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG),
- DWC2_HPRT0_PRTRST);
- MicroSecondDelay (50000);
- MmioAnd32 (DwHc->DwUsbBase + HPRT0, ~DWC2_HPRT0_PRTRST);
- break;
- case EfiUsbPortSuspend:
- MmioWrite32 (DwHc->DwUsbBase + PCGCCTL, 0);
- MicroSecondDelay (40000);
- Hprt0 = MmioRead32 (DwHc->DwUsbBase + HPRT0);
- Hprt0 &= ~(DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET |
- DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG);
- Hprt0 |= DWC2_HPRT0_PRTRES;
- MmioWrite32 (DwHc->DwUsbBase + HPRT0, Hprt0);
- Hprt0 &= ~DWC2_HPRT0_PRTSUSP;
- MicroSecondDelay (150000);
- Hprt0 &= ~DWC2_HPRT0_PRTRES;
- MmioWrite32 (DwHc->DwUsbBase + HPRT0, Hprt0);
- break;
- case EfiUsbPortPower:
- Hprt0 = MmioRead32 (DwHc->DwUsbBase + HPRT0);
- Hprt0 &= ~(DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET |
- DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG);
- Hprt0 &= ~DWC2_HPRT0_PRTPWR;
- MmioWrite32 (DwHc->DwUsbBase + HPRT0, Hprt0);
- break;
- case EfiUsbPortOwner:
- break;
- case EfiUsbPortConnectChange:
- Hprt0 = MmioRead32 (DwHc->DwUsbBase + HPRT0);
- Hprt0 &= ~DWC2_HPRT0_PRTCONNDET;
- MmioWrite32 (DwHc->DwUsbBase + HPRT0, Hprt0);
- break;
- case EfiUsbPortResetChange:
- break;
- case EfiUsbPortEnableChange:
- Hprt0 = MmioRead32 (DwHc->DwUsbBase + HPRT0);
- Hprt0 &= ~DWC2_HPRT0_PRTENCHNG;
- MmioWrite32 (DwHc->DwUsbBase + HPRT0, Hprt0);
- break;
- case EfiUsbPortSuspendChange:
- break;
- case EfiUsbPortOverCurrentChange:
- Hprt0 = MmioRead32 (DwHc->DwUsbBase + HPRT0);
- Hprt0 &= ~DWC2_HPRT0_PRTOVRCURRCHNG;
- MmioWrite32 (DwHc->DwUsbBase + HPRT0, Hprt0);
- break;
- default:
- Status = EFI_INVALID_PARAMETER;
- break;
- }
-
-Exit:
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-DwHcControlTransfer (
- IN EFI_USB2_HC_PROTOCOL *This,
- IN UINT8 DeviceAddress,
- IN UINT8 DeviceSpeed,
- IN UINTN MaximumPacketLength,
- IN EFI_USB_DEVICE_REQUEST *Request,
- IN EFI_USB_DATA_DIRECTION TransferDirection,
- IN OUT VOID *Data,
- IN OUT UINTN *DataLength,
- IN UINTN TimeOut,
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
- OUT UINT32 *TransferResult
- )
-{
- DWUSB_OTGHC_DEV *DwHc;
- EFI_STATUS Status;
- UINT32 Pid;
- UINTN Length;
- EFI_USB_DATA_DIRECTION StatusDirection;
- UINT32 Direction;
- EFI_EVENT TimeoutEvt = NULL;
-
- if ((Request == NULL) || (TransferResult == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((TransferDirection != EfiUsbDataIn) &&
- (TransferDirection != EfiUsbDataOut) &&
- (TransferDirection != EfiUsbNoData)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((TransferDirection == EfiUsbNoData) &&
- ((Data != NULL) || (*DataLength != 0))) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((TransferDirection != EfiUsbNoData) &&
- ((Data == NULL) || (*DataLength == 0))) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((MaximumPacketLength != 8) && (MaximumPacketLength != 16) &&
- (MaximumPacketLength != 32) && (MaximumPacketLength != 64)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((DeviceSpeed == EFI_USB_SPEED_LOW) && (MaximumPacketLength != 8)) {
- return EFI_INVALID_PARAMETER;
- }
-
- DwHc = DWHC_FROM_THIS (This);
-
- Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimeoutEvt);
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
-
- Status = gBS->SetTimer (TimeoutEvt, TimerForTransfer,
- EFI_TIMER_PERIOD_MILLISECONDS (TimeOut));
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
-
- Pid = DWC2_HC_PID_SETUP;
- Length = 8;
- Status = DwHcTransfer (DwHc, TimeoutEvt,
- DWC2_HC_CHANNEL, Translator, DeviceSpeed,
- DeviceAddress, MaximumPacketLength, &Pid, 0,
- Request, &Length, 0, DWC2_HCCHAR_EPTYPE_CONTROL,
- TransferResult, 1);
-
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Setup Stage Error for device 0x%x: 0x%x\n",
- DeviceAddress, *TransferResult));
- goto Exit;
- }
-
- if (Data) {
- Pid = DWC2_HC_PID_DATA1;
-
- if (TransferDirection == EfiUsbDataIn) {
- Direction = 1;
- } else {
- Direction = 0;
- }
-
- Status = DwHcTransfer (DwHc, TimeoutEvt,
- DWC2_HC_CHANNEL, Translator, DeviceSpeed,
- DeviceAddress, MaximumPacketLength, &Pid,
- Direction, Data, DataLength, 0,
- DWC2_HCCHAR_EPTYPE_CONTROL,
- TransferResult, 0);
-
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Data Stage Error for device 0x%x: 0x%x\n",
- DeviceAddress, *TransferResult));
- goto Exit;
- }
- }
-
- if ((TransferDirection == EfiUsbDataOut) ||
- (TransferDirection == EfiUsbNoData)) {
- StatusDirection = 1;
- } else {
- StatusDirection = 0;
- }
-
- Pid = DWC2_HC_PID_DATA1;
- Length = 0;
- Status = DwHcTransfer (DwHc, TimeoutEvt,
- DWC2_HC_CHANNEL, Translator, DeviceSpeed,
- DeviceAddress, MaximumPacketLength, &Pid,
- StatusDirection, DwHc->StatusBuffer, &Length, 0,
- DWC2_HCCHAR_EPTYPE_CONTROL, TransferResult, 1);
-
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Status Stage Error for 0x%x: 0x%x\n",
- DeviceAddress, *TransferResult));
- goto Exit;
- }
-
-Exit:
- if (TimeoutEvt != NULL) {
- gBS->CloseEvent (TimeoutEvt);
- }
-
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "RequestType 0x%x\n", Request->RequestType));
- DEBUG ((DEBUG_ERROR, "Request 0x%x\n", Request->Request));
- DEBUG ((DEBUG_ERROR, "Value 0x%x\n", Request->Value));
- DEBUG ((DEBUG_ERROR, "Index 0x%x\n", Request->Index));
- DEBUG ((DEBUG_ERROR, "Length 0x%x\n", Request->Length));
- }
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-DwHcBulkTransfer (
- IN EFI_USB2_HC_PROTOCOL *This,
- IN UINT8 DeviceAddress,
- IN UINT8 EndPointAddress,
- IN UINT8 DeviceSpeed,
- IN UINTN MaximumPacketLength,
- IN UINT8 DataBuffersNumber,
- IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM],
- IN OUT UINTN *DataLength,
- IN OUT UINT8 *DataToggle,
- IN UINTN TimeOut,
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
- OUT UINT32 *TransferResult
- )
-{
- DWUSB_OTGHC_DEV *DwHc;
- EFI_STATUS Status;
- UINT8 TransferDirection;
- UINT8 EpAddress;
- UINT32 Pid;
- EFI_EVENT TimeoutEvt = NULL;
-
- if ((Data == NULL) || (Data[0] == NULL) ||
- (DataLength == NULL) || (*DataLength == 0) ||
- (TransferResult == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((*DataToggle != 0) && (*DataToggle != 1)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((DeviceSpeed == EFI_USB_SPEED_LOW) ||
- (DeviceSpeed == EFI_USB_SPEED_SUPER)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (((DeviceSpeed == EFI_USB_SPEED_FULL) && (MaximumPacketLength > 64)) ||
- ((DeviceSpeed == EFI_USB_SPEED_HIGH) && (MaximumPacketLength > 512)))
- return EFI_INVALID_PARAMETER;
-
- DwHc = DWHC_FROM_THIS (This);
-
- Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimeoutEvt);
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
-
- Status = gBS->SetTimer (TimeoutEvt, TimerForTransfer,
- EFI_TIMER_PERIOD_MILLISECONDS (TimeOut));
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
-
- Status = EFI_DEVICE_ERROR;
- TransferDirection = (EndPointAddress >> 7) & 0x01;
- EpAddress = EndPointAddress & 0x0F;
- Pid = (*DataToggle << 1);
-
- Status = DwHcTransfer (DwHc, TimeoutEvt,
- DWC2_HC_CHANNEL_BULK, Translator, DeviceSpeed,
- DeviceAddress, MaximumPacketLength, &Pid,
- TransferDirection, Data[0], DataLength, EpAddress,
- DWC2_HCCHAR_EPTYPE_BULK, TransferResult, 1);
-
- *DataToggle = (Pid >> 1);
-
-Exit:
- if (TimeoutEvt != NULL) {
- gBS->CloseEvent (TimeoutEvt);
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-DwHcAsyncInterruptTransfer (
- IN EFI_USB2_HC_PROTOCOL *This,
- IN UINT8 DeviceAddress,
- IN UINT8 EndPointAddress,
- IN UINT8 DeviceSpeed,
- IN UINTN MaximumPacketLength,
- IN BOOLEAN IsNewTransfer,
- IN OUT UINT8 *DataToggle,
- IN UINTN PollingInterval,
- IN UINTN DataLength,
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
- IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallbackFunction,
- IN VOID *Context OPTIONAL
- )
-{
- DWUSB_OTGHC_DEV *DwHc;
- EFI_STATUS Status;
- EFI_TPL PreviousTpl;
- VOID *Data = NULL;
- DWUSB_DEFERRED_REQ *FoundReq = NULL;
- DWUSB_DEFERRED_REQ *NewReq = NULL;
-
- if (!(EndPointAddress & USB_ENDPOINT_DIR_IN)) {
- return EFI_INVALID_PARAMETER;
- }
-
- DwHc = DWHC_FROM_THIS (This);
-
- PreviousTpl = gBS->RaiseTPL (TPL_NOTIFY);
- FoundReq = DwHcFindDeferredTransfer (DwHc, DeviceAddress, EndPointAddress);
-
- if (IsNewTransfer) {
- if (FoundReq != NULL) {
- Status = EFI_INVALID_PARAMETER;
- goto Done;
- }
-
- if (DataLength == 0) {
- Status = EFI_INVALID_PARAMETER;
- goto Done;
- }
-
- if ((*DataToggle != 1) && (*DataToggle != 0)) {
- Status = EFI_INVALID_PARAMETER;
- goto Done;
- }
-
- if ((PollingInterval > 255) || (PollingInterval < 1)) {
- Status = EFI_INVALID_PARAMETER;
- goto Done;
- }
-
- if (CallbackFunction == NULL) {
- Status = EFI_INVALID_PARAMETER;
- goto Done;
- }
- }
-
- if (!IsNewTransfer) {
- if (FoundReq == NULL) {
- DEBUG ((DEBUG_ERROR, "%u:%u> transfer not found\n", DeviceAddress, EndPointAddress & 0xF));
- Status = EFI_INVALID_PARAMETER;
- goto Done;
- }
-
- *DataToggle = FoundReq->Pid >> 1;
- FreePool (FoundReq->Data);
-
- RemoveEntryList (&FoundReq->List);
- FreePool (FoundReq);
-
- Status = EFI_SUCCESS;
- goto Done;
- }
-
- NewReq = AllocateZeroPool (sizeof *NewReq);
- if (NewReq == NULL) {
- DEBUG ((DEBUG_ERROR, "DwHcAsyncInterruptTransfer: failed to allocate req"));
- Status = EFI_OUT_OF_RESOURCES;
- goto Done;
- }
-
- Data = AllocateZeroPool (DataLength);
- if (Data == NULL) {
- DEBUG ((DEBUG_ERROR, "DwHcAsyncInterruptTransfer: failed to allocate buffer\n"));
- Status = EFI_OUT_OF_RESOURCES;
- goto Done;
- }
-
- InitializeListHead (&NewReq->List);
-
- NewReq->FrameInterval = PollingInterval;
- NewReq->TargetFrame = DwHc->CurrentFrame +
- NewReq->FrameInterval;
-
- NewReq->DwHc = DwHc;
- NewReq->Channel = DWC2_HC_CHANNEL_ASYNC;
- NewReq->Translator = Translator;
- NewReq->DeviceSpeed = DeviceSpeed;
- NewReq->DeviceAddress = DeviceAddress;
- NewReq->MaximumPacketLength = MaximumPacketLength;
- NewReq->TransferDirection = (EndPointAddress >> 7) & 0x01;
- NewReq->Data = Data;
- NewReq->DataLength = DataLength;
- NewReq->Pid = *DataToggle << 1;
- NewReq->EpAddress = EndPointAddress & 0x0F;
- NewReq->EpType = DWC2_HCCHAR_EPTYPE_INTR;
- NewReq->IgnoreAck = FALSE;
- NewReq->CallbackFunction = CallbackFunction;
- NewReq->CallbackContext = Context;
- NewReq->TimeOut = 1000; /* 1000 ms */
-
- InsertTailList (&DwHc->DeferredList, &NewReq->List);
- Status = EFI_SUCCESS;
-
-Done:
- gBS->RestoreTPL (PreviousTpl);
-
- if (Status != EFI_SUCCESS) {
- if (Data != NULL) {
- FreePool (Data);
- }
-
- if (NewReq != NULL) {
- FreePool (NewReq);
- }
- }
-
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-DwHcSyncInterruptTransfer (
- IN EFI_USB2_HC_PROTOCOL *This,
- IN UINT8 DeviceAddress,
- IN UINT8 EndPointAddress,
- IN UINT8 DeviceSpeed,
- IN UINTN MaximumPacketLength,
- IN OUT VOID *Data,
- IN OUT UINTN *DataLength,
- IN OUT UINT8 *DataToggle,
- IN UINTN TimeOut,
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
- OUT UINT32 *TransferResult
- )
-{
- DWUSB_OTGHC_DEV *DwHc;
- EFI_STATUS Status;
- EFI_EVENT TimeoutEvt;
- UINT8 TransferDirection;
- UINT8 EpAddress;
- UINT32 Pid;
-
- DwHc = DWHC_FROM_THIS (This);
-
- if (Data == NULL ||
- DataLength == NULL ||
- DataToggle == NULL ||
- TransferResult == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (*DataLength == 0) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((*DataToggle != 0) && (*DataToggle != 1)) {
- return EFI_INVALID_PARAMETER;
- }
-
- Status = gBS->CreateEvent (EVT_TIMER, 0, NULL, NULL, &TimeoutEvt);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = gBS->SetTimer (TimeoutEvt, TimerForTransfer,
- EFI_TIMER_PERIOD_MILLISECONDS (TimeOut));
- if (EFI_ERROR (Status)) {
- goto Exit;
- }
-
- TransferDirection = (EndPointAddress >> 7) & 0x01;
- EpAddress = EndPointAddress & 0x0F;
- Pid = (*DataToggle << 1);
- Status = DwHcTransfer (DwHc, TimeoutEvt,
- DWC2_HC_CHANNEL_SYNC, Translator,
- DeviceSpeed, DeviceAddress,
- MaximumPacketLength,
- &Pid, TransferDirection, Data,
- DataLength, EpAddress,
- DWC2_HCCHAR_EPTYPE_INTR,
- TransferResult, 0);
- *DataToggle = (Pid >> 1);
-
-Exit:
- if (TimeoutEvt != NULL) {
- gBS->CloseEvent (TimeoutEvt);
- }
- return Status;
-}
-
-EFI_STATUS
-EFIAPI
-DwHcIsochronousTransfer (
- IN EFI_USB2_HC_PROTOCOL *This,
- IN UINT8 DeviceAddress,
- IN UINT8 EndPointAddress,
- IN UINT8 DeviceSpeed,
- IN UINTN MaximumPacketLength,
- IN UINT8 DataBuffersNumber,
- IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
- IN UINTN DataLength,
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
- OUT UINT32 *TransferResult
- )
-{
- DEBUG ((DEBUG_ERROR, "Iso\n"));
- return EFI_UNSUPPORTED;
-}
-
-EFI_STATUS
-EFIAPI
-DwHcAsyncIsochronousTransfer (
- IN EFI_USB2_HC_PROTOCOL *This,
- IN UINT8 DeviceAddress,
- IN UINT8 EndPointAddress,
- IN UINT8 DeviceSpeed,
- IN UINTN MaximumPacketLength,
- IN UINT8 DataBuffersNumber,
- IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
- IN UINTN DataLength,
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
- IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack,
- IN VOID *Context
- )
-{
- DEBUG ((DEBUG_ERROR, "AsyncIso\n"));
- return EFI_UNSUPPORTED;
-}
-
-/**
- Supported Functions
-**/
-
-VOID
-InitFslspClkSel (
- IN DWUSB_OTGHC_DEV *DwHc
- )
-{
- UINT32 PhyClk;
-
- PhyClk = DWC2_HCFG_FSLSPCLKSEL_30_60_MHZ;
-
- MmioAndThenOr32 (DwHc->DwUsbBase + HCFG,
- ~DWC2_HCFG_FSLSPCLKSEL_MASK,
- PhyClk << DWC2_HCFG_FSLSPCLKSEL_OFFSET);
-}
-
-VOID
-DwFlushTxFifo (
- IN DWUSB_OTGHC_DEV *DwHc,
- IN EFI_EVENT Timeout,
- IN INT32 Num
- )
-{
- EFI_STATUS Status;
-
- MmioWrite32 (DwHc->DwUsbBase + GRSTCTL, DWC2_GRSTCTL_TXFFLSH |
- (Num << DWC2_GRSTCTL_TXFNUM_OFFSET));
-
- Status = Wait4Bit (Timeout, DwHc->DwUsbBase + GRSTCTL, DWC2_GRSTCTL_TXFFLSH, 0);
- if (Status)
- DEBUG ((DEBUG_ERROR, "DwFlushTxFifo: Timeout!\n"));
-
- MicroSecondDelay (1);
-}
-
-VOID
-DwFlushRxFifo (
- IN DWUSB_OTGHC_DEV *DwHc,
- IN EFI_EVENT Timeout
- )
-{
- EFI_STATUS Status;
-
- MmioWrite32 (DwHc->DwUsbBase + GRSTCTL, DWC2_GRSTCTL_RXFFLSH);
-
- Status = Wait4Bit (Timeout, DwHc->DwUsbBase + GRSTCTL, DWC2_GRSTCTL_RXFFLSH, 0);
- if (Status)
- DEBUG ((DEBUG_ERROR, "DwFlushRxFifo: Timeout!\n"));
-
- MicroSecondDelay (1);
-}
-
-EFI_STATUS
-DwHcInit (
- IN DWUSB_OTGHC_DEV *DwHc,
- IN EFI_EVENT Timeout
- )
-{
- UINT32 NpTxFifoSz = 0;
- UINT32 pTxFifoSz = 0;
- UINT32 Hprt0 = 0;
- INT32 i, Status, NumChannels;
-
- MmioWrite32 (DwHc->DwUsbBase + PCGCCTL, 0);
-
- InitFslspClkSel (DwHc);
-
- MmioWrite32 (DwHc->DwUsbBase + GRXFSIZ, DWC2_HOST_RX_FIFO_SIZE);
-
- NpTxFifoSz |= DWC2_HOST_NPERIO_TX_FIFO_SIZE << DWC2_FIFOSIZE_DEPTH_OFFSET;
- NpTxFifoSz |= DWC2_HOST_RX_FIFO_SIZE << DWC2_FIFOSIZE_STARTADDR_OFFSET;
- MmioWrite32 (DwHc->DwUsbBase + GNPTXFSIZ, NpTxFifoSz);
-
- pTxFifoSz |= DWC2_HOST_PERIO_TX_FIFO_SIZE << DWC2_FIFOSIZE_DEPTH_OFFSET;
- pTxFifoSz |= (DWC2_HOST_RX_FIFO_SIZE + DWC2_HOST_NPERIO_TX_FIFO_SIZE) <<
- DWC2_FIFOSIZE_STARTADDR_OFFSET;
- MmioWrite32 (DwHc->DwUsbBase + HPTXFSIZ, pTxFifoSz);
-
- MmioAnd32 (DwHc->DwUsbBase + GOTGCTL, ~(DWC2_GOTGCTL_HSTSETHNPEN));
-
- DwFlushTxFifo (DwHc, Timeout, 0x10);
- DwFlushRxFifo (DwHc, Timeout);
-
- NumChannels = MmioRead32 (DwHc->DwUsbBase + GHWCFG2);
- NumChannels &= DWC2_HWCFG2_NUM_HOST_CHAN_MASK;
- NumChannels >>= DWC2_HWCFG2_NUM_HOST_CHAN_OFFSET;
- NumChannels += 1;
- DEBUG ((DEBUG_INFO, "Host has %u channels\n", NumChannels));
-
- for (i = 0; i < NumChannels; i++)
- MmioAndThenOr32 (DwHc->DwUsbBase + HCCHAR (i),
- ~(DWC2_HCCHAR_CHEN | DWC2_HCCHAR_EPDIR),
- DWC2_HCCHAR_CHDIS);
-
- for (i = 0; i < NumChannels; i++) {
- MmioAndThenOr32 (DwHc->DwUsbBase + HCCHAR (i),
- ~DWC2_HCCHAR_EPDIR,
- (DWC2_HCCHAR_CHEN | DWC2_HCCHAR_CHDIS));
- Status = Wait4Bit (Timeout, DwHc->DwUsbBase + HCCHAR (i), DWC2_HCCHAR_CHEN, 0);
- if (Status) {
- DEBUG ((DEBUG_ERROR, "DwHcInit: Timeout!\n"));
- return Status;
- }
- }
-
- if (MmioRead32 (DwHc->DwUsbBase + GINTSTS) & DWC2_GINTSTS_CURMODE_HOST) {
- Hprt0 = MmioRead32 (DwHc->DwUsbBase + HPRT0);
- Hprt0 &= ~(DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET);
- Hprt0 &= ~(DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG);
-
- if (!(Hprt0 & DWC2_HPRT0_PRTPWR)) {
- Hprt0 |= DWC2_HPRT0_PRTPWR;
- MmioWrite32 (DwHc->DwUsbBase + HPRT0, Hprt0);
- }
- }
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-DwCoreInit (
- IN DWUSB_OTGHC_DEV *DwHc,
- IN EFI_EVENT Timeout
- )
-{
- UINT32 AhbCfg = 0;
- UINT32 UsbCfg = 0;
- EFI_STATUS Status;
-
- UsbCfg = MmioRead32 (DwHc->DwUsbBase + GUSBCFG);
-
- UsbCfg |= DWC2_GUSBCFG_ULPI_EXT_VBUS_DRV;
- UsbCfg &= ~DWC2_GUSBCFG_TERM_SEL_DL_PULSE;
-
- MmioWrite32 (DwHc->DwUsbBase + GUSBCFG, UsbCfg);
-
- Status = DwCoreReset (DwHc, Timeout);
- if (Status != EFI_SUCCESS) {
- DEBUG ((DEBUG_ERROR, "DwCoreReset failed\n"));
- return Status;
- }
-
- UsbCfg &= ~(DWC2_GUSBCFG_ULPI_UTMI_SEL | DWC2_GUSBCFG_PHYIF);
- UsbCfg |= CONFIG_DWC2_PHY_TYPE << DWC2_GUSBCFG_ULPI_UTMI_SEL_OFFSET;
- UsbCfg &= ~DWC2_GUSBCFG_DDRSEL;
-
- MmioWrite32 (DwHc->DwUsbBase + GUSBCFG, UsbCfg);
-
- Status = DwCoreReset (DwHc, Timeout);
- if (Status != EFI_SUCCESS) {
- DEBUG ((DEBUG_ERROR, "DwCoreReset 2 failed\n"));
- return Status;
- }
-
- UsbCfg = MmioRead32 (DwHc->DwUsbBase + GUSBCFG);
-
- UsbCfg &= ~(DWC2_GUSBCFG_ULPI_FSLS | DWC2_GUSBCFG_ULPI_CLK_SUS_M);
- MmioWrite32 (DwHc->DwUsbBase + GUSBCFG, UsbCfg);
-
- AhbCfg &= ~DWC2_GAHBCFG_AXI_BURST4_MASK;
- AhbCfg |= DWC2_GAHBCFG_DMAENABLE | DWC2_GAHBCFG_WAIT_AXI_WRITES;
-
- MmioWrite32 (DwHc->DwUsbBase + GAHBCFG, AhbCfg);
- MmioAnd32 (DwHc->DwUsbBase + GUSBCFG, ~(DWC2_GUSBCFG_HNPCAP | DWC2_GUSBCFG_SRPCAP));
-
- return EFI_SUCCESS;
-}
-
-VOID
-DestroyDwUsbHc (
- IN DWUSB_OTGHC_DEV *DwHc
- )
-{
- UINT32 Pages;
- EFI_TPL PreviousTpl;
-
- if (DwHc == NULL) {
- return;
- }
-
- if (DwHc->PeriodicEvent != NULL) {
- PreviousTpl = gBS->RaiseTPL (TPL_NOTIFY);
- gBS->CloseEvent (DwHc->PeriodicEvent);
- gBS->RestoreTPL (PreviousTpl);
- }
-
- if (DwHc->ExitBootServiceEvent != NULL) {
- gBS->CloseEvent (DwHc->ExitBootServiceEvent);
- }
-
- Pages = EFI_SIZE_TO_PAGES (DWC2_DATA_BUF_SIZE);
- DmaUnmap (DwHc->AlignedBufferMapping);
- DmaFreeBuffer (Pages, DwHc->AlignedBuffer);
-
- Pages = EFI_SIZE_TO_PAGES (DWC2_STATUS_BUF_SIZE);
- FreePages (DwHc->StatusBuffer, Pages);
-
- gBS->FreePool (DwHc);
-}
-
-STATIC
-VOID
-EFIAPI
-DwUsbHcExitBootService (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- DWUSB_OTGHC_DEV *DwHc;
-
- DwHc = (DWUSB_OTGHC_DEV*)Context;
- DwHcQuiesce (DwHc);
-}
-
-STATIC
-UINT32
-FramesPassed (
- IN DWUSB_OTGHC_DEV *DwHc
- )
-{
- UINT32 MicroFrameStart = DwHc->LastMicroFrame;
- UINT32 MicroFrameEnd =
- MmioRead32 (DwHc->DwUsbBase + HFNUM) &
- DWC2_HFNUM_FRNUM_MASK;
- UINT32 MicroFramesPassed;
-
- DwHc->LastMicroFrame = (UINT16)MicroFrameEnd;
-
- if (MicroFrameEnd < MicroFrameStart) {
- /*
- * Being delayed by 0x8000 microframes is 262 seconds.
- * Unlikely. Also, we can't really do better unless we
- * start polling time (which is tedious in EFI...).
- */
- MicroFrameEnd += DWC2_HFNUM_FRNUM_MASK + 1;
- }
-
- MicroFramesPassed = MicroFrameEnd - MicroFrameStart;
-
- /*
- * Round up. We're supposedly getting called every
- * 8 microframes anyway. This means we'll end up
- * going a bit faster, which is okay.
- */
- return ALIGN_VALUE (MicroFramesPassed, 8) / 8;
-}
-
-STATIC
-VOID
-DwHcPeriodicHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- UINT32 Frame;
- LIST_ENTRY *Entry;
- LIST_ENTRY *NextEntry;
- DWUSB_OTGHC_DEV *DwHc = Context;
-
- DwHc->CurrentFrame += FramesPassed (DwHc);
- Frame = DwHc->CurrentFrame;
-
- EFI_LIST_FOR_EACH_SAFE (Entry, NextEntry,
- &DwHc->DeferredList) {
- DWUSB_DEFERRED_REQ *Req = EFI_LIST_CONTAINER (Entry, DWUSB_DEFERRED_REQ, List);
-
- if (Frame >= Req->TargetFrame) {
- Req->TargetFrame = Frame + Req->FrameInterval;
- DwHcDeferredTransfer (Req);
- }
- }
-}
-
-EFI_STATUS
-CreateDwUsbHc (
- OUT DWUSB_OTGHC_DEV **OutDwHc
- )
-{
- DWUSB_OTGHC_DEV *DwHc;
- UINT32 Pages;
- UINTN BufferSize;
- EFI_STATUS Status;
-
- DwHc = AllocateZeroPool (sizeof (DWUSB_OTGHC_DEV));
- if (DwHc == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- DwHc->Signature = DWUSB_OTGHC_DEV_SIGNATURE;
- DwHc->DwUsbOtgHc.GetCapability = DwHcGetCapability;
- DwHc->DwUsbOtgHc.Reset = DwHcReset;
- DwHc->DwUsbOtgHc.GetState = DwHcGetState;
- DwHc->DwUsbOtgHc.SetState = DwHcSetState;
- DwHc->DwUsbOtgHc.ControlTransfer = DwHcControlTransfer;
- DwHc->DwUsbOtgHc.BulkTransfer = DwHcBulkTransfer;
- DwHc->DwUsbOtgHc.AsyncInterruptTransfer = DwHcAsyncInterruptTransfer;
- DwHc->DwUsbOtgHc.SyncInterruptTransfer = DwHcSyncInterruptTransfer;
- DwHc->DwUsbOtgHc.IsochronousTransfer = DwHcIsochronousTransfer;
- DwHc->DwUsbOtgHc.AsyncIsochronousTransfer = DwHcAsyncIsochronousTransfer;
- DwHc->DwUsbOtgHc.GetRootHubPortStatus = DwHcGetRootHubPortStatus;
- DwHc->DwUsbOtgHc.SetRootHubPortFeature = DwHcSetRootHubPortFeature;
- DwHc->DwUsbOtgHc.ClearRootHubPortFeature = DwHcClearRootHubPortFeature;
- DwHc->DwUsbOtgHc.MajorRevision = 0x02;
- DwHc->DwUsbOtgHc.MinorRevision = 0x00;
- DwHc->DwUsbBase = DW2_USB_BASE_ADDRESS;
-
- Pages = EFI_SIZE_TO_PAGES (DWC2_STATUS_BUF_SIZE);
- DwHc->StatusBuffer = AllocatePages (Pages);
- if (DwHc->StatusBuffer == NULL) {
- DEBUG ((DEBUG_ERROR, "CreateDwUsbHc: No pages available for StatusBuffer\n"));
- return EFI_OUT_OF_RESOURCES;
- }
-
- Pages = EFI_SIZE_TO_PAGES (DWC2_DATA_BUF_SIZE);
- Status = DmaAllocateBuffer (EfiBootServicesData, Pages, (VOID**)&DwHc->AlignedBuffer);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "CreateDwUsbHc: DmaAllocateBuffer: %r\n", Status));
- return Status;
- }
-
- BufferSize = EFI_PAGES_TO_SIZE (Pages);
- Status = DmaMap (MapOperationBusMasterCommonBuffer, DwHc->AlignedBuffer, &BufferSize,
- &DwHc->AlignedBufferBusAddress, &DwHc->AlignedBufferMapping);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "CreateDwUsbHc: DmaMap: %r\n", Status));
- return Status;
- }
-
- InitializeListHead (&DwHc->DeferredList);
-
- Status = gBS->CreateEventEx (
- EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- DwUsbHcExitBootService,
- DwHc,
- &gEfiEventExitBootServicesGuid,
- &DwHc->ExitBootServiceEvent
- );
-
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "CreateDwUsbHc: DwUsbHcExitBootService: %r\n", Status));
- return Status;
- }
-
- Status = gBS->CreateEvent (
- EVT_TIMER | EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- DwHcPeriodicHandler,
- DwHc, &DwHc->PeriodicEvent
- );
- if (Status != EFI_SUCCESS) {
- DEBUG ((DEBUG_ERROR, "CreateDwUsbHc: DwHcPeriodicHandler: %r\n", Status));
- return Status;
- }
-
- Status = gBS->SetTimer (DwHc->PeriodicEvent, TimerPeriodic,
- EFI_TIMER_PERIOD_MILLISECONDS (1));
- if (Status != EFI_SUCCESS) {
- DEBUG ((DEBUG_ERROR, "CreateDwUsbHc: PeriodicEvent: %r\n", Status));
- return Status;
- }
-
- *OutDwHc = DwHc;
- return EFI_SUCCESS;
-}
-
-VOID
-DwHcQuiesce (
- IN DWUSB_OTGHC_DEV *DwHc
- )
-{
- if (DwHc->PeriodicEvent != NULL) {
- EFI_TPL PreviousTpl;
- PreviousTpl = gBS->RaiseTPL (TPL_NOTIFY);
- gBS->CloseEvent (DwHc->PeriodicEvent);
- DwHc->PeriodicEvent = NULL;
- gBS->RestoreTPL (PreviousTpl);
- }
-
- MmioAndThenOr32 (DwHc->DwUsbBase + HPRT0,
- ~(DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET |
- DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG),
- DWC2_HPRT0_PRTRST);
-
- MicroSecondDelay (50000);
-
- MmioWrite32 (DwHc->DwUsbBase + GRSTCTL, DWC2_GRSTCTL_CSFTRST);
- MicroSecondDelay (100000);
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.h b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.h
deleted file mode 100644
index 106e5425..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.h
+++ /dev/null
@@ -1,156 +0,0 @@
-/** @file
- *
- * Copyright (c) 2017-2018, Andrey Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2015-2016, Linaro Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#ifndef __DWUSBHOSTDXE_H__
-#define __DWUSBHOSTDXE_H__
-
-#include <Uefi.h>
-
-#include <IndustryStandard/Bcm2836.h>
-#include <IndustryStandard/RpiMbox.h>
-#include <Protocol/Usb2HostController.h>
-#include <Protocol/RpiFirmware.h>
-
-#include <Guid/EventGroup.h>
-
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-#include <Library/BaseLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
-#include <Library/ReportStatusCodeLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/PcdLib.h>
-#include <Library/IoLib.h>
-#include <Library/TimerLib.h>
-#include <Library/DmaLib.h>
-#include <Library/ArmLib.h>
-
-#define MAX_DEVICE 16
-#define MAX_ENDPOINT 16
-
-#define DWUSB_OTGHC_DEV_SIGNATURE SIGNATURE_32 ('d', 'w', 'h', 'c')
-#define DWHC_FROM_THIS(a) CR(a, DWUSB_OTGHC_DEV, DwUsbOtgHc, DWUSB_OTGHC_DEV_SIGNATURE)
-
-//
-// Iterate through the double linked list. NOT delete safe
-//
-#define EFI_LIST_FOR_EACH(Entry, ListHead) \
- for(Entry = (ListHead)->ForwardLink; Entry != (ListHead); Entry = Entry->ForwardLink)
-
-//
-// Iterate through the double linked list. This is delete-safe.
-// Do not touch NextEntry
-//
-#define EFI_LIST_FOR_EACH_SAFE(Entry, NextEntry, ListHead) \
- for(Entry = (ListHead)->ForwardLink, NextEntry = Entry->ForwardLink;\
- Entry != (ListHead); Entry = NextEntry, NextEntry = Entry->ForwardLink)
-
-#define EFI_LIST_CONTAINER(Entry, Type, Field) BASE_CR(Entry, Type, Field)
-
-//
-// The RequestType in EFI_USB_DEVICE_REQUEST is composed of
-// three fields: One bit direction, 2 bit type, and 5 bit
-// target.
-//
-#define USB_REQUEST_TYPE(Dir, Type, Target) \
- ((UINT8)((((Dir) == EfiUsbDataIn ? 0x01 : 0) << 7) | (Type) | (Target)))
-
-typedef struct {
- VENDOR_DEVICE_PATH Custom;
- EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
-} EFI_DW_DEVICE_PATH;
-
-typedef struct _DWUSB_DEFERRED_REQ {
- IN OUT LIST_ENTRY List;
- IN struct _DWUSB_OTGHC_DEV *DwHc;
- IN UINT32 Channel;
- IN UINT32 FrameInterval;
- IN UINT32 TargetFrame;
- IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator;
- IN UINT8 DeviceSpeed;
- IN UINT8 DeviceAddress;
- IN UINTN MaximumPacketLength;
- IN UINT32 TransferDirection;
- IN OUT VOID *Data;
- IN OUT UINTN DataLength;
- IN OUT UINT32 Pid;
- IN UINT32 EpAddress;
- IN UINT32 EpType;
- OUT UINT32 TransferResult;
- IN BOOLEAN IgnoreAck;
- IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallbackFunction;
- IN VOID *CallbackContext;
- IN UINTN TimeOut;
-} DWUSB_DEFERRED_REQ;
-
-typedef struct _DWUSB_OTGHC_DEV {
- UINTN Signature;
-
- EFI_USB2_HC_PROTOCOL DwUsbOtgHc;
-
- EFI_USB_HC_STATE DwHcState;
-
- EFI_EVENT ExitBootServiceEvent;
-
- EFI_EVENT PeriodicEvent;
-
- EFI_PHYSICAL_ADDRESS DwUsbBase;
- UINT8 *StatusBuffer;
-
- UINT8 *AlignedBuffer;
- VOID * AlignedBufferMapping;
- UINTN AlignedBufferBusAddress;
- LIST_ENTRY DeferredList;
- /*
- * 1ms frames.
- */
- UINTN CurrentFrame;
- /*
- * 125us frames;
- */
- UINT16 LastMicroFrame;
-} DWUSB_OTGHC_DEV;
-
-extern EFI_COMPONENT_NAME_PROTOCOL gComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gComponentName2;
-
-EFI_STATUS
-CreateDwUsbHc (
- OUT DWUSB_OTGHC_DEV **OutDwHc
- );
-
-VOID
-DestroyDwUsbHc (
- IN DWUSB_OTGHC_DEV *Dev
- );
-
-EFI_STATUS
-EFIAPI
-DwHcReset (
- IN EFI_USB2_HC_PROTOCOL *This,
- IN UINT16 Attributes
- );
-
-EFI_STATUS
-EFIAPI
-DwHcSetState (
- IN EFI_USB2_HC_PROTOCOL *This,
- IN EFI_USB_HC_STATE State
- );
-
-VOID
-DwHcQuiesce (
- IN DWUSB_OTGHC_DEV *DwHc
- );
-
-#endif /* __DWUSBHOSTDXE_H__ */
diff --git a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf
deleted file mode 100644
index f86480c0..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf
+++ /dev/null
@@ -1,55 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2017-2018, Andrei Warkentin <andrey.warkentin@gmail.com>
-# Copyright (c) 2015-2016, Linaro Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x0001001A
- BASE_NAME = DwUsbHostDxe
- FILE_GUID = 4bf1704c-03f4-46d5-bca6-82fa580badfd
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = DwUsbHostEntryPoint
-
-[Sources.common]
- DwcHw.h
- DwUsbHostDxe.h
- DwUsbHostDxe.c
- DriverBinding.c
- ComponentName.c
-
-[Packages]
- ArmPkg/ArmPkg.dec
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- MdeModulePkg/MdeModulePkg.dec
- Silicon/Broadcom/Bcm283x/Bcm283x.dec
- Platform/RaspberryPi/RPi3/RPi3.dec
-
-[LibraryClasses]
- MemoryAllocationLib
- BaseLib
- UefiLib
- UefiBootServicesTableLib
- UefiDriverEntryPoint
- BaseMemoryLib
- DebugLib
- ReportStatusCodeLib
- TimerLib
- DmaLib
- IoLib
-
-[Guids]
- gEfiEventExitBootServicesGuid
-
-[Protocols]
- gEfiDriverBindingProtocolGuid
- gEfiUsb2HcProtocolGuid
- gRaspberryPiFirmwareProtocolGuid
-
-[Depex]
- gRaspberryPiFirmwareProtocolGuid
diff --git a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwcHw.h b/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwcHw.h
deleted file mode 100644
index 88fd9393..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/DwUsbHostDxe/DwcHw.h
+++ /dev/null
@@ -1,782 +0,0 @@
-/** @file
- *
- * Copyright (c) 2017, Andrey Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2015-2016, Linaro Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#ifndef __DWCHW_H__
-#define __DWCHW_H__
-
-#define DW2_USB_BASE_ADDRESS 0x3f980000
-
-#define HSOTG_REG(x) (x)
-
-#define HCCHAR(_ch) HSOTG_REG(0x0500 + 0x20 * (_ch))
-#define HCSPLT(_ch) HSOTG_REG(0x0504 + 0x20 * (_ch))
-#define HCINT(_ch) HSOTG_REG(0x0508 + 0x20 * (_ch))
-#define HCINTMSK(_ch) HSOTG_REG(0x050c + 0x20 * (_ch))
-#define HCTSIZ(_ch) HSOTG_REG(0x0510 + 0x20 * (_ch))
-#define HCDMA(_ch) HSOTG_REG(0x0514 + 0x20 * (_ch))
-#define HCDMAB(_ch) HSOTG_REG(0x051c + 0x20 * (_ch))
-
-#define HCFG HSOTG_REG(0x0400)
-#define HFIR HSOTG_REG(0x0404)
-#define HFNUM HSOTG_REG(0x0408)
-#define HPTXSTS HSOTG_REG(0x0410)
-#define HAINT HSOTG_REG(0x0414)
-#define HAINTMSK HSOTG_REG(0x0418)
-#define HFLBADDR HSOTG_REG(0x041c)
-
-#define GOTGCTL HSOTG_REG(0x000) // OTG control and status
-#define GOTGINT HSOTG_REG(0x004) // OTG interrupt
-#define GAHBCFG HSOTG_REG(0x008) // AHB config
-#define GUSBCFG HSOTG_REG(0x00C) // Core USB config
-#define GRSTCTL HSOTG_REG(0x010) // Core Reset
-#define GINTSTS HSOTG_REG(0x014) // Core Interrupt
-#define GINTMSK HSOTG_REG(0x018) // Core Interrupt Mask
-#define GRXSTSR HSOTG_REG(0x01C) // Receive Status Queue Read
-#define GRXSTSP HSOTG_REG(0x020) // Receive Status Queue Read and POP
-#define GRXFSIZ HSOTG_REG(0x024) // Receive FIFO Size
-#define GNPTXFSIZ HSOTG_REG(0x028) // Non-periodic TX FIFO Size
-#define GNPTXSTS HSOTG_REG(0x02C) // Non-periodic TX FIFO/Queue Status
-#define GI2CCTL HSOTG_REG(0x0030) // I2C access
-#define GPVNDCTL HSOTG_REG(0x0034) // PHY vendor control
-#define GGPIO HSOTG_REG(0x0038) // GPIO
-#define GUID HSOTG_REG(0x003c) // User ID
-#define GSNPSID HSOTG_REG(0x0040) // Synopsis ID
-#define GHWCFG1 HSOTG_REG(0x0044) // User HW Config1
-#define GHWCFG2 HSOTG_REG(0x0048) // User HW Config2
-#define GHWCFG3 HSOTG_REG(0x004c) // User HW Config3
-#define GHWCFG4 HSOTG_REG(0x0050) // User HW Config4
-#define GLPMCFG HSOTG_REG(0x0054) // Core LPM config
-#define HPTXFSIZ HSOTG_REG(0x100) // Host periodic TX FIFO Size
-#define DPTXFSIZN(_a) HSOTG_REG(0x104 + (((_a) - 1) * 4))
-#define HPRT0 HSOTG_REG(0x0440)
-#define PCGCCTL HSOTG_REG(0xE00)
-
-#define DWC2_GOTGCTL_SESREQSCS (1 << 0)
-#define DWC2_GOTGCTL_SESREQSCS_OFFSET 0
-#define DWC2_GOTGCTL_SESREQ (1 << 1)
-#define DWC2_GOTGCTL_SESREQ_OFFSET 1
-#define DWC2_GOTGCTL_HSTNEGSCS (1 << 8)
-#define DWC2_GOTGCTL_HSTNEGSCS_OFFSET 8
-#define DWC2_GOTGCTL_HNPREQ (1 << 9)
-#define DWC2_GOTGCTL_HNPREQ_OFFSET 9
-#define DWC2_GOTGCTL_HSTSETHNPEN (1 << 10)
-#define DWC2_GOTGCTL_HSTSETHNPEN_OFFSET 10
-#define DWC2_GOTGCTL_DEVHNPEN (1 << 11)
-#define DWC2_GOTGCTL_DEVHNPEN_OFFSET 11
-#define DWC2_GOTGCTL_CONIDSTS (1 << 16)
-#define DWC2_GOTGCTL_CONIDSTS_OFFSET 16
-#define DWC2_GOTGCTL_DBNCTIME (1 << 17)
-#define DWC2_GOTGCTL_DBNCTIME_OFFSET 17
-#define DWC2_GOTGCTL_ASESVLD (1 << 18)
-#define DWC2_GOTGCTL_ASESVLD_OFFSET 18
-#define DWC2_GOTGCTL_BSESVLD (1 << 19)
-#define DWC2_GOTGCTL_BSESVLD_OFFSET 19
-#define DWC2_GOTGCTL_OTGVER (1 << 20)
-#define DWC2_GOTGCTL_OTGVER_OFFSET 20
-#define DWC2_GOTGINT_SESENDDET (1 << 2)
-#define DWC2_GOTGINT_SESENDDET_OFFSET 2
-#define DWC2_GOTGINT_SESREQSUCSTSCHNG (1 << 8)
-#define DWC2_GOTGINT_SESREQSUCSTSCHNG_OFFSET 8
-#define DWC2_GOTGINT_HSTNEGSUCSTSCHNG (1 << 9)
-#define DWC2_GOTGINT_HSTNEGSUCSTSCHNG_OFFSET 9
-#define DWC2_GOTGINT_RESERVER10_16_MASK (0x7F << 10)
-#define DWC2_GOTGINT_RESERVER10_16_OFFSET 10
-#define DWC2_GOTGINT_HSTNEGDET (1 << 17)
-#define DWC2_GOTGINT_HSTNEGDET_OFFSET 17
-#define DWC2_GOTGINT_ADEVTOUTCHNG (1 << 18)
-#define DWC2_GOTGINT_ADEVTOUTCHNG_OFFSET 18
-#define DWC2_GOTGINT_DEBDONE (1 << 19)
-#define DWC2_GOTGINT_DEBDONE_OFFSET 19
-#define DWC2_GAHBCFG_GLBLINTRMSK (1 << 0)
-#define DWC2_GAHBCFG_GLBLINTRMSK_OFFSET 0
-#define DWC2_GAHBCFG_AXI_BURST4_MASK (3 << 1)
-#define DWC2_GAHBCFG_WAIT_AXI_WRITES (1 << 4)
-#define DWC2_GAHBCFG_DMAENABLE (1 << 5)
-#define DWC2_GAHBCFG_DMAENABLE_OFFSET 5
-#define DWC2_GAHBCFG_NPTXFEMPLVL_TXFEMPLVL (1 << 7)
-#define DWC2_GAHBCFG_NPTXFEMPLVL_TXFEMPLVL_OFFSET 7
-#define DWC2_GAHBCFG_PTXFEMPLVL (1 << 8)
-#define DWC2_GAHBCFG_PTXFEMPLVL_OFFSET 8
-#define DWC2_GUSBCFG_TOUTCAL_MASK (0x7 << 0)
-#define DWC2_GUSBCFG_TOUTCAL_OFFSET 0
-#define DWC2_GUSBCFG_PHYIF (1 << 3)
-#define DWC2_GUSBCFG_PHYIF_OFFSET 3
-#define DWC2_GUSBCFG_ULPI_UTMI_SEL (1 << 4)
-#define DWC2_GUSBCFG_ULPI_UTMI_SEL_OFFSET 4
-#define DWC2_GUSBCFG_FSINTF (1 << 5)
-#define DWC2_GUSBCFG_FSINTF_OFFSET 5
-#define DWC2_GUSBCFG_PHYSEL (1 << 6)
-#define DWC2_GUSBCFG_PHYSEL_OFFSET 6
-#define DWC2_GUSBCFG_DDRSEL (1 << 7)
-#define DWC2_GUSBCFG_DDRSEL_OFFSET 7
-#define DWC2_GUSBCFG_SRPCAP (1 << 8)
-#define DWC2_GUSBCFG_SRPCAP_OFFSET 8
-#define DWC2_GUSBCFG_HNPCAP (1 << 9)
-#define DWC2_GUSBCFG_HNPCAP_OFFSET 9
-#define DWC2_GUSBCFG_USBTRDTIM_MASK (0xF << 10)
-#define DWC2_GUSBCFG_USBTRDTIM_OFFSET 10
-#define DWC2_GUSBCFG_NPTXFRWNDEN (1 << 14)
-#define DWC2_GUSBCFG_NPTXFRWNDEN_OFFSET 14
-#define DWC2_GUSBCFG_PHYLPWRCLKSEL (1 << 15)
-#define DWC2_GUSBCFG_PHYLPWRCLKSEL_OFFSET 15
-#define DWC2_GUSBCFG_OTGUTMIFSSEL (1 << 16)
-#define DWC2_GUSBCFG_OTGUTMIFSSEL_OFFSET 16
-#define DWC2_GUSBCFG_ULPI_FSLS (1 << 17)
-#define DWC2_GUSBCFG_ULPI_FSLS_OFFSET 17
-#define DWC2_GUSBCFG_ULPI_AUTO_RES (1 << 18)
-#define DWC2_GUSBCFG_ULPI_AUTO_RES_OFFSET 18
-#define DWC2_GUSBCFG_ULPI_CLK_SUS_M (1 << 19)
-#define DWC2_GUSBCFG_ULPI_CLK_SUS_M_OFFSET 19
-#define DWC2_GUSBCFG_ULPI_EXT_VBUS_DRV (1 << 20)
-#define DWC2_GUSBCFG_ULPI_EXT_VBUS_DRV_OFFSET 20
-#define DWC2_GUSBCFG_ULPI_INT_VBUS_INDICATOR (1 << 21)
-#define DWC2_GUSBCFG_ULPI_INT_VBUS_INDICATOR_OFFSET 21
-#define DWC2_GUSBCFG_TERM_SEL_DL_PULSE (1 << 22)
-#define DWC2_GUSBCFG_TERM_SEL_DL_PULSE_OFFSET 22
-#define DWC2_GUSBCFG_IC_USB_CAP (1 << 26)
-#define DWC2_GUSBCFG_IC_USB_CAP_OFFSET 26
-#define DWC2_GUSBCFG_IC_TRAFFIC_PULL_REMOVE (1 << 27)
-#define DWC2_GUSBCFG_IC_TRAFFIC_PULL_REMOVE_OFFSET 27
-#define DWC2_GUSBCFG_TX_END_DELAY (1 << 28)
-#define DWC2_GUSBCFG_TX_END_DELAY_OFFSET 28
-#define DWC2_GUSBCFG_FORCEHOSTMODE (1 << 29)
-#define DWC2_GUSBCFG_FORCEHOSTMODE_OFFSET 29
-#define DWC2_GUSBCFG_FORCEDEVMODE (1 << 30)
-#define DWC2_GUSBCFG_FORCEDEVMODE_OFFSET 30
-#define DWC2_GLPMCTL_LPM_CAP_EN (1 << 0)
-#define DWC2_GLPMCTL_LPM_CAP_EN_OFFSET 0
-#define DWC2_GLPMCTL_APPL_RESP (1 << 1)
-#define DWC2_GLPMCTL_APPL_RESP_OFFSET 1
-#define DWC2_GLPMCTL_HIRD_MASK (0xF << 2)
-#define DWC2_GLPMCTL_HIRD_OFFSET 2
-#define DWC2_GLPMCTL_REM_WKUP_EN (1 << 6)
-#define DWC2_GLPMCTL_REM_WKUP_EN_OFFSET 6
-#define DWC2_GLPMCTL_EN_UTMI_SLEEP (1 << 7)
-#define DWC2_GLPMCTL_EN_UTMI_SLEEP_OFFSET 7
-#define DWC2_GLPMCTL_HIRD_THRES_MASK (0x1F << 8)
-#define DWC2_GLPMCTL_HIRD_THRES_OFFSET 8
-#define DWC2_GLPMCTL_LPM_RESP_MASK (0x3 << 13)
-#define DWC2_GLPMCTL_LPM_RESP_OFFSET 13
-#define DWC2_GLPMCTL_PRT_SLEEP_STS (1 << 15)
-#define DWC2_GLPMCTL_PRT_SLEEP_STS_OFFSET 15
-#define DWC2_GLPMCTL_SLEEP_STATE_RESUMEOK (1 << 16)
-#define DWC2_GLPMCTL_SLEEP_STATE_RESUMEOK_OFFSET 16
-#define DWC2_GLPMCTL_LPM_CHAN_INDEX_MASK (0xF << 17)
-#define DWC2_GLPMCTL_LPM_CHAN_INDEX_OFFSET 17
-#define DWC2_GLPMCTL_RETRY_COUNT_MASK (0x7 << 21)
-#define DWC2_GLPMCTL_RETRY_COUNT_OFFSET 21
-#define DWC2_GLPMCTL_SEND_LPM (1 << 24)
-#define DWC2_GLPMCTL_SEND_LPM_OFFSET 24
-#define DWC2_GLPMCTL_RETRY_COUNT_STS_MASK (0x7 << 25)
-#define DWC2_GLPMCTL_RETRY_COUNT_STS_OFFSET 25
-#define DWC2_GLPMCTL_HSIC_CONNECT (1 << 30)
-#define DWC2_GLPMCTL_HSIC_CONNECT_OFFSET 30
-#define DWC2_GLPMCTL_INV_SEL_HSIC (1 << 31)
-#define DWC2_GLPMCTL_INV_SEL_HSIC_OFFSET 31
-#define DWC2_GRSTCTL_CSFTRST (1 << 0)
-#define DWC2_GRSTCTL_CSFTRST_OFFSET 0
-#define DWC2_GRSTCTL_HSFTRST (1 << 1)
-#define DWC2_GRSTCTL_HSFTRST_OFFSET 1
-#define DWC2_GRSTCTL_HSTFRM (1 << 2)
-#define DWC2_GRSTCTL_HSTFRM_OFFSET 2
-#define DWC2_GRSTCTL_INTKNQFLSH (1 << 3)
-#define DWC2_GRSTCTL_INTKNQFLSH_OFFSET 3
-#define DWC2_GRSTCTL_RXFFLSH (1 << 4)
-#define DWC2_GRSTCTL_RXFFLSH_OFFSET 4
-#define DWC2_GRSTCTL_TXFFLSH (1 << 5)
-#define DWC2_GRSTCTL_TXFFLSH_OFFSET 5
-#define DWC2_GRSTCTL_TXFNUM_MASK (0x1F << 6)
-#define DWC2_GRSTCTL_TXFNUM_OFFSET 6
-#define DWC2_GRSTCTL_DMAREQ (1 << 30)
-#define DWC2_GRSTCTL_DMAREQ_OFFSET 30
-#define DWC2_GRSTCTL_AHBIDLE (1 << 31)
-#define DWC2_GRSTCTL_AHBIDLE_OFFSET 31
-#define DWC2_GINTMSK_MODEMISMATCH (1 << 1)
-#define DWC2_GINTMSK_MODEMISMATCH_OFFSET 1
-#define DWC2_GINTMSK_OTGINTR (1 << 2)
-#define DWC2_GINTMSK_OTGINTR_OFFSET 2
-#define DWC2_GINTMSK_SOFINTR (1 << 3)
-#define DWC2_GINTMSK_SOFINTR_OFFSET 3
-#define DWC2_GINTMSK_RXSTSQLVL (1 << 4)
-#define DWC2_GINTMSK_RXSTSQLVL_OFFSET 4
-#define DWC2_GINTMSK_NPTXFEMPTY (1 << 5)
-#define DWC2_GINTMSK_NPTXFEMPTY_OFFSET 5
-#define DWC2_GINTMSK_GINNAKEFF (1 << 6)
-#define DWC2_GINTMSK_GINNAKEFF_OFFSET 6
-#define DWC2_GINTMSK_GOUTNAKEFF (1 << 7)
-#define DWC2_GINTMSK_GOUTNAKEFF_OFFSET 7
-#define DWC2_GINTMSK_I2CINTR (1 << 9)
-#define DWC2_GINTMSK_I2CINTR_OFFSET 9
-#define DWC2_GINTMSK_ERLYSUSPEND (1 << 10)
-#define DWC2_GINTMSK_ERLYSUSPEND_OFFSET 10
-#define DWC2_GINTMSK_USBSUSPEND (1 << 11)
-#define DWC2_GINTMSK_USBSUSPEND_OFFSET 11
-#define DWC2_GINTMSK_USBRESET (1 << 12)
-#define DWC2_GINTMSK_USBRESET_OFFSET 12
-#define DWC2_GINTMSK_ENUMDONE (1 << 13)
-#define DWC2_GINTMSK_ENUMDONE_OFFSET 13
-#define DWC2_GINTMSK_ISOOUTDROP (1 << 14)
-#define DWC2_GINTMSK_ISOOUTDROP_OFFSET 14
-#define DWC2_GINTMSK_EOPFRAME (1 << 15)
-#define DWC2_GINTMSK_EOPFRAME_OFFSET 15
-#define DWC2_GINTMSK_EPMISMATCH (1 << 17)
-#define DWC2_GINTMSK_EPMISMATCH_OFFSET 17
-#define DWC2_GINTMSK_INEPINTR (1 << 18)
-#define DWC2_GINTMSK_INEPINTR_OFFSET 18
-#define DWC2_GINTMSK_OUTEPINTR (1 << 19)
-#define DWC2_GINTMSK_OUTEPINTR_OFFSET 19
-#define DWC2_GINTMSK_INCOMPLISOIN (1 << 20)
-#define DWC2_GINTMSK_INCOMPLISOIN_OFFSET 20
-#define DWC2_GINTMSK_INCOMPLISOOUT (1 << 21)
-#define DWC2_GINTMSK_INCOMPLISOOUT_OFFSET 21
-#define DWC2_GINTMSK_PORTINTR (1 << 24)
-#define DWC2_GINTMSK_PORTINTR_OFFSET 24
-#define DWC2_GINTMSK_HCINTR (1 << 25)
-#define DWC2_GINTMSK_HCINTR_OFFSET 25
-#define DWC2_GINTMSK_PTXFEMPTY (1 << 26)
-#define DWC2_GINTMSK_PTXFEMPTY_OFFSET 26
-#define DWC2_GINTMSK_LPMTRANRCVD (1 << 27)
-#define DWC2_GINTMSK_LPMTRANRCVD_OFFSET 27
-#define DWC2_GINTMSK_CONIDSTSCHNG (1 << 28)
-#define DWC2_GINTMSK_CONIDSTSCHNG_OFFSET 28
-#define DWC2_GINTMSK_DISCONNECT (1 << 29)
-#define DWC2_GINTMSK_DISCONNECT_OFFSET 29
-#define DWC2_GINTMSK_SESSREQINTR (1 << 30)
-#define DWC2_GINTMSK_SESSREQINTR_OFFSET 30
-#define DWC2_GINTMSK_WKUPINTR (1 << 31)
-#define DWC2_GINTMSK_WKUPINTR_OFFSET 31
-#define DWC2_GINTSTS_CURMODE_DEVICE (0 << 0)
-#define DWC2_GINTSTS_CURMODE_HOST (1 << 0)
-#define DWC2_GINTSTS_CURMODE (1 << 0)
-#define DWC2_GINTSTS_CURMODE_OFFSET 0
-#define DWC2_GINTSTS_MODEMISMATCH (1 << 1)
-#define DWC2_GINTSTS_MODEMISMATCH_OFFSET 1
-#define DWC2_GINTSTS_OTGINTR (1 << 2)
-#define DWC2_GINTSTS_OTGINTR_OFFSET 2
-#define DWC2_GINTSTS_SOFINTR (1 << 3)
-#define DWC2_GINTSTS_SOFINTR_OFFSET 3
-#define DWC2_GINTSTS_RXSTSQLVL (1 << 4)
-#define DWC2_GINTSTS_RXSTSQLVL_OFFSET 4
-#define DWC2_GINTSTS_NPTXFEMPTY (1 << 5)
-#define DWC2_GINTSTS_NPTXFEMPTY_OFFSET 5
-#define DWC2_GINTSTS_GINNAKEFF (1 << 6)
-#define DWC2_GINTSTS_GINNAKEFF_OFFSET 6
-#define DWC2_GINTSTS_GOUTNAKEFF (1 << 7)
-#define DWC2_GINTSTS_GOUTNAKEFF_OFFSET 7
-#define DWC2_GINTSTS_I2CINTR (1 << 9)
-#define DWC2_GINTSTS_I2CINTR_OFFSET 9
-#define DWC2_GINTSTS_ERLYSUSPEND (1 << 10)
-#define DWC2_GINTSTS_ERLYSUSPEND_OFFSET 10
-#define DWC2_GINTSTS_USBSUSPEND (1 << 11)
-#define DWC2_GINTSTS_USBSUSPEND_OFFSET 11
-#define DWC2_GINTSTS_USBRESET (1 << 12)
-#define DWC2_GINTSTS_USBRESET_OFFSET 12
-#define DWC2_GINTSTS_ENUMDONE (1 << 13)
-#define DWC2_GINTSTS_ENUMDONE_OFFSET 13
-#define DWC2_GINTSTS_ISOOUTDROP (1 << 14)
-#define DWC2_GINTSTS_ISOOUTDROP_OFFSET 14
-#define DWC2_GINTSTS_EOPFRAME (1 << 15)
-#define DWC2_GINTSTS_EOPFRAME_OFFSET 15
-#define DWC2_GINTSTS_INTOKENRX (1 << 16)
-#define DWC2_GINTSTS_INTOKENRX_OFFSET 16
-#define DWC2_GINTSTS_EPMISMATCH (1 << 17)
-#define DWC2_GINTSTS_EPMISMATCH_OFFSET 17
-#define DWC2_GINTSTS_INEPINT (1 << 18)
-#define DWC2_GINTSTS_INEPINT_OFFSET 18
-#define DWC2_GINTSTS_OUTEPINTR (1 << 19)
-#define DWC2_GINTSTS_OUTEPINTR_OFFSET 19
-#define DWC2_GINTSTS_INCOMPLISOIN (1 << 20)
-#define DWC2_GINTSTS_INCOMPLISOIN_OFFSET 20
-#define DWC2_GINTSTS_INCOMPLISOOUT (1 << 21)
-#define DWC2_GINTSTS_INCOMPLISOOUT_OFFSET 21
-#define DWC2_GINTSTS_PORTINTR (1 << 24)
-#define DWC2_GINTSTS_PORTINTR_OFFSET 24
-#define DWC2_GINTSTS_HCINTR (1 << 25)
-#define DWC2_GINTSTS_HCINTR_OFFSET 25
-#define DWC2_GINTSTS_PTXFEMPTY (1 << 26)
-#define DWC2_GINTSTS_PTXFEMPTY_OFFSET 26
-#define DWC2_GINTSTS_LPMTRANRCVD (1 << 27)
-#define DWC2_GINTSTS_LPMTRANRCVD_OFFSET 27
-#define DWC2_GINTSTS_CONIDSTSCHNG (1 << 28)
-#define DWC2_GINTSTS_CONIDSTSCHNG_OFFSET 28
-#define DWC2_GINTSTS_DISCONNECT (1 << 29)
-#define DWC2_GINTSTS_DISCONNECT_OFFSET 29
-#define DWC2_GINTSTS_SESSREQINTR (1 << 30)
-#define DWC2_GINTSTS_SESSREQINTR_OFFSET 30
-#define DWC2_GINTSTS_WKUPINTR (1 << 31)
-#define DWC2_GINTSTS_WKUPINTR_OFFSET 31
-#define DWC2_GRXSTS_EPNUM_MASK (0xF << 0)
-#define DWC2_GRXSTS_EPNUM_OFFSET 0
-#define DWC2_GRXSTS_BCNT_MASK (0x7FF << 4)
-#define DWC2_GRXSTS_BCNT_OFFSET 4
-#define DWC2_GRXSTS_DPID_MASK (0x3 << 15)
-#define DWC2_GRXSTS_DPID_OFFSET 15
-#define DWC2_GRXSTS_PKTSTS_MASK (0xF << 17)
-#define DWC2_GRXSTS_PKTSTS_OFFSET 17
-#define DWC2_GRXSTS_FN_MASK (0xF << 21)
-#define DWC2_GRXSTS_FN_OFFSET 21
-#define DWC2_FIFOSIZE_STARTADDR_MASK (0xFFFF << 0)
-#define DWC2_FIFOSIZE_STARTADDR_OFFSET 0
-#define DWC2_FIFOSIZE_DEPTH_MASK (0xFFFF << 16)
-#define DWC2_FIFOSIZE_DEPTH_OFFSET 16
-#define DWC2_GNPTXSTS_NPTXFSPCAVAIL_MASK (0xFFFF << 0)
-#define DWC2_GNPTXSTS_NPTXFSPCAVAIL_OFFSET 0
-#define DWC2_GNPTXSTS_NPTXQSPCAVAIL_MASK (0xFF << 16)
-#define DWC2_GNPTXSTS_NPTXQSPCAVAIL_OFFSET 16
-#define DWC2_GNPTXSTS_NPTXQTOP_TERMINATE (1 << 24)
-#define DWC2_GNPTXSTS_NPTXQTOP_TERMINATE_OFFSET 24
-#define DWC2_GNPTXSTS_NPTXQTOP_TOKEN_MASK (0x3 << 25)
-#define DWC2_GNPTXSTS_NPTXQTOP_TOKEN_OFFSET 25
-#define DWC2_GNPTXSTS_NPTXQTOP_CHNEP_MASK (0xF << 27)
-#define DWC2_GNPTXSTS_NPTXQTOP_CHNEP_OFFSET 27
-#define DWC2_DTXFSTS_TXFSPCAVAIL_MASK (0xFFFF << 0)
-#define DWC2_DTXFSTS_TXFSPCAVAIL_OFFSET 0
-#define DWC2_GI2CCTL_RWDATA_MASK (0xFF << 0)
-#define DWC2_GI2CCTL_RWDATA_OFFSET 0
-#define DWC2_GI2CCTL_REGADDR_MASK (0xFF << 8)
-#define DWC2_GI2CCTL_REGADDR_OFFSET 8
-#define DWC2_GI2CCTL_ADDR_MASK (0x7F << 16)
-#define DWC2_GI2CCTL_ADDR_OFFSET 16
-#define DWC2_GI2CCTL_I2CEN (1 << 23)
-#define DWC2_GI2CCTL_I2CEN_OFFSET 23
-#define DWC2_GI2CCTL_ACK (1 << 24)
-#define DWC2_GI2CCTL_ACK_OFFSET 24
-#define DWC2_GI2CCTL_I2CSUSPCTL (1 << 25)
-#define DWC2_GI2CCTL_I2CSUSPCTL_OFFSET 25
-#define DWC2_GI2CCTL_I2CDEVADDR_MASK (0x3 << 26)
-#define DWC2_GI2CCTL_I2CDEVADDR_OFFSET 26
-#define DWC2_GI2CCTL_RW (1 << 30)
-#define DWC2_GI2CCTL_RW_OFFSET 30
-#define DWC2_GI2CCTL_BSYDNE (1 << 31)
-#define DWC2_GI2CCTL_BSYDNE_OFFSET 31
-#define DWC2_HWCFG1_EP_DIR0_MASK (0x3 << 0)
-#define DWC2_HWCFG1_EP_DIR0_OFFSET 0
-#define DWC2_HWCFG1_EP_DIR1_MASK (0x3 << 2)
-#define DWC2_HWCFG1_EP_DIR1_OFFSET 2
-#define DWC2_HWCFG1_EP_DIR2_MASK (0x3 << 4)
-#define DWC2_HWCFG1_EP_DIR2_OFFSET 4
-#define DWC2_HWCFG1_EP_DIR3_MASK (0x3 << 6)
-#define DWC2_HWCFG1_EP_DIR3_OFFSET 6
-#define DWC2_HWCFG1_EP_DIR4_MASK (0x3 << 8)
-#define DWC2_HWCFG1_EP_DIR4_OFFSET 8
-#define DWC2_HWCFG1_EP_DIR5_MASK (0x3 << 10)
-#define DWC2_HWCFG1_EP_DIR5_OFFSET 10
-#define DWC2_HWCFG1_EP_DIR6_MASK (0x3 << 12)
-#define DWC2_HWCFG1_EP_DIR6_OFFSET 12
-#define DWC2_HWCFG1_EP_DIR7_MASK (0x3 << 14)
-#define DWC2_HWCFG1_EP_DIR7_OFFSET 14
-#define DWC2_HWCFG1_EP_DIR8_MASK (0x3 << 16)
-#define DWC2_HWCFG1_EP_DIR8_OFFSET 16
-#define DWC2_HWCFG1_EP_DIR9_MASK (0x3 << 18)
-#define DWC2_HWCFG1_EP_DIR9_OFFSET 18
-#define DWC2_HWCFG1_EP_DIR10_MASK (0x3 << 20)
-#define DWC2_HWCFG1_EP_DIR10_OFFSET 20
-#define DWC2_HWCFG1_EP_DIR11_MASK (0x3 << 22)
-#define DWC2_HWCFG1_EP_DIR11_OFFSET 22
-#define DWC2_HWCFG1_EP_DIR12_MASK (0x3 << 24)
-#define DWC2_HWCFG1_EP_DIR12_OFFSET 24
-#define DWC2_HWCFG1_EP_DIR13_MASK (0x3 << 26)
-#define DWC2_HWCFG1_EP_DIR13_OFFSET 26
-#define DWC2_HWCFG1_EP_DIR14_MASK (0x3 << 28)
-#define DWC2_HWCFG1_EP_DIR14_OFFSET 28
-#define DWC2_HWCFG1_EP_DIR15_MASK (0x3 << 30)
-#define DWC2_HWCFG1_EP_DIR15_OFFSET 30
-#define DWC2_HWCFG2_OP_MODE_MASK (0x7 << 0)
-#define DWC2_HWCFG2_OP_MODE_OFFSET 0
-#define DWC2_HWCFG2_ARCHITECTURE_SLAVE_ONLY (0x0 << 3)
-#define DWC2_HWCFG2_ARCHITECTURE_EXT_DMA (0x1 << 3)
-#define DWC2_HWCFG2_ARCHITECTURE_INT_DMA (0x2 << 3)
-#define DWC2_HWCFG2_ARCHITECTURE_MASK (0x3 << 3)
-#define DWC2_HWCFG2_ARCHITECTURE_OFFSET 3
-#define DWC2_HWCFG2_POINT2POINT (1 << 5)
-#define DWC2_HWCFG2_POINT2POINT_OFFSET 5
-#define DWC2_HWCFG2_HS_PHY_TYPE_MASK (0x3 << 6)
-#define DWC2_HWCFG2_HS_PHY_TYPE_OFFSET 6
-#define DWC2_HWCFG2_FS_PHY_TYPE_MASK (0x3 << 8)
-#define DWC2_HWCFG2_FS_PHY_TYPE_OFFSET 8
-#define DWC2_HWCFG2_NUM_DEV_EP_MASK (0xF << 10)
-#define DWC2_HWCFG2_NUM_DEV_EP_OFFSET 10
-#define DWC2_HWCFG2_NUM_HOST_CHAN_MASK (0xF << 14)
-#define DWC2_HWCFG2_NUM_HOST_CHAN_OFFSET 14
-#define DWC2_HWCFG2_PERIO_EP_SUPPORTED (1 << 18)
-#define DWC2_HWCFG2_PERIO_EP_SUPPORTED_OFFSET 18
-#define DWC2_HWCFG2_DYNAMIC_FIFO (1 << 19)
-#define DWC2_HWCFG2_DYNAMIC_FIFO_OFFSET 19
-#define DWC2_HWCFG2_MULTI_PROC_INT (1 << 20)
-#define DWC2_HWCFG2_MULTI_PROC_INT_OFFSET 20
-#define DWC2_HWCFG2_NONPERIO_TX_Q_DEPTH_MASK (0x3 << 22)
-#define DWC2_HWCFG2_NONPERIO_TX_Q_DEPTH_OFFSET 22
-#define DWC2_HWCFG2_HOST_PERIO_TX_Q_DEPTH_MASK (0x3 << 24)
-#define DWC2_HWCFG2_HOST_PERIO_TX_Q_DEPTH_OFFSET 24
-#define DWC2_HWCFG2_DEV_TOKEN_Q_DEPTH_MASK (0x1F << 26)
-#define DWC2_HWCFG2_DEV_TOKEN_Q_DEPTH_OFFSET 26
-#define DWC2_HWCFG3_XFER_SIZE_CNTR_WIDTH_MASK (0xF << 0)
-#define DWC2_HWCFG3_XFER_SIZE_CNTR_WIDTH_OFFSET 0
-#define DWC2_HWCFG3_PACKET_SIZE_CNTR_WIDTH_MASK (0x7 << 4)
-#define DWC2_HWCFG3_PACKET_SIZE_CNTR_WIDTH_OFFSET 4
-#define DWC2_HWCFG3_OTG_FUNC (1 << 7)
-#define DWC2_HWCFG3_OTG_FUNC_OFFSET 7
-#define DWC2_HWCFG3_I2C (1 << 8)
-#define DWC2_HWCFG3_I2C_OFFSET 8
-#define DWC2_HWCFG3_VENDOR_CTRL_IF (1 << 9)
-#define DWC2_HWCFG3_VENDOR_CTRL_IF_OFFSET 9
-#define DWC2_HWCFG3_OPTIONAL_FEATURES (1 << 10)
-#define DWC2_HWCFG3_OPTIONAL_FEATURES_OFFSET 10
-#define DWC2_HWCFG3_SYNCH_RESET_TYPE (1 << 11)
-#define DWC2_HWCFG3_SYNCH_RESET_TYPE_OFFSET 11
-#define DWC2_HWCFG3_OTG_ENABLE_IC_USB (1 << 12)
-#define DWC2_HWCFG3_OTG_ENABLE_IC_USB_OFFSET 12
-#define DWC2_HWCFG3_OTG_ENABLE_HSIC (1 << 13)
-#define DWC2_HWCFG3_OTG_ENABLE_HSIC_OFFSET 13
-#define DWC2_HWCFG3_OTG_LPM_EN (1 << 15)
-#define DWC2_HWCFG3_OTG_LPM_EN_OFFSET 15
-#define DWC2_HWCFG3_DFIFO_DEPTH_MASK (0xFFFF << 16)
-#define DWC2_HWCFG3_DFIFO_DEPTH_OFFSET 16
-#define DWC2_HWCFG4_NUM_DEV_PERIO_IN_EP_MASK (0xF << 0)
-#define DWC2_HWCFG4_NUM_DEV_PERIO_IN_EP_OFFSET 0
-#define DWC2_HWCFG4_POWER_OPTIMIZ (1 << 4)
-#define DWC2_HWCFG4_POWER_OPTIMIZ_OFFSET 4
-#define DWC2_HWCFG4_MIN_AHB_FREQ_MASK (0x1FF << 5)
-#define DWC2_HWCFG4_MIN_AHB_FREQ_OFFSET 5
-#define DWC2_HWCFG4_UTMI_PHY_DATA_WIDTH_MASK (0x3 << 14)
-#define DWC2_HWCFG4_UTMI_PHY_DATA_WIDTH_OFFSET 14
-#define DWC2_HWCFG4_NUM_DEV_MODE_CTRL_EP_MASK (0xF << 16)
-#define DWC2_HWCFG4_NUM_DEV_MODE_CTRL_EP_OFFSET 16
-#define DWC2_HWCFG4_IDDIG_FILT_EN (1 << 20)
-#define DWC2_HWCFG4_IDDIG_FILT_EN_OFFSET 20
-#define DWC2_HWCFG4_VBUS_VALID_FILT_EN (1 << 21)
-#define DWC2_HWCFG4_VBUS_VALID_FILT_EN_OFFSET 21
-#define DWC2_HWCFG4_A_VALID_FILT_EN (1 << 22)
-#define DWC2_HWCFG4_A_VALID_FILT_EN_OFFSET 22
-#define DWC2_HWCFG4_B_VALID_FILT_EN (1 << 23)
-#define DWC2_HWCFG4_B_VALID_FILT_EN_OFFSET 23
-#define DWC2_HWCFG4_SESSION_END_FILT_EN (1 << 24)
-#define DWC2_HWCFG4_SESSION_END_FILT_EN_OFFSET 24
-#define DWC2_HWCFG4_DED_FIFO_EN (1 << 25)
-#define DWC2_HWCFG4_DED_FIFO_EN_OFFSET 25
-#define DWC2_HWCFG4_NUM_IN_EPS_MASK (0xF << 26)
-#define DWC2_HWCFG4_NUM_IN_EPS_OFFSET 26
-#define DWC2_HWCFG4_DESC_DMA (1 << 30)
-#define DWC2_HWCFG4_DESC_DMA_OFFSET 30
-#define DWC2_HWCFG4_DESC_DMA_DYN (1 << 31)
-#define DWC2_HWCFG4_DESC_DMA_DYN_OFFSET 31
-#define DWC2_HCFG_FSLSPCLKSEL_30_60_MHZ 0
-#define DWC2_HCFG_FSLSPCLKSEL_48_MHZ 1
-#define DWC2_HCFG_FSLSPCLKSEL_6_MHZ 2
-#define DWC2_HCFG_FSLSPCLKSEL_MASK (0x3 << 0)
-#define DWC2_HCFG_FSLSPCLKSEL_OFFSET 0
-#define DWC2_HCFG_FSLSSUPP (1 << 2)
-#define DWC2_HCFG_FSLSSUPP_OFFSET 2
-#define DWC2_HCFG_DESCDMA (1 << 23)
-#define DWC2_HCFG_DESCDMA_OFFSET 23
-#define DWC2_HCFG_FRLISTEN_MASK (0x3 << 24)
-#define DWC2_HCFG_FRLISTEN_OFFSET 24
-#define DWC2_HCFG_PERSCHEDENA (1 << 26)
-#define DWC2_HCFG_PERSCHEDENA_OFFSET 26
-#define DWC2_HCFG_PERSCHEDSTAT (1 << 27)
-#define DWC2_HCFG_PERSCHEDSTAT_OFFSET 27
-#define DWC2_HFIR_FRINT_MASK (0xFFFF << 0)
-#define DWC2_HFIR_FRINT_OFFSET 0
-#define DWC2_HFNUM_FRNUM_MASK (0x3FFF << 0)
-#define DWC2_HFNUM_FRNUM_OFFSET 0
-#define DWC2_HFNUM_FRREM_MASK (0xFFFF << 16)
-#define DWC2_HFNUM_FRREM_OFFSET 16
-#define DWC2_HPTXSTS_PTXFSPCAVAIL_MASK (0xFFFF << 0)
-#define DWC2_HPTXSTS_PTXFSPCAVAIL_OFFSET 0
-#define DWC2_HPTXSTS_PTXQSPCAVAIL_MASK (0xFF << 16)
-#define DWC2_HPTXSTS_PTXQSPCAVAIL_OFFSET 16
-#define DWC2_HPTXSTS_PTXQTOP_TERMINATE (1 << 24)
-#define DWC2_HPTXSTS_PTXQTOP_TERMINATE_OFFSET 24
-#define DWC2_HPTXSTS_PTXQTOP_TOKEN_MASK (0x3 << 25)
-#define DWC2_HPTXSTS_PTXQTOP_TOKEN_OFFSET 25
-#define DWC2_HPTXSTS_PTXQTOP_CHNUM_MASK (0xF << 27)
-#define DWC2_HPTXSTS_PTXQTOP_CHNUM_OFFSET 27
-#define DWC2_HPTXSTS_PTXQTOP_ODD (1 << 31)
-#define DWC2_HPTXSTS_PTXQTOP_ODD_OFFSET 31
-#define DWC2_HPRT0_PRTCONNSTS (1 << 0)
-#define DWC2_HPRT0_PRTCONNSTS_OFFSET 0
-#define DWC2_HPRT0_PRTCONNDET (1 << 1)
-#define DWC2_HPRT0_PRTCONNDET_OFFSET 1
-#define DWC2_HPRT0_PRTENA (1 << 2)
-#define DWC2_HPRT0_PRTENA_OFFSET 2
-#define DWC2_HPRT0_PRTENCHNG (1 << 3)
-#define DWC2_HPRT0_PRTENCHNG_OFFSET 3
-#define DWC2_HPRT0_PRTOVRCURRACT (1 << 4)
-#define DWC2_HPRT0_PRTOVRCURRACT_OFFSET 4
-#define DWC2_HPRT0_PRTOVRCURRCHNG (1 << 5)
-#define DWC2_HPRT0_PRTOVRCURRCHNG_OFFSET 5
-#define DWC2_HPRT0_PRTRES (1 << 6)
-#define DWC2_HPRT0_PRTRES_OFFSET 6
-#define DWC2_HPRT0_PRTSUSP (1 << 7)
-#define DWC2_HPRT0_PRTSUSP_OFFSET 7
-#define DWC2_HPRT0_PRTRST (1 << 8)
-#define DWC2_HPRT0_PRTRST_OFFSET 8
-#define DWC2_HPRT0_PRTLNSTS_MASK (0x3 << 10)
-#define DWC2_HPRT0_PRTLNSTS_OFFSET 10
-#define DWC2_HPRT0_PRTPWR (1 << 12)
-#define DWC2_HPRT0_PRTPWR_OFFSET 12
-#define DWC2_HPRT0_PRTTSTCTL_MASK (0xF << 13)
-#define DWC2_HPRT0_PRTTSTCTL_OFFSET 13
-#define DWC2_HPRT0_PRTSPD_MASK (0x3 << 17)
-#define DWC2_HPRT0_PRTSPD_OFFSET 17
-#define DWC2_HAINT_CH0 (1 << 0)
-#define DWC2_HAINT_CH0_OFFSET 0
-#define DWC2_HAINT_CH1 (1 << 1)
-#define DWC2_HAINT_CH1_OFFSET 1
-#define DWC2_HAINT_CH2 (1 << 2)
-#define DWC2_HAINT_CH2_OFFSET 2
-#define DWC2_HAINT_CH3 (1 << 3)
-#define DWC2_HAINT_CH3_OFFSET 3
-#define DWC2_HAINT_CH4 (1 << 4)
-#define DWC2_HAINT_CH4_OFFSET 4
-#define DWC2_HAINT_CH5 (1 << 5)
-#define DWC2_HAINT_CH5_OFFSET 5
-#define DWC2_HAINT_CH6 (1 << 6)
-#define DWC2_HAINT_CH6_OFFSET 6
-#define DWC2_HAINT_CH7 (1 << 7)
-#define DWC2_HAINT_CH7_OFFSET 7
-#define DWC2_HAINT_CH8 (1 << 8)
-#define DWC2_HAINT_CH8_OFFSET 8
-#define DWC2_HAINT_CH9 (1 << 9)
-#define DWC2_HAINT_CH9_OFFSET 9
-#define DWC2_HAINT_CH10 (1 << 10)
-#define DWC2_HAINT_CH10_OFFSET 10
-#define DWC2_HAINT_CH11 (1 << 11)
-#define DWC2_HAINT_CH11_OFFSET 11
-#define DWC2_HAINT_CH12 (1 << 12)
-#define DWC2_HAINT_CH12_OFFSET 12
-#define DWC2_HAINT_CH13 (1 << 13)
-#define DWC2_HAINT_CH13_OFFSET 13
-#define DWC2_HAINT_CH14 (1 << 14)
-#define DWC2_HAINT_CH14_OFFSET 14
-#define DWC2_HAINT_CH15 (1 << 15)
-#define DWC2_HAINT_CH15_OFFSET 15
-#define DWC2_HAINT_CHINT_MASK 0xffff
-#define DWC2_HAINT_CHINT_OFFSET 0
-#define DWC2_HAINTMSK_CH0 (1 << 0)
-#define DWC2_HAINTMSK_CH0_OFFSET 0
-#define DWC2_HAINTMSK_CH1 (1 << 1)
-#define DWC2_HAINTMSK_CH1_OFFSET 1
-#define DWC2_HAINTMSK_CH2 (1 << 2)
-#define DWC2_HAINTMSK_CH2_OFFSET 2
-#define DWC2_HAINTMSK_CH3 (1 << 3)
-#define DWC2_HAINTMSK_CH3_OFFSET 3
-#define DWC2_HAINTMSK_CH4 (1 << 4)
-#define DWC2_HAINTMSK_CH4_OFFSET 4
-#define DWC2_HAINTMSK_CH5 (1 << 5)
-#define DWC2_HAINTMSK_CH5_OFFSET 5
-#define DWC2_HAINTMSK_CH6 (1 << 6)
-#define DWC2_HAINTMSK_CH6_OFFSET 6
-#define DWC2_HAINTMSK_CH7 (1 << 7)
-#define DWC2_HAINTMSK_CH7_OFFSET 7
-#define DWC2_HAINTMSK_CH8 (1 << 8)
-#define DWC2_HAINTMSK_CH8_OFFSET 8
-#define DWC2_HAINTMSK_CH9 (1 << 9)
-#define DWC2_HAINTMSK_CH9_OFFSET 9
-#define DWC2_HAINTMSK_CH10 (1 << 10)
-#define DWC2_HAINTMSK_CH10_OFFSET 10
-#define DWC2_HAINTMSK_CH11 (1 << 11)
-#define DWC2_HAINTMSK_CH11_OFFSET 11
-#define DWC2_HAINTMSK_CH12 (1 << 12)
-#define DWC2_HAINTMSK_CH12_OFFSET 12
-#define DWC2_HAINTMSK_CH13 (1 << 13)
-#define DWC2_HAINTMSK_CH13_OFFSET 13
-#define DWC2_HAINTMSK_CH14 (1 << 14)
-#define DWC2_HAINTMSK_CH14_OFFSET 14
-#define DWC2_HAINTMSK_CH15 (1 << 15)
-#define DWC2_HAINTMSK_CH15_OFFSET 15
-#define DWC2_HAINTMSK_CHINT_MASK 0xffff
-#define DWC2_HAINTMSK_CHINT_OFFSET 0
-#define DWC2_HCCHAR_MPS_MASK (0x7FF << 0)
-#define DWC2_HCCHAR_MPS_OFFSET 0
-#define DWC2_HCCHAR_EPNUM_MASK (0xF << 11)
-#define DWC2_HCCHAR_EPNUM_OFFSET 11
-#define DWC2_HCCHAR_EPDIR (1 << 15)
-#define DWC2_HCCHAR_EPDIR_OFFSET 15
-#define DWC2_HCCHAR_LSPDDEV (1 << 17)
-#define DWC2_HCCHAR_LSPDDEV_OFFSET 17
-#define DWC2_HCCHAR_EPTYPE_CONTROL 0
-#define DWC2_HCCHAR_EPTYPE_ISOC 1
-#define DWC2_HCCHAR_EPTYPE_BULK 2
-#define DWC2_HCCHAR_EPTYPE_INTR 3
-#define DWC2_HCCHAR_EPTYPE_MASK (0x3 << 18)
-#define DWC2_HCCHAR_EPTYPE_OFFSET 18
-#define DWC2_HCCHAR_MULTICNT_MASK (0x3 << 20)
-#define DWC2_HCCHAR_MULTICNT_OFFSET 20
-#define DWC2_HCCHAR_DEVADDR_MASK (0x7F << 22)
-#define DWC2_HCCHAR_DEVADDR_OFFSET 22
-#define DWC2_HCCHAR_ODDFRM (1 << 29)
-#define DWC2_HCCHAR_ODDFRM_OFFSET 29
-#define DWC2_HCCHAR_CHDIS (1 << 30)
-#define DWC2_HCCHAR_CHDIS_OFFSET 30
-#define DWC2_HCCHAR_CHEN (1 << 31)
-#define DWC2_HCCHAR_CHEN_OFFSET 31
-#define DWC2_HCSPLT_PRTADDR_MASK (0x7F << 0)
-#define DWC2_HCSPLT_PRTADDR_OFFSET 0
-#define DWC2_HCSPLT_HUBADDR_MASK (0x7F << 7)
-#define DWC2_HCSPLT_HUBADDR_OFFSET 7
-#define DWC2_HCSPLT_XACTPOS_MASK (0x3 << 14)
-#define DWC2_HCSPLT_XACTPOS_OFFSET 14
-#define DWC2_HCSPLT_COMPSPLT (1 << 16)
-#define DWC2_HCSPLT_COMPSPLT_OFFSET 16
-#define DWC2_HCSPLT_SPLTENA (1 << 31)
-#define DWC2_HCSPLT_SPLTENA_OFFSET 31
-#define DWC2_HCINT_XFERCOMP (1 << 0) // Transfer complete
-#define DWC2_HCINT_XFERCOMP_OFFSET 0
-#define DWC2_HCINT_CHHLTD (1 << 1) // Channel halted
-#define DWC2_HCINT_CHHLTD_OFFSET 1
-#define DWC2_HCINT_AHBERR (1 << 2) // AHB error
-#define DWC2_HCINT_AHBERR_OFFSET 2
-#define DWC2_HCINT_STALL (1 << 3) // Stall response received
-#define DWC2_HCINT_STALL_OFFSET 3
-#define DWC2_HCINT_NAK (1 << 4) // NAK response
-#define DWC2_HCINT_NAK_OFFSET 4
-#define DWC2_HCINT_ACK (1 << 5) // ACK response
-#define DWC2_HCINT_ACK_OFFSET 5
-#define DWC2_HCINT_NYET (1 << 6) // NYET
-#define DWC2_HCINT_NYET_OFFSET 6
-#define DWC2_HCINT_XACTERR (1 << 7) // Transaction Error
-#define DWC2_HCINT_XACTERR_OFFSET 7
-#define DWC2_HCINT_BBLERR (1 << 8) // Babble Error
-#define DWC2_HCINT_BBLERR_OFFSET 8
-#define DWC2_HCINT_FRMOVRUN (1 << 9) // Frame overrun
-#define DWC2_HCINT_FRMOVRUN_OFFSET 9
-#define DWC2_HCINT_DATATGLERR (1 << 10) // Data Toggle
-#define DWC2_HCINT_DATATGLERR_OFFSET 10
-#define DWC2_HCINT_BNA (1 << 11) // Buffer Not Available
-#define DWC2_HCINT_BNA_OFFSET 11
-#define DWC2_HCINT_XCS_XACT (1 << 12) // Excessive Transaction
-#define DWC2_HCINT_XCS_XACT_OFFSET 12
-#define DWC2_HCINT_FRM_LIST_ROLL (1 << 13) // Frame List Rollover
-#define DWC2_HCINT_FRM_LIST_ROLL_OFFSET 13
-#define DWC2_HCINTMSK_XFERCOMPL (1 << 0)
-#define DWC2_HCINTMSK_XFERCOMPL_OFFSET 0
-#define DWC2_HCINTMSK_CHHLTD (1 << 1)
-#define DWC2_HCINTMSK_CHHLTD_OFFSET 1
-#define DWC2_HCINTMSK_AHBERR (1 << 2)
-#define DWC2_HCINTMSK_AHBERR_OFFSET 2
-#define DWC2_HCINTMSK_STALL (1 << 3)
-#define DWC2_HCINTMSK_STALL_OFFSET 3
-#define DWC2_HCINTMSK_NAK (1 << 4)
-#define DWC2_HCINTMSK_NAK_OFFSET 4
-#define DWC2_HCINTMSK_ACK (1 << 5)
-#define DWC2_HCINTMSK_ACK_OFFSET 5
-#define DWC2_HCINTMSK_NYET (1 << 6)
-#define DWC2_HCINTMSK_NYET_OFFSET 6
-#define DWC2_HCINTMSK_XACTERR (1 << 7)
-#define DWC2_HCINTMSK_XACTERR_OFFSET 7
-#define DWC2_HCINTMSK_BBLERR (1 << 8)
-#define DWC2_HCINTMSK_BBLERR_OFFSET 8
-#define DWC2_HCINTMSK_FRMOVRUN (1 << 9)
-#define DWC2_HCINTMSK_FRMOVRUN_OFFSET 9
-#define DWC2_HCINTMSK_DATATGLERR (1 << 10)
-#define DWC2_HCINTMSK_DATATGLERR_OFFSET 10
-#define DWC2_HCINTMSK_BNA (1 << 11)
-#define DWC2_HCINTMSK_BNA_OFFSET 11
-#define DWC2_HCINTMSK_XCS_XACT (1 << 12)
-#define DWC2_HCINTMSK_XCS_XACT_OFFSET 12
-#define DWC2_HCINTMSK_FRM_LIST_ROLL (1 << 13)
-#define DWC2_HCINTMSK_FRM_LIST_ROLL_OFFSET 13
-#define DWC2_HCTSIZ_XFERSIZE_MASK 0x7ffff
-#define DWC2_HCTSIZ_XFERSIZE_OFFSET 0
-#define DWC2_HCTSIZ_SCHINFO_MASK 0xff
-#define DWC2_HCTSIZ_SCHINFO_OFFSET 0
-#define DWC2_HCTSIZ_NTD_MASK (0xff << 8)
-#define DWC2_HCTSIZ_NTD_OFFSET 8
-#define DWC2_HCTSIZ_PKTCNT_MASK (0x3ff << 19)
-#define DWC2_HCTSIZ_PKTCNT_OFFSET 19
-#define DWC2_HCTSIZ_PID_MASK (0x3 << 29)
-#define DWC2_HCTSIZ_PID_OFFSET 29
-#define DWC2_HCTSIZ_DOPNG (1 << 31)
-#define DWC2_HCTSIZ_DOPNG_OFFSET 31
-#define DWC2_HCDMA_CTD_MASK (0xFF << 3)
-#define DWC2_HCDMA_CTD_OFFSET 3
-#define DWC2_HCDMA_DMA_ADDR_MASK (0x1FFFFF << 11)
-#define DWC2_HCDMA_DMA_ADDR_OFFSET 11
-#define DWC2_PCGCCTL_STOPPCLK (1 << 0)
-#define DWC2_PCGCCTL_STOPPCLK_OFFSET 0
-#define DWC2_PCGCCTL_GATEHCLK (1 << 1)
-#define DWC2_PCGCCTL_GATEHCLK_OFFSET 1
-#define DWC2_PCGCCTL_PWRCLMP (1 << 2)
-#define DWC2_PCGCCTL_PWRCLMP_OFFSET 2
-#define DWC2_PCGCCTL_RSTPDWNMODULE (1 << 3)
-#define DWC2_PCGCCTL_RSTPDWNMODULE_OFFSET 3
-#define DWC2_PCGCCTL_PHYSUSPENDED (1 << 4)
-#define DWC2_PCGCCTL_PHYSUSPENDED_OFFSET 4
-#define DWC2_PCGCCTL_ENBL_SLEEP_GATING (1 << 5)
-#define DWC2_PCGCCTL_ENBL_SLEEP_GATING_OFFSET 5
-#define DWC2_PCGCCTL_PHY_IN_SLEEP (1 << 6)
-#define DWC2_PCGCCTL_PHY_IN_SLEEP_OFFSET 6
-#define DWC2_PCGCCTL_DEEP_SLEEP (1 << 7)
-#define DWC2_PCGCCTL_DEEP_SLEEP_OFFSET 7
-#define DWC2_SNPSID_DEVID_VER_2xx (0x4f542 << 12)
-#define DWC2_SNPSID_DEVID_VER_3xx (0x4f543 << 12)
-#define DWC2_SNPSID_DEVID_MASK (0xfffff << 12)
-#define DWC2_SNPSID_DEVID_OFFSET 12
-
-/* Host controller specific */
-#define DWC2_HC_PID_DATA0 0
-#define DWC2_HC_PID_DATA2 1
-#define DWC2_HC_PID_DATA1 2
-#define DWC2_HC_PID_MDATA 3
-#define DWC2_HC_PID_SETUP 3
-
-/* roothub.a masks */
-#define RH_A_NDP (0xff << 0) /* number of downstream ports */
-#define RH_A_PSM (1 << 8) /* power switching mode */
-#define RH_A_NPS (1 << 9) /* no power switching */
-#define RH_A_DT (1 << 10) /* device type (mbz) */
-#define RH_A_OCPM (1 << 11) /* over current protection mode */
-#define RH_A_NOCP (1 << 12) /* no over current protection */
-#define RH_A_POTPGT (0xff << 24) /* power on to power good time */
-
-/* roothub.b masks */
-#define RH_B_DR 0x0000ffff /* device removable flags */
-#define RH_B_PPCM 0xffff0000 /* port power control mask */
-
-#define DWC2_PHY_TYPE_FS 0
-#define DWC2_PHY_TYPE_UTMI 1
-#define DWC2_PHY_TYPE_ULPI 2
-#define CONFIG_DWC2_PHY_TYPE DWC2_PHY_TYPE_UTMI /* PHY type */
-#define CONFIG_DWC2_UTMI_WIDTH 8 /* UTMI bus width (8/16) */
-
-#define DWC2_DMA_BURST_SIZE 32 /* DMA burst len */
-#define DWC2_MAX_CHANNELS 16 /* Max # of EPs */
-#define DWC2_HOST_RX_FIFO_SIZE (516 + DWC2_MAX_CHANNELS)
-#define DWC2_HOST_NPERIO_TX_FIFO_SIZE 0x100 /* nPeriodic TX FIFO */
-#define DWC2_HOST_PERIO_TX_FIFO_SIZE 0x200 /* Periodic TX FIFO */
-#define DWC2_MAX_TRANSFER_SIZE 65535
-#define DWC2_MAX_PACKET_COUNT 511
-
-#define DWC2_HC_CHANNEL 0
-#define DWC2_HC_CHANNEL_ASYNC 1
-#define DWC2_HC_CHANNEL_SYNC 2
-#define DWC2_HC_CHANNEL_BULK 3
-#define DWC2_HC_PORT 0
-
-#define DWC2_STATUS_BUF_SIZE 64
-#define DWC2_DATA_BUF_SIZE (64 * 1024)
-
-
-#define USB_PORT_FEAT_CONNECTION 0
-#define USB_PORT_FEAT_ENABLE 1
-#define USB_PORT_FEAT_SUSPEND 2
-#define USB_PORT_FEAT_OVER_CURRENT 3
-#define USB_PORT_FEAT_RESET 4
-#define USB_PORT_FEAT_POWER 8
-#define USB_PORT_FEAT_LOWSPEED 9
-#define USB_PORT_FEAT_HIGHSPEED 10
-#define USB_PORT_FEAT_C_CONNECTION 16
-#define USB_PORT_FEAT_C_ENABLE 17
-#define USB_PORT_FEAT_C_SUSPEND 18
-#define USB_PORT_FEAT_C_OVER_CURRENT 19
-#define USB_PORT_FEAT_C_RESET 20
-#define USB_PORT_FEAT_TEST 21
-
-#endif /* __DWCHW_H__ */
diff --git a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
deleted file mode 100644
index eb804893..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.c
+++ /dev/null
@@ -1,579 +0,0 @@
-/** @file
- *
- * Copyright (c) 2017, Andrey Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2016, Linaro, Ltd. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-#include <PiDxe.h>
-
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/DxeServicesLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-#include <libfdt.h>
-
-#include <Protocol/RpiFirmware.h>
-
-#include <Guid/Fdt.h>
-
-STATIC VOID *mFdtImage;
-
-STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol;
-
-STATIC
-EFI_STATUS
-FixEthernetAliases (
- VOID
-)
-{
- INTN Aliases;
- CONST CHAR8 *Ethernet;
- CONST CHAR8 *Ethernet0;
- CONST CHAR8 *Alias;
- UINTN CopySize;
- CHAR8 *Copy;
- INTN Retval;
- EFI_STATUS Status;
-
- //
- // Look up the 'ethernet[0]' aliases
- //
- Aliases = fdt_path_offset (mFdtImage, "/aliases");
- if (Aliases < 0) {
- DEBUG ((DEBUG_ERROR, "%a: failed to locate '/aliases'\n", __FUNCTION__));
- return EFI_NOT_FOUND;
- }
- Ethernet = fdt_getprop (mFdtImage, Aliases, "ethernet", NULL);
- Ethernet0 = fdt_getprop (mFdtImage, Aliases, "ethernet0", NULL);
- Alias = Ethernet ? Ethernet : Ethernet0;
- if (!Alias) {
- DEBUG ((DEBUG_ERROR, "%a: failed to locate 'ethernet[0]' alias\n", __FUNCTION__));
- return EFI_NOT_FOUND;
- }
-
- //
- // Create copy for fdt_setprop
- //
- CopySize = AsciiStrSize (Alias);
- Copy = AllocateCopyPool (CopySize, Alias);
- if (!Copy) {
- DEBUG ((DEBUG_ERROR, "%a: failed to copy '%a'\n", __FUNCTION__, Alias));
- return EFI_OUT_OF_RESOURCES;
- }
-
- //
- // Create missing aliases
- //
- Status = EFI_SUCCESS;
- if (!Ethernet) {
- Retval = fdt_setprop (mFdtImage, Aliases, "ethernet", Copy, CopySize);
- if (Retval != 0) {
- Status = EFI_NOT_FOUND;
- DEBUG ((DEBUG_ERROR, "%a: failed to create 'ethernet' alias (%d)\n",
- __FUNCTION__, Retval));
- }
- DEBUG ((DEBUG_INFO, "%a: created 'ethernet' alias '%a'\n", __FUNCTION__, Copy));
- }
- if (!Ethernet0) {
- Retval = fdt_setprop (mFdtImage, Aliases, "ethernet0", Copy, CopySize);
- if (Retval != 0) {
- Status = EFI_NOT_FOUND;
- DEBUG ((DEBUG_ERROR, "%a: failed to create 'ethernet0' alias (%d)\n",
- __FUNCTION__, Retval));
- }
- DEBUG ((DEBUG_INFO, "%a: created 'ethernet0' alias '%a'\n", __FUNCTION__, Copy));
- }
-
- FreePool (Copy);
- return Status;
-}
-
-STATIC
-EFI_STATUS
-UpdateMacAddress (
- VOID
- )
-{
- INTN Node;
- INTN Retval;
- EFI_STATUS Status;
- UINT8 MacAddress[6];
-
- //
- // Locate the node that the 'ethernet' alias refers to
- //
- Node = fdt_path_offset (mFdtImage, "ethernet");
- if (Node < 0) {
- DEBUG ((DEBUG_ERROR, "%a: failed to locate 'ethernet' alias\n", __FUNCTION__));
- return EFI_NOT_FOUND;
- }
-
- //
- // Get the MAC address from the firmware
- //
- Status = mFwProtocol->GetMacAddress (MacAddress);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to retrieve MAC address\n", __FUNCTION__));
- return Status;
- }
-
- Retval = fdt_setprop (mFdtImage, Node, "mac-address", MacAddress,
- sizeof MacAddress);
- if (Retval != 0) {
- DEBUG ((DEBUG_ERROR, "%a: failed to create 'mac-address' property (%d)\n",
- __FUNCTION__, Retval));
- return EFI_NOT_FOUND;
- }
-
- DEBUG ((DEBUG_INFO, "%a: setting MAC address to %02x:%02x:%02x:%02x:%02x:%02x\n",
- __FUNCTION__, MacAddress[0], MacAddress[1], MacAddress[2], MacAddress[3],
- MacAddress[4], MacAddress[5]));
- return EFI_SUCCESS;
-}
-
-//
-// Add "bcm2835-usb" to the USB compatible property list, if not present.
-// Required because some Linux kernels can't handle USB devices otherwise.
-//
-STATIC
-EFI_STATUS
-AddUsbCompatibleProperty (
- VOID
- )
-{
- CONST CHAR8 Prop[] = "brcm,bcm2708-usb";
- CONST CHAR8 NewProp[] = "brcm,bcm2835-usb";
- CONST CHAR8 *List;
- CHAR8 *NewList;
- INT32 ListSize;
- INTN Node;
- INTN Retval;
-
- // Locate the node that the 'usb' alias refers to
- Node = fdt_path_offset (mFdtImage, "usb");
- if (Node < 0) {
- DEBUG ((DEBUG_ERROR, "%a: failed to locate 'usb' alias\n", __FUNCTION__));
- return EFI_NOT_FOUND;
- }
-
- // Get the property list. This is a list of NUL terminated strings.
- List = fdt_getprop (mFdtImage, Node, "compatible", &ListSize);
- if (List == NULL) {
- DEBUG ((DEBUG_ERROR, "%a: failed to locate properties\n", __FUNCTION__));
- return EFI_NOT_FOUND;
- }
-
- // Check if the compatible value we plan to add is already present
- if (fdt_stringlist_contains (List, ListSize, NewProp)) {
- DEBUG ((DEBUG_INFO, "%a: property '%a' is already set.\n",
- __FUNCTION__, NewProp));
- return EFI_SUCCESS;
- }
-
- // Make sure the compatible device is what we expect
- if (!fdt_stringlist_contains (List, ListSize, Prop)) {
- DEBUG ((DEBUG_ERROR, "%a: property '%a' is missing!\n",
- __FUNCTION__, Prop));
- return EFI_NOT_FOUND;
- }
-
- // Add the new NUL terminated entry to our list
- DEBUG ((DEBUG_INFO, "%a: adding '%a' to the properties\n",
- __FUNCTION__, NewProp));
-
- NewList = AllocatePool (ListSize + sizeof (NewProp));
- if (NewList == NULL) {
- DEBUG ((DEBUG_ERROR, "%a: failed to allocate memory\n", __FUNCTION__));
- return EFI_OUT_OF_RESOURCES;;
- }
- CopyMem (NewList, List, ListSize);
- CopyMem (&NewList[ListSize], NewProp, sizeof (NewProp));
-
- Retval = fdt_setprop (mFdtImage, Node, "compatible", NewList,
- ListSize + sizeof (NewProp));
- FreePool (NewList);
- if (Retval != 0) {
- DEBUG ((DEBUG_ERROR, "%a: failed to update properties (%d)\n",
- __FUNCTION__, Retval));
- return EFI_NOT_FOUND;
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-CleanMemoryNodes (
- VOID
- )
-{
- INTN Node;
- INT32 Retval;
-
- Node = fdt_path_offset (mFdtImage, "/memory");
- if (Node < 0) {
- return EFI_SUCCESS;
- }
-
- /*
- * Remove bogus memory nodes which can make the booted
- * OS go crazy and ignore the UEFI map.
- */
- DEBUG ((DEBUG_INFO, "Removing bogus /memory\n"));
- Retval = fdt_del_node (mFdtImage, Node);
- if (Retval != 0) {
- DEBUG ((DEBUG_ERROR, "Failed to remove /memory\n"));
- return EFI_NOT_FOUND;
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-SanitizePSCI (
- VOID
- )
-{
- INTN Node;
- INTN Root;
- INT32 Retval;
-
- Root = fdt_path_offset (mFdtImage, "/");
- ASSERT (Root >= 0);
- if (Root < 0) {
- return EFI_NOT_FOUND;
- }
-
- Node = fdt_path_offset (mFdtImage, "/psci");
- if (Node < 0) {
- Node = fdt_add_subnode (mFdtImage, Root, "psci");
- }
-
- ASSERT (Node >= 0);
- if (Node < 0) {
- DEBUG ((DEBUG_ERROR, "Couldn't find/create /psci\n"));
- return EFI_NOT_FOUND;
- }
-
- Retval = fdt_setprop_string (mFdtImage, Node, "compatible", "arm,psci-1.0");
- if (Retval != 0) {
- DEBUG ((DEBUG_ERROR, "Couldn't set /psci compatible property\n"));
- return EFI_NOT_FOUND;
- }
-
- Retval = fdt_setprop_string (mFdtImage, Node, "method", "smc");
- if (Retval != 0) {
- DEBUG ((DEBUG_ERROR, "Couldn't set /psci method property\n"));
- return EFI_NOT_FOUND;
- }
-
- Root = fdt_path_offset (mFdtImage, "/cpus");
- if (Root < 0) {
- DEBUG ((DEBUG_ERROR, "No CPUs to update with PSCI enable-method?\n"));
- return EFI_NOT_FOUND;
- }
-
- Node = fdt_first_subnode (mFdtImage, Root);
- while (Node >= 0) {
- if (fdt_setprop_string (mFdtImage, Node, "enable-method", "psci") != 0) {
- DEBUG ((DEBUG_ERROR, "Failed to update enable-method for a CPU\n"));
- return EFI_NOT_FOUND;
- }
-
- fdt_delprop (mFdtImage, Node, "cpu-release-addr");
- Node = fdt_next_subnode (mFdtImage, Node);
- }
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-CleanSimpleFramebuffer (
- VOID
- )
-{
- INTN Node;
- INT32 Retval;
-
- /*
- * Should look for nodes by kind and remove aliases
- * by matching against device.
- */
- Node = fdt_path_offset (mFdtImage, "display0");
- if (Node < 0) {
- return EFI_SUCCESS;
- }
-
- /*
- * Remove bogus GPU-injected simple-framebuffer, which
- * doesn't reflect the framebuffer built by UEFI.
- */
- DEBUG ((DEBUG_INFO, "Removing bogus display0\n"));
- Retval = fdt_del_node (mFdtImage, Node);
- if (Retval != 0) {
- DEBUG ((DEBUG_ERROR, "Failed to remove display0\n"));
- return EFI_NOT_FOUND;
- }
-
- Node = fdt_path_offset (mFdtImage, "/aliases");
- if (Node < 0) {
- DEBUG ((DEBUG_ERROR, "Couldn't find /aliases to remove display0\n"));
- return EFI_NOT_FOUND;
- }
-
- Retval = fdt_delprop (mFdtImage, Node, "display0");
- if (Retval != 0) {
- DEBUG ((DEBUG_ERROR, "Failed to remove display0 alias\n"));
- return EFI_NOT_FOUND;
- }
-
- return EFI_SUCCESS;
-}
-
-#define MAX_CMDLINE_SIZE 512
-
-STATIC
-EFI_STATUS
-UpdateBootArgs (
- VOID
- )
-{
- INTN Node;
- INTN Retval;
- EFI_STATUS Status;
- CHAR8 *CommandLine;
-
- //
- // Locate the /chosen node
- //
- Node = fdt_path_offset (mFdtImage, "/chosen");
- if (Node < 0) {
- DEBUG ((DEBUG_ERROR, "%a: failed to locate /chosen node\n", __FUNCTION__));
- return EFI_NOT_FOUND;
- }
-
- //
- // If /chosen/bootargs already exists, we want to add a space character
- // before adding the firmware supplied arguments. However, the RpiFirmware
- // protocol expects a 32-bit aligned buffer. So let's allocate 4 bytes of
- // slack, and skip the first 3 when passing this buffer into libfdt.
- //
- CommandLine = AllocatePool (MAX_CMDLINE_SIZE) + 4;
- if (!CommandLine) {
- DEBUG ((DEBUG_ERROR, "%a: failed to allocate memory\n", __FUNCTION__));
- return EFI_OUT_OF_RESOURCES;
- }
-
- //
- // Get the command line from the firmware
- //
- Status = mFwProtocol->GetCommandLine (MAX_CMDLINE_SIZE, CommandLine + 4);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to retrieve command line\n", __FUNCTION__));
- return Status;
- }
-
- if (AsciiStrLen (CommandLine + 4) == 0) {
- DEBUG ((DEBUG_INFO, "%a: empty command line received\n", __FUNCTION__));
- return EFI_SUCCESS;
- }
-
- CommandLine[3] = ' ';
-
- Retval = fdt_appendprop_string (mFdtImage, Node, "bootargs", &CommandLine[3]);
- if (Retval != 0) {
- DEBUG ((DEBUG_ERROR, "%a: failed to set /chosen/bootargs property (%d)\n",
- __FUNCTION__, Retval));
- }
-
- DEBUG_CODE_BEGIN ();
- CONST CHAR8 *Prop;
- INT32 Length;
- INT32 Index;
-
- Node = fdt_path_offset (mFdtImage, "/chosen");
- ASSERT (Node >= 0);
-
- Prop = fdt_getprop (mFdtImage, Node, "bootargs", &Length);
- ASSERT (Prop != NULL);
-
- DEBUG ((DEBUG_INFO, "Command line set from firmware (length %d):\n'", Length));
-
- for (Index = 0; Index < Length; Index++, Prop++) {
- if (*Prop == '\0') {
- continue;
- }
- DEBUG ((DEBUG_INFO, "%c", *Prop));
- }
-
- DEBUG ((DEBUG_INFO, "'\n"));
- DEBUG_CODE_END ();
-
- FreePool (CommandLine - 4);
- return EFI_SUCCESS;
-}
-
-
-/**
- @param ImageHandle of the loaded driver
- @param SystemTable Pointer to the System Table
-
- @retval EFI_SUCCESS Protocol registered
- @retval EFI_OUT_OF_RESOURCES Cannot allocate protocol data structure
- @retval EFI_DEVICE_ERROR Hardware problems
-
-**/
-EFI_STATUS
-EFIAPI
-FdtDxeInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- EFI_GUID *FdtGuid;
- VOID *FdtImage;
- UINTN FdtSize;
- INT32 Retval;
- UINT32 BoardRevision;
- BOOLEAN Internal;
-
- Status = gBS->LocateProtocol (&gRaspberryPiFirmwareProtocolGuid, NULL,
- (VOID**)&mFwProtocol);
- ASSERT_EFI_ERROR (Status);
-
- Internal = FALSE;
- FdtImage = (VOID*)(UINTN)PcdGet32 (PcdFdtBaseAddress);
- Retval = fdt_check_header (FdtImage);
- if (Retval == 0) {
- /*
- * Have FDT passed via config.txt.
- */
- FdtSize = fdt_totalsize (FdtImage);
- DEBUG ((DEBUG_INFO, "Device Tree passed via config.txt (0x%lx bytes)\n", FdtSize));
- Status = EFI_SUCCESS;
- } else {
- /*
- * Use one of the embedded FDT's.
- */
- Internal = TRUE;
- DEBUG ((DEBUG_INFO, "No/Bad Device Tree found at address 0x%p (%a), "
- "looking up internal one...\n", FdtImage, fdt_strerror (Retval)));
- /*
- * Query the board revision to differentiate between models.
- */
- Status = mFwProtocol->GetModelRevision (&BoardRevision);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Failed to get board type: %r\n", Status));
- DEBUG ((DEBUG_INFO, "Using default internal Device Tree\n"));
- FdtGuid = &gRaspberryPiDefaultFdtGuid;
- } else {
- // www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
- switch ((BoardRevision >> 4) & 0xFF) {
- case 0x08:
- DEBUG ((DEBUG_INFO, "Using Raspberry Pi 3 Model B internal Device Tree\n"));
- FdtGuid = &gRaspberryPi3ModelBFdtGuid;
- break;
- case 0x0D:
- DEBUG ((DEBUG_INFO, "Using Raspberry Pi 3 Model B+ internal Device Tree\n"));
- FdtGuid = &gRaspberryPi3ModelBPlusFdtGuid;
- break;
- case 0x11:
- DEBUG ((DEBUG_INFO, "Using Raspberry Pi 4 Model B internal Device Tree\n"));
- FdtGuid = &gRaspberryPi4ModelBFdtGuid;
- break;
- default:
- DEBUG ((DEBUG_INFO, "Using default internal Device Tree\n"));
- FdtGuid = &gRaspberryPiDefaultFdtGuid;
- break;
- }
- }
- do {
- Status = GetSectionFromAnyFv (FdtGuid, EFI_SECTION_RAW, 0, &FdtImage, &FdtSize);
- if (Status == EFI_SUCCESS) {
- if (fdt_check_header (FdtImage) != 0) {
- Status = EFI_INCOMPATIBLE_VERSION;
- }
- }
- // No retry needed if we are successful or are dealing with the default Fdt.
- if ( (Status == EFI_SUCCESS) ||
- (CompareGuid (FdtGuid, &gRaspberryPiDefaultFdtGuid)) )
- break;
- // Otherwise, try one more time with the default Fdt. An example of this
- // is if we detected a non-default Fdt, that isn't included in the FDF.
- DEBUG ((DEBUG_INFO, "Internal Device Tree was not found for this platform, "
- "falling back to default...\n"));
- FdtGuid = &gRaspberryPiDefaultFdtGuid;
- } while (1);
- }
-
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Failed to locate Device Tree: %r\n", Status));
- return Status;
- }
-
- /*
- * Probably overkill.
- */
- FdtSize += EFI_PAGE_SIZE * 2;
- Status = gBS->AllocatePages (AllocateAnyPages, EfiBootServicesData,
- EFI_SIZE_TO_PAGES (FdtSize), (EFI_PHYSICAL_ADDRESS*)&mFdtImage);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Failed to allocate Device Tree: %r\n", Status));
- return Status;
- }
-
- Retval = fdt_open_into (FdtImage, mFdtImage, FdtSize);
- ASSERT (Retval == 0);
-
- Status = SanitizePSCI ();
- if (EFI_ERROR (Status)) {
- Print (L"Failed to sanitize PSCI: %r\n", Status);
- }
-
- Status = CleanMemoryNodes ();
- if (EFI_ERROR (Status)) {
- Print (L"Failed to clean memory nodes: %r\n", Status);
- }
-
- Status = CleanSimpleFramebuffer ();
- if (EFI_ERROR (Status)) {
- Print (L"Failed to clean frame buffer: %r\n", Status);
- }
-
- Status = FixEthernetAliases ();
- if (EFI_ERROR (Status)) {
- Print (L"Failed to fix ethernet aliases: %r\n", Status);
- }
-
- Status = UpdateMacAddress ();
- if (EFI_ERROR (Status)) {
- Print (L"Failed to update MAC address: %r\n", Status);
- }
-
- Status = AddUsbCompatibleProperty ();
- if (EFI_ERROR (Status)) {
- Print (L"Failed to update USB compatible properties: %r\n", Status);
- }
-
- if (Internal) {
- /*
- * A GPU-provided DTB already has the full command line.
- */
- Status = UpdateBootArgs ();
- if (EFI_ERROR (Status)) {
- Print (L"Failed to update boot arguments: %r\n", Status);
- }
- }
-
- DEBUG ((DEBUG_INFO, "Installed Device Tree at address 0x%p\n", mFdtImage));
- Status = gBS->InstallConfigurationTable (&gFdtTableGuid, mFdtImage);
- ASSERT_EFI_ERROR (Status);
-
- return Status;
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.inf b/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.inf
deleted file mode 100644
index 570b05b6..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/FdtDxe/FdtDxe.inf
+++ /dev/null
@@ -1,50 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2017, Andrei Warkentin <andrey.warkentin@gmail.com>
-# Copyright (c) 2016, Linaro, Ltd. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x0001001A
- BASE_NAME = FdtDxe
- FILE_GUID = 8505280f-109e-437e-9fe4-1aa09c7074d9
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = FdtDxeInitialize
-
-[Sources]
- FdtDxe.c
-
-[Packages]
- EmbeddedPkg/EmbeddedPkg.dec
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- Platform/RaspberryPi/RPi3/RPi3.dec
-
-[LibraryClasses]
- BaseLib
- DebugLib
- DxeServicesLib
- FdtLib
- MemoryAllocationLib
- UefiBootServicesTableLib
- UefiDriverEntryPoint
-
-[Guids]
- gFdtTableGuid
- gRaspberryPi3ModelBFdtGuid
- gRaspberryPi3ModelBPlusFdtGuid
- gRaspberryPi4ModelBFdtGuid
- gRaspberryPiDefaultFdtGuid
-
-[Protocols]
- gRaspberryPiFirmwareProtocolGuid ## CONSUMES
-
-[Depex]
- gRaspberryPiFirmwareProtocolGuid
-
-[FixedPcd]
- gRaspberryPiTokenSpaceGuid.PcdFdtBaseAddress
diff --git a/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/ComponentName.c b/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/ComponentName.c
deleted file mode 100644
index 6a094bfe..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/ComponentName.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/** @file
- *
- * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2006-2016, Intel Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include "GraphicsConsole.h"
-
-//
-// EFI Component Name Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gGraphicsConsoleComponentName = {
- GraphicsConsoleComponentNameGetDriverName,
- GraphicsConsoleComponentNameGetControllerName,
- "eng"
-};
-
-//
-// EFI Component Name 2 Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gGraphicsConsoleComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)GraphicsConsoleComponentNameGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)GraphicsConsoleComponentNameGetControllerName,
- "en"
-};
-
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE mGraphicsConsoleDriverNameTable[] = {
- {
- "eng;en",
- (CHAR16*)L"Graphics Console Driver"
- },
- {
- NULL,
- NULL
- }
-};
-
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mGraphicsConsoleDriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gGraphicsConsoleComponentName)
- );
-}
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-{
- return EFI_UNSUPPORTED;
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/GraphicsConsole.c b/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/GraphicsConsole.c
deleted file mode 100644
index 5e15b59e..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/GraphicsConsole.c
+++ /dev/null
@@ -1,1831 +0,0 @@
-/** @file
- *
- * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2006-2016, Intel Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include "GraphicsConsole.h"
-
-//
-// Graphics Console Device Private Data template
-//
-GRAPHICS_CONSOLE_DEV mGraphicsConsoleDevTemplate = {
- GRAPHICS_CONSOLE_DEV_SIGNATURE,
- (EFI_GRAPHICS_OUTPUT_PROTOCOL*)NULL,
- {
- GraphicsConsoleConOutReset,
- GraphicsConsoleConOutOutputString,
- GraphicsConsoleConOutTestString,
- GraphicsConsoleConOutQueryMode,
- GraphicsConsoleConOutSetMode,
- GraphicsConsoleConOutSetAttribute,
- GraphicsConsoleConOutClearScreen,
- GraphicsConsoleConOutSetCursorPosition,
- GraphicsConsoleConOutEnableCursor,
- (EFI_SIMPLE_TEXT_OUTPUT_MODE*)NULL
- },
- {
- 0,
- -1,
- EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK),
- 0,
- 0,
- TRUE
- },
- (GRAPHICS_CONSOLE_MODE_DATA*)NULL,
- (EFI_GRAPHICS_OUTPUT_BLT_PIXEL*)NULL,
- {
- (EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL*)NULL,
- (EFI_GRAPHICS_OUTPUT_PROTOCOL*)NULL,
- TRUE,
- }
-};
-
-GRAPHICS_CONSOLE_MODE_DATA mGraphicsConsoleModeData[] = {
- {100, 31},
- //
- // New modes can be added here.
- // The last entry is specific for full screen mode.
- //
- {0, 0}
-};
-
-EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
-EFI_HII_FONT_PROTOCOL *mHiiFont;
-EFI_HII_HANDLE mHiiHandle;
-VOID *mHiiRegistration;
-
-EFI_GUID mFontPackageListGuid = { 0xf5f219d3, 0x7006, 0x4648, {0xac, 0x8d, 0xd6, 0x1d, 0xfb, 0x7b, 0xc6, 0xad} };
-
-CHAR16 mCrLfString[3] = { CHAR_CARRIAGE_RETURN, CHAR_LINEFEED, CHAR_NULL };
-
-EFI_GRAPHICS_OUTPUT_BLT_PIXEL mGraphicsEfiColors[16] = {
- //
- // B G R reserved
- //
- {0x00, 0x00, 0x00, 0x00}, // BLACK
- {0x98, 0x00, 0x00, 0x00}, // LIGHTBLUE
- {0x00, 0x98, 0x00, 0x00}, // LIGHGREEN
- {0x98, 0x98, 0x00, 0x00}, // LIGHCYAN
- {0x00, 0x00, 0x98, 0x00}, // LIGHRED
- {0x98, 0x00, 0x98, 0x00}, // MAGENTA
- {0x00, 0x98, 0x98, 0x00}, // BROWN
- {0x98, 0x98, 0x98, 0x00}, // LIGHTGRAY
- {0x30, 0x30, 0x30, 0x00}, // DARKGRAY - BRIGHT BLACK
- {0xff, 0x00, 0x00, 0x00}, // BLUE
- {0x00, 0xff, 0x00, 0x00}, // LIME
- {0xff, 0xff, 0x00, 0x00}, // CYAN
- {0x00, 0x00, 0xff, 0x00}, // RED
- {0xff, 0x00, 0xff, 0x00}, // FUCHSIA
- {0x00, 0xff, 0xff, 0x00}, // YELLOW
- {0xff, 0xff, 0xff, 0x00} // WHITE
-};
-
-EFI_NARROW_GLYPH mCursorGlyph = {
- 0x0000,
- 0x00,
- { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF }
-};
-
-CHAR16 SpaceStr[] = { NARROW_CHAR, ' ', 0 };
-
-EFI_DRIVER_BINDING_PROTOCOL gGraphicsConsoleDriverBinding = {
- GraphicsConsoleControllerDriverSupported,
- GraphicsConsoleControllerDriverStart,
- GraphicsConsoleControllerDriverStop,
- 0xa,
- NULL,
- NULL
-};
-
-/**
- Test to see if Graphics Console could be supported on the Controller.
-
- Graphics Console could be supported if Graphics Output Protocol
- exists on the Controller.
-
- @param This Protocol instance pointer.
- @param Controller Handle of device to test.
- @param RemainingDevicePath Optional parameter use to pick a specific child
- device to start.
-
- @retval EFI_SUCCESS This driver supports this device.
- @retval other This driver does not support this device.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleControllerDriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
-
- GraphicsOutput = NULL;
- //
- // Open the IO Abstraction(s) needed to perform the supported test
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiGraphicsOutputProtocolGuid,
- (VOID**)&GraphicsOutput,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- ASSERT (GraphicsOutput != NULL);
-
- //
- // We need to ensure that we do not layer on top of a virtual handle.
- // We need to ensure that the handles produced by the conspliter do not
- // get used.
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- (VOID**)&DevicePath,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (!EFI_ERROR (Status)) {
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- } else {
- goto Error;
- }
-
- //
- // Does Hii Exist? If not, we aren't ready to run
- //
- Status = EfiLocateHiiProtocol ();
-
- //
- // Close the I/O Abstraction(s) used to perform the supported test
- //
-Error:
- gBS->CloseProtocol (
- Controller,
- &gEfiGraphicsOutputProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- return Status;
-}
-
-/**
- Initialize all the text modes which the graphics console supports.
-
- It returns information for available text modes that the graphics can support.
-
- @param[in] HorizontalResolution The size of video screen in pixels in the X dimension.
- @param[in] VerticalResolution The size of video screen in pixels in the Y dimension.
- @param[in] GopModeNumber The graphics mode number which graphis console is based on.
- @param[out] TextModeCount The total number of text modes that graphics console supports.
- @param[out] TextModeData The buffer to the text modes column and row information.
- Caller is responsible to free it when it's non-NULL.
-
- @retval EFI_SUCCESS The supporting mode information is returned.
- @retval EFI_INVALID_PARAMETER The parameters are invalid.
-
-**/
-EFI_STATUS
-InitializeGraphicsConsoleTextMode (
- IN UINT32 HorizontalResolution,
- IN UINT32 VerticalResolution,
- IN UINT32 GopModeNumber,
- OUT UINTN *TextModeCount,
- OUT GRAPHICS_CONSOLE_MODE_DATA **TextModeData
- )
-{
- UINTN Index;
- UINTN Count;
- GRAPHICS_CONSOLE_MODE_DATA *ModeBuffer;
- GRAPHICS_CONSOLE_MODE_DATA *NewModeBuffer;
- UINTN ValidCount;
- UINTN ValidIndex;
- UINTN MaxColumns;
- UINTN MaxRows;
-
- if ((TextModeCount == NULL) || (TextModeData == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- Count = sizeof (mGraphicsConsoleModeData) / sizeof (GRAPHICS_CONSOLE_MODE_DATA);
-
- //
- // Compute the maximum number of text Rows and Columns that this current graphics mode can support.
- // To make graphics console work well, MaxColumns and MaxRows should not be zero.
- //
- MaxColumns = HorizontalResolution / EFI_GLYPH_WIDTH;
- MaxRows = VerticalResolution / EFI_GLYPH_HEIGHT;
-
- //
- // According to UEFI spec, all output devices support at least 80x25 text mode.
- //
- ASSERT ((MaxColumns >= 80) && (MaxRows >= 25));
-
- //
- // Add full screen mode to the last entry.
- //
- mGraphicsConsoleModeData[Count - 1].Columns = MaxColumns;
- mGraphicsConsoleModeData[Count - 1].Rows = MaxRows;
-
- //
- // Get defined mode buffer pointer.
- //
- ModeBuffer = mGraphicsConsoleModeData;
-
- //
- // Here we make sure that the final mode exposed does not include the duplicated modes,
- // and does not include the invalid modes which exceed the max column and row.
- // Reserve 2 modes for 80x25, 80x50 of graphics console.
- //
- NewModeBuffer = AllocateZeroPool (sizeof (GRAPHICS_CONSOLE_MODE_DATA) * (Count + 2));
- ASSERT (NewModeBuffer != NULL);
-
- //
- // Mode 0 and mode 1 is for 80x25, 80x50 according to UEFI spec.
- //
- ValidCount = 0;
-
- NewModeBuffer[ValidCount].Columns = 80;
- NewModeBuffer[ValidCount].Rows = 25;
- NewModeBuffer[ValidCount].GopWidth = HorizontalResolution;
- NewModeBuffer[ValidCount].GopHeight = VerticalResolution;
- NewModeBuffer[ValidCount].GopModeNumber = GopModeNumber;
- NewModeBuffer[ValidCount].DeltaX = (HorizontalResolution - (NewModeBuffer[ValidCount].Columns * EFI_GLYPH_WIDTH)) >> 1;
- NewModeBuffer[ValidCount].DeltaY = (VerticalResolution - (NewModeBuffer[ValidCount].Rows * EFI_GLYPH_HEIGHT)) >> 1;
- ValidCount++;
-
- if ((MaxColumns >= 80) && (MaxRows >= 50)) {
- NewModeBuffer[ValidCount].Columns = 80;
- NewModeBuffer[ValidCount].Rows = 50;
- NewModeBuffer[ValidCount].DeltaX = (HorizontalResolution - (80 * EFI_GLYPH_WIDTH)) >> 1;
- NewModeBuffer[ValidCount].DeltaY = (VerticalResolution - (50 * EFI_GLYPH_HEIGHT)) >> 1;
- }
- NewModeBuffer[ValidCount].GopWidth = HorizontalResolution;
- NewModeBuffer[ValidCount].GopHeight = VerticalResolution;
- NewModeBuffer[ValidCount].GopModeNumber = GopModeNumber;
- ValidCount++;
-
- //
- // Start from mode 2 to put the valid mode other than 80x25 and 80x50 in the output mode buffer.
- //
- for (Index = 0; Index < Count; Index++) {
- if ((ModeBuffer[Index].Columns == 0) || (ModeBuffer[Index].Rows == 0) ||
- (ModeBuffer[Index].Columns > MaxColumns) || (ModeBuffer[Index].Rows > MaxRows)) {
- //
- // Skip the pre-defined mode which is invalid or exceeds the max column and row.
- //
- continue;
- }
- for (ValidIndex = 0; ValidIndex < ValidCount; ValidIndex++) {
- if ((ModeBuffer[Index].Columns == NewModeBuffer[ValidIndex].Columns) &&
- (ModeBuffer[Index].Rows == NewModeBuffer[ValidIndex].Rows)) {
- //
- // Skip the duplicated mode.
- //
- break;
- }
- }
- if (ValidIndex == ValidCount) {
- NewModeBuffer[ValidCount].Columns = ModeBuffer[Index].Columns;
- NewModeBuffer[ValidCount].Rows = ModeBuffer[Index].Rows;
- NewModeBuffer[ValidCount].GopWidth = HorizontalResolution;
- NewModeBuffer[ValidCount].GopHeight = VerticalResolution;
- NewModeBuffer[ValidCount].GopModeNumber = GopModeNumber;
- NewModeBuffer[ValidCount].DeltaX = (HorizontalResolution - (NewModeBuffer[ValidCount].Columns * EFI_GLYPH_WIDTH)) >> 1;
- NewModeBuffer[ValidCount].DeltaY = (VerticalResolution - (NewModeBuffer[ValidCount].Rows * EFI_GLYPH_HEIGHT)) >> 1;
- ValidCount++;
- }
- }
-
- DEBUG_CODE (
- for (Index = 0; Index < ValidCount; Index++) {
- DEBUG ((DEBUG_INFO, "Graphics - Mode %d, Column = %d, Row = %d\n",
- Index, NewModeBuffer[Index].Columns, NewModeBuffer[Index].Rows));
- }
- );
-
- //
- // Return valid mode count and mode information buffer.
- //
- *TextModeCount = ValidCount;
- *TextModeData = NewModeBuffer;
- return EFI_SUCCESS;
-}
-
-/**
- Start this driver on Controller by opening Graphics Output Protocol,
- and installing Simple Text Out protocol on Controller.
-
- @param This Protocol instance pointer.
- @param Controller Handle of device to bind driver to
- @param RemainingDevicePath Optional parameter use to pick a specific child
- device to start.
-
- @retval EFI_SUCCESS This driver is added to Controller.
- @retval other This driver does not support this device.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleControllerDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- GRAPHICS_CONSOLE_DEV *Private;
- UINT32 HorizontalResolution;
- UINT32 VerticalResolution;
- UINT32 ModeIndex;
- UINTN MaxMode;
- UINT32 ModeNumber;
- EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode;
- UINTN SizeOfInfo;
- EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
-
- ModeNumber = 0;
-
- //
- // Initialize the Graphics Console device instance
- //
- Private = AllocateCopyPool (
- sizeof (GRAPHICS_CONSOLE_DEV),
- &mGraphicsConsoleDevTemplate
- );
- if (Private == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Private->SimpleTextOutput.Mode = &(Private->SimpleTextOutputMode);
-
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiGraphicsOutputProtocolGuid,
- (VOID**)&Private->GraphicsOutput,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- goto Error;
- }
-
- Private->ExtendedTextOutput.TextOut = &(Private->SimpleTextOutput);
- Private->ExtendedTextOutput.GraphicsOutput = Private->GraphicsOutput;
-
- HorizontalResolution = PcdGet32 (PcdVideoHorizontalResolution);
- VerticalResolution = PcdGet32 (PcdVideoVerticalResolution);
-
- ASSERT (Private->GraphicsOutput != NULL);
- //
- // The console is build on top of Graphics Output Protocol, find the mode number
- // for the user-defined mode; if there are multiple video devices,
- // graphic console driver will set all the video devices to the same mode.
- //
- if ((HorizontalResolution == 0x0) || (VerticalResolution == 0x0)) {
- //
- // Find the highest resolution which GOP supports.
- //
- MaxMode = Private->GraphicsOutput->Mode->MaxMode;
-
- for (ModeIndex = 0; ModeIndex < MaxMode; ModeIndex++) {
- Status = Private->GraphicsOutput->QueryMode (
- Private->GraphicsOutput,
- ModeIndex,
- &SizeOfInfo,
- &Info
- );
- if (!EFI_ERROR (Status)) {
- if ((Info->HorizontalResolution > HorizontalResolution) ||
- ((Info->HorizontalResolution == HorizontalResolution) && (Info->VerticalResolution > VerticalResolution))) {
- HorizontalResolution = Info->HorizontalResolution;
- VerticalResolution = Info->VerticalResolution;
- ModeNumber = ModeIndex;
- }
- FreePool (Info);
- }
- }
- if ((HorizontalResolution == 0x0) || (VerticalResolution == 0x0)) {
- Status = EFI_UNSUPPORTED;
- goto Error;
- }
- } else {
- //
- // Use user-defined resolution
- //
- Status = CheckModeSupported (
- Private->GraphicsOutput,
- HorizontalResolution,
- VerticalResolution,
- &ModeNumber
- );
- if (EFI_ERROR (Status)) {
- //
- // if not supporting current mode, try 800x600 which is required by UEFI/EFI spec.
- //
- HorizontalResolution = 800;
- VerticalResolution = 600;
- Status = CheckModeSupported (
- Private->GraphicsOutput,
- HorizontalResolution,
- VerticalResolution,
- &ModeNumber
- );
- Mode = Private->GraphicsOutput->Mode;
- if (EFI_ERROR (Status) && Mode->MaxMode != 0) {
- //
- // Set default mode failed or device don't support default mode, then get the current mode information.
- //
- HorizontalResolution = Mode->Info->HorizontalResolution;
- VerticalResolution = Mode->Info->VerticalResolution;
- ModeNumber = Mode->Mode;
- }
- }
- }
- if (ModeNumber != Private->GraphicsOutput->Mode->Mode) {
- //
- // Current graphics mode is not set or is not set to the mode which we has found,
- // set the new graphic mode.
- //
- Status = Private->GraphicsOutput->SetMode (Private->GraphicsOutput, ModeNumber);
- if (EFI_ERROR (Status)) {
- //
- // The mode set operation failed
- //
- goto Error;
- }
- }
-
- DEBUG ((DEBUG_INFO, "GraphicsConsole video resolution %d x %d\n", HorizontalResolution, VerticalResolution));
-
- //
- // Initialize the mode which GraphicsConsole supports.
- //
- Status = InitializeGraphicsConsoleTextMode (
- HorizontalResolution,
- VerticalResolution,
- ModeNumber,
- &MaxMode,
- &Private->ModeData
- );
-
- if (EFI_ERROR (Status)) {
- goto Error;
- }
-
- //
- // Update the maximum number of modes
- //
- Private->SimpleTextOutputMode.MaxMode = (INT32)MaxMode;
-
- DEBUG_CODE_BEGIN ();
- Status = GraphicsConsoleConOutSetMode (&Private->SimpleTextOutput, 0);
- if (EFI_ERROR (Status)) {
- goto Error;
- }
- Status = GraphicsConsoleConOutOutputString (&Private->SimpleTextOutput,
- (CHAR16*)L"Graphics Console Started\n\r");
- if (EFI_ERROR (Status)) {
- goto Error;
- }
- DEBUG_CODE_END ();
-
- //
- // Install protocol interfaces for the Graphics Console device.
- //
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Controller,
- &gEfiSimpleTextOutProtocolGuid,
- &Private->SimpleTextOutput,
- &gExtendedTextOutputProtocolGuid,
- &Private->ExtendedTextOutput,
- NULL
- );
-
-Error:
- if (EFI_ERROR (Status)) {
- //
- // Close GOP.
- //
- gBS->CloseProtocol (
- Controller,
- &gEfiGraphicsOutputProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- if (Private->LineBuffer != NULL) {
- FreePool (Private->LineBuffer);
- }
-
- if (Private->ModeData != NULL) {
- FreePool (Private->ModeData);
- }
-
- //
- // Free private data
- //
- FreePool (Private);
- }
-
- return Status;
-}
-
-/**
- Stop this driver on Controller by removing Simple Text Out protocol
- and closing the Graphics Output Protocol on Controller.
-
-
- @param This Protocol instance pointer.
- @param Controller Handle of device to stop driver on
- @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
- children is zero stop the entire bus driver.
- @param ChildHandleBuffer List of Child Handles to Stop.
-
- @retval EFI_SUCCESS This driver is removed Controller.
- @retval EFI_NOT_STARTED Simple Text Out protocol could not be found the
- Controller.
- @retval other This driver was not removed from this device.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleControllerDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
-{
- EFI_STATUS Status;
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOutput;
- GRAPHICS_CONSOLE_DEV *Private;
-
- Status = gBS->OpenProtocol (
- Controller,
- &gEfiSimpleTextOutProtocolGuid,
- (VOID**)&SimpleTextOutput,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_GET_PROTOCOL
- );
- if (EFI_ERROR (Status)) {
- return EFI_NOT_STARTED;
- }
-
- Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (SimpleTextOutput);
-
- Status = gBS->UninstallMultipleProtocolInterfaces (
- Controller,
- &gEfiSimpleTextOutProtocolGuid,
- &Private->SimpleTextOutput,
- &gExtendedTextOutputProtocolGuid,
- &Private->ExtendedTextOutput,
- NULL
- );
-
- if (!EFI_ERROR (Status)) {
- //
- // Close GOP.
- //
- gBS->CloseProtocol (
- Controller,
- &gEfiGraphicsOutputProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- if (Private->LineBuffer != NULL) {
- FreePool (Private->LineBuffer);
- }
-
- if (Private->ModeData != NULL) {
- FreePool (Private->ModeData);
- }
-
- //
- // Free our instance data
- //
- FreePool (Private);
- }
-
- return Status;
-}
-
-/**
- Check if the current specific mode supported the user defined resolution
- for the Graphics Console device based on Graphics Output Protocol.
-
- If yes, set the graphic devcice's current mode to this specific mode.
-
- @param GraphicsOutput Graphics Output Protocol instance pointer.
- @param HorizontalResolution User defined horizontal resolution
- @param VerticalResolution User defined vertical resolution.
- @param CurrentModeNumber Current specific mode to be check.
-
- @retval EFI_SUCCESS The mode is supported.
- @retval EFI_UNSUPPORTED The specific mode is out of range of graphics
- device supported.
- @retval other The specific mode does not support user defined
- resolution or failed to set the current mode to the
- specific mode on graphics device.
-
-**/
-EFI_STATUS
-CheckModeSupported (
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,
- IN UINT32 HorizontalResolution,
- IN UINT32 VerticalResolution,
- OUT UINT32 *CurrentModeNumber
- )
-{
- UINT32 ModeNumber;
- EFI_STATUS Status;
- UINTN SizeOfInfo;
- EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
- UINT32 MaxMode;
-
- Status = EFI_SUCCESS;
- MaxMode = GraphicsOutput->Mode->MaxMode;
-
- for (ModeNumber = 0; ModeNumber < MaxMode; ModeNumber++) {
- Status = GraphicsOutput->QueryMode (
- GraphicsOutput,
- ModeNumber,
- &SizeOfInfo,
- &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);
- }
- }
-
- if (ModeNumber == GraphicsOutput->Mode->MaxMode) {
- Status = EFI_UNSUPPORTED;
- }
-
- *CurrentModeNumber = ModeNumber;
- return Status;
-}
-
-
-/**
- Locate HII Database protocol and HII Font protocol.
-
- @retval EFI_SUCCESS HII Database protocol and HII Font protocol
- are located successfully.
- @return other Failed to locate HII Database protocol or
- HII Font protocol.
-
-**/
-EFI_STATUS
-EfiLocateHiiProtocol (
- VOID
- )
-{
- EFI_STATUS Status;
-
- Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, (VOID**)&mHiiDatabase);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID**)&mHiiFont);
- return Status;
-}
-
-//
-// Body of the STO functions
-//
-
-/**
- Reset the text output device hardware and optionally run diagnostics.
-
- Implements SIMPLE_TEXT_OUTPUT.Reset().
- If ExtendeVerification is TRUE, then perform dependent Graphics Console
- device reset, and set display mode to mode 0.
- If ExtendedVerification is FALSE, only set display mode to mode 0.
-
- @param This Protocol instance pointer.
- @param ExtendedVerification Indicates that the driver may perform a more
- exhaustive verification operation of the device
- during reset.
-
- @retval EFI_SUCCESS The text output device was reset.
- @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and
- could not be reset.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleConOutReset (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- )
-{
- EFI_STATUS Status;
- Status = This->SetMode (This, 0);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- Status = This->SetAttribute (This, EFI_TEXT_ATTR (This->Mode->Attribute & 0x0F, EFI_BACKGROUND_BLACK));
- return Status;
-}
-
-
-/**
- Write a Unicode string to the output device.
-
- Implements SIMPLE_TEXT_OUTPUT.OutputString().
- The Unicode string will be converted to Glyphs and will be
- sent to the Graphics Console.
-
- @param This Protocol instance pointer.
- @param WString The NULL-terminated Unicode string to be displayed
- on the output device(s). All output devices must
- also support the Unicode drawing defined in this file.
-
- @retval EFI_SUCCESS The string was output to the device.
- @retval EFI_DEVICE_ERROR The device reported an error while attempting to output
- the text.
- @retval EFI_UNSUPPORTED The output device's mode is not currently in a
- defined text mode.
- @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
- characters in the Unicode string could not be
- rendered and were skipped.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleConOutOutputString (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN CHAR16 *WString
- )
-{
- GRAPHICS_CONSOLE_DEV *Private;
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- INTN Mode;
- UINTN MaxColumn;
- UINTN MaxRow;
- UINTN Width;
- UINTN Height;
- UINTN Delta;
- EFI_STATUS Status;
- BOOLEAN Warning;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;
- UINTN DeltaX;
- UINTN DeltaY;
- UINTN Count;
- UINTN Index;
- INT32 OriginAttribute;
- EFI_TPL OldTpl;
-
- if (This->Mode->Mode == -1) {
- //
- // If current mode is not valid, return error.
- //
- return EFI_UNSUPPORTED;
- }
-
- Status = EFI_SUCCESS;
-
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
- //
- // Current mode
- //
- Mode = This->Mode->Mode;
- Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
- GraphicsOutput = Private->GraphicsOutput;
-
- MaxColumn = Private->ModeData[Mode].Columns;
- MaxRow = Private->ModeData[Mode].Rows;
- DeltaX = (UINTN) Private->ModeData[Mode].DeltaX;
- DeltaY = (UINTN) Private->ModeData[Mode].DeltaY;
- Width = MaxColumn * EFI_GLYPH_WIDTH;
- Height = (MaxRow - 1) * EFI_GLYPH_HEIGHT;
- Delta = Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL);
-
- //
- // The Attributes won't change when during the time OutputString is called
- //
- GetTextColors (This, &Foreground, &Background);
-
- FlushCursor (This);
-
- Warning = FALSE;
-
- //
- // Backup attribute
- //
- OriginAttribute = This->Mode->Attribute;
-
- while (*WString != L'\0') {
-
- if (*WString == CHAR_BACKSPACE) {
- //
- // If the cursor is at the left edge of the display, then move the cursor
- // one row up.
- //
- if (This->Mode->CursorColumn == 0 && This->Mode->CursorRow > 0) {
- This->Mode->CursorRow--;
- This->Mode->CursorColumn = (INT32)(MaxColumn - 1);
- This->OutputString (This, SpaceStr);
- FlushCursor (This);
- This->Mode->CursorRow--;
- This->Mode->CursorColumn = (INT32)(MaxColumn - 1);
- } else if (This->Mode->CursorColumn > 0) {
- //
- // If the cursor is not at the left edge of the display, then move the cursor
- // left one column.
- //
- This->Mode->CursorColumn--;
- This->OutputString (This, SpaceStr);
- FlushCursor (This);
- This->Mode->CursorColumn--;
- }
-
- WString++;
-
- } else if (*WString == CHAR_LINEFEED) {
- //
- // If the cursor is at the bottom of the display, then scroll the display one
- // row, and do not update the cursor position. Otherwise, move the cursor
- // down one row.
- //
- if (This->Mode->CursorRow == (INT32)(MaxRow - 1)) {
- //
- // Scroll Screen Up One Row
- //
- GraphicsOutput->Blt (
- GraphicsOutput,
- NULL,
- EfiBltVideoToVideo,
- DeltaX,
- DeltaY + EFI_GLYPH_HEIGHT,
- DeltaX,
- DeltaY,
- Width,
- Height,
- Delta
- );
-
- //
- // Print Blank Line at last line
- //
- GraphicsOutput->Blt (
- GraphicsOutput,
- &Background,
- EfiBltVideoFill,
- 0,
- 0,
- DeltaX,
- DeltaY + Height,
- Width,
- EFI_GLYPH_HEIGHT,
- Delta
- );
- } else {
- This->Mode->CursorRow++;
- }
-
- WString++;
-
- } else if (*WString == CHAR_CARRIAGE_RETURN) {
- //
- // Move the cursor to the beginning of the current row.
- //
- This->Mode->CursorColumn = 0;
- WString++;
-
- } else if (*WString == WIDE_CHAR) {
-
- This->Mode->Attribute |= EFI_WIDE_ATTRIBUTE;
- WString++;
-
- } else if (*WString == NARROW_CHAR) {
-
- This->Mode->Attribute &= (~(UINT32)EFI_WIDE_ATTRIBUTE);
- WString++;
-
- } else {
- //
- // Print the character at the current cursor position and move the cursor
- // right one column. If this moves the cursor past the right edge of the
- // display, then the line should wrap to the beginning of the next line. This
- // is equivalent to inserting a CR and an LF. Note that if the cursor is at the
- // bottom of the display, and the line wraps, then the display will be scrolled
- // one line.
- // If wide char is going to be displayed, need to display one character at a time
- // Or, need to know the display length of a certain string.
- //
- // Index is used to determine how many character width units (wide = 2, narrow = 1)
- // Count is used to determine how many characters are used regardless of their attributes
- //
- for (Count = 0, Index = 0; (This->Mode->CursorColumn + Index) < MaxColumn; Count++, Index++) {
- if (WString[Count] == CHAR_NULL ||
- WString[Count] == CHAR_BACKSPACE ||
- WString[Count] == CHAR_LINEFEED ||
- WString[Count] == CHAR_CARRIAGE_RETURN ||
- WString[Count] == WIDE_CHAR ||
- WString[Count] == NARROW_CHAR) {
- break;
- }
- //
- // Is the wide attribute on?
- //
- if ((This->Mode->Attribute & EFI_WIDE_ATTRIBUTE) != 0) {
- //
- // If wide, add one more width unit than normal since we are going to increment at the end of the for loop
- //
- Index++;
- //
- // This is the end-case where if we are at column 79 and about to print a wide character
- // We should prevent this from happening because we will wrap inappropriately. We should
- // not print this character until the next line.
- //
- if ((This->Mode->CursorColumn + Index + 1) > MaxColumn) {
- Index++;
- break;
- }
- }
- }
-
- Status = DrawUnicodeWeightAtCursorN (This, WString, Count);
- if (EFI_ERROR (Status)) {
- Warning = TRUE;
- }
- //
- // At the end of line, output carriage return and line feed
- //
- WString += Count;
- This->Mode->CursorColumn += (INT32)Index;
- if (This->Mode->CursorColumn > (INT32)MaxColumn) {
- This->Mode->CursorColumn -= 2;
- This->OutputString (This, SpaceStr);
- }
-
- if (This->Mode->CursorColumn >= (INT32)MaxColumn) {
- FlushCursor (This);
- if (!Private->ExtendedTextOutput.AutoWrap) {
- This->Mode->CursorColumn = MaxColumn - 1;
- } else {
- This->OutputString (This, mCrLfString);
- }
- FlushCursor (This);
- }
- }
- }
-
- This->Mode->Attribute = OriginAttribute;
-
- FlushCursor (This);
-
- if (Warning) {
- Status = EFI_WARN_UNKNOWN_GLYPH;
- }
-
- gBS->RestoreTPL (OldTpl);
- return Status;
-
-}
-
-/**
- Verifies that all characters in a Unicode string can be output to the
- target device.
-
- Implements SIMPLE_TEXT_OUTPUT.TestString().
- If one of the characters in the *Wstring is neither valid valid Unicode
- drawing characters, not ASCII code, then this function will return
- EFI_UNSUPPORTED
-
- @param This Protocol instance pointer.
- @param WString The NULL-terminated Unicode string to be examined for the output
- device(s).
-
- @retval EFI_SUCCESS The device(s) are capable of rendering the output string.
- @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be
- rendered by one or more of the output devices mapped
- by the EFI handle.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleConOutTestString (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN CHAR16 *WString
- )
-{
- EFI_STATUS Status;
- UINT16 Count;
-
- EFI_IMAGE_OUTPUT *Blt;
-
- Blt = NULL;
- Count = 0;
-
- while (WString[Count] != 0) {
- Status = mHiiFont->GetGlyph (
- mHiiFont,
- WString[Count],
- NULL,
- &Blt,
- NULL
- );
- if (Blt != NULL) {
- FreePool (Blt);
- Blt = NULL;
- }
- Count++;
-
- if (EFI_ERROR (Status)) {
- return EFI_UNSUPPORTED;
- }
- }
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Returns information for an available text mode that the output device(s)
- supports
-
- Implements SIMPLE_TEXT_OUTPUT.QueryMode().
- It returnes information for an available text mode that the Graphics Console supports.
- In this driver,we only support text mode 80x25, which is defined as mode 0.
-
- @param This Protocol instance pointer.
- @param ModeNumber The mode number to return information on.
- @param Columns The returned columns of the requested mode.
- @param Rows The returned rows of the requested mode.
-
- @retval EFI_SUCCESS The requested mode information is returned.
- @retval EFI_UNSUPPORTED The mode number is not valid.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleConOutQueryMode (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN ModeNumber,
- OUT UINTN *Columns,
- OUT UINTN *Rows
- )
-{
- GRAPHICS_CONSOLE_DEV *Private;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
-
- if (ModeNumber >= (UINTN)This->Mode->MaxMode) {
- return EFI_UNSUPPORTED;
- }
-
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
- Status = EFI_SUCCESS;
-
- Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
-
- *Columns = Private->ModeData[ModeNumber].Columns;
- *Rows = Private->ModeData[ModeNumber].Rows;
-
- if (*Columns <= 0 || *Rows <= 0) {
- Status = EFI_UNSUPPORTED;
- goto Done;
-
- }
-
-Done:
- gBS->RestoreTPL (OldTpl);
- return Status;
-}
-
-
-/**
- Sets the output device(s) to a specified mode.
-
- Implements SIMPLE_TEXT_OUTPUT.SetMode().
- Set the Graphics Console to a specified mode. In this driver, we only support mode 0.
-
- @param This Protocol instance pointer.
- @param ModeNumber The text mode to set.
-
- @retval EFI_SUCCESS The requested text mode is set.
- @retval EFI_DEVICE_ERROR The requested text mode cannot be set because of
- Graphics Console device error.
- @retval EFI_UNSUPPORTED The text mode number is not valid.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleConOutSetMode (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN ModeNumber
- )
-{
- EFI_STATUS Status;
- GRAPHICS_CONSOLE_DEV *Private;
- GRAPHICS_CONSOLE_MODE_DATA *ModeData;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *NewLineBuffer;
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_TPL OldTpl;
-
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
- GraphicsOutput = Private->GraphicsOutput;
-
- //
- // Make sure the requested mode number is supported
- //
- if (ModeNumber >= (UINTN)This->Mode->MaxMode) {
- Status = EFI_UNSUPPORTED;
- goto Done;
- }
-
- ModeData = &(Private->ModeData[ModeNumber]);
-
- if (ModeData->Columns <= 0 && ModeData->Rows <= 0) {
- Status = EFI_UNSUPPORTED;
- goto Done;
- }
-
- //
- // If the mode has been set at least one other time, then LineBuffer will not be NULL
- //
- if (Private->LineBuffer != NULL) {
- //
- // If the new mode is the same as the old mode, then just return EFI_SUCCESS
- //
- if ((INT32)ModeNumber == This->Mode->Mode) {
- //
- // Clear the current text window on the current graphics console
- //
- This->ClearScreen (This);
- Status = EFI_SUCCESS;
- goto Done;
- }
- //
- // Otherwise, the size of the text console and/or the GOP mode will
- // be changed, so erase the cursor, and free the LineBuffer for the
- // current mode
- //
- FlushCursor (This);
-
- FreePool (Private->LineBuffer);
- }
-
- //
- // Attempt to allocate a line buffer for the requested mode number
- //
- NewLineBuffer = AllocatePool (sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * ModeData->Columns * EFI_GLYPH_WIDTH * EFI_GLYPH_HEIGHT);
-
- if (NewLineBuffer == NULL) {
- //
- // The new line buffer could not be allocated, so return an error.
- // No changes to the state of the current console have been made, so the current console is still valid
- //
- Status = EFI_OUT_OF_RESOURCES;
- goto Done;
- }
-
- //
- // Assign the current line buffer to the newly allocated line buffer
- //
- Private->LineBuffer = NewLineBuffer;
-
- if (ModeData->GopModeNumber != GraphicsOutput->Mode->Mode) {
- //
- // Either no graphics mode is currently set, or it is set
- // to the wrong resolution, so set the new graphics mode
- //
- Status = GraphicsOutput->SetMode (GraphicsOutput, ModeData->GopModeNumber);
- if (EFI_ERROR (Status)) {
- //
- // The mode set operation failed
- //
- goto Done;
- }
- } else {
- //
- // The current graphics mode is correct, so simply clear the entire display
- //
- Status = GraphicsOutput->Blt (
- GraphicsOutput,
- &mGraphicsEfiColors[0],
- EfiBltVideoFill,
- 0,
- 0,
- 0,
- 0,
- ModeData->GopWidth,
- ModeData->GopHeight,
- 0
- );
- }
-
- //
- // The new mode is valid, so commit the mode change
- //
- This->Mode->Mode = (INT32)ModeNumber;
-
- //
- // Move the text cursor to the upper left hand corner of the display and flush it
- //
- This->Mode->CursorColumn = 0;
- This->Mode->CursorRow = 0;
-
- FlushCursor (This);
-
- Status = EFI_SUCCESS;
-
-Done:
- gBS->RestoreTPL (OldTpl);
- return Status;
-}
-
-
-/**
- Sets the background and foreground colors for the OutputString () and
- ClearScreen () functions.
-
- Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
-
- @param This Protocol instance pointer.
- @param Attribute The attribute to set. Bits 0..3 are the foreground
- color, and bits 4..6 are the background color.
- All other bits are undefined and must be zero.
-
- @retval EFI_SUCCESS The requested attribute is set.
- @retval EFI_DEVICE_ERROR The requested attribute cannot be set due to Graphics Console port error.
- @retval EFI_UNSUPPORTED The attribute requested is not defined.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleConOutSetAttribute (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN Attribute
- )
-{
- EFI_TPL OldTpl;
-
- if ((Attribute | 0x7F) != 0x7F) {
- return EFI_UNSUPPORTED;
- }
-
- if ((INT32)Attribute == This->Mode->Attribute) {
- return EFI_SUCCESS;
- }
-
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- FlushCursor (This);
-
- This->Mode->Attribute = (INT32)Attribute;
-
- FlushCursor (This);
-
- gBS->RestoreTPL (OldTpl);
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Clears the output device(s) display to the currently selected background
- color.
-
- Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
-
- @param This Protocol instance pointer.
-
- @retval EFI_SUCCESS The operation completed successfully.
- @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
- @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleConOutClearScreen (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
- )
-{
- EFI_STATUS Status;
- GRAPHICS_CONSOLE_DEV *Private;
- GRAPHICS_CONSOLE_MODE_DATA *ModeData;
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background;
- EFI_TPL OldTpl;
-
- if (This->Mode->Mode == -1) {
- //
- // If current mode is not valid, return error.
- //
- return EFI_UNSUPPORTED;
- }
-
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
- GraphicsOutput = Private->GraphicsOutput;
- ModeData = &(Private->ModeData[This->Mode->Mode]);
-
- GetTextColors (This, &Foreground, &Background);
- Status = GraphicsOutput->Blt (
- GraphicsOutput,
- &Background,
- EfiBltVideoFill,
- 0,
- 0,
- 0,
- 0,
- ModeData->GopWidth,
- ModeData->GopHeight,
- 0
- );
-
- This->Mode->CursorColumn = 0;
- This->Mode->CursorRow = 0;
-
- FlushCursor (This);
-
- gBS->RestoreTPL (OldTpl);
-
- return Status;
-}
-
-
-/**
- Sets the current coordinates of the cursor position.
-
- Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
-
- @param This Protocol instance pointer.
- @param Column The position to set the cursor to. Must be greater than or
- equal to zero and less than the number of columns and rows
- by QueryMode ().
- @param Row The position to set the cursor to. Must be greater than or
- equal to zero and less than the number of columns and rows
- by QueryMode ().
-
- @retval EFI_SUCCESS The operation completed successfully.
- @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
- @retval EFI_UNSUPPORTED The output device is not in a valid text mode, or the
- cursor position is invalid for the current mode.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleConOutSetCursorPosition (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN Column,
- IN UINTN Row
- )
-{
- GRAPHICS_CONSOLE_DEV *Private;
- GRAPHICS_CONSOLE_MODE_DATA *ModeData;
- EFI_STATUS Status;
- EFI_TPL OldTpl;
-
- if (This->Mode->Mode == -1) {
- //
- // If current mode is not valid, return error.
- //
- return EFI_UNSUPPORTED;
- }
-
- Status = EFI_SUCCESS;
-
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
- ModeData = &(Private->ModeData[This->Mode->Mode]);
-
- if ((Column >= ModeData->Columns) || (Row >= ModeData->Rows)) {
- Status = EFI_UNSUPPORTED;
- goto Done;
- }
-
- if ((This->Mode->CursorColumn == (INT32)Column) && (This->Mode->CursorRow == (INT32)Row)) {
- Status = EFI_SUCCESS;
- goto Done;
- }
-
- FlushCursor (This);
-
- This->Mode->CursorColumn = (INT32)Column;
- This->Mode->CursorRow = (INT32)Row;
-
- FlushCursor (This);
-
-Done:
- gBS->RestoreTPL (OldTpl);
-
- return Status;
-}
-
-
-/**
- Makes the cursor visible or invisible.
-
- Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
-
- @param This Protocol instance pointer.
- @param Visible If TRUE, the cursor is set to be visible, If FALSE,
- the cursor is set to be invisible.
-
- @retval EFI_SUCCESS The operation completed successfully.
- @retval EFI_UNSUPPORTED The output device's mode is not currently in a
- defined text mode.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleConOutEnableCursor (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN BOOLEAN Visible
- )
-{
- EFI_TPL OldTpl;
-
- if (This->Mode->Mode == -1) {
- //
- // If current mode is not valid, return error.
- //
- return EFI_UNSUPPORTED;
- }
-
- OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
-
- FlushCursor (This);
-
- This->Mode->CursorVisible = Visible;
-
- FlushCursor (This);
-
- gBS->RestoreTPL (OldTpl);
- return EFI_SUCCESS;
-}
-
-/**
- Gets Graphics Console devcie's foreground color and background color.
-
- @param This Protocol instance pointer.
- @param Foreground Returned text foreground color.
- @param Background Returned text background color.
-
- @retval EFI_SUCCESS It returned always.
-
-**/
-EFI_STATUS
-GetTextColors (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,
- OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background
- )
-{
- INTN Attribute;
-
- Attribute = This->Mode->Attribute & 0x7F;
-
- *Foreground = mGraphicsEfiColors[Attribute & 0x0f];
- *Background = mGraphicsEfiColors[Attribute >> 4];
-
- return EFI_SUCCESS;
-}
-
-/**
- Draw Unicode string on the Graphics Console device's screen.
-
- @param This Protocol instance pointer.
- @param UnicodeWeight One Unicode string to be displayed.
- @param Count The count of Unicode string.
-
- @retval EFI_OUT_OF_RESOURCES If no memory resource to use.
- @retval EFI_UNSUPPORTED If no Graphics Output Protocol exists.
- @retval EFI_SUCCESS Drawing Unicode string implemented successfully.
-
-**/
-EFI_STATUS
-DrawUnicodeWeightAtCursorN (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN CHAR16 *UnicodeWeight,
- IN UINTN Count
- )
-{
- EFI_STATUS Status;
- GRAPHICS_CONSOLE_DEV *Private;
- EFI_IMAGE_OUTPUT *Blt;
- EFI_STRING String;
- EFI_FONT_DISPLAY_INFO *FontInfo;
-
- Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
- Blt = (EFI_IMAGE_OUTPUT*)AllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));
- if (Blt == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- Blt->Width = (UINT16)(Private->ModeData[This->Mode->Mode].GopWidth);
- Blt->Height = (UINT16)(Private->ModeData[This->Mode->Mode].GopHeight);
-
- String = AllocateCopyPool ((Count + 1) * sizeof (CHAR16), UnicodeWeight);
- if (String == NULL) {
- FreePool (Blt);
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // Set the end character
- //
- *(String + Count) = L'\0';
-
- FontInfo = (EFI_FONT_DISPLAY_INFO*)AllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO));
- if (FontInfo == NULL) {
- FreePool (Blt);
- FreePool (String);
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // Get current foreground and background colors.
- //
- GetTextColors (This, &FontInfo->ForegroundColor, &FontInfo->BackgroundColor);
-
- //
- // If Graphics Output protocol exists, using HII Font protocol to draw.
- //
- Blt->Image.Screen = Private->GraphicsOutput;
-
- Status = mHiiFont->StringToImage (
- mHiiFont,
- EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_DIRECT_TO_SCREEN | EFI_HII_IGNORE_LINE_BREAK,
- String,
- FontInfo,
- &Blt,
- This->Mode->CursorColumn * EFI_GLYPH_WIDTH + Private->ModeData[This->Mode->Mode].DeltaX,
- This->Mode->CursorRow * EFI_GLYPH_HEIGHT + Private->ModeData[This->Mode->Mode].DeltaY,
- NULL,
- NULL,
- NULL
- );
-
- if (Blt != NULL) {
- FreePool (Blt);
- }
- if (String != NULL) {
- FreePool (String);
- }
- if (FontInfo != NULL) {
- FreePool (FontInfo);
- }
- return Status;
-}
-
-/**
- Flush the cursor on the screen.
-
- If CursorVisible is FALSE, nothing to do and return directly.
- If CursorVisible is TRUE,
- i) If the cursor shows on screen, it will be erased.
- ii) If the cursor does not show on screen, it will be shown.
-
- @param This Protocol instance pointer.
-
- @retval EFI_SUCCESS The cursor is erased successfully.
-
-**/
-EFI_STATUS
-FlushCursor (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
- )
-{
- GRAPHICS_CONSOLE_DEV *Private;
- EFI_SIMPLE_TEXT_OUTPUT_MODE *CurrentMode;
- INTN GlyphX;
- INTN GlyphY;
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Foreground;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Background;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION BltChar[EFI_GLYPH_HEIGHT][EFI_GLYPH_WIDTH];
- UINTN PosX;
- UINTN PosY;
-
- CurrentMode = This->Mode;
-
- if (!CurrentMode->CursorVisible) {
- return EFI_SUCCESS;
- }
-
- Private = GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS (This);
- GraphicsOutput = Private->GraphicsOutput;
-
- //
- // In this driver, only narrow character was supported.
- //
- //
- // Blt a character to the screen
- //
- GlyphX = (CurrentMode->CursorColumn * EFI_GLYPH_WIDTH) + Private->ModeData[CurrentMode->Mode].DeltaX;
- GlyphY = (CurrentMode->CursorRow * EFI_GLYPH_HEIGHT) + Private->ModeData[CurrentMode->Mode].DeltaY;
-
- GraphicsOutput->Blt (
- GraphicsOutput,
- (EFI_GRAPHICS_OUTPUT_BLT_PIXEL*)BltChar,
- EfiBltVideoToBltBuffer,
- GlyphX,
- GlyphY,
- 0,
- 0,
- EFI_GLYPH_WIDTH,
- EFI_GLYPH_HEIGHT,
- EFI_GLYPH_WIDTH * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
- );
-
- GetTextColors (This, &Foreground.Pixel, &Background.Pixel);
-
- //
- // Convert Monochrome bitmap of the Glyph to BltBuffer structure
- //
- for (PosY = 0; PosY < EFI_GLYPH_HEIGHT; PosY++) {
- for (PosX = 0; PosX < EFI_GLYPH_WIDTH; PosX++) {
- if ((mCursorGlyph.GlyphCol1[PosY] & (BIT0 << PosX)) != 0) {
- BltChar[PosY][EFI_GLYPH_WIDTH - PosX - 1].Raw ^= Foreground.Raw;
- }
- }
- }
-
- GraphicsOutput->Blt (
- GraphicsOutput,
- (EFI_GRAPHICS_OUTPUT_BLT_PIXEL*)BltChar,
- EfiBltBufferToVideo,
- 0,
- 0,
- GlyphX,
- GlyphY,
- EFI_GLYPH_WIDTH,
- EFI_GLYPH_HEIGHT,
- EFI_GLYPH_WIDTH * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
- );
-
- return EFI_SUCCESS;
-}
-
-/**
- HII Database Protocol notification event handler.
-
- Register font package when HII Database Protocol has been installed.
-
- @param[in] Event Event whose notification function is being invoked.
- @param[in] Context Pointer to the notification function's context.
-**/
-VOID
-EFIAPI
-RegisterFontPackage (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- EFI_STATUS Status;
- EFI_HII_SIMPLE_FONT_PACKAGE_HDR *SimplifiedFont;
- UINT32 PackageLength;
- UINT8 *Package;
- UINT8 *Location;
- EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
-
- //
- // Locate HII Database Protocol
- //
- Status = gBS->LocateProtocol (
- &gEfiHiiDatabaseProtocolGuid,
- NULL,
- (VOID**)&HiiDatabase
- );
- if (EFI_ERROR (Status)) {
- return;
- }
-
- //
- // Add 4 bytes to the header for entire length for HiiAddPackages use only.
- //
- // +--------------------------------+ <-- Package
- // | |
- // | PackageLength(4 bytes) |
- // | |
- // |--------------------------------| <-- SimplifiedFont
- // | |
- // |EFI_HII_SIMPLE_FONT_PACKAGE_HDR |
- // | |
- // |--------------------------------| <-- Location
- // | |
- // | gUsStdNarrowGlyphData |
- // | |
- // +--------------------------------+
-
- PackageLength = sizeof (EFI_HII_SIMPLE_FONT_PACKAGE_HDR) + mNarrowFontSize + 4;
- Package = AllocateZeroPool (PackageLength);
- ASSERT (Package != NULL);
-
- WriteUnaligned32 ((UINT32*)Package, PackageLength);
- SimplifiedFont = (EFI_HII_SIMPLE_FONT_PACKAGE_HDR*)(Package + 4);
- SimplifiedFont->Header.Length = (UINT32)(PackageLength - 4);
- SimplifiedFont->Header.Type = EFI_HII_PACKAGE_SIMPLE_FONTS;
- SimplifiedFont->NumberOfNarrowGlyphs = (UINT16)(mNarrowFontSize / sizeof (EFI_NARROW_GLYPH));
-
- Location = (UINT8*)(&SimplifiedFont->NumberOfWideGlyphs + 1);
- CopyMem (Location, gUsStdNarrowGlyphData, mNarrowFontSize);
-
- //
- // Add this simplified font package to a package list then install it.
- //
- mHiiHandle = HiiAddPackages (
- &mFontPackageListGuid,
- NULL,
- Package,
- NULL
- );
- ASSERT (mHiiHandle != NULL);
- FreePool (Package);
-}
-
-/**
- The user Entry Point for module GraphicsConsole. The user code starts with this function.
-
- @param[in] ImageHandle The firmware allocated handle for the EFI image.
- @param[in] SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The entry point is executed successfully.
- @return other Some error occurs when executing this entry point.
-
-**/
-EFI_STATUS
-EFIAPI
-InitializeGraphicsConsole (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- //
- // Register notify function on HII Database Protocol to add font package.
- //
- EfiCreateProtocolNotifyEvent (
- &gEfiHiiDatabaseProtocolGuid,
- TPL_CALLBACK,
- RegisterFontPackage,
- NULL,
- &mHiiRegistration
- );
-
- //
- // Install driver model protocol(s).
- //
- Status = EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &gGraphicsConsoleDriverBinding,
- ImageHandle,
- &gGraphicsConsoleComponentName,
- &gGraphicsConsoleComponentName2
- );
- ASSERT_EFI_ERROR (Status);
-
- return Status;
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/GraphicsConsole.h b/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/GraphicsConsole.h
deleted file mode 100644
index 62980fd0..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/GraphicsConsole.h
+++ /dev/null
@@ -1,585 +0,0 @@
-/** @file
- *
- * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2006-2016, Intel Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#ifndef _GRAPHICS_CONSOLE_H_
-#define _GRAPHICS_CONSOLE_H_
-
-#include <Uefi.h>
-#include <Protocol/ExtendedTextOut.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/HiiFont.h>
-#include <Protocol/HiiDatabase.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/UefiLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/HiiLib.h>
-#include <Library/BaseLib.h>
-#include <Library/PcdLib.h>
-#include <Guid/MdeModuleHii.h>
-
-extern EFI_COMPONENT_NAME_PROTOCOL gGraphicsConsoleComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gGraphicsConsoleComponentName2;
-extern EFI_DRIVER_BINDING_PROTOCOL gGraphicsConsoleDriverBinding;
-extern EFI_NARROW_GLYPH gUsStdNarrowGlyphData[];
-
-extern UINT32 mNarrowFontSize;
-
-typedef union {
- EFI_NARROW_GLYPH NarrowGlyph;
- EFI_WIDE_GLYPH WideGlyph;
-} GLYPH_UNION;
-
-//
-// Device Structure
-//
-#define GRAPHICS_CONSOLE_DEV_SIGNATURE SIGNATURE_32 ('g', 's', 't', 'o')
-
-typedef struct {
- UINTN Columns;
- UINTN Rows;
- INTN DeltaX;
- INTN DeltaY;
- UINT32 GopWidth;
- UINT32 GopHeight;
- UINT32 GopModeNumber;
-} GRAPHICS_CONSOLE_MODE_DATA;
-
-typedef struct {
- UINTN Signature;
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL SimpleTextOutput;
- EFI_SIMPLE_TEXT_OUTPUT_MODE SimpleTextOutputMode;
- GRAPHICS_CONSOLE_MODE_DATA *ModeData;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LineBuffer;
- EXTENDED_TEXT_OUTPUT_PROTOCOL ExtendedTextOutput;
-} GRAPHICS_CONSOLE_DEV;
-
-#define GRAPHICS_CONSOLE_CON_OUT_DEV_FROM_THIS(a) \
- CR (a, GRAPHICS_CONSOLE_DEV, SimpleTextOutput, GRAPHICS_CONSOLE_DEV_SIGNATURE)
-
-
-//
-// EFI Component Name Functions
-//
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
-
- @param DriverName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleComponentNameGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- );
-
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
-
- @param ControllerHandle[in] The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
-
- @param ChildHandle[in] The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
-
- @param Language[in] A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
-
- @param ControllerName[out] A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
-
- @retval EFI_INVALID_PARAMETER ControllerHandle is NULL.
-
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
-
- @retval EFI_INVALID_PARAMETER Language is NULL.
-
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
-
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
-
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleComponentNameGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- );
-
-
-/**
- Reset the text output device hardware and optionally run diagnostics.
-
- Implements SIMPLE_TEXT_OUTPUT.Reset().
- If ExtendeVerification is TRUE, then perform dependent Graphics Console
- device reset, and set display mode to mode 0.
- If ExtendedVerification is FALSE, only set display mode to mode 0.
-
- @param This Protocol instance pointer.
- @param ExtendedVerification Indicates that the driver may perform a more
- exhaustive verification operation of the device
- during reset.
-
- @retval EFI_SUCCESS The text output device was reset.
- @retval EFI_DEVICE_ERROR The text output device is not functioning correctly and
- could not be reset.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleConOutReset (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- );
-
-/**
- Write a Unicode string to the output device.
-
- Implements SIMPLE_TEXT_OUTPUT.OutputString().
- The Unicode string will be converted to Glyphs and will be
- sent to the Graphics Console.
-
- @param This Protocol instance pointer.
- @param WString The NULL-terminated Unicode string to be displayed
- on the output device(s). All output devices must
- also support the Unicode drawing defined in this file.
-
- @retval EFI_SUCCESS The string was output to the device.
- @retval EFI_DEVICE_ERROR The device reported an error while attempting to output
- the text.
- @retval EFI_UNSUPPORTED The output device's mode is not currently in a
- defined text mode.
- @retval EFI_WARN_UNKNOWN_GLYPH This warning code indicates that some of the
- characters in the Unicode string could not be
- rendered and were skipped.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleConOutOutputString (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN CHAR16 *WString
- );
-
-/**
- Verifies that all characters in a Unicode string can be output to the
- target device.
-
- Implements SIMPLE_TEXT_OUTPUT.TestString().
- If one of the characters in the *Wstring is neither valid valid Unicode
- drawing characters, not ASCII code, then this function will return
- EFI_UNSUPPORTED
-
- @param This Protocol instance pointer.
- @param WString The NULL-terminated Unicode string to be examined for the output
- device(s).
-
- @retval EFI_SUCCESS The device(s) are capable of rendering the output string.
- @retval EFI_UNSUPPORTED Some of the characters in the Unicode string cannot be
- rendered by one or more of the output devices mapped
- by the EFI handle.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleConOutTestString (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN CHAR16 *WString
- );
-
-/**
- Returns information for an available text mode that the output device(s)
- supports
-
- Implements SIMPLE_TEXT_OUTPUT.QueryMode().
- It returnes information for an available text mode that the Graphics Console supports.
- In this driver,we only support text mode 80x25, which is defined as mode 0.
-
- @param This Protocol instance pointer.
- @param ModeNumber The mode number to return information on.
- @param Columns The returned columns of the requested mode.
- @param Rows The returned rows of the requested mode.
-
- @retval EFI_SUCCESS The requested mode information is returned.
- @retval EFI_UNSUPPORTED The mode number is not valid.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleConOutQueryMode (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN ModeNumber,
- OUT UINTN *Columns,
- OUT UINTN *Rows
- );
-
-
-/**
- Sets the output device(s) to a specified mode.
-
- Implements SIMPLE_TEXT_OUTPUT.SetMode().
- Set the Graphics Console to a specified mode. In this driver, we only support mode 0.
-
- @param This Protocol instance pointer.
- @param ModeNumber The text mode to set.
-
- @retval EFI_SUCCESS The requested text mode is set.
- @retval EFI_DEVICE_ERROR The requested text mode cannot be set because of
- Graphics Console device error.
- @retval EFI_UNSUPPORTED The text mode number is not valid.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleConOutSetMode (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN ModeNumber
- );
-
-/**
- Sets the background and foreground colors for the OutputString () and
- ClearScreen () functions.
-
- Implements SIMPLE_TEXT_OUTPUT.SetAttribute().
-
- @param This Protocol instance pointer.
- @param Attribute The attribute to set. Bits 0..3 are the foreground
- color, and bits 4..6 are the background color.
- All other bits are undefined and must be zero.
-
- @retval EFI_SUCCESS The requested attribute is set.
- @retval EFI_DEVICE_ERROR The requested attribute cannot be set due to Graphics Console port error.
- @retval EFI_UNSUPPORTED The attribute requested is not defined.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleConOutSetAttribute (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN Attribute
- );
-
-/**
- Clears the output device(s) display to the currently selected background
- color.
-
- Implements SIMPLE_TEXT_OUTPUT.ClearScreen().
-
- @param This Protocol instance pointer.
-
- @retval EFI_SUCCESS The operation completed successfully.
- @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
- @retval EFI_UNSUPPORTED The output device is not in a valid text mode.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleConOutClearScreen (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
- );
-
-/**
- Sets the current coordinates of the cursor position.
-
- Implements SIMPLE_TEXT_OUTPUT.SetCursorPosition().
-
- @param This Protocol instance pointer.
- @param Column The position to set the cursor to. Must be greater than or
- equal to zero and less than the number of columns and rows
- by QueryMode ().
- @param Row The position to set the cursor to. Must be greater than or
- equal to zero and less than the number of columns and rows
- by QueryMode ().
-
- @retval EFI_SUCCESS The operation completed successfully.
- @retval EFI_DEVICE_ERROR The device had an error and could not complete the request.
- @retval EFI_UNSUPPORTED The output device is not in a valid text mode, or the
- cursor position is invalid for the current mode.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleConOutSetCursorPosition (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN UINTN Column,
- IN UINTN Row
- );
-
-
-/**
- Makes the cursor visible or invisible.
-
- Implements SIMPLE_TEXT_OUTPUT.EnableCursor().
-
- @param This Protocol instance pointer.
- @param Visible If TRUE, the cursor is set to be visible, If FALSE,
- the cursor is set to be invisible.
-
- @retval EFI_SUCCESS The operation completed successfully.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleConOutEnableCursor (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN BOOLEAN Visible
- );
-
-/**
- Test to see if Graphics Console could be supported on the Controller.
-
- Graphics Console could be supported if Graphics Output Protocol exists
- on the Controller.
-
- @param This Protocol instance pointer.
- @param Controller Handle of device to test.
- @param RemainingDevicePath Optional parameter use to pick a specific child
- device to start.
-
- @retval EFI_SUCCESS This driver supports this device.
- @retval other This driver does not support this device.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleControllerDriverSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-
-/**
- Start this driver on Controller by opening the Graphics Output Protocol,
- and installing Simple Text Out protocol on Controller.
-
- @param This Protocol instance pointer.
- @param Controller Handle of device to bind driver to
- @param RemainingDevicePath Optional parameter use to pick a specific child
- device to start.
-
- @retval EFI_SUCCESS This driver is added to Controller.
- @retval other This driver does not support this device.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleControllerDriverStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- );
-
-/**
- Stop this driver on Controller by removing Simple Text Out protocol
- and closing the Graphics Output Protocol on Controller.
-
- @param This Protocol instance pointer.
- @param Controller Handle of device to stop driver on
- @param NumberOfChildren Number of Handles in ChildHandleBuffer. If number of
- children is zero stop the entire bus driver.
- @param ChildHandleBuffer List of Child Handles to Stop.
-
- @retval EFI_SUCCESS This driver is removed Controller.
- @retval EFI_NOT_STARTED Simple Text Out protocol could not be found the
- Controller.
- @retval other This driver was not removed from this device.
-
-**/
-EFI_STATUS
-EFIAPI
-GraphicsConsoleControllerDriverStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- );
-
-
-/**
- Locate HII Database protocol and HII Font protocol.
-
- @retval EFI_SUCCESS HII Database protocol and HII Font protocol
- are located successfully.
- @return other Failed to locate HII Database protocol or
- HII Font protocol.
-
-**/
-EFI_STATUS
-EfiLocateHiiProtocol (
- VOID
- );
-
-
-/**
- Gets Graphics Console devcie's foreground color and background color.
-
- @param This Protocol instance pointer.
- @param Foreground Returned text foreground color.
- @param Background Returned text background color.
-
- @retval EFI_SUCCESS It returned always.
-
-**/
-EFI_STATUS
-GetTextColors (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,
- OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background
- );
-
-/**
- Draw Unicode string on the Graphics Console device's screen.
-
- @param This Protocol instance pointer.
- @param UnicodeWeight One Unicode string to be displayed.
- @param Count The count of Unicode string.
-
- @retval EFI_OUT_OF_RESOURCES If no memory resource to use.
- @retval EFI_UNSUPPORTED If no Graphics Output Protocol exists.
- @retval EFI_SUCCESS Drawing Unicode string implemented successfully.
-
-**/
-EFI_STATUS
-DrawUnicodeWeightAtCursorN (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This,
- IN CHAR16 *UnicodeWeight,
- IN UINTN Count
- );
-
-/**
- Flush the cursor on the screen.
-
- If CursorVisible is FALSE, nothing to do and return directly.
- If CursorVisible is TRUE,
- i) If the cursor shows on screen, it will be erased.
- ii) If the cursor does not show on screen, it will be shown.
-
- @param This Protocol instance pointer.
-
- @retval EFI_SUCCESS The cursor is erased successfully.
-
-**/
-EFI_STATUS
-FlushCursor (
- IN EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *This
- );
-
-/**
- Check if the current specific mode supported the user defined resolution
- for the Graphics Console device based on Graphics Output Protocol.
-
- If yes, set the graphic device's current mode to this specific mode.
-
- @param GraphicsOutput Graphics Output Protocol instance pointer.
- @param HorizontalResolution User defined horizontal resolution
- @param VerticalResolution User defined vertical resolution.
- @param CurrentModeNumber Current specific mode to be check.
-
- @retval EFI_SUCCESS The mode is supported.
- @retval EFI_UNSUPPORTED The specific mode is out of range of graphics
- device supported.
- @retval other The specific mode does not support user defined
- resolution or failed to set the current mode to the
- specific mode on graphics device.
-
-**/
-EFI_STATUS
-CheckModeSupported (
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,
- IN UINT32 HorizontalResolution,
- IN UINT32 VerticalResolution,
- OUT UINT32 *CurrentModeNumber
- );
-
-#endif
diff --git a/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/GraphicsConsoleDxe.inf b/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
deleted file mode 100644
index 51d1eed1..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
+++ /dev/null
@@ -1,68 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2006-2014, Intel Corporation. All rights reserved.
-# Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x0001001A
- BASE_NAME = GraphicsConsoleDxe
- MODULE_UNI_FILE = GraphicsConsoleDxe.uni
- FILE_GUID = CCCB0C28-4B24-11d5-9A5A-0090273FC14D
- MODULE_TYPE = UEFI_DRIVER
- VERSION_STRING = 1.1
- ENTRY_POINT = InitializeGraphicsConsole
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-# VALID_ARCHITECTURES = IA32 X64 IPF EBC AARCH64
-#
-# DRIVER_BINDING = gGraphicsConsoleDriverBinding
-# COMPONENT_NAME = gGraphicsConsoleComponentName
-# COMPONENT_NAME2 = gGraphicsConsoleComponentName2
-#
-
-[Sources]
- ComponentName.c
- NewFont.c
- GraphicsConsole.c
- GraphicsConsole.h
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- Silicon/Broadcom/Bcm283x/Bcm283x.dec
- Platform/RaspberryPi/RPi3/RPi3.dec
-
-[LibraryClasses]
- UefiBootServicesTableLib
- UefiRuntimeServicesTableLib
- MemoryAllocationLib
- BmpSupportLib
- BaseMemoryLib
- UefiLib
- UefiDriverEntryPoint
- DebugLib
- HiiLib
- PcdLib
-
-[Protocols]
- gEfiDevicePathProtocolGuid
- gEfiSimpleTextOutProtocolGuid
- gEfiGraphicsOutputProtocolGuid
- gEfiHiiFontProtocolGuid
- gEfiHiiDatabaseProtocolGuid
- gExtendedTextOutputProtocolGuid
-
-[FeaturePcd]
-
-[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution ## SOMETIMES_CONSUMES
- gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution ## SOMETIMES_CONSUMES
-
-[UserExtensions.TianoCore."ExtraFiles"]
- GraphicsConsoleDxeExtra.uni
diff --git a/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/GraphicsConsoleDxe.uni b/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/GraphicsConsoleDxe.uni
deleted file mode 100644
index a7d8b843..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/GraphicsConsoleDxe.uni
+++ /dev/null
@@ -1,12 +0,0 @@
-/** @file
- *
- * Copyright (c) 2006-2014, Intel Corporation. All rights reserved.
- * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#string STR_MODULE_ABSTRACT #language en-US "Console support on graphic devices"
-
-#string STR_MODULE_DESCRIPTION #language en-US "Install SimpleTextOutputProtocol on GraphicsOutputProtocol devices\n"
diff --git a/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/GraphicsConsoleDxeExtra.uni b/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/GraphicsConsoleDxeExtra.uni
deleted file mode 100644
index b849a6b9..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/GraphicsConsoleDxeExtra.uni
+++ /dev/null
@@ -1,12 +0,0 @@
-/** @file
- *
- * Copyright (c) 2006-2014, Intel Corporation. All rights reserved.
- * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#string STR_PROPERTIES_MODULE_NAME
-#language en-US
-"Graphics Console DXE Driver"
diff --git a/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/NewFont.c b/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/NewFont.c
deleted file mode 100644
index 87a949b2..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/GraphicsConsoleDxe/NewFont.c
+++ /dev/null
@@ -1,281 +0,0 @@
-/** @file
- *
- * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-/*
- * Based on ftp://www.unicode.org/Public/MAPPINGS/VENDORS/MICSFT/PC/CP437.TXT and
- * https://en.wikipedia.org/wiki/Code_page_437 for the cp437 Unicode equivalents
- * and the cp437 8x19 font from that_editor.
- *
- * https://github.com/bisqwit/that_editor/blob/master/8x19.inc
- * https://github.com/bisqwit/that_editor/blob/master/sourcematerial/vga8x19.bdf
- * https://github.com/stsp/dosemu2/blob/master/COPYING.DOSEMU
- */
-
-#include "GraphicsConsole.h"
-
-EFI_NARROW_GLYPH gUsStdNarrowGlyphData[] = {
- { 0x263a, 0x00, {0x00, 0x00, 0x7E, 0x81, 0xA5, 0xA5, 0x81, 0x81, 0xA5, 0xA5, 0x99, 0x81, 0x81, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x263b, 0x00, {0x00, 0x00, 0x7E, 0xFF, 0xDB, 0xFF, 0xFF, 0xFF, 0xDB, 0xE7, 0xFF, 0xFF, 0xFF, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2665, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0xFE, 0xFE, 0xFE, 0xFE, 0x7C, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2666, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x7C, 0xFE, 0xFE, 0x7C, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2663, 0x00, {0x00, 0x00, 0x00, 0x18, 0x3C, 0x3C, 0xFF, 0xE7, 0xE7, 0xE7, 0xFF, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2660, 0x00, {0x00, 0x00, 0x00, 0x18, 0x3C, 0x7E, 0xFF, 0xFF, 0xFF, 0x7E, 0x7E, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2022, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x3C, 0x3C, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x25d8, 0x00, {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xE7, 0xC3, 0xC3, 0xE7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}},
- { 0x25cb, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0x66, 0x42, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x25d9, 0x00, {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xDB, 0x99, 0xBD, 0xBD, 0x99, 0xDB, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}},
- { 0x2642, 0x00, {0x00, 0x00, 0x1E, 0x06, 0x0E, 0x0A, 0x1A, 0x78, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2640, 0x00, {0x00, 0x00, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x266a, 0x00, {0x00, 0x00, 0x3F, 0x33, 0x33, 0x3F, 0x30, 0x30, 0x30, 0x30, 0x30, 0x70, 0xF0, 0xE0, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x266b, 0x00, {0x00, 0x00, 0x7F, 0x63, 0x63, 0x7F, 0x63, 0x63, 0x63, 0x63, 0x63, 0x67, 0xE7, 0xE6, 0xC0, 0x00, 0x00, 0x00, 0x00}},
- { 0x263c, 0x00, {0x00, 0x00, 0x00, 0x18, 0x18, 0xDB, 0xFF, 0x3C, 0xE7, 0x3C, 0xFF, 0xDB, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x25ba, 0x00, {0x00, 0x80, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC, 0xFE, 0xFC, 0xF8, 0xF0, 0xE0, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x25c4, 0x00, {0x00, 0x02, 0x06, 0x0E, 0x1E, 0x3E, 0x7E, 0xFE, 0x7E, 0x3E, 0x1E, 0x0E, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2195, 0x00, {0x00, 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x203c, 0x00, {0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00b6, 0x00, {0x00, 0x00, 0x7F, 0xDB, 0xDB, 0xDB, 0xDB, 0x7B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x1B, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00a7, 0x00, {0x00, 0x00, 0x7C, 0xC6, 0x62, 0x30, 0x78, 0x4C, 0x64, 0x3C, 0x18, 0x8C, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x25ac, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0xFE, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x21a8, 0x00, {0x00, 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2191, 0x00, {0x00, 0x00, 0x18, 0x3C, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2193, 0x00, {0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2192, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x0C, 0xFE, 0x0C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2190, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x30, 0x60, 0xFE, 0x60, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x221f, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0xC0, 0xC0, 0xC0, 0xC0, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2194, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x28, 0x6C, 0xFE, 0x6C, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x25b2, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x38, 0x7C, 0x7C, 0xFE, 0xFE, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x25bc, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xFE, 0xFE, 0x7C, 0x7C, 0x38, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0020, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0021, 0x00, {0x00, 0x00, 0x18, 0x3C, 0x3C, 0x3C, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0022, 0x00, {0x66, 0x66, 0x66, 0x66, 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0023, 0x00, {0x00, 0x00, 0x00, 0x6C, 0x6C, 0x6C, 0xFE, 0x6C, 0x6C, 0x6C, 0xFE, 0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0024, 0x00, {0x10, 0x10, 0x7C, 0xD6, 0xD6, 0xD2, 0x70, 0x38, 0x1C, 0x16, 0x96, 0xD6, 0xD6, 0x7C, 0x10, 0x10, 0x00, 0x00, 0x00}},
- { 0x0025, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC2, 0xC6, 0x0C, 0x18, 0x30, 0x60, 0xC6, 0x86, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0026, 0x00, {0x00, 0x00, 0x38, 0x6C, 0x6C, 0x6C, 0x38, 0x76, 0xDC, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0027, 0x00, {0x30, 0x30, 0x30, 0x30, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0028, 0x00, {0x00, 0x00, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x18, 0x0C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0029, 0x00, {0x00, 0x00, 0x30, 0x18, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x002a, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x24, 0x3C, 0xFF, 0x3C, 0x24, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x002b, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x002c, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00}},
- { 0x002d, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x002e, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x002f, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0030, 0x00, {0x00, 0x00, 0x38, 0x6C, 0xC6, 0xC6, 0xC6, 0xD6, 0xD6, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0031, 0x00, {0x00, 0x00, 0x18, 0x38, 0x78, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0032, 0x00, {0x00, 0x00, 0x7C, 0xC6, 0x06, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0xC0, 0xC6, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0033, 0x00, {0x00, 0x00, 0x7C, 0xC6, 0x06, 0x06, 0x06, 0x3C, 0x06, 0x06, 0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0034, 0x00, {0x00, 0x00, 0x0C, 0x1C, 0x3C, 0x6C, 0xCC, 0xFE, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0035, 0x00, {0x00, 0x00, 0xFE, 0xC0, 0xC0, 0xC0, 0xC0, 0xFC, 0x06, 0x06, 0x06, 0x06, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0036, 0x00, {0x00, 0x00, 0x38, 0x60, 0xC0, 0xC0, 0xC0, 0xFC, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0037, 0x00, {0x00, 0x00, 0xFE, 0xC6, 0x06, 0x06, 0x06, 0x0C, 0x18, 0x30, 0x30, 0x30, 0x30, 0x30, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0038, 0x00, {0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0039, 0x00, {0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0x06, 0x06, 0x0C, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x003a, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x003b, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x30, 0x00, 0x00, 0x00, 0x00}},
- { 0x003c, 0x00, {0x00, 0x00, 0x00, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x003d, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x003e, 0x00, {0x00, 0x00, 0x00, 0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x003f, 0x00, {0x00, 0x00, 0x7C, 0xC6, 0x86, 0x06, 0x0C, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0040, 0x00, {0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xCE, 0xDE, 0xDE, 0xDE, 0xDE, 0xCC, 0xC0, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0041, 0x00, {0x00, 0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0042, 0x00, {0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x66, 0x66, 0x66, 0x66, 0x66, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0043, 0x00, {0x00, 0x00, 0x3C, 0x66, 0xC2, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC2, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0044, 0x00, {0x00, 0x00, 0xF8, 0x6C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x6C, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0045, 0x00, {0x00, 0x00, 0xFE, 0x66, 0x62, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x62, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0046, 0x00, {0x00, 0x00, 0xFE, 0x66, 0x62, 0x62, 0x68, 0x78, 0x68, 0x60, 0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0047, 0x00, {0x00, 0x00, 0x3C, 0x66, 0xC2, 0xC0, 0xC0, 0xC0, 0xC0, 0xDE, 0xC6, 0xC6, 0x66, 0x3A, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0048, 0x00, {0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0049, 0x00, {0x00, 0x00, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x004a, 0x00, {0x00, 0x00, 0x1E, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0xCC, 0xCC, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x004b, 0x00, {0x00, 0x00, 0xE6, 0x66, 0x66, 0x66, 0x6C, 0x78, 0x78, 0x6C, 0x66, 0x66, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x004c, 0x00, {0x00, 0x00, 0xF0, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x60, 0x62, 0x62, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x004d, 0x00, {0x00, 0x00, 0xC6, 0xEE, 0xFE, 0xD6, 0xD6, 0xD6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x004e, 0x00, {0x00, 0x00, 0xC6, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x004f, 0x00, {0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0050, 0x00, {0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0051, 0x00, {0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xD6, 0xDE, 0x7C, 0x0C, 0x0E, 0x00, 0x00, 0x00}},
- { 0x0052, 0x00, {0x00, 0x00, 0xFC, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x6C, 0x66, 0x66, 0x66, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0053, 0x00, {0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC2, 0x60, 0x38, 0x0C, 0x06, 0x86, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0054, 0x00, {0x00, 0x00, 0x7E, 0x7E, 0x5A, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0055, 0x00, {0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0056, 0x00, {0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0057, 0x00, {0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xD6, 0xD6, 0xD6, 0xFE, 0xEE, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0058, 0x00, {0x00, 0x00, 0xC6, 0xC6, 0x6C, 0x6C, 0x38, 0x38, 0x38, 0x38, 0x6C, 0x6C, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0059, 0x00, {0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x005a, 0x00, {0x00, 0x00, 0xFE, 0xC6, 0x86, 0x86, 0x0C, 0x18, 0x30, 0x60, 0xC2, 0xC2, 0xC6, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x005b, 0x00, {0x00, 0x00, 0x3C, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x005c, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0xC0, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x005d, 0x00, {0x00, 0x00, 0x3C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x005e, 0x00, {0x00, 0x10, 0x38, 0x6C, 0xC6, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x005f, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00}},
- { 0x0060, 0x00, {0x30, 0x30, 0x30, 0x30, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0061, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0x0C, 0x0C, 0x7C, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0062, 0x00, {0x00, 0x00, 0xE0, 0x60, 0x60, 0x60, 0x78, 0x6C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0063, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC0, 0xC0, 0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0064, 0x00, {0x00, 0x00, 0x1C, 0x0C, 0x0C, 0x0C, 0x3C, 0x6C, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0065, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xFE, 0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0066, 0x00, {0x00, 0x00, 0x1C, 0x36, 0x32, 0x30, 0x78, 0x30, 0x30, 0x30, 0x30, 0x30, 0x30, 0x78, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0067, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0x0C, 0xCC, 0x78, 0x00}},
- { 0x0068, 0x00, {0x00, 0x00, 0xE0, 0x60, 0x60, 0x60, 0x6C, 0x76, 0x66, 0x66, 0x66, 0x66, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0069, 0x00, {0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x006a, 0x00, {0x00, 0x00, 0x00, 0x0C, 0x0C, 0x00, 0x1C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0xCC, 0xCC, 0xCC, 0x78, 0x00}},
- { 0x006b, 0x00, {0x00, 0x00, 0xE0, 0x60, 0x60, 0x60, 0x66, 0x6C, 0x78, 0x78, 0x6C, 0x66, 0x66, 0xE6, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x006c, 0x00, {0x00, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x006d, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6C, 0xFE, 0xD6, 0xD6, 0xD6, 0xD6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x006e, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x006f, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0070, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0x60, 0xF0, 0x00}},
- { 0x0071, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x7C, 0x0C, 0x0C, 0x0C, 0x1E, 0x00}},
- { 0x0072, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xDC, 0x76, 0x66, 0x60, 0x60, 0x60, 0x60, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0073, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC2, 0x78, 0x0C, 0x86, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0074, 0x00, {0x00, 0x00, 0x10, 0x30, 0x30, 0x30, 0xFC, 0x30, 0x30, 0x30, 0x30, 0x30, 0x36, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0075, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0076, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0077, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xD6, 0xD6, 0xD6, 0xFE, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0078, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0x6C, 0x38, 0x10, 0x38, 0x6C, 0xC6, 0x82, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0079, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0x0C, 0xF8, 0x00}},
- { 0x007a, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xCC, 0x18, 0x30, 0x60, 0xC0, 0xC6, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x007b, 0x00, {0x00, 0x00, 0x0E, 0x18, 0x18, 0x18, 0x18, 0x70, 0x18, 0x18, 0x18, 0x18, 0x18, 0x0E, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x007c, 0x00, {0x00, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x007d, 0x00, {0x00, 0x00, 0x70, 0x18, 0x18, 0x18, 0x18, 0x0E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x007e, 0x00, {0x00, 0x76, 0xD4, 0x9C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2302, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xC6, 0xC6, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00c7, 0x00, {0x00, 0x00, 0x3C, 0x66, 0xC2, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC2, 0x66, 0x3C, 0x0C, 0x06, 0x7C, 0x00, 0x00, 0x00}},
- { 0x00fc, 0x00, {0x00, 0x00, 0x00, 0xCC, 0xCC, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00e9, 0x00, {0x00, 0x0C, 0x18, 0x30, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xFE, 0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00e2, 0x00, {0x00, 0x10, 0x38, 0x6C, 0x00, 0x00, 0x78, 0x0C, 0x0C, 0x7C, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00e4, 0x00, {0x00, 0x00, 0x00, 0xCC, 0xCC, 0x00, 0x78, 0x0C, 0x0C, 0x7C, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00e0, 0x00, {0x00, 0x60, 0x30, 0x18, 0x0C, 0x00, 0x78, 0x0C, 0x0C, 0x7C, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00e5, 0x00, {0x00, 0x38, 0x6C, 0x6C, 0x38, 0x00, 0x78, 0x0C, 0x0C, 0x7C, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00e7, 0x00, {0x00, 0x00, 0x00, 0x00, 0x3C, 0x66, 0x62, 0x60, 0x60, 0x66, 0x64, 0x3C, 0x0C, 0x06, 0x3C, 0x00, 0x00, 0x00, 0x00}},
- { 0x00ea, 0x00, {0x00, 0x10, 0x38, 0x6C, 0x44, 0x00, 0x7C, 0xC6, 0xC6, 0xFE, 0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00eb, 0x00, {0x00, 0x00, 0x00, 0xC6, 0xC6, 0x00, 0x7C, 0xC6, 0xC6, 0xFE, 0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00e8, 0x00, {0x00, 0x60, 0x30, 0x18, 0x0C, 0x00, 0x7C, 0xC6, 0xC6, 0xFE, 0xC0, 0xC0, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00ef, 0x00, {0x00, 0x00, 0x00, 0x66, 0x66, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00ee, 0x00, {0x00, 0x18, 0x3C, 0x66, 0x42, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00ec, 0x00, {0x00, 0x60, 0x30, 0x18, 0x08, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00c4, 0x00, {0xC6, 0xC6, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00c5, 0x00, {0x38, 0x28, 0x38, 0x10, 0x38, 0x6C, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00c9, 0x00, {0x18, 0x30, 0x60, 0x00, 0xFE, 0x66, 0x62, 0x68, 0x78, 0x68, 0x60, 0x62, 0x66, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00e6, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xCC, 0x76, 0x36, 0x36, 0x7E, 0xD8, 0xD8, 0x6E, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00c6, 0x00, {0x00, 0x00, 0x3E, 0x6C, 0xCC, 0xCC, 0xFE, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCE, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00f4, 0x00, {0x00, 0x10, 0x38, 0x6C, 0x44, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00f6, 0x00, {0x00, 0x00, 0x00, 0xC6, 0xC6, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00f2, 0x00, {0x00, 0x60, 0x30, 0x18, 0x0C, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00fb, 0x00, {0x00, 0x30, 0x78, 0xCC, 0x84, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00f9, 0x00, {0x00, 0x60, 0x30, 0x18, 0x0C, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00ff, 0x00, {0x00, 0x00, 0x00, 0xC6, 0xC6, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7E, 0x06, 0x06, 0x0C, 0x78, 0x00}},
- { 0x00d6, 0x00, {0xC6, 0xC6, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00dc, 0x00, {0xC6, 0xC6, 0x00, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00a2, 0x00, {0x08, 0x08, 0x3C, 0x6E, 0xCA, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xC8, 0xCA, 0x6E, 0x3C, 0x08, 0x08, 0x00, 0x00, 0x00}},
- { 0x00a3, 0x00, {0x00, 0x38, 0x6C, 0x64, 0x64, 0x60, 0xF0, 0x60, 0x60, 0x60, 0x60, 0x62, 0xE6, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00a5, 0x00, {0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x18, 0x7E, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x20a7, 0x00, {0x00, 0xF8, 0xCC, 0xCC, 0xFC, 0xF8, 0xC4, 0xCC, 0xDE, 0xCC, 0xCC, 0xCC, 0xCC, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0192, 0x00, {0x00, 0x0E, 0x1B, 0x19, 0x18, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x18, 0x18, 0x18, 0x98, 0xD8, 0x70, 0x00, 0x00, 0x00}},
- { 0x00e1, 0x00, {0x00, 0x18, 0x30, 0x60, 0xC0, 0x00, 0x78, 0x0C, 0x0C, 0x7C, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00ed, 0x00, {0x00, 0x0C, 0x18, 0x30, 0x20, 0x00, 0x38, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00f3, 0x00, {0x00, 0x18, 0x30, 0x60, 0x40, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00fa, 0x00, {0x00, 0x18, 0x30, 0x60, 0x40, 0x00, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0xCC, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00f1, 0x00, {0x00, 0x00, 0x36, 0xD4, 0x88, 0x00, 0xDC, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00d1, 0x00, {0x36, 0xCC, 0x00, 0xC6, 0xE6, 0xF6, 0xDE, 0xCE, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00aa, 0x00, {0x00, 0x3C, 0x6C, 0x6C, 0x6C, 0x3E, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00ba, 0x00, {0x00, 0x38, 0x6C, 0x6C, 0x6C, 0x38, 0x00, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00bf, 0x00, {0x00, 0x00, 0x30, 0x30, 0x00, 0x30, 0x30, 0x30, 0x60, 0xC0, 0xC6, 0xC6, 0xC6, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2310, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00ac, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x06, 0x06, 0x06, 0x06, 0x06, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00bd, 0x00, {0x00, 0xC0, 0xC0, 0xC0, 0xC2, 0xC6, 0x0C, 0x18, 0x30, 0x60, 0xC0, 0x9C, 0x06, 0x0C, 0x18, 0x3E, 0x00, 0x00, 0x00}},
- { 0x00bc, 0x00, {0x00, 0xC0, 0xC0, 0xC0, 0xC2, 0xC6, 0x0C, 0x18, 0x30, 0x66, 0xCE, 0x9A, 0x32, 0x3E, 0x06, 0x06, 0x00, 0x00, 0x00}},
- { 0x00a1, 0x00, {0x00, 0x00, 0x18, 0x18, 0x00, 0x18, 0x18, 0x18, 0x18, 0x3C, 0x3C, 0x3C, 0x3C, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00ab, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x6C, 0xD8, 0xD8, 0x6C, 0x36, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00bb, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xD8, 0x6C, 0x36, 0x36, 0x6C, 0xD8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2591, 0x00, {0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11, 0x44, 0x11}},
- { 0x2592, 0x00, {0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55, 0xAA, 0x55}},
- { 0x2593, 0x00, {0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD, 0x77, 0xDD}},
- { 0x2502, 0x00, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18}},
- { 0x2524, 0x00, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18}},
- { 0x2561, 0x00, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18}},
- { 0x2562, 0x00, {0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xF6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36}},
- { 0x2556, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36}},
- { 0x2555, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x18, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18}},
- { 0x2563, 0x00, {0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xF6, 0x06, 0xF6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36}},
- { 0x2551, 0x00, {0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36}},
- { 0x2557, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x06, 0xF6, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36}},
- { 0x255d, 0x00, {0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xF6, 0x06, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x255c, 0x00, {0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x255b, 0x00, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xF8, 0x18, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2510, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18}},
- { 0x2514, 0x00, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2534, 0x00, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x252c, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18}},
- { 0x251c, 0x00, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18}},
- { 0x2500, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x253c, 0x00, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18}},
- { 0x255e, 0x00, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x1F, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18}},
- { 0x255f, 0x00, {0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36}},
- { 0x255a, 0x00, {0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2554, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36}},
- { 0x2569, 0x00, {0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xF7, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2566, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xF7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36}},
- { 0x2560, 0x00, {0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x37, 0x30, 0x37, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36}},
- { 0x2550, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x256c, 0x00, {0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xF7, 0x00, 0xF7, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36}},
- { 0x2567, 0x00, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2568, 0x00, {0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2564, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x00, 0xFF, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18}},
- { 0x2565, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36}},
- { 0x2559, 0x00, {0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x3F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2558, 0x00, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x1F, 0x18, 0x1F, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2552, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x18, 0x1F, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18}},
- { 0x2553, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3F, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36}},
- { 0x256b, 0x00, {0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0xFF, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36, 0x36}},
- { 0x256a, 0x00, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xFF, 0x18, 0xFF, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18}},
- { 0x2518, 0x00, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x250c, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1F, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18}},
- { 0x2588, 0x00, {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}},
- { 0x2584, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}},
- { 0x258c, 0x00, {0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0, 0xF0}},
- { 0x2590, 0x00, {0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F, 0x0F}},
- { 0x2580, 0x00, {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x03b1, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xDC, 0xD8, 0xD8, 0xD8, 0xD8, 0xDC, 0x76, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00df, 0x00, {0x00, 0x00, 0x78, 0xCC, 0xCC, 0xCC, 0xCC, 0xD8, 0xCC, 0xC6, 0xC6, 0xC6, 0xC6, 0xCC, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0393, 0x00, {0x00, 0x00, 0xFE, 0xC6, 0xC6, 0xC6, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x03c0, 0x00, {0x00, 0x00, 0x00, 0x00, 0xFE, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x03a3, 0x00, {0x00, 0x00, 0x00, 0xFE, 0xC6, 0xC2, 0x60, 0x30, 0x18, 0x30, 0x60, 0xC2, 0xC6, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x03c3, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0xD8, 0x70, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00b5, 0x00, {0x00, 0x00, 0x00, 0x00, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x66, 0x7C, 0x60, 0x60, 0xC0, 0x00, 0x00, 0x00, 0x00}},
- { 0x03c4, 0x00, {0x00, 0x00, 0x00, 0x00, 0x76, 0xDC, 0x98, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x03a6, 0x00, {0x00, 0x00, 0x00, 0x7E, 0x18, 0x3C, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x18, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0398, 0x00, {0x00, 0x00, 0x00, 0x38, 0x6C, 0xC6, 0xC6, 0xC6, 0xFE, 0xC6, 0xC6, 0xC6, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x03a9, 0x00, {0x00, 0x00, 0x38, 0x6C, 0xC6, 0xC6, 0xC6, 0xC6, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0xEE, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x03b4, 0x00, {0x00, 0x00, 0x1E, 0x20, 0x30, 0x18, 0x0C, 0x3E, 0x66, 0x66, 0x66, 0x66, 0x66, 0x3C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x221e, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x7E, 0xDB, 0xDB, 0xDB, 0xDB, 0xDB, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x03c6, 0x00, {0x00, 0x00, 0x00, 0x03, 0x06, 0x7E, 0xDB, 0xDB, 0xDB, 0xDB, 0xD3, 0x7E, 0x60, 0xC0, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x03b5, 0x00, {0x00, 0x00, 0x1C, 0x30, 0x60, 0x60, 0x60, 0x7C, 0x60, 0x60, 0x60, 0x60, 0x30, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2229, 0x00, {0x00, 0x00, 0x00, 0x7C, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0xC6, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2261, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0xFE, 0x00, 0x00, 0xFE, 0x00, 0x00, 0xFE, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00b1, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x7E, 0x18, 0x18, 0x00, 0x00, 0xFF, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2265, 0x00, {0x00, 0x00, 0x00, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2264, 0x00, {0x00, 0x00, 0x00, 0x06, 0x0C, 0x18, 0x30, 0x60, 0x30, 0x18, 0x0C, 0x06, 0x00, 0x7E, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2320, 0x00, {0x00, 0x00, 0x0E, 0x1B, 0x1B, 0x1B, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18}},
- { 0x2321, 0x00, {0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0xD8, 0xD8, 0xD8, 0x70, 0x00, 0x00}},
- { 0x00f7, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x7E, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2248, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0xDC, 0x00, 0x76, 0xDC, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00b0, 0x00, {0x00, 0x38, 0x6C, 0x6C, 0x6C, 0x38, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x2219, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00b7, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x221a, 0x00, {0x00, 0x0F, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0x0C, 0xEC, 0x6C, 0x6C, 0x6C, 0x3C, 0x1C, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x207f, 0x00, {0x00, 0xD8, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x6C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00b2, 0x00, {0x00, 0x70, 0xD8, 0x10, 0x30, 0x60, 0xC8, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x25a0, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x7C, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x00a0, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}},
- { 0x0000, 0x00, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}} //EOL
-};
-
-// Get available Unicode glyphs narrow fonts(8*19 pixels) size.
-UINT32 mNarrowFontSize = sizeof (gUsStdNarrowGlyphData);
diff --git a/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/ComponentName.c b/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/ComponentName.c
deleted file mode 100644
index 07d762c5..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/ComponentName.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/** @file
- *
- * Component Name Protocol implementation for the MMC DXE driver
- *
- * Copyright (c) 2011, ARM Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include "Mmc.h"
-
-//
-// EFI Component Name Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME_PROTOCOL gMmcComponentName = {
- MmcGetDriverName,
- MmcGetControllerName,
- "eng"
-};
-
-//
-// EFI Component Name 2 Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_COMPONENT_NAME2_PROTOCOL gMmcComponentName2 = {
- (EFI_COMPONENT_NAME2_GET_DRIVER_NAME)MmcGetDriverName,
- (EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)MmcGetControllerName,
- "en"
-};
-
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_UNICODE_STRING_TABLE
-mMmcDriverNameTable[] = {
- {"eng;en", L"MMC/SD Card Interface Driver"},
- {NULL, NULL}
-};
-
-/**
- Retrieves a Unicode string that is the user readable name of the driver.
-
- This function retrieves the user readable name of a driver in the form of a
- Unicode string. If the driver specified by This has a user readable name in
- the language specified by Language, then a pointer to the driver name is
- returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
- by This does not support the language specified by Language,
- then EFI_UNSUPPORTED is returned.
-
- @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
- @param Language A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified
- in RFC 4646 or ISO 639-2 language code format.
- @param DriverName A pointer to the Unicode string to return.
- This Unicode string is the name of the
- driver specified by This in the language
- specified by Language.
-
- @retval EFI_SUCCESS The Unicode string for the Driver specified by
- This and the language specified by Language was
- returned in DriverName.
- @retval EFI_INVALID_PARAMETER Language is NULL.
- @retval EFI_INVALID_PARAMETER DriverName is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-MmcGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- )
-{
- return LookupUnicodeString2 (
- Language,
- This->SupportedLanguages,
- mMmcDriverNameTable,
- DriverName,
- (BOOLEAN)(This == &gMmcComponentName)
- );
-}
-
-/**
- Retrieves a Unicode string that is the user readable name of the controller
- that is being managed by a driver.
-
- This function retrieves the user readable name of the controller specified by
- ControllerHandle and ChildHandle in the form of a Unicode string. If the
- driver specified by This has a user readable name in the language specified by
- Language, then a pointer to the controller name is returned in ControllerName,
- and EFI_SUCCESS is returned. If the driver specified by This is not currently
- managing the controller specified by ControllerHandle and ChildHandle,
- then EFI_UNSUPPORTED is returned. If the driver specified by This does not
- support the language specified by Language, then EFI_UNSUPPORTED is returned.
-
- @param This A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
- EFI_COMPONENT_NAME_PROTOCOL instance.
- @param ControllerHandle The handle of a controller that the driver
- specified by This is managing. This handle
- specifies the controller whose name is to be
- returned.
- @param ChildHandle The handle of the child controller to retrieve
- the name of. This is an optional parameter that
- may be NULL. It will be NULL for device
- drivers. It will also be NULL for a bus drivers
- that wish to retrieve the name of the bus
- controller. It will not be NULL for a bus
- driver that wishes to retrieve the name of a
- child controller.
- @param Language A pointer to a Null-terminated ASCII string
- array indicating the language. This is the
- language of the driver name that the caller is
- requesting, and it must match one of the
- languages specified in SupportedLanguages. The
- number of languages supported by a driver is up
- to the driver writer. Language is specified in
- RFC 4646 or ISO 639-2 language code format.
- @param ControllerName A pointer to the Unicode string to return.
- This Unicode string is the name of the
- controller specified by ControllerHandle and
- ChildHandle in the language specified by
- Language from the point of view of the driver
- specified by This.
-
- @retval EFI_SUCCESS The Unicode string for the user readable name in
- the language specified by Language for the
- driver specified by This was returned in
- DriverName.
- @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
- EFI_HANDLE.
- @retval EFI_INVALID_PARAMETER Language is NULL.
- @retval EFI_INVALID_PARAMETER ControllerName is NULL.
- @retval EFI_UNSUPPORTED The driver specified by This is not currently
- managing the controller specified by
- ControllerHandle and ChildHandle.
- @retval EFI_UNSUPPORTED The driver specified by This does not support
- the language specified by Language.
-
-**/
-EFI_STATUS
-EFIAPI
-MmcGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- )
-{
- return EFI_UNSUPPORTED;
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/Diagnostics.c b/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/Diagnostics.c
deleted file mode 100644
index 58f1e251..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/Diagnostics.c
+++ /dev/null
@@ -1,257 +0,0 @@
-/** @file
- *
- * Diagnostics Protocol implementation for the MMC DXE driver
- *
- * Copyright (c) 2011-2014, ARM Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <Uefi.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/BaseLib.h>
-
-#include "Mmc.h"
-
-#define DIAGNOSTIC_LOGBUFFER_MAXCHAR 1024
-
-CHAR16* mLogBuffer = NULL;
-UINTN mLogRemainChar = 0;
-
-CHAR16*
-DiagnosticInitLog (
- UINTN MaxBufferChar
- )
-{
- mLogRemainChar = MaxBufferChar;
- mLogBuffer = AllocatePool ((UINTN)MaxBufferChar * sizeof (CHAR16));
- return mLogBuffer;
-}
-
-UINTN
-DiagnosticLog (
- CONST CHAR16* Str
- )
-{
- UINTN len = StrLen (Str);
- if (len < mLogRemainChar) {
- StrCpyS (mLogBuffer, mLogRemainChar, Str);
- mLogRemainChar -= len;
- mLogBuffer += len;
- return len;
- } else {
- return 0;
- }
-}
-
-VOID
-GenerateRandomBuffer (
- VOID* Buffer,
- UINTN BufferSize
- )
-{
- UINT64 i;
- UINT64* Buffer64 = (UINT64*)Buffer;
-
- for (i = 0; i < (BufferSize >> 3); i++) {
- *Buffer64 = i | (~i << 32);
- Buffer64++;
- }
-}
-
-BOOLEAN
-CompareBuffer (
- VOID *BufferA,
- VOID *BufferB,
- UINTN BufferSize
- )
-{
- UINTN i;
- UINT64* BufferA64 = (UINT64*)BufferA;
- UINT64* BufferB64 = (UINT64*)BufferB;
-
- for (i = 0; i < (BufferSize >> 3); i++) {
- if (*BufferA64 != *BufferB64) {
- DEBUG ((DEBUG_ERROR, "CompareBuffer: Error at %i", i));
- DEBUG ((DEBUG_ERROR, "(0x%lX) != (0x%lX)\n", *BufferA64, *BufferB64));
- return FALSE;
- }
- BufferA64++;
- BufferB64++;
- }
- return TRUE;
-}
-
-EFI_STATUS
-MmcReadWriteDataTest (
- MMC_HOST_INSTANCE *MmcHostInstance,
- EFI_LBA Lba,
- UINTN BufferSize
- )
-{
- VOID *BackBuffer;
- VOID *WriteBuffer;
- VOID *ReadBuffer;
- EFI_STATUS Status;
-
- // Check if a Media is Present
- if (!MmcHostInstance->BlockIo.Media->MediaPresent) {
- DiagnosticLog (L"ERROR: No Media Present\n");
- return EFI_NO_MEDIA;
- }
-
- if (MmcHostInstance->State != MmcTransferState) {
- DiagnosticLog (L"ERROR: Not ready for Transfer state\n");
- return EFI_NOT_READY;
- }
-
- BackBuffer = AllocatePool (BufferSize);
- WriteBuffer = AllocatePool (BufferSize);
- ReadBuffer = AllocatePool (BufferSize);
-
- // Read (and save) buffer at a specific location
- Status = MmcReadBlocks (&(MmcHostInstance->BlockIo),
- MmcHostInstance->BlockIo.Media->MediaId, Lba, BufferSize, BackBuffer);
- if (Status != EFI_SUCCESS) {
- DiagnosticLog (L"ERROR: Fail to Read Block (1)\n");
- return Status;
- }
-
- // Write buffer at the same location
- GenerateRandomBuffer (WriteBuffer, BufferSize);
- Status = MmcWriteBlocks (&(MmcHostInstance->BlockIo),
- MmcHostInstance->BlockIo.Media->MediaId, Lba, BufferSize, WriteBuffer);
- if (Status != EFI_SUCCESS) {
- DiagnosticLog (L"ERROR: Fail to Write Block (1)\n");
- return Status;
- }
-
- // Read the buffer at the same location
- Status = MmcReadBlocks (&(MmcHostInstance->BlockIo),
- MmcHostInstance->BlockIo.Media->MediaId, Lba, BufferSize, ReadBuffer);
- if (Status != EFI_SUCCESS) {
- DiagnosticLog (L"ERROR: Fail to Read Block (2)\n");
- return Status;
- }
-
- // Check that is conform
- if (!CompareBuffer (ReadBuffer, WriteBuffer, BufferSize)) {
- DiagnosticLog (L"ERROR: Fail to Read/Write Block (1)\n");
- return EFI_INVALID_PARAMETER;
- }
-
- // Restore content at the original location
- Status = MmcWriteBlocks (&(MmcHostInstance->BlockIo),
- MmcHostInstance->BlockIo.Media->MediaId, Lba, BufferSize, BackBuffer);
- if (Status != EFI_SUCCESS) {
- DiagnosticLog (L"ERROR: Fail to Write Block (2)\n");
- return Status;
- }
-
- // Read the restored content
- Status = MmcReadBlocks (&(MmcHostInstance->BlockIo),
- MmcHostInstance->BlockIo.Media->MediaId, Lba, BufferSize, ReadBuffer);
- if (Status != EFI_SUCCESS) {
- DiagnosticLog (L"ERROR: Fail to Read Block (3)\n");
- return Status;
- }
-
- // Check the content is correct
- if (!CompareBuffer (ReadBuffer, BackBuffer, BufferSize)) {
- DiagnosticLog (L"ERROR: Fail to Read/Write Block (2)\n");
- return EFI_INVALID_PARAMETER;
- }
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-MmcDriverDiagnosticsRunDiagnostics (
- IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType,
- IN CHAR8 *Language,
- OUT EFI_GUID **ErrorType,
- OUT UINTN *BufferSize,
- OUT CHAR16 **Buffer
- )
-{
- LIST_ENTRY *CurrentLink;
- MMC_HOST_INSTANCE *MmcHostInstance;
- EFI_STATUS Status;
-
- if ((Language == NULL) ||
- (ErrorType == NULL) ||
- (Buffer == NULL) ||
- (ControllerHandle == NULL) ||
- (BufferSize == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- // Check Language is supported (i.e. is "en-*" - only English is supported)
- if (AsciiStrnCmp (Language, "en", 2) != 0) {
- return EFI_UNSUPPORTED;
- }
-
- Status = EFI_SUCCESS;
- *ErrorType = NULL;
- *BufferSize = DIAGNOSTIC_LOGBUFFER_MAXCHAR;
- *Buffer = DiagnosticInitLog (DIAGNOSTIC_LOGBUFFER_MAXCHAR);
-
- DiagnosticLog (L"MMC Driver Diagnostics\n");
-
- // Find the MMC Host instance on which we have been asked to run diagnostics
- MmcHostInstance = NULL;
- CurrentLink = mMmcHostPool.ForwardLink;
- while (CurrentLink != NULL && CurrentLink != &mMmcHostPool && (Status == EFI_SUCCESS)) {
- MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK (CurrentLink);
- ASSERT (MmcHostInstance != NULL);
- if (MmcHostInstance->MmcHandle == ControllerHandle) {
- break;
- }
- CurrentLink = CurrentLink->ForwardLink;
- }
-
- // If we didn't find the controller, return EFI_UNSUPPORTED
- if ((MmcHostInstance == NULL)
- || (MmcHostInstance->MmcHandle != ControllerHandle)) {
- return EFI_UNSUPPORTED;
- }
-
- // LBA=1 Size=BlockSize
- DiagnosticLog (L"MMC Driver Diagnostics - Test: First Block\n");
- Status = MmcReadWriteDataTest (MmcHostInstance, 1, MmcHostInstance->BlockIo.Media->BlockSize);
-
- // LBA=2 Size=BlockSize
- DiagnosticLog (L"MMC Driver Diagnostics - Test: Second Block\n");
- Status = MmcReadWriteDataTest (MmcHostInstance, 2, MmcHostInstance->BlockIo.Media->BlockSize);
-
- // LBA=10 Size=BlockSize
- DiagnosticLog (L"MMC Driver Diagnostics - Test: Any Block\n");
- Status = MmcReadWriteDataTest (MmcHostInstance, MmcHostInstance->BlockIo.Media->LastBlock >> 1,
- MmcHostInstance->BlockIo.Media->BlockSize);
-
- // LBA=LastBlock Size=BlockSize
- DiagnosticLog (L"MMC Driver Diagnostics - Test: Last Block\n");
- Status = MmcReadWriteDataTest (MmcHostInstance, MmcHostInstance->BlockIo.Media->LastBlock,
- MmcHostInstance->BlockIo.Media->BlockSize);
-
- // LBA=1 Size=2*BlockSize
- DiagnosticLog (L"MMC Driver Diagnostics - Test: First Block / 2 BlockSSize\n");
- Status = MmcReadWriteDataTest (MmcHostInstance, 1, 2 * MmcHostInstance->BlockIo.Media->BlockSize);
-
- return Status;
-}
-
-//
-// EFI Driver Diagnostics 2 Protocol
-//
-GLOBAL_REMOVE_IF_UNREFERENCED EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gMmcDriverDiagnostics2 = {
- (EFI_DRIVER_DIAGNOSTICS2_RUN_DIAGNOSTICS)MmcDriverDiagnosticsRunDiagnostics,
- "en"
-};
diff --git a/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/Mmc.c b/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/Mmc.c
deleted file mode 100644
index c3c7279e..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/Mmc.c
+++ /dev/null
@@ -1,454 +0,0 @@
-/** @file
- *
- * Main file of the MMC Dxe driver. The driver entrypoint is defined into this file.
- *
- * Copyright (c) 2011-2013, ARM Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <Protocol/DevicePath.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/DevicePathLib.h>
-
-#include "Mmc.h"
-
-EFI_BLOCK_IO_MEDIA mMmcMediaTemplate = {
- SIGNATURE_32 ('m','m','c','o'), // MediaId
- TRUE, // RemovableMedia
- FALSE, // MediaPresent
- FALSE, // LogicalPartition
- FALSE, // ReadOnly
- FALSE, // WriteCaching
- 512, // BlockSize
- 4, // IoAlign
- 0, // Pad
- 0 // LastBlock
-};
-
-//
-// This device structure is serviced as a header.
-// Its next field points to the first root bridge device node.
-//
-LIST_ENTRY mMmcHostPool;
-
-/**
- Event triggered by the timer to check if any cards have been removed
- or if new ones have been plugged in
-**/
-
-EFI_EVENT gCheckCardsEvent;
-
-/**
- Initialize the MMC Host Pool to support multiple MMC devices
-**/
-VOID
-InitializeMmcHostPool (
- VOID
- )
-{
- InitializeListHead (&mMmcHostPool);
-}
-
-/**
- Insert a new Mmc Host controller to the pool
-**/
-VOID
-InsertMmcHost (
- IN MMC_HOST_INSTANCE *MmcHostInstance
- )
-{
- InsertTailList (&mMmcHostPool, &(MmcHostInstance->Link));
-}
-
-/*
- Remove a new Mmc Host controller to the pool
-*/
-VOID
-RemoveMmcHost (
- IN MMC_HOST_INSTANCE *MmcHostInstance
- )
-{
- RemoveEntryList (&(MmcHostInstance->Link));
-}
-
-MMC_HOST_INSTANCE* CreateMmcHostInstance (
- IN EFI_MMC_HOST_PROTOCOL* MmcHost
- )
-{
- EFI_STATUS Status;
- MMC_HOST_INSTANCE* MmcHostInstance;
- EFI_DEVICE_PATH_PROTOCOL *NewDevicePathNode;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
-
- MmcHostInstance = AllocateZeroPool (sizeof (MMC_HOST_INSTANCE));
- if (MmcHostInstance == NULL) {
- return NULL;
- }
-
- MmcHostInstance->Signature = MMC_HOST_INSTANCE_SIGNATURE;
-
- MmcHostInstance->State = MmcHwInitializationState;
-
- MmcHostInstance->BlockIo.Media = AllocateCopyPool (sizeof (EFI_BLOCK_IO_MEDIA), &mMmcMediaTemplate);
- if (MmcHostInstance->BlockIo.Media == NULL) {
- goto FREE_INSTANCE;
- }
-
- MmcHostInstance->BlockIo.Revision = EFI_BLOCK_IO_INTERFACE_REVISION;
- MmcHostInstance->BlockIo.Reset = MmcReset;
- MmcHostInstance->BlockIo.ReadBlocks = MmcReadBlocks;
- MmcHostInstance->BlockIo.WriteBlocks = MmcWriteBlocks;
- MmcHostInstance->BlockIo.FlushBlocks = MmcFlushBlocks;
-
- MmcHostInstance->MmcHost = MmcHost;
-
- // Create DevicePath for the new MMC Host
- Status = MmcHost->BuildDevicePath (MmcHost, &NewDevicePathNode);
- if (EFI_ERROR (Status)) {
- goto FREE_MEDIA;
- }
-
- DevicePath = (EFI_DEVICE_PATH_PROTOCOL*)AllocatePool (END_DEVICE_PATH_LENGTH);
- if (DevicePath == NULL) {
- goto FREE_MEDIA;
- }
-
- SetDevicePathEndNode (DevicePath);
- MmcHostInstance->DevicePath = AppendDevicePathNode (DevicePath, NewDevicePathNode);
-
- // Publish BlockIO protocol interface
- Status = gBS->InstallMultipleProtocolInterfaces (
- &MmcHostInstance->MmcHandle,
- &gEfiBlockIoProtocolGuid, &MmcHostInstance->BlockIo,
- &gEfiDevicePathProtocolGuid, MmcHostInstance->DevicePath,
- NULL
- );
- if (EFI_ERROR (Status)) {
- goto FREE_DEVICE_PATH;
- }
-
- return MmcHostInstance;
-
-FREE_DEVICE_PATH:
- FreePool (DevicePath);
-
-FREE_MEDIA:
- FreePool (MmcHostInstance->BlockIo.Media);
-
-FREE_INSTANCE:
- FreePool (MmcHostInstance);
-
- return NULL;
-}
-
-EFI_STATUS DestroyMmcHostInstance (
- IN MMC_HOST_INSTANCE* MmcHostInstance
- )
-{
- EFI_STATUS Status;
-
- // Uninstall Protocol Interfaces
- Status = gBS->UninstallMultipleProtocolInterfaces (
- MmcHostInstance->MmcHandle,
- &gEfiBlockIoProtocolGuid, &(MmcHostInstance->BlockIo),
- &gEfiDevicePathProtocolGuid, MmcHostInstance->DevicePath,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
-
- // Free Memory allocated for the instance
- if (MmcHostInstance->BlockIo.Media) {
- FreePool (MmcHostInstance->BlockIo.Media);
- }
- if (MmcHostInstance->CardInfo.ECSDData) {
- FreePages (MmcHostInstance->CardInfo.ECSDData, EFI_SIZE_TO_PAGES (sizeof (ECSD)));
- }
- FreePool (MmcHostInstance);
-
- return Status;
-}
-
-/**
- This function checks if the controller implement the Mmc Host and the Device Path Protocols
-**/
-EFI_STATUS
-EFIAPI
-MmcDriverBindingSupported (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- //EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
- EFI_DEV_PATH_PTR Node;
-
- //
- // Check RemainingDevicePath validation
- //
- if (RemainingDevicePath != NULL) {
- //
- // Check if RemainingDevicePath is the End of Device Path Node,
- // if yes, go on checking other conditions
- //
- if (!IsDevicePathEnd (RemainingDevicePath)) {
- //
- // If RemainingDevicePath isn't the End of Device Path Node,
- // check its validation
- //
- Node.DevPath = RemainingDevicePath;
- if (Node.DevPath->Type != HARDWARE_DEVICE_PATH ||
- Node.DevPath->SubType != HW_VENDOR_DP ||
- DevicePathNodeLength (Node.DevPath) != sizeof (VENDOR_DEVICE_PATH)) {
- return EFI_UNSUPPORTED;
- }
- }
- }
-
- //
- // Check if Mmc Host protocol is installed by platform
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gRaspberryPiMmcHostProtocolGuid,
- (VOID**)&MmcHost,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (Status == EFI_ALREADY_STARTED) {
- return EFI_SUCCESS;
- }
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Close the Mmc Host used to perform the supported test
- //
- gBS->CloseProtocol (
- Controller,
- &gRaspberryPiMmcHostProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
-
- return EFI_SUCCESS;
-}
-
-/**
-
-**/
-EFI_STATUS
-EFIAPI
-MmcDriverBindingStart (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath
- )
-{
- EFI_STATUS Status;
- MMC_HOST_INSTANCE *MmcHostInstance;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
-
- //
- // Check RemainingDevicePath validation
- //
- if (RemainingDevicePath != NULL) {
- //
- // Check if RemainingDevicePath is the End of Device Path Node,
- // if yes, return EFI_SUCCESS
- //
- if (IsDevicePathEnd (RemainingDevicePath)) {
- return EFI_SUCCESS;
- }
- }
-
- //
- // Get the Mmc Host protocol
- //
- Status = gBS->OpenProtocol (
- Controller,
- &gRaspberryPiMmcHostProtocolGuid,
- (VOID**)&MmcHost,
- This->DriverBindingHandle,
- Controller,
- EFI_OPEN_PROTOCOL_BY_DRIVER
- );
- if (EFI_ERROR (Status)) {
- if (Status == EFI_ALREADY_STARTED) {
- return EFI_SUCCESS;
- }
- return Status;
- }
-
- MmcHostInstance = CreateMmcHostInstance (MmcHost);
- if (MmcHostInstance != NULL) {
- // Add the handle to the pool
- InsertMmcHost (MmcHostInstance);
-
- MmcHostInstance->Initialized = FALSE;
-
- // Detect card presence now
- CheckCardsCallback (NULL, NULL);
- }
-
- return EFI_SUCCESS;
-}
-
-/**
-
-**/
-EFI_STATUS
-EFIAPI
-MmcDriverBindingStop (
- IN EFI_DRIVER_BINDING_PROTOCOL *This,
- IN EFI_HANDLE Controller,
- IN UINTN NumberOfChildren,
- IN EFI_HANDLE *ChildHandleBuffer
- )
-{
- EFI_STATUS Status = EFI_SUCCESS;
- LIST_ENTRY *CurrentLink;
- MMC_HOST_INSTANCE *MmcHostInstance;
-
- MMC_TRACE ("MmcDriverBindingStop()");
-
- // For each MMC instance
- CurrentLink = mMmcHostPool.ForwardLink;
- while (CurrentLink != NULL && CurrentLink != &mMmcHostPool && (Status == EFI_SUCCESS)) {
- MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK (CurrentLink);
- ASSERT (MmcHostInstance != NULL);
-
- // Close gRaspberryPiMmcHostProtocolGuid
- Status = gBS->CloseProtocol (
- Controller,
- &gRaspberryPiMmcHostProtocolGuid,
- (VOID**)&MmcHostInstance->MmcHost,
- This->DriverBindingHandle
- );
-
- // Remove MMC Host Instance from the pool
- RemoveMmcHost (MmcHostInstance);
-
- // Destroy MmcHostInstance
- DestroyMmcHostInstance (MmcHostInstance);
- }
-
- return Status;
-}
-
-VOID
-EFIAPI
-CheckCardsCallback (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- LIST_ENTRY *CurrentLink;
- MMC_HOST_INSTANCE *MmcHostInstance;
- EFI_STATUS Status;
-
- CurrentLink = mMmcHostPool.ForwardLink;
- while (CurrentLink != NULL && CurrentLink != &mMmcHostPool) {
- MmcHostInstance = MMC_HOST_INSTANCE_FROM_LINK (CurrentLink);
- ASSERT (MmcHostInstance != NULL);
-
- if (MmcHostInstance->MmcHost->IsCardPresent (MmcHostInstance->MmcHost) == !MmcHostInstance->Initialized) {
- MmcHostInstance->State = MmcHwInitializationState;
- MmcHostInstance->BlockIo.Media->MediaPresent = !MmcHostInstance->Initialized;
- MmcHostInstance->Initialized = !MmcHostInstance->Initialized;
-
- if (MmcHostInstance->BlockIo.Media->MediaPresent) {
- InitializeMmcDevice (MmcHostInstance);
- }
-
- Status = gBS->ReinstallProtocolInterface (
- (MmcHostInstance->MmcHandle),
- &gEfiBlockIoProtocolGuid,
- &(MmcHostInstance->BlockIo),
- &(MmcHostInstance->BlockIo)
- );
-
- if (EFI_ERROR (Status)) {
- Print (L"MMC Card: Error reinstalling BlockIo interface\n");
- }
- }
-
- CurrentLink = CurrentLink->ForwardLink;
- }
-}
-
-
-EFI_DRIVER_BINDING_PROTOCOL gMmcDriverBinding = {
- MmcDriverBindingSupported,
- MmcDriverBindingStart,
- MmcDriverBindingStop,
- 0xa,
- NULL,
- NULL
-};
-
-/**
-
-**/
-EFI_STATUS
-EFIAPI
-MmcDxeInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- //
- // Initializes MMC Host pool
- //
- InitializeMmcHostPool ();
-
- //
- // Install driver model protocol(s).
- //
- Status = EfiLibInstallDriverBindingComponentName2 (
- ImageHandle,
- SystemTable,
- &gMmcDriverBinding,
- ImageHandle,
- &gMmcComponentName,
- &gMmcComponentName2
- );
- ASSERT_EFI_ERROR (Status);
-
- // Install driver diagnostics
- Status = gBS->InstallMultipleProtocolInterfaces (
- &ImageHandle,
- &gEfiDriverDiagnostics2ProtocolGuid,
- &gMmcDriverDiagnostics2,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
-
- // Use a timer to detect if a card has been plugged in or removed
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL | EVT_TIMER,
- TPL_CALLBACK,
- CheckCardsCallback,
- NULL,
- &gCheckCardsEvent
- );
- ASSERT_EFI_ERROR (Status);
-
- Status = gBS->SetTimer (gCheckCardsEvent,
- TimerPeriodic,
- (UINT64)(10 * 1000 * 200)); // 200 ms
- ASSERT_EFI_ERROR (Status);
-
- return Status;
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/Mmc.h b/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/Mmc.h
deleted file mode 100644
index 28a890b0..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/Mmc.h
+++ /dev/null
@@ -1,527 +0,0 @@
-/** @file
- *
- * Main Header file for the MMC DXE driver
- *
- * Copyright (c) 2011-2015, ARM Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#ifndef __MMC_H
-#define __MMC_H
-
-#include <Uefi.h>
-
-#include <Protocol/DiskIo.h>
-#include <Protocol/BlockIo.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/RpiMmcHost.h>
-
-#include <Library/UefiLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-#define MMC_TRACE(txt) DEBUG((DEBUG_BLKIO, "MMC: " txt "\n"))
-
-#define MMC_IOBLOCKS_READ 0
-#define MMC_IOBLOCKS_WRITE 1
-
-#define MMC_OCR_POWERUP 0x80000000
-
-#define MMC_OCR_ACCESS_MASK 0x3 /* bit[30-29] */
-#define MMC_OCR_ACCESS_BYTE 0x1 /* bit[29] */
-#define MMC_OCR_ACCESS_SECTOR 0x2 /* bit[30] */
-
-#define MMC_CSD_GET_CCC(Response) (Response[2] >> 20)
-#define MMC_CSD_GET_TRANSPEED(Response) (Response[3] & 0xFF)
-#define MMC_CSD_GET_READBLLEN(Response) ((Response[2] >> 16) & 0xF)
-#define MMC_CSD_GET_WRITEBLLEN(Response) ((Response[0] >> 22) & 0xF)
-#define MMC_CSD_GET_FILEFORMAT(Response) ((Response[0] >> 10) & 0x3)
-#define MMC_CSD_GET_FILEFORMATGRP(Response) ((Response[0] >> 15) & 0x1)
-#define MMC_CSD_GET_DEVICESIZE(csd) (((Response[1] >> 30) & 0x3) | ((Response[2] & 0x3FF) << 2))
-#define HC_MMC_CSD_GET_DEVICESIZE(Response) ((Response[1] >> 16) | ((Response[2] & 0x3F) << 16));
-#define MMC_CSD_GET_DEVICESIZEMULT(csd) ((Response[1] >> 15) & 0x7)
-
-#define MMC_R0_READY_FOR_DATA (1 << 8)
-
-#define MMC_R0_CURRENTSTATE(Response) ((Response[0] >> 9) & 0xF)
-
-#define MMC_R0_STATE_IDLE 0
-#define MMC_R0_STATE_READY 1
-#define MMC_R0_STATE_IDENT 2
-#define MMC_R0_STATE_STDBY 3
-#define MMC_R0_STATE_TRAN 4
-#define MMC_R0_STATE_DATA 5
-#define MMC_R0_STATE_RECV 6
-#define MMC_R0_STATE_PROG 7
-#define MMC_R0_STATE_DIS 8
-
-
-#define EMMC_CMD6_ARG_ACCESS(x) (((x) & 0x3) << 24)
-#define EMMC_CMD6_ARG_INDEX(x) (((x) & 0xFF) << 16)
-#define EMMC_CMD6_ARG_VALUE(x) (((x) & 0xFF) << 8)
-#define EMMC_CMD6_ARG_CMD_SET(x) (((x) & 0x7) << 0)
-
-#define SWITCH_CMD_DATA_LENGTH 64
-#define SD_HIGH_SPEED_SUPPORTED 0x200
-#define SD_DEFAULT_SPEED 25000000
-#define SD_HIGH_SPEED 50000000
-#define SWITCH_CMD_SUCCESS_MASK 0xf
-
-#define BUSWIDTH_4 4
-
-typedef enum {
- UNKNOWN_CARD,
- MMC_CARD, //MMC card
- MMC_CARD_HIGH, //MMC Card with High capacity
- EMMC_CARD, //eMMC 4.41 card
- SD_CARD, //SD 1.1 card
- SD_CARD_2, //SD 2.0 or above standard card
- SD_CARD_2_HIGH //SD 2.0 or above high capacity card
-} CARD_TYPE;
-
-typedef struct {
- UINT32 Reserved0: 7; // 0
- UINT32 V170_V195: 1; // 1.70V - 1.95V
- UINT32 V200_V260: 7; // 2.00V - 2.60V
- UINT32 V270_V360: 9; // 2.70V - 3.60V
- UINT32 RESERVED_1: 5; // Reserved
- UINT32 AccessMode: 2; // 00b (byte mode), 10b (sector mode)
- UINT32 PowerUp: 1; // This bit is set to LOW if the card has not finished the power up routine
-} OCR;
-
-typedef struct {
- UINT8 SD_SPEC: 4; // SD Memory Card - Spec. Version [59:56]
- UINT8 SCR_STRUCTURE: 4; // SCR Structure [63:60]
- UINT8 SD_BUS_WIDTHS: 4; // DAT Bus widths supported [51:48]
- UINT8 DATA_STAT_AFTER_ERASE: 1; // Data Status after erases [55]
- UINT8 SD_SECURITY: 3; // CPRM Security Support [54:52]
- UINT8 EX_SECURITY_1: 1; // Extended Security Support [43]
- UINT8 SD_SPEC4: 1; // Spec. Version 4.00 or higher [42]
- UINT8 RESERVED_1: 2; // Reserved [41:40]
- UINT8 SD_SPEC3: 1; // Spec. Version 3.00 or higher [47]
- UINT8 EX_SECURITY_2: 3; // Extended Security Support [46:44]
- UINT8 CMD_SUPPORT: 4; // Command Support bits [35:32]
- UINT8 RESERVED_2: 4; // Reserved [39:36]
- UINT32 RESERVED_3; // Manufacturer Usage [31:0]
-} SCR;
-
-typedef struct {
- UINT32 NOT_USED; // 1 [0:0]
- UINT32 CRC; // CRC7 checksum [7:1]
-
- UINT32 MDT; // Manufacturing date [19:8]
- UINT32 RESERVED_1; // Reserved [23:20]
- UINT32 PSN; // Product serial number [55:24]
- UINT8 PRV; // Product revision [63:56]
- UINT8 PNM[5]; // Product name [64:103]
- UINT16 OID; // OEM/Application ID [119:104]
- UINT8 MID; // Manufacturer ID [127:120]
-} CID;
-
-typedef struct {
- UINT8 NOT_USED: 1; // Not used, always 1 [0:0]
- UINT8 CRC: 7; // CRC [7:1]
-
- UINT8 RESERVED_1: 2; // Reserved [9:8]
- UINT8 FILE_FORMAT: 2; // File format [11:10]
- UINT8 TMP_WRITE_PROTECT: 1; // Temporary write protection [12:12]
- UINT8 PERM_WRITE_PROTECT: 1; // Permanent write protection [13:13]
- UINT8 COPY: 1; // Copy flag (OTP) [14:14]
- UINT8 FILE_FORMAT_GRP: 1; // File format group [15:15]
-
- UINT16 RESERVED_2: 5; // Reserved [20:16]
- UINT16 WRITE_BL_PARTIAL: 1; // Partial blocks for write allowed [21:21]
- UINT16 WRITE_BL_LEN: 4; // Max. write data block length [25:22]
- UINT16 R2W_FACTOR: 3; // Write speed factor [28:26]
- UINT16 RESERVED_3: 2; // Reserved [30:29]
- UINT16 WP_GRP_ENABLE: 1; // Write protect group enable [31:31]
-
- UINT32 WP_GRP_SIZE: 7; // Write protect group size [38:32]
- UINT32 SECTOR_SIZE: 7; // Erase sector size [45:39]
- UINT32 ERASE_BLK_EN: 1; // Erase single block enable [46:46]
- UINT32 C_SIZE_MULT: 3; // Device size multiplier [49:47]
- UINT32 VDD_W_CURR_MAX: 3; // Max. write current @ VDD max [52:50]
- UINT32 VDD_W_CURR_MIN: 3; // Max. write current @ VDD min [55:53]
- UINT32 VDD_R_CURR_MAX: 3; // Max. read current @ VDD max [58:56]
- UINT32 VDD_R_CURR_MIN: 3; // Max. read current @ VDD min [61:59]
- UINT32 C_SIZELow2: 2; // Device size [63:62]
-
- UINT32 C_SIZEHigh10: 10;// Device size [73:64]
- UINT32 RESERVED_4: 2; // Reserved [75:74]
- UINT32 DSR_IMP: 1; // DSR implemented [76:76]
- UINT32 READ_BLK_MISALIGN: 1; // Read block misalignment [77:77]
- UINT32 WRITE_BLK_MISALIGN: 1; // Write block misalignment [78:78]
- UINT32 READ_BL_PARTIAL: 1; // Partial blocks for read allowed [79:79]
- UINT32 READ_BL_LEN: 4; // Max. read data block length [83:80]
- UINT32 CCC: 12;// Card command classes [95:84]
-
- UINT8 TRAN_SPEED ; // Max. bus clock frequency [103:96]
- UINT8 NSAC ; // Data read access-time 2 in CLK cycles (NSAC*100) [111:104]
- UINT8 TAAC ; // Data read access-time 1 [119:112]
-
- UINT8 RESERVED_5: 2; // Reserved [121:120]
- UINT8 SPEC_VERS: 4; // System specification version [125:122]
- UINT8 CSD_STRUCTURE: 2; // CSD structure [127:126]
-} CSD;
-
-typedef struct {
- UINT8 RESERVED_1[16]; // Reserved [15:0]
- UINT8 SECURE_REMOVAL_TYPE; // Secure Removal Type [16:16]
- UINT8 PRODUCT_STATE_AWARENESS_ENABLEMENT; // Product state awareness enablement [17:17]
- UINT8 MAX_PRE_LOADING_DATA_SIZE[4]; // MAX pre loading data size [21:18]
- UINT8 PRE_LOADING_DATA_SIZE[4]; // Pre loading data size [25:22]
- UINT8 FFU_STATUS; // FFU Status [26:26]
- UINT8 RESERVED_2[2]; // Reserved [28:27]
- UINT8 MODE_OPERATION_CODES; // Mode operation codes [29:29]
- UINT8 MODE_CONFIG; // Mode config [30:30]
- UINT8 RESERVED_3; // Reserved [31:31]
- UINT8 FLUSH_CACHE; // Flushing of the cache [32:32]
- UINT8 CACHE_CTRL; // Control to turn the cache ON/OFF [33:33]
- UINT8 POWER_OFF_NOTIFICATION; // Power Off Notification [34:34]
- UINT8 PACKED_FAILURE_INDEX; // Packed command failure index [35:35]
- UINT8 PACKED_COMMAND_STATUS; // Packed command status [36:36]
- UINT8 CONTEXT_CONF[15]; // Context configuration [51:37]
- UINT8 EXT_PARTITIONS_ATTRIBUTE[2]; // Extended partitions attribute [53:52]
- UINT8 EXCEPTION_EVENTS_STATUS[2]; // Exception events status [55:54]
- UINT8 EXCEPTION_EVENTS_CTRL[2]; // Exception events control [57:56]
- UINT8 DYNCAP_NEEDED; // Number of addressed group to be released [58:58]
- UINT8 CLASS_6_CTRL; // Class 6 commands control [59:59]
- UINT8 INI_TIMEOUT_EMU; // 1st initialization after disabling sector size emulation [60:60]
- UINT8 DATA_SECTOR_SIZE; // Sector size [61:61]
- UINT8 USE_NATIVE_SECTOR; // Sector size emulation [62:62]
- UINT8 NATIVE_SECTOR_SIZE; // Native sector size [63:63]
- UINT8 VENDOR_SPECIFIC_FIELD[64]; // Vendor specific fields [127:64]
- UINT8 RESERVED_4[2]; // Reserved [129:128]
- UINT8 PROGRAM_CID_CSD_DDR_SUPPORT; // Program CID/CSD in DDR mode support [130:130]
- UINT8 PERIODIC_WAKEUP; // Periodic wake-up [131:131]
- UINT8 TCASE_SUPPORT; // Package case temperature is controlled [132:132]
- UINT8 PRODUCTION_STATE_AWARENESS; // Production state awareness [133:133]
- UINT8 SECTOR_BAD_BLK_MGMNT; // Bad block management mode [134:134]
- UINT8 RESERVED_5; // Reserved [135:135]
- UINT8 ENH_START_ADDR[4]; // Enhanced user data start address [139:136]
- UINT8 ENH_SIZE_MULT[3]; // Enhanced user data area size [142:140]
- UINT8 GP_SIZE_MULT[12]; // General purpose partition size [154:143]
- UINT8 PARTITION_SETTING_COMPLETED; // Partitioning setting [155:155]
- UINT8 PARTITIONS_ATTRIBUTE; // Partitions attribute [156:156]
- UINT8 MAX_ENH_SIZE_MULT[3]; // Max enhanced area size [159:157]
- UINT8 PARTITIONING_SUPPORT; // Partitioning [160:160]
- UINT8 HPI_MGMT; // HPI management [161:161]
- UINT8 RST_N_FUNCTION; // H/W reset function [162:162]
- UINT8 BKOPS_EN; // Enable background operations handshake [163:163]
- UINT8 BKOPS_START; // Manually start background operations [164:164]
- UINT8 SANITIZE_START; // Start sanitize operation [165:165]
- UINT8 WR_REL_PARAM; // Write reliability parameter register [166:166]
- UINT8 WR_REL_SET; // Write reliability setting register [167:167]
- UINT8 RPMB_SIZE_MULT; // RPMB size [168:168]
- UINT8 FW_CONFIG; // FW configuration [169:169]
- UINT8 RESERVED_6; // Reserved [170:170]
- UINT8 USER_WP; // User area write protection register [171:171]
- UINT8 RESERVED_7; // Reserved [172:172]
- UINT8 BOOT_WP; // Boot area write protection register [173:173]
- UINT8 BOOT_WP_STATUS; // Boot write protection register [174:174]
- UINT8 ERASE_GROUP_DEF; // High-density erase group definition [175:175]
- UINT8 RESERVED_8; // Reserved [176:176]
- UINT8 BOOT_BUS_CONDITIONS; // Boot bus conditions [177:177]
- UINT8 BOOT_CONFIG_PROT; // Boot config protection [178:178]
- UINT8 PARTITION_CONFIG; // Partition config [179:179]
- UINT8 RESERVED_9; // Reserved [180:180]
- UINT8 ERASED_MEM_CONT; // Erased memory content [181:181]
- UINT8 RESERVED_10; // Reserved [182:182]
- UINT8 BUS_WIDTH; // Bus width mode [183:183]
- UINT8 RESERVED_11; // Reserved [184:184]
- UINT8 HS_TIMING; // High-speed interface timing [185:185]
- UINT8 RESERVED_12; // Reserved [186:186]
- UINT8 POWER_CLASS; // Power class [187:187]
- UINT8 RESERVED_13; // Reserved [188:188]
- UINT8 CMD_SET_REV; // Command set revision [189:189]
- UINT8 RESERVED_14; // Reserved [190:190]
- UINT8 CMD_SET; // Command set [191:191]
- UINT8 EXT_CSD_REV; // Extended CSD revision [192:192]
- UINT8 RESERVED_15; // Reserved [193:193]
- UINT8 CSD_STRUCTURE; // CSD Structure [194:194]
- UINT8 RESERVED_16; // Reserved [195:195]
- UINT8 DEVICE_TYPE; // Device type [196:196]
- UINT8 DRIVER_STRENGTH; // I/O Driver strength [197:197]
- UINT8 OUT_OF_INTERRUPT_TIME; // Out-of-interrupt busy timing [198:198]
- UINT8 PARTITION_SWITCH_TIME; // Partition switching timing [199:199]
- UINT8 PWR_CL_52_195; // Power class for 52MHz at 1.95V 1 R [200:200]
- UINT8 PWR_CL_26_195; // Power class for 26MHz at 1.95V 1 R [201:201]
- UINT8 PWR_CL_52_360; // Power class for 52MHz at 3.6V 1 R [202:202]
- UINT8 PWR_CL_26_360; // Power class for 26MHz at 3.6V 1 R [203:203]
- UINT8 RESERVED_17; // Reserved [204:204]
- UINT8 MIN_PERF_R_4_26; // Minimum read performance for 4bit at 26MHz [205:205]
- UINT8 MIN_PERF_W_4_26; // Minimum write performance for 4bit at 26MHz [206:206]
- UINT8 MIN_PERF_R_8_26_4_52; // Minimum read performance for 8bit at 26MHz, for 4bit at 52MHz [207:207]
- UINT8 MIN_PERF_W_8_26_4_52; // Minimum write performance for 8bit at 26MHz, for 4bit at 52MHz [208:208]
- UINT8 MIN_PERF_R_8_52; // Minimum read performance for 8bit at 52MHz [209:209]
- UINT8 MIN_PERF_W_8_52; // Minimum write performance for 8bit at 52MHz [210:210]
- UINT8 RESERVED_18; // Reserved [211:211]
- UINT32 SECTOR_COUNT; // Sector count [215:212]
- UINT8 SLEEP_NOTIFICATION_TIME; // Sleep notification timout [216:216]
- UINT8 S_A_TIMEOUT; // Sleep/awake timeout [217:217]
- UINT8 PRODUCTION_STATE_AWARENESS_TIMEOUT; // Production state awareness timeout [218:218]
- UINT8 S_C_VCCQ; // Sleep current (VCCQ) [219:219]
- UINT8 S_C_VCC; // Sleep current (VCC) [220:220]
- UINT8 HC_WP_GRP_SIZE; // High-capacity write protect group size [221:221]
- UINT8 REL_WR_SECTOR_C; // Reliable write sector count [222:222]
- UINT8 ERASE_TIMEOUT_MULT; // High-capacity erase timeout [223:223]
- UINT8 HC_ERASE_GRP_SIZE; // High-capacity erase unit size [224:224]
- UINT8 ACC_SIZE; // Access size [225:225]
- UINT8 BOOT_SIZE_MULTI; // Boot partition size [226:226]
- UINT8 RESERVED_19; // Reserved [227:227]
- UINT8 BOOT_INFO; // Boot information [228:228]
- UINT8 SECURE_TRIM_MULT; // Secure TRIM Multiplier [229:229]
- UINT8 SECURE_ERASE_MULT; // Secure Erase Multiplier [230:230]
- UINT8 SECURE_FEATURE_SUPPORT; // Secure Feature Support [231:231]
- UINT8 TRIM_MULT; // TRIM Multiplier [232:232]
- UINT8 RESERVED_20; // Reserved [233:233]
- UINT8 MIN_PREF_DDR_R_8_52; // Minimum read performance for 8bit at 52MHz in DDR mode [234:234]
- UINT8 MIN_PREF_DDR_W_8_52; // Minimum write performance for 8bit at 52MHz in DDR mode [235:235]
- UINT8 PWR_CL_200_130; // Power class for 200MHz at VCCQ=1.3V, VCC=3.6V [236:236]
- UINT8 PWR_CL_200_195; // Power class for 200MHz at VCCQ=1.95V, VCC=3.6V [237:237]
- UINT8 PWR_CL_DDR_52_195; // Power class for 52MHz, DDR at 1.95V [238:238]
- UINT8 PWR_CL_DDR_52_360; // Power class for 52Mhz, DDR at 3.6V [239:239]
- UINT8 RESERVED_21; // Reserved [240:240]
- UINT8 INI_TIMEOUT_AP; // 1st initialization time after partitioning [241:241]
- UINT8 CORRECTLY_PRG_SECTORS_NUM[4]; // Number of correctly programmed sectors [245:242]
- UINT8 BKOPS_STATUS; // Background operations status [246:246]
- UINT8 POWER_OFF_LONG_TIME; // Power off notification (long) timeout [247:247]
- UINT8 GENERIC_CMD6_TIME; // Generic CMD6 timeout [248:248]
- UINT8 CACHE_SIZE[4]; // Cache size [252:249]
- UINT8 PWR_CL_DDR_200_360; // Power class for 200MHz, DDR at VCC=3.6V [253:253]
- UINT8 FIRMWARE_VERSION[8]; // Firmware version [261:254]
- UINT8 DEVICE_VERSION[2]; // Device version [263:262]
- UINT8 OPTIMAL_TRIM_UNIT_SIZE; // Optimal trim unit size [264:264]
- UINT8 OPTIMAL_WRITE_SIZE; // Optimal write size [265:265]
- UINT8 OPTIMAL_READ_SIZE; // Optimal read size [266:266]
- UINT8 PRE_EOL_INFO; // Pre EOL information [267:267]
- UINT8 DEVICE_LIFE_TIME_EST_TYP_A; // Device life time estimation type A [268:268]
- UINT8 DEVICE_LIFE_TIME_EST_TYP_B; // Device life time estimation type B [269:269]
- UINT8 VENDOR_PROPRIETARY_HEALTH_REPORT[32]; // Vendor proprietary health report [301:270]
- UINT8 NUMBER_OF_FW_SECTORS_CORRECTLY_PROGRAMMED[4]; // Number of FW sectors correctly programmed [305:302]
- UINT8 RESERVED_22[181]; // Reserved [486:306]
- UINT8 FFU_ARG[4]; // FFU argument [490:487]
- UINT8 OPERATION_CODE_TIMEOUT; // Operation codes timeout [491:491]
- UINT8 FFU_FEATURES; // FFU features [492:492]
- UINT8 SUPPORTED_MODES; // Supported modes [493:493]
- UINT8 EXT_SUPPORT; // Extended partitions attribute support [494:494]
- UINT8 LARGE_UNIT_SIZE_M1; // Large unit size [495:495]
- UINT8 CONTEXT_CAPABILITIES; // Context management capabilities [496:496]
- UINT8 TAG_RES_SIZE; // Tag resource size [497:497]
- UINT8 TAG_UNIT_SIZE; // Tag unit size [498:498]
- UINT8 DATA_TAG_SUPPORT; // Data tag support [499:499]
- UINT8 MAX_PACKED_WRITES; // Max packed write commands [500:500]
- UINT8 MAX_PACKED_READS; // Max packed read commands [501:501]
- UINT8 BKOPS_SUPPORT; // Background operations support [502:502]
- UINT8 HPI_FEATURES; // HPI features [503:503]
- UINT8 S_CMD_SET; // Supported command sets [504:504]
- UINT8 EXT_SECURITY_ERR; // Extended security commands error [505:505]
- UINT8 RESERVED_23[6]; // Reserved [511:506]
-} ECSD;
-
-typedef struct {
- UINT16 RCA;
- CARD_TYPE CardType;
- OCR OCRData;
- CID CIDData;
- CSD CSDData;
- ECSD *ECSDData; // MMC V4 extended card specific
-} CARD_INFO;
-
-typedef struct _MMC_HOST_INSTANCE {
- UINTN Signature;
- LIST_ENTRY Link;
- EFI_HANDLE MmcHandle;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
-
- MMC_STATE State;
- EFI_BLOCK_IO_PROTOCOL BlockIo;
- CARD_INFO CardInfo;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
-
- BOOLEAN Initialized;
-} MMC_HOST_INSTANCE;
-
-#define MMC_HOST_INSTANCE_SIGNATURE SIGNATURE_32('m', 'm', 'c', 'h')
-#define MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS(a) CR (a, MMC_HOST_INSTANCE, BlockIo, MMC_HOST_INSTANCE_SIGNATURE)
-#define MMC_HOST_INSTANCE_FROM_LINK(a) CR (a, MMC_HOST_INSTANCE, Link, MMC_HOST_INSTANCE_SIGNATURE)
-
-
-EFI_STATUS
-EFIAPI
-MmcGetDriverName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN CHAR8 *Language,
- OUT CHAR16 **DriverName
- );
-
-EFI_STATUS
-EFIAPI
-MmcGetControllerName (
- IN EFI_COMPONENT_NAME_PROTOCOL *This,
- IN EFI_HANDLE ControllerHandle,
- IN EFI_HANDLE ChildHandle OPTIONAL,
- IN CHAR8 *Language,
- OUT CHAR16 **ControllerName
- );
-
-extern EFI_COMPONENT_NAME_PROTOCOL gMmcComponentName;
-extern EFI_COMPONENT_NAME2_PROTOCOL gMmcComponentName2;
-
-extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gMmcDriverDiagnostics2;
-
-extern LIST_ENTRY mMmcHostPool;
-
-/**
- Reset the block device.
-
- This function implements EFI_BLOCK_IO_PROTOCOL.Reset().
- It resets the block device hardware.
- ExtendedVerification is ignored in this implementation.
-
- @param This Indicates a pointer to the calling context.
- @param ExtendedVerification Indicates that the driver may perform a more exhaustive
- verification operation of the device during reset.
-
- @retval EFI_SUCCESS The block device was reset.
- @retval EFI_DEVICE_ERROR The block device is not functioning correctly and could not be reset.
-
-**/
-EFI_STATUS
-EFIAPI
-MmcReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- );
-
-/**
- Reads the requested number of blocks from the device.
-
- This function implements EFI_BLOCK_IO_PROTOCOL.ReadBlocks().
- It reads the requested number of blocks from the device.
- All the blocks are read, or an error is returned.
-
- @param This Indicates a pointer to the calling context.
- @param MediaId The media ID that the read request is for.
- @param Lba The starting logical block address to read from on the device.
- @param BufferSize The size of the Buffer in bytes.
- This must be a multiple of the intrinsic block size of the device.
- @param Buffer A pointer to the destination buffer for the data. The caller is
- responsible for either having implicit or explicit ownership of the buffer.
-
- @retval EFI_SUCCESS The data was read correctly from the device.
- @retval EFI_DEVICE_ERROR The device reported an error while attempting to perform the read operation.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
- @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the intrinsic block size of the device.
- @retval EFI_INVALID_PARAMETER The read request contains LBAs that are not valid,
- or the buffer is not on proper alignment.
-
-**/
-EFI_STATUS
-EFIAPI
-MmcReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- );
-
-/**
- Writes a specified number of blocks to the device.
-
- This function implements EFI_BLOCK_IO_PROTOCOL.WriteBlocks().
- It writes a specified number of blocks to the device.
- All blocks are written, or an error is returned.
-
- @param This Indicates a pointer to the calling context.
- @param MediaId The media ID that the write request is for.
- @param Lba The starting logical block address to be written.
- @param BufferSize The size of the Buffer in bytes.
- This must be a multiple of the intrinsic block size of the device.
- @param Buffer Pointer to the source buffer for the data.
-
- @retval EFI_SUCCESS The data were written correctly to the device.
- @retval EFI_WRITE_PROTECTED The device cannot be written to.
- @retval EFI_NO_MEDIA There is no media in the device.
- @retval EFI_MEDIA_CHANGED The MediaId is not for the current media.
- @retval EFI_DEVICE_ERROR The device reported an error while attempting to perform the write operation.
- @retval EFI_BAD_BUFFER_SIZE The BufferSize parameter is not a multiple of the intrinsic
- block size of the device.
- @retval EFI_INVALID_PARAMETER The write request contains LBAs that are not valid,
- or the buffer is not on proper alignment.
-
-**/
-EFI_STATUS
-EFIAPI
-MmcWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
- );
-
-/**
- Flushes all modified data to a physical block device.
-
- @param This Indicates a pointer to the calling context.
-
- @retval EFI_SUCCESS All outstanding data were written correctly to the device.
- @retval EFI_DEVICE_ERROR The device reported an error while attempting to write data.
- @retval EFI_NO_MEDIA There is no media in the device.
-
-**/
-EFI_STATUS
-EFIAPI
-MmcFlushBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This
- );
-
-EFI_STATUS
-MmcNotifyState (
- IN MMC_HOST_INSTANCE *MmcHostInstance,
- IN MMC_STATE State
- );
-
-EFI_STATUS
-InitializeMmcDevice (
- IN MMC_HOST_INSTANCE *MmcHost
- );
-
-VOID
-EFIAPI
-CheckCardsCallback (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-VOID
-PrintCSD (
- IN UINT32* Csd
- );
-
-VOID
-PrintRCA (
- IN UINT32 Rca
- );
-
-VOID
-PrintOCR (
- IN UINT32 Ocr
- );
-
-VOID
-PrintResponseR1 (
- IN UINT32 Response
- );
-
-VOID
-PrintCID (
- IN UINT32* Cid
- );
-
-#endif
diff --git a/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcBlockIo.c b/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcBlockIo.c
deleted file mode 100644
index 29a9fd7d..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcBlockIo.c
+++ /dev/null
@@ -1,463 +0,0 @@
-/** @file
- *
- * Copyright (c) 2011-2015, ARM Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <Library/BaseMemoryLib.h>
-
-#include "Mmc.h"
-
-#define MMCI0_BLOCKLEN 512
-#define MMCI0_TIMEOUT 1000
-
-STATIC
-EFI_STATUS
-R1TranAndReady (
- UINT32 *Response
- )
-{
- if ((*Response & MMC_R0_READY_FOR_DATA) != 0 &&
- MMC_R0_CURRENTSTATE (Response) == MMC_R0_STATE_TRAN) {
- return EFI_SUCCESS;
- }
-
- return EFI_NOT_READY;
-}
-
-STATIC
-EFI_STATUS
-ValidateWrittenBlockCount (
- IN MMC_HOST_INSTANCE *MmcHostInstance,
- IN UINTN Count,
- OUT UINTN *TransferredBlocks
- )
-{
- UINT32 R1;
- UINT8 Data[4];
- EFI_STATUS Status;
- UINT32 BlocksWritten;
- EFI_MMC_HOST_PROTOCOL *MmcHost = MmcHostInstance->MmcHost;
-
- if (MmcHostInstance->CardInfo.CardType == MMC_CARD ||
- MmcHostInstance->CardInfo.CardType == MMC_CARD_HIGH ||
- MmcHostInstance->CardInfo.CardType == EMMC_CARD) {
- /*
- * Not on MMC.
- */
- return EFI_SUCCESS;
- }
-
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD55,
- MmcHostInstance->CardInfo.RCA << 16);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a(%u): error: %r\n", __FUNCTION__, __LINE__, Status));
- return Status;
- }
-
- Status = MmcHost->SendCommand (MmcHost, MMC_ACMD22, 0);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a(%u): error: %r\n",
- __FUNCTION__, __LINE__, Status));
- return Status;
- }
-
- MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, &R1);
- Status = R1TranAndReady (&R1);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- // Read Data
- Status = MmcHost->ReadBlockData (MmcHost, 0, sizeof (Data),
- (VOID*)Data);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a(%u): error: %r\n", __FUNCTION__, __LINE__, Status));
- return Status;
- }
-
- /*
- * Big Endian.
- */
- BlocksWritten = ((UINT32)Data[0] << 24) |
- ((UINT32)Data[1] << 16) |
- ((UINT32)Data[2] << 8) |
- ((UINT32)Data[3] << 0);
- if (BlocksWritten != Count) {
- DEBUG ((DEBUG_ERROR, "%a(%u): expected %u != gotten %u\n",
- __FUNCTION__, __LINE__, Count, BlocksWritten));
- if (BlocksWritten == 0) {
- return EFI_DEVICE_ERROR;
- }
- }
-
- *TransferredBlocks = BlocksWritten;
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-WaitUntilTran (
- IN MMC_HOST_INSTANCE *MmcHostInstance
- )
-{
- INTN Timeout;
- UINT32 Response[1];
- EFI_STATUS Status = EFI_SUCCESS;
- EFI_MMC_HOST_PROTOCOL *MmcHost = MmcHostInstance->MmcHost;
-
- Timeout = MMCI0_TIMEOUT;
- while (Timeout--) {
- /*
- * We expect CMD13 to timeout while card is programming,
- * because the card holds DAT0 low (busy).
- */
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD13,
- MmcHostInstance->CardInfo.RCA << 16);
- if (EFI_ERROR (Status) && Status != EFI_TIMEOUT) {
- DEBUG ((DEBUG_ERROR, "%a(%u) CMD13 failed: %r\n", __FUNCTION__, __LINE__, Status));
- break;
- }
-
- if (Status == EFI_SUCCESS) {
- MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, Response);
- Status = R1TranAndReady (Response);
- if (!EFI_ERROR (Status)) {
- break;
- }
- }
-
- gBS->Stall (1000);
- }
-
- if (0 == Timeout) {
- DEBUG ((DEBUG_ERROR, "%a(%u) card is busy\n", __FUNCTION__, __LINE__));
- return EFI_NOT_READY;
- }
-
- return Status;
-}
-
-EFI_STATUS
-MmcNotifyState (
- IN MMC_HOST_INSTANCE *MmcHostInstance,
- IN MMC_STATE State
- )
-{
- MmcHostInstance->State = State;
- return MmcHostInstance->MmcHost->NotifyState (MmcHostInstance->MmcHost, State);
-}
-
-EFI_STATUS
-EFIAPI
-MmcReset (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN BOOLEAN ExtendedVerification
- )
-{
- MMC_HOST_INSTANCE *MmcHostInstance;
-
- MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
-
- if (MmcHostInstance->MmcHost == NULL) {
- // Nothing to do
- return EFI_SUCCESS;
- }
-
- // If a card is not present then clear all media settings
- if (!MmcHostInstance->MmcHost->IsCardPresent (MmcHostInstance->MmcHost)) {
- MmcHostInstance->BlockIo.Media->MediaPresent = FALSE;
- MmcHostInstance->BlockIo.Media->LastBlock = 0;
- MmcHostInstance->BlockIo.Media->BlockSize = 512; // Should be zero but there is a bug in DiskIo
- MmcHostInstance->BlockIo.Media->ReadOnly = FALSE;
-
- // Indicate that the driver requires initialization
- MmcHostInstance->State = MmcHwInitializationState;
-
- return EFI_SUCCESS;
- }
-
- // Implement me. Either send a CMD0 (could not work for some MMC host)
- // or just turn off/turn on power and restart Identification mode.
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-MmcDetectCard (
- EFI_MMC_HOST_PROTOCOL *MmcHost
- )
-{
- if (!MmcHost->IsCardPresent (MmcHost)) {
- return EFI_NO_MEDIA;
- } else {
- return EFI_SUCCESS;
- }
-}
-
-EFI_STATUS
-MmcStopTransmission (
- EFI_MMC_HOST_PROTOCOL *MmcHost
- )
-{
- EFI_STATUS Status;
- UINT32 Response[4];
- // Command 12 - Stop transmission (ends read or write)
- // Normally only needed for streaming transfers or after error.
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD12, 0);
- if (!EFI_ERROR (Status)) {
- MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1b, Response);
- }
- return Status;
-}
-
-STATIC
-EFI_STATUS
-MmcTransferBlock (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINTN Cmd,
- IN UINTN Transfer,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer,
- OUT UINTN *TransferredSize
- )
-{
- EFI_STATUS Status;
- MMC_HOST_INSTANCE *MmcHostInstance;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
- UINTN CmdArg;
-
- MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
- MmcHost = MmcHostInstance->MmcHost;
-
- //Set command argument based on the card access mode (Byte mode or Block mode)
- if ((MmcHostInstance->CardInfo.OCRData.AccessMode & MMC_OCR_ACCESS_MASK) ==
- MMC_OCR_ACCESS_SECTOR) {
- CmdArg = Lba;
- } else {
- CmdArg = Lba * This->Media->BlockSize;
- }
-
- Status = MmcHost->SendCommand (MmcHost, Cmd, CmdArg);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a(MMC_CMD%d): Error %r\n", __func__, MMC_INDX (Cmd), Status));
- return Status;
- }
-
- if (Transfer == MMC_IOBLOCKS_READ) {
- Status = MmcHost->ReadBlockData (MmcHost, Lba, BufferSize, Buffer);
- } else {
- Status = MmcHost->WriteBlockData (MmcHost, Lba, BufferSize, Buffer);
- if (!EFI_ERROR (Status)) {
- Status = MmcNotifyState (MmcHostInstance, MmcProgrammingState);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a(): Error MmcProgrammingState\n", __func__));
- return Status;
- }
- }
- }
-
- if (EFI_ERROR (Status) ||
- BufferSize > This->Media->BlockSize) {
- /*
- * CMD12 needs to be set for multiblock (to transition from
- * RECV to PROG) or for errors.
- */
- EFI_STATUS Status2 = MmcStopTransmission (MmcHost);
- if (EFI_ERROR (Status2)) {
- DEBUG ((DEBUG_ERROR, "MmcIoBlocks(): CMD12 error on Status %r: %r\n",
- Status, Status2));
- return Status2;
- }
-
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_BLKIO, "%a(): Error %a Block Data and Status = %r\n",
- __func__, Transfer == MMC_IOBLOCKS_READ ? "Read" : "Write", Status));
- return Status;
- }
-
- ASSERT (Cmd == MMC_CMD25 || Cmd == MMC_CMD18);
- }
-
- //
- // For reads, should be already in TRAN. For writes, wait
- // until programming finishes.
- //
- Status = WaitUntilTran (MmcHostInstance);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "WaitUntilTran after write failed\n"));
- return Status;
- }
-
- Status = MmcNotifyState (MmcHostInstance, MmcTransferState);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "MmcIoBlocks() : Error MmcTransferState\n"));
- return Status;
- }
-
- if (Transfer != MMC_IOBLOCKS_READ) {
- UINTN BlocksWritten = 0;
-
- Status = ValidateWrittenBlockCount (MmcHostInstance,
- BufferSize /
- This->Media->BlockSize,
- &BlocksWritten);
- *TransferredSize = BlocksWritten * This->Media->BlockSize;
- } else {
- *TransferredSize = BufferSize;
- }
-
- return Status;
-}
-
-EFI_STATUS
-MmcIoBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINTN Transfer,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-{
- EFI_STATUS Status;
- UINTN Cmd;
- MMC_HOST_INSTANCE *MmcHostInstance;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
- UINTN BytesRemainingToBeTransfered;
- UINTN BlockCount;
- UINTN ConsumeSize;
-
- BlockCount = 1;
- MmcHostInstance = MMC_HOST_INSTANCE_FROM_BLOCK_IO_THIS (This);
- ASSERT (MmcHostInstance != NULL);
- MmcHost = MmcHostInstance->MmcHost;
- ASSERT (MmcHost);
-
- if (This->Media->MediaId != MediaId) {
- return EFI_MEDIA_CHANGED;
- }
-
- if ((MmcHost == NULL) || (Buffer == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- // Check if a Card is Present
- if (!MmcHostInstance->BlockIo.Media->MediaPresent) {
- return EFI_NO_MEDIA;
- }
-
- if (PcdGet32 (PcdMmcDisableMulti) == 0 &&
- MMC_HOST_HAS_ISMULTIBLOCK (MmcHost) &&
- MmcHost->IsMultiBlock (MmcHost)) {
- BlockCount = (BufferSize + This->Media->BlockSize - 1) / This->Media->BlockSize;
- }
-
- // All blocks must be within the device
- if ((Lba + (BufferSize / This->Media->BlockSize)) > (This->Media->LastBlock + 1)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((Transfer == MMC_IOBLOCKS_WRITE) && (This->Media->ReadOnly == TRUE)) {
- return EFI_WRITE_PROTECTED;
- }
-
- // Reading 0 Byte is valid
- if (BufferSize == 0) {
- return EFI_SUCCESS;
- }
-
- // The buffer size must be an exact multiple of the block size
- if ((BufferSize % This->Media->BlockSize) != 0) {
- return EFI_BAD_BUFFER_SIZE;
- }
-
- // Check the alignment
- if ((This->Media->IoAlign > 2) && (((UINTN)Buffer & (This->Media->IoAlign - 1)) != 0)) {
- return EFI_INVALID_PARAMETER;
- }
-
- BytesRemainingToBeTransfered = BufferSize;
- while (BytesRemainingToBeTransfered > 0) {
- Status = WaitUntilTran (MmcHostInstance);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "WaitUntilTran before IO failed"));
- return Status;
- }
-
- if (Transfer == MMC_IOBLOCKS_READ) {
- if (BlockCount == 1) {
- // Read a single block
- Cmd = MMC_CMD17;
- } else {
- // Read multiple blocks
- Cmd = MMC_CMD18;
- }
- } else {
- if (BlockCount == 1) {
- // Write a single block
- Cmd = MMC_CMD24;
- } else {
- // Write multiple blocks
- Cmd = MMC_CMD25;
- }
- }
-
- ConsumeSize = BlockCount * This->Media->BlockSize;
- if (BytesRemainingToBeTransfered < ConsumeSize) {
- ConsumeSize = BytesRemainingToBeTransfered;
- }
-
- Status = MmcTransferBlock (This, Cmd, Transfer, MediaId, Lba, ConsumeSize, Buffer, &ConsumeSize);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a(): Failed to transfer block and Status:%r\n", __func__, Status));
- return Status;
- }
-
- BytesRemainingToBeTransfered -= ConsumeSize;
- if (BytesRemainingToBeTransfered > 0) {
- Lba += BlockCount;
- Buffer = (UINT8*)Buffer + ConsumeSize;
- }
- }
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-MmcReadBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- OUT VOID *Buffer
- )
-{
- return MmcIoBlocks (This, MMC_IOBLOCKS_READ, MediaId, Lba, BufferSize, Buffer);
-}
-
-EFI_STATUS
-EFIAPI
-MmcWriteBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This,
- IN UINT32 MediaId,
- IN EFI_LBA Lba,
- IN UINTN BufferSize,
- IN VOID *Buffer
- )
-{
- return MmcIoBlocks (This, MMC_IOBLOCKS_WRITE, MediaId, Lba, BufferSize, Buffer);
-}
-
-EFI_STATUS
-EFIAPI
-MmcFlushBlocks (
- IN EFI_BLOCK_IO_PROTOCOL *This
- )
-{
- return EFI_SUCCESS;
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcDebug.c b/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcDebug.c
deleted file mode 100644
index 22209fca..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcDebug.c
+++ /dev/null
@@ -1,164 +0,0 @@
-/** @file
- *
- * Copyright (c) 2011-2013, ARM Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include "Mmc.h"
-
-#if !defined(MDEPKG_NDEBUG)
-CONST CHAR8* mStrUnit[] = { "100kbit/s", "1Mbit/s", "10Mbit/s", "100MBit/s",
- "Unknown", "Unknown", "Unknown", "Unknown" };
-CONST CHAR8* mStrValue[] = { "1.0", "1.2", "1.3", "1.5", "2.0", "2.5",
- "3.0", "3.5", "4.0", "4.5", "5.0", "5.5",
- "6.0", "7.0", "8.0" };
-#endif
-
-VOID
-PrintCID (
- IN UINT32* Cid
- )
-{
- DEBUG ((DEBUG_ERROR, "- PrintCID\n"));
- DEBUG ((DEBUG_ERROR, "\t- Manufacturing date: %d/%d\n", (Cid[0] >> 8) & 0xF, (Cid[0] >> 12) & 0xFF));
- DEBUG ((DEBUG_ERROR, "\t- Product serial number: 0x%X%X\n", Cid[1] & 0xFFFFFF, (Cid[0] >> 24) & 0xFF));
- DEBUG ((DEBUG_ERROR, "\t- Product revision: %d\n", Cid[1] >> 24));
- //DEBUG ((DEBUG_ERROR, "\t- Product name: %s\n", (char*)(Cid + 2)));
- DEBUG ((DEBUG_ERROR, "\t- OEM ID: %c%c\n", (Cid[3] >> 8) & 0xFF, (Cid[3] >> 16) & 0xFF));
-}
-
-
-VOID
-PrintCSD (
- IN UINT32* Csd
- )
-{
- UINTN Value;
-
- if (((Csd[2] >> 30) & 0x3) == 0) {
- DEBUG ((DEBUG_ERROR, "- PrintCSD Version 1.01-1.10/Version 2.00/Standard Capacity\n"));
- } else if (((Csd[2] >> 30) & 0x3) == 1) {
- DEBUG ((DEBUG_ERROR, "- PrintCSD Version 2.00/High Capacity\n"));
- } else {
- DEBUG ((DEBUG_ERROR, "- PrintCSD Version Higher than v3.3\n"));
- }
-
- DEBUG ((DEBUG_ERROR, "\t- Supported card command class: 0x%X\n", MMC_CSD_GET_CCC (Csd)));
- DEBUG ((DEBUG_ERROR, "\t- Max Speed: %a * %a\n", mStrValue[(MMC_CSD_GET_TRANSPEED (Csd) >> 3) & 0xF],
- mStrUnit[MMC_CSD_GET_TRANSPEED (Csd) & 7]));
- DEBUG ((DEBUG_ERROR, "\t- Maximum Read Data Block: %d\n", 2 << (MMC_CSD_GET_READBLLEN (Csd) - 1)));
- DEBUG ((DEBUG_ERROR, "\t- Maximum Write Data Block: %d\n", 2 << (MMC_CSD_GET_WRITEBLLEN (Csd) - 1)));
-
- if (!MMC_CSD_GET_FILEFORMATGRP (Csd)) {
- Value = MMC_CSD_GET_FILEFORMAT (Csd);
- if (Value == 0) {
- DEBUG ((DEBUG_ERROR, "\t- Format (0): Hard disk-like file system with partition table\n"));
- } else if (Value == 1) {
- DEBUG ((DEBUG_ERROR, "\t- Format (1): DOS FAT (floppy-like) with boot sector only (no partition table)\n"));
- } else if (Value == 2) {
- DEBUG ((DEBUG_ERROR, "\t- Format (2): Universal File Format\n"));
- } else {
- DEBUG ((DEBUG_ERROR, "\t- Format (3): Others/Unknown\n"));
- }
- } else {
- DEBUG ((DEBUG_ERROR, "\t- Format: Reserved\n"));
- }
-}
-
-VOID
-PrintRCA (
- IN UINT32 Rca
- )
-{
- DEBUG ((DEBUG_ERROR, "- PrintRCA: 0x%X\n", Rca));
- DEBUG ((DEBUG_ERROR, "\t- Status: 0x%X\n", Rca & 0xFFFF));
- DEBUG ((DEBUG_ERROR, "\t- RCA: 0x%X\n", (Rca >> 16) & 0xFFFF));
-}
-
-VOID
-PrintOCR (
- IN UINT32 Ocr
- )
-{
- UINTN MinV;
- UINTN MaxV;
- UINTN Volts;
- UINTN Loop;
-
- MinV = 36; // 3.6
- MaxV = 20; // 2.0
- Volts = 20; // 2.0
-
- // The MMC register bits [23:8] indicate the working range of the card
- for (Loop = 8; Loop < 24; Loop++) {
- if (Ocr & (1 << Loop)) {
- if (MinV > Volts) {
- MinV = Volts;
- }
- if (MaxV < Volts) {
- MaxV = Volts + 1;
- }
- }
- Volts++;
- }
-
- DEBUG ((DEBUG_ERROR, "- PrintOCR Ocr (0x%X)\n", Ocr));
- DEBUG ((DEBUG_ERROR, "\t- Card operating voltage: %d.%d to %d.%d\n", MinV / 10, MinV % 10, MaxV / 10, MaxV % 10));
- if (((Ocr >> 29) & 3) == 0) {
- DEBUG ((DEBUG_ERROR, "\t- AccessMode: Byte Mode\n"));
- } else {
- DEBUG ((DEBUG_ERROR, "\t- AccessMode: Block Mode (0x%X)\n", ((Ocr >> 29) & 3)));
- }
-
- if (Ocr & MMC_OCR_POWERUP) {
- DEBUG ((DEBUG_ERROR, "\t- PowerUp\n"));
- } else {
- DEBUG ((DEBUG_ERROR, "\t- Voltage Not Supported\n"));
- }
-}
-
-VOID
-PrintResponseR1 (
- IN UINT32 Response
- )
-{
- DEBUG ((DEBUG_INFO, "Response: 0x%X\n", Response));
- if (Response & MMC_R0_READY_FOR_DATA) {
- DEBUG ((DEBUG_INFO, "\t- READY_FOR_DATA\n"));
- }
-
- switch ((Response >> 9) & 0xF) {
- case 0:
- DEBUG ((DEBUG_INFO, "\t- State: Idle\n"));
- break;
- case 1:
- DEBUG ((DEBUG_INFO, "\t- State: Ready\n"));
- break;
- case 2:
- DEBUG ((DEBUG_INFO, "\t- State: Ident\n"));
- break;
- case 3:
- DEBUG ((DEBUG_INFO, "\t- State: StandBy\n"));
- break;
- case 4:
- DEBUG ((DEBUG_INFO, "\t- State: Tran\n"));
- break;
- case 5:
- DEBUG ((DEBUG_INFO, "\t- State: Data\n"));
- break;
- case 6:
- DEBUG ((DEBUG_INFO, "\t- State: Rcv\n"));
- break;
- case 7:
- DEBUG ((DEBUG_INFO, "\t- State: Prg\n"));
- break;
- case 8:
- DEBUG ((DEBUG_INFO, "\t- State: Dis\n"));
- break;
- default:
- DEBUG ((DEBUG_INFO, "\t- State: Reserved\n"));
- break;
- }
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcDxe.inf b/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcDxe.inf
deleted file mode 100644
index 0690f9da..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcDxe.inf
+++ /dev/null
@@ -1,53 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
-# Copyright (c) 2011-2015, ARM Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x0001001A
- BASE_NAME = MmcDxe
- FILE_GUID = b6f44cc0-9e45-11df-be21-0002a5f5f51b
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
-
- ENTRY_POINT = MmcDxeInitialize
-
-[Sources.common]
- ComponentName.c
- Mmc.h
- Mmc.c
- MmcBlockIo.c
- MmcIdentification.c
- MmcDebug.c
- Diagnostics.c
-
-[Packages]
- Platform/RaspberryPi/RPi3/RPi3.dec
- MdePkg/MdePkg.dec
-
-[LibraryClasses]
- BaseLib
- UefiLib
- UefiDriverEntryPoint
- BaseMemoryLib
-
-[Protocols]
- gEfiDiskIoProtocolGuid
- gEfiBlockIoProtocolGuid
- gEfiDevicePathProtocolGuid
- gEfiDriverDiagnostics2ProtocolGuid
- gRaspberryPiMmcHostProtocolGuid
-
-[Pcd]
- gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit
- gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed
- gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz
- gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz
- gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti
-
-[Depex]
- TRUE
diff --git a/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcIdentification.c b/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcIdentification.c
deleted file mode 100644
index 4ee5c5ca..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/MmcDxe/MmcIdentification.c
+++ /dev/null
@@ -1,974 +0,0 @@
-/** @file
- *
- * Copyright (c) 2011-2015, ARM Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/TimerLib.h>
-
-#include "Mmc.h"
-
-typedef union {
- UINT32 Raw;
- OCR Ocr;
-} OCR_RESPONSE;
-
-#define MAX_RETRY_COUNT 1000
-#define CMD_RETRY_COUNT 20
-#define RCA_SHIFT_OFFSET 16
-#define EMMC_CARD_SIZE 512
-#define EMMC_ECSD_SIZE_OFFSET 53
-
-#define EXTCSD_BUS_WIDTH 183
-#define EXTCSD_HS_TIMING 185
-
-#define EMMC_TIMING_BACKWARD 0
-#define EMMC_TIMING_HS 1
-#define EMMC_TIMING_HS200 2
-#define EMMC_TIMING_HS400 3
-
-#define EMMC_BUS_WIDTH_1BIT 0
-#define EMMC_BUS_WIDTH_4BIT 1
-#define EMMC_BUS_WIDTH_8BIT 2
-#define EMMC_BUS_WIDTH_DDR_4BIT 5
-#define EMMC_BUS_WIDTH_DDR_8BIT 6
-
-#define EMMC_SWITCH_ERROR (1 << 7)
-
-#define SD_BUS_WIDTH_1BIT (1 << 0)
-#define SD_BUS_WIDTH_4BIT (1 << 2)
-
-#define SD_CCC_SWITCH (1 << 10)
-
-#define DEVICE_STATE(x) (((x) >> 9) & 0xf)
-typedef enum _EMMC_DEVICE_STATE {
- EMMC_IDLE_STATE = 0,
- EMMC_READY_STATE,
- EMMC_IDENT_STATE,
- EMMC_STBY_STATE,
- EMMC_TRAN_STATE,
- EMMC_DATA_STATE,
- EMMC_RCV_STATE,
- EMMC_PRG_STATE,
- EMMC_DIS_STATE,
- EMMC_BTST_STATE,
- EMMC_SLP_STATE
-} EMMC_DEVICE_STATE;
-
-UINT32 mEmmcRcaCount = 0;
-
-STATIC
-EFI_STATUS
-EFIAPI
-EmmcGetDeviceState (
- IN MMC_HOST_INSTANCE *MmcHostInstance,
- OUT EMMC_DEVICE_STATE *State
- )
-{
- EFI_MMC_HOST_PROTOCOL *Host;
- EFI_STATUS Status;
- UINT32 Data, RCA;
-
- if (State == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- Host = MmcHostInstance->MmcHost;
- RCA = MmcHostInstance->CardInfo.RCA << RCA_SHIFT_OFFSET;
- Status = Host->SendCommand (Host, MMC_CMD13, RCA);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "EmmcGetDeviceState(): Failed to get card status, Status=%r.\n", Status));
- return Status;
- }
- Status = Host->ReceiveResponse (Host, MMC_RESPONSE_TYPE_R1, &Data);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "EmmcGetDeviceState(): Failed to get response of CMD13, Status=%r.\n", Status));
- return Status;
- }
- if (Data & EMMC_SWITCH_ERROR) {
- DEBUG ((DEBUG_ERROR, "EmmcGetDeviceState(): Failed to switch expected mode, Status=%r.\n", Status));
- return EFI_DEVICE_ERROR;
- }
- *State = DEVICE_STATE (Data);
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-EmmcSetEXTCSD (
- IN MMC_HOST_INSTANCE *MmcHostInstance,
- UINT32 ExtCmdIndex,
- UINT32 Value
- )
-{
- EFI_MMC_HOST_PROTOCOL *Host;
- EMMC_DEVICE_STATE State;
- EFI_STATUS Status;
- UINT32 Argument;
-
- Host = MmcHostInstance->MmcHost;
- Argument = EMMC_CMD6_ARG_ACCESS (3) | EMMC_CMD6_ARG_INDEX (ExtCmdIndex) |
- EMMC_CMD6_ARG_VALUE (Value) | EMMC_CMD6_ARG_CMD_SET (1);
- Status = Host->SendCommand (Host, MMC_CMD6, Argument);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "EmmcSetEXTCSD(): Failed to send CMD6, Status=%r.\n", Status));
- return Status;
- }
- // Make sure device exiting prog mode
- do {
- Status = EmmcGetDeviceState (MmcHostInstance, &State);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "EmmcSetEXTCSD(): Failed to get device state, Status=%r.\n", Status));
- return Status;
- }
- } while (State == EMMC_PRG_STATE);
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-EmmcIdentificationMode (
- IN MMC_HOST_INSTANCE *MmcHostInstance,
- IN OCR_RESPONSE Response
- )
-{
- EFI_MMC_HOST_PROTOCOL *Host;
- EFI_BLOCK_IO_MEDIA *Media;
- EFI_STATUS Status;
- EMMC_DEVICE_STATE State;
- UINT32 RCA;
-
- Host = MmcHostInstance->MmcHost;
- Media = MmcHostInstance->BlockIo.Media;
-
- // Fetch card identity register
- Status = Host->SendCommand (Host, MMC_CMD2, 0);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "EmmcIdentificationMode(): Failed to send CMD2, Status=%r.\n", Status));
- return Status;
- }
-
- Status = Host->ReceiveResponse (Host, MMC_RESPONSE_TYPE_R2, (UINT32*)&(MmcHostInstance->CardInfo.CIDData));
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "EmmcIdentificationMode(): CID retrieval error, Status=%r.\n", Status));
- return Status;
- }
-
- // Assign a relative address value to the card
- MmcHostInstance->CardInfo.RCA = ++mEmmcRcaCount; // TODO: might need a more sophisticated way of doing this
- RCA = MmcHostInstance->CardInfo.RCA << RCA_SHIFT_OFFSET;
- Status = Host->SendCommand (Host, MMC_CMD3, RCA);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "EmmcIdentificationMode(): RCA set error, Status=%r.\n", Status));
- return Status;
- }
-
- // Fetch card specific data
- Status = Host->SendCommand (Host, MMC_CMD9, RCA);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "EmmcIdentificationMode(): Failed to send CMD9, Status=%r.\n", Status));
- return Status;
- }
-
- Status = Host->ReceiveResponse (Host, MMC_RESPONSE_TYPE_R2, (UINT32*)&(MmcHostInstance->CardInfo.CSDData));
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "EmmcIdentificationMode(): CSD retrieval error, Status=%r.\n", Status));
- return Status;
- }
-
- // Select the card
- Status = Host->SendCommand (Host, MMC_CMD7, RCA);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "EmmcIdentificationMode(): Card selection error, Status=%r.\n", Status));
- }
-
- if (MMC_HOST_HAS_SETIOS (Host)) {
- // Set 1-bit bus width
- Status = Host->SetIos (Host, 0, 1, EMMCBACKWARD);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "EmmcIdentificationMode(): Set 1-bit bus width error, Status=%r.\n", Status));
- return Status;
- }
-
- // Set 1-bit bus width for EXTCSD
- Status = EmmcSetEXTCSD (MmcHostInstance, EXTCSD_BUS_WIDTH, EMMC_BUS_WIDTH_1BIT);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "EmmcIdentificationMode(): Set extcsd bus width error, Status=%r.\n", Status));
- return Status;
- }
- }
-
- // Fetch ECSD
- MmcHostInstance->CardInfo.ECSDData = AllocatePages (EFI_SIZE_TO_PAGES (sizeof (ECSD)));
- if (MmcHostInstance->CardInfo.ECSDData == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- Status = Host->SendCommand (Host, MMC_CMD8, 0);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "EmmcIdentificationMode(): ECSD fetch error, Status=%r.\n", Status));
- }
-
- Status = Host->ReadBlockData (Host, 0, 512, (UINT32*)MmcHostInstance->CardInfo.ECSDData);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "EmmcIdentificationMode(): ECSD read error, Status=%r.\n", Status));
- goto FreePageExit;
- }
-
- // Make sure device exiting data mode
- do {
- Status = EmmcGetDeviceState (MmcHostInstance, &State);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "EmmcIdentificationMode(): Failed to get device state, Status=%r.\n", Status));
- goto FreePageExit;
- }
- } while (State == EMMC_DATA_STATE);
-
- // Set up media
- Media->BlockSize = EMMC_CARD_SIZE; // 512-byte support is mandatory for eMMC cards
- Media->MediaId = MmcHostInstance->CardInfo.CIDData.PSN;
- Media->ReadOnly = MmcHostInstance->CardInfo.CSDData.PERM_WRITE_PROTECT;
- Media->LogicalBlocksPerPhysicalBlock = 1;
- Media->IoAlign = 4;
- // Compute last block using bits [215:212] of the ECSD
- Media->LastBlock = MmcHostInstance->CardInfo.ECSDData->SECTOR_COUNT - 1; // eMMC isn't supposed to report this for
- // Cards <2GB in size, but the model does.
-
- // Setup card type
- MmcHostInstance->CardInfo.CardType = EMMC_CARD;
- return EFI_SUCCESS;
-
-FreePageExit:
- FreePages (MmcHostInstance->CardInfo.ECSDData, EFI_SIZE_TO_PAGES (sizeof (ECSD)));
- return Status;
-}
-
-STATIC
-EFI_STATUS
-InitializeEmmcDevice (
- IN MMC_HOST_INSTANCE *MmcHostInstance
- )
-{
- EFI_MMC_HOST_PROTOCOL *Host;
- EFI_STATUS Status = EFI_SUCCESS;
- ECSD *ECSDData;
- UINT32 BusClockFreq, Idx, BusMode;
- UINT32 BusWidth = 8;
- UINT32 TimingMode[4] = { EMMCHS52DDR1V2, EMMCHS52DDR1V8, EMMCHS52, EMMCHS26 };
-
- Host = MmcHostInstance->MmcHost;
- ECSDData = MmcHostInstance->CardInfo.ECSDData;
- if (ECSDData->DEVICE_TYPE == EMMCBACKWARD) {
- return EFI_SUCCESS;
- }
-
- if (PcdGet32 (PcdMmcForceDefaultSpeed)) {
- DEBUG ((DEBUG_WARN, "Forcing default speed mode\n"));
- return EFI_SUCCESS;
- }
-
- if (PcdGet32 (PcdMmcForce1Bit)) {
- DEBUG ((DEBUG_WARN, "Forcing 1 bit mode\n"));
- BusWidth = 1;
- }
-
- if (!MMC_HOST_HAS_SETIOS (Host)) {
- DEBUG ((DEBUG_ERROR, "Controller doesn't support speed / bus width change\n"));
- return EFI_SUCCESS;
- }
-
- Status = EmmcSetEXTCSD (MmcHostInstance, EXTCSD_HS_TIMING, EMMC_TIMING_HS);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "InitializeEmmcDevice(): Failed to switch high speed mode, Status:%r.\n", Status));
- return Status;
- }
-
- for (Idx = 0; Idx < 4; Idx++) {
- switch (TimingMode[Idx]) {
- case EMMCHS52DDR1V2:
- case EMMCHS52DDR1V8:
- case EMMCHS52:
- BusClockFreq = 52000000;
- break;
- case EMMCHS26:
- BusClockFreq = 26000000;
- break;
- default:
- return EFI_UNSUPPORTED;
- }
- Status = Host->SetIos (Host, BusClockFreq, BusWidth, TimingMode[Idx]);
- if (!EFI_ERROR (Status)) {
- switch (TimingMode[Idx]) {
- case EMMCHS52DDR1V2:
- case EMMCHS52DDR1V8:
- BusMode = EMMC_BUS_WIDTH_DDR_8BIT;
- break;
- case EMMCHS52:
- case EMMCHS26:
- BusMode = EMMC_BUS_WIDTH_8BIT;
- break;
- default:
- return EFI_UNSUPPORTED;
- }
- Status = EmmcSetEXTCSD (MmcHostInstance, EXTCSD_BUS_WIDTH, BusMode);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "InitializeEmmcDevice(): Failed to set EXTCSD bus width, Status:%r\n", Status));
- }
- return Status;
- }
- }
- return Status;
-}
-
-STATIC
-UINT32
-SdSwitchCmdArgument (
- IN UINT32 AccessMode,
- IN UINT32 CommandSystem,
- IN UINT32 DriveStrength,
- IN UINT32 PowerLimit,
- IN BOOLEAN Mode
- )
-{
- return (AccessMode & 0xF) | ((PowerLimit & 0xF) << 4) | \
- ((DriveStrength & 0xF) << 8) | ((DriveStrength & 0xF) << 12) | \
- (Mode ? BIT31 : 0);
-}
-
-STATIC
-EFI_STATUS
-SdSelect (
- IN MMC_HOST_INSTANCE *MmcHostInstance
- )
-{
- /*
- * Moves a card from standby to transfer state.
- */
- EFI_STATUS Status;
- EFI_MMC_HOST_PROTOCOL *MmcHost = MmcHostInstance->MmcHost;
-
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD7,
- MmcHostInstance->CardInfo.RCA << 16);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: error: %r\n", __FUNCTION__, Status));
- }
-
- return Status;
-}
-
-STATIC
-EFI_STATUS
-SdDeselect (
- IN MMC_HOST_INSTANCE *MmcHostInstance
- )
-{
- /*
- * Moves a card from transfer to standby.
- */
- EFI_STATUS Status;
- EFI_MMC_HOST_PROTOCOL *MmcHost = MmcHostInstance->MmcHost;
-
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD7, 0);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: error: %r\n", __FUNCTION__, Status));
- }
-
- return Status;
-}
-
-STATIC
-EFI_STATUS
-SdGetCsd (
- IN MMC_HOST_INSTANCE *MmcHostInstance,
- IN UINT32 *Response,
- IN BOOLEAN Print
- )
-{
- EFI_STATUS Status;
- EFI_MMC_HOST_PROTOCOL *MmcHost = MmcHostInstance->MmcHost;
-
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD9,
- MmcHostInstance->CardInfo.RCA << 16);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a(%u): error: %r\n", __FUNCTION__, __LINE__, Status));
- return Status;
- }
-
- Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_CSD, Response);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a(%u): error %r\n", __FUNCTION__,
- __LINE__, Status));
- return Status;
- }
-
- if (Print) {
- PrintCSD (Response);
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-SdSet4Bit (
- IN MMC_HOST_INSTANCE *MmcHostInstance
-)
-{
- UINT32 CmdArg;
- EFI_STATUS Status;
- EFI_MMC_HOST_PROTOCOL *MmcHost = MmcHostInstance->MmcHost;
-
- if (PcdGet32 (PcdMmcForce1Bit)) {
- DEBUG ((DEBUG_WARN, "Forcing 1 bit mode\n"));
- return EFI_SUCCESS;
- }
-
- if (!MMC_HOST_HAS_SETIOS (MmcHost)) {
- DEBUG ((DEBUG_WARN, "Controller doesn't support bus width change\n"));
- return EFI_SUCCESS;
- }
-
- CmdArg = MmcHostInstance->CardInfo.RCA << 16;
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD55, CmdArg);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a(%u): error: %r\n", __FUNCTION__, __LINE__, Status));
- return Status;
- }
-
- /* Width: 4 */
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD6, 2);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a(%u): error %r\n", __FUNCTION__, __LINE__, Status));
- return Status;
- }
-
- Status = MmcHost->SetIos (MmcHost, 0, BUSWIDTH_4, EMMCBACKWARD);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a(%u): error: %r\n", __FUNCTION__, __LINE__, Status));
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-SdSetSpeed (
- IN MMC_HOST_INSTANCE *MmcHostInstance,
- IN BOOLEAN CccSwitch
- )
-{
- UINT32 Speed;
- UINT32 CmdArg;
- EFI_STATUS Status;
- UINT32 Buffer[16];
- UINT32 Response[4];
- EFI_MMC_HOST_PROTOCOL *MmcHost = MmcHostInstance->MmcHost;
-
- if (!MMC_HOST_HAS_SETIOS (MmcHost)) {
- DEBUG ((DEBUG_WARN, "Controller doesn't support speed change\n"));
- return EFI_SUCCESS;
- }
-
- Speed = PcdGet32 (PcdMmcSdDefaultSpeedMHz) * 1000000;
- if (Speed == 0) {
- Speed = SD_DEFAULT_SPEED;
- } else {
- DEBUG ((DEBUG_INFO, "Using default speed override %u Hz\n", Speed));
- }
-
- /*
- * First set base speed. We'll then try HS.
- */
- Status = MmcHost->SetIos (MmcHost, Speed, 0, EMMCBACKWARD);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: error setting speed %u: %r\n", __FUNCTION__, Speed, Status));
- return Status;
- }
-
- if (PcdGet32 (PcdMmcForceDefaultSpeed)) {
- DEBUG ((DEBUG_WARN, "Forcing default speed mode\n"));
- return EFI_SUCCESS;
- }
-
- if (!CccSwitch) {
- return EFI_SUCCESS;
- }
-
- /* Query. */
- CmdArg = SdSwitchCmdArgument (0xf, 0xf, 0xf, 0xf, FALSE);
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD6, CmdArg);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a(%u): error: %r\n",
- __FUNCTION__, __LINE__, Status));
- return Status;
- } else {
- Status = MmcHost->ReadBlockData (MmcHost, 0, SWITCH_CMD_DATA_LENGTH,
- Buffer);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a(%u): error: %r\n",
- __FUNCTION__, __LINE__, Status));
- return Status;
- }
- }
-
- if (!(Buffer[3] & SD_HIGH_SPEED_SUPPORTED)) {
- DEBUG ((DEBUG_ERROR, "%a: High Speed not supported by Card\n"));
- return EFI_SUCCESS;
- }
-
- /* Switch to high speed. */
- CmdArg = SdSwitchCmdArgument (1, 0xf, 0xf, 0xf, TRUE);
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD6, CmdArg);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a(%u): error: %r\n", __FUNCTION__, __LINE__, Status));
- return Status;
- } else {
- Status = MmcHost->ReadBlockData (MmcHost, 0,
- SWITCH_CMD_DATA_LENGTH, Buffer);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a(%u): error: %r\n", __FUNCTION__, __LINE__, Status));
- return Status;
- }
-
- if ((Buffer[4] & SWITCH_CMD_SUCCESS_MASK) != 0x1) {
- DEBUG ((DEBUG_ERROR, "Problem switching SD card into HS mode\n"));
- DEBUG ((DEBUG_ERROR, "%08x %08x %08x %08x\n",
- Buffer[0], Buffer[1], Buffer[2], Buffer[3]));
- DEBUG ((DEBUG_ERROR, "%08x %08x %08x %08x\n",
- Buffer[4], Buffer[5], Buffer[6], Buffer[8]));
- return Status;
- }
- }
-
- DEBUG ((DEBUG_ERROR, "Dumping CSD after high-speed switch\n"));
- SdDeselect (MmcHostInstance);
- SdGetCsd (MmcHostInstance, Response, TRUE);
- SdSelect (MmcHostInstance);
-
- Speed = PcdGet32 (PcdMmcSdHighSpeedMHz) * 1000000;
- if (Speed == 0) {
- Speed = SD_HIGH_SPEED;
- } else {
- DEBUG ((DEBUG_INFO, "Using high speed override %u Hz\n", Speed));
- }
-
- Status = MmcHost->SetIos (MmcHost, Speed, 0, EMMCBACKWARD);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: error setting speed %u: %r\n", __FUNCTION__, Speed, Status));
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-InitializeSdMmcDevice (
- IN MMC_HOST_INSTANCE *MmcHostInstance
- )
-{
- UINT32 Response[4];
- UINT32 Buffer[128];
- UINTN BlockSize;
- UINTN CardSize;
- UINTN NumBlocks;
- BOOLEAN CccSwitch;
- SCR Scr;
- EFI_STATUS Status;
- EFI_MMC_HOST_PROTOCOL *MmcHost = MmcHostInstance->MmcHost;
-
- Status = SdGetCsd (MmcHostInstance, Response, TRUE);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if (MMC_CSD_GET_CCC (Response) & SD_CCC_SWITCH) {
- CccSwitch = TRUE;
- } else {
- CccSwitch = FALSE;
- }
-
- if (MmcHostInstance->CardInfo.CardType == SD_CARD_2_HIGH) {
- CardSize = HC_MMC_CSD_GET_DEVICESIZE (Response);
- NumBlocks = ((CardSize + 1) * 1024);
- BlockSize = 1 << MMC_CSD_GET_READBLLEN (Response);
- } else {
- CardSize = MMC_CSD_GET_DEVICESIZE (Response);
- NumBlocks = (CardSize + 1) * (1 << (MMC_CSD_GET_DEVICESIZEMULT (Response) + 2));
- BlockSize = 1 << MMC_CSD_GET_READBLLEN (Response);
- }
-
- // For >=2G card, BlockSize may be 1K, but the transfer size is 512 bytes.
- if (BlockSize > 512) {
- NumBlocks = MultU64x32 (NumBlocks, BlockSize / 512);
- BlockSize = 512;
- }
-
- MmcHostInstance->BlockIo.Media->LastBlock = (NumBlocks - 1);
- MmcHostInstance->BlockIo.Media->BlockSize = BlockSize;
- MmcHostInstance->BlockIo.Media->ReadOnly = MmcHost->IsReadOnly (MmcHost);
- MmcHostInstance->BlockIo.Media->MediaPresent = TRUE;
- MmcHostInstance->BlockIo.Media->MediaId++;
-
- Status = SdSelect (MmcHostInstance);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD55,
- MmcHostInstance->CardInfo.RCA << 16);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a (MMC_CMD55): Error and Status = %r\n", __FUNCTION__, Status));
- return Status;
- }
- Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R1, Response);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a (MMC_CMD55): Error and Status = %r\n", __FUNCTION__, Status));
- return Status;
- }
- if ((Response[0] & MMC_STATUS_APP_CMD) == 0) {
- return EFI_SUCCESS;
- }
-
- /* SCR */
- Status = MmcHost->SendCommand (MmcHost, MMC_ACMD51, 0);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a(MMC_ACMD51): Error and Status = %r\n", __func__, Status));
- return Status;
- } else {
- Status = MmcHost->ReadBlockData (MmcHost, 0, 8, Buffer);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a(MMC_ACMD51): ReadBlockData Error and Status = %r\n", __func__, Status));
- return Status;
- }
- CopyMem (&Scr, Buffer, 8);
- if (Scr.SD_SPEC == 2) {
- if (Scr.SD_SPEC3 == 1) {
- if (Scr.SD_SPEC4 == 1) {
- DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 4.xx\n"));
- } else {
- DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 3.0x\n"));
- }
- } else {
- if (Scr.SD_SPEC4 == 0) {
- DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 2.0\n"));
- } else {
- DEBUG ((DEBUG_ERROR, "Found invalid SD Card\n"));
- }
- }
- } else {
- if ((Scr.SD_SPEC3 == 0) && (Scr.SD_SPEC4 == 0)) {
- if (Scr.SD_SPEC == 1) {
- DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 1.10\n"));
- } else {
- DEBUG ((DEBUG_INFO, "Found SD Card for Spec Version 1.0\n"));
- }
- } else {
- DEBUG ((DEBUG_ERROR, "Found invalid SD Card\n"));
- }
- }
- }
-
- Status = SdSetSpeed (MmcHostInstance, CccSwitch);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if (Scr.SD_BUS_WIDTHS & SD_BUS_WIDTH_4BIT) {
- Status = SdSet4Bit (MmcHostInstance);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-MmcIdentificationMode (
- IN MMC_HOST_INSTANCE *MmcHostInstance
- )
-{
- EFI_STATUS Status;
- UINT32 Response[4];
- UINTN Timeout;
- UINTN CmdArg;
- BOOLEAN IsHCS;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
- OCR_RESPONSE OcrResponse;
-
- MmcHost = MmcHostInstance->MmcHost;
- CmdArg = 0;
- IsHCS = FALSE;
-
- if (MmcHost == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- // We can get into this function if we restart the identification mode
- if (MmcHostInstance->State == MmcHwInitializationState) {
- // Initialize the MMC Host HW
- Status = MmcNotifyState (MmcHostInstance, MmcHwInitializationState);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "MmcIdentificationMode() : Error MmcHwInitializationState, Status=%r.\n", Status));
- return Status;
- }
- }
-
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD0, 0);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "MmcIdentificationMode(MMC_CMD0): Error, Status=%r.\n", Status));
- return Status;
- }
- Status = MmcNotifyState (MmcHostInstance, MmcIdleState);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "MmcIdentificationMode() : Error MmcIdleState, Status=%r.\n", Status));
- return Status;
- }
-
- // Send CMD1 to get OCR (MMC)
- // This command only valid for MMC and eMMC
- Timeout = MAX_RETRY_COUNT;
- do {
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD1, EMMC_CMD1_CAPACITY_GREATER_THAN_2GB);
- if (EFI_ERROR (Status))
- break;
- Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR, (UINT32*)&OcrResponse);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "MmcIdentificationMode() : Failed to receive OCR, Status=%r.\n", Status));
- return Status;
- }
- Timeout--;
- } while (!OcrResponse.Ocr.PowerUp && (Timeout > 0));
- if (Status == EFI_SUCCESS) {
- if (!OcrResponse.Ocr.PowerUp) {
- DEBUG ((DEBUG_ERROR, "MmcIdentificationMode(MMC_CMD1): Card initialisation failure, Status=%r.\n", Status));
- return EFI_DEVICE_ERROR;
- }
- OcrResponse.Ocr.PowerUp = 0;
- if (OcrResponse.Raw == EMMC_CMD1_CAPACITY_GREATER_THAN_2GB) {
- MmcHostInstance->CardInfo.OCRData.AccessMode = BIT1;
- } else {
- MmcHostInstance->CardInfo.OCRData.AccessMode = 0x0;
- }
- // Check whether MMC or eMMC
- if (OcrResponse.Raw == EMMC_CMD1_CAPACITY_GREATER_THAN_2GB ||
- OcrResponse.Raw == EMMC_CMD1_CAPACITY_LESS_THAN_2GB) {
- return EmmcIdentificationMode (MmcHostInstance, OcrResponse);
- }
- }
-
- // Are we using SDIO ?
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD5, 0);
- if (Status == EFI_SUCCESS) {
- DEBUG ((DEBUG_ERROR, "MmcIdentificationMode(MMC_CMD5): Error - SDIO not supported, Status=%r.\n", Status));
- return EFI_UNSUPPORTED;
- }
-
- // Check which kind of card we are using. Ver2.00 or later SD Memory Card (PL180 is SD v1.1)
- CmdArg = (0x0UL << 12 | BIT8 | 0xCEUL << 0);
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD8, CmdArg);
- if (Status == EFI_SUCCESS) {
- DEBUG ((DEBUG_ERROR, "Card is SD2.0 => Supports high capacity\n"));
- IsHCS = TRUE;
- Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_R7, Response);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "MmcIdentificationMode() : Failed to receive response to CMD8, Status=%r.\n", Status));
- return Status;
- }
- PrintResponseR1 (Response[0]);
- // Check if it is valid response
- if (Response[0] != CmdArg) {
- DEBUG ((DEBUG_ERROR, "The Card is not usable\n"));
- return EFI_UNSUPPORTED;
- }
- } else {
- DEBUG ((DEBUG_ERROR, "Not a SD2.0 Card\n"));
- }
-
- // We need to wait for the MMC or SD card is ready => (gCardInfo.OCRData.PowerUp == 1)
- Timeout = MAX_RETRY_COUNT;
- while (Timeout > 0) {
- // SD Card or MMC Card ? CMD55 indicates to the card that the next command is an application specific command
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD55, 0);
- if (Status == EFI_SUCCESS) {
- DEBUG ((DEBUG_INFO, "Card should be SD\n"));
- if (IsHCS) {
- MmcHostInstance->CardInfo.CardType = SD_CARD_2;
- } else {
- MmcHostInstance->CardInfo.CardType = SD_CARD;
- }
-
- // Note: The first time CmdArg will be zero
- CmdArg = ((UINTN*) &(MmcHostInstance->CardInfo.OCRData))[0];
- if (IsHCS) {
- CmdArg |= BIT30;
- }
- Status = MmcHost->SendCommand (MmcHost, MMC_ACMD41, CmdArg);
- if (!EFI_ERROR (Status)) {
- Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR, Response);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "MmcIdentificationMode() : Failed to receive OCR, Status=%r.\n", Status));
- return Status;
- }
- ((UINT32*) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
- }
- } else {
- DEBUG ((DEBUG_INFO, "Card should be MMC\n"));
- MmcHostInstance->CardInfo.CardType = MMC_CARD;
-
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD1, 0x800000);
- if (!EFI_ERROR (Status)) {
- Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_OCR, Response);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "MmcIdentificationMode() : Failed to receive OCR, Status=%r.\n", Status));
- return Status;
- }
- ((UINT32*) &(MmcHostInstance->CardInfo.OCRData))[0] = Response[0];
- }
- }
-
- if (!EFI_ERROR (Status)) {
- if (!MmcHostInstance->CardInfo.OCRData.PowerUp) {
- gBS->Stall (1);
- Timeout--;
- } else {
- if ((MmcHostInstance->CardInfo.CardType == SD_CARD_2) && (MmcHostInstance->CardInfo.OCRData.AccessMode & BIT1)) {
- MmcHostInstance->CardInfo.CardType = SD_CARD_2_HIGH;
- DEBUG ((DEBUG_ERROR, "High capacity card.\n"));
- }
- break; // The MMC/SD card is ready. Continue the Identification Mode
- }
- } else {
- gBS->Stall (1);
- Timeout--;
- }
- }
-
- if (Timeout == 0) {
- DEBUG ((DEBUG_ERROR, "MmcIdentificationMode(): No Card\n"));
- return EFI_NO_MEDIA;
- } else {
- PrintOCR (Response[0]);
- }
-
- Status = MmcNotifyState (MmcHostInstance, MmcReadyState);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "MmcIdentificationMode() : Error MmcReadyState\n"));
- return Status;
- }
-
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD2, 0);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "MmcIdentificationMode(MMC_CMD2): Error\n"));
- return Status;
- }
- Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_CID, Response);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "MmcIdentificationMode() : Failed to receive CID, Status=%r.\n", Status));
- return Status;
- }
-
- PrintCID (Response);
-
- Status = MmcHost->NotifyState (MmcHost, MmcIdentificationState);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "MmcIdentificationMode() : Error MmcIdentificationState\n"));
- return Status;
- }
-
- //
- // Note, SD specifications say that "if the command execution causes a state change, it
- // will be visible to the host in the response to the next command"
- // The status returned for this CMD3 will be 2 - identification
- //
- CmdArg = 1;
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD3, CmdArg);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "MmcIdentificationMode(MMC_CMD3): Error\n"));
- return Status;
- }
-
- Status = MmcHost->ReceiveResponse (MmcHost, MMC_RESPONSE_TYPE_RCA, Response);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "MmcIdentificationMode() : Failed to receive RCA, Status=%r.\n", Status));
- return Status;
- }
- PrintRCA (Response[0]);
-
- // For MMC card, RCA is assigned by CMD3 while CMD3 dumps the RCA for SD card
- if (MmcHostInstance->CardInfo.CardType != MMC_CARD) {
- MmcHostInstance->CardInfo.RCA = Response[0] >> 16;
- } else {
- MmcHostInstance->CardInfo.RCA = CmdArg;
- }
- Status = MmcNotifyState (MmcHostInstance, MmcStandByState);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "MmcIdentificationMode() : Error MmcStandByState\n"));
- return Status;
- }
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-InitializeMmcDevice (
- IN MMC_HOST_INSTANCE *MmcHostInstance
- )
-{
- EFI_STATUS Status;
- EFI_MMC_HOST_PROTOCOL *MmcHost;
- UINTN BlockCount;
-
- BlockCount = 1;
- MmcHost = MmcHostInstance->MmcHost;
-
- Status = MmcIdentificationMode (MmcHostInstance);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "InitializeMmcDevice(): Error in Identification Mode, Status=%r\n", Status));
- return Status;
- }
-
- Status = MmcNotifyState (MmcHostInstance, MmcTransferState);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "InitializeMmcDevice(): Error MmcTransferState, Status=%r\n", Status));
- return Status;
- }
-
- if (MmcHostInstance->CardInfo.CardType != EMMC_CARD) {
- Status = InitializeSdMmcDevice (MmcHostInstance);
- } else {
- Status = InitializeEmmcDevice (MmcHostInstance);
- }
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- // Set Block Length
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD16, MmcHostInstance->BlockIo.Media->BlockSize);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
- "InitializeMmcDevice(MMC_CMD16): Error MmcHostInstance->BlockIo.Media->BlockSize: %d and Error = %r\n",
- MmcHostInstance->BlockIo.Media->BlockSize, Status));
- return Status;
- }
-
- // Block Count (not used). Could return an error for SD card
- if (MmcHostInstance->CardInfo.CardType == MMC_CARD) {
- Status = MmcHost->SendCommand (MmcHost, MMC_CMD23, BlockCount);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "InitializeMmcDevice(MMC_CMD23): Error, Status=%r\n", Status));
- return Status;
- }
- }
-
- return EFI_SUCCESS;
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c
deleted file mode 100644
index 6aa68a09..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.c
+++ /dev/null
@@ -1,944 +0,0 @@
-/** @file
- *
- * Static SMBIOS Table for ARM platform
- * Derived from EmulatorPkg package
- *
- * Note SMBIOS 2.7.1 Required structures:
- * BIOS Information (Type 0)
- * System Information (Type 1)
- * Board Information (Type 2)
- * System Enclosure (Type 3)
- * Processor Information (Type 4) - CPU Driver
- * Cache Information (Type 7) - For cache that is external to processor
- * System Slots (Type 9) - If system has slots
- * Physical Memory Array (Type 16)
- * Memory Device (Type 17) - For each socketed system-memory Device
- * Memory Array Mapped Address (Type 19) - One per contiguous block per Physical Memroy Array
- * System Boot Information (Type 32)
- *
- * Copyright (c) 2017-2018, Andrey Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2013, Linaro.org
- * Copyright (c) 2012, Apple Inc. All rights reserved.<BR>
- * Copyright (c) Microsoft Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <Base.h>
-#include <IndustryStandard/SmBios.h>
-#include <IndustryStandard/RpiMbox.h>
-#include <Protocol/Smbios.h>
-#include <Protocol/RpiFirmware.h>
-#include <Guid/SmBios.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiDriverEntryPoint.h>
-#include <Library/UefiLib.h>
-#include <Library/BaseLib.h>
-#include <Library/PcdLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/PrintLib.h>
-
-#define SMB_IS_DIGIT(c) (((c) >= '0') && ((c) <= '9'))
-
-STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol;
-
-/***********************************************************************
- SMBIOS data definition TYPE0 BIOS Information
-************************************************************************/
-SMBIOS_TABLE_TYPE0 mBIOSInfoType0 = {
- { EFI_SMBIOS_TYPE_BIOS_INFORMATION, sizeof (SMBIOS_TABLE_TYPE0), 0 },
- 1, // Vendor String
- 2, // BiosVersion String
- 0x0, // BiosSegment
- 3, // BiosReleaseDate String
- 0x1F, // BiosSize
- { // BiosCharacteristics
- 0, // Reserved :2; ///< Bits 0-1.
- 0, // Unknown :1;
- 0, // BiosCharacteristicsNotSupported :1;
- 0, // IsaIsSupported :1;
- 0, // McaIsSupported :1;
- 0, // EisaIsSupported :1;
- 0, // PciIsSupported :1;
- 0, // PcmciaIsSupported :1;
- 0, // PlugAndPlayIsSupported :1;
- 0, // ApmIsSupported :1;
- 0, // BiosIsUpgradable :1;
- 0, // BiosShadowingAllowed :1;
- 0, // VlVesaIsSupported :1;
- 0, // EscdSupportIsAvailable :1;
- 0, // BootFromCdIsSupported :1;
- 1, // SelectableBootIsSupported :1;
- 0, // RomBiosIsSocketed :1;
- 0, // BootFromPcmciaIsSupported :1;
- 0, // EDDSpecificationIsSupported :1;
- 0, // JapaneseNecFloppyIsSupported :1;
- 0, // JapaneseToshibaFloppyIsSupported :1;
- 0, // Floppy525_360IsSupported :1;
- 0, // Floppy525_12IsSupported :1;
- 0, // Floppy35_720IsSupported :1;
- 0, // Floppy35_288IsSupported :1;
- 0, // PrintScreenIsSupported :1;
- 0, // Keyboard8042IsSupported :1;
- 0, // SerialIsSupported :1;
- 0, // PrinterIsSupported :1;
- 0, // CgaMonoIsSupported :1;
- 0, // NecPc98 :1;
- 0 // ReservedForVendor :32; ///< Bits 32-63. Bits 32-47 reserved for BIOS vendor
- ///< and bits 48-63 reserved for System Vendor.
- },
- { // BIOSCharacteristicsExtensionBytes[]
- 0x01, // AcpiIsSupported :1;
- // UsbLegacyIsSupported :1;
- // AgpIsSupported :1;
- // I2OBootIsSupported :1;
- // Ls120BootIsSupported :1;
- // AtapiZipDriveBootIsSupported :1;
- // Boot1394IsSupported :1;
- // SmartBatteryIsSupported :1;
- // BIOSCharacteristicsExtensionBytes[1]
- 0x0e, // BiosBootSpecIsSupported :1;
- // FunctionKeyNetworkBootIsSupported :1;
- // TargetContentDistributionEnabled :1;
- // UefiSpecificationSupported :1;
- // VirtualMachineSupported :1;
- // ExtensionByte2Reserved :3;
- },
- 0, // SystemBiosMajorRelease
- 0, // SystemBiosMinorRelease
- 0, // EmbeddedControllerFirmwareMajorRelease
- 0, // EmbeddedControllerFirmwareMinorRelease
-};
-
-CHAR8 mBiosVendor[128] = "EDK2";
-CHAR8 mBiosVersion[128] = "EDK2-DEV";
-
-CHAR8 *mBIOSInfoType0Strings[] = {
- mBiosVendor, // Vendor
- mBiosVersion, // Version
- __DATE__ " " __TIME__, // Release Date
- NULL
-};
-
-/***********************************************************************
- SMBIOS data definition TYPE1 System Information
-************************************************************************/
-SMBIOS_TABLE_TYPE1 mSysInfoType1 = {
- { EFI_SMBIOS_TYPE_SYSTEM_INFORMATION, sizeof (SMBIOS_TABLE_TYPE1), 0 },
- 1, // Manufacturer String
- 2, // ProductName String
- 3, // Version String
- 4, // SerialNumber String
- { 0x25EF0280, 0xEC82, 0x42B0, { 0x8F, 0xB6, 0x10, 0xAD, 0xCC, 0xC6, 0x7C, 0x02 } },
- SystemWakeupTypePowerSwitch,
- 5, // SKUNumber String
- 6, // Family String
-};
-
-CHAR8 mSysInfoManufName[128];
-CHAR8 mSysInfoProductName[128];
-CHAR8 mSysInfoVersionName[128];
-CHAR8 mSysInfoSerial[sizeof (UINT64) * 2 + 1];
-CHAR8 mSysInfoSKU[sizeof (UINT64) * 2 + 1];
-
-CHAR8 *mSysInfoType1Strings[] = {
- mSysInfoManufName,
- mSysInfoProductName,
- mSysInfoVersionName,
- mSysInfoSerial,
- mSysInfoSKU,
- "Raspberry Pi",
- NULL
-};
-
-/***********************************************************************
- SMBIOS data definition TYPE2 Board Information
-************************************************************************/
-SMBIOS_TABLE_TYPE2 mBoardInfoType2 = {
- { EFI_SMBIOS_TYPE_BASEBOARD_INFORMATION, sizeof (SMBIOS_TABLE_TYPE2), 0 },
- 1, // Manufacturer String
- 2, // ProductName String
- 3, // Version String
- 4, // SerialNumber String
- 0, // AssetTag String
- { // FeatureFlag
- 1, // Motherboard :1;
- 0, // RequiresDaughterCard :1;
- 0, // Removable :1;
- 0, // Replaceable :1;
- 0, // HotSwappable :1;
- 0, // Reserved :3;
- },
- 0, // LocationInChassis String
- 0, // ChassisHandle;
- BaseBoardTypeMotherBoard, // BoardType;
- 0, // NumberOfContainedObjectHandles;
- { 0 } // ContainedObjectHandles[1];
-};
-CHAR8 *mBoardInfoType2Strings[] = {
- mSysInfoManufName,
- mSysInfoProductName,
- mSysInfoVersionName,
- mSysInfoSerial,
- NULL
-};
-
-/***********************************************************************
- SMBIOS data definition TYPE3 Enclosure Information
-************************************************************************/
-SMBIOS_TABLE_TYPE3 mEnclosureInfoType3 = {
- { EFI_SMBIOS_TYPE_SYSTEM_ENCLOSURE, sizeof (SMBIOS_TABLE_TYPE3), 0 },
- 1, // Manufacturer String
- MiscChassisEmbeddedPc, // Type;
- 2, // Version String
- 3, // SerialNumber String
- 0, // AssetTag String
- ChassisStateSafe, // BootupState;
- ChassisStateSafe, // PowerSupplyState;
- ChassisStateSafe, // ThermalState;
- ChassisSecurityStatusNone,// SecurityStatus;
- { 0, 0, 0, 0 }, // OemDefined[4];
- 0, // Height;
- 0, // NumberofPowerCords;
- 0, // ContainedElementCount;
- 0, // ContainedElementRecordLength;
- { { 0 } }, // ContainedElements[1];
-};
-CHAR8 *mEnclosureInfoType3Strings[] = {
- mSysInfoManufName,
- mSysInfoProductName,
- mSysInfoSerial,
- NULL
-};
-
-/***********************************************************************
- SMBIOS data definition TYPE4 Processor Information
-************************************************************************/
-SMBIOS_TABLE_TYPE4 mProcessorInfoType4 = {
- { EFI_SMBIOS_TYPE_PROCESSOR_INFORMATION, sizeof (SMBIOS_TABLE_TYPE4), 0},
- 1, // Socket String
- CentralProcessor, // ProcessorType; ///< The enumeration value from PROCESSOR_TYPE_DATA.
- ProcessorFamilyIndicatorFamily2, // ProcessorFamily; ///< The enumeration value from PROCESSOR_FAMILY2_DATA.
- 2, // ProcessorManufacture String;
- { // ProcessorId;
- { // PROCESSOR_SIGNATURE
- 0, // ProcessorSteppingId:4;
- 0, // ProcessorModel: 4;
- 0, // ProcessorFamily: 4;
- 0, // ProcessorType: 2;
- 0, // ProcessorReserved1: 2;
- 0, // ProcessorXModel: 4;
- 0, // ProcessorXFamily: 8;
- 0, // ProcessorReserved2: 4;
- },
-
- { // PROCESSOR_FEATURE_FLAGS
- 0, // ProcessorFpu :1;
- 0, // ProcessorVme :1;
- 0, // ProcessorDe :1;
- 0, // ProcessorPse :1;
- 0, // ProcessorTsc :1;
- 0, // ProcessorMsr :1;
- 0, // ProcessorPae :1;
- 0, // ProcessorMce :1;
- 0, // ProcessorCx8 :1;
- 0, // ProcessorApic :1;
- 0, // ProcessorReserved1 :1;
- 0, // ProcessorSep :1;
- 0, // ProcessorMtrr :1;
- 0, // ProcessorPge :1;
- 0, // ProcessorMca :1;
- 0, // ProcessorCmov :1;
- 0, // ProcessorPat :1;
- 0, // ProcessorPse36 :1;
- 0, // ProcessorPsn :1;
- 0, // ProcessorClfsh :1;
- 0, // ProcessorReserved2 :1;
- 0, // ProcessorDs :1;
- 0, // ProcessorAcpi :1;
- 0, // ProcessorMmx :1;
- 0, // ProcessorFxsr :1;
- 0, // ProcessorSse :1;
- 0, // ProcessorSse2 :1;
- 0, // ProcessorSs :1;
- 0, // ProcessorReserved3 :1;
- 0, // ProcessorTm :1;
- 0, // ProcessorReserved4 :2;
- }
- },
- 3, // ProcessorVersion String;
- { // Voltage;
- 1, // ProcessorVoltageCapability5V :1;
- 1, // ProcessorVoltageCapability3_3V :1;
- 1, // ProcessorVoltageCapability2_9V :1;
- 0, // ProcessorVoltageCapabilityReserved :1; ///< Bit 3, must be zero.
- 0, // ProcessorVoltageReserved :3; ///< Bits 4-6, must be zero.
- 0 // ProcessorVoltageIndicateLegacy :1;
- },
- 0, // ExternalClock;
- 0, // MaxSpeed;
- 0, // CurrentSpeed;
- 0x41, // Status;
- ProcessorUpgradeOther, // ProcessorUpgrade; ///< The enumeration value from PROCESSOR_UPGRADE.
- 0, // L1CacheHandle;
- 0, // L2CacheHandle;
- 0, // L3CacheHandle;
- 0, // SerialNumber;
- 0, // AssetTag;
- 0, // PartNumber;
- 4, // CoreCount;
- 4, // EnabledCoreCount;
- 4, // ThreadCount;
- 0x6C, // ProcessorCharacteristics;
- ProcessorFamilyARM, // ARM Processor Family;
-};
-
-CHAR8 mCpuName[128] = "Unknown ARM CPU";
-
-CHAR8 *mProcessorInfoType4Strings[] = {
- "Socket",
- "Broadcom",
- mCpuName,
- NULL
-};
-
-/***********************************************************************
- SMBIOS data definition TYPE7 Cache Information
-************************************************************************/
-SMBIOS_TABLE_TYPE7 mCacheInfoType7 = {
- { EFI_SMBIOS_TYPE_CACHE_INFORMATION, sizeof (SMBIOS_TABLE_TYPE7), 0 },
- 1, // SocketDesignation String
- 0x018A, // Cache Configuration
- 0x00FF, // Maximum Size 256k
- 0x00FF, // Install Size 256k
- { // Supported SRAM Type
- 0, //Other :1
- 0, //Unknown :1
- 0, //NonBurst :1
- 1, //Burst :1
- 0, //PiplelineBurst :1
- 1, //Synchronous :1
- 0, //Asynchronous :1
- 0 //Reserved :9
- },
- { // Current SRAM Type
- 0, //Other :1
- 0, //Unknown :1
- 0, //NonBurst :1
- 1, //Burst :1
- 0, //PiplelineBurst :1
- 1, //Synchronous :1
- 0, //Asynchronous :1
- 0 //Reserved :9
- },
- 0, // Cache Speed unknown
- CacheErrorMultiBit, // Error Correction Multi
- CacheTypeUnknown, // System Cache Type
- CacheAssociativity2Way // Associativity
-};
-CHAR8 *mCacheInfoType7Strings[] = {
- "Cache1",
- NULL
-};
-
-/***********************************************************************
- SMBIOS data definition TYPE9 System Slot Information
-************************************************************************/
-SMBIOS_TABLE_TYPE9 mSysSlotInfoType9 = {
- { EFI_SMBIOS_TYPE_SYSTEM_SLOTS, sizeof (SMBIOS_TABLE_TYPE9), 0 },
- 1, // SlotDesignation String
- SlotTypeOther, // SlotType; ///< The enumeration value from MISC_SLOT_TYPE.
- SlotDataBusWidthOther, // SlotDataBusWidth; ///< The enumeration value from MISC_SLOT_DATA_BUS_WIDTH.
- SlotUsageAvailable, // CurrentUsage; ///< The enumeration value from MISC_SLOT_USAGE.
- SlotLengthOther, // SlotLength; ///< The enumeration value from MISC_SLOT_LENGTH.
- 0, // SlotID;
- { // SlotCharacteristics1;
- 1, // CharacteristicsUnknown :1;
- 0, // Provides50Volts :1;
- 0, // Provides33Volts :1;
- 0, // SharedSlot :1;
- 0, // PcCard16Supported :1;
- 0, // CardBusSupported :1;
- 0, // ZoomVideoSupported :1;
- 0, // ModemRingResumeSupported:1;
- },
- { // SlotCharacteristics2;
- 0, // PmeSignalSupported :1;
- 0, // HotPlugDevicesSupported :1;
- 0, // SmbusSignalSupported :1;
- 0, // Reserved :5; ///< Set to 0.
- },
- 0, // SegmentGroupNum;
- 0, // BusNum;
- 0, // DevFuncNum;
-};
-CHAR8 *mSysSlotInfoType9Strings[] = {
- "SD Card",
- NULL
-};
-
-/***********************************************************************
- SMBIOS data definition TYPE16 Physical Memory ArrayInformation
-************************************************************************/
-SMBIOS_TABLE_TYPE16 mPhyMemArrayInfoType16 = {
- { EFI_SMBIOS_TYPE_PHYSICAL_MEMORY_ARRAY, sizeof (SMBIOS_TABLE_TYPE16), 0 },
- MemoryArrayLocationSystemBoard, // Location; ///< The enumeration value from MEMORY_ARRAY_LOCATION.
- MemoryArrayUseSystemMemory, // Use; ///< The enumeration value from MEMORY_ARRAY_USE.
- MemoryErrorCorrectionUnknown, // MemoryErrorCorrection; ///< The enumeration value from MEMORY_ERROR_CORRECTION.
- 0x40000000, // MaximumCapacity;
- 0xFFFE, // MemoryErrorInformationHandle;
- 1, // NumberOfMemoryDevices;
- 0x40000000ULL, // ExtendedMaximumCapacity;
-};
-CHAR8 *mPhyMemArrayInfoType16Strings[] = {
- NULL
-};
-
-/***********************************************************************
- SMBIOS data definition TYPE17 Memory Device Information
-************************************************************************/
-SMBIOS_TABLE_TYPE17 mMemDevInfoType17 = {
- { EFI_SMBIOS_TYPE_MEMORY_DEVICE, sizeof (SMBIOS_TABLE_TYPE17), 0 },
- 0, // MemoryArrayHandle; // Should match SMBIOS_TABLE_TYPE16.Handle, initialized at runtime, refer to PhyMemArrayInfoUpdateSmbiosType16()
- 0xFFFE, // MemoryErrorInformationHandle;
- 0xFFFF, // TotalWidth;
- 0xFFFF, // DataWidth;
- 0x0400, // Size; // When bit 15 is 0: Size in MB
- // When bit 15 is 1: Size in KB, and continues in ExtendedSize
- MemoryFormFactorUnknown, // FormFactor; ///< The enumeration value from MEMORY_FORM_FACTOR.
- 0xff, // DeviceSet;
- 1, // DeviceLocator String
- 2, // BankLocator String
- MemoryTypeDram, // MemoryType; ///< The enumeration value from MEMORY_DEVICE_TYPE.
- { // TypeDetail;
- 0, // Reserved :1;
- 0, // Other :1;
- 1, // Unknown :1;
- 0, // FastPaged :1;
- 0, // StaticColumn :1;
- 0, // PseudoStatic :1;
- 0, // Rambus :1;
- 0, // Synchronous :1;
- 0, // Cmos :1;
- 0, // Edo :1;
- 0, // WindowDram :1;
- 0, // CacheDram :1;
- 0, // Nonvolatile :1;
- 0, // Registered :1;
- 0, // Unbuffered :1;
- 0, // Reserved1 :1;
- },
- 0, // Speed;
- 3, // Manufacturer String
- 0, // SerialNumber String
- 0, // AssetTag String
- 0, // PartNumber String
- 0, // Attributes;
- 0, // ExtendedSize;
- 0, // ConfiguredMemoryClockSpeed;
-};
-CHAR8 *mMemDevInfoType17Strings[] = {
- "OS Virtual Memory",
- "malloc",
- "OSV",
- NULL
-};
-
-/***********************************************************************
- SMBIOS data definition TYPE19 Memory Array Mapped Address Information
-************************************************************************/
-SMBIOS_TABLE_TYPE19 mMemArrMapInfoType19 = {
- { EFI_SMBIOS_TYPE_MEMORY_ARRAY_MAPPED_ADDRESS, sizeof (SMBIOS_TABLE_TYPE19), 0 },
- 0x00000000, // StartingAddress;
- 0x00000000, // EndingAddress;
- 0, // MemoryArrayHandle;
- 1, // PartitionWidth;
- 0, // ExtendedStartingAddress;
- 0, // ExtendedEndingAddress;
-};
-CHAR8 *mMemArrMapInfoType19Strings[] = {
- NULL
-};
-
-/***********************************************************************
- SMBIOS data definition TYPE32 Boot Information
-************************************************************************/
-SMBIOS_TABLE_TYPE32 mBootInfoType32 = {
- { EFI_SMBIOS_TYPE_SYSTEM_BOOT_INFORMATION, sizeof (SMBIOS_TABLE_TYPE32), 0 },
- { 0, 0, 0, 0, 0, 0 }, // Reserved[6];
- BootInformationStatusNoError // BootStatus
-};
-
-CHAR8 *mBootInfoType32Strings[] = {
- NULL
-};
-
-
-/**
-
- Create SMBIOS record.
-
- Converts a fixed SMBIOS structure and an array of pointers to strings into
- an SMBIOS record where the strings are cat'ed on the end of the fixed record
- and terminated via a double NULL and add to SMBIOS table.
-
- SMBIOS_TABLE_TYPE32 gSmbiosType12 = {
- { EFI_SMBIOS_TYPE_SYSTEM_CONFIGURATION_OPTIONS, sizeof (SMBIOS_TABLE_TYPE12), 0 },
- 1 // StringCount
- };
-
- CHAR8 *gSmbiosType12Strings[] = {
- "Not Found",
- NULL
- };
-
- ...
-
- LogSmbiosData (
- (EFI_SMBIOS_TABLE_HEADER*)&gSmbiosType12,
- gSmbiosType12Strings
- );
-
- @param Template Fixed SMBIOS structure, required.
- @param StringPack Array of strings to convert to an SMBIOS string pack.
- NULL is OK.
- @param DataSmbiosHande The new SMBIOS record handle .
- NULL is OK.
-**/
-
-EFI_STATUS
-EFIAPI
-LogSmbiosData (
- IN EFI_SMBIOS_TABLE_HEADER *Template,
- IN CHAR8 **StringPack,
- OUT EFI_SMBIOS_HANDLE *DataSmbiosHande
- )
-{
- EFI_STATUS Status;
- EFI_SMBIOS_PROTOCOL *Smbios;
- EFI_SMBIOS_HANDLE SmbiosHandle;
- EFI_SMBIOS_TABLE_HEADER *Record;
- UINTN Index;
- UINTN StringSize;
- UINTN Size;
- CHAR8 *Str;
-
- //
- // Locate Smbios protocol.
- //
- Status = gBS->LocateProtocol (&gEfiSmbiosProtocolGuid, NULL, (VOID**)&Smbios);
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- // Calculate the size of the fixed record and optional string pack
-
- Size = Template->Length;
- if (StringPack == NULL) {
- // At least a double null is required
- Size += 2;
- } else {
- for (Index = 0; StringPack[Index] != NULL; Index++) {
- StringSize = AsciiStrSize (StringPack[Index]);
- Size += StringSize;
- }
- if (StringPack[0] == NULL) {
- // At least a double null is required
- Size += 1;
- }
-
- // Don't forget the terminating double null
- Size += 1;
- }
-
- // Copy over Template
- Record = (EFI_SMBIOS_TABLE_HEADER*)AllocateZeroPool (Size);
- if (Record == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- CopyMem (Record, Template, Template->Length);
-
- // Append string pack
- Str = ((CHAR8*)Record) + Record->Length;
-
- for (Index = 0; StringPack[Index] != NULL; Index++) {
- StringSize = AsciiStrSize (StringPack[Index]);
- CopyMem (Str, StringPack[Index], StringSize);
- Str += StringSize;
- }
-
- *Str = 0;
- SmbiosHandle = SMBIOS_HANDLE_PI_RESERVED;
- Status = Smbios->Add (
- Smbios,
- gImageHandle,
- &SmbiosHandle,
- Record
- );
-
- if ((Status == EFI_SUCCESS) && (DataSmbiosHande != NULL)) {
- *DataSmbiosHande = SmbiosHandle;
- }
-
- ASSERT_EFI_ERROR (Status);
- FreePool (Record);
- return Status;
-}
-
-/***********************************************************************
- SMBIOS data update TYPE0 BIOS Information
-************************************************************************/
-VOID
-BIOSInfoUpdateSmbiosType0 (
- VOID
- )
-{
- UINT32 FirmwareRevision = 0;
- EFI_STATUS Status = EFI_SUCCESS;
- INTN i;
- INTN State = 0;
- INTN Value[2];
-
- // Populate the Firmware major and minor.
- Status = mFwProtocol->GetFirmwareRevision (&FirmwareRevision);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Failed to get firmware revision: %r\n", Status));
- } else {
- // This expects Broadcom / The Raspberry Pi Foundation to switch to
- // less nonsensical VideoCore firmware revisions in the future...
- mBIOSInfoType0.EmbeddedControllerFirmwareMajorRelease =
- (UINT8)((FirmwareRevision >> 16) & 0xFF);
- mBIOSInfoType0.EmbeddedControllerFirmwareMinorRelease =
- (UINT8)(FirmwareRevision & 0xFF);
- }
-
- // mBiosVendor and mBiosVersion, which are referenced in mBIOSInfoType0Strings,
- // are left unchanged if the following calls fail.
- UnicodeStrToAsciiStrS ((CHAR16*)PcdGetPtr (PcdFirmwareVendor),
- mBiosVendor, sizeof (mBiosVendor));
- UnicodeStrToAsciiStrS ((CHAR16*)PcdGetPtr (PcdFirmwareVersionString),
- mBiosVersion, sizeof (mBiosVersion));
-
- // Look for a "x.y" numeric string anywhere in mBiosVersion and
- // try to parse it to populate the BIOS major and minor.
- for (i = 0; (i < AsciiStrLen (mBiosVersion)) && (State < 4); i++) {
- switch (State) {
- case 0:
- if (!SMB_IS_DIGIT (mBiosVersion[i]))
- break;
- Value[0] = Value[1] = 0;
- State++;
- // Fall through
- case 1:
- case 3:
- if (SMB_IS_DIGIT (mBiosVersion[i])) {
- Value[State / 2] = (Value[State / 2] * 10) + (mBiosVersion[i] - '0');
- if (Value[State / 2] > 255) {
- while (SMB_IS_DIGIT (mBiosVersion[i + 1]))
- i++;
- // Reset our state (we may have something like "Firmware X83737.1 v1.23")
- State = 0;
- }
- } else {
- State++;
- }
- if (State != 2)
- break;
- // Fall through
- case 2:
- if ((mBiosVersion[i] == '.') && (SMB_IS_DIGIT (mBiosVersion[i + 1]))) {
- State++;
- } else {
- State = 0;
- }
- break;
- }
- }
- if ((State == 3) || (State == 4)) {
- mBIOSInfoType0.SystemBiosMajorRelease = (UINT8)Value[0];
- mBIOSInfoType0.SystemBiosMinorRelease = (UINT8)Value[1];
- }
-
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mBIOSInfoType0, mBIOSInfoType0Strings, NULL);
-}
-
-/***********************************************************************
- SMBIOS data update TYPE1 System Information
-************************************************************************/
-VOID
-I64ToHexString (
- IN OUT CHAR8* TargetStringSz,
- IN UINT32 TargetStringSize,
- IN UINT64 Value
- )
-{
- static CHAR8 ItoH[] = { '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F' };
- UINT8 StringInx;
- INT8 NibbleInx;
-
- ZeroMem ((void*)TargetStringSz, TargetStringSize);
-
- //
- // Convert each nibble to hex string, starting from
- // the highest non-zero nibble.
- //
- StringInx = 0;
- for (NibbleInx = sizeof (UINT64) * 2; NibbleInx > 0; --NibbleInx) {
- UINT64 NibbleMask = (((UINT64)0xF) << ((NibbleInx - 1) * 4));
- UINT8 Nibble = (UINT8)((Value & NibbleMask) >> ((NibbleInx - 1) * 4));
-
- ASSERT (Nibble <= 0xF);
-
- if (StringInx < (TargetStringSize - 1)) {
- TargetStringSz[StringInx++] = ItoH[Nibble];
- } else {
- break;
- }
- }
-}
-
-VOID
-SysInfoUpdateSmbiosType1 (
- VOID
- )
-{
- UINT32 BoardRevision = 0;
- EFI_STATUS Status = EFI_SUCCESS;
- UINT64 BoardSerial = 0;
- INTN Prod = -1;
- INTN Manu = -1;
-
- Status = mFwProtocol->GetModelRevision (&BoardRevision);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Failed to get board model: %r\n", Status));
- } else {
- Prod = (BoardRevision >> 4) & 0xFF;
- Manu = (BoardRevision >> 16) & 0x0F;
- }
-
- AsciiStrCpyS (mSysInfoProductName, sizeof (mSysInfoProductName),
- mFwProtocol->GetModelName (Prod));
- AsciiStrCpyS (mSysInfoManufName, sizeof (mSysInfoManufName),
- mFwProtocol->GetManufacturerName (Manu));
- AsciiSPrint (mSysInfoVersionName, sizeof (mSysInfoVersionName),
- "%X", BoardRevision);
-
- I64ToHexString (mSysInfoSKU, sizeof (mSysInfoSKU), BoardRevision);
-
- Status = mFwProtocol->GetSerial (&BoardSerial);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Failed to get board serial: %r\n", Status));
- }
-
- I64ToHexString (mSysInfoSerial, sizeof (mSysInfoSerial), BoardSerial);
-
- DEBUG ((DEBUG_ERROR, "Board Serial Number: %a\n", mSysInfoSerial));
-
- mSysInfoType1.Uuid.Data1 = BoardRevision;
- mSysInfoType1.Uuid.Data2 = 0x0;
- mSysInfoType1.Uuid.Data3 = 0x0;
- // Swap endianness, so that the serial is more user-friendly as a UUID
- BoardSerial = SwapBytes64 (BoardSerial);
- CopyMem (mSysInfoType1.Uuid.Data4, &BoardSerial, sizeof (BoardSerial));
-
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mSysInfoType1, mSysInfoType1Strings, NULL);
-}
-
-/***********************************************************************
- SMBIOS data update TYPE2 Board Information
-************************************************************************/
-VOID
-BoardInfoUpdateSmbiosType2 (
- VOID
- )
-{
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mBoardInfoType2, mBoardInfoType2Strings, NULL);
-}
-
-/***********************************************************************
- SMBIOS data update TYPE3 Enclosure Information
-************************************************************************/
-VOID
-EnclosureInfoUpdateSmbiosType3 (
- VOID
- )
-{
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mEnclosureInfoType3, mEnclosureInfoType3Strings, NULL);
-}
-
-/***********************************************************************
- SMBIOS data update TYPE4 Processor Information
-************************************************************************/
-VOID
-ProcessorInfoUpdateSmbiosType4 (
- IN UINTN MaxCpus
- )
-{
- EFI_STATUS Status;
- UINT32 Rate;
-
- mProcessorInfoType4.CoreCount = (UINT8)MaxCpus;
- mProcessorInfoType4.EnabledCoreCount = (UINT8)MaxCpus;
- mProcessorInfoType4.ThreadCount = (UINT8)MaxCpus;
-
- Status = mFwProtocol->GetMaxClockRate (RPI_MBOX_CLOCK_RATE_ARM, &Rate);
- if (Status != EFI_SUCCESS) {
- DEBUG ((DEBUG_ERROR, "Couldn't get the max CPU speed: %r\n", Status));
- } else {
- mProcessorInfoType4.MaxSpeed = Rate / 1000000;
- DEBUG ((DEBUG_INFO, "Max CPU speed: %uHz\n", Rate));
- }
-
- Status = mFwProtocol->GetClockRate (RPI_MBOX_CLOCK_RATE_ARM, &Rate);
- if (Status != EFI_SUCCESS) {
- DEBUG ((DEBUG_ERROR, "Couldn't get the current CPU speed: %r\n", Status));
- } else {
- mProcessorInfoType4.CurrentSpeed = Rate / 1000000;
- DEBUG ((DEBUG_INFO, "Current CPU speed: %uHz\n", Rate));
- }
-
- AsciiStrCpyS (mCpuName, sizeof (mCpuName), mFwProtocol->GetCpuName (-1));
-
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mProcessorInfoType4, mProcessorInfoType4Strings, NULL);
-}
-
-/***********************************************************************
- SMBIOS data update TYPE7 Cache Information
-************************************************************************/
-VOID
-CacheInfoUpdateSmbiosType7 (
- VOID
- )
-{
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mCacheInfoType7, mCacheInfoType7Strings, NULL);
-}
-
-/***********************************************************************
- SMBIOS data update TYPE9 System Slot Information
-************************************************************************/
-VOID
-SysSlotInfoUpdateSmbiosType9 (
- VOID
- )
-{
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mSysSlotInfoType9, mSysSlotInfoType9Strings, NULL);
-}
-
-/***********************************************************************
- SMBIOS data update TYPE16 Physical Memory Array Information
-************************************************************************/
-VOID
-PhyMemArrayInfoUpdateSmbiosType16 (
- VOID
- )
-{
- EFI_SMBIOS_HANDLE MemArraySmbiosHande;
-
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mPhyMemArrayInfoType16, mPhyMemArrayInfoType16Strings, &MemArraySmbiosHande);
-
- //
- // Update the memory device information
- //
- mMemDevInfoType17.MemoryArrayHandle = MemArraySmbiosHande;
-}
-
-/***********************************************************************
- SMBIOS data update TYPE17 Memory Device Information
-************************************************************************/
-VOID
-MemDevInfoUpdateSmbiosType17 (
- VOID
- )
-{
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mMemDevInfoType17, mMemDevInfoType17Strings, NULL);
-}
-
-/***********************************************************************
- SMBIOS data update TYPE19 Memory Array Map Information
-************************************************************************/
-VOID
-MemArrMapInfoUpdateSmbiosType19 (
- VOID
- )
-{
- EFI_STATUS Status;
- UINT32 BoardRevision = 0;
-
- // Note: Type 19 addresses are expressed in KB, not bytes
- // The memory layout used in all known Pi SoC's starts at 0
- mMemArrMapInfoType19.StartingAddress = 0;
- // The minimum RAM size used on any Raspberry Pi model is 256 MB
- mMemArrMapInfoType19.EndingAddress = 256 * 1024;
- Status = mFwProtocol->GetModelRevision (&BoardRevision);
- if (Status != EFI_SUCCESS) {
- DEBUG ((DEBUG_WARN, "Couldn't get the board memory size - defaulting to 256 MB: %r\n", Status));
- } else {
- // www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
- // Bits [20-22] indicate the amount of memory starting with 256MB (000b)
- // and doubling in size for each value (001b = 512 MB, 010b = 1GB, etc.)
- mMemArrMapInfoType19.EndingAddress <<= (BoardRevision >> 20) & 0x07;
- }
- mMemArrMapInfoType19.EndingAddress -= 1;
-
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mMemArrMapInfoType19, mMemArrMapInfoType19Strings, NULL);
-}
-
-
-/***********************************************************************
- SMBIOS data update TYPE32 Boot Information
-************************************************************************/
-VOID
-BootInfoUpdateSmbiosType32 (
- VOID
- )
-{
- LogSmbiosData ((EFI_SMBIOS_TABLE_HEADER*)&mBootInfoType32, mBootInfoType32Strings, NULL);
-}
-
-/***********************************************************************
- Driver Entry
-************************************************************************/
-EFI_STATUS
-EFIAPI
-PlatformSmbiosDriverEntryPoint (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- Status = gBS->LocateProtocol (&gRaspberryPiFirmwareProtocolGuid, NULL,
- (VOID**)&mFwProtocol);
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- BIOSInfoUpdateSmbiosType0 ();
-
- SysInfoUpdateSmbiosType1 ();
-
- BoardInfoUpdateSmbiosType2 ();
-
- EnclosureInfoUpdateSmbiosType3 ();
-
- ProcessorInfoUpdateSmbiosType4 (4); //One example for creating and updating
-
- CacheInfoUpdateSmbiosType7 ();
-
- SysSlotInfoUpdateSmbiosType9 ();
-
- PhyMemArrayInfoUpdateSmbiosType16 ();
-
- MemDevInfoUpdateSmbiosType17 ();
-
- MemArrMapInfoUpdateSmbiosType19 ();
-
- BootInfoUpdateSmbiosType32 ();
-
- return EFI_SUCCESS;
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf b/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf
deleted file mode 100644
index 48545062..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf
+++ /dev/null
@@ -1,52 +0,0 @@
-#/** @file
-#
-# SMBIOS Table for ARM platform
-#
-# Copyright (c) 2017, Andrei Warkentin <andrey.warkentin@gmail.com>
-# Copyright (c) Microsoft Corporation. All rights reserved.
-# Copyright (c) 2013 Linaro.org
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x0001001A
- BASE_NAME = PlatformSmbiosDxe
- FILE_GUID = BAD0554E-22E9-4D83-9AFD-CC87727A1A45
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = PlatformSmbiosDriverEntryPoint
-
-[Sources]
- PlatformSmbiosDxe.c
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- ArmPlatformPkg/ArmPlatformPkg.dec
- ArmPkg/ArmPkg.dec
- Platform/RaspberryPi/RPi3/RPi3.dec
-
-[LibraryClasses]
- UefiBootServicesTableLib
- MemoryAllocationLib
- BaseMemoryLib
- BaseLib
- UefiLib
- UefiDriverEntryPoint
- DebugLib
- PrintLib
-
-[Protocols]
- gEfiSmbiosProtocolGuid # PROTOCOL SOMETIMES_CONSUMED
- gRaspberryPiFirmwareProtocolGuid ## CONSUMES
-[Guids]
-
-[Depex]
- gEfiSmbiosProtocolGuid AND gRaspberryPiFirmwareProtocolGuid
-
-[Pcd]
- gArmTokenSpaceGuid.PcdSystemMemorySize
- gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVendor
- gEfiMdeModulePkgTokenSpaceGuid.PcdFirmwareVersionString
diff --git a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
deleted file mode 100644
index 5a9d4c3f..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.c
+++ /dev/null
@@ -1,1241 +0,0 @@
-/** @file
- *
- * Copyright (c) 2017-2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2016, Linaro, Ltd. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <PiDxe.h>
-
-#include <Library/ArmLib.h>
-#include <Library/DmaLib.h>
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/IoLib.h>
-#include <Library/SynchronizationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-
-#include <IndustryStandard/Bcm2836.h>
-#include <IndustryStandard/RpiMbox.h>
-
-#include <Protocol/RpiFirmware.h>
-
-//
-// The number of statically allocated buffer pages
-//
-#define NUM_PAGES 1
-
-//
-// The number of iterations to perform when waiting for the mailbox
-// status to change
-//
-#define MAX_TRIES 0x100000
-
-STATIC VOID *mDmaBuffer;
-STATIC VOID *mDmaBufferMapping;
-STATIC UINTN mDmaBufferBusAddress;
-
-STATIC SPIN_LOCK mMailboxLock;
-
-STATIC
-BOOLEAN
-DrainMailbox (
- VOID
- )
-{
- INTN Tries;
- UINT32 Val;
-
- //
- // Get rid of stale response data in the mailbox
- //
- Tries = 0;
- do {
- Val = MmioRead32 (BCM2836_MBOX_BASE_ADDRESS + BCM2836_MBOX_STATUS_OFFSET);
- if (Val & (1U << BCM2836_MBOX_STATUS_EMPTY)) {
- return TRUE;
- }
- ArmDataSynchronizationBarrier ();
- MmioRead32 (BCM2836_MBOX_BASE_ADDRESS + BCM2836_MBOX_READ_OFFSET);
- } while (++Tries < MAX_TRIES);
-
- return FALSE;
-}
-
-STATIC
-BOOLEAN
-MailboxWaitForStatusCleared (
- IN UINTN StatusMask
- )
-{
- INTN Tries;
- UINT32 Val;
-
- //
- // Get rid of stale response data in the mailbox
- //
- Tries = 0;
- do {
- Val = MmioRead32 (BCM2836_MBOX_BASE_ADDRESS + BCM2836_MBOX_STATUS_OFFSET);
- if ((Val & StatusMask) == 0) {
- return TRUE;
- }
- ArmDataSynchronizationBarrier ();
- } while (++Tries < MAX_TRIES);
-
- return FALSE;
-}
-
-STATIC
-EFI_STATUS
-MailboxTransaction (
- IN UINTN Length,
- IN UINTN Channel,
- OUT UINT32 *Result
- )
-{
- if (Channel >= BCM2836_MBOX_NUM_CHANNELS) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Get rid of stale response data in the mailbox
- //
- if (!DrainMailbox ()) {
- DEBUG ((DEBUG_ERROR, "%a: timeout waiting for mailbox to drain\n",
- __FUNCTION__));
- return EFI_TIMEOUT;
- }
-
- //
- // Wait for the 'output register full' bit to become clear
- //
- if (!MailboxWaitForStatusCleared (1U << BCM2836_MBOX_STATUS_FULL)) {
- DEBUG ((DEBUG_ERROR, "%a: timeout waiting for outbox to become empty\n",
- __FUNCTION__));
- return EFI_TIMEOUT;
- }
-
- ArmDataSynchronizationBarrier ();
-
- //
- // Start the mailbox transaction
- //
- MmioWrite32 (BCM2836_MBOX_BASE_ADDRESS + BCM2836_MBOX_WRITE_OFFSET,
- (UINT32)((UINTN)mDmaBufferBusAddress | Channel));
-
- ArmDataSynchronizationBarrier ();
-
- //
- // Wait for the 'input register empty' bit to clear
- //
- if (!MailboxWaitForStatusCleared (1U << BCM2836_MBOX_STATUS_EMPTY)) {
- DEBUG ((DEBUG_ERROR, "%a: timeout waiting for inbox to become full\n",
- __FUNCTION__));
- return EFI_TIMEOUT;
- }
-
- //
- // Read back the result
- //
- ArmDataSynchronizationBarrier ();
- *Result = MmioRead32 (BCM2836_MBOX_BASE_ADDRESS + BCM2836_MBOX_READ_OFFSET);
- ArmDataSynchronizationBarrier ();
-
- return EFI_SUCCESS;
-}
-
-#pragma pack(1)
-typedef struct {
- UINT32 BufferSize;
- UINT32 Response;
-} RPI_FW_BUFFER_HEAD;
-
-typedef struct {
- UINT32 TagId;
- UINT32 TagSize;
- UINT32 TagValueSize;
-} RPI_FW_TAG_HEAD;
-
-typedef struct {
- UINT32 DeviceId;
- UINT32 PowerState;
-} RPI_FW_POWER_STATE_TAG;
-
-typedef struct {
- RPI_FW_BUFFER_HEAD BufferHead;
- RPI_FW_TAG_HEAD TagHead;
- RPI_FW_POWER_STATE_TAG TagBody;
- UINT32 EndTag;
-} RPI_FW_SET_POWER_STATE_CMD;
-#pragma pack()
-
-STATIC
-EFI_STATUS
-EFIAPI
-RpiFirmwareSetPowerState (
- IN UINT32 DeviceId,
- IN BOOLEAN PowerState,
- IN BOOLEAN Wait
- )
-{
- RPI_FW_SET_POWER_STATE_CMD *Cmd;
- EFI_STATUS Status;
- UINT32 Result;
-
- if (!AcquireSpinLockOrFail (&mMailboxLock)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION__));
- return EFI_DEVICE_ERROR;
- }
-
- Cmd = mDmaBuffer;
- ZeroMem (Cmd, sizeof (*Cmd));
-
- Cmd->BufferHead.BufferSize = sizeof (*Cmd);
- Cmd->BufferHead.Response = 0;
- Cmd->TagHead.TagId = RPI_MBOX_SET_POWER_STATE;
- Cmd->TagHead.TagSize = sizeof (Cmd->TagBody);
- Cmd->TagHead.TagValueSize = 0;
- Cmd->TagBody.DeviceId = DeviceId;
- Cmd->TagBody.PowerState = (PowerState ? RPI_MBOX_POWER_STATE_ENABLE : 0) |
- (Wait ? RPI_MBOX_POWER_STATE_WAIT : 0);
- Cmd->EndTag = 0;
-
- Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result);
-
- ReleaseSpinLock (&mMailboxLock);
-
- if (EFI_ERROR (Status) ||
- Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
- DEBUG ((DEBUG_ERROR,
- "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
- __FUNCTION__, Status, Cmd->BufferHead.Response));
- Status = EFI_DEVICE_ERROR;
- }
-
- if (!EFI_ERROR (Status) &&
- PowerState ^ (Cmd->TagBody.PowerState & RPI_MBOX_POWER_STATE_ENABLE)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to %sable power for device %d\n",
- __FUNCTION__, PowerState ? "en" : "dis", DeviceId));
- Status = EFI_DEVICE_ERROR;
- }
-
- return Status;
-}
-
-#pragma pack()
-typedef struct {
- UINT32 Base;
- UINT32 Size;
-} RPI_FW_ARM_MEMORY_TAG;
-
-typedef struct {
- RPI_FW_BUFFER_HEAD BufferHead;
- RPI_FW_TAG_HEAD TagHead;
- RPI_FW_ARM_MEMORY_TAG TagBody;
- UINT32 EndTag;
-} RPI_FW_GET_ARM_MEMORY_CMD;
-#pragma pack()
-
-STATIC
-EFI_STATUS
-EFIAPI
-RpiFirmwareGetArmMemory (
- OUT UINT32 *Base,
- OUT UINT32 *Size
- )
-{
- RPI_FW_GET_ARM_MEMORY_CMD *Cmd;
- EFI_STATUS Status;
- UINT32 Result;
-
- if (!AcquireSpinLockOrFail (&mMailboxLock)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION__));
- return EFI_DEVICE_ERROR;
- }
-
- Cmd = mDmaBuffer;
- ZeroMem (Cmd, sizeof (*Cmd));
-
- Cmd->BufferHead.BufferSize = sizeof (*Cmd);
- Cmd->BufferHead.Response = 0;
- Cmd->TagHead.TagId = RPI_MBOX_GET_ARM_MEMSIZE;
- Cmd->TagHead.TagSize = sizeof (Cmd->TagBody);
- Cmd->TagHead.TagValueSize = 0;
- Cmd->EndTag = 0;
-
- Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result);
-
- ReleaseSpinLock (&mMailboxLock);
-
- if (EFI_ERROR (Status) ||
- Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
- DEBUG ((DEBUG_ERROR,
- "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
- __FUNCTION__, Status, Cmd->BufferHead.Response));
- return EFI_DEVICE_ERROR;
- }
-
- *Base = Cmd->TagBody.Base;
- *Size = Cmd->TagBody.Size;
- return EFI_SUCCESS;
-}
-
-#pragma pack()
-typedef struct {
- UINT8 MacAddress[6];
- UINT32 Padding;
-} RPI_FW_MAC_ADDR_TAG;
-
-typedef struct {
- RPI_FW_BUFFER_HEAD BufferHead;
- RPI_FW_TAG_HEAD TagHead;
- RPI_FW_MAC_ADDR_TAG TagBody;
- UINT32 EndTag;
-} RPI_FW_GET_MAC_ADDR_CMD;
-#pragma pack()
-
-STATIC
-EFI_STATUS
-EFIAPI
-RpiFirmwareGetMacAddress (
- OUT UINT8 MacAddress[6]
- )
-{
- RPI_FW_GET_MAC_ADDR_CMD *Cmd;
- EFI_STATUS Status;
- UINT32 Result;
-
- if (!AcquireSpinLockOrFail (&mMailboxLock)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION__));
- return EFI_DEVICE_ERROR;
- }
-
- Cmd = mDmaBuffer;
- ZeroMem (Cmd, sizeof (*Cmd));
-
- Cmd->BufferHead.BufferSize = sizeof (*Cmd);
- Cmd->BufferHead.Response = 0;
- Cmd->TagHead.TagId = RPI_MBOX_GET_MAC_ADDRESS;
- Cmd->TagHead.TagSize = sizeof (Cmd->TagBody);
- Cmd->TagHead.TagValueSize = 0;
- Cmd->EndTag = 0;
-
- Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result);
-
- ReleaseSpinLock (&mMailboxLock);
-
- if (EFI_ERROR (Status) ||
- Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
- DEBUG ((DEBUG_ERROR,
- "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
- __FUNCTION__, Status, Cmd->BufferHead.Response));
- return EFI_DEVICE_ERROR;
- }
-
- CopyMem (MacAddress, Cmd->TagBody.MacAddress, sizeof (Cmd->TagBody.MacAddress));
- return EFI_SUCCESS;
-}
-
-#pragma pack()
-typedef struct {
- UINT64 Serial;
-} RPI_FW_SERIAL_TAG;
-
-typedef struct {
- RPI_FW_BUFFER_HEAD BufferHead;
- RPI_FW_TAG_HEAD TagHead;
- RPI_FW_SERIAL_TAG TagBody;
- UINT32 EndTag;
-} RPI_FW_GET_SERIAL_CMD;
-#pragma pack()
-
-STATIC
-EFI_STATUS
-EFIAPI
-RpiFirmwareGetSerial (
- OUT UINT64 *Serial
- )
-{
- RPI_FW_GET_SERIAL_CMD *Cmd;
- EFI_STATUS Status;
- UINT32 Result;
-
- if (!AcquireSpinLockOrFail (&mMailboxLock)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION__));
- return EFI_DEVICE_ERROR;
- }
-
- Cmd = mDmaBuffer;
- ZeroMem (Cmd, sizeof (*Cmd));
-
- Cmd->BufferHead.BufferSize = sizeof (*Cmd);
- Cmd->BufferHead.Response = 0;
- Cmd->TagHead.TagId = RPI_MBOX_GET_BOARD_SERIAL;
- Cmd->TagHead.TagSize = sizeof (Cmd->TagBody);
- Cmd->TagHead.TagValueSize = 0;
- Cmd->EndTag = 0;
-
- Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result);
-
- ReleaseSpinLock (&mMailboxLock);
-
- if (EFI_ERROR (Status) ||
- Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
- DEBUG ((DEBUG_ERROR,
- "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
- __FUNCTION__, Status, Cmd->BufferHead.Response));
- return EFI_DEVICE_ERROR;
- }
-
- *Serial = Cmd->TagBody.Serial;
- // Some platforms return 0 for serial. For those, try to use the MAC address.
- if (*Serial == 0) {
- Status = RpiFirmwareGetMacAddress ((UINT8*) Serial);
- // Convert to a more user-friendly value
- *Serial = SwapBytes64 (*Serial << 16);
- }
-
- return Status;
-}
-
-#pragma pack()
-typedef struct {
- UINT32 Model;
-} RPI_FW_MODEL_TAG;
-
-typedef struct {
- RPI_FW_BUFFER_HEAD BufferHead;
- RPI_FW_TAG_HEAD TagHead;
- RPI_FW_MODEL_TAG TagBody;
- UINT32 EndTag;
-} RPI_FW_GET_MODEL_CMD;
-#pragma pack()
-
-STATIC
-EFI_STATUS
-EFIAPI
-RpiFirmwareGetModel (
- OUT UINT32 *Model
- )
-{
- RPI_FW_GET_MODEL_CMD *Cmd;
- EFI_STATUS Status;
- UINT32 Result;
-
- if (!AcquireSpinLockOrFail (&mMailboxLock)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION__));
- return EFI_DEVICE_ERROR;
- }
-
- Cmd = mDmaBuffer;
- ZeroMem (Cmd, sizeof (*Cmd));
-
- Cmd->BufferHead.BufferSize = sizeof (*Cmd);
- Cmd->BufferHead.Response = 0;
- Cmd->TagHead.TagId = RPI_MBOX_GET_BOARD_MODEL;
- Cmd->TagHead.TagSize = sizeof (Cmd->TagBody);
- Cmd->TagHead.TagValueSize = 0;
- Cmd->EndTag = 0;
-
- Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result);
-
- ReleaseSpinLock (&mMailboxLock);
-
- if (EFI_ERROR (Status) ||
- Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
- DEBUG ((DEBUG_ERROR,
- "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
- __FUNCTION__, Status, Cmd->BufferHead.Response));
- return EFI_DEVICE_ERROR;
- }
-
- *Model = Cmd->TagBody.Model;
- return EFI_SUCCESS;
-}
-
-#pragma pack()
-typedef struct {
- UINT32 Revision;
-} RPI_FW_MODEL_REVISION_TAG;
-
-typedef struct {
- RPI_FW_BUFFER_HEAD BufferHead;
- RPI_FW_TAG_HEAD TagHead;
- RPI_FW_MODEL_REVISION_TAG TagBody;
- UINT32 EndTag;
-} RPI_FW_GET_REVISION_CMD;
-#pragma pack()
-
-STATIC
-EFI_STATUS
-EFIAPI
-RpiFirmwareGetModelRevision (
- OUT UINT32 *Revision
- )
-{
- RPI_FW_GET_REVISION_CMD *Cmd;
- EFI_STATUS Status;
- UINT32 Result;
-
- if (!AcquireSpinLockOrFail (&mMailboxLock)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION__));
- return EFI_DEVICE_ERROR;
- }
-
- Cmd = mDmaBuffer;
- ZeroMem (Cmd, sizeof (*Cmd));
-
- Cmd->BufferHead.BufferSize = sizeof (*Cmd);
- Cmd->BufferHead.Response = 0;
- Cmd->TagHead.TagId = RPI_MBOX_GET_BOARD_REVISION;
- Cmd->TagHead.TagSize = sizeof (Cmd->TagBody);
- Cmd->TagHead.TagValueSize = 0;
- Cmd->EndTag = 0;
-
- Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result);
-
- ReleaseSpinLock (&mMailboxLock);
-
- if (EFI_ERROR (Status) ||
- Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
- DEBUG ((DEBUG_ERROR,
- "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
- __FUNCTION__, Status, Cmd->BufferHead.Response));
- return EFI_DEVICE_ERROR;
- }
-
- *Revision = Cmd->TagBody.Revision;
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-RpiFirmwareGetFirmwareRevision (
- OUT UINT32 *Revision
- )
-{
- RPI_FW_GET_REVISION_CMD *Cmd;
- EFI_STATUS Status;
- UINT32 Result;
-
- if (!AcquireSpinLockOrFail (&mMailboxLock)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION__));
- return EFI_DEVICE_ERROR;
- }
-
- Cmd = mDmaBuffer;
- ZeroMem (Cmd, sizeof (*Cmd));
-
- Cmd->BufferHead.BufferSize = sizeof (*Cmd);
- Cmd->BufferHead.Response = 0;
- Cmd->TagHead.TagId = RPI_MBOX_GET_REVISION;
- Cmd->TagHead.TagSize = sizeof (Cmd->TagBody);
- Cmd->TagHead.TagValueSize = 0;
- Cmd->EndTag = 0;
-
- Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result);
-
- ReleaseSpinLock (&mMailboxLock);
-
- if (EFI_ERROR (Status) ||
- Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
- DEBUG ((DEBUG_ERROR,
- "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
- __FUNCTION__, Status, Cmd->BufferHead.Response));
- return EFI_DEVICE_ERROR;
- }
-
- *Revision = Cmd->TagBody.Revision;
- return EFI_SUCCESS;
-}
-
-STATIC
-CHAR8*
-EFIAPI
-RpiFirmwareGetModelName (
- IN INTN ModelId
- )
-{
- UINT32 Revision;
-
- // If a negative ModelId is passed, detect it.
- if ((ModelId < 0) && (RpiFirmwareGetModelRevision (&Revision) == EFI_SUCCESS)) {
- ModelId = (Revision >> 4) & 0xFF;
- }
-
- switch (ModelId) {
- // www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
- case 0x00:
- return "Raspberry Pi Model A";
- case 0x01:
- return "Raspberry Pi Model B";
- case 0x02:
- return "Raspberry Pi Model A+";
- case 0x03:
- return "Raspberry Pi Model B+";
- case 0x04:
- return "Raspberry Pi 2 Model B";
- case 0x06:
- return "Raspberry Pi Compute Module 1";
- case 0x08:
- return "Raspberry Pi 3 Model B";
- case 0x09:
- return "Raspberry Pi Zero";
- case 0x0A:
- return "Raspberry Pi Compute Module 3";
- case 0x0C:
- return "Raspberry Pi Zero W";
- case 0x0D:
- return "Raspberry Pi 3 Model B+";
- case 0x0E:
- return "Raspberry Pi 3 Model A+";
- case 0x11:
- return "Raspberry Pi 4 Model B";
- default:
- return "Unknown Raspberry Pi Model";
- }
-}
-
-STATIC
-CHAR8*
-EFIAPI
-RpiFirmwareGetManufacturerName (
- IN INTN ManufacturerId
- )
-{
- UINT32 Revision;
-
- // If a negative ModelId is passed, detect it.
- if ((ManufacturerId < 0) && (RpiFirmwareGetModelRevision (&Revision) == EFI_SUCCESS)) {
- ManufacturerId = (Revision >> 16) & 0x0F;
- }
-
- switch (ManufacturerId) {
- // www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
- case 0x00:
- return "Sony UK";
- case 0x01:
- return "Egoman";
- case 0x02:
- case 0x04:
- return "Embest";
- case 0x03:
- return "Sony Japan";
- case 0x05:
- return "Stadium";
- default:
- return "Unknown Manufacturer";
- }
-}
-
-STATIC
-CHAR8*
-EFIAPI
-RpiFirmwareGetCpuName (
- IN INTN CpuId
- )
-{
- UINT32 Revision;
-
- // If a negative CpuId is passed, detect it.
- if ((CpuId < 0) && (RpiFirmwareGetModelRevision (&Revision) == EFI_SUCCESS)) {
- CpuId = (Revision >> 12) & 0x0F;
- }
-
- switch (CpuId) {
- // www.raspberrypi.org/documentation/hardware/raspberrypi/revision-codes/README.md
- case 0x00:
- return "BCM2835 (ARM11)";
- case 0x01:
- return "BCM2836 (ARM Cortex-A7)";
- case 0x02:
- return "BCM2837 (ARM Cortex-A53)";
- case 0x03:
- return "BCM2711 (ARM Cortex-A72)";
- default:
- return "Unknown CPU Model";
- }
-}
-
-#pragma pack()
-typedef struct {
- UINT32 Width;
- UINT32 Height;
-} RPI_FW_FB_SIZE_TAG;
-
-typedef struct {
- RPI_FW_BUFFER_HEAD BufferHead;
- RPI_FW_TAG_HEAD TagHead;
- RPI_FW_FB_SIZE_TAG TagBody;
- UINT32 EndTag;
-} RPI_FW_GET_FB_SIZE_CMD;
-
-typedef struct {
- UINT32 Depth;
-} RPI_FW_FB_DEPTH_TAG;
-
-typedef struct {
- UINT32 Pitch;
-} RPI_FW_FB_PITCH_TAG;
-
-typedef struct {
- UINT32 AlignmentBase;
- UINT32 Size;
-} RPI_FW_FB_ALLOC_TAG;
-
-typedef struct {
- RPI_FW_BUFFER_HEAD BufferHead;
- RPI_FW_TAG_HEAD FreeFbTag;
- UINT32 EndTag;
-} RPI_FW_FREE_FB_CMD;
-
-typedef struct {
- RPI_FW_BUFFER_HEAD BufferHead;
- RPI_FW_TAG_HEAD PhysSizeTag;
- RPI_FW_FB_SIZE_TAG PhysSize;
- RPI_FW_TAG_HEAD VirtSizeTag;
- RPI_FW_FB_SIZE_TAG VirtSize;
- RPI_FW_TAG_HEAD DepthTag;
- RPI_FW_FB_DEPTH_TAG Depth;
- RPI_FW_TAG_HEAD AllocFbTag;
- RPI_FW_FB_ALLOC_TAG AllocFb;
- RPI_FW_TAG_HEAD PitchTag;
- RPI_FW_FB_PITCH_TAG Pitch;
- UINT32 EndTag;
-} RPI_FW_INIT_FB_CMD;
-#pragma pack()
-
-STATIC
-EFI_STATUS
-EFIAPI
-RpiFirmwareGetFbSize (
- OUT UINT32 *Width,
- OUT UINT32 *Height
- )
-{
- RPI_FW_GET_FB_SIZE_CMD *Cmd;
- EFI_STATUS Status;
- UINT32 Result;
-
- if (!AcquireSpinLockOrFail (&mMailboxLock)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION__));
- return EFI_DEVICE_ERROR;
- }
-
- Cmd = mDmaBuffer;
- ZeroMem (Cmd, sizeof (*Cmd));
-
- Cmd->BufferHead.BufferSize = sizeof (*Cmd);
- Cmd->BufferHead.Response = 0;
- Cmd->TagHead.TagId = RPI_MBOX_GET_FB_GEOMETRY;
- Cmd->TagHead.TagSize = sizeof (Cmd->TagBody);
- Cmd->TagHead.TagValueSize = 0;
- Cmd->EndTag = 0;
-
- Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result);
-
- ReleaseSpinLock (&mMailboxLock);
-
- if (EFI_ERROR (Status) ||
- Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
- DEBUG ((DEBUG_ERROR,
- "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
- __FUNCTION__, Status, Cmd->BufferHead.Response));
- return EFI_DEVICE_ERROR;
- }
-
- *Width = Cmd->TagBody.Width;
- *Height = Cmd->TagBody.Height;
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-RpiFirmwareFreeFb (VOID)
-{
- RPI_FW_FREE_FB_CMD *Cmd;
- EFI_STATUS Status;
- UINT32 Result;
-
- if (!AcquireSpinLockOrFail (&mMailboxLock)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION__));
- return EFI_DEVICE_ERROR;
- }
-
- Cmd = mDmaBuffer;
- ZeroMem (Cmd, sizeof (*Cmd));
-
- Cmd->BufferHead.BufferSize = sizeof (*Cmd);
- Cmd->BufferHead.Response = 0;
-
- Cmd->FreeFbTag.TagId = RPI_MBOX_FREE_FB;
- Cmd->FreeFbTag.TagSize = 0;
- Cmd->FreeFbTag.TagValueSize = 0;
- Cmd->EndTag = 0;
-
- Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result);
- ReleaseSpinLock (&mMailboxLock);
-
- if (EFI_ERROR (Status) ||
- Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
- DEBUG ((DEBUG_ERROR,
- "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
- __FUNCTION__, Status, Cmd->BufferHead.Response));
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-RpiFirmwareAllocFb (
- IN UINT32 Width,
- IN UINT32 Height,
- IN UINT32 Depth,
- OUT EFI_PHYSICAL_ADDRESS *FbBase,
- OUT UINTN *FbSize,
- OUT UINTN *Pitch
- )
-{
- RPI_FW_INIT_FB_CMD *Cmd;
- EFI_STATUS Status;
- UINT32 Result;
-
- ASSERT (FbSize != NULL);
- ASSERT (FbBase != NULL);
-
- if (!AcquireSpinLockOrFail (&mMailboxLock)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION__));
- return EFI_DEVICE_ERROR;
- }
-
- Cmd = mDmaBuffer;
- ZeroMem (Cmd, sizeof (*Cmd));
-
- Cmd->BufferHead.BufferSize = sizeof (*Cmd);
- Cmd->BufferHead.Response = 0;
-
- Cmd->PhysSizeTag.TagId = RPI_MBOX_SET_FB_PGEOM;
- Cmd->PhysSizeTag.TagSize = sizeof (Cmd->PhysSize);
- Cmd->PhysSize.Width = Width;
- Cmd->PhysSize.Height = Height;
- Cmd->VirtSizeTag.TagId = RPI_MBOX_SET_FB_VGEOM;
- Cmd->VirtSizeTag.TagSize = sizeof (Cmd->VirtSize);
- Cmd->VirtSize.Width = Width;
- Cmd->VirtSize.Height = Height;
- Cmd->DepthTag.TagId = RPI_MBOX_SET_FB_DEPTH;
- Cmd->DepthTag.TagSize = sizeof (Cmd->Depth);
- Cmd->Depth.Depth = Depth;
- Cmd->AllocFbTag.TagId = RPI_MBOX_ALLOC_FB;
- Cmd->AllocFbTag.TagSize = sizeof (Cmd->AllocFb);
- Cmd->AllocFb.AlignmentBase = 32;
- Cmd->PitchTag.TagId = RPI_MBOX_GET_FB_LINELENGTH;
- Cmd->PitchTag.TagSize = sizeof (Cmd->Pitch);
- Cmd->EndTag = 0;
-
- Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result);
-
- ReleaseSpinLock (&mMailboxLock);
-
- if (EFI_ERROR (Status) ||
- Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
- DEBUG ((DEBUG_ERROR,
- "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
- __FUNCTION__, Status, Cmd->BufferHead.Response));
- return EFI_DEVICE_ERROR;
- }
-
- *Pitch = Cmd->Pitch.Pitch;
- *FbBase = Cmd->AllocFb.AlignmentBase - BCM2836_DMA_DEVICE_OFFSET;
- *FbSize = Cmd->AllocFb.Size;
- return EFI_SUCCESS;
-}
-
-#pragma pack()
-typedef struct {
- RPI_FW_BUFFER_HEAD BufferHead;
- RPI_FW_TAG_HEAD TagHead;
- UINT8 CommandLine[0];
-} RPI_FW_GET_COMMAND_LINE_CMD;
-#pragma pack()
-
-STATIC
-EFI_STATUS
-EFIAPI
-RpiFirmwareGetCommmandLine (
- IN UINTN BufferSize,
- OUT CHAR8 CommandLine[]
- )
-{
- RPI_FW_GET_COMMAND_LINE_CMD *Cmd;
- EFI_STATUS Status;
- UINT32 Result;
-
- if ((BufferSize % sizeof (UINT32)) != 0) {
- DEBUG ((DEBUG_ERROR, "%a: BufferSize must be a multiple of 4\n",
- __FUNCTION__));
- return EFI_INVALID_PARAMETER;
- }
-
- if (sizeof (*Cmd) + BufferSize > EFI_PAGES_TO_SIZE (NUM_PAGES)) {
- DEBUG ((DEBUG_ERROR, "%a: BufferSize exceeds size of DMA buffer\n",
- __FUNCTION__));
- return EFI_OUT_OF_RESOURCES;
- }
-
- if (!AcquireSpinLockOrFail (&mMailboxLock)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION__));
- return EFI_DEVICE_ERROR;
- }
-
- Cmd = mDmaBuffer;
- ZeroMem (Cmd, sizeof (*Cmd) + BufferSize + sizeof (UINT32));
-
- Cmd->BufferHead.BufferSize = sizeof (*Cmd) + BufferSize + sizeof (UINT32);
- Cmd->BufferHead.Response = 0;
- Cmd->TagHead.TagId = RPI_MBOX_GET_COMMAND_LINE;
- Cmd->TagHead.TagSize = BufferSize;
- Cmd->TagHead.TagValueSize = 0;
-
- Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result);
-
- ReleaseSpinLock (&mMailboxLock);
-
- if (EFI_ERROR (Status) ||
- Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
- DEBUG ((DEBUG_ERROR,
- "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
- __FUNCTION__, Status, Cmd->BufferHead.Response));
- return EFI_DEVICE_ERROR;
- }
-
- Cmd->TagHead.TagValueSize &= ~RPI_MBOX_VALUE_SIZE_RESPONSE_MASK;
- if (Cmd->TagHead.TagValueSize >= BufferSize &&
- Cmd->CommandLine[Cmd->TagHead.TagValueSize - 1] != '\0') {
- DEBUG ((DEBUG_ERROR, "%a: insufficient buffer size\n", __FUNCTION__));
- return EFI_OUT_OF_RESOURCES;
- }
-
- CopyMem (CommandLine, Cmd->CommandLine, Cmd->TagHead.TagValueSize);
-
- if (CommandLine[Cmd->TagHead.TagValueSize - 1] != '\0') {
- //
- // Add a NUL terminator if required.
- //
- CommandLine[Cmd->TagHead.TagValueSize] = '\0';
- }
-
- return EFI_SUCCESS;
-}
-
-#pragma pack()
-typedef struct {
- UINT32 ClockId;
- UINT32 ClockRate;
- UINT32 SkipTurbo;
-} RPI_FW_SET_CLOCK_RATE_TAG;
-
-typedef struct {
- RPI_FW_BUFFER_HEAD BufferHead;
- RPI_FW_TAG_HEAD TagHead;
- RPI_FW_SET_CLOCK_RATE_TAG TagBody;
- UINT32 EndTag;
-} RPI_FW_SET_CLOCK_RATE_CMD;
-#pragma pack()
-
-STATIC
-EFI_STATUS
-EFIAPI
-RpiFirmwareSetClockRate (
- IN UINT32 ClockId,
- IN UINT32 ClockRate,
- IN BOOLEAN SkipTurbo
- )
-{
- RPI_FW_SET_CLOCK_RATE_CMD *Cmd;
- EFI_STATUS Status;
- UINT32 Result;
-
- if (!AcquireSpinLockOrFail (&mMailboxLock)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION__));
- return EFI_DEVICE_ERROR;
- }
-
- Cmd = mDmaBuffer;
- ZeroMem (Cmd, sizeof (*Cmd));
-
- Cmd->BufferHead.BufferSize = sizeof (*Cmd);
- Cmd->BufferHead.Response = 0;
- Cmd->TagHead.TagId = RPI_MBOX_SET_CLOCK_RATE;
- Cmd->TagHead.TagSize = sizeof (Cmd->TagBody);
- Cmd->TagHead.TagValueSize = 0;
- Cmd->TagBody.ClockId = ClockId;
- Cmd->TagBody.ClockRate = ClockRate;
- Cmd->TagBody.SkipTurbo = SkipTurbo ? 1 : 0;
- Cmd->EndTag = 0;
-
- Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result);
-
- ReleaseSpinLock (&mMailboxLock);
-
- if (EFI_ERROR (Status) ||
- Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
- DEBUG ((DEBUG_ERROR,
- "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
- __FUNCTION__, Status, Cmd->BufferHead.Response));
- return EFI_DEVICE_ERROR;
- }
-
- return EFI_SUCCESS;
-}
-
-
-#pragma pack()
-typedef struct {
- UINT32 ClockId;
- UINT32 ClockRate;
-} RPI_FW_CLOCK_RATE_TAG;
-
-typedef struct {
- RPI_FW_BUFFER_HEAD BufferHead;
- RPI_FW_TAG_HEAD TagHead;
- RPI_FW_CLOCK_RATE_TAG TagBody;
- UINT32 EndTag;
-} RPI_FW_GET_CLOCK_RATE_CMD;
-#pragma pack()
-
-STATIC
-EFI_STATUS
-EFIAPI
-RpiFirmwareGetClockRate (
- IN UINT32 ClockId,
- IN UINT32 ClockKind,
- OUT UINT32 *ClockRate
- )
-{
- RPI_FW_GET_CLOCK_RATE_CMD *Cmd;
- EFI_STATUS Status;
- UINT32 Result;
-
- if (!AcquireSpinLockOrFail (&mMailboxLock)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION__));
- return EFI_DEVICE_ERROR;
- }
-
- Cmd = mDmaBuffer;
- ZeroMem (Cmd, sizeof (*Cmd));
-
- Cmd->BufferHead.BufferSize = sizeof (*Cmd);
- Cmd->BufferHead.Response = 0;
- Cmd->TagHead.TagId = ClockKind;
- Cmd->TagHead.TagSize = sizeof (Cmd->TagBody);
- Cmd->TagHead.TagValueSize = 0;
- Cmd->TagBody.ClockId = ClockId;
- Cmd->EndTag = 0;
-
- Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result);
-
- ReleaseSpinLock (&mMailboxLock);
-
- if (EFI_ERROR (Status) ||
- Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
- DEBUG ((DEBUG_ERROR,
- "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
- __FUNCTION__, Status, Cmd->BufferHead.Response));
- return EFI_DEVICE_ERROR;
- }
-
- *ClockRate = Cmd->TagBody.ClockRate;
- return EFI_SUCCESS;
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-RpiFirmwareGetCurrentClockRate (
- IN UINT32 ClockId,
- OUT UINT32 *ClockRate
- )
-{
- return RpiFirmwareGetClockRate (ClockId, RPI_MBOX_GET_CLOCK_RATE, ClockRate);
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-RpiFirmwareGetMaxClockRate (
- IN UINT32 ClockId,
- OUT UINT32 *ClockRate
- )
-{
- return RpiFirmwareGetClockRate (ClockId, RPI_MBOX_GET_MAX_CLOCK_RATE, ClockRate);
-}
-
-STATIC
-EFI_STATUS
-EFIAPI
-RpiFirmwareGetMinClockRate (
- IN UINT32 ClockId,
- OUT UINT32 *ClockRate
- )
-{
- return RpiFirmwareGetClockRate (ClockId, RPI_MBOX_GET_MIN_CLOCK_RATE, ClockRate);
-}
-
-#pragma pack()
-typedef struct {
- UINT32 Pin;
- UINT32 State;
-} RPI_FW_SET_GPIO_TAG;
-
-typedef struct {
- RPI_FW_BUFFER_HEAD BufferHead;
- RPI_FW_TAG_HEAD TagHead;
- RPI_FW_SET_GPIO_TAG TagBody;
- UINT32 EndTag;
-} RPI_FW_SET_GPIO_CMD;
-#pragma pack()
-
-STATIC
-VOID
-RpiFirmwareSetLed (
- IN BOOLEAN On
- )
-{
- RPI_FW_SET_GPIO_CMD *Cmd;
- EFI_STATUS Status;
- UINT32 Result;
-
- if (!AcquireSpinLockOrFail (&mMailboxLock)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to acquire spinlock\n", __FUNCTION__));
- return;
- }
-
- Cmd = mDmaBuffer;
- ZeroMem (Cmd, sizeof (*Cmd));
-
- Cmd->BufferHead.BufferSize = sizeof (*Cmd);
- Cmd->BufferHead.Response = 0;
- Cmd->TagHead.TagId = RPI_MBOX_SET_GPIO;
- Cmd->TagHead.TagSize = sizeof (Cmd->TagBody);
- /*
- * GPIO_PIN_2 = Activity LED
- * GPIO_PIN_4 = HDMI Detect (Input / Active Low)
- * GPIO_PIN_7 = Power LED (Input / Active Low)
- *
- * There's also a 128 pin offset.
- */
- Cmd->TagBody.Pin = 128 + 2;
- Cmd->TagBody.State = On;
- Cmd->TagHead.TagValueSize = 0;
- Cmd->EndTag = 0;
-
- Status = MailboxTransaction (Cmd->BufferHead.BufferSize, RPI_MBOX_VC_CHANNEL, &Result);
-
- ReleaseSpinLock (&mMailboxLock);
-
- if (EFI_ERROR (Status) ||
- Cmd->BufferHead.Response != RPI_MBOX_RESP_SUCCESS) {
- DEBUG ((DEBUG_ERROR,
- "%a: mailbox transaction error: Status == %r, Response == 0x%x\n",
- __FUNCTION__, Status, Cmd->BufferHead.Response));
- }
-}
-
-STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL mRpiFirmwareProtocol = {
- RpiFirmwareSetPowerState,
- RpiFirmwareGetMacAddress,
- RpiFirmwareGetCommmandLine,
- RpiFirmwareGetCurrentClockRate,
- RpiFirmwareGetMaxClockRate,
- RpiFirmwareGetMinClockRate,
- RpiFirmwareSetClockRate,
- RpiFirmwareAllocFb,
- RpiFirmwareFreeFb,
- RpiFirmwareGetFbSize,
- RpiFirmwareSetLed,
- RpiFirmwareGetSerial,
- RpiFirmwareGetModel,
- RpiFirmwareGetModelRevision,
- RpiFirmwareGetModelName,
- RpiFirmwareGetFirmwareRevision,
- RpiFirmwareGetManufacturerName,
- RpiFirmwareGetCpuName,
- RpiFirmwareGetArmMemory
-};
-
-/**
- Initialize the state information for the CPU Architectural Protocol
-
- @param ImageHandle of the loaded driver
- @param SystemTable Pointer to the System Table
-
- @retval EFI_SUCCESS Protocol registered
- @retval EFI_OUT_OF_RESOURCES Cannot allocate protocol data structure
- @retval EFI_DEVICE_ERROR Hardware problems
-
-**/
-EFI_STATUS
-RpiFirmwareDxeInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- UINTN BufferSize;
-
- //
- // We only need one of these
- //
- ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gRaspberryPiFirmwareProtocolGuid);
-
- InitializeSpinLock (&mMailboxLock);
-
- Status = DmaAllocateBuffer (EfiBootServicesData, NUM_PAGES, &mDmaBuffer);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to allocate DMA buffer (Status == %r)\n", __FUNCTION__));
- return Status;
- }
-
- BufferSize = EFI_PAGES_TO_SIZE (NUM_PAGES);
- Status = DmaMap (MapOperationBusMasterCommonBuffer, mDmaBuffer, &BufferSize,
- &mDmaBufferBusAddress, &mDmaBufferMapping);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to map DMA buffer (Status == %r)\n", __FUNCTION__));
- goto FreeBuffer;
- }
-
- //
- // The channel index is encoded in the low bits of the bus address,
- // so make sure these are cleared.
- //
- ASSERT (!(mDmaBufferBusAddress & (BCM2836_MBOX_NUM_CHANNELS - 1)));
-
- Status = gBS->InstallProtocolInterface (&ImageHandle,
- &gRaspberryPiFirmwareProtocolGuid, EFI_NATIVE_INTERFACE,
- &mRpiFirmwareProtocol);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR,
- "%a: failed to install RPI firmware protocol (Status == %r)\n",
- __FUNCTION__, Status));
- goto UnmapBuffer;
- }
-
- return EFI_SUCCESS;
-
-UnmapBuffer:
- DmaUnmap (mDmaBufferMapping);
-FreeBuffer:
- DmaFreeBuffer (NUM_PAGES, mDmaBuffer);
-
- return Status;
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf b/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
deleted file mode 100644
index bba00070..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
+++ /dev/null
@@ -1,44 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2017-2018, Andrei Warkentin <andrey.warkentin@gmail.com>
-# Copyright (c) 2016, Linaro, Ltd. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x0001001A
- BASE_NAME = RpiFirmwareDxe
- FILE_GUID = 6d4628df-49a0-4b67-a325-d5af35c65745
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = RpiFirmwareDxeInitialize
-
-[Sources]
- RpiFirmwareDxe.c
-
-[Packages]
- ArmPkg/ArmPkg.dec
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- Silicon/Broadcom/Bcm283x/Bcm283x.dec
- Platform/RaspberryPi/RPi3/RPi3.dec
-
-[LibraryClasses]
- ArmLib
- BaseLib
- BaseMemoryLib
- DebugLib
- DmaLib
- IoLib
- SynchronizationLib
- UefiBootServicesTableLib
- UefiDriverEntryPoint
- UefiLib
-
-[Protocols]
- gRaspberryPiFirmwareProtocolGuid ## PRODUCES
-
-[Depex]
- TRUE
diff --git a/Platform/RaspberryPi/RPi3/Drivers/SdHostDxe/SdHostDxe.c b/Platform/RaspberryPi/RPi3/Drivers/SdHostDxe/SdHostDxe.c
deleted file mode 100644
index 2f31c5eb..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/SdHostDxe/SdHostDxe.c
+++ /dev/null
@@ -1,781 +0,0 @@
-/** @file
- *
- * Copyright (c) 2017, Andrei Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) Microsoft Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <Uefi.h>
-#include <Library/BaseLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DebugLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/IoLib.h>
-#include <Library/PcdLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DmaLib.h>
-#include <Library/TimerLib.h>
-
-#include <Protocol/EmbeddedExternalDevice.h>
-#include <Protocol/BlockIo.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/RpiMmcHost.h>
-#include <Protocol/RpiFirmware.h>
-
-#include <IndustryStandard/Bcm2836.h>
-#include <IndustryStandard/RpiMbox.h>
-#include <IndustryStandard/Bcm2836SdHost.h>
-
-#define SDHOST_BLOCK_BYTE_LENGTH 512
-
-// Driver Timing Parameters
-#define CMD_STALL_AFTER_POLL_US 1
-#define CMD_MIN_POLL_TOTAL_TIME_US 100000 // 100ms
-#define CMD_MAX_POLL_COUNT (CMD_MIN_POLL_TOTAL_TIME_US / CMD_STALL_AFTER_POLL_US)
-#define CMD_MAX_RETRY_COUNT 3
-#define CMD_STALL_AFTER_RETRY_US 20 // 20us
-#define FIFO_MAX_POLL_COUNT 1000000
-#define STALL_TO_STABILIZE_US 10000 // 10ms
-
-#define IDENT_MODE_SD_CLOCK_FREQ_HZ 400000 // 400KHz
-
-// Macros adopted from MmcDxe internal header
-#define SDHOST_R0_READY_FOR_DATA BIT8
-#define SDHOST_R0_CURRENTSTATE(Response) ((Response >> 9) & 0xF)
-
-#define DEBUG_MMCHOST_SD DEBUG_VERBOSE
-#define DEBUG_MMCHOST_SD_INFO DEBUG_INFO
-#define DEBUG_MMCHOST_SD_ERROR DEBUG_ERROR
-
-STATIC RASPBERRY_PI_FIRMWARE_PROTOCOL *mFwProtocol;
-
-// Per Physical Layer Simplified Specs
-#ifndef NDEBUG
-STATIC CONST CHAR8* mStrSdState[] = { "idle", "ready", "ident", "stby",
- "tran", "data", "rcv", "prg", "dis",
- "ina" };
-STATIC CONST CHAR8 *mFsmState[] = { "identmode", "datamode", "readdata",
- "writedata", "readwait", "readcrc",
- "writecrc", "writewait1", "powerdown",
- "powerup", "writestart1", "writestart2",
- "genpulses", "writewait2", "?",
- "startpowdown" };
-#endif /* NDEBUG */
-STATIC UINT32 mLastGoodCmd = MMC_GET_INDX (MMC_CMD0);
-
-STATIC inline BOOLEAN
-IsAppCmd (
- VOID
- )
-{
- return mLastGoodCmd == MMC_CMD55;
-}
-
-STATIC BOOLEAN
-IsBusyCmd (
- IN UINT32 MmcCmd
- )
-{
- if (IsAppCmd ()) {
- return FALSE;
- }
-
- return MmcCmd == MMC_CMD7 || MmcCmd == MMC_CMD12;
-}
-
-STATIC BOOLEAN
-IsWriteCmd (
- IN UINT32 MmcCmd
- )
-{
- if (IsAppCmd ()) {
- return FALSE;
- }
-
- return MmcCmd == MMC_CMD24 || MmcCmd == MMC_CMD25;
-}
-
-STATIC BOOLEAN
-IsReadCmd (
- IN UINT32 MmcCmd,
- IN UINT32 Argument
- )
-{
- if (MmcCmd == MMC_CMD8 && !IsAppCmd ()) {
- if (Argument == CMD8_MMC_ARG) {
- DEBUG ((DEBUG_MMCHOST_SD, "Sending MMC CMD8 variant\n"));
- return TRUE;
- } else {
- ASSERT (Argument == CMD8_SD_ARG);
- DEBUG ((DEBUG_MMCHOST_SD, "Sending SD CMD8 variant\n"));
- return FALSE;
- }
- }
-
- return
- (MmcCmd == MMC_CMD6 && !IsAppCmd ()) ||
- (MmcCmd == MMC_CMD17 && !IsAppCmd ()) ||
- (MmcCmd == MMC_CMD18 && !IsAppCmd ()) ||
- (MmcCmd == MMC_CMD13 && IsAppCmd ()) ||
- (MmcCmd == MMC_ACMD22 && IsAppCmd ()) ||
- (MmcCmd == MMC_ACMD51 && IsAppCmd ());
-}
-
-STATIC VOID
-SdHostDumpRegisters (
- VOID
- )
-{
- DEBUG ((DEBUG_MMCHOST_SD, "SdHost: Registers Dump:\n"));
- DEBUG ((DEBUG_MMCHOST_SD, " CMD: 0x%8.8X\n", MmioRead32 (SDHOST_CMD)));
- DEBUG ((DEBUG_MMCHOST_SD, " ARG: 0x%8.8X\n", MmioRead32 (SDHOST_ARG)));
- DEBUG ((DEBUG_MMCHOST_SD, " TOUT: 0x%8.8X\n", MmioRead32 (SDHOST_TOUT)));
- DEBUG ((DEBUG_MMCHOST_SD, " CDIV: 0x%8.8X\n", MmioRead32 (SDHOST_CDIV)));
- DEBUG ((DEBUG_MMCHOST_SD, " RSP0: 0x%8.8X\n", MmioRead32 (SDHOST_RSP0)));
- DEBUG ((DEBUG_MMCHOST_SD, " RSP1: 0x%8.8X\n", MmioRead32 (SDHOST_RSP1)));
- DEBUG ((DEBUG_MMCHOST_SD, " RSP2: 0x%8.8X\n", MmioRead32 (SDHOST_RSP2)));
- DEBUG ((DEBUG_MMCHOST_SD, " RSP3: 0x%8.8X\n", MmioRead32 (SDHOST_RSP3)));
- DEBUG ((DEBUG_MMCHOST_SD, " HSTS: 0x%8.8X\n", MmioRead32 (SDHOST_HSTS)));
- DEBUG ((DEBUG_MMCHOST_SD, " VDD: 0x%8.8X\n", MmioRead32 (SDHOST_VDD)));
- DEBUG ((DEBUG_MMCHOST_SD, " EDM: 0x%8.8X\n", MmioRead32 (SDHOST_EDM)));
- DEBUG ((DEBUG_MMCHOST_SD, " HCFG: 0x%8.8X\n", MmioRead32 (SDHOST_HCFG)));
- DEBUG ((DEBUG_MMCHOST_SD, " HBCT: 0x%8.8X\n", MmioRead32 (SDHOST_HBCT)));
- DEBUG ((DEBUG_MMCHOST_SD, " HBLC: 0x%8.8X\n\n", MmioRead32 (SDHOST_HBLC)));
-}
-
-#ifndef NDEBUG
-STATIC EFI_STATUS
-SdHostGetSdStatus (
- UINT32* SdStatus
- )
-{
- ASSERT (SdStatus != NULL);
-
- // On command completion with R1 or R1b response type
- // the SDCard status will be in RSP0
- UINT32 Rsp0 = MmioRead32 (SDHOST_RSP0);
- if (Rsp0 != 0xFFFFFFFF) {
- *SdStatus = Rsp0;
- return EFI_SUCCESS;
- }
-
- return EFI_NO_RESPONSE;
-}
-#endif /* NDEBUG */
-
-STATIC VOID
-SdHostDumpSdCardStatus (
- VOID
- )
-{
-#ifndef NDEBUG
- UINT32 SdCardStatus;
- EFI_STATUS Status = SdHostGetSdStatus (&SdCardStatus);
- if (!EFI_ERROR (Status)) {
- UINT32 CurrState = SDHOST_R0_CURRENTSTATE (SdCardStatus);
- DEBUG ((DEBUG_MMCHOST_SD,
- "SdHost: SdCardStatus 0x%8.8X: ReadyForData?%d, State[%d]: %a\n",
- SdCardStatus,
- ((SdCardStatus & SDHOST_R0_READY_FOR_DATA) ? 1 : 0),
- CurrState,
- ((CurrState < (sizeof (mStrSdState) / sizeof (*mStrSdState))) ?
- mStrSdState[CurrState] : "UNDEF")));
- }
-#endif /* NDEBUG */
-}
-
-STATIC VOID
-SdHostDumpStatus (
- VOID
- )
-{
- SdHostDumpRegisters ();
-
-#ifndef NDEBUG
- UINT32 Hsts = MmioRead32 (SDHOST_HSTS);
-
- if (Hsts & SDHOST_HSTS_ERROR) {
- DEBUG ((DEBUG_MMCHOST_SD_ERROR, "SdHost: Diagnose HSTS: 0x%8.8X\n", Hsts));
-
- DEBUG ((DEBUG_MMCHOST_SD_ERROR, "SdHost: Last Good CMD = %u\n", MMC_GET_INDX (mLastGoodCmd)));
- if (Hsts & SDHOST_HSTS_FIFO_ERROR)
- DEBUG ((DEBUG_MMCHOST_SD_ERROR, " - Fifo Error\n"));
- if (Hsts & SDHOST_HSTS_CRC7_ERROR)
- DEBUG ((DEBUG_MMCHOST_SD_ERROR, " - CRC7 Error\n"));
- if (Hsts & SDHOST_HSTS_CRC16_ERROR)
- DEBUG ((DEBUG_MMCHOST_SD_ERROR, " - CRC16 Error\n"));
- if (Hsts & SDHOST_HSTS_CMD_TIME_OUT)
- DEBUG ((DEBUG_MMCHOST_SD_ERROR, " - CMD Timeout (TOUT %x)\n", MmioRead32 (SDHOST_TOUT)));
- if (Hsts & SDHOST_HSTS_REW_TIME_OUT)
- DEBUG ((DEBUG_MMCHOST_SD_ERROR, " - Read/Erase/Write Transfer Timeout\n"));
- }
-
- UINT32 Edm = MmioRead32 (SDHOST_EDM);
- DEBUG (((Hsts & SDHOST_HSTS_ERROR) ? DEBUG_MMCHOST_SD_ERROR : DEBUG_MMCHOST_SD,
- "SdHost: Diagnose EDM: 0x%8.8X\n", Edm));
- DEBUG (((Hsts & SDHOST_HSTS_ERROR) ? DEBUG_MMCHOST_SD_ERROR : DEBUG_MMCHOST_SD,
- " - FSM: 0x%x (%a)\n", (Edm & 0xF), mFsmState[Edm & 0xF]));
- DEBUG (((Hsts & SDHOST_HSTS_ERROR) ? DEBUG_MMCHOST_SD_ERROR : DEBUG_MMCHOST_SD,
- " - Fifo Count: %d\n", ((Edm >> 4) & 0x1F)));
- DEBUG (((Hsts & SDHOST_HSTS_ERROR) ? DEBUG_MMCHOST_SD_ERROR : DEBUG_MMCHOST_SD,
- " - Fifo Write Threshold: %d\n",
- ((Edm >> SDHOST_EDM_WRITE_THRESHOLD_SHIFT) & SDHOST_EDM_THRESHOLD_MASK)));
- DEBUG (((Hsts & SDHOST_HSTS_ERROR) ? DEBUG_MMCHOST_SD_ERROR : DEBUG_MMCHOST_SD,
- " - Fifo Read Threshold: %d\n",
- ((Edm >> SDHOST_EDM_READ_THRESHOLD_SHIFT) & SDHOST_EDM_THRESHOLD_MASK)));
-#endif
-
- SdHostDumpSdCardStatus ();
-}
-
-STATIC EFI_STATUS
-SdHostSetClockFrequency (
- IN UINTN TargetSdFreqHz
- )
-{
- EFI_STATUS Status;
- UINT32 CoreClockFreqHz = 0;
-
- // First figure out the core clock
- Status = mFwProtocol->GetClockRate (RPI_MBOX_CLOCK_RATE_CORE, &CoreClockFreqHz);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- ASSERT (CoreClockFreqHz != 0);
-
- // fSDCLK = fcore_pclk/(ClockDiv+2)
- UINT32 ClockDiv = (CoreClockFreqHz - (2 * TargetSdFreqHz)) / TargetSdFreqHz;
- UINT32 ActualSdFreqHz = CoreClockFreqHz / (ClockDiv + 2);
-
- DEBUG ((DEBUG_MMCHOST_SD_INFO,
- "SdHost: CoreClock=%dHz, CDIV=%d, Requested SdClock=%dHz, Actual SdClock=%dHz\n",
- CoreClockFreqHz, ClockDiv, TargetSdFreqHz, ActualSdFreqHz));
-
- MmioWrite32 (SDHOST_CDIV, ClockDiv);
- // Set timeout after 1 second, i.e ActualSdFreqHz SD clock cycles
- MmioWrite32 (SDHOST_TOUT, ActualSdFreqHz);
-
- gBS->Stall (STALL_TO_STABILIZE_US);
-
- return Status;
-}
-
-STATIC BOOLEAN
-SdIsCardPresent (
- IN EFI_MMC_HOST_PROTOCOL *This
- )
-{
- return TRUE;
-}
-
-STATIC BOOLEAN
-SdIsReadOnly (
- IN EFI_MMC_HOST_PROTOCOL *This
- )
-{
- return FALSE;
-}
-
-STATIC EFI_STATUS
-SdBuildDevicePath (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN EFI_DEVICE_PATH_PROTOCOL **DevicePath
- )
-{
- EFI_DEVICE_PATH_PROTOCOL *NewDevicePathNode;
- EFI_GUID DevicePathGuid = EFI_CALLER_ID_GUID;
-
- DEBUG ((DEBUG_MMCHOST_SD, "SdHost: SdBuildDevicePath()\n"));
-
- NewDevicePathNode = CreateDeviceNode (HARDWARE_DEVICE_PATH, HW_VENDOR_DP, sizeof (VENDOR_DEVICE_PATH));
- CopyGuid (&((VENDOR_DEVICE_PATH*)NewDevicePathNode)->Guid, &DevicePathGuid);
- *DevicePath = NewDevicePathNode;
-
- return EFI_SUCCESS;
-}
-
-STATIC EFI_STATUS
-SdSendCommand (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN MMC_CMD MmcCmd,
- IN UINT32 Argument
- )
-{
- UINT32 Hsts;
-
- //
- // Fail fast, CMD5 (CMD_IO_SEND_OP_COND)
- // is only valid for SDIO cards and thus
- // expected to always fail.
- //
- if (MmcCmd == MMC_CMD5) {
- DEBUG ((DEBUG_MMCHOST_SD, "SdHost: SdSendCommand(CMD%d, Argument: %08x) ignored\n",
- MMC_GET_INDX (MmcCmd), Argument));
- return EFI_UNSUPPORTED;
- }
-
- if (MmioRead32 (SDHOST_CMD) & SDHOST_CMD_NEW_FLAG) {
- DEBUG ((DEBUG_MMCHOST_SD_ERROR,
- "SdHost: SdSendCommand(): Failed to execute CMD%d, a CMD is already being executed.\n",
- MMC_GET_INDX (MmcCmd)));
- SdHostDumpStatus ();
- return EFI_DEVICE_ERROR;
- }
-
- // Write command argument
- MmioWrite32 (SDHOST_ARG, Argument);
-
- UINT32 SdCmd = 0;
- {
- // Set response type
- if (MmcCmd & MMC_CMD_WAIT_RESPONSE) {
- if (MmcCmd & MMC_CMD_LONG_RESPONSE) {
- SdCmd |= SDHOST_CMD_RESPONSE_CMD_LONG_RESP;
- }
- } else {
- SdCmd |= SDHOST_CMD_RESPONSE_CMD_NO_RESP;
- }
-
- if (IsBusyCmd (MmcCmd)) {
- SdCmd |= SDHOST_CMD_BUSY_CMD;
- }
-
- if (IsReadCmd (MmcCmd, Argument)) {
- SdCmd |= SDHOST_CMD_READ_CMD;
- }
-
- if (IsWriteCmd (MmcCmd)) {
- SdCmd |= SDHOST_CMD_WRITE_CMD;
- }
-
- SdCmd |= MMC_GET_INDX (MmcCmd);
- }
-
- if (IsReadCmd (MmcCmd, Argument) || IsWriteCmd (MmcCmd)) {
- if (IsAppCmd () && MmcCmd == MMC_ACMD22) {
- MmioWrite32 (SDHOST_HBCT, 0x4);
- } else if (IsAppCmd () && MmcCmd == MMC_ACMD51) {
- MmioWrite32 (SDHOST_HBCT, 0x8);
- } else if (!IsAppCmd () && MmcCmd == MMC_CMD6) {
- MmioWrite32 (SDHOST_HBCT, 0x40);
- } else {
- MmioWrite32 (SDHOST_HBCT, SDHOST_BLOCK_BYTE_LENGTH);
- }
- }
-
- DEBUG ((DEBUG_MMCHOST_SD,
- "SdHost: SdSendCommand(CMD%d, Argument: %08x): BUSY=%d, RESP=%d, WRITE=%d, READ=%d\n",
- MMC_GET_INDX (MmcCmd), Argument, ((SdCmd & SDHOST_CMD_BUSY_CMD) ? 1 : 0),
- ((SdCmd & (SDHOST_CMD_RESPONSE_CMD_LONG_RESP | SDHOST_CMD_RESPONSE_CMD_NO_RESP)) >> 9),
- ((SdCmd & SDHOST_CMD_WRITE_CMD) ? 1 : 0), ((SdCmd & SDHOST_CMD_READ_CMD) ? 1 : 0)));
-
- UINT32 PollCount = 0;
- UINT32 RetryCount = 0;
- BOOLEAN IsCmdExecuted = FALSE;
- EFI_STATUS Status = EFI_SUCCESS;
-
- // Keep retrying the command until it succeeds.
- while ((RetryCount < CMD_MAX_RETRY_COUNT) && !IsCmdExecuted) {
- Status = EFI_SUCCESS;
-
- // Clear prev cmd status
- MmioWrite32 (SDHOST_HSTS, SDHOST_HSTS_CLEAR);
-
- if (IsReadCmd (MmcCmd, Argument) || IsWriteCmd (MmcCmd)) {
- // Flush Fifo if this cmd will start a new transfer in case
- // there is stale bytes in the Fifo
- MmioOr32 (SDHOST_EDM, SDHOST_EDM_FIFO_CLEAR);
- }
-
- if (MmioRead32 (SDHOST_CMD) & SDHOST_CMD_NEW_FLAG) {
- DEBUG ((DEBUG_MMCHOST_SD_ERROR,
- "%a(%u): CMD%d is still being executed after %d trial(s)\n",
- __FUNCTION__, __LINE__, MMC_GET_INDX (MmcCmd), RetryCount));
- }
-
- // Write command and set it to start execution
- MmioWrite32 (SDHOST_CMD, SDHOST_CMD_NEW_FLAG | SdCmd);
-
- // Poll for the command status until it finishes execution
- while (PollCount < CMD_MAX_POLL_COUNT) {
- UINT32 CmdReg = MmioRead32 (SDHOST_CMD);
-
- // Read status of command response
- if (CmdReg & SDHOST_CMD_FAIL_FLAG) {
- Status = EFI_DEVICE_ERROR;
- /*
- * Must fall-through and wait for the command completion!
- */
- }
-
- // Check if command is completed.
- if (!(CmdReg & SDHOST_CMD_NEW_FLAG)) {
- IsCmdExecuted = TRUE;
- break;
- }
-
- ++PollCount;
- gBS->Stall (CMD_STALL_AFTER_POLL_US);
- }
-
- if (!IsCmdExecuted) {
- ++RetryCount;
- gBS->Stall (CMD_STALL_AFTER_RETRY_US);
- }
- }
-
- if (RetryCount == CMD_MAX_RETRY_COUNT) {
- Status = EFI_TIMEOUT;
- }
-
- Hsts = MmioRead32 (SDHOST_HSTS);
- if (EFI_ERROR (Status) ||
- (Hsts & SDHOST_HSTS_ERROR) != 0) {
- if (MmcCmd == MMC_CMD1 && (Hsts & SDHOST_HSTS_CRC7_ERROR) != 0) {
- /*
- * SdHost seems to have no way to specify
- * R3 as a transfer type.
- */
- IsCmdExecuted = TRUE;
- Status = EFI_SUCCESS;
- MmioWrite32 (SDHOST_HSTS, SDHOST_HSTS_CLEAR);
- } else if (MmcCmd == MMC_CMD7 && Argument == 0) {
- /*
- * Deselecting the SDCard with CMD7 and RCA=0x0
- * always timeout on SDHost.
- */
- Status = EFI_SUCCESS;
- } else {
- DEBUG ((DEBUG_MMCHOST_SD_ERROR, "%a(%u): CMD%d execution failed after %d trial(s)\n",
- __FUNCTION__, __LINE__, MMC_GET_INDX (MmcCmd), RetryCount));
- SdHostDumpStatus ();
- }
-
- MmioWrite32 (SDHOST_HSTS, SDHOST_HSTS_CLEAR);
- }
-
- if (IsCmdExecuted && !EFI_ERROR (Status)) {
- ASSERT (!(MmioRead32 (SDHOST_HSTS) & SDHOST_HSTS_ERROR));
- mLastGoodCmd = MmcCmd;
- }
-
- return Status;
-}
-
-STATIC EFI_STATUS
-SdReceiveResponse (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN MMC_RESPONSE_TYPE Type,
- IN UINT32* Buffer
- )
-{
- if (Buffer == NULL) {
- DEBUG ((DEBUG_MMCHOST_SD_ERROR, "SdHost: SdReceiveResponse(): Input Buffer is NULL\n"));
- return EFI_INVALID_PARAMETER;
- }
-
- if ((Type == MMC_RESPONSE_TYPE_R1) ||
- (Type == MMC_RESPONSE_TYPE_R1b) ||
- (Type == MMC_RESPONSE_TYPE_R3) ||
- (Type == MMC_RESPONSE_TYPE_R6) ||
- (Type == MMC_RESPONSE_TYPE_R7)) {
- Buffer[0] = MmioRead32 (SDHOST_RSP0);
- DEBUG ((DEBUG_MMCHOST_SD, "SdHost: SdReceiveResponse(Type: %x), Buffer[0]: %08x\n",
- Type, Buffer[0]));
-
- } else if (Type == MMC_RESPONSE_TYPE_R2) {
- Buffer[0] = MmioRead32 (SDHOST_RSP0);
- Buffer[1] = MmioRead32 (SDHOST_RSP1);
- Buffer[2] = MmioRead32 (SDHOST_RSP2);
- Buffer[3] = MmioRead32 (SDHOST_RSP3);
-
- DEBUG ((DEBUG_MMCHOST_SD,
- "SdHost: SdReceiveResponse(Type: %x), Buffer[0-3]: %08x, %08x, %08x, %08x\n",
- Type, Buffer[0], Buffer[1], Buffer[2], Buffer[3]));
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC EFI_STATUS
-SdReadBlockData (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN EFI_LBA Lba,
- IN UINTN Length,
- IN UINT32* Buffer
- )
-{
- DEBUG ((DEBUG_MMCHOST_SD, "SdHost: SdReadBlockData(LBA: 0x%x, Length: 0x%x, Buffer: 0x%x)\n",
- (UINT32)Lba, Length, Buffer));
-
- ASSERT (Buffer != NULL);
- ASSERT (Length % 4 == 0);
-
- EFI_STATUS Status = EFI_SUCCESS;
-
- mFwProtocol->SetLed (TRUE);
- {
- UINT32 NumWords = Length / 4;
- UINT32 WordIdx;
-
- for (WordIdx = 0; WordIdx < NumWords; ++WordIdx) {
- UINT32 PollCount = 0;
- while (PollCount < FIFO_MAX_POLL_COUNT) {
- UINT32 Hsts = MmioRead32 (SDHOST_HSTS);
- if ((Hsts & SDHOST_HSTS_DATA_FLAG) != 0) {
- MmioWrite32 (SDHOST_HSTS, SDHOST_HSTS_DATA_FLAG);
- Buffer[WordIdx] = MmioRead32 (SDHOST_DATA);
- break;
- }
-
- ++PollCount;
- gBS->Stall (CMD_STALL_AFTER_RETRY_US);
- }
-
- if (PollCount == FIFO_MAX_POLL_COUNT) {
- DEBUG ((DEBUG_MMCHOST_SD_ERROR,
- "SdHost: SdReadBlockData(): Block Word%d read poll timed-out\n", WordIdx));
- SdHostDumpStatus ();
- MmioWrite32 (SDHOST_HSTS, SDHOST_HSTS_CLEAR);
- Status = EFI_TIMEOUT;
- break;
- }
- }
- }
- mFwProtocol->SetLed (FALSE);
-
- return Status;
-}
-
-STATIC EFI_STATUS
-SdWriteBlockData (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN EFI_LBA Lba,
- IN UINTN Length,
- IN UINT32* Buffer
- )
-{
- DEBUG ((DEBUG_MMCHOST_SD,
- "SdHost: SdWriteBlockData(LBA: 0x%x, Length: 0x%x, Buffer: 0x%x)\n",
- (UINT32)Lba, Length, Buffer));
-
- ASSERT (Buffer != NULL);
- ASSERT (Length % SDHOST_BLOCK_BYTE_LENGTH == 0);
-
- EFI_STATUS Status = EFI_SUCCESS;
-
- mFwProtocol->SetLed (TRUE);
- {
- UINT32 NumWords = Length / 4;
- UINT32 WordIdx;
-
- for (WordIdx = 0; WordIdx < NumWords; ++WordIdx) {
- UINT32 PollCount = 0;
- while (PollCount < FIFO_MAX_POLL_COUNT) {
- if (MmioRead32 (SDHOST_HSTS) & SDHOST_HSTS_DATA_FLAG) {
- MmioWrite32 (SDHOST_HSTS, SDHOST_HSTS_DATA_FLAG);
- MmioWrite32 (SDHOST_DATA, Buffer[WordIdx]);
- break;
- }
-
- ++PollCount;
- gBS->Stall (CMD_STALL_AFTER_RETRY_US);
- }
-
- if (PollCount == FIFO_MAX_POLL_COUNT) {
- DEBUG ((DEBUG_MMCHOST_SD_ERROR,
- "SdHost: SdWriteBlockData(): Block Word%d write poll timed-out\n", WordIdx));
- SdHostDumpStatus ();
- MmioWrite32 (SDHOST_HSTS, SDHOST_HSTS_CLEAR);
- Status = EFI_TIMEOUT;
- break;
- }
- }
- }
- mFwProtocol->SetLed (FALSE);
-
- return Status;
-}
-
-STATIC EFI_STATUS
-SdSetIos (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN UINT32 BusClockFreq,
- IN UINT32 BusWidth,
- IN UINT32 TimingMode
- )
-{
- if (BusWidth != 0) {
- UINT32 Hcfg = MmioRead32 (SDHOST_HCFG);
-
- DEBUG ((DEBUG_MMCHOST_SD_INFO, "Setting BusWidth %u\n", BusWidth));
- if (BusWidth == 4) {
- Hcfg |= SDHOST_HCFG_WIDE_EXT_BUS;
- } else {
- Hcfg &= ~SDHOST_HCFG_WIDE_EXT_BUS;
- }
-
- Hcfg |= SDHOST_HCFG_WIDE_INT_BUS | SDHOST_HCFG_SLOW_CARD;
- MmioWrite32 (SDHOST_HCFG, Hcfg);
- }
-
- if (BusClockFreq != 0) {
- DEBUG ((DEBUG_MMCHOST_SD_INFO, "Setting Freq %u Hz\n", BusClockFreq));
- SdHostSetClockFrequency (BusClockFreq);
- }
-
- return EFI_SUCCESS;
-}
-
-STATIC EFI_STATUS
-SdNotifyState (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN MMC_STATE State
- )
-{
- DEBUG ((DEBUG_MMCHOST_SD, "SdHost: SdNotifyState(State: %d) ", State));
-
- switch (State) {
- case MmcHwInitializationState:
- DEBUG ((DEBUG_MMCHOST_SD, "MmcHwInitializationState\n", State));
-
- // Turn-off SD Card power
- MmioWrite32 (SDHOST_VDD, 0);
-
- // Reset command and arg
- MmioWrite32 (SDHOST_CMD, 0);
- MmioWrite32 (SDHOST_ARG, 0);
- // Reset clock divider
- MmioWrite32 (SDHOST_CDIV, 0);
- // Default timeout
- MmioWrite32 (SDHOST_TOUT, 0xffffffff);
- // Clear status flags
- MmioWrite32 (SDHOST_HSTS, SDHOST_HSTS_CLEAR);;
- // Reset controller configs
- MmioWrite32 (SDHOST_HCFG, 0);
- MmioWrite32 (SDHOST_HBCT, 0);
- MmioWrite32 (SDHOST_HBLC, 0);
-
- gBS->Stall (STALL_TO_STABILIZE_US);
-
- // Turn-on SD Card power
- MmioWrite32 (SDHOST_VDD, 1);
-
- gBS->Stall (STALL_TO_STABILIZE_US);
-
- // Write controller configs
- UINT32 Hcfg = 0;
- Hcfg |= SDHOST_HCFG_WIDE_INT_BUS;
- Hcfg |= SDHOST_HCFG_SLOW_CARD; // Use all bits of CDIV in DataMode
- MmioWrite32 (SDHOST_HCFG, Hcfg);
-
- // Set default clock frequency
- EFI_STATUS Status = SdHostSetClockFrequency (IDENT_MODE_SD_CLOCK_FREQ_HZ);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_MMCHOST_SD_ERROR,
- "SdHost: SdNotifyState(): Fail to initialize SD clock to %dHz\n",
- IDENT_MODE_SD_CLOCK_FREQ_HZ));
- SdHostDumpStatus ();
- return Status;
- }
- break;
- case MmcIdleState:
- DEBUG ((DEBUG_MMCHOST_SD, "MmcIdleState\n", State));
- break;
- case MmcReadyState:
- DEBUG ((DEBUG_MMCHOST_SD, "MmcReadyState\n", State));
- break;
- case MmcIdentificationState:
- DEBUG ((DEBUG_MMCHOST_SD, "MmcIdentificationState\n", State));
- break;
- case MmcStandByState:
- DEBUG ((DEBUG_MMCHOST_SD, "MmcStandByState\n", State));
- break;
- case MmcTransferState:
- DEBUG ((DEBUG_MMCHOST_SD, "MmcTransferState\n", State));
- break;
- break;
- case MmcSendingDataState:
- DEBUG ((DEBUG_MMCHOST_SD, "MmcSendingDataState\n", State));
- break;
- case MmcReceiveDataState:
- DEBUG ((DEBUG_MMCHOST_SD, "MmcReceiveDataState\n", State));
- break;
- case MmcProgrammingState:
- DEBUG ((DEBUG_MMCHOST_SD, "MmcProgrammingState\n", State));
- break;
- case MmcDisconnectState:
- case MmcInvalidState:
- default:
- DEBUG ((DEBUG_MMCHOST_SD_ERROR, "SdHost: SdNotifyState(): Invalid State: %d\n", State));
- ASSERT (0);
- }
-
- return EFI_SUCCESS;
-}
-
-BOOLEAN
-SdIsMultiBlock (
- IN EFI_MMC_HOST_PROTOCOL *This
- )
-{
- return TRUE;
-}
-
-EFI_MMC_HOST_PROTOCOL gMmcHost =
- {
- MMC_HOST_PROTOCOL_REVISION,
- SdIsCardPresent,
- SdIsReadOnly,
- SdBuildDevicePath,
- SdNotifyState,
- SdSendCommand,
- SdReceiveResponse,
- SdReadBlockData,
- SdWriteBlockData,
- SdSetIos,
- SdIsMultiBlock
- };
-
-EFI_STATUS
-SdHostInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE Handle = NULL;
-
- if (PcdGet32 (PcdSdIsArasan)) {
- DEBUG ((DEBUG_INFO, "SD is not routed to SdHost\n"));
- return EFI_REQUEST_UNLOAD_IMAGE;
- }
-
- Status = gBS->LocateProtocol (&gRaspberryPiFirmwareProtocolGuid, NULL, (VOID**)&mFwProtocol);
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- DEBUG ((DEBUG_MMCHOST_SD, "SdHost: Initialize\n"));
- DEBUG ((DEBUG_MMCHOST_SD, "Config:\n"));
- DEBUG ((DEBUG_MMCHOST_SD, " - FIFO_MAX_POLL_COUNT=%d\n", FIFO_MAX_POLL_COUNT));
- DEBUG ((DEBUG_MMCHOST_SD, " - CMD_STALL_AFTER_POLL_US=%dus\n", CMD_STALL_AFTER_POLL_US));
- DEBUG ((DEBUG_MMCHOST_SD, " - CMD_MIN_POLL_TOTAL_TIME_US=%dms\n", CMD_MIN_POLL_TOTAL_TIME_US / 1000));
- DEBUG ((DEBUG_MMCHOST_SD, " - CMD_MAX_POLL_COUNT=%d\n", CMD_MAX_POLL_COUNT));
- DEBUG ((DEBUG_MMCHOST_SD, " - CMD_MAX_RETRY_COUNT=%d\n", CMD_MAX_RETRY_COUNT));
- DEBUG ((DEBUG_MMCHOST_SD, " - CMD_STALL_AFTER_RETRY_US=%dus\n", CMD_STALL_AFTER_RETRY_US));
-
- Status = gBS->InstallMultipleProtocolInterfaces (
- &Handle,
- &gRaspberryPiMmcHostProtocolGuid,
- &gMmcHost,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
- return Status;
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/SdHostDxe/SdHostDxe.inf b/Platform/RaspberryPi/RPi3/Drivers/SdHostDxe/SdHostDxe.inf
deleted file mode 100644
index 4a950dc0..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/SdHostDxe/SdHostDxe.inf
+++ /dev/null
@@ -1,49 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2017, Andrei Warkentin <andrey.warkentin@gmail.com>
-# Copyright (c) Microsoft Corporation. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x0001001A
- BASE_NAME = SdHost
- FILE_GUID = 58ABD787-F64D-4CA2-A034-B9AC2D5AD0CF
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
-
- ENTRY_POINT = SdHostInitialize
-
-
-[Sources.common]
- SdHostDxe.c
-
-[Packages]
- ArmPkg/ArmPkg.dec
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- Silicon/Broadcom/Bcm283x/Bcm283x.dec
- Platform/RaspberryPi/RPi3/RPi3.dec
-
-[LibraryClasses]
- PcdLib
- UefiLib
- UefiDriverEntryPoint
- MemoryAllocationLib
- IoLib
- DmaLib
- CacheMaintenanceLib
-
-[Guids]
-
-[Protocols]
- gRaspberryPiMmcHostProtocolGuid ## PRODUCES
- gRaspberryPiFirmwareProtocolGuid ## CONSUMES
-
-[Pcd]
- gRaspberryPiTokenSpaceGuid.PcdSdIsArasan
-
-[Depex]
- gRaspberryPiFirmwareProtocolGuid AND gRaspberryPiConfigAppliedProtocolGuid
diff --git a/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/FileIo.c b/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/FileIo.c
deleted file mode 100644
index 3bcd7942..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/FileIo.c
+++ /dev/null
@@ -1,190 +0,0 @@
-/** @file
- *
- * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2007-2009, Intel Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include "VarBlockService.h"
-
-
-EFI_STATUS
-FileWrite (
- IN EFI_FILE_PROTOCOL *File,
- IN UINTN Offset,
- IN UINTN Buffer,
- IN UINTN Size
- )
-{
- EFI_STATUS Status;
-
- Status = File->SetPosition (File, Offset);
- ASSERT_EFI_ERROR (Status);
- if (!EFI_ERROR (Status)) {
- Status = File->Write (File, &Size, (VOID*)Buffer);
- ASSERT_EFI_ERROR (Status);
- }
- return Status;
-}
-
-
-VOID
-FileClose (
- IN EFI_FILE_PROTOCOL *File
- )
-{
- File->Flush (File);
- File->Close (File);
-}
-
-
-EFI_STATUS
-FileOpen (
- IN EFI_DEVICE_PATH_PROTOCOL *Device,
- IN CHAR16 *MappedFile,
- OUT EFI_FILE_PROTOCOL **File,
- IN UINT64 OpenMode
- )
-{
- EFI_HANDLE Handle;
- EFI_FILE_HANDLE Root;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Volume;
- EFI_STATUS Status;
-
- *File = NULL;
-
- Status = gBS->LocateDevicePath (
- &gEfiSimpleFileSystemProtocolGuid,
- &Device,
- &Handle
- );
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = gBS->HandleProtocol (
- Handle,
- &gEfiSimpleFileSystemProtocolGuid,
- (VOID**)&Volume
- );
- ASSERT_EFI_ERROR (Status);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Open the root directory of the volume
- //
- Root = NULL;
- Status = Volume->OpenVolume (
- Volume,
- &Root
- );
- ASSERT_EFI_ERROR (Status);
- ASSERT (Root != NULL);
-
- //
- // Open file
- //
- Status = Root->Open (
- Root,
- File,
- MappedFile,
- OpenMode,
- 0
- );
- if (EFI_ERROR (Status)) {
- *File = NULL;
- }
-
- //
- // Close the Root directory
- //
- Root->Close (Root);
- return Status;
-}
-
-
-EFI_STATUS
-CheckStore (
- IN EFI_HANDLE SimpleFileSystemHandle,
- OUT EFI_DEVICE_PATH_PROTOCOL **Device
- )
-{
- EFI_STATUS Status;
- EFI_BLOCK_IO_PROTOCOL *BlkIo;
- EFI_FILE_PROTOCOL *File;
-
- *Device = NULL;
- Status = gBS->HandleProtocol (
- SimpleFileSystemHandle,
- &gEfiBlockIoProtocolGuid,
- (VOID*)&BlkIo
- );
-
- if (EFI_ERROR (Status)) {
- goto ErrHandle;
- }
- if (!BlkIo->Media->MediaPresent) {
- DEBUG ((DEBUG_ERROR, "FwhMappedFile: Media not present!\n"));
- Status = EFI_NO_MEDIA;
- goto ErrHandle;
- }
- if (BlkIo->Media->ReadOnly) {
- DEBUG ((DEBUG_ERROR, "FwhMappedFile: Media is read-only!\n"));
- Status = EFI_ACCESS_DENIED;
- goto ErrHandle;
- }
-
- Status = FileOpen (DevicePathFromHandle (SimpleFileSystemHandle),
- mFvInstance->MappedFile, &File,
- EFI_FILE_MODE_READ);
- if (EFI_ERROR (Status)) {
- goto ErrHandle;
- }
-
- /* We found it! Maybe do more checks...? */
-
- FileClose (File);
- *Device = DuplicateDevicePath (DevicePathFromHandle (SimpleFileSystemHandle));
-
- ASSERT (*Device != NULL);
-
-ErrHandle:
- return Status;
-}
-
-
-EFI_STATUS
-CheckStoreExists (
- IN EFI_DEVICE_PATH_PROTOCOL *Device
- )
-{
- EFI_HANDLE Handle;
- EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Volume;
- EFI_STATUS Status;
-
- Status = gBS->LocateDevicePath (
- &gEfiSimpleFileSystemProtocolGuid,
- &Device,
- &Handle
- );
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = gBS->HandleProtocol (
- Handle,
- &gEfiSimpleFileSystemProtocolGuid,
- (VOID**)&Volume
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- return EFI_SUCCESS;
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/FvbInfo.c b/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/FvbInfo.c
deleted file mode 100644
index 0e0c108d..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/FvbInfo.c
+++ /dev/null
@@ -1,109 +0,0 @@
-/** @file
- *
- * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2006-2014, Intel Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <Pi/PiFirmwareVolume.h>
-#include <Guid/SystemNvDataGuid.h>
-#include <Library/BaseLib.h>
-#include <Library/PcdLib.h>
-
-typedef struct {
- UINT64 FvLength;
- EFI_FIRMWARE_VOLUME_HEADER FvbInfo;
- EFI_FV_BLOCK_MAP_ENTRY End[1];
-} EFI_FVB_MEDIA_INFO;
-
-EFI_FVB_MEDIA_INFO mPlatformFvbMediaInfo[] = {
- //
- // System NvStorage FVB
- //
- {
- FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
- FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
- FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
- FixedPcdGet32 (PcdNvStorageEventLogSize),
- {
- {
- 0,
- }, // ZeroVector[16]
- EFI_SYSTEM_NV_DATA_FV_GUID,
- FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
- FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
- FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
- FixedPcdGet32 (PcdNvStorageEventLogSize),
- EFI_FVH_SIGNATURE,
- EFI_FVB2_MEMORY_MAPPED |
- EFI_FVB2_READ_ENABLED_CAP |
- EFI_FVB2_READ_STATUS |
- EFI_FVB2_WRITE_ENABLED_CAP |
- EFI_FVB2_WRITE_STATUS |
- EFI_FVB2_ERASE_POLARITY |
- EFI_FVB2_ALIGNMENT_16,
- sizeof (EFI_FIRMWARE_VOLUME_HEADER) + sizeof (EFI_FV_BLOCK_MAP_ENTRY),
- 0, // CheckSum
- 0, // ExtHeaderOffset
- {
- 0,
- }, // Reserved[1]
- 2, // Revision
- {
- {
- (FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
- FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
- FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
- FixedPcdGet32 (PcdNvStorageEventLogSize)) /
- FixedPcdGet32 (PcdFirmwareBlockSize),
- FixedPcdGet32 (PcdFirmwareBlockSize),
- }
- } // BlockMap[1]
- },
- {
- {
- 0,
- 0
- }
- } // End[1]
- }
-};
-
-
-EFI_STATUS
-GetFvbInfo (
- IN UINT64 FvLength,
- OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
- )
-{
- STATIC BOOLEAN Checksummed = FALSE;
- UINTN Index;
-
- if (!Checksummed) {
- for (Index = 0;
- Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO);
- Index += 1) {
- UINT16 Checksum;
- mPlatformFvbMediaInfo[Index].FvbInfo.Checksum = 0;
- Checksum = CalculateCheckSum16 (
- (UINT16*)&mPlatformFvbMediaInfo[Index].FvbInfo,
- mPlatformFvbMediaInfo[Index].FvbInfo.HeaderLength
- );
- mPlatformFvbMediaInfo[Index].FvbInfo.Checksum = Checksum;
- }
- Checksummed = TRUE;
- }
-
- for (Index = 0;
- Index < sizeof (mPlatformFvbMediaInfo) / sizeof (EFI_FVB_MEDIA_INFO);
- Index += 1) {
- if (mPlatformFvbMediaInfo[Index].FvLength == FvLength) {
- *FvbInfo = &mPlatformFvbMediaInfo[Index].FvbInfo;
- return EFI_SUCCESS;
- }
- }
-
- return EFI_NOT_FOUND;
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockService.c b/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockService.c
deleted file mode 100644
index 57230943..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockService.c
+++ /dev/null
@@ -1,965 +0,0 @@
-/** @file
- *
- * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2006-2014, Intel Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <Protocol/DevicePath.h>
-#include <Protocol/FirmwareVolumeBlock.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/DxeServicesTableLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-
-#include "VarBlockService.h"
-
-#define EFI_FVB2_STATUS \
- (EFI_FVB2_READ_STATUS | EFI_FVB2_WRITE_STATUS | EFI_FVB2_LOCK_STATUS)
-
-EFI_FW_VOL_INSTANCE *mFvInstance;
-
-FV_MEMMAP_DEVICE_PATH mFvMemmapDevicePathTemplate = {
- {
- {
- HARDWARE_DEVICE_PATH,
- HW_MEMMAP_DP,
- {
- (UINT8)(sizeof (MEMMAP_DEVICE_PATH)),
- (UINT8)(sizeof (MEMMAP_DEVICE_PATH) >> 8)
- }
- },
- EfiMemoryMappedIO,
- (EFI_PHYSICAL_ADDRESS)0,
- (EFI_PHYSICAL_ADDRESS)0,
- },
- {
- END_DEVICE_PATH_TYPE,
- END_ENTIRE_DEVICE_PATH_SUBTYPE,
- {
- END_DEVICE_PATH_LENGTH,
- 0
- }
- }
-};
-
-FV_PIWG_DEVICE_PATH mFvPIWGDevicePathTemplate = {
- {
- {
- MEDIA_DEVICE_PATH,
- MEDIA_PIWG_FW_VOL_DP,
- {
- (UINT8)(sizeof (MEDIA_FW_VOL_DEVICE_PATH)),
- (UINT8)(sizeof (MEDIA_FW_VOL_DEVICE_PATH) >> 8)
- }
- },
- { 0 }
- },
- {
- END_DEVICE_PATH_TYPE,
- END_ENTIRE_DEVICE_PATH_SUBTYPE,
- {
- END_DEVICE_PATH_LENGTH,
- 0
- }
- }
-};
-
-EFI_FW_VOL_BLOCK_DEVICE mFvbDeviceTemplate = {
- NULL,
- {
- FvbProtocolGetAttributes,
- FvbProtocolSetAttributes,
- FvbProtocolGetPhysicalAddress,
- FvbProtocolGetBlockSize,
- FvbProtocolRead,
- FvbProtocolWrite,
- FvbProtocolEraseBlocks,
- NULL
- }
-};
-
-
-EFI_STATUS
-VarStoreWrite (
- IN UINTN Address,
- IN OUT UINTN *NumBytes,
- IN UINT8 *Buffer
- )
-{
- CopyMem ((VOID*)Address, Buffer, *NumBytes);
- mFvInstance->Dirty = TRUE;
-
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-VarStoreErase (
- IN UINTN Address,
- IN UINTN LbaLength
- )
-{
- SetMem ((VOID*)Address, LbaLength, 0xff);
- mFvInstance->Dirty = TRUE;
-
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-FvbGetVolumeAttributes (
- OUT EFI_FVB_ATTRIBUTES_2 *Attributes
- )
-{
- *Attributes = mFvInstance->VolumeHeader->Attributes;
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-FvbGetLbaAddress (
- IN EFI_LBA Lba,
- OUT UINTN *LbaAddress,
- OUT UINTN *LbaLength,
- OUT UINTN *NumOfBlocks
- )
-/*++
-
- Routine Description:
- Retrieves the starting address of an LBA in an FV
-
- Arguments:
- Lba - The logical block address
- LbaAddress - On output, contains the physical starting address
- of the Lba
- LbaLength - On output, contains the length of the block
- NumOfBlocks - A pointer to a caller allocated UINTN in which the
- number of consecutive blocks starting with Lba is
- returned. All blocks in this range have a size of
- BlockSize
-
- Returns:
- EFI_SUCCESS
- EFI_INVALID_PARAMETER
-
---*/
-{
- UINT32 NumBlocks;
- UINT32 BlockLength;
- UINTN Offset;
- EFI_LBA StartLba;
- EFI_LBA NextLba;
- EFI_FV_BLOCK_MAP_ENTRY *BlockMap;
-
- StartLba = 0;
- Offset = 0;
- BlockMap = &(mFvInstance->VolumeHeader->BlockMap[0]);
-
- //
- // Parse the blockmap of the FV to find which map entry the Lba belongs to.
- //
- while (TRUE) {
- NumBlocks = BlockMap->NumBlocks;
- BlockLength = BlockMap->Length;
-
- if (NumBlocks == 0 || BlockLength == 0) {
- return EFI_INVALID_PARAMETER;
- }
-
- NextLba = StartLba + NumBlocks;
-
- //
- // The map entry found.
- //
- if (Lba >= StartLba && Lba < NextLba) {
- Offset = Offset + (UINTN)MultU64x32 ((Lba - StartLba), BlockLength);
- if (LbaAddress != NULL) {
- *LbaAddress = mFvInstance->FvBase + Offset;
- }
-
- if (LbaLength != NULL) {
- *LbaLength = BlockLength;
- }
-
- if (NumOfBlocks != NULL) {
- *NumOfBlocks = (UINTN)(NextLba - Lba);
- }
-
- return EFI_SUCCESS;
- }
-
- StartLba = NextLba;
- Offset = Offset + NumBlocks * BlockLength;
- BlockMap++;
- }
-}
-
-
-EFI_STATUS
-FvbEraseBlock (
- IN EFI_LBA Lba
- )
-/*++
-
-Routine Description:
- Erases and initializes a firmware volume block
-
-Arguments:
- Lba - The logical block index to be erased
-
-Returns:
- EFI_SUCCESS - The erase request was successfully completed
- EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state
- EFI_DEVICE_ERROR - The block device is not functioning correctly and
- could not be written. Firmware device may have been
- partially erased
- EFI_INVALID_PARAMETER
-
---*/
-{
- EFI_FVB_ATTRIBUTES_2 Attributes;
- UINTN LbaAddress;
- UINTN LbaLength;
- EFI_STATUS Status;
-
- //
- // Check if the FV is write enabled
- //
- FvbGetVolumeAttributes (&Attributes);
-
- if ((Attributes & EFI_FVB2_WRITE_STATUS) == 0) {
- return EFI_ACCESS_DENIED;
- }
- //
- // Get the starting address of the block for erase. For debug reasons,
- // LbaWriteAddress may not be the same as LbaAddress.
- //
- Status = FvbGetLbaAddress (Lba, &LbaAddress, &LbaLength, NULL);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- return VarStoreErase (
- LbaAddress,
- LbaLength
- );
-}
-
-
-EFI_STATUS
-FvbSetVolumeAttributes (
- IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
- )
-/*++
-
- Routine Description:
- Modifies the current settings of the firmware volume according to the
- input parameter, and returns the new setting of the volume
-
- Arguments:
- Attributes - On input, it is a pointer to EFI_FVB_ATTRIBUTES_2
- containing the desired firmware volume settings.
- On successful return, it contains the new setting.
-
- Returns:
- EFI_SUCCESS - Successfully returns
- EFI_ACCESS_DENIED - The volume setting is locked and cannot be modified
- EFI_INVALID_PARAMETER
-
---*/
-{
- EFI_FVB_ATTRIBUTES_2 OldAttributes;
- EFI_FVB_ATTRIBUTES_2 *AttribPtr;
- UINT32 Capabilities;
- UINT32 OldStatus;
- UINT32 NewStatus;
- EFI_FVB_ATTRIBUTES_2 UnchangedAttributes;
-
- AttribPtr =
- (EFI_FVB_ATTRIBUTES_2*) &(mFvInstance->VolumeHeader->Attributes);
- OldAttributes = *AttribPtr;
- Capabilities = OldAttributes & (EFI_FVB2_READ_DISABLED_CAP | \
- EFI_FVB2_READ_ENABLED_CAP | \
- EFI_FVB2_WRITE_DISABLED_CAP | \
- EFI_FVB2_WRITE_ENABLED_CAP | \
- EFI_FVB2_LOCK_CAP \
- );
- OldStatus = OldAttributes & EFI_FVB2_STATUS;
- NewStatus = *Attributes & EFI_FVB2_STATUS;
-
- UnchangedAttributes = EFI_FVB2_READ_DISABLED_CAP | \
- EFI_FVB2_READ_ENABLED_CAP | \
- EFI_FVB2_WRITE_DISABLED_CAP | \
- EFI_FVB2_WRITE_ENABLED_CAP | \
- EFI_FVB2_LOCK_CAP | \
- EFI_FVB2_STICKY_WRITE | \
- EFI_FVB2_MEMORY_MAPPED | \
- EFI_FVB2_ERASE_POLARITY | \
- EFI_FVB2_READ_LOCK_CAP | \
- EFI_FVB2_WRITE_LOCK_CAP | \
- EFI_FVB2_ALIGNMENT;
-
- //
- // Some attributes of FV is read only can *not* be set.
- //
- if ((OldAttributes & UnchangedAttributes) ^ (*Attributes & UnchangedAttributes)) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // If firmware volume is locked, no status bit can be updated.
- //
- if (OldAttributes & EFI_FVB2_LOCK_STATUS) {
- if (OldStatus ^ NewStatus) {
- return EFI_ACCESS_DENIED;
- }
- }
-
- //
- // Test read disable.
- //
- if ((Capabilities & EFI_FVB2_READ_DISABLED_CAP) == 0) {
- if ((NewStatus & EFI_FVB2_READ_STATUS) == 0) {
- return EFI_INVALID_PARAMETER;
- }
- }
-
- //
- // Test read enable.
- //
- if ((Capabilities & EFI_FVB2_READ_ENABLED_CAP) == 0) {
- if (NewStatus & EFI_FVB2_READ_STATUS) {
- return EFI_INVALID_PARAMETER;
- }
- }
-
- //
- // Test write disable.
- //
- if ((Capabilities & EFI_FVB2_WRITE_DISABLED_CAP) == 0) {
- if ((NewStatus & EFI_FVB2_WRITE_STATUS) == 0) {
- return EFI_INVALID_PARAMETER;
- }
- }
-
- //
- // Test write enable.
- //
- if ((Capabilities & EFI_FVB2_WRITE_ENABLED_CAP) == 0) {
- if (NewStatus & EFI_FVB2_WRITE_STATUS) {
- return EFI_INVALID_PARAMETER;
- }
- }
-
- //
- // Test lock.
- //
- if ((Capabilities & EFI_FVB2_LOCK_CAP) == 0) {
- if (NewStatus & EFI_FVB2_LOCK_STATUS) {
- return EFI_INVALID_PARAMETER;
- }
- }
-
- *AttribPtr = (*AttribPtr) & (0xFFFFFFFF & (~EFI_FVB2_STATUS));
- *AttribPtr = (*AttribPtr) | NewStatus;
- *Attributes = *AttribPtr;
-
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-EFIAPI
-FvbProtocolGetPhysicalAddress (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- OUT EFI_PHYSICAL_ADDRESS *Address
- )
-{
- *Address = mFvInstance->FvBase;
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-EFIAPI
-FvbProtocolGetBlockSize (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- IN CONST EFI_LBA Lba,
- OUT UINTN *BlockSize,
- OUT UINTN *NumOfBlocks
- )
-/*++
-
- Routine Description:
- Retrieve the size of a logical block
-
- Arguments:
- This - Calling context
- Lba - Indicates which block to return the size for.
- BlockSize - A pointer to a caller allocated UINTN in which
- the size of the block is returned
- NumOfBlocks - a pointer to a caller allocated UINTN in which the
- number of consecutive blocks starting with Lba is
- returned. All blocks in this range have a size of
- BlockSize
-
- Returns:
- EFI_SUCCESS - The firmware volume was read successfully and
- contents are in Buffer
-
---*/
-{
- return FvbGetLbaAddress (
- Lba,
- NULL,
- BlockSize,
- NumOfBlocks
- );
-}
-
-
-EFI_STATUS
-EFIAPI
-FvbProtocolGetAttributes (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- OUT EFI_FVB_ATTRIBUTES_2 *Attributes
- )
-/*++
-
- Routine Description:
- Retrieves Volume attributes. No polarity translations are done.
-
- Arguments:
- This - Calling context
- Attributes - output buffer which contains attributes
-
- Returns:
- EFI_SUCCESS - Successfully returns
-
---*/
-{
- return FvbGetVolumeAttributes (Attributes);
-}
-
-
-EFI_STATUS
-EFIAPI
-FvbProtocolSetAttributes (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
- )
-/*++
-
- Routine Description:
- Sets Volume attributes. No polarity translations are done.
-
- Arguments:
- This - Calling context
- Attributes - output buffer which contains attributes
-
- Returns:
- EFI_SUCCESS - Successfully returns
-
---*/
-{
- return FvbSetVolumeAttributes (Attributes);
-}
-
-
-EFI_STATUS
-EFIAPI
-FvbProtocolEraseBlocks (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL*This,
- ...
- )
-/*++
-
- Routine Description:
-
- The EraseBlock() function erases one or more blocks as denoted by the
- variable argument list. The entire parameter list of blocks must be
- verified prior to erasing any blocks. If a block is requested that does
- not exist within the associated firmware volume (it has a larger index than
- the last block of the firmware volume), the EraseBlock() function must
- return EFI_INVALID_PARAMETER without modifying the contents of the firmware
- volume.
-
- Arguments:
- This - Calling context
- ... - Starting LBA followed by Number of Lba to erase.
- a -1 to terminate the list.
-
- Returns:
- EFI_SUCCESS - The erase request was successfully completed
- EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state
- EFI_DEVICE_ERROR - The block device is not functioning correctly and
- could not be written. Firmware device may have been
- partially erased
-
---*/
-{
- UINTN NumOfBlocks;
- VA_LIST args;
- EFI_LBA StartingLba;
- UINTN NumOfLba;
- EFI_STATUS Status;
-
- NumOfBlocks = mFvInstance->NumOfBlocks;
- VA_START (args, This);
-
- do {
- StartingLba = VA_ARG (args, EFI_LBA);
- if (StartingLba == EFI_LBA_LIST_TERMINATOR) {
- break;
- }
-
- NumOfLba = VA_ARG (args, UINTN);
-
- if ((NumOfLba == 0) || ((StartingLba + NumOfLba) > NumOfBlocks)) {
- VA_END (args);
- return EFI_INVALID_PARAMETER;
- }
- } while (1);
-
- VA_END (args);
-
- VA_START (args, This);
- do {
- StartingLba = VA_ARG (args, EFI_LBA);
- if (StartingLba == EFI_LBA_LIST_TERMINATOR) {
- break;
- }
-
- NumOfLba = VA_ARG (args, UINTN);
-
- while (NumOfLba > 0) {
- Status = FvbEraseBlock (StartingLba);
- if (EFI_ERROR (Status)) {
- VA_END (args);
- return Status;
- }
-
- StartingLba++;
- NumOfLba--;
- }
-
- } while (1);
-
- VA_END (args);
-
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-EFIAPI
-FvbProtocolWrite (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- IN EFI_LBA Lba,
- IN UINTN Offset,
- IN OUT UINTN *NumBytes,
- IN UINT8 *Buffer
- )
-/*++
-
- Routine Description:
-
- Writes data beginning at Lba:Offset from FV. The write terminates either
- when *NumBytes of data have been written, or when a block boundary is
- reached. *NumBytes is updated to reflect the actual number of bytes
- written. The write opertion does not include erase. This routine will
- attempt to write only the specified bytes. If the writes do not stick,
- it will return an error.
-
- Arguments:
- This - Calling context
- Lba - Block in which to begin write
- Offset - Offset in the block at which to begin write
- NumBytes - On input, indicates the requested write size. On
- output, indicates the actual number of bytes
- written
- Buffer - Buffer containing source data for the write.
-
- Returns:
- EFI_SUCCESS - The firmware volume was written successfully
- EFI_BAD_BUFFER_SIZE - Write attempted across a LBA boundary. On output,
- NumBytes contains the total number of bytes
- actually written
- EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state
- EFI_DEVICE_ERROR - The block device is not functioning correctly and
- could not be written
- EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL
-
---*/
-{
- EFI_FVB_ATTRIBUTES_2 Attributes;
- UINTN LbaAddress;
- UINTN LbaLength;
- EFI_STATUS Status;
- EFI_STATUS ReturnStatus;
-
- //
- // Check for invalid conditions.
- //
- if ((NumBytes == NULL) || (Buffer == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (*NumBytes == 0) {
- return EFI_INVALID_PARAMETER;
- }
-
- Status = FvbGetLbaAddress (Lba, &LbaAddress, &LbaLength, NULL);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Check if the FV is write enabled.
- //
- FvbGetVolumeAttributes (&Attributes);
-
- if ((Attributes & EFI_FVB2_WRITE_STATUS) == 0) {
- return EFI_ACCESS_DENIED;
- }
-
- //
- // Perform boundary checks and adjust NumBytes.
- //
- if (Offset > LbaLength) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (LbaLength < (*NumBytes + Offset)) {
- *NumBytes = (UINT32)(LbaLength - Offset);
- Status = EFI_BAD_BUFFER_SIZE;
- }
-
- ReturnStatus = VarStoreWrite (
- LbaAddress + Offset,
- NumBytes,
- Buffer
- );
- if (EFI_ERROR (ReturnStatus)) {
- return ReturnStatus;
- }
-
- return Status;
-}
-
-
-EFI_STATUS
-EFIAPI
-FvbProtocolRead (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- IN CONST EFI_LBA Lba,
- IN CONST UINTN Offset,
- IN OUT UINTN *NumBytes,
- IN UINT8 *Buffer
- )
-/*++
-
- Routine Description:
-
- Reads data beginning at Lba:Offset from FV. The Read terminates either
- when *NumBytes of data have been read, or when a block boundary is
- reached. *NumBytes is updated to reflect the actual number of bytes
- written. The write opertion does not include erase. This routine will
- attempt to write only the specified bytes. If the writes do not stick,
- it will return an error.
-
- Arguments:
- This - Calling context
- Lba - Block in which to begin Read
- Offset - Offset in the block at which to begin Read
- NumBytes - On input, indicates the requested write size. On
- output, indicates the actual number of bytes Read
- Buffer - Buffer containing source data for the Read.
-
- Returns:
- EFI_SUCCESS - The firmware volume was read successfully and
- contents are in Buffer
- EFI_BAD_BUFFER_SIZE - Read attempted across a LBA boundary. On output,
- NumBytes contains the total number of bytes
- returned in Buffer
- EFI_ACCESS_DENIED - The firmware volume is in the ReadDisabled state
- EFI_DEVICE_ERROR - The block device is not functioning correctly and
- could not be read
- EFI_INVALID_PARAMETER - NumBytes or Buffer are NULL
-
---*/
-{
- EFI_FVB_ATTRIBUTES_2 Attributes;
- UINTN LbaAddress;
- UINTN LbaLength;
- EFI_STATUS Status;
-
- //
- // Check for invalid conditions.
- //
- if ((NumBytes == NULL) || (Buffer == NULL)) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (*NumBytes == 0) {
- return EFI_INVALID_PARAMETER;
- }
-
- Status = FvbGetLbaAddress (Lba, &LbaAddress, &LbaLength, NULL);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Check if the FV is read enabled.
- //
- FvbGetVolumeAttributes (&Attributes);
-
- if ((Attributes & EFI_FVB2_READ_STATUS) == 0) {
- return EFI_ACCESS_DENIED;
- }
-
- //
- // Perform boundary checks and adjust NumBytes.
- //
- if (Offset > LbaLength) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (LbaLength < (*NumBytes + Offset)) {
- *NumBytes = (UINT32)(LbaLength - Offset);
- Status = EFI_BAD_BUFFER_SIZE;
- }
-
- CopyMem (Buffer, (VOID*)(LbaAddress + Offset), (UINTN)*NumBytes);
-
- return Status;
-}
-
-
-EFI_STATUS
-ValidateFvHeader (
- IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader
- )
-/*++
-
- Routine Description:
- Check the integrity of firmware volume header
-
- Arguments:
- FwVolHeader - A pointer to a firmware volume header
-
- Returns:
- EFI_SUCCESS - The firmware volume is consistent
- EFI_NOT_FOUND - The firmware volume has corrupted. So it is not an
- FV
-
---*/
-{
- UINT16 Checksum;
-
- //
- // Verify the header revision, header signature, length
- // Length of FvBlock cannot be 2**64-1
- // HeaderLength cannot be an odd number.
- //
- if ((FwVolHeader->Revision != EFI_FVH_REVISION) ||
- (FwVolHeader->Signature != EFI_FVH_SIGNATURE) ||
- (FwVolHeader->FvLength == ((UINTN)-1)) ||
- ((FwVolHeader->HeaderLength & 0x01) != 0)
- ) {
- return EFI_NOT_FOUND;
- }
-
- //
- // Verify the header checksum.
- //
-
- Checksum = CalculateSum16 ((UINT16*)FwVolHeader, FwVolHeader->HeaderLength);
- if (Checksum != 0) {
- UINT16 Expected;
-
- Expected =
- (UINT16)(((UINTN)FwVolHeader->Checksum + 0x10000 - Checksum) & 0xffff);
-
- DEBUG ((DEBUG_INFO, "FV@%p Checksum is 0x%x, expected 0x%x\n",
- FwVolHeader, FwVolHeader->Checksum, Expected));
- return EFI_NOT_FOUND;
- }
-
- return EFI_SUCCESS;
-}
-
-
-EFI_STATUS
-EFIAPI
-FvbInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-/*++
-
- Routine Description:
- This function does common initialization for FVB services
-
- Arguments:
-
- Returns:
-
---*/
-{
- EFI_STATUS Status;
- UINT32 BufferSize;
- EFI_FV_BLOCK_MAP_ENTRY *PtrBlockMapEntry;
- EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
- UINT32 MaxLbaSize;
- EFI_PHYSICAL_ADDRESS BaseAddress;
- UINTN Length;
- UINTN NumOfBlocks;
- RETURN_STATUS PcdStatus;
- UINTN StartOffset;
-
- BaseAddress = PcdGet32 (PcdNvStorageVariableBase);
- Length = (FixedPcdGet32 (PcdFlashNvStorageVariableSize) +
- FixedPcdGet32 (PcdFlashNvStorageFtwWorkingSize) +
- FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize) +
- FixedPcdGet32 (PcdNvStorageEventLogSize));
- StartOffset = BaseAddress - FixedPcdGet64 (PcdFdBaseAddress);
-
- BufferSize = sizeof (EFI_FW_VOL_INSTANCE);
-
- mFvInstance = AllocateRuntimeZeroPool (BufferSize);
- if (mFvInstance == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- mFvInstance->FvBase = (UINTN)BaseAddress;
- mFvInstance->FvLength = (UINTN)Length;
- mFvInstance->Offset = StartOffset;
- /*
- * Should I parse config.txt instead and find the real name?
- */
- mFvInstance->MappedFile = L"RPI_EFI.FD";
-
- Status = ValidateFvHeader (mFvInstance->VolumeHeader);
- if (!EFI_ERROR (Status)) {
- if (mFvInstance->VolumeHeader->FvLength != Length ||
- mFvInstance->VolumeHeader->BlockMap[0].Length !=
- PcdGet32 (PcdFirmwareBlockSize)) {
- Status = EFI_VOLUME_CORRUPTED;
- }
- }
- if (EFI_ERROR (Status)) {
- EFI_FIRMWARE_VOLUME_HEADER *GoodFwVolHeader;
- UINTN WriteLength;
-
- DEBUG ((DEBUG_INFO,
- "Variable FV header is not valid. It will be reinitialized.\n"));
-
- //
- // Get FvbInfo
- //
- Status = GetFvbInfo (Length, &GoodFwVolHeader);
- ASSERT_EFI_ERROR (Status);
-
- //
- // Erase all the blocks
- //
- Status = VarStoreErase ((UINTN)mFvInstance->FvBase, mFvInstance->FvLength);
- ASSERT_EFI_ERROR (Status);
- //
- // Write good FV header
- //
- WriteLength = GoodFwVolHeader->HeaderLength;
- Status = VarStoreWrite ((UINTN)mFvInstance->FvBase, &WriteLength,
- (UINT8*)GoodFwVolHeader);
- ASSERT_EFI_ERROR (Status);
- ASSERT (WriteLength == GoodFwVolHeader->HeaderLength);
-
- Status = ValidateFvHeader (mFvInstance->VolumeHeader);
- ASSERT_EFI_ERROR (Status);
- }
-
- MaxLbaSize = 0;
- NumOfBlocks = 0;
- for (PtrBlockMapEntry = mFvInstance->VolumeHeader->BlockMap;
- PtrBlockMapEntry->NumBlocks != 0;
- PtrBlockMapEntry++) {
- //
- // Get the maximum size of a block.
- //
- if (MaxLbaSize < PtrBlockMapEntry->Length) {
- MaxLbaSize = PtrBlockMapEntry->Length;
- }
-
- NumOfBlocks = NumOfBlocks + PtrBlockMapEntry->NumBlocks;
- }
-
- //
- // The total number of blocks in the FV.
- //
- mFvInstance->NumOfBlocks = NumOfBlocks;
-
- //
- // Add a FVB Protocol Instance
- //
- FvbDevice = AllocateRuntimePool (sizeof (EFI_FW_VOL_BLOCK_DEVICE));
- ASSERT (FvbDevice != NULL);
- CopyMem (FvbDevice, &mFvbDeviceTemplate, sizeof (EFI_FW_VOL_BLOCK_DEVICE));
-
- //
- // Set up the devicepath
- //
- if (mFvInstance->VolumeHeader->ExtHeaderOffset == 0) {
- FV_MEMMAP_DEVICE_PATH *FvMemmapDevicePath;
-
- //
- // FV does not contains extension header, then produce MEMMAP_DEVICE_PATH
- //
- FvMemmapDevicePath = AllocateCopyPool (sizeof (FV_MEMMAP_DEVICE_PATH),
- &mFvMemmapDevicePathTemplate);
- FvMemmapDevicePath->MemMapDevPath.StartingAddress = mFvInstance->FvBase;
- FvMemmapDevicePath->MemMapDevPath.EndingAddress = mFvInstance->FvBase +
- mFvInstance->FvLength - 1;
- FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL*)FvMemmapDevicePath;
- } else {
- FV_PIWG_DEVICE_PATH *FvPiwgDevicePath;
-
- FvPiwgDevicePath = AllocateCopyPool (sizeof (FV_PIWG_DEVICE_PATH),
- &mFvPIWGDevicePathTemplate);
- CopyGuid (&FvPiwgDevicePath->FvDevPath.FvName,
- (GUID*)(UINTN)(mFvInstance->FvBase + mFvInstance->VolumeHeader->ExtHeaderOffset));
- FvbDevice->DevicePath = (EFI_DEVICE_PATH_PROTOCOL*)FvPiwgDevicePath;
- }
-
- //
- // Module type specific hook.
- //
- InstallProtocolInterfaces (FvbDevice);
-
- //
- // Set several PCD values to point to flash.
- //
- PcdStatus = PcdSet64S (PcdFlashNvStorageVariableBase64,
- (UINTN)PcdGet32 (PcdNvStorageVariableBase));
- ASSERT_RETURN_ERROR (PcdStatus);
- PcdStatus = PcdSet32S (PcdFlashNvStorageFtwWorkingBase,
- PcdGet32 (PcdNvStorageFtwWorkingBase));
- ASSERT_RETURN_ERROR (PcdStatus);
- PcdStatus = PcdSet32S (PcdFlashNvStorageFtwSpareBase,
- PcdGet32 (PcdNvStorageFtwSpareBase));
- ASSERT_RETURN_ERROR (PcdStatus);
-
- InstallFSNotifyHandler ();
- InstallDumpVarEventHandlers ();
- InstallVirtualAddressChangeHandler ();
-
- return EFI_SUCCESS;
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockService.h b/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockService.h
deleted file mode 100644
index b65c2645..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockService.h
+++ /dev/null
@@ -1,211 +0,0 @@
-/** @file
- *
- * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2007-2009, Intel Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#ifndef _FW_BLOCK_SERVICE_H
-#define _FW_BLOCK_SERVICE_H
-
-#include <Guid/EventGroup.h>
-#include <Library/DebugLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/PcdLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiRuntimeLib.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/FirmwareVolumeBlock.h>
-#include <Protocol/SimpleFileSystem.h>
-#include <Protocol/BlockIo.h>
-#include <Protocol/LoadedImage.h>
-
-typedef struct {
- union {
- UINTN FvBase;
- EFI_FIRMWARE_VOLUME_HEADER *VolumeHeader;
- };
- UINTN FvLength;
- UINTN Offset;
- UINTN NumOfBlocks;
- EFI_DEVICE_PATH_PROTOCOL *Device;
- CHAR16 *MappedFile;
- BOOLEAN Dirty;
-} EFI_FW_VOL_INSTANCE;
-
-extern EFI_FW_VOL_INSTANCE *mFvInstance;
-
-typedef struct {
- MEDIA_FW_VOL_DEVICE_PATH FvDevPath;
- EFI_DEVICE_PATH_PROTOCOL EndDevPath;
-} FV_PIWG_DEVICE_PATH;
-
-typedef struct {
- MEMMAP_DEVICE_PATH MemMapDevPath;
- EFI_DEVICE_PATH_PROTOCOL EndDevPath;
-} FV_MEMMAP_DEVICE_PATH;
-
-typedef struct {
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance;
-} EFI_FW_VOL_BLOCK_DEVICE;
-
-EFI_STATUS
-GetFvbInfo (
- IN UINT64 FvLength,
- OUT EFI_FIRMWARE_VOLUME_HEADER **FvbInfo
- );
-
-EFI_STATUS
-FvbSetVolumeAttributes (
- IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
- );
-
-EFI_STATUS
-FvbGetVolumeAttributes (
- OUT EFI_FVB_ATTRIBUTES_2 *Attributes
- );
-
-EFI_STATUS
-FvbGetPhysicalAddress (
- OUT EFI_PHYSICAL_ADDRESS *Address
- );
-
-EFI_STATUS
-EFIAPI
-FvbInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- );
-
-
-VOID
-EFIAPI
-FvbClassAddressChangeEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
- );
-
-EFI_STATUS
-FvbGetLbaAddress (
- IN EFI_LBA Lba,
- OUT UINTN *LbaAddress,
- OUT UINTN *LbaLength,
- OUT UINTN *NumOfBlocks
- );
-
-//
-// Protocol APIs
-//
-EFI_STATUS
-EFIAPI
-FvbProtocolGetAttributes (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- OUT EFI_FVB_ATTRIBUTES_2 *Attributes
- );
-
-EFI_STATUS
-EFIAPI
-FvbProtocolSetAttributes (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- IN OUT EFI_FVB_ATTRIBUTES_2 *Attributes
- );
-
-EFI_STATUS
-EFIAPI
-FvbProtocolGetPhysicalAddress (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- OUT EFI_PHYSICAL_ADDRESS *Address
- );
-
-EFI_STATUS
-EFIAPI
-FvbProtocolGetBlockSize (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- IN CONST EFI_LBA Lba,
- OUT UINTN *BlockSize,
- OUT UINTN *NumOfBlocks
- );
-
-EFI_STATUS
-EFIAPI
-FvbProtocolRead (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- IN CONST EFI_LBA Lba,
- IN CONST UINTN Offset,
- IN OUT UINTN *NumBytes,
- IN UINT8 *Buffer
- );
-
-EFI_STATUS
-EFIAPI
-FvbProtocolWrite (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- IN EFI_LBA Lba,
- IN UINTN Offset,
- IN OUT UINTN *NumBytes,
- IN UINT8 *Buffer
- );
-
-EFI_STATUS
-EFIAPI
-FvbProtocolEraseBlocks (
- IN CONST EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
- ...
- );
-
-VOID
-InstallProtocolInterfaces (
- IN EFI_FW_VOL_BLOCK_DEVICE *FvbDevice
- );
-
-VOID
-InstallVirtualAddressChangeHandler (
- VOID
- );
-
-VOID
-InstallFSNotifyHandler (
- VOID
- );
-
-VOID
-InstallDumpVarEventHandlers (
- VOID
-);
-
-EFI_STATUS
-FileWrite (
- IN EFI_FILE_PROTOCOL *File,
- IN UINTN Offset,
- IN UINTN Buffer,
- IN UINTN Size
- );
-
-EFI_STATUS
-CheckStore (
- IN EFI_HANDLE SimpleFileSystemHandle,
- OUT EFI_DEVICE_PATH_PROTOCOL **Device
- );
-
-EFI_STATUS
-CheckStoreExists (
- IN EFI_DEVICE_PATH_PROTOCOL *Device
- );
-
-EFI_STATUS
-FileOpen (
- IN EFI_DEVICE_PATH_PROTOCOL *Device,
- IN CHAR16 *MappedFile,
- OUT EFI_FILE_PROTOCOL **File,
- IN UINT64 OpenMode
- );
-
-VOID
-FileClose (
- IN EFI_FILE_PROTOCOL *File
- );
-
-#endif
diff --git a/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c b/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
deleted file mode 100644
index 07f3f1c2..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.c
+++ /dev/null
@@ -1,325 +0,0 @@
-/** @file
- *
- * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- * Copyright (C) 2015, Red Hat, Inc.
- * Copyright (c) 2006-2014, Intel Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include "VarBlockService.h"
-
-VOID *mSFSRegistration;
-
-
-VOID
-InstallProtocolInterfaces (
- IN EFI_FW_VOL_BLOCK_DEVICE *FvbDevice
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE FwbHandle;
- EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *OldFwbInterface;
-
- //
- // Find a handle with a matching device path that has supports FW Block
- // protocol.
- //
- Status = gBS->LocateDevicePath (&gEfiFirmwareVolumeBlockProtocolGuid,
- &FvbDevice->DevicePath, &FwbHandle);
- if (EFI_ERROR (Status)) {
- //
- // LocateDevicePath fails so install a new interface and device path.
- //
- FwbHandle = NULL;
- Status = gBS->InstallMultipleProtocolInterfaces (
- &FwbHandle,
- &gEfiFirmwareVolumeBlockProtocolGuid,
- &FvbDevice->FwVolBlockInstance,
- &gEfiDevicePathProtocolGuid,
- FvbDevice->DevicePath,
- NULL
- );
- ASSERT_EFI_ERROR (Status);
- } else if (IsDevicePathEnd (FvbDevice->DevicePath)) {
- //
- // Device already exists, so reinstall the FVB protocol
- //
- Status = gBS->HandleProtocol (
- FwbHandle,
- &gEfiFirmwareVolumeBlockProtocolGuid,
- (VOID**)&OldFwbInterface
- );
- ASSERT_EFI_ERROR (Status);
-
- Status = gBS->ReinstallProtocolInterface (
- FwbHandle,
- &gEfiFirmwareVolumeBlockProtocolGuid,
- OldFwbInterface,
- &FvbDevice->FwVolBlockInstance
- );
- ASSERT_EFI_ERROR (Status);
- } else {
- //
- // There was a FVB protocol on an End Device Path node
- //
- ASSERT (FALSE);
- }
-}
-
-
-STATIC
-VOID
-EFIAPI
-FvbVirtualAddressChangeEvent (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-/*++
-
- Routine Description:
-
- Fixup internal data so that EFI can be called in virtual mode.
-
- Arguments:
-
- (Standard EFI notify event - EFI_EVENT_NOTIFY)
-
- Returns:
-
- None
-
---*/
-{
- EfiConvertPointer (0x0, (VOID**)&mFvInstance->FvBase);
- EfiConvertPointer (0x0, (VOID**)&mFvInstance->VolumeHeader);
- EfiConvertPointer (0x0, (VOID**)&mFvInstance);
-}
-
-
-VOID
-InstallVirtualAddressChangeHandler (
- VOID
- )
-{
- EFI_STATUS Status;
- EFI_EVENT VirtualAddressChangeEvent;
-
- Status = gBS->CreateEventEx (
- EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- FvbVirtualAddressChangeEvent,
- NULL,
- &gEfiEventVirtualAddressChangeGuid,
- &VirtualAddressChangeEvent
- );
- ASSERT_EFI_ERROR (Status);
-}
-
-
-STATIC
-EFI_STATUS
-DoDump (
- IN EFI_DEVICE_PATH_PROTOCOL *Device
- )
-{
- EFI_STATUS Status;
- EFI_FILE_PROTOCOL *File;
-
- Status = FileOpen (Device,
- mFvInstance->MappedFile,
- &File,
- EFI_FILE_MODE_WRITE |
- EFI_FILE_MODE_READ);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = FileWrite (File,
- mFvInstance->Offset,
- mFvInstance->FvBase,
- mFvInstance->FvLength);
- FileClose (File);
- return Status;
-}
-
-
-STATIC
-VOID
-EFIAPI
-DumpVars (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- EFI_STATUS Status;
-
- if (mFvInstance->Device == NULL) {
- DEBUG ((DEBUG_INFO, "Variable store not found?\n"));
- return;
- }
-
- if (!mFvInstance->Dirty) {
- DEBUG ((DEBUG_INFO, "Variables not dirty, not dumping!\n"));
- return;
- }
-
- Status = DoDump (mFvInstance->Device);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Couldn't dump '%s'\n", mFvInstance->MappedFile));
- ASSERT_EFI_ERROR (Status);
- return;
- }
-
- DEBUG ((DEBUG_INFO, "Variables dumped!\n"));
- mFvInstance->Dirty = FALSE;
-}
-
-
-VOID
-ReadyToBootHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- EFI_STATUS Status;
- EFI_EVENT ImageInstallEvent;
- VOID *ImageRegistration;
-
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- DumpVars,
- NULL,
- &ImageInstallEvent
- );
- ASSERT_EFI_ERROR (Status);
-
- Status = gBS->RegisterProtocolNotify (
- &gEfiLoadedImageProtocolGuid,
- ImageInstallEvent,
- &ImageRegistration
- );
- ASSERT_EFI_ERROR (Status);
-
- DumpVars (NULL, NULL);
- Status = gBS->CloseEvent (Event);
- ASSERT_EFI_ERROR (Status);
-}
-
-
-VOID
-InstallDumpVarEventHandlers (
- VOID
- )
-{
- EFI_STATUS Status;
- EFI_EVENT ResetEvent;
- EFI_EVENT ReadyToBootEvent;
-
- Status = gBS->CreateEventEx (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- DumpVars,
- NULL,
- &gRaspberryPiEventResetGuid,
- &ResetEvent
- );
- ASSERT_EFI_ERROR (Status);
-
- Status = gBS->CreateEventEx (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- ReadyToBootHandler,
- NULL,
- &gEfiEventReadyToBootGuid,
- &ReadyToBootEvent
- );
- ASSERT_EFI_ERROR (Status);
-}
-
-
-VOID
-EFIAPI
-OnSimpleFileSystemInstall (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- EFI_STATUS Status;
- UINTN HandleSize;
- EFI_HANDLE Handle;
- EFI_DEVICE_PATH_PROTOCOL *Device;
-
- if ((mFvInstance->Device != NULL) &&
- !EFI_ERROR (CheckStoreExists (mFvInstance->Device))) {
- //
- // We've already found the variable store before,
- // and that device is not removed from the ssystem.
- //
- return;
- }
-
- while (TRUE) {
- HandleSize = sizeof (EFI_HANDLE);
- Status = gBS->LocateHandle (
- ByRegisterNotify,
- NULL,
- mSFSRegistration,
- &HandleSize,
- &Handle
- );
- if (Status == EFI_NOT_FOUND) {
- break;
- }
-
- ASSERT_EFI_ERROR (Status);
-
- Status = CheckStore (Handle, &Device);
- if (EFI_ERROR (Status)) {
- continue;
- }
-
- Status = DoDump (Device);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Couldn't update '%s'\n", mFvInstance->MappedFile));
- ASSERT_EFI_ERROR (Status);
- continue;
- }
-
- if (mFvInstance->Device != NULL) {
- gBS->FreePool (mFvInstance->Device);
- }
-
- DEBUG ((DEBUG_INFO, "Found variable store!\n"));
- mFvInstance->Device = Device;
- break;
- }
-}
-
-
-VOID
-InstallFSNotifyHandler (
- VOID
- )
-{
- EFI_STATUS Status;
- EFI_EVENT Event;
-
- Status = gBS->CreateEvent (
- EVT_NOTIFY_SIGNAL,
- TPL_CALLBACK,
- OnSimpleFileSystemInstall,
- NULL,
- &Event
- );
- ASSERT_EFI_ERROR (Status);
-
- Status = gBS->RegisterProtocolNotify (
- &gEfiSimpleFileSystemProtocolGuid,
- Event,
- &mSFSRegistration
- );
- ASSERT_EFI_ERROR (Status);
-}
diff --git a/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf b/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
deleted file mode 100644
index 394a4f61..00000000
--- a/Platform/RaspberryPi/RPi3/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
+++ /dev/null
@@ -1,87 +0,0 @@
-#/** @file
-#
-# Support for the FS-backed "flash" device.
-# The trick is to keep it inside the RPI firmware file itself...
-#
-# Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
-# Copyright (c) 2006-2013, Intel Corporation. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x0001001A
- BASE_NAME = VarBlockServiceDxe
- FILE_GUID = 733cbac2-b23f-4b92-bc8e-fb01ce5907b7
- MODULE_TYPE = DXE_RUNTIME_DRIVER
- VERSION_STRING = 1.0
- ENTRY_POINT = FvbInitialize
-
-#
-# The following information is for reference only and not required by the build
-# tools.
-#
-# VALID_ARCHITECTURES = AARCH64
-#
-
-[Sources]
- FvbInfo.c
- VarBlockService.h
- VarBlockService.c
- VarBlockServiceDxe.c
- FileIo.c
-
-[Packages]
- ArmPkg/ArmPkg.dec
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- Platform/RaspberryPi/RPi3/RPi3.dec
-
-[LibraryClasses]
- BaseLib
- BaseMemoryLib
- DebugLib
- DevicePathLib
- DxeServicesTableLib
- MemoryAllocationLib
- PcdLib
- UefiBootServicesTableLib
- UefiDriverEntryPoint
- UefiRuntimeLib
-
-[Guids]
- gEfiEventVirtualAddressChangeGuid
- gRaspberryPiEventResetGuid
- gEfiEventReadyToBootGuid
-
-[Protocols]
- gEfiSimpleFileSystemProtocolGuid
- gEfiLoadedImageProtocolGuid
- gEfiBlockIoProtocolGuid
- gEfiFirmwareVolumeBlockProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
- gEfiDevicePathProtocolGuid # PROTOCOL SOMETIMES_PRODUCED
-
-[FixedPcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
- gRaspberryPiTokenSpaceGuid.PcdNvStorageVariableBase
- gRaspberryPiTokenSpaceGuid.PcdNvStorageFtwWorkingBase
- gRaspberryPiTokenSpaceGuid.PcdNvStorageFtwSpareBase
- gRaspberryPiTokenSpaceGuid.PcdNvStorageEventLogSize
- gRaspberryPiTokenSpaceGuid.PcdFirmwareBlockSize
- gArmTokenSpaceGuid.PcdFdBaseAddress
- gArmTokenSpaceGuid.PcdFdSize
-
-[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase
- gRaspberryPiTokenSpaceGuid.PcdNvStorageEventLogBase
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64
-
-[FeaturePcd]
-
-[Depex]
- TRUE
diff --git a/Platform/RaspberryPi/RPi3/Include/IndustryStandard/RpiMbox.h b/Platform/RaspberryPi/RPi3/Include/IndustryStandard/RpiMbox.h
deleted file mode 100644
index d3b6f117..00000000
--- a/Platform/RaspberryPi/RPi3/Include/IndustryStandard/RpiMbox.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/** @file
- *
- * Copyright (c) 2019, Pete Batard <pete@akeo.ie>
- * Copyright (c) 2016, Linaro Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#ifndef __RASPBERRY_PI_MAILBOX_H__
-#define __RASPBERRY_PI_MAILBOX_H__
-
-/* Mailbox channels */
-#define RPI_MBOX_PM_CHANNEL 0
-#define RPI_MBOX_FB_CHANNEL 1
-#define RPI_MBOX_VUART_CHANNEL 2
-#define RPI_MBOX_VCHIQ_CHANNEL 3
-#define RPI_MBOX_LED_CHANNEL 4
-#define RPI_MBOX_BUTTON_CHANNEL 5
-#define RPI_MBOX_TOUCHSCREEN_CHANNEL 6
-/* Request from ARM for response by VideoCore */
-#define RPI_MBOX_VC_CHANNEL 8
-/* Request from VideoCore for response by ARM */
-#define RPI_MBOX_ARM_CHANNEL 9
-
-#define RPI_MBOX_RESP_SUCCESS 0x80000000
-#define RPI_MBOX_RESP_FAILURE 0x80000001
-
-#define RPI_MBOX_VALUE_SIZE_RESPONSE_MASK BIT31
-
-#define RPI_MBOX_GET_REVISION 0x00000001
-#define RPI_MBOX_GET_BOARD_MODEL 0x00010001
-#define RPI_MBOX_GET_BOARD_REVISION 0x00010002
-#define RPI_MBOX_GET_MAC_ADDRESS 0x00010003
-#define RPI_MBOX_GET_BOARD_SERIAL 0x00010004
-#define RPI_MBOX_GET_ARM_MEMSIZE 0x00010005
-
-#define RPI_MBOX_SET_POWER_STATE 0x00028001
-
-#define RPI_MBOX_POWER_STATE_SDHCI 0x00000000
-#define RPI_MBOX_POWER_STATE_UART0 0x00000001
-#define RPI_MBOX_POWER_STATE_UART1 0x00000002
-#define RPI_MBOX_POWER_STATE_USB_HCD 0x00000003
-#define RPI_MBOX_POWER_STATE_I2C0 0x00000004
-#define RPI_MBOX_POWER_STATE_I2C1 0x00000005
-#define RPI_MBOX_POWER_STATE_I2C2 0x00000006
-#define RPI_MBOX_POWER_STATE_SPI 0x00000007
-#define RPI_MBOX_POWER_STATE_CCP2TX 0x00000008
-
-#define RPI_MBOX_GET_CLOCK_RATE 0x00030002
-#define RPI_MBOX_GET_MAX_CLOCK_RATE 0x00030004
-#define RPI_MBOX_GET_MIN_CLOCK_RATE 0x00030007
-
-#define RPI_MBOX_SET_CLOCK_RATE 0x00038002
-#define RPI_MBOX_SET_GPIO 0x00038041
-
-#define RPI_MBOX_GET_FB_GEOMETRY 0x00040003
-#define RPI_MBOX_GET_FB_LINELENGTH 0x00040008
-#define RPI_MBOX_GET_FB_COLOR_DEPTH 0x00040005
-#define RPI_MBOX_GET_FB_REGION 0x00040001
-
-#define RPI_MBOX_SET_FB_PGEOM 0x00048003
-#define RPI_MBOX_SET_FB_VGEOM 0x00048004
-#define RPI_MBOX_SET_FB_DEPTH 0x00048005
-#define RPI_MBOX_ALLOC_FB 0x00040001
-#define RPI_MBOX_FREE_FB 0x00048001
-
-#define RPI_MBOX_GET_COMMAND_LINE 0x00050001
-
-#define RPI_MBOX_POWER_STATE_ENABLE BIT0
-#define RPI_MBOX_POWER_STATE_WAIT BIT1
-
-#define RPI_MBOX_CLOCK_RATE_EMMC 0x000000001
-#define RPI_MBOX_CLOCK_RATE_UART 0x000000002
-#define RPI_MBOX_CLOCK_RATE_ARM 0x000000003
-#define RPI_MBOX_CLOCK_RATE_CORE 0x000000004
-#define RPI_MBOX_CLOCK_RATE_V3D 0x000000005
-#define RPI_MBOX_CLOCK_RATE_H264 0x000000006
-#define RPI_MBOX_CLOCK_RATE_ISP 0x000000007
-#define RPI_MBOX_CLOCK_RATE_SDRAM 0x000000008
-#define RPI_MBOX_CLOCK_RATE_PIXEL 0x000000009
-#define RPI_MBOX_CLOCK_RATE_PWM 0x00000000a
-
-#endif /* __RASPBERRY_PI_MAILBOX_H__ */
diff --git a/Platform/RaspberryPi/RPi3/Include/Protocol/DwUsb.h b/Platform/RaspberryPi/RPi3/Include/Protocol/DwUsb.h
deleted file mode 100644
index 4882aad6..00000000
--- a/Platform/RaspberryPi/RPi3/Include/Protocol/DwUsb.h
+++ /dev/null
@@ -1,47 +0,0 @@
-/** @file
- *
- * Copyright (c) 2015-2016, Linaro. All rights reserved.
- * Copyright (c) 2015-2016, Hisilicon Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#ifndef __DW_USB_PROTOCOL_H__
-#define __DW_USB_PROTOCOL_H__
-
-//
-// Protocol GUID
-//
-#define DW_USB_PROTOCOL_GUID { 0x109fa264, 0x7811, 0x4862, { 0xa9, 0x73, 0x4a, 0xb2, 0xef, 0x2e, 0xe2, 0xff }}
-
-//
-// Protocol interface structure
-//
-typedef struct _DW_USB_PROTOCOL DW_USB_PROTOCOL;
-
-#define USB_HOST_MODE 0
-#define USB_DEVICE_MODE 1
-#define USB_CABLE_NOT_ATTACHED 2
-
-typedef
-EFI_STATUS
-(EFIAPI *DW_USB_GET_SERIAL_NO) (
- OUT CHAR16 *SerialNo,
- OUT UINT8 *Length
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *DW_USB_PHY_INIT) (
- IN UINT8 Mode
- );
-
-struct _DW_USB_PROTOCOL {
- DW_USB_GET_SERIAL_NO Get;
- DW_USB_PHY_INIT PhyInit;
-};
-
-extern EFI_GUID gDwUsbProtocolGuid;
-
-#endif /* __DW_USB_PROTOCOL_H__ */
diff --git a/Platform/RaspberryPi/RPi3/Include/Protocol/ExtendedTextOut.h b/Platform/RaspberryPi/RPi3/Include/Protocol/ExtendedTextOut.h
deleted file mode 100644
index 0c57e438..00000000
--- a/Platform/RaspberryPi/RPi3/Include/Protocol/ExtendedTextOut.h
+++ /dev/null
@@ -1,30 +0,0 @@
-/** @file
- *
- * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#ifndef __EXTENDED_TEXT_OUT_PROTOCOL_H__
-#define __EXTENDED_TEXT_OUT_PROTOCOL_H__
-
-#include <Protocol/SimpleTextOut.h>
-#include <Protocol/GraphicsOutput.h>
-
-#define EXTENDED_TEXT_OUTPUT_PROTOCOL_GUID \
- { \
- 0x387477ff, 0xffc7, 0xffd2, {0x8e, 0x39, 0x0, 0xff, 0xc9, 0x69, 0x72, 0x3b } \
- }
-
-typedef struct _EXTENDED_TEXT_OUTPUT_PROTOCOL EXTENDED_TEXT_OUTPUT_PROTOCOL;
-
-struct _EXTENDED_TEXT_OUTPUT_PROTOCOL {
- EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *TextOut;
- EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
- BOOLEAN AutoWrap;
-};
-
-extern EFI_GUID gExtendedTextOutputProtocolGuid;
-
-#endif /* __EXTENDED_TEXT_OUT_PROTOCOL_H__ */
diff --git a/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h b/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h
deleted file mode 100644
index e49d6e61..00000000
--- a/Platform/RaspberryPi/RPi3/Include/Protocol/RpiFirmware.h
+++ /dev/null
@@ -1,154 +0,0 @@
-/** @file
- *
- * Copyright (c) 2016, Linaro Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#ifndef __RASPBERRY_PI_FIRMWARE_PROTOCOL_H__
-#define __RASPBERRY_PI_FIRMWARE_PROTOCOL_H__
-
-#define RASPBERRY_PI_FIRMWARE_PROTOL_GUID \
- { 0x0ACA9535, 0x7AD0, 0x4286, { 0xB0, 0x2E, 0x87, 0xFA, 0x7E, 0x2A, 0x57, 0x11 } }
-
-typedef
-EFI_STATUS
-(EFIAPI *SET_POWER_STATE) (
- IN UINT32 DeviceId,
- IN BOOLEAN PowerState,
- IN BOOLEAN Wait
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *GET_MAC_ADDRESS) (
- OUT UINT8 MacAddress[6]
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *GET_COMMAND_LINE) (
- IN UINTN BufferSize,
- OUT CHAR8 CommandLine[]
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *GET_CLOCK_RATE) (
- IN UINT32 ClockId,
- OUT UINT32 *ClockRate
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *SET_CLOCK_RATE) (
- IN UINT32 ClockId,
- OUT UINT32 ClockRate,
- IN BOOLEAN SkipTurbo
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *GET_FB) (
- IN UINT32 Width,
- IN UINT32 Height,
- IN UINT32 Depth,
- OUT EFI_PHYSICAL_ADDRESS *FbBase,
- OUT UINTN *FbSize,
- OUT UINTN *Pitch
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *GET_FB_SIZE) (
- OUT UINT32 *Width,
- OUT UINT32 *Height
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *FREE_FB) (
- VOID
- );
-
-typedef
-VOID
-(EFIAPI *SET_LED) (
- BOOLEAN On
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *GET_SERIAL) (
- UINT64 *Serial
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *GET_MODEL) (
- UINT32 *Model
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *GET_MODEL_REVISION) (
- UINT32 *Revision
- );
-
-typedef
-CHAR8*
-(EFIAPI *GET_MODEL_NAME) (
- INTN ModelId
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *GET_FIRMWARE_REVISION) (
- UINT32 *Revision
- );
-
-typedef
-CHAR8*
-(EFIAPI *GET_MANUFACTURER_NAME) (
- INTN ManufacturerId
- );
-
-typedef
-CHAR8*
-(EFIAPI *GET_CPU_NAME) (
- INTN CpuId
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *GET_ARM_MEM) (
- UINT32 *Base,
- UINT32 *Size
- );
-
-typedef struct {
- SET_POWER_STATE SetPowerState;
- GET_MAC_ADDRESS GetMacAddress;
- GET_COMMAND_LINE GetCommandLine;
- GET_CLOCK_RATE GetClockRate;
- GET_CLOCK_RATE GetMaxClockRate;
- GET_CLOCK_RATE GetMinClockRate;
- SET_CLOCK_RATE SetClockRate;
- GET_FB GetFB;
- FREE_FB FreeFB;
- GET_FB_SIZE GetFBSize;
- SET_LED SetLed;
- GET_SERIAL GetSerial;
- GET_MODEL GetModel;
- GET_MODEL_REVISION GetModelRevision;
- GET_MODEL_NAME GetModelName;
- GET_FIRMWARE_REVISION GetFirmwareRevision;
- GET_MANUFACTURER_NAME GetManufacturerName;
- GET_CPU_NAME GetCpuName;
- GET_ARM_MEM GetArmMem;
-} RASPBERRY_PI_FIRMWARE_PROTOCOL;
-
-extern EFI_GUID gRaspberryPiFirmwareProtocolGuid;
-
-#endif /* __RASPBERRY_PI_FIRMWARE_PROTOCOL_H__ */
diff --git a/Platform/RaspberryPi/RPi3/Include/Protocol/RpiMmcHost.h b/Platform/RaspberryPi/RPi3/Include/Protocol/RpiMmcHost.h
deleted file mode 100644
index c558e00b..00000000
--- a/Platform/RaspberryPi/RPi3/Include/Protocol/RpiMmcHost.h
+++ /dev/null
@@ -1,200 +0,0 @@
-/** @file
- *
- * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2011-2014, ARM Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#ifndef __RASPBERRY_PI_MMC_HOST_PROTOCOL_H__
-#define __RASPBERRY_PI_MMC_HOST_PROTOCOL_H__
-
-/*
- * Global ID for the MMC Host Protocol
- */
-#define RASPBERRY_PI_MMC_HOST_PROTOCOL_GUID \
- { 0x3e591c00, 0x9e4a, 0x11df, {0x92, 0x44, 0x00, 0x02, 0xA5, 0xF5, 0xF5, 0x1B } }
-
-#define MMC_RESPONSE_TYPE_R1 0
-#define MMC_RESPONSE_TYPE_R1b 0
-#define MMC_RESPONSE_TYPE_R2 1
-#define MMC_RESPONSE_TYPE_R3 0
-#define MMC_RESPONSE_TYPE_R6 0
-#define MMC_RESPONSE_TYPE_R7 0
-#define MMC_RESPONSE_TYPE_OCR 0
-#define MMC_RESPONSE_TYPE_CID 1
-#define MMC_RESPONSE_TYPE_CSD 1
-#define MMC_RESPONSE_TYPE_RCA 0
-
-typedef UINT32 MMC_RESPONSE_TYPE;
-
-typedef UINT32 MMC_CMD;
-
-#define MMC_CMD_WAIT_RESPONSE (1 << 16)
-#define MMC_CMD_LONG_RESPONSE (1 << 17)
-#define MMC_CMD_NO_CRC_RESPONSE (1 << 18)
-
-#define MMC_INDX(Index) ((Index) & 0xFFFF)
-#define MMC_GET_INDX(MmcCmd) ((MmcCmd) & 0xFFFF)
-
-#define MMC_CMD0 (MMC_INDX(0) | MMC_CMD_NO_CRC_RESPONSE)
-#define MMC_CMD1 (MMC_INDX(1) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_NO_CRC_RESPONSE)
-#define MMC_CMD2 (MMC_INDX(2) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_LONG_RESPONSE)
-#define MMC_CMD3 (MMC_INDX(3) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD5 (MMC_INDX(5) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_NO_CRC_RESPONSE)
-#define MMC_CMD6 (MMC_INDX(6) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD7 (MMC_INDX(7) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD8 (MMC_INDX(8) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD9 (MMC_INDX(9) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_LONG_RESPONSE)
-#define MMC_CMD11 (MMC_INDX(11) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD12 (MMC_INDX(12) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD13 (MMC_INDX(13) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD16 (MMC_INDX(16) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD17 (MMC_INDX(17) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD18 (MMC_INDX(18) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD20 (MMC_INDX(20) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD23 (MMC_INDX(23) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD24 (MMC_INDX(24) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD25 (MMC_INDX(25) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_CMD55 (MMC_INDX(55) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_ACMD22 (MMC_INDX(22) | MMC_CMD_WAIT_RESPONSE)
-#define MMC_ACMD41 (MMC_INDX(41) | MMC_CMD_WAIT_RESPONSE | MMC_CMD_NO_CRC_RESPONSE)
-#define MMC_ACMD51 (MMC_INDX(51) | MMC_CMD_WAIT_RESPONSE)
-
-// Valid responses for CMD1 in eMMC
-#define EMMC_CMD1_CAPACITY_LESS_THAN_2GB 0x00FF8080 // Capacity <= 2GB, byte addressing used
-#define EMMC_CMD1_CAPACITY_GREATER_THAN_2GB 0x40FF8080 // Capacity > 2GB, 512-byte sector addressing used
-
-#define MMC_STATUS_APP_CMD (1 << 5)
-
-typedef enum _MMC_STATE {
- MmcInvalidState = 0,
- MmcHwInitializationState,
- MmcIdleState,
- MmcReadyState,
- MmcIdentificationState,
- MmcStandByState,
- MmcTransferState,
- MmcSendingDataState,
- MmcReceiveDataState,
- MmcProgrammingState,
- MmcDisconnectState,
-} MMC_STATE;
-
-#define EMMCBACKWARD (0)
-#define EMMCHS26 (1 << 0) // High-Speed @26MHz at rated device voltages
-#define EMMCHS52 (1 << 1) // High-Speed @52MHz at rated device voltages
-#define EMMCHS52DDR1V8 (1 << 2) // High-Speed Dual Data Rate @52MHz 1.8V or 3V I/O
-#define EMMCHS52DDR1V2 (1 << 3) // High-Speed Dual Data Rate @52MHz 1.2V I/O
-#define EMMCHS200SDR1V8 (1 << 4) // HS200 Single Data Rate @200MHz 1.8V I/O
-#define EMMCHS200SDR1V2 (1 << 5) // HS200 Single Data Rate @200MHz 1.2V I/O
-#define EMMCHS400DDR1V8 (1 << 6) // HS400 Dual Data Rate @400MHz 1.8V I/O
-#define EMMCHS400DDR1V2 (1 << 7) // HS400 Dual Data Rate @400MHz 1.2V I/O
-
-///
-/// Forward declaration for EFI_MMC_HOST_PROTOCOL
-///
-typedef struct _EFI_MMC_HOST_PROTOCOL EFI_MMC_HOST_PROTOCOL;
-
-typedef
-BOOLEAN
-(EFIAPI *MMC_ISCARDPRESENT) (
- IN EFI_MMC_HOST_PROTOCOL *This
- );
-
-typedef
-BOOLEAN
-(EFIAPI *MMC_ISREADONLY) (
- IN EFI_MMC_HOST_PROTOCOL *This
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *MMC_BUILDDEVICEPATH) (
- IN EFI_MMC_HOST_PROTOCOL *This,
- OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *MMC_NOTIFYSTATE) (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN MMC_STATE State
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *MMC_SENDCOMMAND) (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN MMC_CMD Cmd,
- IN UINT32 Argument
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *MMC_RECEIVERESPONSE) (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN MMC_RESPONSE_TYPE Type,
- IN UINT32 *Buffer
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *MMC_READBLOCKDATA) (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN EFI_LBA Lba,
- IN UINTN Length,
- OUT UINT32 *Buffer
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *MMC_WRITEBLOCKDATA) (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN EFI_LBA Lba,
- IN UINTN Length,
- IN UINT32 *Buffer
- );
-
-typedef
-EFI_STATUS
-(EFIAPI *MMC_SETIOS) (
- IN EFI_MMC_HOST_PROTOCOL *This,
- IN UINT32 BusClockFreq,
- IN UINT32 BusWidth,
- IN UINT32 TimingMode
- );
-
-typedef
-BOOLEAN
-(EFIAPI *MMC_ISMULTIBLOCK) (
- IN EFI_MMC_HOST_PROTOCOL *This
- );
-
-struct _EFI_MMC_HOST_PROTOCOL {
- UINT32 Revision;
- MMC_ISCARDPRESENT IsCardPresent;
- MMC_ISREADONLY IsReadOnly;
- MMC_BUILDDEVICEPATH BuildDevicePath;
-
- MMC_NOTIFYSTATE NotifyState;
-
- MMC_SENDCOMMAND SendCommand;
- MMC_RECEIVERESPONSE ReceiveResponse;
-
- MMC_READBLOCKDATA ReadBlockData;
- MMC_WRITEBLOCKDATA WriteBlockData;
-
- MMC_SETIOS SetIos;
- MMC_ISMULTIBLOCK IsMultiBlock;
-};
-
-#define MMC_HOST_PROTOCOL_REVISION 0x00010002 // 1.2
-
-#define MMC_HOST_HAS_SETIOS(Host) (Host->Revision >= MMC_HOST_PROTOCOL_REVISION && \
- Host->SetIos != NULL)
-#define MMC_HOST_HAS_ISMULTIBLOCK(Host) (Host->Revision >= MMC_HOST_PROTOCOL_REVISION && \
- Host->IsMultiBlock != NULL)
-
-#endif /* __RASPBERRY_PI_MMC_HOST_PROTOCOL_H__ */
diff --git a/Platform/RaspberryPi/RPi3/Library/MemoryInitPeiLib/MemoryInitPeiLib.c b/Platform/RaspberryPi/RPi3/Library/MemoryInitPeiLib/MemoryInitPeiLib.c
deleted file mode 100644
index 60cf397f..00000000
--- a/Platform/RaspberryPi/RPi3/Library/MemoryInitPeiLib/MemoryInitPeiLib.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/** @file
- *
- * Copyright (c) 2017-2018, Andrey Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2011-2015, ARM Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <PiPei.h>
-
-#include <Library/ArmMmuLib.h>
-#include <Library/ArmPlatformLib.h>
-#include <Library/DebugLib.h>
-#include <Library/HobLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
-
-extern UINT64 mSystemMemoryEnd;
-
-VOID
-BuildMemoryTypeInformationHob (
- VOID
- );
-
-STATIC
-VOID
-InitMmu (
- IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable
- )
-{
- RETURN_STATUS Status;
-
- //Note: Because we called PeiServicesInstallPeiMemory() before to call InitMmu() the MMU Page Table
- // resides in DRAM (even at the top of DRAM as it is the first permanent memory allocation)
- Status = ArmConfigureMmu (MemoryTable, NULL, NULL);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "Error: Failed to enable MMU\n"));
- }
-}
-
-STATIC
-VOID
-AddRuntimeServicesRegion (
- IN ARM_MEMORY_REGION_DESCRIPTOR *Desc
-)
-{
- BuildResourceDescriptorHob (
- EFI_RESOURCE_SYSTEM_MEMORY,
- EFI_RESOURCE_ATTRIBUTE_PRESENT |
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
- EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE |
- EFI_RESOURCE_ATTRIBUTE_TESTED,
- Desc->PhysicalBase,
- Desc->Length
- );
-
- BuildMemoryAllocationHob (
- Desc->PhysicalBase,
- Desc->Length,
- EfiRuntimeServicesData
- );
-}
-
-STATIC
-VOID
-AddReservedMemoryRegion (
- IN ARM_MEMORY_REGION_DESCRIPTOR *Desc
- )
-{
- BuildResourceDescriptorHob (
- EFI_RESOURCE_SYSTEM_MEMORY,
- EFI_RESOURCE_ATTRIBUTE_PRESENT |
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
- EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE |
- EFI_RESOURCE_ATTRIBUTE_TESTED,
- Desc->PhysicalBase,
- Desc->Length
- );
-
- BuildMemoryAllocationHob (
- Desc->PhysicalBase,
- Desc->Length,
- EfiReservedMemoryType
- );
-}
-
-/*++
-
-Routine Description:
-
-
-
-Arguments:
-
- FileHandle - Handle of the file being invoked.
- PeiServices - Describes the list of possible PEI Services.
-
-Returns:
-
- Status - EFI_SUCCESS if the boot mode could be set
-
---*/
-EFI_STATUS
-EFIAPI
-MemoryPeim (
- IN EFI_PHYSICAL_ADDRESS UefiMemoryBase,
- IN UINT64 UefiMemorySize
- )
-{
- ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable;
-
- // Get Virtual Memory Map from the Platform Library
- ArmPlatformGetVirtualMemoryMap (&MemoryTable);
-
- // Ensure PcdSystemMemorySize has been set
- ASSERT (PcdGet64 (PcdSystemMemorySize) != 0);
-
- // FD without variable store
- AddReservedMemoryRegion (&MemoryTable[0]);
-
- // Variable store.
- AddRuntimeServicesRegion (&MemoryTable[1]);
-
- // Trusted Firmware region
- AddReservedMemoryRegion (&MemoryTable[2]);
-
- // Usable memory.
- BuildResourceDescriptorHob (
- EFI_RESOURCE_SYSTEM_MEMORY,
- EFI_RESOURCE_ATTRIBUTE_PRESENT |
- EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
- EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
- EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE |
- EFI_RESOURCE_ATTRIBUTE_TESTED,
- MemoryTable[3].PhysicalBase,
- MemoryTable[3].Length
- );
-
- AddReservedMemoryRegion (&MemoryTable[4]);
-
- // Build Memory Allocation Hob
- InitMmu (MemoryTable);
-
- if (FeaturePcdGet (PcdPrePiProduceMemoryTypeInformationHob)) {
- // Optional feature that helps prevent EFI memory map fragmentation.
- BuildMemoryTypeInformationHob ();
- }
-
- return EFI_SUCCESS;
-}
diff --git a/Platform/RaspberryPi/RPi3/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf b/Platform/RaspberryPi/RPi3/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf
deleted file mode 100644
index 0084c010..00000000
--- a/Platform/RaspberryPi/RPi3/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf
+++ /dev/null
@@ -1,45 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2016, Linaro, Ltd. All rights reserved.
-# Copyright (c) 2011-2014, ARM Ltd. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x0001001A
- BASE_NAME = MemoryInitPeiLib
- FILE_GUID = 4bbc9c10-a100-43fb-8311-332ba497d1b4
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = MemoryInitPeiLib|SEC PEIM
-
-[Sources]
- MemoryInitPeiLib.c
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- ArmPkg/ArmPkg.dec
- ArmPlatformPkg/ArmPlatformPkg.dec
-
-[LibraryClasses]
- DebugLib
- HobLib
- ArmMmuLib
- ArmPlatformLib
-
-[Guids]
- gEfiMemoryTypeInformationGuid
-
-[FeaturePcd]
- gEmbeddedTokenSpaceGuid.PcdPrePiProduceMemoryTypeInformationHob
-
-[FixedPcd]
- gArmTokenSpaceGuid.PcdSystemMemoryBase
- gArmTokenSpaceGuid.PcdSystemMemorySize
-
-[Depex]
- TRUE
diff --git a/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.c b/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.c
deleted file mode 100644
index 12c3829d..00000000
--- a/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.c
+++ /dev/null
@@ -1,788 +0,0 @@
-/** @file
- *
- * Copyright (c) 2018, Pete Batard <pete@akeo.ie>
- * Copyright (c) 2017-2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2016, Linaro Ltd. All rights reserved.
- * Copyright (c) 2015-2016, Red Hat, Inc.
- * Copyright (c) 2014, ARM Ltd. All rights reserved.
- * Copyright (c) 2004-2016, Intel Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <Library/BootLogoLib.h>
-#include <Library/CapsuleLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/HobLib.h>
-#include <Library/PcdLib.h>
-#include <Library/UefiBootManagerLib.h>
-#include <Library/UefiLib.h>
-#include <Library/PrintLib.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/EsrtManagement.h>
-#include <Protocol/GraphicsOutput.h>
-#include <Protocol/LoadedImage.h>
-#include <Guid/EventGroup.h>
-#include <Guid/TtyTerm.h>
-#include <Protocol/BootLogo.h>
-
-#include "PlatformBm.h"
-
-#define BOOT_PROMPT L"ESC (setup), F1 (shell), ENTER (boot)"
-
-#define DP_NODE_LEN(Type) { (UINT8)sizeof (Type), (UINT8)(sizeof (Type) >> 8) }
-
-#pragma pack (1)
-typedef struct {
- VENDOR_DEVICE_PATH SerialDxe;
- UART_DEVICE_PATH Uart;
- VENDOR_DEFINED_DEVICE_PATH TermType;
- EFI_DEVICE_PATH_PROTOCOL End;
-} PLATFORM_SERIAL_CONSOLE;
-#pragma pack ()
-
-typedef struct {
- VENDOR_DEVICE_PATH Custom;
- USB_DEVICE_PATH Hub;
- USB_DEVICE_PATH Dev;
- EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
-} PLATFORM_USB_DEV;
-
-typedef struct {
- VENDOR_DEVICE_PATH Custom;
- EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
-} PLATFORM_SD_DEV;
-
-#define ARASAN_MMC_DXE_FILE_GUID \
- { 0x100c2cfa, 0xb586, 0x4198, { 0x9b, 0x4c, 0x16, 0x83, 0xd1, 0x95, 0xb1, 0xda } }
-
-#define SDHOST_MMC_DXE_FILE_GUID \
- { 0x58abd787, 0xf64d, 0x4ca2, { 0xa0, 0x34, 0xb9, 0xac, 0x2d, 0x5a, 0xd0, 0xcf } }
-
-#define SERIAL_DXE_FILE_GUID \
- { 0xD3987D4B, 0x971A, 0x435F, { 0x8C, 0xAF, 0x49, 0x67, 0xEB, 0x62, 0x72, 0x41 } }
-
-STATIC PLATFORM_SD_DEV mArasan = {
- //
- // VENDOR_DEVICE_PATH ArasanMMCHostDxe
- //
- {
- { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DP_NODE_LEN (VENDOR_DEVICE_PATH) },
- ARASAN_MMC_DXE_FILE_GUID
- },
-
- //
- // EFI_DEVICE_PATH_PROTOCOL End
- //
- {
- END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
- DP_NODE_LEN (EFI_DEVICE_PATH_PROTOCOL)
- }
-};
-
-STATIC PLATFORM_SD_DEV mSDHost = {
- //
- // VENDOR_DEVICE_PATH SdHostDxe
- //
- {
- { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DP_NODE_LEN (VENDOR_DEVICE_PATH) },
- SDHOST_MMC_DXE_FILE_GUID
- },
-
- //
- // EFI_DEVICE_PATH_PROTOCOL End
- //
- {
- END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
- DP_NODE_LEN (EFI_DEVICE_PATH_PROTOCOL)
- }
-};
-
-STATIC PLATFORM_SERIAL_CONSOLE mSerialConsole = {
- //
- // VENDOR_DEVICE_PATH SerialDxe
- //
- {
- { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DP_NODE_LEN (VENDOR_DEVICE_PATH) },
- SERIAL_DXE_FILE_GUID
- },
-
- //
- // UART_DEVICE_PATH Uart
- //
- {
- { MESSAGING_DEVICE_PATH, MSG_UART_DP, DP_NODE_LEN (UART_DEVICE_PATH) },
- 0, // Reserved
- FixedPcdGet64 (PcdUartDefaultBaudRate), // BaudRate
- FixedPcdGet8 (PcdUartDefaultDataBits), // DataBits
- FixedPcdGet8 (PcdUartDefaultParity), // Parity
- FixedPcdGet8 (PcdUartDefaultStopBits) // StopBits
- },
-
- //
- // VENDOR_DEFINED_DEVICE_PATH TermType
- //
- {
- {
- MESSAGING_DEVICE_PATH, MSG_VENDOR_DP,
- DP_NODE_LEN (VENDOR_DEFINED_DEVICE_PATH)
- }
- //
- // Guid to be filled in dynamically
- //
- },
-
- //
- // EFI_DEVICE_PATH_PROTOCOL End
- //
- {
- END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
- DP_NODE_LEN (EFI_DEVICE_PATH_PROTOCOL)
- }
-};
-
-
-#pragma pack (1)
-typedef struct {
- USB_CLASS_DEVICE_PATH Keyboard;
- EFI_DEVICE_PATH_PROTOCOL End;
-} PLATFORM_USB_KEYBOARD;
-#pragma pack ()
-
-STATIC PLATFORM_USB_KEYBOARD mUsbKeyboard = {
- //
- // USB_CLASS_DEVICE_PATH Keyboard
- //
- {
- {
- MESSAGING_DEVICE_PATH, MSG_USB_CLASS_DP,
- DP_NODE_LEN (USB_CLASS_DEVICE_PATH)
- },
- 0xFFFF, // VendorId: any
- 0xFFFF, // ProductId: any
- 3, // DeviceClass: HID
- 1, // DeviceSubClass: boot
- 1 // DeviceProtocol: keyboard
- },
-
- //
- // EFI_DEVICE_PATH_PROTOCOL End
- //
- {
- END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
- DP_NODE_LEN (EFI_DEVICE_PATH_PROTOCOL)
- }
-};
-
-STATIC EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *mSerialConProtocol;
-
-/**
- Check if the handle satisfies a particular condition.
-
- @param[in] Handle The handle to check.
- @param[in] ReportText A caller-allocated string passed in for reporting
- purposes. It must never be NULL.
-
- @retval TRUE The condition is satisfied.
- @retval FALSE Otherwise. This includes the case when the condition could not
- be fully evaluated due to an error.
-**/
-typedef
-BOOLEAN
-(EFIAPI *FILTER_FUNCTION) (
- IN EFI_HANDLE Handle,
- IN CONST CHAR16 *ReportText
- );
-
-
-/**
- Process a handle.
-
- @param[in] Handle The handle to process.
- @param[in] ReportText A caller-allocated string passed in for reporting
- purposes. It must never be NULL.
-**/
-typedef
-VOID
-(EFIAPI *CALLBACK_FUNCTION) (
- IN EFI_HANDLE Handle,
- IN CONST CHAR16 *ReportText
- );
-
-/**
- Locate all handles that carry the specified protocol, filter them with a
- callback function, and pass each handle that passes the filter to another
- callback.
-
- @param[in] ProtocolGuid The protocol to look for.
-
- @param[in] Filter The filter function to pass each handle to. If this
- parameter is NULL, then all handles are processed.
-
- @param[in] Process The callback function to pass each handle to that
- clears the filter.
-**/
-STATIC
-VOID
-FilterAndProcess (
- IN EFI_GUID *ProtocolGuid,
- IN FILTER_FUNCTION Filter OPTIONAL,
- IN CALLBACK_FUNCTION Process
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE *Handles;
- UINTN NoHandles;
- UINTN Idx;
-
- Status = gBS->LocateHandleBuffer (ByProtocol, ProtocolGuid,
- NULL /* SearchKey */, &NoHandles, &Handles);
- if (EFI_ERROR (Status)) {
- //
- // This is not an error, just an informative condition.
- //
- DEBUG ((DEBUG_VERBOSE, "%a: %g: %r\n", __FUNCTION__, ProtocolGuid,
- Status));
- return;
- }
-
- ASSERT (NoHandles > 0);
- for (Idx = 0; Idx < NoHandles; ++Idx) {
- CHAR16 *DevicePathText;
- STATIC CHAR16 Fallback[] = L"<device path unavailable>";
-
- //
- // The ConvertDevicePathToText() function handles NULL input transparently.
- //
- DevicePathText = ConvertDevicePathToText (
- DevicePathFromHandle (Handles[Idx]),
- FALSE, // DisplayOnly
- FALSE // AllowShortcuts
- );
- if (DevicePathText == NULL) {
- DevicePathText = Fallback;
- }
-
- if (Filter == NULL || Filter (Handles[Idx], DevicePathText)) {
- Process (Handles[Idx], DevicePathText);
- }
-
- if (DevicePathText != Fallback) {
- FreePool (DevicePathText);
- }
- }
- gBS->FreePool (Handles);
-}
-
-/**
- This CALLBACK_FUNCTION retrieves the EFI_DEVICE_PATH_PROTOCOL from the
- handle, and adds it to ConOut and ErrOut.
-**/
-STATIC
-VOID
-EFIAPI
-AddOutput (
- IN EFI_HANDLE Handle,
- IN CONST CHAR16 *ReportText
- )
-{
- EFI_STATUS Status;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
-
- DevicePath = DevicePathFromHandle (Handle);
- if (DevicePath == NULL) {
- DEBUG ((DEBUG_ERROR, "%a: %s: handle %p: device path not found\n",
- __FUNCTION__, ReportText, Handle));
- return;
- }
-
- Status = EfiBootManagerUpdateConsoleVariable (ConOut, DevicePath, NULL);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: %s: adding to ConOut: %r\n", __FUNCTION__,
- ReportText, Status));
- return;
- }
-
- Status = EfiBootManagerUpdateConsoleVariable (ErrOut, DevicePath, NULL);
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: %s: adding to ErrOut: %r\n", __FUNCTION__,
- ReportText, Status));
- return;
- }
-
- DEBUG ((DEBUG_VERBOSE, "%a: %s: added to ConOut and ErrOut\n", __FUNCTION__,
- ReportText));
-}
-
-STATIC
-INTN
-PlatformRegisterBootOption (
- EFI_DEVICE_PATH_PROTOCOL *DevicePath,
- CHAR16 *Description,
- UINT32 Attributes
- )
-{
- EFI_STATUS Status;
- INTN OptionIndex;
- EFI_BOOT_MANAGER_LOAD_OPTION NewOption;
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
- UINTN BootOptionCount;
-
- Status = EfiBootManagerInitializeLoadOption (
- &NewOption,
- LoadOptionNumberUnassigned,
- LoadOptionTypeBoot,
- Attributes,
- Description,
- DevicePath,
- NULL,
- 0
- );
- ASSERT_EFI_ERROR (Status);
-
- BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
-
- OptionIndex = EfiBootManagerFindLoadOption (&NewOption, BootOptions, BootOptionCount);
-
- if (OptionIndex == -1) {
- Status = EfiBootManagerAddLoadOptionVariable (&NewOption, MAX_UINTN);
- ASSERT_EFI_ERROR (Status);
- OptionIndex = BootOptionCount;
- }
-
- EfiBootManagerFreeLoadOption (&NewOption);
- EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
-
- return OptionIndex;
-}
-
-STATIC
-INTN
-PlatformRegisterFvBootOption (
- CONST EFI_GUID *FileGuid,
- CHAR16 *Description,
- UINT32 Attributes
- )
-{
- EFI_STATUS Status;
- MEDIA_FW_VOL_FILEPATH_DEVICE_PATH FileNode;
- EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
- INTN OptionIndex;
-
- Status = gBS->HandleProtocol (
- gImageHandle,
- &gEfiLoadedImageProtocolGuid,
- (VOID**)&LoadedImage
- );
- ASSERT_EFI_ERROR (Status);
-
- EfiInitializeFwVolDevicepathNode (&FileNode, FileGuid);
- DevicePath = DevicePathFromHandle (LoadedImage->DeviceHandle);
- ASSERT (DevicePath != NULL);
- DevicePath = AppendDevicePathNode (DevicePath, (EFI_DEVICE_PATH_PROTOCOL*)&FileNode);
- ASSERT (DevicePath != NULL);
-
- OptionIndex = PlatformRegisterBootOption (DevicePath, Description, Attributes);
- FreePool (DevicePath);
-
- return OptionIndex;
-}
-
-STATIC
-VOID
-RemoveStaleBootOptions (
- VOID
-)
-{
- EFI_BOOT_MANAGER_LOAD_OPTION *BootOptions;
- UINTN BootOptionCount;
- UINTN Index;
- EFI_STATUS Status;
-
- BootOptions = EfiBootManagerGetLoadOptions (&BootOptionCount,
- LoadOptionTypeBoot);
-
- for (Index = 0; Index < BootOptionCount; ++Index) {
- EFI_DEVICE_PATH_PROTOCOL *DevicePath = BootOptions[Index].FilePath;
-
- if (CompareMem (&mArasan, DevicePath, GetDevicePathSize (DevicePath)) == 0) {
- if (PcdGet32 (PcdSdIsArasan)) {
- continue;
- }
- } else if (CompareMem (&mSDHost, DevicePath, GetDevicePathSize (DevicePath)) == 0) {
- if (!PcdGet32 (PcdSdIsArasan)) {
- continue;
- }
- } else {
- continue;
- }
-
- //
- // Delete the boot options corresponding to stale SD controllers.
- //
- Status = EfiBootManagerDeleteLoadOptionVariable (
- BootOptions[Index].OptionNumber, LoadOptionTypeBoot);
- DEBUG_CODE (
- CHAR16 *DevicePathString;
-
- DevicePathString = ConvertDevicePathToText(BootOptions[Index].FilePath, FALSE, FALSE);
- DEBUG ((
- EFI_ERROR (Status) ? EFI_D_WARN : EFI_D_INFO,
- "%a: removing stale Boot#%04x %s: %r\n",
- __FUNCTION__,
- (UINT32)BootOptions[Index].OptionNumber,
- DevicePathString == NULL ? L"<unavailable>" : DevicePathString,
- Status
- ));
- if (DevicePathString != NULL) {
- FreePool (DevicePathString);
- }
- );
- }
-
- EfiBootManagerFreeLoadOptions (BootOptions, BootOptionCount);
-}
-
-STATIC
-VOID
-PlatformRegisterOptionsAndKeys (
- VOID
- )
-{
- EFI_STATUS Status;
- EFI_INPUT_KEY Enter;
- EFI_INPUT_KEY F1;
- EFI_INPUT_KEY Esc;
- EFI_BOOT_MANAGER_LOAD_OPTION BootOption;
- INTN ShellOption;
-
- RemoveStaleBootOptions ();
-
- ShellOption = PlatformRegisterFvBootOption (&gUefiShellFileGuid,
- L"UEFI Shell", LOAD_OPTION_CATEGORY_APP);
- if (ShellOption != -1) {
- //
- // F1 boots Shell.
- //
- F1.ScanCode = SCAN_F1;
- F1.UnicodeChar = CHAR_NULL;
- Status = EfiBootManagerAddKeyOptionVariable (NULL, (UINT16)ShellOption, 0, &F1, NULL);
- ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
- }
-
- //
- // Register ENTER as CONTINUE key
- //
- Enter.ScanCode = SCAN_NULL;
- Enter.UnicodeChar = CHAR_CARRIAGE_RETURN;
- Status = EfiBootManagerRegisterContinueKeyOption (0, &Enter, NULL);
- ASSERT_EFI_ERROR (Status);
-
- //
- // Map ESC to Boot Manager Menu
- //
- Esc.ScanCode = SCAN_ESC;
- Esc.UnicodeChar = CHAR_NULL;
- Status = EfiBootManagerGetBootManagerMenu (&BootOption);
- ASSERT_EFI_ERROR (Status);
- Status = EfiBootManagerAddKeyOptionVariable (NULL, (UINT16)BootOption.OptionNumber, 0, &Esc, NULL);
- ASSERT (Status == EFI_SUCCESS || Status == EFI_ALREADY_STARTED);
-}
-
-STATIC VOID
-SerialConPrint (
- IN CHAR16 *Text
- )
-{
- if (mSerialConProtocol != NULL) {
- mSerialConProtocol->OutputString (mSerialConProtocol, Text);
- }
-}
-
-STATIC
-VOID
-EFIAPI
-ExitBootServicesHandler (
- IN EFI_EVENT Event,
- IN VOID *Context
- )
-{
- EFI_STATUS Status;
- //
- // Long enough to occlude the string printed
- // in PlatformBootManagerWaitCallback.
- //
- STATIC CHAR16 *OsBootStr = L"Exiting UEFI and booting EL2 OS kernel!\r\n";
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Green;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Yellow;
-
- if (!PcdGet32 (PcdDebugShowUEFIExit)) {
- return;
- }
-
- Green.Raw = 0x00007F00;
- Black.Raw = 0x00000000;
- Yellow.Raw = 0x00FFFF00;
-
- Status = BootLogoUpdateProgress (Yellow.Pixel,
- Black.Pixel,
- OsBootStr,
- Green.Pixel,
- 100, 0);
- if (Status == EFI_SUCCESS) {
- SerialConPrint (OsBootStr);
- } else {
- Print (L"\n");
- Print (OsBootStr);
- Print (L"\n");
- }
-}
-
-//
-// BDS Platform Functions
-//
-/**
- Do the platform init, can be customized by OEM/IBV
- Possible things that can be done in PlatformBootManagerBeforeConsole:
- > Update console variable: 1. include hot-plug devices;
- > 2. Clear ConIn and add SOL for AMT
- > Register new Driver#### or Boot####
- > Register new Key####: e.g.: F12
- > Signal ReadyToLock event
- > Authentication action: 1. connect Auth devices;
- > 2. Identify auto logon user.
-**/
-VOID
-EFIAPI
-PlatformBootManagerBeforeConsole (
- VOID
- )
-{
- EFI_STATUS Status;
- EFI_EVENT ExitBSEvent;
- ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;
-
- Status = gBS->CreateEventEx (
- EVT_NOTIFY_SIGNAL,
- TPL_NOTIFY,
- ExitBootServicesHandler,
- NULL,
- &gEfiEventExitBootServicesGuid,
- &ExitBSEvent
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_ERROR, "%a: failed to register ExitBootServices handler\n", __FUNCTION__));
- }
-
- if (GetBootModeHob () == BOOT_ON_FLASH_UPDATE) {
- DEBUG ((DEBUG_INFO, "ProcessCapsules Before EndOfDxe ......\n"));
- Status = ProcessCapsules ();
- DEBUG ((DEBUG_INFO, "ProcessCapsules returned %r\n", Status));
- } else {
- Status = gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL, (VOID**)&EsrtManagement);
- if (!EFI_ERROR (Status)) {
- EsrtManagement->SyncEsrtFmp ();
- }
- }
-
- //
- // Now add the device path of all handles with GOP on them to ConOut and
- // ErrOut.
- //
- FilterAndProcess (&gEfiGraphicsOutputProtocolGuid, NULL, AddOutput);
-
- //
- // Add the hardcoded short-form USB keyboard device path to ConIn.
- //
- EfiBootManagerUpdateConsoleVariable (ConIn, (EFI_DEVICE_PATH_PROTOCOL*)&mUsbKeyboard, NULL);
-
- //
- // Add the hardcoded serial console device path to ConIn, ConOut, ErrOut.
- //
- ASSERT (FixedPcdGet8 (PcdDefaultTerminalType) == 4);
- CopyGuid (&mSerialConsole.TermType.Guid, &gEfiTtyTermGuid);
-
- EfiBootManagerUpdateConsoleVariable (ConIn, (EFI_DEVICE_PATH_PROTOCOL*)&mSerialConsole, NULL);
- EfiBootManagerUpdateConsoleVariable (ConOut, (EFI_DEVICE_PATH_PROTOCOL*)&mSerialConsole, NULL);
- EfiBootManagerUpdateConsoleVariable (ErrOut, (EFI_DEVICE_PATH_PROTOCOL*)&mSerialConsole, NULL);
-
- //
- // Signal EndOfDxe PI Event
- //
- EfiEventGroupSignal (&gEfiEndOfDxeEventGroupGuid);
-
- //
- // Dispatch deferred images after EndOfDxe event and ReadyToLock installation.
- //
- EfiBootManagerDispatchDeferredImages ();
-}
-
-/**
- Do the platform specific action after the console is ready
- Possible things that can be done in PlatformBootManagerAfterConsole:
- > Console post action:
- > Dynamically switch output mode from 100x31 to 80x25 for certain senarino
- > Signal console ready platform customized event
- > Run diagnostics like memory testing
- > Connect certain devices
- > Dispatch aditional option roms
- > Special boot: e.g.: USB boot, enter UI
-**/
-VOID
-EFIAPI
-PlatformBootManagerAfterConsole (
- VOID
- )
-{
- ESRT_MANAGEMENT_PROTOCOL *EsrtManagement;
- EFI_STATUS Status;
- EFI_HANDLE SerialHandle;
-
- Status = EfiBootManagerConnectDevicePath ((EFI_DEVICE_PATH_PROTOCOL*)&mSerialConsole, &SerialHandle);
- if (Status == EFI_SUCCESS) {
- gBS->HandleProtocol (SerialHandle, &gEfiSimpleTextOutProtocolGuid, (VOID**)&mSerialConProtocol);
- }
-
- //
- // Show the splash screen.
- //
- Status = BootLogoEnableLogo ();
- if (Status == EFI_SUCCESS) {
- SerialConPrint (BOOT_PROMPT);
- } else {
- Print (BOOT_PROMPT);
- }
-
- //
- // Connect the rest of the devices.
- //
- EfiBootManagerConnectAll ();
-
- Status = gBS->LocateProtocol (&gEsrtManagementProtocolGuid, NULL, (VOID**)&EsrtManagement);
- if (!EFI_ERROR (Status)) {
- EsrtManagement->SyncEsrtFmp ();
- }
-
- if (GetBootModeHob () == BOOT_ON_FLASH_UPDATE) {
- DEBUG ((DEBUG_INFO, "ProcessCapsules After EndOfDxe ......\n"));
- Status = ProcessCapsules ();
- DEBUG ((DEBUG_INFO, "ProcessCapsules returned %r\n", Status));
- }
-
- PlatformRegisterOptionsAndKeys ();
-}
-
-/**
- This function is called each second during the boot manager waits the
- timeout.
-
- @param TimeoutRemain The remaining timeout.
-**/
-VOID
-EFIAPI
-PlatformBootManagerWaitCallback (
- IN UINT16 TimeoutRemain
- )
-{
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION Black;
- EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION White;
- UINT16 Timeout;
- EFI_STATUS Status;
- EFI_BOOT_LOGO_PROTOCOL *BootLogo;
-
- Timeout = PcdGet16 (PcdPlatformBootTimeOut);
-
- Black.Raw = 0x00000000;
- White.Raw = 0x00FFFFFF;
-
- Status = BootLogoUpdateProgress (
- White.Pixel,
- Black.Pixel,
- BOOT_PROMPT,
- White.Pixel,
- (Timeout - TimeoutRemain) * 100 / Timeout,
- 0
- );
- if (Status == EFI_SUCCESS) {
- SerialConPrint (L".");
- } else {
- Print (L".");
- }
-
- if (TimeoutRemain == 0) {
- BootLogo = NULL;
-
- //
- // Clear out the boot logo so that Windows displays its own logo
- // instead of ours.
- //
- Status = gBS->LocateProtocol (&gEfiBootLogoProtocolGuid, NULL, (VOID**)&BootLogo);
- if (!EFI_ERROR (Status) && (BootLogo != NULL)) {
- Status = BootLogo->SetBootLogo (BootLogo, NULL, 0, 0, 0, 0);
- ASSERT_EFI_ERROR (Status);
- };
-
- gST->ConOut->ClearScreen (gST->ConOut);
- }
-}
-
-/**
- The function is called when no boot option could be launched,
- including platform recovery options and options pointing to applications
- built into firmware volumes.
- If this function returns, BDS attempts to enter an infinite loop.
-**/
-VOID
-EFIAPI
-PlatformBootManagerUnableToBoot (
- VOID
- )
-{
- EFI_STATUS Status;
- EFI_INPUT_KEY Key;
- EFI_BOOT_MANAGER_LOAD_OPTION BootManagerMenu;
- UINTN Index;
-
- //
- // BootManagerMenu doesn't contain the correct information when return status
- // is EFI_NOT_FOUND.
- //
- Status = EfiBootManagerGetBootManagerMenu (&BootManagerMenu);
- if (EFI_ERROR (Status)) {
- return;
- }
- //
- // Normally BdsDxe does not print anything to the system console, but this is
- // a last resort -- the end-user will likely not see any DEBUG messages
- // logged in this situation.
- //
- // AsciiPrint() will NULL-check gST->ConOut internally. We check gST->ConIn
- // here to see if it makes sense to request and wait for a keypress.
- //
- if (gST->ConIn != NULL) {
- AsciiPrint (
- "%a: No bootable option or device was found.\n"
- "%a: Press any key to enter the Boot Manager Menu.\n",
- gEfiCallerBaseName,
- gEfiCallerBaseName);
- Status = gBS->WaitForEvent (1, &gST->ConIn->WaitForKey, &Index);
- ASSERT_EFI_ERROR (Status);
- ASSERT (Index == 0);
-
- //
- // Drain any queued keys.
- //
- while (!EFI_ERROR (gST->ConIn->ReadKeyStroke (gST->ConIn, &Key))) {
- //
- // just throw away Key
- //
- }
- }
-
- for (;;) {
- EfiBootManagerBoot (&BootManagerMenu);
- }
-}
diff --git a/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.h b/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.h
deleted file mode 100644
index 8408c7fb..00000000
--- a/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBm.h
+++ /dev/null
@@ -1,54 +0,0 @@
-/** @file
- *
- * Copyright (c) 2017-2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2016, Linaro Ltd. All rights reserved.
- * Copyright (c) 2015-2016, Red Hat, Inc.
- * Copyright (c) 2014, ARM Ltd. All rights reserved.
- * Copyright (c) 2004-2016, Intel Corporation. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#ifndef _PLATFORM_BM_H_
-#define _PLATFORM_BM_H_
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-
-/**
- Use SystemTable Conout to stop video based Simple Text Out consoles from
- going to the video device. Put up LogoFile on every video device that is a
- console.
-
- @param[in] LogoFile File name of logo to display on the center of the
- screen.
-
- @retval EFI_SUCCESS ConsoleControl has been flipped to graphics and logo
- displayed.
- @retval EFI_UNSUPPORTED Logo not found
-**/
-EFI_STATUS
-EnableQuietBoot (
- IN EFI_GUID *LogoFile
- );
-
-/**
- Use SystemTable Conout to turn on video based Simple Text Out consoles. The
- Simple Text Out screens will now be synced up with all non video output
- devices
-
- @retval EFI_SUCCESS UGA devices are back in text mode and synced up.
-**/
-EFI_STATUS
-DisableQuietBoot (
- VOID
- );
-
-#endif // _PLATFORM_BM_H_
diff --git a/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
deleted file mode 100644
index e1b132a0..00000000
--- a/Platform/RaspberryPi/RPi3/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ /dev/null
@@ -1,84 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2017-2018, Andrei Warkentin <andrey.warkentin@gmail.com>
-# Copyright (c) 2016, Linaro Ltd. All rights reserved.
-# Copyright (c) 2015-2016, Red Hat, Inc.
-# Copyright (c) 2014, ARM Ltd. All rights reserved.
-# Copyright (c) 2007-2014, Intel Corporation. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x0001001A
- BASE_NAME = PlatformBootManagerLib
- FILE_GUID = 92FD2DE3-B9CB-4B35-8141-42AD34D73C9F
- 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 = AARCH64
-#
-
-[Sources]
- PlatformBm.h
- PlatformBm.c
-
-[Packages]
- MdeModulePkg/MdeModulePkg.dec
- MdePkg/MdePkg.dec
- ShellPkg/ShellPkg.dec
- Platform/RaspberryPi/RPi3/RPi3.dec
-
-[LibraryClasses]
- BaseLib
- BaseMemoryLib
- BootLogoLib
- CapsuleLib
- DebugLib
- DevicePathLib
- DxeServicesLib
- HobLib
- MemoryAllocationLib
- PcdLib
- PrintLib
- UefiBootManagerLib
- UefiBootServicesTableLib
- UefiLib
-
-[FeaturePcd]
- gEfiMdePkgTokenSpaceGuid.PcdUgaConsumeSupport
-
-[FixedPcd]
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultBaudRate
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultDataBits
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultParity
- gEfiMdePkgTokenSpaceGuid.PcdUartDefaultStopBits
- gEfiMdePkgTokenSpaceGuid.PcdDefaultTerminalType
-
-[Pcd]
- gEfiMdePkgTokenSpaceGuid.PcdPlatformBootTimeOut
- gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit
- gRaspberryPiTokenSpaceGuid.PcdSdIsArasan
-
-[Guids]
- gEfiFileInfoGuid
- gEfiFileSystemInfoGuid
- gEfiFileSystemVolumeLabelInfoIdGuid
- gEfiEndOfDxeEventGroupGuid
- gEfiTtyTermGuid
- gUefiShellFileGuid
- gEfiEventExitBootServicesGuid
-
-[Protocols]
- gEfiDevicePathProtocolGuid
- gEfiGraphicsOutputProtocolGuid
- gEfiLoadedImageProtocolGuid
- gEfiSimpleFileSystemProtocolGuid
- gEsrtManagementProtocolGuid
- gEfiUsb2HcProtocolGuid
- gEfiBootLogoProtocolGuid
diff --git a/Platform/RaspberryPi/RPi3/Library/PlatformLib/AArch64/RaspberryPiHelper.S b/Platform/RaspberryPi/RPi3/Library/PlatformLib/AArch64/RaspberryPiHelper.S
deleted file mode 100644
index 36af208d..00000000
--- a/Platform/RaspberryPi/RPi3/Library/PlatformLib/AArch64/RaspberryPiHelper.S
+++ /dev/null
@@ -1,101 +0,0 @@
-/** @file
- *
- * Copyright (c) 2016, Linaro Limited. All rights reserved.
- * Copyright (c) 2011-2013, ARM Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <AsmMacroIoLibV8.h>
-#include <Library/ArmLib.h>
-#include <IndustryStandard/Bcm2836.h>
-#include <IndustryStandard/RpiMbox.h>
-
-#define MAX_TRIES 0x100000
-
- .macro drain
- mov x5, #MAX_TRIES
-0: ldr w6, [x4, #BCM2836_MBOX_STATUS_OFFSET]
- tbnz w6, #BCM2836_MBOX_STATUS_EMPTY, 1f
- dmb ld
- ldr wzr, [x4, #BCM2836_MBOX_READ_OFFSET]
- subs x5, x5, #1
- b.ne 0b
-1:
- .endm
-
- .macro poll, status
- mov x5, #MAX_TRIES
-0: ldr w6, [x4, #BCM2836_MBOX_STATUS_OFFSET]
- tbz w6, #\status, 1f
- dmb ld
- subs x5, x5, #1
- b.ne 0b
-1:
- .endm
-
-ASM_FUNC (ArmPlatformPeiBootAction)
- adr x0, .Lmeminfo_buffer
- mov x1, #FixedPcdGet64 (PcdDmaDeviceOffset)
- orr x0, x0, #RPI_MBOX_VC_CHANNEL
- add x0, x0, x1
-
- MOV32 (x4, BCM2836_MBOX_BASE_ADDRESS)
-
- drain
- poll BCM2836_MBOX_STATUS_FULL
- str w0, [x4, #BCM2836_MBOX_WRITE_OFFSET]
- dmb sy
- poll BCM2836_MBOX_STATUS_EMPTY
- dmb sy
- ldr wzr, [x4, #BCM2836_MBOX_READ_OFFSET]
- dmb ld
-
- ldr w0, .Lmemsize
- sub x0, x0, #1
- adr x1, mSystemMemoryEnd
- str x0, [x1]
- ret
-
- .align 4
-.Lmeminfo_buffer:
- .long .Lbuffer_size
- .long 0x0
- .long RPI_MBOX_GET_ARM_MEMSIZE
- .long 8 // buf size
- .long 0 // input len
- .long 0 // mem base
-.Lmemsize:
- .long 0 // mem size
- .long 0 // end tag
- .set .Lbuffer_size, . - .Lmeminfo_buffer
-
-//UINTN
-//ArmPlatformGetPrimaryCoreMpId (
-// VOID
-// );
-ASM_FUNC (ArmPlatformGetPrimaryCoreMpId)
- MOV32 (w0, FixedPcdGet32 (PcdArmPrimaryCore))
- ret
-
-//UINTN
-//ArmPlatformIsPrimaryCore (
-// IN UINTN MpId
-// );
-ASM_FUNC (ArmPlatformIsPrimaryCore)
- mov x0, #1
- ret
-
-//UINTN
-//ArmPlatformGetCorePosition (
-// IN UINTN MpId
-// );
-// With this function: CorePos = (ClusterId * 4) + CoreId
-ASM_FUNC (ArmPlatformGetCorePosition)
- and x1, x0, #ARM_CORE_MASK
- and x0, x0, #ARM_CLUSTER_MASK
- add x0, x1, x0, LSR #6
- ret
-
-ASM_FUNCTION_REMOVE_IF_UNREFERENCED
diff --git a/Platform/RaspberryPi/RPi3/Library/PlatformLib/PlatformLib.inf b/Platform/RaspberryPi/RPi3/Library/PlatformLib/PlatformLib.inf
deleted file mode 100644
index 5c1f55e2..00000000
--- a/Platform/RaspberryPi/RPi3/Library/PlatformLib/PlatformLib.inf
+++ /dev/null
@@ -1,59 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2017-2018, Andrei Warkentin <andrey.warkentin@gmail.com>
-# Copyright (c) 2014-2016, Linaro Limited. All rights reserved.
-# Copyright (c) 2011-2014, ARM Limited. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x0001001A
- BASE_NAME = PlatformLib
- FILE_GUID = 050182ef-f708-4148-b4bc-256cabf74fea
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = ArmPlatformLib|SEC PEIM
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- ArmPkg/ArmPkg.dec
- ArmPlatformPkg/ArmPlatformPkg.dec
- Silicon/Broadcom/Bcm283x/Bcm283x.dec
- Platform/RaspberryPi/RPi3/RPi3.dec
-
-[LibraryClasses]
- ArmLib
- FdtLib
- IoLib
- MemoryAllocationLib
- PcdLib
- PrintLib
-
-[Sources.common]
- RaspberryPi.c
- RaspberryPiMem.c
-
-[Sources.AARCH64]
- AArch64/RaspberryPiHelper.S
-
-[FixedPcd]
- gArmTokenSpaceGuid.PcdFdBaseAddress
- gArmTokenSpaceGuid.PcdFvBaseAddress
- gArmPlatformTokenSpaceGuid.PcdCoreCount
- gArmTokenSpaceGuid.PcdArmPrimaryCoreMask
- gArmTokenSpaceGuid.PcdArmPrimaryCore
- gArmTokenSpaceGuid.PcdFdSize
- gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset
- gArmTokenSpaceGuid.PcdSystemMemoryBase
- gArmTokenSpaceGuid.PcdSystemMemorySize
- gRaspberryPiTokenSpaceGuid.PcdNvStorageEventLogSize
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingSize
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize
-
-[Ppis]
- gArmMpCoreInfoPpiGuid
diff --git a/Platform/RaspberryPi/RPi3/Library/PlatformLib/RaspberryPi.c b/Platform/RaspberryPi/RPi3/Library/PlatformLib/RaspberryPi.c
deleted file mode 100644
index f032f3c7..00000000
--- a/Platform/RaspberryPi/RPi3/Library/PlatformLib/RaspberryPi.c
+++ /dev/null
@@ -1,93 +0,0 @@
-/** @file
- *
- * Copyright (c) 2014-2016, Linaro Limited. All rights reserved.
- * Copyright (c) 2014, Red Hat, Inc.
- * Copyright (c) 2011-2013, ARM Limited. All rights reserved.
- *
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <Library/IoLib.h>
-#include <Library/ArmPlatformLib.h>
-#include <Library/DebugLib.h>
-#include <Pi/PiBootMode.h>
-
-#include <Ppi/ArmMpCoreInfo.h>
-
-/**
- Return the current Boot Mode
-
- This function returns the boot reason on the platform
-
- @return Return the current Boot Mode of the platform
-
-**/
-EFI_BOOT_MODE
-ArmPlatformGetBootMode (
- VOID
- )
-{
- return BOOT_WITH_FULL_CONFIGURATION;
-}
-
-/**
- This function is called by PrePeiCore, in the SEC phase.
-**/
-RETURN_STATUS
-ArmPlatformInitialize (
- IN UINTN MpId
- )
-{
- return RETURN_SUCCESS;
-}
-
-VOID
-ArmPlatformInitializeSystemMemory (
- VOID
- )
-{
-}
-
-STATIC ARM_CORE_INFO mRpi3InfoTable[] = {
- { 0x0, 0x0, }, // Cluster 0, Core 0
- { 0x0, 0x1, }, // Cluster 0, Core 1
- { 0x0, 0x2, }, // Cluster 0, Core 2
- { 0x0, 0x3, }, // Cluster 0, Core 3
-};
-
-STATIC
-EFI_STATUS
-PrePeiCoreGetMpCoreInfo (
- OUT UINTN *CoreCount,
- OUT ARM_CORE_INFO **ArmCoreTable
- )
-{
- // Only support one cluster
- *CoreCount = sizeof (mRpi3InfoTable) / sizeof (ARM_CORE_INFO);
- *ArmCoreTable = mRpi3InfoTable;
-
- return EFI_SUCCESS;
-}
-
-STATIC ARM_MP_CORE_INFO_PPI mMpCoreInfoPpi = {
- PrePeiCoreGetMpCoreInfo
-};
-STATIC EFI_PEI_PPI_DESCRIPTOR mPlatformPpiTable[] = {
- {
- EFI_PEI_PPI_DESCRIPTOR_PPI,
- &gArmMpCoreInfoPpiGuid,
- &mMpCoreInfoPpi
- }
-};
-
-VOID
-ArmPlatformGetPlatformPpiList (
- OUT UINTN *PpiListSize,
- OUT EFI_PEI_PPI_DESCRIPTOR **PpiList
- )
-{
- *PpiListSize = sizeof (mPlatformPpiTable);
- *PpiList = mPlatformPpiTable;
-}
diff --git a/Platform/RaspberryPi/RPi3/Library/PlatformLib/RaspberryPiMem.c b/Platform/RaspberryPi/RPi3/Library/PlatformLib/RaspberryPiMem.c
deleted file mode 100644
index 97d5af52..00000000
--- a/Platform/RaspberryPi/RPi3/Library/PlatformLib/RaspberryPiMem.c
+++ /dev/null
@@ -1,154 +0,0 @@
-/** @file
- *
- * Copyright (c) 2017-2018, Andrey Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2014, Linaro Limited. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <Library/ArmPlatformLib.h>
-#include <Library/DebugLib.h>
-#include <IndustryStandard/Bcm2836.h>
-#include <Library/PcdLib.h>
-
-extern UINT64 mSystemMemoryEnd;
-extern UINT64 mGPUMemoryBase;
-extern UINT64 mGPUMemoryLength;
-
-#define VariablesSize (FixedPcdGet32(PcdFlashNvStorageVariableSize) + \
- FixedPcdGet32(PcdFlashNvStorageFtwWorkingSize) + \
- FixedPcdGet32(PcdFlashNvStorageFtwSpareSize) + \
- FixedPcdGet32(PcdNvStorageEventLogSize))
-
-#define VariablesBase (FixedPcdGet64(PcdFdBaseAddress) + \
- FixedPcdGet32(PcdFdSize) - \
- VariablesSize)
-
-#define ATFBase (FixedPcdGet64(PcdFdBaseAddress) + FixedPcdGet32(PcdFdSize))
-
-STATIC ARM_MEMORY_REGION_DESCRIPTOR RaspberryPiMemoryRegionDescriptor[] = {
- {
- /* Firmware Volume. */
- FixedPcdGet64 (PcdFdBaseAddress), FixedPcdGet64 (PcdFdBaseAddress),
- FixedPcdGet32 (PcdFdSize) - VariablesSize,
- ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
- },
- {
- /* Variables Volume. */
- VariablesBase, VariablesBase,
- VariablesSize,
- ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
- },
- {
- /* ATF reserved RAM. */
- ATFBase, ATFBase,
- FixedPcdGet64 (PcdSystemMemoryBase) - ATFBase,
- ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
- },
- {
- /* System RAM. */
- FixedPcdGet64 (PcdSystemMemoryBase), FixedPcdGet64 (PcdSystemMemoryBase),
- 0,
- ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK
- },
- {
- /* Reserved GPU RAM. */
- 0,
- 0,
- 0,
- ARM_MEMORY_REGION_ATTRIBUTE_DEVICE
- },
- {
- /* SOC registers. */
- BCM2836_SOC_REGISTERS,
- BCM2836_SOC_REGISTERS,
- BCM2836_SOC_REGISTER_LENGTH,
- ARM_MEMORY_REGION_ATTRIBUTE_DEVICE
- },
- {
- }
-};
-
-/**
- Return the Virtual Memory Map of your platform
-
- This Virtual Memory Map is used by MemoryInitPei Module to initialize the MMU
- on your platform.
-
- @param[out] VirtualMemoryMap Array of ARM_MEMORY_REGION_DESCRIPTOR
- describing a Physical-to-Virtual Memory
- mapping. This array must be ended by a
- zero-filled entry
-
-**/
-VOID
-ArmPlatformGetVirtualMemoryMap (
- IN ARM_MEMORY_REGION_DESCRIPTOR** VirtualMemoryMap
- )
-{
- RaspberryPiMemoryRegionDescriptor[3].Length = mSystemMemoryEnd + 1 -
- FixedPcdGet64 (PcdSystemMemoryBase);
-
- RaspberryPiMemoryRegionDescriptor[4].PhysicalBase =
- RaspberryPiMemoryRegionDescriptor[3].PhysicalBase +
- RaspberryPiMemoryRegionDescriptor[3].Length;
-
- RaspberryPiMemoryRegionDescriptor[4].VirtualBase =
- RaspberryPiMemoryRegionDescriptor[4].PhysicalBase;
-
- RaspberryPiMemoryRegionDescriptor[4].Length =
- RaspberryPiMemoryRegionDescriptor[5].PhysicalBase -
- RaspberryPiMemoryRegionDescriptor[4].PhysicalBase;
-
- DEBUG ((DEBUG_INFO, "FD:\n"
- "\tPhysicalBase: 0x%lX\n"
- "\tVirtualBase: 0x%lX\n"
- "\tLength: 0x%lX\n",
- RaspberryPiMemoryRegionDescriptor[0].PhysicalBase,
- RaspberryPiMemoryRegionDescriptor[0].VirtualBase,
- RaspberryPiMemoryRegionDescriptor[0].Length +
- RaspberryPiMemoryRegionDescriptor[1].Length));
-
- DEBUG ((DEBUG_INFO, "Variables (part of FD):\n"
- "\tPhysicalBase: 0x%lX\n"
- "\tVirtualBase: 0x%lX\n"
- "\tLength: 0x%lX\n",
- RaspberryPiMemoryRegionDescriptor[1].PhysicalBase,
- RaspberryPiMemoryRegionDescriptor[1].VirtualBase,
- RaspberryPiMemoryRegionDescriptor[1].Length));
-
- DEBUG ((DEBUG_INFO, "ATF RAM:\n"
- "\tPhysicalBase: 0x%lX\n"
- "\tVirtualBase: 0x%lX\n"
- "\tLength: 0x%lX\n",
- RaspberryPiMemoryRegionDescriptor[2].PhysicalBase,
- RaspberryPiMemoryRegionDescriptor[2].VirtualBase,
- RaspberryPiMemoryRegionDescriptor[2].Length));
-
- DEBUG ((DEBUG_INFO, "System RAM:\n"
- "\tPhysicalBase: 0x%lX\n"
- "\tVirtualBase: 0x%lX\n"
- "\tLength: 0x%lX\n",
- RaspberryPiMemoryRegionDescriptor[3].PhysicalBase,
- RaspberryPiMemoryRegionDescriptor[3].VirtualBase,
- RaspberryPiMemoryRegionDescriptor[3].Length));
-
- DEBUG ((DEBUG_INFO, "GPU Reserved:\n"
- "\tPhysicalBase: 0x%lX\n"
- "\tVirtualBase: 0x%lX\n"
- "\tLength: 0x%lX\n",
- RaspberryPiMemoryRegionDescriptor[4].PhysicalBase,
- RaspberryPiMemoryRegionDescriptor[4].VirtualBase,
- RaspberryPiMemoryRegionDescriptor[4].Length));
-
- DEBUG ((DEBUG_INFO, "SoC reserved:\n"
- "\tPhysicalBase: 0x%lX\n"
- "\tVirtualBase: 0x%lX\n"
- "\tLength: 0x%lX\n",
- RaspberryPiMemoryRegionDescriptor[5].PhysicalBase,
- RaspberryPiMemoryRegionDescriptor[5].VirtualBase,
- RaspberryPiMemoryRegionDescriptor[5].Length));
-
- *VirtualMemoryMap = RaspberryPiMemoryRegionDescriptor;
-}
diff --git a/Platform/RaspberryPi/RPi3/Library/PlatformUiAppLib/PlatformUiAppLib.c b/Platform/RaspberryPi/RPi3/Library/PlatformUiAppLib/PlatformUiAppLib.c
deleted file mode 100644
index 1bd2b83f..00000000
--- a/Platform/RaspberryPi/RPi3/Library/PlatformUiAppLib/PlatformUiAppLib.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/** @file
- *
- * Copyright (c) 2019, Andrey Warkentin <andrey.warkentin@gmail.com>
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <Library/PrintLib.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/UefiLib.h>
-#include <Library/DevicePathLib.h>
-#include <Library/UefiBootManagerLib.h>
-#include <Protocol/DevicePath.h>
-
-#define ARASAN_MMC_DXE_FILE_GUID \
- { 0x100c2cfa, 0xb586, 0x4198, { 0x9b, 0x4c, 0x16, 0x83, 0xd1, 0x95, 0xb1, 0xda } }
-
-#define SDHOST_MMC_DXE_FILE_GUID \
- { 0x58abd787, 0xf64d, 0x4ca2, { 0xa0, 0x34, 0xb9, 0xac, 0x2d, 0x5a, 0xd0, 0xcf } }
-
-#define DP_NODE_LEN(Type) { (UINT8)sizeof (Type), (UINT8)(sizeof (Type) >> 8) }
-
-typedef struct {
- VENDOR_DEVICE_PATH Custom;
- EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
-} PLATFORM_SD_DEV;
-
-STATIC PLATFORM_SD_DEV mArasan = {
- //
- // VENDOR_DEVICE_PATH ArasanMMCHostDxe
- //
- {
- { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DP_NODE_LEN (VENDOR_DEVICE_PATH) },
- ARASAN_MMC_DXE_FILE_GUID
- },
-
- //
- // EFI_DEVICE_PATH_PROTOCOL End
- //
- {
- END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
- DP_NODE_LEN (EFI_DEVICE_PATH_PROTOCOL)
- }
-};
-
-STATIC PLATFORM_SD_DEV mSDHost = {
- //
- // VENDOR_DEVICE_PATH SdHostDxe
- //
- {
- { HARDWARE_DEVICE_PATH, HW_VENDOR_DP, DP_NODE_LEN (VENDOR_DEVICE_PATH) },
- SDHOST_MMC_DXE_FILE_GUID
- },
-
- //
- // EFI_DEVICE_PATH_PROTOCOL End
- //
- {
- END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE,
- DP_NODE_LEN (EFI_DEVICE_PATH_PROTOCOL)
- }
-};
-
-STATIC
-CHAR16*
-EFIAPI
-BootDescriptionHandler (
- IN EFI_HANDLE Handle,
- IN CONST CHAR16 *DefaultDescription
- )
-{
- CHAR16 *Name;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
-
- DevicePath = DevicePathFromHandle (Handle);
- if (CompareMem (&mArasan, DevicePath, GetDevicePathSize (DevicePath)) == 0) {
- Name = L"SD/MMC on Arasan SDHCI";
- } else if (CompareMem (&mSDHost, DevicePath, GetDevicePathSize (DevicePath)) == 0) {
- Name = L"SD/MMC on Broadcom SDHOST";
- } else {
- return NULL;
- }
-
- return AllocateCopyPool(StrSize (Name), Name);
-}
-
-EFI_STATUS
-EFIAPI
-PlatformUiAppLibConstructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- EFI_STATUS Status;
-
- Status = EfiBootManagerRegisterBootDescriptionHandler(BootDescriptionHandler);
- ASSERT_EFI_ERROR (Status);
-
- return EFI_SUCCESS;
-}
-
-EFI_STATUS
-EFIAPI
-PlatformUiAppLibDestructor (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- return EFI_SUCCESS;
-}
diff --git a/Platform/RaspberryPi/RPi3/Library/PlatformUiAppLib/PlatformUiAppLib.inf b/Platform/RaspberryPi/RPi3/Library/PlatformUiAppLib/PlatformUiAppLib.inf
deleted file mode 100644
index 27b0c30c..00000000
--- a/Platform/RaspberryPi/RPi3/Library/PlatformUiAppLib/PlatformUiAppLib.inf
+++ /dev/null
@@ -1,42 +0,0 @@
-#/** @file
-#
-# Copyright (c) 2017-2018, Andrei Warkentin <andrey.warkentin@gmail.com>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x0001001A
- BASE_NAME = PlatformUiAppLib
- FILE_GUID = CCB2DCE1-5EC9-42CB-88C5-D349E134C9FC
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = NULL|DXE_DRIVER UEFI_APPLICATION
- CONSTRUCTOR = PlatformUiAppLibConstructor
- DESTRUCTOR = PlatformUiAppLibDestructor
-
-[Sources]
- PlatformUiAppLib.c
-
-[Packages]
- MdePkg/MdePkg.dec
- MdeModulePkg/MdeModulePkg.dec
- Platform/RaspberryPi/RPi3/RPi3.dec
-
-[LibraryClasses]
- UefiLib
- UefiBootServicesTableLib
- BaseMemoryLib
- DebugLib
- PrintLib
- UefiBootManagerLib
- MemoryAllocationLib
-
-[Guids]
-
-[Protocols]
-
-[FeaturePcd]
-
-[Pcd]
diff --git a/Platform/RaspberryPi/RPi3/Library/ResetLib/ResetLib.c b/Platform/RaspberryPi/RPi3/Library/ResetLib/ResetLib.c
deleted file mode 100644
index c62a9232..00000000
--- a/Platform/RaspberryPi/RPi3/Library/ResetLib/ResetLib.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/** @file
- *
- * Support ResetSystem Runtime call using PSCI calls.
- * Signals the gRaspberryPiEventResetGuid event group on reset.
- *
- * Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
- * Copyright (c) 2014, Linaro Ltd. All rights reserved.
- * Copyright (c) 2013-2015, ARM Ltd. All rights reserved.
- * Copyright (c) 2008-2009, Apple Inc. All rights reserved.
- *
- * SPDX-License-Identifier: BSD-2-Clause-Patent
- *
- **/
-
-#include <PiDxe.h>
-
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/EfiResetSystemLib.h>
-#include <Library/ArmSmcLib.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiRuntimeLib.h>
-
-#include <IndustryStandard/ArmStdSmc.h>
-
-/**
- Resets the entire platform.
-
- @param ResetType The type of reset to perform.
- @param ResetStatus The status code for the reset.
- @param DataSize The size, in bytes, of WatchdogData.
- @param ResetData For a ResetType of EfiResetCold, EfiResetWarm, or
- EfiResetShutdown the data buffer starts with a Null-terminated
- Unicode string, optionally followed by additional binary data.
-
-**/
-EFI_STATUS
-EFIAPI
-LibResetSystem (
- IN EFI_RESET_TYPE ResetType,
- IN EFI_STATUS ResetStatus,
- IN UINTN DataSize,
- IN CHAR16 *ResetData OPTIONAL
- )
-{
- ARM_SMC_ARGS ArmSmcArgs;
-
- if (!EfiAtRuntime ()) {
- /*
- * Only if still in UEFI.
- */
- EfiEventGroupSignal (&gRaspberryPiEventResetGuid);
- }
-
- switch (ResetType) {
- case EfiResetPlatformSpecific:
- // Map the platform specific reset as reboot
- case EfiResetWarm:
- // Map a warm reset into a cold reset
- case EfiResetCold:
- // Send a PSCI 0.2 SYSTEM_RESET command
- ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_RESET;
- break;
- case EfiResetShutdown:
- // Send a PSCI 0.2 SYSTEM_OFF command
- ArmSmcArgs.Arg0 = ARM_SMC_ID_PSCI_SYSTEM_OFF;
- break;
- default:
- ASSERT (FALSE);
- return EFI_UNSUPPORTED;
- }
-
- ArmCallSmc (&ArmSmcArgs);
-
- // We should never be here
- DEBUG ((DEBUG_ERROR, "%a: PSCI Reset failed\n", __FUNCTION__));
- CpuDeadLoop ();
- return EFI_UNSUPPORTED;
-}
-
-/**
- Initialize any infrastructure required for LibResetSystem () to function.
-
- @param ImageHandle The firmware allocated handle for the EFI image.
- @param SystemTable A pointer to the EFI System Table.
-
- @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
-
-**/
-EFI_STATUS
-EFIAPI
-LibInitializeResetSystem (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
- )
-{
- return EFI_SUCCESS;
-}
diff --git a/Platform/RaspberryPi/RPi3/Library/ResetLib/ResetLib.inf b/Platform/RaspberryPi/RPi3/Library/ResetLib/ResetLib.inf
deleted file mode 100644
index f58020bf..00000000
--- a/Platform/RaspberryPi/RPi3/Library/ResetLib/ResetLib.inf
+++ /dev/null
@@ -1,40 +0,0 @@
-#/** @file
-#
-# Reset System lib using PSCI hypervisor or secure monitor calls.
-# Signals the gRaspberryPiEventResetGuid event group on reset.
-#
-# Copyright (c) 2018, Andrei Warkentin <andrey.warkentin@gmail.com>
-# Copyright (c) 2014, Linaro Ltd. All rights reserved.
-# Copyright (c) 2014, ARM Ltd. All rights reserved.
-# Copyright (c) 2008, Apple Inc. All rights reserved.
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x0001001A
- BASE_NAME = ResetLib
- FILE_GUID = B9F59B69-A105-41C7-8F5A-2C60DD7FD7AB
- MODULE_TYPE = BASE
- VERSION_STRING = 1.0
- LIBRARY_CLASS = EfiResetSystemLib
-
-[Sources]
- ResetLib.c
-
-[Packages]
- ArmPkg/ArmPkg.dec
- MdePkg/MdePkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- Platform/RaspberryPi/RPi3/RPi3.dec
-
-[LibraryClasses]
- DebugLib
- BaseLib
- ArmSmcLib
- UefiLib
- UefiRuntimeLib
-
-[Guids]
- gRaspberryPiEventResetGuid
diff --git a/Platform/RaspberryPi/RPi3/RPi3.dec b/Platform/RaspberryPi/RPi3/RPi3.dec
deleted file mode 100644
index 0554ee20..00000000
--- a/Platform/RaspberryPi/RPi3/RPi3.dec
+++ /dev/null
@@ -1,58 +0,0 @@
-## @file
-#
-# Copyright (c) 2016, Linaro, Ltd. All rights reserved.
-# Copyright (c) 2017-2018, Andrei Warkentin <andrey.warkentin@gmail.com>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-##
-
-[Defines]
- DEC_SPECIFICATION = 0x0001001A
- PACKAGE_NAME = RPi3Pkg
- PACKAGE_GUID = DFA0CA8B-F3AC-4607-96AC-46FA04B84DCC
- PACKAGE_VERSION = 1.0
-
-[Includes]
- Include
-
-[Protocols]
- gRaspberryPiFirmwareProtocolGuid = { 0x0ACA9535, 0x7AD0, 0x4286, { 0xB0, 0x2E, 0x87, 0xFA, 0x7E, 0x2A, 0x57, 0x11 } }
- gRaspberryPiConfigAppliedProtocolGuid = { 0x0ACA4444, 0x7AD0, 0x4286, { 0xB0, 0x2E, 0x87, 0xFA, 0x7E, 0x2A, 0x57, 0x11 } }
- gRaspberryPiMmcHostProtocolGuid = { 0x3e591c00, 0x9e4a, 0x11df, {0x92, 0x44, 0x00, 0x02, 0xA5, 0xF5, 0xF5, 0x1B } }
- gExtendedTextOutputProtocolGuid = { 0x387477ff, 0xffc7, 0xffd2, {0x8e, 0x39, 0x0, 0xff, 0xc9, 0x69, 0x72, 0x3b } }
-
-[Guids]
- gRaspberryPiTokenSpaceGuid = {0xCD7CC258, 0x31DB, 0x11E6, {0x9F, 0xD3, 0x63, 0xB0, 0xB8, 0xEE, 0xD6, 0xB5}}
- gRaspberryPiEventResetGuid = {0xCD7CC258, 0x31DB, 0x11E6, {0x9F, 0xD3, 0x63, 0xB4, 0xB4, 0xE4, 0xD4, 0xB4}}
- gConfigDxeFormSetGuid = {0xCD7CC258, 0x31DB, 0x22E6, {0x9F, 0x22, 0x63, 0xB0, 0xB8, 0xEE, 0xD6, 0xB5}}
- # GUIDs used by FdtDxe to serve a Device Tree at runtime. Not all of these need to apply
- # to the current platform or match an actual FDF binary, but they need to be defined.
- gRaspberryPi3ModelBFdtGuid = { 0xDF5DA223, 0x1D27, 0x47C3, { 0x8D, 0x1B, 0x9A, 0x41, 0xB5, 0x5A, 0x18, 0xBC } }
- gRaspberryPi3ModelBPlusFdtGuid = { 0x3D523012, 0x73FE, 0x40E5, { 0x89, 0x2E, 0x1A, 0x4D, 0xF6, 0x0F, 0x3C, 0x0C } }
- gRaspberryPi4ModelBFdtGuid = { 0x80AB6833, 0xCAE4, 0x4CEE, { 0xB5, 0x9D, 0xEB, 0x20, 0x39, 0xB0, 0x55, 0x51 } }
- # Default Fdt to serve if the hardware model can't be detected. Should match one of the above.
- gRaspberryPiDefaultFdtGuid = {0xDF5DA223, 0x1D27, 0x47C3, { 0x8D, 0x1B, 0x9A, 0x41, 0xB5, 0x5A, 0x18, 0xBC}}
-
-[PcdsFixedAtBuild.common]
- gRaspberryPiTokenSpaceGuid.PcdFdtBaseAddress|0x10000|UINT32|0x00000001
- gRaspberryPiTokenSpaceGuid.PcdFirmwareBlockSize|0x0|UINT32|0x00000002
- gRaspberryPiTokenSpaceGuid.PcdNvStorageEventLogBase|0x0|UINT32|0x00000003
- gRaspberryPiTokenSpaceGuid.PcdNvStorageEventLogSize|0x0|UINT32|0x00000004
- gRaspberryPiTokenSpaceGuid.PcdNvStorageVariableBase|0x0|UINT32|0x00000005
- gRaspberryPiTokenSpaceGuid.PcdNvStorageFtwSpareBase|0x0|UINT32|0x00000006
- gRaspberryPiTokenSpaceGuid.PcdNvStorageFtwWorkingBase|0x0|UINT32|0x00000007
-
-[PcdsFixedAtBuild, PcdsPatchableInModule, PcdsDynamic, PcdsDynamicEx]
- gRaspberryPiTokenSpaceGuid.PcdCpuClock|0|UINT32|0x0000000d
- gRaspberryPiTokenSpaceGuid.PcdSdIsArasan|0|UINT32|0x0000000e
- gRaspberryPiTokenSpaceGuid.PcdMmcForce1Bit|0|UINT32|0x0000000f
- gRaspberryPiTokenSpaceGuid.PcdMmcForceDefaultSpeed|0|UINT32|0x00000010
- gRaspberryPiTokenSpaceGuid.PcdMmcSdDefaultSpeedMHz|0|UINT32|0x00000011
- gRaspberryPiTokenSpaceGuid.PcdMmcSdHighSpeedMHz|0|UINT32|0x00000012
- gRaspberryPiTokenSpaceGuid.PcdMmcDisableMulti|0|UINT32|0x00000013
- gRaspberryPiTokenSpaceGuid.PcdDebugEnableJTAG|0|UINT32|0x00000014
- gRaspberryPiTokenSpaceGuid.PcdDebugShowUEFIExit|0|UINT32|0x00000015
- gRaspberryPiTokenSpaceGuid.PcdCustomCpuClock|0|UINT32|0x00000016
- gRaspberryPiTokenSpaceGuid.PcdDisplayEnableScaledVModes|0|UINT8|0x00000017
- gRaspberryPiTokenSpaceGuid.PcdDisplayEnableSShot|0|UINT32|0x00000018
diff --git a/Platform/RaspberryPi/RPi3/RPi3.dsc b/Platform/RaspberryPi/RPi3/RPi3.dsc
index e3dc2d49..a0365c5c 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.dsc
+++ b/Platform/RaspberryPi/RPi3/RPi3.dsc
@@ -162,7 +162,7 @@
[LibraryClasses.common.SEC]
PcdLib|MdePkg/Library/BasePcdLibNull/BasePcdLibNull.inf
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
- MemoryInitPeiLib|Platform/RaspberryPi/$(PLATFORM_NAME)/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf
+ MemoryInitPeiLib|Platform/RaspberryPi/Library/MemoryInitPeiLib/MemoryInitPeiLib.inf
PlatformPeiLib|ArmPlatformPkg/PlatformPei/PlatformPeiLib.inf
ExtractGuidedSectionLib|EmbeddedPkg/Library/PrePiExtractGuidedSectionLib/PrePiExtractGuidedSectionLib.inf
LzmaDecompressLib|MdeModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf
@@ -202,7 +202,7 @@
[LibraryClasses.common.DXE_RUNTIME_DRIVER]
MemoryAllocationLib|MdePkg/Library/UefiMemoryAllocationLib/UefiMemoryAllocationLib.inf
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
- EfiResetSystemLib|Platform/RaspberryPi/$(PLATFORM_NAME)/Library/ResetLib/ResetLib.inf
+ EfiResetSystemLib|Platform/RaspberryPi/Library/ResetLib/ResetLib.inf
ArmSmcLib|ArmPkg/Library/ArmSmcLib/ArmSmcLib.inf
!if $(SECURE_BOOT_ENABLE) == TRUE
@@ -332,12 +332,12 @@
[LibraryClasses.common]
ArmLib|ArmPkg/Library/ArmLib/ArmBaseLib.inf
ArmMmuLib|ArmPkg/Library/ArmMmuLib/ArmMmuBaseLib.inf
- ArmPlatformLib|Platform/RaspberryPi/$(PLATFORM_NAME)/Library/PlatformLib/PlatformLib.inf
+ ArmPlatformLib|Platform/RaspberryPi/Library/PlatformLib/PlatformLib.inf
TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf
UefiBootManagerLib|MdeModulePkg/Library/UefiBootManagerLib/UefiBootManagerLib.inf
BootLogoLib|MdeModulePkg/Library/BootLogoLib/BootLogoLib.inf
- PlatformBootManagerLib|Platform/RaspberryPi/$(PLATFORM_NAME)/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+ PlatformBootManagerLib|Platform/RaspberryPi/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
@@ -479,7 +479,7 @@
#
ArmPkg/Drivers/CpuDxe/CpuDxe.inf
MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
- Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
+ Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf {
<LibraryClasses>
@@ -506,18 +506,18 @@
MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
- Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
+ Platform/RaspberryPi/Drivers/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
MdeModulePkg/Universal/SerialDxe/SerialDxe.inf
- Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/DisplayDxe/DisplayDxe.inf
+ Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.inf
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
Silicon/Broadcom/Bcm283x/Drivers/InterruptDxe/InterruptDxe.inf
- Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
- Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/FdtDxe/FdtDxe.inf
- Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/ConfigDxe/ConfigDxe.inf
+ Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
+ Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
+ Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
ArmPkg/Drivers/TimerDxe/TimerDxe.inf
MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
@@ -541,7 +541,7 @@
#
# SMBIOS Support
#
- Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf
+ Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf
MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
#
@@ -557,12 +557,12 @@
MdeModulePkg/Universal/SetupBrowserDxe/SetupBrowserDxe.inf
MdeModulePkg/Universal/DriverHealthManagerDxe/DriverHealthManagerDxe.inf
MdeModulePkg/Universal/BdsDxe/BdsDxe.inf
- Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/LogoDxe/LogoDxe.inf
+ Platform/RaspberryPi/Drivers/LogoDxe/LogoDxe.inf
MdeModulePkg/Application/UiApp/UiApp.inf {
<LibraryClasses>
NULL|MdeModulePkg/Library/DeviceManagerUiLib/DeviceManagerUiLib.inf
NULL|MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf
- NULL|Platform/RaspberryPi/$(PLATFORM_NAME)/Library/PlatformUiAppLib/PlatformUiAppLib.inf
+ NULL|Platform/RaspberryPi/Library/PlatformUiAppLib/PlatformUiAppLib.inf
NULL|MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf
}
@@ -575,7 +575,7 @@
#
# USB Support
#
- Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf
+ Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf
MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
@@ -584,9 +584,9 @@
#
# SD/MMC support
#
- Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/SdHostDxe/SdHostDxe.inf
- Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.inf
- Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/MmcDxe/MmcDxe.inf
+ Platform/RaspberryPi/Drivers/SdHostDxe/SdHostDxe.inf
+ Platform/RaspberryPi/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.inf
+ Platform/RaspberryPi/Drivers/MmcDxe/MmcDxe.inf
#
# Networking stack
diff --git a/Platform/RaspberryPi/RPi3/RPi3.fdf b/Platform/RaspberryPi/RPi3/RPi3.fdf
index b06a15fb..fd4e490f 100644
--- a/Platform/RaspberryPi/RPi3/RPi3.fdf
+++ b/Platform/RaspberryPi/RPi3/RPi3.fdf
@@ -189,7 +189,7 @@ READ_LOCK_STATUS = TRUE
INF MdeModulePkg/Core/RuntimeDxe/RuntimeDxe.inf
INF MdeModulePkg/Universal/SecurityStubDxe/SecurityStubDxe.inf
INF MdeModulePkg/Universal/CapsuleRuntimeDxe/CapsuleRuntimeDxe.inf
- INF Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
+ INF Platform/RaspberryPi/Drivers/VarBlockServiceDxe/VarBlockServiceDxe.inf
INF MdeModulePkg/Universal/FaultTolerantWriteDxe/FaultTolerantWriteDxe.inf
INF MdeModulePkg/Universal/Variable/RuntimeDxe/VariableRuntimeDxe.inf
!if $(SECURE_BOOT_ENABLE) == TRUE
@@ -206,16 +206,16 @@ READ_LOCK_STATUS = TRUE
#
INF MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
INF MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
- INF Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
+ INF Platform/RaspberryPi/Drivers/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
INF MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
INF MdeModulePkg/Universal/SerialDxe/SerialDxe.inf
- INF Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/DisplayDxe/DisplayDxe.inf
+ INF Platform/RaspberryPi/Drivers/DisplayDxe/DisplayDxe.inf
INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
INF Silicon/Broadcom/Bcm283x/Drivers/InterruptDxe/InterruptDxe.inf
- INF Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
- INF Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/FdtDxe/FdtDxe.inf
- INF Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/ConfigDxe/ConfigDxe.inf
+ INF Platform/RaspberryPi/Drivers/RpiFirmwareDxe/RpiFirmwareDxe.inf
+ INF Platform/RaspberryPi/Drivers/FdtDxe/FdtDxe.inf
+ INF Platform/RaspberryPi/Drivers/ConfigDxe/ConfigDxe.inf
INF ArmPkg/Drivers/TimerDxe/TimerDxe.inf
INF MdeModulePkg/Universal/WatchdogTimerDxe/WatchdogTimer.inf
INF MdeModulePkg/Universal/EbcDxe/EbcDxe.inf
@@ -247,7 +247,7 @@ READ_LOCK_STATUS = TRUE
#
# SMBIOS Support
#
- INF Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf
+ INF Platform/RaspberryPi/Drivers/PlatformSmbiosDxe/PlatformSmbiosDxe.inf
INF MdeModulePkg/Universal/SmbiosDxe/SmbiosDxe.inf
#
@@ -284,7 +284,7 @@ READ_LOCK_STATUS = TRUE
#
# USB Support
#
- INF Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf
+ INF Platform/RaspberryPi/Drivers/DwUsbHostDxe/DwUsbHostDxe.inf
INF MdeModulePkg/Bus/Usb/UsbBusDxe/UsbBusDxe.inf
INF MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
INF MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
@@ -293,14 +293,14 @@ READ_LOCK_STATUS = TRUE
#
# SD/MMC support
#
- INF Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/SdHostDxe/SdHostDxe.inf
- INF Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.inf
- INF Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/MmcDxe/MmcDxe.inf
+ INF Platform/RaspberryPi/Drivers/SdHostDxe/SdHostDxe.inf
+ INF Platform/RaspberryPi/Drivers/ArasanMmcHostDxe/ArasanMmcHostDxe.inf
+ INF Platform/RaspberryPi/Drivers/MmcDxe/MmcDxe.inf
#
# Pi logo (splash screen)
#
- INF Platform/RaspberryPi/$(PLATFORM_NAME)/Drivers/LogoDxe/LogoDxe.inf
+ INF Platform/RaspberryPi/Drivers/LogoDxe/LogoDxe.inf
#
# Device Tree support (used by FdtDxe)