17#define QEMU_NOR_BLOCK_SIZE SIZE_256KB
19#define MAX_FLASH_BANKS 4
47 Status =
gBS->LocateProtocol (
48 &gFdtClientProtocolGuid,
55 for (FindNodeStatus = FdtClient->FindCompatibleNode (
60 !EFI_ERROR (FindNodeStatus) && Num < MAX_FLASH_BANKS;
61 FindNodeStatus = FdtClient->FindNextCompatibleNode (
68 Status = FdtClient->GetNodeProperty (
75 if (EFI_ERROR (Status)) {
78 "%a: GetNodeProperty () failed (Status == %r)\n",
85 ASSERT ((PropSize % (4 *
sizeof (UINT32))) == 0);
87 while (PropSize >= (4 *
sizeof (UINT32)) && Num < MAX_FLASH_BANKS) {
92 PropSize -= 4 *
sizeof (UINT32);
98 if ((
PcdGet32 (PcdOvmfFdBaseAddress) +
PcdGet32 (PcdOvmfFirmwareFdSize) > Base) &&
99 ((Base + Size) >
PcdGet32 (PcdOvmfFdBaseAddress)))
104 mNorFlashDevices[Num].DeviceBaseAddress = (
UINTN)Base;
105 mNorFlashDevices[Num].RegionBaseAddress = (
UINTN)Base;
106 mNorFlashDevices[Num].Size = (
UINTN)Size;
107 mNorFlashDevices[Num].BlockSize = QEMU_NOR_BLOCK_SIZE;
121 Status = FdtClient->SetNodeProperty (
128 if (EFI_ERROR (Status)) {
129 DEBUG ((DEBUG_WARN,
"Failed to set NOR flash status to 'disabled'\n"));
133 *NorFlashDescriptions = mNorFlashDevices;
UINT64 EFIAPI ReadUnaligned64(IN CONST UINT64 *Buffer)
UINT64 EFIAPI SwapBytes64(IN UINT64 Value)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define PcdGet32(TokenName)
EFI_STATUS VirtNorFlashPlatformInitialization(VOID)
EFI_STATUS VirtNorFlashPlatformGetDevices(OUT VIRT_NOR_FLASH_DESCRIPTION **NorFlashDescriptions, OUT UINT32 *Count)