41 ASSERT (FwCfgResource !=
NULL);
43 return FwCfgResource->FwCfgSelectorAddress;
62 ASSERT (FwCfgResource !=
NULL);
64 return FwCfgResource->FwCfgDataAddress;
83 ASSERT (FwCfgResource !=
NULL);
85 return FwCfgResource->FwCfgDmaAddress;
101 UINT64 FwCfgSelectorAddress;
102 UINT64 FwCfgSelectorSize;
103 UINT64 FwCfgDataAddress;
104 UINT64 FwCfgDataSize;
105 UINT64 FwCfgDmaAddress;
114 if (FwCfgResource !=
NULL) {
118 DeviceTreeBase = (VOID *)(
UINTN)
PcdGet64 (PcdDeviceTreeInitialBaseAddress);
119 ASSERT (DeviceTreeBase !=
NULL);
123 ASSERT (fdt_check_header (DeviceTreeBase) == 0);
129 ASSERT (FwCfgResource !=
NULL);
131 for (Prev = 0; ; Prev = Node) {
132 Node = fdt_next_node (DeviceTreeBase, Prev,
NULL);
140 Type = fdt_getprop (DeviceTreeBase, Node,
"compatible", &Len);
141 if ((Type !=
NULL) &&
148 Reg = fdt_getprop (DeviceTreeBase, Node,
"reg", &Len);
149 if ((Reg != 0) && (Len == (2 *
sizeof (UINT64)))) {
152 FwCfgSelectorAddress = FwCfgDataAddress + FwCfgDataSize;
153 FwCfgSelectorSize = 2;
165 ASSERT (FwCfgSelectorAddress <= MAX_UINTN - FwCfgSelectorSize + 1);
166 ASSERT (FwCfgDataAddress <= MAX_UINTN - FwCfgDataSize + 1);
168 FwCfgResource->FwCfgSelectorAddress = FwCfgSelectorAddress;
169 FwCfgResource->FwCfgDataAddress = FwCfgDataAddress;
173 "Found FwCfg @ 0x%Lx/0x%Lx\n",
174 FwCfgSelectorAddress,
179 FwCfgDmaAddress = FwCfgDataAddress + 0x10;
185 ASSERT (FwCfgDmaAddress <= MAX_UINTN - FwCfgDmaSize + 1);
187 DEBUG ((DEBUG_INFO,
"Found FwCfg DMA @ 0x%Lx\n", FwCfgDmaAddress));
188 FwCfgResource->FwCfgDmaAddress = FwCfgDmaAddress;
193 if ((FwCfgSelectorAddress != 0) && (FwCfgDataAddress != 0)) {
210 FwCfgResource->FwCfgDataAddress = 0;
211 FwCfgResource->FwCfgSelectorAddress = 0;
212 FwCfgResource->FwCfgDmaAddress = 0;
216 "%a: Signature dose not match QEMU!\n",
227 "%a: Failed to parse FDT QemuCfg node\n",
UINT16 EFIAPI SwapBytes16(IN UINT16 Value)
INTN EFIAPI AsciiStrnCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString, IN UINTN Length)
UINT64 EFIAPI SwapBytes64(IN UINT64 Value)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
UINT32 EFIAPI MmioRead32(IN UINTN Address)
UINT16 EFIAPI MmioWrite16(IN UINTN Address, IN UINT16 Value)
#define SIGNATURE_32(A, B, C, D)
#define DEBUG(Expression)
#define PcdGet64(TokenName)
QEMU_FW_CFG_RESOURCE * QemuGetFwCfgResourceHob(VOID)
VOID QemuBuildFwCfgResourceHob(IN QEMU_FW_CFG_RESOURCE *FwCfgResource)
UINTN EFIAPI QemuGetFwCfgDmaAddress(VOID)
UINTN EFIAPI QemuGetFwCfgDataAddress(VOID)
UINTN EFIAPI QemuGetFwCfgSelectorAddress(VOID)