51 *OriginalAttributes =
NULL;
54 if (
PcdGetBool (PcdPciDisableBusEnumeration)) {
62 Status =
gBS->LocateHandleBuffer (
64 &gEfiPciIoProtocolGuid,
69 if (Status == EFI_NOT_FOUND) {
76 if (EFI_ERROR (Status)) {
79 "%a: LocateHandleBuffer(): %r\n",
86 OrigAttrs =
AllocatePool (NoHandles *
sizeof *OrigAttrs);
87 if (OrigAttrs ==
NULL) {
90 "%a: AllocatePool(): out of resources\n",
96 for (Idx = 0; Idx < NoHandles; ++Idx) {
103 Status =
gBS->HandleProtocol (
105 &gEfiPciIoProtocolGuid,
109 OrigAttrs[Idx].PciIo = PciIo;
114 Status = PciIo->Attributes (
118 &OrigAttrs[Idx].PciAttributes
120 if (EFI_ERROR (Status)) {
123 "%a: EfiPciIoAttributeOperationGet: %r\n",
127 goto RestoreAttributes;
133 Status = PciIo->Attributes (
139 if (EFI_ERROR (Status)) {
142 "%a: EfiPciIoAttributeOperationSupported: %r\n",
146 goto RestoreAttributes;
153 Status = PciIo->Attributes (
159 if (EFI_ERROR (Status)) {
162 "%a: EfiPciIoAttributeOperationEnable: %r\n",
166 goto RestoreAttributes;
174 *OriginalAttributes = OrigAttrs;
181 OrigAttrs[Idx].PciIo->Attributes (
182 OrigAttrs[Idx].PciIo,
184 OrigAttrs[Idx].PciAttributes,
218 ASSERT ((OriginalAttributes ==
NULL) == (Count == 0));
219 if (OriginalAttributes ==
NULL) {
223 for (Idx = 0; Idx < Count; ++Idx) {
224 OriginalAttributes[Idx].PciIo->Attributes (
225 OriginalAttributes[Idx].PciIo,
227 OriginalAttributes[Idx].PciAttributes,
VOID EFIAPI FreePool(IN VOID *Buffer)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
@ EfiPciIoAttributeOperationGet
@ EfiPciIoAttributeOperationEnable
@ EfiPciIoAttributeOperationSet
@ EfiPciIoAttributeOperationSupported
#define EFI_PCI_IO_ATTRIBUTE_MEMORY
Enable the Memory decode bit in the PCI Config Header.
#define EFI_PCI_IO_ATTRIBUTE_IO
Enable the I/O decode bit in the PCI Config Header.
#define PcdGetBool(TokenName)
VOID RestorePciDecoding(IN ORIGINAL_ATTRIBUTES *OriginalAttributes, IN UINTN Count)
VOID EnablePciDecoding(OUT ORIGINAL_ATTRIBUTES **OriginalAttributes, OUT UINTN *Count)
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)