]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/LegacyRegion2.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Include / Protocol / LegacyRegion2.h
CommitLineData
23bb88ec 1/** @file\r
2 The Legacy Region Protocol controls the read, write and boot-lock attributes for\r
3 the region 0xC0000 to 0xFFFFF.\r
4\r
9095d37b 5 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
9344f092 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
23bb88ec 7\r
8 @par Revision Reference:\r
9095d37b 9 This Protocol is defined in UEFI Platform Initialization Specification 1.2\r
23bb88ec 10 Volume 5: Standards\r
11\r
23bb88ec 12**/\r
13\r
14#ifndef __LEGACY_REGION2_H__\r
15#define __LEGACY_REGION2_H__\r
16\r
23bb88ec 17#define EFI_LEGACY_REGION2_PROTOCOL_GUID \\r
18{ \\r
19 0x70101eaf, 0x85, 0x440c, {0xb3, 0x56, 0x8e, 0xe3, 0x6f, 0xef, 0x24, 0xf0 } \\r
20}\r
21\r
22typedef struct _EFI_LEGACY_REGION2_PROTOCOL EFI_LEGACY_REGION2_PROTOCOL;\r
23\r
24/**\r
25 Modify the hardware to allow (decode) or disallow (not decode) memory reads in a region.\r
26\r
9095d37b 27 If the On parameter evaluates to TRUE, this function enables memory reads in the address range\r
23bb88ec 28 Start to (Start + Length - 1).\r
9095d37b 29 If the On parameter evaluates to FALSE, this function disables memory reads in the address range\r
23bb88ec 30 Start to (Start + Length - 1).\r
31\r
32 @param This[in] Indicates the EFI_LEGACY_REGION2_PROTOCOL instance.\r
33 @param Start[in] The beginning of the physical address of the region whose attributes\r
34 should be modified.\r
35 @param Length[in] The number of bytes of memory whose attributes should be modified.\r
36 The actual number of bytes modified may be greater than the number\r
37 specified.\r
38 @param Granularity[out] The number of bytes in the last region affected. This may be less\r
39 than the total number of bytes affected if the starting address\r
40 was not aligned to a region's starting address or if the length\r
41 was greater than the number of bytes in the first region.\r
42 @param On[in] Decode / Non-Decode flag.\r
43\r
44 @retval EFI_SUCCESS The region's attributes were successfully modified.\r
45 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r
46\r
47**/\r
48typedef\r
49EFI_STATUS\r
a1749b80 50(EFIAPI *EFI_LEGACY_REGION2_DECODE)(\r
2f88bd3a
MK
51 IN EFI_LEGACY_REGION2_PROTOCOL *This,\r
52 IN UINT32 Start,\r
53 IN UINT32 Length,\r
54 OUT UINT32 *Granularity,\r
55 IN BOOLEAN *On\r
56 );\r
23bb88ec 57\r
58/**\r
59 Modify the hardware to disallow memory writes in a region.\r
60\r
61 This function changes the attributes of a memory range to not allow writes.\r
62\r
63 @param This[in] Indicates the EFI_LEGACY_REGION2_PROTOCOL instance.\r
64 @param Start[in] The beginning of the physical address of the region whose\r
65 attributes should be modified.\r
66 @param Length[in] The number of bytes of memory whose attributes should be modified.\r
67 The actual number of bytes modified may be greater than the number\r
68 specified.\r
69 @param Granularity[out] The number of bytes in the last region affected. This may be less\r
70 than the total number of bytes affected if the starting address was\r
71 not aligned to a region's starting address or if the length was\r
72 greater than the number of bytes in the first region.\r
73\r
74 @retval EFI_SUCCESS The region's attributes were successfully modified.\r
75 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r
76\r
77**/\r
78typedef\r
79EFI_STATUS\r
a1749b80 80(EFIAPI *EFI_LEGACY_REGION2_LOCK)(\r
2f88bd3a
MK
81 IN EFI_LEGACY_REGION2_PROTOCOL *This,\r
82 IN UINT32 Start,\r
83 IN UINT32 Length,\r
84 OUT UINT32 *Granularity\r
85 );\r
23bb88ec 86\r
87/**\r
88 Modify the hardware to disallow memory attribute changes in a region.\r
89\r
9095d37b 90 This function makes the attributes of a region read only. Once a region is boot-locked with this\r
23bb88ec 91 function, the read and write attributes of that region cannot be changed until a power cycle has\r
92 reset the boot-lock attribute. Calls to Decode(), Lock() and Unlock() will have no effect.\r
93\r
94 @param This[in] Indicates the EFI_LEGACY_REGION2_PROTOCOL instance.\r
95 @param Start[in] The beginning of the physical address of the region whose\r
96 attributes should be modified.\r
97 @param Length[in] The number of bytes of memory whose attributes should be modified.\r
98 The actual number of bytes modified may be greater than the number\r
99 specified.\r
100 @param Granularity[out] The number of bytes in the last region affected. This may be less\r
101 than the total number of bytes affected if the starting address was\r
102 not aligned to a region's starting address or if the length was\r
103 greater than the number of bytes in the first region.\r
104\r
105 @retval EFI_SUCCESS The region's attributes were successfully modified.\r
106 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r
107 @retval EFI_UNSUPPORTED The chipset does not support locking the configuration registers in\r
108 a way that will not affect memory regions outside the legacy memory\r
109 region.\r
110\r
111**/\r
112typedef\r
113EFI_STATUS\r
114(EFIAPI *EFI_LEGACY_REGION2_BOOT_LOCK)(\r
115 IN EFI_LEGACY_REGION2_PROTOCOL *This,\r
116 IN UINT32 Start,\r
117 IN UINT32 Length,\r
118 OUT UINT32 *Granularity OPTIONAL\r
119 );\r
120\r
23bb88ec 121/**\r
122 Modify the hardware to allow memory writes in a region.\r
123\r
9095d37b 124 This function changes the attributes of a memory range to allow writes.\r
23bb88ec 125\r
126 @param This[in] Indicates the EFI_LEGACY_REGION2_PROTOCOL instance.\r
127 @param Start[in] The beginning of the physical address of the region whose\r
128 attributes should be modified.\r
129 @param Length[in] The number of bytes of memory whose attributes should be modified.\r
130 The actual number of bytes modified may be greater than the number\r
131 specified.\r
132 @param Granularity[out] The number of bytes in the last region affected. This may be less\r
133 than the total number of bytes affected if the starting address was\r
134 not aligned to a region's starting address or if the length was\r
135 greater than the number of bytes in the first region.\r
136\r
137 @retval EFI_SUCCESS The region's attributes were successfully modified.\r
138 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r
139\r
140**/\r
141typedef\r
142EFI_STATUS\r
a1749b80 143(EFIAPI *EFI_LEGACY_REGION2_UNLOCK)(\r
2f88bd3a
MK
144 IN EFI_LEGACY_REGION2_PROTOCOL *This,\r
145 IN UINT32 Start,\r
146 IN UINT32 Length,\r
147 OUT UINT32 *Granularity\r
148 );\r
23bb88ec 149\r
150typedef enum {\r
151 LegacyRegionDecoded, ///< This region is currently set to allow reads.\r
152 LegacyRegionNotDecoded, ///< This region is currently set to not allow reads.\r
153 LegacyRegionWriteEnabled, ///< This region is currently set to allow writes.\r
154 LegacyRegionWriteDisabled, ///< This region is currently set to write protected.\r
155 LegacyRegionBootLocked, ///< This region's attributes are locked, cannot be modified until\r
156 ///< after a power cycle.\r
157 LegacyRegionNotLocked ///< This region's attributes are not locked.\r
158} EFI_LEGACY_REGION_ATTRIBUTE;\r
159\r
23bb88ec 160typedef struct {\r
e3f903d5 161 ///\r
162 /// The beginning of the physical address of this\r
163 /// region.\r
164 ///\r
2f88bd3a 165 UINT32 Start;\r
e3f903d5 166 ///\r
167 /// The number of bytes in this region.\r
168 ///\r
2f88bd3a 169 UINT32 Length;\r
e3f903d5 170 ///\r
171 /// Attribute of the Legacy Region Descriptor that\r
172 /// describes the capabilities for that memory region.\r
173 ///\r
2f88bd3a 174 EFI_LEGACY_REGION_ATTRIBUTE Attribute;\r
e3f903d5 175 ///\r
176 /// Describes the byte length programmability\r
177 /// associated with the Start address and the specified\r
178 /// Attribute setting.\r
2f88bd3a 179 UINT32 Granularity;\r
23bb88ec 180} EFI_LEGACY_REGION_DESCRIPTOR;\r
181\r
23bb88ec 182/**\r
183 Get region information for the attributes of the Legacy Region.\r
184\r
9095d37b 185 This function is used to discover the granularity of the attributes for the memory in the legacy\r
23bb88ec 186 region. Each attribute may have a different granularity and the granularity may not be the same\r
9095d37b 187 for all memory ranges in the legacy region.\r
23bb88ec 188\r
189 @param This[in] Indicates the EFI_LEGACY_REGION2_PROTOCOL instance.\r
190 @param DescriptorCount[out] The number of region descriptor entries returned in the Descriptor\r
191 buffer.\r
192 @param Descriptor[out] A pointer to a pointer used to return a buffer where the legacy\r
193 region information is deposited. This buffer will contain a list of\r
194 DescriptorCount number of region descriptors. This function will\r
195 provide the memory for the buffer.\r
196\r
197 @retval EFI_SUCCESS The information structure was returned.\r
198 @retval EFI_UNSUPPORTED This function is not supported.\r
199\r
200**/\r
201typedef\r
202EFI_STATUS\r
a1749b80 203(EFIAPI *EFI_LEGACY_REGION_GET_INFO)(\r
23bb88ec 204 IN EFI_LEGACY_REGION2_PROTOCOL *This,\r
205 OUT UINT32 *DescriptorCount,\r
206 OUT EFI_LEGACY_REGION_DESCRIPTOR **Descriptor\r
207 );\r
208\r
9095d37b
LG
209///\r
210/// The EFI_LEGACY_REGION2_PROTOCOL is used to abstract the hardware control of the memory\r
e3f903d5 211/// attributes of the Option ROM shadowing region, 0xC0000 to 0xFFFFF.\r
212/// There are three memory attributes that can be modified through this protocol: read, write and\r
213/// boot-lock. These protocols may be set in any combination.\r
214///\r
23bb88ec 215struct _EFI_LEGACY_REGION2_PROTOCOL {\r
2f88bd3a
MK
216 EFI_LEGACY_REGION2_DECODE Decode;\r
217 EFI_LEGACY_REGION2_LOCK Lock;\r
218 EFI_LEGACY_REGION2_BOOT_LOCK BootLock;\r
219 EFI_LEGACY_REGION2_UNLOCK UnLock;\r
220 EFI_LEGACY_REGION_GET_INFO GetInfo;\r
23bb88ec 221};\r
222\r
2f88bd3a 223extern EFI_GUID gEfiLegacyRegion2ProtocolGuid;\r
23bb88ec 224\r
225#endif\r