]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/IoMmuDxe/IoMmuDxe.c
OvmfPkg: Add IoMmuDxe driver
[mirror_edk2.git] / OvmfPkg / IoMmuDxe / IoMmuDxe.c
1 /** @file
2
3 IoMmuDxe driver installs EDKII_IOMMU_PROTOCOL to provide the support for DMA
4 operations when SEV is enabled.
5
6 Copyright (c) 2017, AMD Inc. All rights reserved.<BR>
7
8 This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD
10 License which accompanies this distribution. The full text of the license may
11 be found at http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17
18 #include <PiDxe.h>
19
20 #include <Library/BaseLib.h>
21 #include <Library/DebugLib.h>
22 #include <Library/BaseMemoryLib.h>
23 #include <Library/MemoryAllocationLib.h>
24 #include <Library/UefiBootServicesTableLib.h>
25 #include <Library/MemEncryptSevLib.h>
26
27 #include "AmdSevIoMmu.h"
28
29 EFI_STATUS
30 EFIAPI
31 IoMmuDxeEntryPoint (
32 IN EFI_HANDLE ImageHandle,
33 IN EFI_SYSTEM_TABLE *SystemTable
34 )
35 {
36 EFI_STATUS Status = EFI_SUCCESS;
37 EFI_HANDLE Handle = NULL;
38
39 //
40 // When SEV is enabled, install IoMmu protocol otherwise install the
41 // placeholder protocol so that other dependent module can run.
42 //
43 if (MemEncryptSevIsEnabled ()) {
44 AmdSevInstallIoMmuProtocol ();
45 } else {
46 Status = gBS->InstallMultipleProtocolInterfaces (
47 &Handle,
48 &gIoMmuAbsentProtocolGuid,
49 NULL, NULL);
50 }
51
52 return Status;
53 }