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 - 2010, Intel Corporation. All rights reserved.<BR>
11 This program and the accompanying materials
12 are licensed and made available under the terms and conditions of the BSD License
13 which accompanies this distribution. The full text of the license may be found at
14 http://opensource.org/licenses/bsd-license.php
16 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
17 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
21 #include <LegacyRegion2.h>
23 EFI_HANDLE mLegacyRegion2Handle
= NULL
;
25 EFI_LEGACY_REGION2_PROTOCOL mLegacyRegion2
= {
28 LegacyRegion2BootLock
,
34 Modify the hardware to allow (decode) or disallow (not decode) memory reads in a region.
36 If the On parameter evaluates to TRUE, this function enables memory reads in the address range
37 Start to (Start + Length - 1).
38 If the On parameter evaluates to FALSE, this function disables memory reads in the address range
39 Start to (Start + Length - 1).
41 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
42 @param Start[in] The beginning of the physical address of the region whose attributes
44 @param Length[in] The number of bytes of memory whose attributes should be modified.
45 The actual number of bytes modified may be greater than the number
47 @param Granularity[out] The number of bytes in the last region affected. This may be less
48 than the total number of bytes affected if the starting address
49 was not aligned to a region's starting address or if the length
50 was greater than the number of bytes in the first region.
51 @param On[in] Decode / Non-Decode flag.
53 @retval EFI_SUCCESS The region's attributes were successfully modified.
54 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
60 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
63 OUT UINT32
*Granularity
,
67 if ((Start
< 0xC0000) || ((Start
+ Length
- 1) > 0xFFFFF)) {
68 return EFI_INVALID_PARAMETER
;
71 ASSERT (Granularity
!= NULL
);
77 Modify the hardware to disallow memory writes in a region.
79 This function changes the attributes of a memory range to not allow writes.
81 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
82 @param Start[in] The beginning of the physical address of the region whose
83 attributes should be modified.
84 @param Length[in] The number of bytes of memory whose attributes should be modified.
85 The actual number of bytes modified may be greater than the number
87 @param Granularity[out] The number of bytes in the last region affected. This may be less
88 than the total number of bytes affected if the starting address was
89 not aligned to a region's starting address or if the length was
90 greater than the number of bytes in the first region.
92 @retval EFI_SUCCESS The region's attributes were successfully modified.
93 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
99 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
102 OUT UINT32
*Granularity
105 if ((Start
< 0xC0000) || ((Start
+ Length
- 1) > 0xFFFFF)) {
106 return EFI_INVALID_PARAMETER
;
109 ASSERT (Granularity
!= NULL
);
115 Modify the hardware to disallow memory attribute changes in a region.
117 This function makes the attributes of a region read only. Once a region is boot-locked with this
118 function, the read and write attributes of that region cannot be changed until a power cycle has
119 reset the boot-lock attribute. Calls to Decode(), Lock() and Unlock() will have no effect.
121 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
122 @param Start[in] The beginning of the physical address of the region whose
123 attributes should be modified.
124 @param Length[in] The number of bytes of memory whose attributes should be modified.
125 The actual number of bytes modified may be greater than the number
127 @param Granularity[out] The number of bytes in the last region affected. This may be less
128 than the total number of bytes affected if the starting address was
129 not aligned to a region's starting address or if the length was
130 greater than the number of bytes in the first region.
132 @retval EFI_SUCCESS The region's attributes were successfully modified.
133 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
134 @retval EFI_UNSUPPORTED The chipset does not support locking the configuration registers in
135 a way that will not affect memory regions outside the legacy memory
141 LegacyRegion2BootLock (
142 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
145 OUT UINT32
*Granularity
148 if ((Start
< 0xC0000) || ((Start
+ Length
- 1) > 0xFFFFF)) {
149 return EFI_INVALID_PARAMETER
;
152 return EFI_UNSUPPORTED
;
156 Modify the hardware to allow memory writes in a region.
158 This function changes the attributes of a memory range to allow writes.
160 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
161 @param Start[in] The beginning of the physical address of the region whose
162 attributes should be modified.
163 @param Length[in] The number of bytes of memory whose attributes should be modified.
164 The actual number of bytes modified may be greater than the number
166 @param Granularity[out] The number of bytes in the last region affected. This may be less
167 than the total number of bytes affected if the starting address was
168 not aligned to a region's starting address or if the length was
169 greater than the number of bytes in the first region.
171 @retval EFI_SUCCESS The region's attributes were successfully modified.
172 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
177 LegacyRegion2Unlock (
178 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
181 OUT UINT32
*Granularity
184 if ((Start
< 0xC0000) || ((Start
+ Length
- 1) > 0xFFFFF)) {
185 return EFI_INVALID_PARAMETER
;
188 ASSERT (Granularity
!= NULL
);
194 Get region information for the attributes of the Legacy Region.
196 This function is used to discover the granularity of the attributes for the memory in the legacy
197 region. Each attribute may have a different granularity and the granularity may not be the same
198 for all memory ranges in the legacy region.
200 @param This[in] Indicates the EFI_LEGACY_REGION2_PROTOCOL instance.
201 @param DescriptorCount[out] The number of region descriptor entries returned in the Descriptor
203 @param Descriptor[out] A pointer to a pointer used to return a buffer where the legacy
204 region information is deposited. This buffer will contain a list of
205 DescriptorCount number of region descriptors. This function will
206 provide the memory for the buffer.
208 @retval EFI_SUCCESS The information structure was returned.
209 @retval EFI_UNSUPPORTED This function is not supported.
214 LegacyRegionGetInfo (
215 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
216 OUT UINT32
*DescriptorCount
,
217 OUT EFI_LEGACY_REGION_DESCRIPTOR
**Descriptor
220 return EFI_UNSUPPORTED
;
224 The user Entry Point for module LegacyRegionDxe. The user code starts with this function.
226 @param[in] ImageHandle The firmware allocated handle for the EFI image.
227 @param[in] SystemTable A pointer to the EFI System Table.
229 @retval EFI_SUCCESS The entry point is executed successfully.
234 LegacyRegion2Install (
235 IN EFI_HANDLE ImageHandle
,
236 IN EFI_SYSTEM_TABLE
*SystemTable
242 // Make sure the Legacy Region 2 Protocol is not already installed in the system
244 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL
, &gEfiLegacyRegion2ProtocolGuid
);
247 // Install the protocol on a new handle.
249 Status
= gBS
->InstallMultipleProtocolInterfaces (
250 &mLegacyRegion2Handle
,
251 &gEfiLegacyRegion2ProtocolGuid
, &mLegacyRegion2
,
254 ASSERT_EFI_ERROR (Status
);