]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/IoMmuDxe/IoMmuDxe.c
0ea42cbc13cee853b2ad23c1b0de4ce106c287f7
[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 are licensed and made available
9 under the terms and conditions of the BSD License which accompanies this
10 distribution. The full text of the license may be found at
11 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;
37 EFI_HANDLE Handle;
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 Status = AmdSevInstallIoMmuProtocol ();
45 } else {
46 Handle = NULL;
47
48 Status = gBS->InstallMultipleProtocolInterfaces (
49 &Handle,
50 &gIoMmuAbsentProtocolGuid,
51 NULL, NULL);
52 }
53
54 return Status;
55 }