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, Intel Corporation
11 All rights reserved. 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 ASSERT (Granularity
!= NULL
);
73 Modify the hardware to disallow memory writes in a region.
75 This function changes the attributes of a memory range to not allow writes.
77 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
78 @param Start[in] The beginning of the physical address of the region whose
79 attributes should be modified.
80 @param Length[in] The number of bytes of memory whose attributes should be modified.
81 The actual number of bytes modified may be greater than the number
83 @param Granularity[out] The number of bytes in the last region affected. This may be less
84 than the total number of bytes affected if the starting address was
85 not aligned to a region's starting address or if the length was
86 greater than the number of bytes in the first region.
88 @retval EFI_SUCCESS The region's attributes were successfully modified.
89 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
95 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
98 OUT UINT32
*Granularity
101 ASSERT (Granularity
!= NULL
);
107 Modify the hardware to disallow memory attribute changes in a region.
109 This function makes the attributes of a region read only. Once a region is boot-locked with this
110 function, the read and write attributes of that region cannot be changed until a power cycle has
111 reset the boot-lock attribute. Calls to Decode(), Lock() and Unlock() will have no effect.
113 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
114 @param Start[in] The beginning of the physical address of the region whose
115 attributes should be modified.
116 @param Length[in] The number of bytes of memory whose attributes should be modified.
117 The actual number of bytes modified may be greater than the number
119 @param Granularity[out] The number of bytes in the last region affected. This may be less
120 than the total number of bytes affected if the starting address was
121 not aligned to a region's starting address or if the length was
122 greater than the number of bytes in the first region.
124 @retval EFI_SUCCESS The region's attributes were successfully modified.
125 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
126 @retval EFI_UNSUPPORTED The chipset does not support locking the configuration registers in
127 a way that will not affect memory regions outside the legacy memory
133 LegacyRegion2BootLock (
134 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
137 OUT UINT32
*Granularity
140 ASSERT (Granularity
!= NULL
);
146 Modify the hardware to allow memory writes in a region.
148 This function changes the attributes of a memory range to allow writes.
150 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
151 @param Start[in] The beginning of the physical address of the region whose
152 attributes should be modified.
153 @param Length[in] The number of bytes of memory whose attributes should be modified.
154 The actual number of bytes modified may be greater than the number
156 @param Granularity[out] The number of bytes in the last region affected. This may be less
157 than the total number of bytes affected if the starting address was
158 not aligned to a region's starting address or if the length was
159 greater than the number of bytes in the first region.
161 @retval EFI_SUCCESS The region's attributes were successfully modified.
162 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
167 LegacyRegion2Unlock (
168 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
171 OUT UINT32
*Granularity
174 ASSERT (Granularity
!= NULL
);
180 Get region information for the attributes of the Legacy Region.
182 This function is used to discover the granularity of the attributes for the memory in the legacy
183 region. Each attribute may have a different granularity and the granularity may not be the same
184 for all memory ranges in the legacy region.
186 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
187 @param DescriptorCount[out] The number of region descriptor entries returned in the Descriptor
189 @param Descriptor[out] A pointer to a pointer used to return a buffer where the legacy
190 region information is deposited. This buffer will contain a list of
191 DescriptorCount number of region descriptors. This function will
192 provide the memory for the buffer.
194 @retval EFI_SUCCESS The region's attributes were successfully modified.
195 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
200 LegacyRegionGetInfo (
201 IN EFI_LEGACY_REGION2_PROTOCOL
*This
,
202 OUT UINT32
*DescriptorCount
,
203 OUT EFI_LEGACY_REGION_DESCRIPTOR
**Descriptor
206 ASSERT (DescriptorCount
!= NULL
);
207 ASSERT (Descriptor
!= NULL
);
209 *DescriptorCount
= 0;
216 The user Entry Point for module LegacyRegionDxe. The user code starts with this function.
218 @param[in] ImageHandle The firmware allocated handle for the EFI image.
219 @param[in] SystemTable A pointer to the EFI System Table.
221 @retval EFI_SUCCESS The entry point is executed successfully.
226 LegacyRegion2Install (
227 IN EFI_HANDLE ImageHandle
,
228 IN EFI_SYSTEM_TABLE
*SystemTable
234 // Make sure the Legacy Region 2 Protocol is not already installed in the system
236 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL
, &gEfiLegacyRegion2ProtocolGuid
);
239 // Install the protocol on a new handle.
241 Status
= gBS
->InstallMultipleProtocolInterfaces (
242 &mLegacyRegion2Handle
,
243 &gEfiLegacyRegion2ProtocolGuid
, &mLegacyRegion2
,
246 ASSERT_EFI_ERROR (Status
);