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