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. 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.
22 #include <Protocol/LegacyRegion.h>
23 #include <Library/DebugLib.h>
24 #include <Library/UefiBootServicesTableLib.h>
27 Sets hardware to decode or not decode a region.
29 @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance
30 @param Start Start of region to decode.
31 @param Length Size in bytes of the region.
32 @param On Decode/nondecode flag.
34 @retval EFI_SUCCESS Decode range successfully changed.
40 IN EFI_LEGACY_REGION_PROTOCOL
*This
,
50 Sets a region to read only.
52 @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance
53 @param Start Start of region to lock.
54 @param Length Size in bytes of the region.
55 @param Granularity Lock attribute affects this granularity in bytes.
57 @retval EFI_SUCCESS The region was made read only.
63 IN EFI_LEGACY_REGION_PROTOCOL
*This
,
66 OUT UINT32
*Granularity OPTIONAL
73 Sets a region to read only and ensures that flash is locked from being
74 inadvertently modified.
76 @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance
77 @param Start Start of region to lock.
78 @param Length Size in bytes of the region.
79 @param Granularity Lock attribute affects this granularity in bytes.
81 @retval EFI_SUCCESS The region was made read only and flash is locked.
86 LegacyRegionBootLock (
87 IN EFI_LEGACY_REGION_PROTOCOL
*This
,
90 OUT UINT32
*Granularity OPTIONAL
97 Sets a region to read-write.
99 @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance
100 @param Start Start of region to lock.
101 @param Length Size in bytes of the region.
102 @param Granularity Lock attribute affects this granularity in bytes.
104 @retval EFI_SUCCESS The region was successfully made read-write.
110 IN EFI_LEGACY_REGION_PROTOCOL
*This
,
113 OUT UINT32
*Granularity OPTIONAL
120 // Module global for the handle the Legacy Region Protocol is installed
122 EFI_HANDLE mLegacyRegionHandle
= NULL
;
125 // Module global for the Legacy Region Protocol instance that is installed onto
126 // mLegacyRegionHandle
128 EFI_LEGACY_REGION_PROTOCOL mLegacyRegion
= {
131 LegacyRegionBootLock
,
136 The user Entry Point for module LegacyRegionDxe. The user code starts with this function.
138 @param[in] ImageHandle The firmware allocated handle for the EFI image.
139 @param[in] SystemTable A pointer to the EFI System Table.
141 @retval EFI_SUCCESS The entry point is executed successfully.
142 @retval other Some error occurs when executing this entry point.
147 LegacyRegionInstall (
148 IN EFI_HANDLE ImageHandle
,
149 IN EFI_SYSTEM_TABLE
*SystemTable
155 // Make sure the Legacy Region Protocol is not already installed in the system
157 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL
, &gEfiLegacyRegionProtocolGuid
);
160 // Install the protocol on a new handle.
162 Status
= gBS
->InstallMultipleProtocolInterfaces (
163 &mLegacyRegionHandle
,
164 &gEfiLegacyRegionProtocolGuid
, &mLegacyRegion
,
167 ASSERT_EFI_ERROR (Status
);