2 Dummy implementation of Legacy Region 2 Protocol.
4 This generic implementation of the Legacy Region 2 Protocol does not actually
5 perform any lock/unlock operations. This module may be used on platforms
6 that do not provide HW locking of the legacy memory regions. It can also
7 be used as a template driver for implementing the Legacy Region 2 Protocol on
8 a platform that does support HW locking of the legacy memory regions.
10 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>
11 SPDX-License-Identifier: BSD-2-Clause-Patent
15 #include <LegacyRegion2.h>
17 EFI_HANDLE mLegacyRegion2Handle
= NULL
;
19 EFI_LEGACY_REGION2_PROTOCOL mLegacyRegion2
= {
22 LegacyRegion2BootLock
,
28 Modify the hardware to allow (decode) or disallow (not decode) memory reads in a region.
30 If the On parameter evaluates to TRUE, this function enables memory reads in the address range
31 Start to (Start + Length - 1).
32 If the On parameter evaluates to FALSE, this function disables memory reads in the address range
33 Start to (Start + Length - 1).
35 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
36 @param Start[in] The beginning of the physical address of the region whose attributes
38 @param Length[in] The number of bytes of memory whose attributes should be modified.
39 The actual number of bytes modified may be greater than the number
41 @param Granularity[out] The number of bytes in the last region affected. This may be less
42 than the total number of bytes affected if the starting address
43 was not aligned to a region's starting address or if the length
44 was greater than the number of bytes in the first region.
45 @param On[in] Decode / Non-Decode flag.
47 @retval EFI_SUCCESS The region's attributes were successfully modified.
48 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
54 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
57 OUT UINT32
*Granularity
,
61 if ((Start
< 0xC0000) || ((Start
+ Length
- 1) > 0xFFFFF)) {
62 return EFI_INVALID_PARAMETER
;
65 ASSERT (Granularity
!= NULL
);
71 Modify the hardware to disallow memory writes in a region.
73 This function changes the attributes of a memory range to not allow writes.
75 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
76 @param Start[in] The beginning of the physical address of the region whose
77 attributes should be modified.
78 @param Length[in] The number of bytes of memory whose attributes should be modified.
79 The actual number of bytes modified may be greater than the number
81 @param Granularity[out] The number of bytes in the last region affected. This may be less
82 than the total number of bytes affected if the starting address was
83 not aligned to a region's starting address or if the length was
84 greater than the number of bytes in the first region.
86 @retval EFI_SUCCESS The region's attributes were successfully modified.
87 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
93 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
96 OUT UINT32
*Granularity
99 if ((Start
< 0xC0000) || ((Start
+ Length
- 1) > 0xFFFFF)) {
100 return EFI_INVALID_PARAMETER
;
103 ASSERT (Granularity
!= NULL
);
109 Modify the hardware to disallow memory attribute changes in a region.
111 This function makes the attributes of a region read only. Once a region is boot-locked with this
112 function, the read and write attributes of that region cannot be changed until a power cycle has
113 reset the boot-lock attribute. Calls to Decode(), Lock() and Unlock() will have no effect.
115 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
116 @param Start[in] The beginning of the physical address of the region whose
117 attributes should be modified.
118 @param Length[in] The number of bytes of memory whose attributes should be modified.
119 The actual number of bytes modified may be greater than the number
121 @param Granularity[out] The number of bytes in the last region affected. This may be less
122 than the total number of bytes affected if the starting address was
123 not aligned to a region's starting address or if the length was
124 greater than the number of bytes in the first region.
126 @retval EFI_SUCCESS The region's attributes were successfully modified.
127 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
128 @retval EFI_UNSUPPORTED The chipset does not support locking the configuration registers in
129 a way that will not affect memory regions outside the legacy memory
135 LegacyRegion2BootLock (
136 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
139 OUT UINT32
*Granularity
142 if ((Start
< 0xC0000) || ((Start
+ Length
- 1) > 0xFFFFF)) {
143 return EFI_INVALID_PARAMETER
;
146 return EFI_UNSUPPORTED
;
150 Modify the hardware to allow memory writes in a region.
152 This function changes the attributes of a memory range to allow writes.
154 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
155 @param Start[in] The beginning of the physical address of the region whose
156 attributes should be modified.
157 @param Length[in] The number of bytes of memory whose attributes should be modified.
158 The actual number of bytes modified may be greater than the number
160 @param Granularity[out] The number of bytes in the last region affected. This may be less
161 than the total number of bytes affected if the starting address was
162 not aligned to a region's starting address or if the length was
163 greater than the number of bytes in the first region.
165 @retval EFI_SUCCESS The region's attributes were successfully modified.
166 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
171 LegacyRegion2Unlock (
172 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
175 OUT UINT32
*Granularity
178 if ((Start
< 0xC0000) || ((Start
+ Length
- 1) > 0xFFFFF)) {
179 return EFI_INVALID_PARAMETER
;
182 ASSERT (Granularity
!= NULL
);
188 Get region information for the attributes of the Legacy Region.
190 This function is used to discover the granularity of the attributes for the memory in the legacy
191 region. Each attribute may have a different granularity and the granularity may not be the same
192 for all memory ranges in the legacy region.
194 @param This[in] Indicates the EFI_LEGACY_REGION2_PROTOCOL instance.
195 @param DescriptorCount[out] The number of region descriptor entries returned in the Descriptor
197 @param Descriptor[out] A pointer to a pointer used to return a buffer where the legacy
198 region information is deposited. This buffer will contain a list of
199 DescriptorCount number of region descriptors. This function will
200 provide the memory for the buffer.
202 @retval EFI_SUCCESS The information structure was returned.
203 @retval EFI_UNSUPPORTED This function is not supported.
208 LegacyRegionGetInfo (
209 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
210 OUT UINT32
*DescriptorCount
,
211 OUT EFI_LEGACY_REGION_DESCRIPTOR
**Descriptor
214 return EFI_UNSUPPORTED
;
218 The user Entry Point for module LegacyRegionDxe. The user code starts with this function.
220 @param[in] ImageHandle The firmware allocated handle for the EFI image.
221 @param[in] SystemTable A pointer to the EFI System Table.
223 @retval EFI_SUCCESS The entry point is executed successfully.
228 LegacyRegion2Install (
229 IN EFI_HANDLE ImageHandle
,
230 IN EFI_SYSTEM_TABLE
*SystemTable
236 // Make sure the Legacy Region 2 Protocol is not already installed in the system
238 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL
, &gEfiLegacyRegion2ProtocolGuid
);
241 // Install the protocol on a new handle.
243 Status
= gBS
->InstallMultipleProtocolInterfaces (
244 &mLegacyRegion2Handle
,
245 &gEfiLegacyRegion2ProtocolGuid
, &mLegacyRegion2
,
248 ASSERT_EFI_ERROR (Status
);