2 Produces the Legacy Region Protocol.
4 This generic implementation of the Legacy Region 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 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.
22 #include <Protocol/LegacyRegion.h>
23 #include <Library/DebugLib.h>
24 #include <Library/UefiBootServicesTableLib.h>
27 // Function prototypes of the Legacy Region Protocol services this module produces
32 IN EFI_LEGACY_REGION_PROTOCOL
*This
,
41 IN EFI_LEGACY_REGION_PROTOCOL
*This
,
44 OUT UINT32
*Granularity OPTIONAL
49 LegacyRegionBootLock (
50 IN EFI_LEGACY_REGION_PROTOCOL
*This
,
53 OUT UINT32
*Granularity OPTIONAL
59 IN EFI_LEGACY_REGION_PROTOCOL
*This
,
62 OUT UINT32
*Granularity OPTIONAL
66 // Module global for the handle the Legacy Region Protocol is installed
68 EFI_HANDLE mLegacyRegionHandle
= NULL
;
71 // Module global for the Legacy Region Protocol instance that is installed onto
72 // mLegacyRegionHandle
74 EFI_LEGACY_REGION_PROTOCOL mLegacyRegion
= {
82 Sets hardware to decode or not decode a region.
84 @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance
85 @param Start Start of region to decode.
86 @param Length Size in bytes of the region.
87 @param On Decode/nondecode flag.
89 @retval EFI_SUCCESS Decode range successfully changed.
95 IN EFI_LEGACY_REGION_PROTOCOL
*This
,
105 Sets a region to read only.
107 @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance
108 @param Start Start of region to lock.
109 @param Length Size in bytes of the region.
110 @param Granularity Lock attribute affects this granularity in bytes.
112 @retval EFI_SUCCESS The region was made read only.
118 IN EFI_LEGACY_REGION_PROTOCOL
*This
,
121 OUT UINT32
*Granularity OPTIONAL
128 Sets a region to read only and ensures that flash is locked from being
129 inadvertently modified.
131 @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance
132 @param Start Start of region to lock.
133 @param Length Size in bytes of the region.
134 @param Granularity Lock attribute affects this granularity in bytes.
136 @retval EFI_SUCCESS The region was made read only and flash is locked.
141 LegacyRegionBootLock (
142 IN EFI_LEGACY_REGION_PROTOCOL
*This
,
145 OUT UINT32
*Granularity OPTIONAL
152 Sets a region to read-write.
154 @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance
155 @param Start Start of region to lock.
156 @param Length Size in bytes of the region.
157 @param Granularity Lock attribute affects this granularity in bytes.
159 @retval EFI_SUCCESS The region was successfully made read-write.
165 IN EFI_LEGACY_REGION_PROTOCOL
*This
,
168 OUT UINT32
*Granularity OPTIONAL
175 The user Entry Point for module LegacyRegionDxe. The user code starts with this function.
177 @param[in] ImageHandle The firmware allocated handle for the EFI image.
178 @param[in] SystemTable A pointer to the EFI System Table.
180 @retval EFI_SUCCESS The entry point is executed successfully.
181 @retval other Some error occurs when executing this entry point.
186 LegacyRegionInstall (
187 IN EFI_HANDLE ImageHandle
,
188 IN EFI_SYSTEM_TABLE
*SystemTable
194 // Make sure the Legacy Region Protocol is not already installed in the system
196 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL
, &gEfiLegacyRegionProtocolGuid
);
199 // Install the protocol on a new handle.
201 Status
= gBS
->InstallMultipleProtocolInterfaces (
202 &mLegacyRegionHandle
,
203 &gEfiLegacyRegionProtocolGuid
, &mLegacyRegion
,
206 ASSERT_EFI_ERROR (Status
);