| 1 | /** @file\r |
| 2 | The definition for DMA access Library.\r |
| 3 | \r |
| 4 | Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r |
| 5 | This program and the accompanying materials\r |
| 6 | are licensed and made available under the terms and conditions of the BSD License\r |
| 7 | which accompanies this distribution. The full text of the license may be found at\r |
| 8 | http://opensource.org/licenses/bsd-license.php.\r |
| 9 | \r |
| 10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
| 11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r |
| 12 | \r |
| 13 | **/\r |
| 14 | \r |
| 15 | #ifndef __DMA_ACCESS_LIB_H__\r |
| 16 | #define __DMA_ACCESS_LIB_H__\r |
| 17 | \r |
| 18 | typedef struct {\r |
| 19 | UINT8 HostAddressWidth;\r |
| 20 | UINTN VTdEngineCount;\r |
| 21 | UINT64 VTdEngineAddress[1];\r |
| 22 | } VTD_INFO;\r |
| 23 | \r |
| 24 | /**\r |
| 25 | Set DMA protected region.\r |
| 26 | \r |
| 27 | @param EngineMask The mask of the VTd engine to be accessed.\r |
| 28 | @param LowMemoryBase The protected low memory region base.\r |
| 29 | @param LowMemoryLength The protected low memory region length.\r |
| 30 | @param HighMemoryBase The protected high memory region base.\r |
| 31 | @param HighMemoryLength The protected high memory region length.\r |
| 32 | \r |
| 33 | @retval EFI_SUCCESS The DMA protection is set.\r |
| 34 | @retval EFI_UNSUPPORTED The DMA protection is not set.\r |
| 35 | **/\r |
| 36 | EFI_STATUS\r |
| 37 | SetDmaProtectedRange (\r |
| 38 | IN UINT64 EngineMask,\r |
| 39 | IN UINT32 LowMemoryBase,\r |
| 40 | IN UINT32 LowMemoryLength,\r |
| 41 | IN UINT64 HighMemoryBase,\r |
| 42 | IN UINT64 HighMemoryLength\r |
| 43 | );\r |
| 44 | \r |
| 45 | /**\r |
| 46 | Diable DMA protection.\r |
| 47 | \r |
| 48 | @param EngineMask The mask of the VTd engine to be accessed.\r |
| 49 | \r |
| 50 | @retval DMA protection is disabled.\r |
| 51 | **/\r |
| 52 | EFI_STATUS\r |
| 53 | DisableDmaProtection (\r |
| 54 | IN UINT64 EngineMask\r |
| 55 | );\r |
| 56 | \r |
| 57 | /**\r |
| 58 | Get protected low memory alignment.\r |
| 59 | \r |
| 60 | @param EngineMask The mask of the VTd engine to be accessed.\r |
| 61 | \r |
| 62 | @return protected low memory alignment.\r |
| 63 | **/\r |
| 64 | UINT32\r |
| 65 | GetLowMemoryAlignment (\r |
| 66 | IN UINT64 EngineMask\r |
| 67 | );\r |
| 68 | \r |
| 69 | /**\r |
| 70 | Get protected high memory alignment.\r |
| 71 | \r |
| 72 | @param EngineMask The mask of the VTd engine to be accessed.\r |
| 73 | \r |
| 74 | @return protected high memory alignment.\r |
| 75 | **/\r |
| 76 | UINT64\r |
| 77 | GetHighMemoryAlignment (\r |
| 78 | IN UINT64 EngineMask\r |
| 79 | );\r |
| 80 | \r |
| 81 | #endif\r |
| 82 | \r |