14#define IS_RANGE_INVALID(Start, Size, MaxValue) (Start >= MaxValue || Size == 0)
31 if (IS_RANGE_INVALID (Start, Size, MaxValue)) {
35 return Start + Size - 1;
52 OUT UINT64 *LastAddress
55 if (Mem->Limit > *LastAddress) {
56 *LastAddress = Mem->Limit;
65 OUT UINT64 *LastMmioAddress
74 if (LastMmioAddress ==
NULL) {
75 return EFI_INVALID_PARAMETER;
100 if (EFI_ERROR (Status)) {
130 if (Aperture ==
NULL) {
134 Aperture->Base = MAX_UINT64;
168 if (Aperture ==
NULL) {
169 if (!IS_RANGE_INVALID (Start, Size, MaxValue)) {
175 return EFI_INVALID_PARAMETER;
178 return EFI_WARN_BUFFER_TOO_SMALL;
181 if (IS_RANGE_INVALID (Start, Size, MaxValue)) {
188 Aperture->Base = Start;
189 Aperture->Limit = End;
229 if (Aperture ==
NULL) {
230 if (!IS_RANGE_INVALID (Start, Size, MaxValue) ||
231 !IS_RANGE_INVALID (PStart, PSize, MaxValue))
238 return EFI_INVALID_PARAMETER;
241 return EFI_WARN_BUFFER_TOO_SMALL;
249 if (!IS_RANGE_INVALID (Start, Size, MaxValue)) {
250 Aperture->Base = Start;
251 Aperture->Limit = Start + Size - 1;
254 if (!IS_RANGE_INVALID (PStart, PSize, MaxValue)) {
255 PEnd = PStart + PSize - 1;
257 if (PStart < Aperture->Base) {
258 Aperture->Base = PStart;
261 if (PEnd > Aperture->Limit) {
262 Aperture->Limit = PEnd;
277 if ((HostBridge ==
NULL) || (DataSize == 0) ||
278 (BusNrStart ==
NULL) || (BusNrLast ==
NULL))
280 return EFI_INVALID_PARAMETER;
286 if (HostBridge->Version != 0) {
287 return EFI_INCOMPATIBLE_VERSION;
290 *BusNrStart = HostBridge->BusNrStart;
291 *BusNrLast = HostBridge->BusNrLast;
312 if ((HostBridge ==
NULL) || (DataSize == 0)) {
313 return EFI_INVALID_PARAMETER;
319 if (HostBridge->Version != 0) {
320 return EFI_INCOMPATIBLE_VERSION;
329 StickyError |= EFI_ERROR (Status);
332 HostBridge->PcieConfigStart,
333 HostBridge->PcieConfigSize,
337 StickyError |= EFI_ERROR (Status);
339 if (HostBridge->Flags.Bits.CombineMemPMem) {
341 HostBridge->MemStart,
343 HostBridge->PMemStart,
344 HostBridge->PMemSize,
348 StickyError |= EFI_ERROR (Status);
351 HostBridge->MemAbove4GStart,
352 HostBridge->MemAbove4GSize,
353 HostBridge->PMemAbove4GStart,
354 HostBridge->PMemAbove4GSize,
358 StickyError |= EFI_ERROR (Status);
367 HostBridge->MemStart,
372 StickyError |= EFI_ERROR (Status);
375 HostBridge->PMemStart,
376 HostBridge->PMemSize,
380 StickyError |= EFI_ERROR (Status);
383 HostBridge->MemAbove4GStart,
384 HostBridge->MemAbove4GSize,
388 StickyError |= EFI_ERROR (Status);
391 HostBridge->PMemAbove4GStart,
392 HostBridge->PMemAbove4GSize,
396 StickyError |= EFI_ERROR (Status);
406 return EFI_WARN_STALE_DATA;
416 OUT UINT64 *Attributes OPTIONAL,
417 OUT BOOLEAN *DmaAbove4G OPTIONAL,
418 OUT BOOLEAN *NoExtendedConfigSpace OPTIONAL,
419 OUT BOOLEAN *CombineMemPMem OPTIONAL
422 if ((HostBridge ==
NULL) || (DataSize == 0)) {
423 return EFI_INVALID_PARAMETER;
429 if (HostBridge->Version != 0) {
430 return EFI_INCOMPATIBLE_VERSION;
434 *Attributes = HostBridge->Attributes;
438 *DmaAbove4G = !!HostBridge->Flags.Bits.DmaAbove4G;
441 if (NoExtendedConfigSpace) {
442 *NoExtendedConfigSpace = !!HostBridge->Flags.Bits.NoExtendedConfigSpace;
445 if (CombineMemPMem) {
446 *CombineMemPMem = !!HostBridge->Flags.Bits.CombineMemPMem;
458 OUT UINT64 *Attributes OPTIONAL,
459 OUT BOOLEAN *DmaAbove4G OPTIONAL,
460 OUT BOOLEAN *NoExtendedConfigSpace OPTIONAL,
461 OUT BOOLEAN *CombineMemPMem OPTIONAL,
479 if (EFI_ERROR (Status)) {
488 NoExtendedConfigSpace,
492 if (EFI_ERROR (Status)) {
STATIC VOID UpdateLastAddressIfHigher(IN PCI_ROOT_BRIDGE_APERTURE *Mem, OUT UINT64 *LastAddress)
EFI_STATUS HardwareInfoPciHostBridgeLastMmioAddress(IN CONST HOST_BRIDGE_INFO *HostBridge, IN UINTN DataSize, IN BOOLEAN HighMem, OUT UINT64 *LastMmioAddress)
STATIC VOID InvalidateRootBridgeAperture(OUT PCI_ROOT_BRIDGE_APERTURE *Aperture)
STATIC UINT64 GetRangeEnd(IN UINT64 Start, IN UINT64 Size, IN UINT64 MaxValue)
STATIC EFI_STATUS FillHostBridgeAperture(IN UINT64 Start, IN UINT64 Size, IN UINT64 MaxValue, OUT PCI_ROOT_BRIDGE_APERTURE *Aperture)
EFI_STATUS HardwareInfoPciHostBridgeGetFlags(IN CONST HOST_BRIDGE_INFO *HostBridge, IN UINTN DataSize, OUT UINT64 *Attributes OPTIONAL, OUT BOOLEAN *DmaAbove4G OPTIONAL, OUT BOOLEAN *NoExtendedConfigSpace OPTIONAL, OUT BOOLEAN *CombineMemPMem OPTIONAL)
STATIC EFI_STATUS MergeHostBridgeApertures(IN UINT64 Start, IN UINT64 Size, IN UINT64 PStart, IN UINT64 PSize, IN UINT64 MaxValue, OUT PCI_ROOT_BRIDGE_APERTURE *Aperture)
EFI_STATUS HardwareInfoPciHostBridgeGet(IN CONST HOST_BRIDGE_INFO *HostBridge, IN UINTN DataSize, OUT UINTN *BusNrStart, OUT UINTN *BusNrLast, OUT UINT64 *Attributes OPTIONAL, OUT BOOLEAN *DmaAbove4G OPTIONAL, OUT BOOLEAN *NoExtendedConfigSpace OPTIONAL, OUT BOOLEAN *CombineMemPMem OPTIONAL, OUT PCI_ROOT_BRIDGE_APERTURE *Io OPTIONAL, OUT PCI_ROOT_BRIDGE_APERTURE *Mem OPTIONAL, OUT PCI_ROOT_BRIDGE_APERTURE *MemAbove4G OPTIONAL, OUT PCI_ROOT_BRIDGE_APERTURE *PMem OPTIONAL, OUT PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G OPTIONAL, OUT PCI_ROOT_BRIDGE_APERTURE *PcieConfig OPTIONAL)
EFI_STATUS HardwareInfoPciHostBridgeGetApertures(IN CONST HOST_BRIDGE_INFO *HostBridge, IN UINTN DataSize, OUT PCI_ROOT_BRIDGE_APERTURE *Io, OUT PCI_ROOT_BRIDGE_APERTURE *Mem, OUT PCI_ROOT_BRIDGE_APERTURE *MemAbove4G, OUT PCI_ROOT_BRIDGE_APERTURE *PMem, OUT PCI_ROOT_BRIDGE_APERTURE *PMemAbove4G, OUT PCI_ROOT_BRIDGE_APERTURE *PcieConfig)
EFI_STATUS HardwareInfoPciHostBridgeGetBusNrRange(IN CONST HOST_BRIDGE_INFO *HostBridge, IN UINTN DataSize, OUT UINTN *BusNrStart, OUT UINTN *BusNrLast)