diff options
author | Chao Li <lichao@loongson.cn> | 2024-06-04 15:36:45 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2024-06-05 21:50:38 +0000 |
commit | 10ab1c67c489942b787b784a48d46623b442cfd1 (patch) | |
tree | 92ace457e033608fecd4f476301e0746ddea6b4a /ArmVirtPkg/Library | |
parent | 10cd8b45ce36152996bcb1520ba36107a8cdc63f (diff) | |
download | edk2-10ab1c67c489942b787b784a48d46623b442cfd1.tar.gz edk2-10ab1c67c489942b787b784a48d46623b442cfd1.tar.bz2 edk2-10ab1c67c489942b787b784a48d46623b442cfd1.zip |
ArmVirtPkg: Remove the NorFlashQemuLib
The FdtNorFlashQemuLib has been enabled, remove ArmVirtPkg version.
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=4770
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Leif Lindholm <quic_llindhol@quicinc.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Chao Li <lichao@loongson.cn>
Diffstat (limited to 'ArmVirtPkg/Library')
-rw-r--r-- | ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c | 136 | ||||
-rw-r--r-- | ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf | 42 |
2 files changed, 0 insertions, 178 deletions
diff --git a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c deleted file mode 100644 index d0fa7e5046..0000000000 --- a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.c +++ /dev/null @@ -1,136 +0,0 @@ -/** @file
-
- Copyright (c) 2014-2018, Linaro Ltd. All rights reserved.<BR>
-
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
- **/
-
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/VirtNorFlashPlatformLib.h>
-
-#include <Protocol/FdtClient.h>
-
-#define QEMU_NOR_BLOCK_SIZE SIZE_256KB
-
-#define MAX_FLASH_BANKS 4
-
-EFI_STATUS
-VirtNorFlashPlatformInitialization (
- VOID
- )
-{
- return EFI_SUCCESS;
-}
-
-STATIC VIRT_NOR_FLASH_DESCRIPTION mNorFlashDevices[MAX_FLASH_BANKS];
-
-EFI_STATUS
-VirtNorFlashPlatformGetDevices (
- OUT VIRT_NOR_FLASH_DESCRIPTION **NorFlashDescriptions,
- OUT UINT32 *Count
- )
-{
- FDT_CLIENT_PROTOCOL *FdtClient;
- INT32 Node;
- EFI_STATUS Status;
- EFI_STATUS FindNodeStatus;
- CONST UINT32 *Reg;
- UINT32 PropSize;
- UINT32 Num;
- UINT64 Base;
- UINT64 Size;
-
- Status = gBS->LocateProtocol (
- &gFdtClientProtocolGuid,
- NULL,
- (VOID **)&FdtClient
- );
- ASSERT_EFI_ERROR (Status);
-
- Num = 0;
- for (FindNodeStatus = FdtClient->FindCompatibleNode (
- FdtClient,
- "cfi-flash",
- &Node
- );
- !EFI_ERROR (FindNodeStatus) && Num < MAX_FLASH_BANKS;
- FindNodeStatus = FdtClient->FindNextCompatibleNode (
- FdtClient,
- "cfi-flash",
- Node,
- &Node
- ))
- {
- Status = FdtClient->GetNodeProperty (
- FdtClient,
- Node,
- "reg",
- (CONST VOID **)&Reg,
- &PropSize
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((
- DEBUG_ERROR,
- "%a: GetNodeProperty () failed (Status == %r)\n",
- __func__,
- Status
- ));
- continue;
- }
-
- ASSERT ((PropSize % (4 * sizeof (UINT32))) == 0);
-
- while (PropSize >= (4 * sizeof (UINT32)) && Num < MAX_FLASH_BANKS) {
- Base = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[0]));
- Size = SwapBytes64 (ReadUnaligned64 ((VOID *)&Reg[2]));
- Reg += 4;
-
- PropSize -= 4 * sizeof (UINT32);
-
- //
- // Disregard any flash devices that overlap with the primary FV.
- // The firmware is not updatable from inside the guest anyway.
- //
- if ((PcdGet64 (PcdFvBaseAddress) + PcdGet32 (PcdFvSize) > Base) &&
- ((Base + Size) > PcdGet64 (PcdFvBaseAddress)))
- {
- continue;
- }
-
- mNorFlashDevices[Num].DeviceBaseAddress = (UINTN)Base;
- mNorFlashDevices[Num].RegionBaseAddress = (UINTN)Base;
- mNorFlashDevices[Num].Size = (UINTN)Size;
- mNorFlashDevices[Num].BlockSize = QEMU_NOR_BLOCK_SIZE;
- Num++;
- }
-
- //
- // UEFI takes ownership of the NOR flash, and exposes its functionality
- // through the UEFI Runtime Services GetVariable, SetVariable, etc. This
- // means we need to disable it in the device tree to prevent the OS from
- // attaching its device driver as well.
- // Note that this also hides other flash banks, but the only other flash
- // bank we expect to encounter is the one that carries the UEFI executable
- // code, which is not intended to be guest updatable, and is usually backed
- // in a readonly manner by QEMU anyway.
- //
- Status = FdtClient->SetNodeProperty (
- FdtClient,
- Node,
- "status",
- "disabled",
- sizeof ("disabled")
- );
- if (EFI_ERROR (Status)) {
- DEBUG ((DEBUG_WARN, "Failed to set NOR flash status to 'disabled'\n"));
- }
- }
-
- *NorFlashDescriptions = mNorFlashDevices;
- *Count = Num;
-
- return EFI_SUCCESS;
-}
diff --git a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf b/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf deleted file mode 100644 index a6b5865be9..0000000000 --- a/ArmVirtPkg/Library/NorFlashQemuLib/NorFlashQemuLib.inf +++ /dev/null @@ -1,42 +0,0 @@ -#/** @file
-#
-# Component description file for NorFlashQemuLib module
-#
-# Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>
-#
-# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
-#**/
-
-[Defines]
- INF_VERSION = 0x00010005
- BASE_NAME = NorFlashQemuLib
- FILE_GUID = 339B7829-4C5F-4EFC-B2DD-5050E530DECE
- MODULE_TYPE = DXE_DRIVER
- VERSION_STRING = 1.0
- LIBRARY_CLASS = VirtNorFlashPlatformLib
-
-[Sources.common]
- NorFlashQemuLib.c
-
-[Packages]
- MdePkg/MdePkg.dec
- ArmPkg/ArmPkg.dec
- ArmVirtPkg/ArmVirtPkg.dec
- EmbeddedPkg/EmbeddedPkg.dec
- OvmfPkg/OvmfPkg.dec
-
-[LibraryClasses]
- BaseLib
- DebugLib
- UefiBootServicesTableLib
-
-[Protocols]
- gFdtClientProtocolGuid ## CONSUMES
-
-[Depex]
- gFdtClientProtocolGuid
-
-[Pcd]
- gArmTokenSpaceGuid.PcdFvBaseAddress
- gArmTokenSpaceGuid.PcdFvSize
|