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 - 2018, Intel Corporation. All rights reserved.<BR>
11 SPDX-License-Identifier: BSD-2-Clause-Patent
16 #include <Protocol/LegacyRegion.h>
17 #include <Library/DebugLib.h>
18 #include <Library/UefiBootServicesTableLib.h>
21 Sets hardware to decode or not decode a region.
23 @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance
24 @param Start Start of region to decode.
25 @param Length Size in bytes of the region.
26 @param On Decode/nondecode flag.
28 @retval EFI_SUCCESS Decode range successfully changed.
34 IN EFI_LEGACY_REGION_PROTOCOL
*This
,
44 Sets a region to read only.
46 @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance
47 @param Start Start of region to lock.
48 @param Length Size in bytes of the region.
49 @param Granularity Lock attribute affects this granularity in bytes.
51 @retval EFI_SUCCESS The region was made read only.
57 IN EFI_LEGACY_REGION_PROTOCOL
*This
,
60 OUT UINT32
*Granularity OPTIONAL
67 Sets a region to read only and ensures that flash is locked from being
68 inadvertently modified.
70 @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance
71 @param Start Start of region to lock.
72 @param Length Size in bytes of the region.
73 @param Granularity Lock attribute affects this granularity in bytes.
75 @retval EFI_SUCCESS The region was made read only and flash is locked.
80 LegacyRegionBootLock (
81 IN EFI_LEGACY_REGION_PROTOCOL
*This
,
84 OUT UINT32
*Granularity OPTIONAL
91 Sets a region to read-write.
93 @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance
94 @param Start Start of region to lock.
95 @param Length Size in bytes of the region.
96 @param Granularity Lock attribute affects this granularity in bytes.
98 @retval EFI_SUCCESS The region was successfully made read-write.
104 IN EFI_LEGACY_REGION_PROTOCOL
*This
,
107 OUT UINT32
*Granularity OPTIONAL
114 // Module global for the handle the Legacy Region Protocol is installed
116 EFI_HANDLE mLegacyRegionHandle
= NULL
;
119 // Module global for the Legacy Region Protocol instance that is installed onto
120 // mLegacyRegionHandle
122 EFI_LEGACY_REGION_PROTOCOL mLegacyRegion
= {
125 LegacyRegionBootLock
,
130 The user Entry Point for module LegacyRegionDxe. The user code starts with this function.
132 @param[in] ImageHandle The firmware allocated handle for the EFI image.
133 @param[in] SystemTable A pointer to the EFI System Table.
135 @retval EFI_SUCCESS The entry point is executed successfully.
136 @retval other Some error occurs when executing this entry point.
141 LegacyRegionInstall (
142 IN EFI_HANDLE ImageHandle
,
143 IN EFI_SYSTEM_TABLE
*SystemTable
149 // Make sure the Legacy Region Protocol is not already installed in the system
151 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL
, &gEfiLegacyRegionProtocolGuid
);
154 // Install the protocol on a new handle.
156 Status
= gBS
->InstallMultipleProtocolInterfaces (
157 &mLegacyRegionHandle
,
158 &gEfiLegacyRegionProtocolGuid
, &mLegacyRegion
,
161 ASSERT_EFI_ERROR (Status
);