hc
2024-03-25 edb30157bad0c0001c32b854271ace01d3b9a16a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
/** @file
  Protocol used to support ACPI VT-d DMA remapping reporting
 
  @copyright
  Copyright 2006 - 2021 Intel Corporation. <BR>
 
  SPDX-License-Identifier: BSD-2-Clause-Patent
**/
 
#ifndef __DMA_REMAP_H__
#define __DMA_REMAP_H__
 
//
// Protocol for GUID.
//
typedef struct _DMA_REMAP_PROTOCOL DMA_REMAP_PROTOCOL;
 
#define  DRHD_SIGNATURE  (('D'<<24) + ('R'<<16) + ('H'<<8) + 'D')
#define  RMRR_SIGNATURE  (('R'<<24) + ('M'<<16) + ('R'<<8) + 'R')
#define  ATSR_SIGNATURE  (('A'<<24) + ('T'<<16) + ('S'<<8) + 'R')
#define  RHSA_SIGNATURE  (('A'<<24) + ('S'<<16) + ('H'<<8) + 'R')
#define  ANDD_SIGNATURE  (('A'<<24) + ('N'<<16) + ('D'<<8) + 'D')
 
typedef enum {
  DrhdType,
  RmrrType,
  AtsrType,
  RhsaType
} REMAP_TYPE;
 
typedef enum {
  PciEndpoint = 1,
  PciBridge   = 2
} PCI_DEV_TYPE;
 
typedef struct {
  UINT8         Device;
  UINT8         Function;
} PCI_NODE;
 
typedef struct {
  UINT8         DeviceType;
  UINT8         EnumerationID;
  UINT8         StartBusNumber;
  PCI_NODE      *PciNode;
} DEVICE_SCOPE;
 
typedef struct {
  UINT32        Signature;
  UINT8         Flags;
  UINT16        SegmentNumber;
  UINT64        RegisterBase;
  UINTN         DeviceScopeNumber;
  DEVICE_SCOPE  *DeviceScope;
} DMAR_DRHD;
 
typedef struct {
  UINT32        Signature;
  UINT16        SegmentNumber;
  UINT64        RsvdMemBase;
  UINT64        RsvdMemLimit;
  UINTN         DeviceScopeNumber;
  DEVICE_SCOPE  *DeviceScope;
} DMAR_RMRR;
 
typedef struct {
  UINT32        Signature;
  UINT8         Flags;
  UINT16        SegmentNumber;
  UINTN         DeviceScopeNumber;
  UINT32        ATSRPresentBit;
  DEVICE_SCOPE  *DeviceScope;
} DMAR_ATSR;
 
typedef struct {
  UINT32        Signature;
  UINT64        RegisterBase;
  UINT32        Domian;
  UINT16        RhsaCount;
} DMAR_RHSA;
 
typedef
EFI_STATUS
(EFIAPI *INSERT_DMA_REMAP) (
  IN  DMA_REMAP_PROTOCOL                                        *This,
  IN  REMAP_TYPE                                                RemapType,
  IN  VOID                                                      *RemapEntry
  );
 
typedef
EFI_STATUS
(EFIAPI *GET_DMAR_TABLE) (
  IN  DMA_REMAP_PROTOCOL                                        *This,
  IN  VOID                                                      **DmarTable
  );
 
typedef struct _DMA_REMAP_PROTOCOL {
  BOOLEAN                   VTdSupport;
  BOOLEAN                   DmaCtrlOptIn;
  BOOLEAN                   InterruptRemap;
  BOOLEAN                   X2ApicOptOut;
  BOOLEAN                   ATS;
  INSERT_DMA_REMAP          InsertDmaRemap;
  GET_DMAR_TABLE            GetDmarTable;
} DMA_REMAP_PROTOCOL;
 
extern EFI_GUID gDmaRemapProtocolGuid;
 
#endif