\r
Copyright (C) 2016, Red Hat, Inc.\r
\r
- This program and the accompanying materials are licensed and made available\r
- under the terms and conditions of the BSD License which accompanies this\r
- distribution. The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.php\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
- WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
**/\r
\r
-#include <Library/MemoryAllocationLib.h>\r
+#include <Library/DebugLib.h> // DEBUG()\r
+#include <Library/MemoryAllocationLib.h> // AllocatePool()\r
+#include <Library/UefiBootServicesTableLib.h> // gBS\r
\r
#include "AcpiPlatform.h"\r
\r
-\r
/**\r
Collect all PciIo protocol instances in the system. Save their original\r
attributes, and enable IO and MMIO decoding for each.\r
**/\r
VOID\r
EnablePciDecoding (\r
- OUT ORIGINAL_ATTRIBUTES **OriginalAttributes,\r
- OUT UINTN *Count\r
+ OUT ORIGINAL_ATTRIBUTES **OriginalAttributes,\r
+ OUT UINTN *Count\r
)\r
{\r
- EFI_STATUS Status;\r
- UINTN NoHandles;\r
- EFI_HANDLE *Handles;\r
- ORIGINAL_ATTRIBUTES *OrigAttrs;\r
- UINTN Idx;\r
+ EFI_STATUS Status;\r
+ UINTN NoHandles;\r
+ EFI_HANDLE *Handles;\r
+ ORIGINAL_ATTRIBUTES *OrigAttrs;\r
+ UINTN Idx;\r
\r
*OriginalAttributes = NULL;\r
*Count = 0;\r
return;\r
}\r
\r
- Status = gBS->LocateHandleBuffer (ByProtocol, &gEfiPciIoProtocolGuid,\r
- NULL /* SearchKey */, &NoHandles, &Handles);\r
+ Status = gBS->LocateHandleBuffer (\r
+ ByProtocol,\r
+ &gEfiPciIoProtocolGuid,\r
+ NULL /* SearchKey */,\r
+ &NoHandles,\r
+ &Handles\r
+ );\r
if (Status == EFI_NOT_FOUND) {\r
//\r
// No PCI devices were found on either of the root bridges. We're done.\r
}\r
\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_WARN, "%a: LocateHandleBuffer(): %r\n", __FUNCTION__,\r
- Status));\r
+ DEBUG ((\r
+ DEBUG_WARN,\r
+ "%a: LocateHandleBuffer(): %r\n",\r
+ __FUNCTION__,\r
+ Status\r
+ ));\r
return;\r
}\r
\r
OrigAttrs = AllocatePool (NoHandles * sizeof *OrigAttrs);\r
if (OrigAttrs == NULL) {\r
- DEBUG ((EFI_D_WARN, "%a: AllocatePool(): out of resources\n",\r
- __FUNCTION__));\r
+ DEBUG ((\r
+ DEBUG_WARN,\r
+ "%a: AllocatePool(): out of resources\n",\r
+ __FUNCTION__\r
+ ));\r
goto FreeHandles;\r
}\r
\r
for (Idx = 0; Idx < NoHandles; ++Idx) {\r
- EFI_PCI_IO_PROTOCOL *PciIo;\r
- UINT64 Attributes;\r
+ EFI_PCI_IO_PROTOCOL *PciIo;\r
+ UINT64 Attributes;\r
\r
//\r
// Look up PciIo on the handle and stash it\r
//\r
- Status = gBS->HandleProtocol (Handles[Idx], &gEfiPciIoProtocolGuid,\r
- (VOID**)&PciIo);\r
+ Status = gBS->HandleProtocol (\r
+ Handles[Idx],\r
+ &gEfiPciIoProtocolGuid,\r
+ (VOID **)&PciIo\r
+ );\r
ASSERT_EFI_ERROR (Status);\r
OrigAttrs[Idx].PciIo = PciIo;\r
\r
//\r
// Stash the current attributes\r
//\r
- Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationGet, 0,\r
- &OrigAttrs[Idx].PciAttributes);\r
+ Status = PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationGet,\r
+ 0,\r
+ &OrigAttrs[Idx].PciAttributes\r
+ );\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_WARN, "%a: EfiPciIoAttributeOperationGet: %r\n",\r
- __FUNCTION__, Status));\r
+ DEBUG ((\r
+ DEBUG_WARN,\r
+ "%a: EfiPciIoAttributeOperationGet: %r\n",\r
+ __FUNCTION__,\r
+ Status\r
+ ));\r
goto RestoreAttributes;\r
}\r
\r
//\r
// Retrieve supported attributes\r
//\r
- Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationSupported, 0,\r
- &Attributes);\r
+ Status = PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationSupported,\r
+ 0,\r
+ &Attributes\r
+ );\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_WARN, "%a: EfiPciIoAttributeOperationSupported: %r\n",\r
- __FUNCTION__, Status));\r
+ DEBUG ((\r
+ DEBUG_WARN,\r
+ "%a: EfiPciIoAttributeOperationSupported: %r\n",\r
+ __FUNCTION__,\r
+ Status\r
+ ));\r
goto RestoreAttributes;\r
}\r
\r
// Enable IO and MMIO decoding\r
//\r
Attributes &= EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY;\r
- Status = PciIo->Attributes (PciIo, EfiPciIoAttributeOperationEnable,\r
- Attributes, NULL);\r
+ Status = PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationEnable,\r
+ Attributes,\r
+ NULL\r
+ );\r
if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_WARN, "%a: EfiPciIoAttributeOperationEnable: %r\n",\r
- __FUNCTION__, Status));\r
+ DEBUG ((\r
+ DEBUG_WARN,\r
+ "%a: EfiPciIoAttributeOperationEnable: %r\n",\r
+ __FUNCTION__,\r
+ Status\r
+ ));\r
goto RestoreAttributes;\r
}\r
}\r
RestoreAttributes:\r
while (Idx > 0) {\r
--Idx;\r
- OrigAttrs[Idx].PciIo->Attributes (OrigAttrs[Idx].PciIo,\r
+ OrigAttrs[Idx].PciIo->Attributes (\r
+ OrigAttrs[Idx].PciIo,\r
EfiPciIoAttributeOperationSet,\r
OrigAttrs[Idx].PciAttributes,\r
NULL\r
);\r
}\r
+\r
FreePool (OrigAttrs);\r
\r
FreeHandles:\r
FreePool (Handles);\r
}\r
\r
-\r
/**\r
Restore the original PCI attributes saved with EnablePciDecoding().\r
\r
**/\r
VOID\r
RestorePciDecoding (\r
- IN ORIGINAL_ATTRIBUTES *OriginalAttributes,\r
- IN UINTN Count\r
+ IN ORIGINAL_ATTRIBUTES *OriginalAttributes,\r
+ IN UINTN Count\r
)\r
{\r
- UINTN Idx;\r
+ UINTN Idx;\r
\r
ASSERT ((OriginalAttributes == NULL) == (Count == 0));\r
if (OriginalAttributes == NULL) {\r
NULL\r
);\r
}\r
+\r
FreePool (OriginalAttributes);\r
}\r