[edk2] [PATCH 07/12] OvmfPkg/IoMmuDxe: clean up used library classes

Laszlo Ersek posted 12 patches 7 years, 4 months ago
[edk2] [PATCH 07/12] OvmfPkg/IoMmuDxe: clean up used library classes
Posted by Laszlo Ersek 7 years, 4 months ago
The following library classes are not used by this module, so remove them
from the INF file's [LibraryClasses] section:
- DxeServicesTableLib
- UefiLib

The following library classes are used by this module, so add them to the
INF file's [LibraryClasses] section:
- BaseMemoryLib (e.g. via CopyMem())
- MemoryAllocationLib (e.g. via AllocatePool())

Sort the list of library classes (in both "IoMmuDxe.inf" and
"AmdSevIoMmu.h").

Remove all non-local #include directives from "IoMmuDxe.c"; both C files
of this module include "AmdSevIoMmu.h", and "AmdSevIoMmu.h" includes all
non-local headers already.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
---
 OvmfPkg/IoMmuDxe/IoMmuDxe.inf  | 8 ++++----
 OvmfPkg/IoMmuDxe/AmdSevIoMmu.h | 4 ++--
 OvmfPkg/IoMmuDxe/IoMmuDxe.c    | 9 ---------
 3 files changed, 6 insertions(+), 15 deletions(-)

diff --git a/OvmfPkg/IoMmuDxe/IoMmuDxe.inf b/OvmfPkg/IoMmuDxe/IoMmuDxe.inf
index 21dc39b9233a..307849706800 100644
--- a/OvmfPkg/IoMmuDxe/IoMmuDxe.inf
+++ b/OvmfPkg/IoMmuDxe/IoMmuDxe.inf
@@ -35,12 +35,12 @@ [Packages]
 
 [LibraryClasses]
   BaseLib
-  UefiLib
-  UefiDriverEntryPoint
-  UefiBootServicesTableLib
-  DxeServicesTableLib
+  BaseMemoryLib
   DebugLib
   MemEncryptSevLib
+  MemoryAllocationLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
 
 [Protocols]
   gEdkiiIoMmuProtocolGuid                     ## SOMETIME_PRODUCES
diff --git a/OvmfPkg/IoMmuDxe/AmdSevIoMmu.h b/OvmfPkg/IoMmuDxe/AmdSevIoMmu.h
index 0f2155350817..bdd83956aab4 100644
--- a/OvmfPkg/IoMmuDxe/AmdSevIoMmu.h
+++ b/OvmfPkg/IoMmuDxe/AmdSevIoMmu.h
@@ -1,36 +1,36 @@
 /** @file
 
   The protocol provides support to allocate, free, map and umap a DMA buffer
   for bus master (e.g PciHostBridge). When SEV is enabled, the DMA operations
   must be performed on unencrypted buffer hence protocol clear the encryption
   bit from the DMA buffer.
 
   Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
   Copyright (c) 2017, AMD Inc. All rights reserved.<BR>
   This program and the accompanying materials are licensed and made available
   under the terms and conditions of the BSD License which accompanies this
   distribution.  The full text of the license may be found at
   http://opensource.org/licenses/bsd-license.php
 
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 **/
 
 #ifndef __AMD_SEV_IOMMU_H_
 #define __AMD_SEV_IOMMU_H
 
 #include <Protocol/IoMmu.h>
 
 #include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
 #include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemEncryptSevLib.h>
 #include <Library/MemoryAllocationLib.h>
 #include <Library/UefiBootServicesTableLib.h>
-#include <Library/MemEncryptSevLib.h>
 
 /**
   Install IOMMU protocol to provide the DMA support for PciHostBridge and
   MemEncryptSevLib.
 
 **/
diff --git a/OvmfPkg/IoMmuDxe/IoMmuDxe.c b/OvmfPkg/IoMmuDxe/IoMmuDxe.c
index 0ea42cbc13ce..70d30ea91627 100644
--- a/OvmfPkg/IoMmuDxe/IoMmuDxe.c
+++ b/OvmfPkg/IoMmuDxe/IoMmuDxe.c
@@ -1,29 +1,20 @@
 /** @file
 
   IoMmuDxe driver installs EDKII_IOMMU_PROTOCOL to provide the support for DMA
   operations when SEV is enabled.
 
   Copyright (c) 2017, AMD Inc. All rights reserved.<BR>
 
   This program and the accompanying materials are licensed and made available
   under the terms and conditions of the BSD License which accompanies this
   distribution.  The full text of the license may be found at
   http://opensource.org/licenses/bsd-license.php
 
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 
 **/
 
-#include <PiDxe.h>
-
-#include <Library/BaseLib.h>
-#include <Library/DebugLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/MemEncryptSevLib.h>
-
 #include "AmdSevIoMmu.h"
 
 EFI_STATUS
-- 
2.13.1.3.g8be5a757fa67


_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel