DmaProtection.h 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691
  1. /** @file
  2. Copyright (c) 2017 - 2019, Intel Corporation. All rights reserved.<BR>
  3. SPDX-License-Identifier: BSD-2-Clause-Patent
  4. **/
  5. #ifndef _DMAR_PROTECTION_H_
  6. #define _DMAR_PROTECTION_H_
  7. #include <Uefi.h>
  8. #include <PiDxe.h>
  9. #include <Library/BaseLib.h>
  10. #include <Library/BaseMemoryLib.h>
  11. #include <Library/MemoryAllocationLib.h>
  12. #include <Library/UefiBootServicesTableLib.h>
  13. #include <Library/IoLib.h>
  14. #include <Library/PciSegmentLib.h>
  15. #include <Library/DebugLib.h>
  16. #include <Library/UefiLib.h>
  17. #include <Library/CacheMaintenanceLib.h>
  18. #include <Library/PerformanceLib.h>
  19. #include <Library/PrintLib.h>
  20. #include <Library/ReportStatusCodeLib.h>
  21. #include <Guid/EventGroup.h>
  22. #include <Guid/Acpi.h>
  23. #include <Protocol/DxeSmmReadyToLock.h>
  24. #include <Protocol/PciRootBridgeIo.h>
  25. #include <Protocol/PciIo.h>
  26. #include <Protocol/PciEnumerationComplete.h>
  27. #include <Protocol/PlatformVtdPolicy.h>
  28. #include <Protocol/IoMmu.h>
  29. #include <Protocol/PciRootBridgeIo.h>
  30. #include <IndustryStandard/Pci.h>
  31. #include <IndustryStandard/DmaRemappingReportingTable.h>
  32. #include <IndustryStandard/Vtd.h>
  33. #define VTD_64BITS_ADDRESS(Lo, Hi) (LShiftU64 (Lo, 12) | LShiftU64 (Hi, 32))
  34. #define ALIGN_VALUE_UP(Value, Alignment) (((Value) + (Alignment) - 1) & (~((Alignment) - 1)))
  35. #define ALIGN_VALUE_LOW(Value, Alignment) ((Value) & (~((Alignment) - 1)))
  36. #define VTD_TPL_LEVEL TPL_NOTIFY
  37. //
  38. // Use 256-bit descriptor
  39. // Queue size is 128.
  40. //
  41. #define VTD_QUEUED_INVALIDATION_DESCRIPTOR_WIDTH 1
  42. #define VTD_INVALIDATION_QUEUE_SIZE 0
  43. //
  44. // This is the initial max PCI DATA number.
  45. // The number may be enlarged later.
  46. //
  47. #define MAX_VTD_PCI_DATA_NUMBER 0x100
  48. typedef struct {
  49. UINT8 DeviceType;
  50. VTD_SOURCE_ID PciSourceId;
  51. EDKII_PLATFORM_VTD_PCI_DEVICE_ID PciDeviceId;
  52. // for statistic analysis
  53. UINTN AccessCount;
  54. } PCI_DEVICE_DATA;
  55. typedef struct {
  56. BOOLEAN IncludeAllFlag;
  57. UINTN PciDeviceDataNumber;
  58. UINTN PciDeviceDataMaxNumber;
  59. PCI_DEVICE_DATA *PciDeviceData;
  60. } PCI_DEVICE_INFORMATION;
  61. typedef struct {
  62. UINTN VtdUnitBaseAddress;
  63. UINT16 Segment;
  64. VTD_VER_REG VerReg;
  65. VTD_CAP_REG CapReg;
  66. VTD_ECAP_REG ECapReg;
  67. VTD_ROOT_ENTRY *RootEntryTable;
  68. VTD_EXT_ROOT_ENTRY *ExtRootEntryTable;
  69. VTD_SECOND_LEVEL_PAGING_ENTRY *FixedSecondLevelPagingEntry;
  70. BOOLEAN HasDirtyContext;
  71. BOOLEAN HasDirtyPages;
  72. PCI_DEVICE_INFORMATION PciDeviceInfo;
  73. BOOLEAN Is5LevelPaging;
  74. UINT8 EnableQueuedInvalidation;
  75. VOID *QiDescBuffer;
  76. UINTN QiDescBufferSize;
  77. } VTD_UNIT_INFORMATION;
  78. //
  79. // This is the initial max ACCESS request.
  80. // The number may be enlarged later.
  81. //
  82. #define MAX_VTD_ACCESS_REQUEST 0x100
  83. typedef struct {
  84. UINT16 Segment;
  85. VTD_SOURCE_ID SourceId;
  86. UINT64 BaseAddress;
  87. UINT64 Length;
  88. UINT64 IoMmuAccess;
  89. } VTD_ACCESS_REQUEST;
  90. /**
  91. The scan bus callback function.
  92. It is called in PCI bus scan for each PCI device under the bus.
  93. @param[in] Context The context of the callback.
  94. @param[in] Segment The segment of the source.
  95. @param[in] Bus The bus of the source.
  96. @param[in] Device The device of the source.
  97. @param[in] Function The function of the source.
  98. @retval EFI_SUCCESS The specific PCI device is processed in the callback.
  99. **/
  100. typedef
  101. EFI_STATUS
  102. (EFIAPI *SCAN_BUS_FUNC_CALLBACK_FUNC) (
  103. IN VOID *Context,
  104. IN UINT16 Segment,
  105. IN UINT8 Bus,
  106. IN UINT8 Device,
  107. IN UINT8 Function
  108. );
  109. extern EFI_ACPI_DMAR_HEADER *mAcpiDmarTable;
  110. extern UINTN mVtdUnitNumber;
  111. extern VTD_UNIT_INFORMATION *mVtdUnitInformation;
  112. extern UINT64 mBelow4GMemoryLimit;
  113. extern UINT64 mAbove4GMemoryLimit;
  114. extern EDKII_PLATFORM_VTD_POLICY_PROTOCOL *mPlatformVTdPolicy;
  115. /**
  116. Prepare VTD configuration.
  117. **/
  118. VOID
  119. PrepareVtdConfig (
  120. VOID
  121. );
  122. /**
  123. Setup VTd translation table.
  124. @retval EFI_SUCCESS Setup translation table successfully.
  125. @retval EFI_OUT_OF_RESOURCE Setup translation table fail.
  126. **/
  127. EFI_STATUS
  128. SetupTranslationTable (
  129. VOID
  130. );
  131. /**
  132. Enable DMAR translation.
  133. @retval EFI_SUCCESS DMAR translation is enabled.
  134. @retval EFI_DEVICE_ERROR DMAR translation is not enabled.
  135. **/
  136. EFI_STATUS
  137. EnableDmar (
  138. VOID
  139. );
  140. /**
  141. Disable DMAR translation.
  142. @retval EFI_SUCCESS DMAR translation is disabled.
  143. @retval EFI_DEVICE_ERROR DMAR translation is not disabled.
  144. **/
  145. EFI_STATUS
  146. DisableDmar (
  147. VOID
  148. );
  149. /**
  150. Flush VTd engine write buffer.
  151. @param[in] VtdIndex The index used to identify a VTd engine.
  152. **/
  153. VOID
  154. FlushWriteBuffer (
  155. IN UINTN VtdIndex
  156. );
  157. /**
  158. Perpare cache invalidation interface.
  159. @param[in] VtdIndex The index used to identify a VTd engine.
  160. @retval EFI_SUCCESS The operation was successful.
  161. @retval EFI_UNSUPPORTED Invalidation method is not supported.
  162. @retval EFI_OUT_OF_RESOURCES A memory allocation failed.
  163. **/
  164. EFI_STATUS
  165. PerpareCacheInvalidationInterface (
  166. IN UINTN VtdIndex
  167. );
  168. /**
  169. Invalidate VTd context cache.
  170. @param[in] VtdIndex The index used to identify a VTd engine.
  171. **/
  172. EFI_STATUS
  173. InvalidateContextCache (
  174. IN UINTN VtdIndex
  175. );
  176. /**
  177. Invalidate VTd IOTLB.
  178. @param[in] VtdIndex The index used to identify a VTd engine.
  179. **/
  180. EFI_STATUS
  181. InvalidateIOTLB (
  182. IN UINTN VtdIndex
  183. );
  184. /**
  185. Invalid VTd global IOTLB.
  186. @param[in] VtdIndex The index of VTd engine.
  187. @retval EFI_SUCCESS VTd global IOTLB is invalidated.
  188. @retval EFI_DEVICE_ERROR VTd global IOTLB is not invalidated.
  189. **/
  190. EFI_STATUS
  191. InvalidateVtdIOTLBGlobal (
  192. IN UINTN VtdIndex
  193. );
  194. /**
  195. Dump VTd registers.
  196. @param[in] VtdIndex The index of VTd engine.
  197. **/
  198. VOID
  199. DumpVtdRegs (
  200. IN UINTN VtdIndex
  201. );
  202. /**
  203. Dump VTd registers for all VTd engine.
  204. **/
  205. VOID
  206. DumpVtdRegsAll (
  207. VOID
  208. );
  209. /**
  210. Dump VTd version registers.
  211. @param[in] VerReg The version register.
  212. **/
  213. VOID
  214. DumpVtdVerRegs (
  215. IN VTD_VER_REG *VerReg
  216. );
  217. /**
  218. Dump VTd capability registers.
  219. @param[in] CapReg The capability register.
  220. **/
  221. VOID
  222. DumpVtdCapRegs (
  223. IN VTD_CAP_REG *CapReg
  224. );
  225. /**
  226. Dump VTd extended capability registers.
  227. @param[in] ECapReg The extended capability register.
  228. **/
  229. VOID
  230. DumpVtdECapRegs (
  231. IN VTD_ECAP_REG *ECapReg
  232. );
  233. /**
  234. Register PCI device to VTd engine.
  235. @param[in] VtdIndex The index of VTd engine.
  236. @param[in] Segment The segment of the source.
  237. @param[in] SourceId The SourceId of the source.
  238. @param[in] DeviceType The DMAR device scope type.
  239. @param[in] CheckExist TRUE: ERROR will be returned if the PCI device is already registered.
  240. FALSE: SUCCESS will be returned if the PCI device is registered.
  241. @retval EFI_SUCCESS The PCI device is registered.
  242. @retval EFI_OUT_OF_RESOURCES No enough resource to register a new PCI device.
  243. @retval EFI_ALREADY_STARTED The device is already registered.
  244. **/
  245. EFI_STATUS
  246. RegisterPciDevice (
  247. IN UINTN VtdIndex,
  248. IN UINT16 Segment,
  249. IN VTD_SOURCE_ID SourceId,
  250. IN UINT8 DeviceType,
  251. IN BOOLEAN CheckExist
  252. );
  253. /**
  254. The scan bus callback function to always enable page attribute.
  255. @param[in] Context The context of the callback.
  256. @param[in] Segment The segment of the source.
  257. @param[in] Bus The bus of the source.
  258. @param[in] Device The device of the source.
  259. @param[in] Function The function of the source.
  260. @retval EFI_SUCCESS The VTd entry is updated to always enable all DMA access for the specific device.
  261. **/
  262. EFI_STATUS
  263. EFIAPI
  264. ScanBusCallbackRegisterPciDevice (
  265. IN VOID *Context,
  266. IN UINT16 Segment,
  267. IN UINT8 Bus,
  268. IN UINT8 Device,
  269. IN UINT8 Function
  270. );
  271. /**
  272. Scan PCI bus and invoke callback function for each PCI devices under the bus.
  273. @param[in] Context The context of the callback function.
  274. @param[in] Segment The segment of the source.
  275. @param[in] Bus The bus of the source.
  276. @param[in] Callback The callback function in PCI scan.
  277. @retval EFI_SUCCESS The PCI devices under the bus are scaned.
  278. **/
  279. EFI_STATUS
  280. ScanPciBus (
  281. IN VOID *Context,
  282. IN UINT16 Segment,
  283. IN UINT8 Bus,
  284. IN SCAN_BUS_FUNC_CALLBACK_FUNC Callback
  285. );
  286. /**
  287. Scan PCI bus and invoke callback function for each PCI devices under all root bus.
  288. @param[in] Context The context of the callback function.
  289. @param[in] Segment The segment of the source.
  290. @param[in] Callback The callback function in PCI scan.
  291. @retval EFI_SUCCESS The PCI devices under the bus are scaned.
  292. **/
  293. EFI_STATUS
  294. ScanAllPciBus (
  295. IN VOID *Context,
  296. IN UINT16 Segment,
  297. IN SCAN_BUS_FUNC_CALLBACK_FUNC Callback
  298. );
  299. /**
  300. Dump the PCI device information managed by this VTd engine.
  301. @param[in] VtdIndex The index of VTd engine.
  302. **/
  303. VOID
  304. DumpPciDeviceInfo (
  305. IN UINTN VtdIndex
  306. );
  307. /**
  308. Find the VTd index by the Segment and SourceId.
  309. @param[in] Segment The segment of the source.
  310. @param[in] SourceId The SourceId of the source.
  311. @param[out] ExtContextEntry The ExtContextEntry of the source.
  312. @param[out] ContextEntry The ContextEntry of the source.
  313. @return The index of the VTd engine.
  314. @retval (UINTN)-1 The VTd engine is not found.
  315. **/
  316. UINTN
  317. FindVtdIndexByPciDevice (
  318. IN UINT16 Segment,
  319. IN VTD_SOURCE_ID SourceId,
  320. OUT VTD_EXT_CONTEXT_ENTRY **ExtContextEntry,
  321. OUT VTD_CONTEXT_ENTRY **ContextEntry
  322. );
  323. /**
  324. Get the DMAR ACPI table.
  325. @retval EFI_SUCCESS The DMAR ACPI table is got.
  326. @retval EFI_ALREADY_STARTED The DMAR ACPI table has been got previously.
  327. @retval EFI_NOT_FOUND The DMAR ACPI table is not found.
  328. **/
  329. EFI_STATUS
  330. GetDmarAcpiTable (
  331. VOID
  332. );
  333. /**
  334. Parse DMAR DRHD table.
  335. @return EFI_SUCCESS The DMAR DRHD table is parsed.
  336. **/
  337. EFI_STATUS
  338. ParseDmarAcpiTableDrhd (
  339. VOID
  340. );
  341. /**
  342. Parse DMAR RMRR table.
  343. @return EFI_SUCCESS The DMAR RMRR table is parsed.
  344. **/
  345. EFI_STATUS
  346. ParseDmarAcpiTableRmrr (
  347. VOID
  348. );
  349. /**
  350. Dump DMAR context entry table.
  351. @param[in] RootEntry DMAR root entry.
  352. @param[in] Is5LevelPaging If it is the 5 level paging.
  353. **/
  354. VOID
  355. DumpDmarContextEntryTable (
  356. IN VTD_ROOT_ENTRY *RootEntry,
  357. IN BOOLEAN Is5LevelPaging
  358. );
  359. /**
  360. Dump DMAR extended context entry table.
  361. @param[in] ExtRootEntry DMAR extended root entry.
  362. @param[in] Is5LevelPaging If it is the 5 level paging.
  363. **/
  364. VOID
  365. DumpDmarExtContextEntryTable (
  366. IN VTD_EXT_ROOT_ENTRY *ExtRootEntry,
  367. IN BOOLEAN Is5LevelPaging
  368. );
  369. /**
  370. Dump DMAR second level paging entry.
  371. @param[in] SecondLevelPagingEntry The second level paging entry.
  372. @param[in] Is5LevelPaging If it is the 5 level paging.
  373. **/
  374. VOID
  375. DumpSecondLevelPagingEntry (
  376. IN VOID *SecondLevelPagingEntry,
  377. IN BOOLEAN Is5LevelPaging
  378. );
  379. /**
  380. Set VTd attribute for a system memory.
  381. @param[in] VtdIndex The index used to identify a VTd engine.
  382. @param[in] DomainIdentifier The domain ID of the source.
  383. @param[in] SecondLevelPagingEntry The second level paging entry in VTd table for the device.
  384. @param[in] BaseAddress The base of device memory address to be used as the DMA memory.
  385. @param[in] Length The length of device memory address to be used as the DMA memory.
  386. @param[in] IoMmuAccess The IOMMU access.
  387. @retval EFI_SUCCESS The IoMmuAccess is set for the memory range specified by BaseAddress and Length.
  388. @retval EFI_INVALID_PARAMETER BaseAddress is not IoMmu Page size aligned.
  389. @retval EFI_INVALID_PARAMETER Length is not IoMmu Page size aligned.
  390. @retval EFI_INVALID_PARAMETER Length is 0.
  391. @retval EFI_INVALID_PARAMETER IoMmuAccess specified an illegal combination of access.
  392. @retval EFI_UNSUPPORTED The bit mask of IoMmuAccess is not supported by the IOMMU.
  393. @retval EFI_UNSUPPORTED The IOMMU does not support the memory range specified by BaseAddress and Length.
  394. @retval EFI_OUT_OF_RESOURCES There are not enough resources available to modify the IOMMU access.
  395. @retval EFI_DEVICE_ERROR The IOMMU device reported an error while attempting the operation.
  396. **/
  397. EFI_STATUS
  398. SetPageAttribute (
  399. IN UINTN VtdIndex,
  400. IN UINT16 DomainIdentifier,
  401. IN VTD_SECOND_LEVEL_PAGING_ENTRY *SecondLevelPagingEntry,
  402. IN UINT64 BaseAddress,
  403. IN UINT64 Length,
  404. IN UINT64 IoMmuAccess
  405. );
  406. /**
  407. Set VTd attribute for a system memory.
  408. @param[in] Segment The Segment used to identify a VTd engine.
  409. @param[in] SourceId The SourceId used to identify a VTd engine and table entry.
  410. @param[in] BaseAddress The base of device memory address to be used as the DMA memory.
  411. @param[in] Length The length of device memory address to be used as the DMA memory.
  412. @param[in] IoMmuAccess The IOMMU access.
  413. @retval EFI_SUCCESS The IoMmuAccess is set for the memory range specified by BaseAddress and Length.
  414. @retval EFI_INVALID_PARAMETER BaseAddress is not IoMmu Page size aligned.
  415. @retval EFI_INVALID_PARAMETER Length is not IoMmu Page size aligned.
  416. @retval EFI_INVALID_PARAMETER Length is 0.
  417. @retval EFI_INVALID_PARAMETER IoMmuAccess specified an illegal combination of access.
  418. @retval EFI_UNSUPPORTED The bit mask of IoMmuAccess is not supported by the IOMMU.
  419. @retval EFI_UNSUPPORTED The IOMMU does not support the memory range specified by BaseAddress and Length.
  420. @retval EFI_OUT_OF_RESOURCES There are not enough resources available to modify the IOMMU access.
  421. @retval EFI_DEVICE_ERROR The IOMMU device reported an error while attempting the operation.
  422. **/
  423. EFI_STATUS
  424. SetAccessAttribute (
  425. IN UINT16 Segment,
  426. IN VTD_SOURCE_ID SourceId,
  427. IN UINT64 BaseAddress,
  428. IN UINT64 Length,
  429. IN UINT64 IoMmuAccess
  430. );
  431. /**
  432. Return the index of PCI data.
  433. @param[in] VtdIndex The index used to identify a VTd engine.
  434. @param[in] Segment The Segment used to identify a VTd engine.
  435. @param[in] SourceId The SourceId used to identify a VTd engine and table entry.
  436. @return The index of the PCI data.
  437. @retval (UINTN)-1 The PCI data is not found.
  438. **/
  439. UINTN
  440. GetPciDataIndex (
  441. IN UINTN VtdIndex,
  442. IN UINT16 Segment,
  443. IN VTD_SOURCE_ID SourceId
  444. );
  445. /**
  446. Dump VTd registers if there is error.
  447. **/
  448. VOID
  449. DumpVtdIfError (
  450. VOID
  451. );
  452. /**
  453. Initialize platform VTd policy.
  454. **/
  455. VOID
  456. InitializePlatformVTdPolicy (
  457. VOID
  458. );
  459. /**
  460. Always enable the VTd page attribute for the device.
  461. @param[in] Segment The Segment used to identify a VTd engine.
  462. @param[in] SourceId The SourceId used to identify a VTd engine and table entry.
  463. @retval EFI_SUCCESS The VTd entry is updated to always enable all DMA access for the specific device.
  464. **/
  465. EFI_STATUS
  466. AlwaysEnablePageAttribute (
  467. IN UINT16 Segment,
  468. IN VTD_SOURCE_ID SourceId
  469. );
  470. /**
  471. Convert the DeviceHandle to SourceId and Segment.
  472. @param[in] DeviceHandle The device who initiates the DMA access request.
  473. @param[out] Segment The Segment used to identify a VTd engine.
  474. @param[out] SourceId The SourceId used to identify a VTd engine and table entry.
  475. @retval EFI_SUCCESS The Segment and SourceId are returned.
  476. @retval EFI_INVALID_PARAMETER DeviceHandle is an invalid handle.
  477. @retval EFI_UNSUPPORTED DeviceHandle is unknown by the IOMMU.
  478. **/
  479. EFI_STATUS
  480. DeviceHandleToSourceId (
  481. IN EFI_HANDLE DeviceHandle,
  482. OUT UINT16 *Segment,
  483. OUT VTD_SOURCE_ID *SourceId
  484. );
  485. /**
  486. Get device information from mapping.
  487. @param[in] Mapping The mapping.
  488. @param[out] DeviceAddress The device address of the mapping.
  489. @param[out] NumberOfPages The number of pages of the mapping.
  490. @retval EFI_SUCCESS The device information is returned.
  491. @retval EFI_INVALID_PARAMETER The mapping is invalid.
  492. **/
  493. EFI_STATUS
  494. GetDeviceInfoFromMapping (
  495. IN VOID *Mapping,
  496. OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
  497. OUT UINTN *NumberOfPages
  498. );
  499. /**
  500. Initialize DMA protection.
  501. **/
  502. VOID
  503. InitializeDmaProtection (
  504. VOID
  505. );
  506. /**
  507. Allocate zero pages.
  508. @param[in] Pages the number of pages.
  509. @return the page address.
  510. @retval NULL No resource to allocate pages.
  511. **/
  512. VOID *
  513. EFIAPI
  514. AllocateZeroPages (
  515. IN UINTN Pages
  516. );
  517. /**
  518. Flush VTD page table and context table memory.
  519. This action is to make sure the IOMMU engine can get final data in memory.
  520. @param[in] VtdIndex The index used to identify a VTd engine.
  521. @param[in] Base The base address of memory to be flushed.
  522. @param[in] Size The size of memory in bytes to be flushed.
  523. **/
  524. VOID
  525. FlushPageTableMemory (
  526. IN UINTN VtdIndex,
  527. IN UINTN Base,
  528. IN UINTN Size
  529. );
  530. /**
  531. Get PCI device information from DMAR DevScopeEntry.
  532. @param[in] Segment The segment number.
  533. @param[in] DmarDevScopeEntry DMAR DevScopeEntry
  534. @param[out] Bus The bus number.
  535. @param[out] Device The device number.
  536. @param[out] Function The function number.
  537. @retval EFI_SUCCESS The PCI device information is returned.
  538. **/
  539. EFI_STATUS
  540. GetPciBusDeviceFunction (
  541. IN UINT16 Segment,
  542. IN EFI_ACPI_DMAR_DEVICE_SCOPE_STRUCTURE_HEADER *DmarDevScopeEntry,
  543. OUT UINT8 *Bus,
  544. OUT UINT8 *Device,
  545. OUT UINT8 *Function
  546. );
  547. /**
  548. Append VTd Access Request to global.
  549. @param[in] Segment The Segment used to identify a VTd engine.
  550. @param[in] SourceId The SourceId used to identify a VTd engine and table entry.
  551. @param[in] BaseAddress The base of device memory address to be used as the DMA memory.
  552. @param[in] Length The length of device memory address to be used as the DMA memory.
  553. @param[in] IoMmuAccess The IOMMU access.
  554. @retval EFI_SUCCESS The IoMmuAccess is set for the memory range specified by BaseAddress and Length.
  555. @retval EFI_INVALID_PARAMETER BaseAddress is not IoMmu Page size aligned.
  556. @retval EFI_INVALID_PARAMETER Length is not IoMmu Page size aligned.
  557. @retval EFI_INVALID_PARAMETER Length is 0.
  558. @retval EFI_INVALID_PARAMETER IoMmuAccess specified an illegal combination of access.
  559. @retval EFI_UNSUPPORTED The bit mask of IoMmuAccess is not supported by the IOMMU.
  560. @retval EFI_UNSUPPORTED The IOMMU does not support the memory range specified by BaseAddress and Length.
  561. @retval EFI_OUT_OF_RESOURCES There are not enough resources available to modify the IOMMU access.
  562. @retval EFI_DEVICE_ERROR The IOMMU device reported an error while attempting the operation.
  563. **/
  564. EFI_STATUS
  565. RequestAccessAttribute (
  566. IN UINT16 Segment,
  567. IN VTD_SOURCE_ID SourceId,
  568. IN UINT64 BaseAddress,
  569. IN UINT64 Length,
  570. IN UINT64 IoMmuAccess
  571. );
  572. #endif