2 Implementation of Legacy Region 2 Protocol based on Framework Legacy Region Protocol.
4 Intel's Framework Legacy Region Protocol is replaced by Legacy Region 2 Protocol in PI 1.2.
5 This module produces PI Legacy Region 2 Protocol on top of Framework Legacy Region Protocol.
7 Copyright (c) 2009, Intel Corporation
8 All rights reserved. This program and the accompanying materials
9 are licensed and made available under the terms and conditions of the BSD License
10 which accompanies this distribution. The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #include "LegacyRegion2OnLegacyRegionThunk.h"
20 EFI_HANDLE mLegacyRegion2Handle
= NULL
;
22 EFI_LEGACY_REGION_PROTOCOL
*mLegacyRegion
;
24 EFI_LEGACY_REGION2_PROTOCOL mLegacyRegion2
= {
27 LegacyRegion2BootLock
,
33 Modify the hardware to allow (decode) or disallow (not decode) memory reads in a region.
35 If the On parameter evaluates to TRUE, this function enables memory reads in the address range
36 Start to (Start + Length - 1).
37 If the On parameter evaluates to FALSE, this function disables memory reads in the address range
38 Start to (Start + Length - 1).
40 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
41 @param Start[in] The beginning of the physical address of the region whose attributes
43 @param Length[in] The number of bytes of memory whose attributes should be modified.
44 The actual number of bytes modified may be greater than the number
46 @param Granularity[out] The number of bytes in the last region affected. This may be less
47 than the total number of bytes affected if the starting address
48 was not aligned to a region's starting address or if the length
49 was greater than the number of bytes in the first region.
50 @param On[in] Decode / Non-Decode flag.
52 @retval EFI_SUCCESS The region's attributes were successfully modified.
53 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
59 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
62 OUT UINT32
*Granularity
,
66 ASSERT (Granularity
!= NULL
);
69 return mLegacyRegion
->Decode (
78 Modify the hardware to disallow memory writes in a region.
80 This function changes the attributes of a memory range to not allow writes.
82 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
83 @param Start[in] The beginning of the physical address of the region whose
84 attributes should be modified.
85 @param Length[in] The number of bytes of memory whose attributes should be modified.
86 The actual number of bytes modified may be greater than the number
88 @param Granularity[out] The number of bytes in the last region affected. This may be less
89 than the total number of bytes affected if the starting address was
90 not aligned to a region's starting address or if the length was
91 greater than the number of bytes in the first region.
93 @retval EFI_SUCCESS The region's attributes were successfully modified.
94 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
100 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
103 OUT UINT32
*Granularity
106 ASSERT (Granularity
!= NULL
);
108 return mLegacyRegion
->Lock (
117 Modify the hardware to disallow memory attribute changes in a region.
119 This function makes the attributes of a region read only. Once a region is boot-locked with this
120 function, the read and write attributes of that region cannot be changed until a power cycle has
121 reset the boot-lock attribute. Calls to Decode(), Lock() and Unlock() will have no effect.
123 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
124 @param Start[in] The beginning of the physical address of the region whose
125 attributes should be modified.
126 @param Length[in] The number of bytes of memory whose attributes should be modified.
127 The actual number of bytes modified may be greater than the number
129 @param Granularity[out] The number of bytes in the last region affected. This may be less
130 than the total number of bytes affected if the starting address was
131 not aligned to a region's starting address or if the length was
132 greater than the number of bytes in the first region.
134 @retval EFI_SUCCESS The region's attributes were successfully modified.
135 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
136 @retval EFI_UNSUPPORTED The chipset does not support locking the configuration registers in
137 a way that will not affect memory regions outside the legacy memory
143 LegacyRegion2BootLock (
144 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
147 OUT UINT32
*Granularity
150 ASSERT (Granularity
!= NULL
);
152 return mLegacyRegion
->BootLock (
161 Modify the hardware to allow memory writes in a region.
163 This function changes the attributes of a memory range to allow writes.
165 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
166 @param Start[in] The beginning of the physical address of the region whose
167 attributes should be modified.
168 @param Length[in] The number of bytes of memory whose attributes should be modified.
169 The actual number of bytes modified may be greater than the number
171 @param Granularity[out] The number of bytes in the last region affected. This may be less
172 than the total number of bytes affected if the starting address was
173 not aligned to a region's starting address or if the length was
174 greater than the number of bytes in the first region.
176 @retval EFI_SUCCESS The region's attributes were successfully modified.
177 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
182 LegacyRegion2Unlock (
183 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
186 OUT UINT32
*Granularity
189 ASSERT (Granularity
!= NULL
);
191 return mLegacyRegion
->UnLock (
200 Get region information for the attributes of the Legacy Region.
202 This function is used to discover the granularity of the attributes for the memory in the legacy
203 region. Each attribute may have a different granularity and the granularity may not be the same
204 for all memory ranges in the legacy region.
206 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
207 @param DescriptorCount[out] The number of region descriptor entries returned in the Descriptor
209 @param Descriptor[out] A pointer to a pointer used to return a buffer where the legacy
210 region information is deposited. This buffer will contain a list of
211 DescriptorCount number of region descriptors. This function will
212 provide the memory for the buffer.
214 @retval EFI_SUCCESS The region's attributes were successfully modified.
215 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
220 LegacyRegionGetInfo (
221 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
222 OUT UINT32
*DescriptorCount
,
223 OUT EFI_LEGACY_REGION_DESCRIPTOR
**Descriptor
226 return EFI_UNSUPPORTED
;
230 The user Entry Point for module LegacyRegionDxe. The user code starts with this function.
232 @param[in] ImageHandle The firmware allocated handle for the EFI image.
233 @param[in] SystemTable A pointer to the EFI System Table.
235 @retval EFI_SUCCESS The entry point is executed successfully.
240 LegacyRegion2OnLegacyRegionThunkInitialize (
241 IN EFI_HANDLE ImageHandle
,
242 IN EFI_SYSTEM_TABLE
*SystemTable
248 // Make sure the Legacy Region 2 Protocol is not already installed in the system
250 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL
, &gEfiLegacyRegion2ProtocolGuid
);
253 // Locate and cache Framework Legacy Region Protocol.
255 Status
= gBS
->LocateProtocol (
256 &gEfiLegacyRegionProtocolGuid
,
258 (VOID
**) &mLegacyRegion
260 ASSERT_EFI_ERROR (Status
);
263 // Install the protocol on a new handle.
265 Status
= gBS
->InstallMultipleProtocolInterfaces (
266 &mLegacyRegion2Handle
,
267 &gEfiLegacyRegion2ProtocolGuid
, &mLegacyRegion2
,
270 ASSERT_EFI_ERROR (Status
);