]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Universal/LegacyRegionDxe/LegacyRegion.c
IntelFrameworkModulePkg: Clean up source files
[mirror_edk2.git] / IntelFrameworkModulePkg / Universal / LegacyRegionDxe / LegacyRegion.c
CommitLineData
19bf20e1 1/** @file\r
78d6366d 2 Produces the Legacy Region Protocol.\r
3\r
0a6f4824
LG
4 This generic implementation of the Legacy Region Protocol does not actually\r
5 perform any lock/unlock operations. This module may be used on platforms\r
6 that do not provide HW locking of the legacy memory regions. It can also\r
78d6366d 7 be used as a template driver for implementing the Legacy Region Protocol on\r
8 a platform that does support HW locking of the legacy memory regions.\r
9\r
0a6f4824 10Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.<BR>\r
180a5a35 11This program and the accompanying materials\r
78d6366d 12are licensed and made available under the terms and conditions of the BSD License\r
13which accompanies this distribution. The full text of the license may be found at\r
14http://opensource.org/licenses/bsd-license.php\r
15\r
16THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
17WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
18\r
19**/\r
20\r
21#include <PiDxe.h>\r
22#include <Protocol/LegacyRegion.h>\r
23#include <Library/DebugLib.h>\r
24#include <Library/UefiBootServicesTableLib.h>\r
25\r
78d6366d 26/**\r
27 Sets hardware to decode or not decode a region.\r
28\r
29 @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance\r
30 @param Start Start of region to decode.\r
31 @param Length Size in bytes of the region.\r
32 @param On Decode/nondecode flag.\r
33\r
34 @retval EFI_SUCCESS Decode range successfully changed.\r
35\r
36**/\r
37EFI_STATUS\r
38EFIAPI\r
39LegacyRegionDecode (\r
40 IN EFI_LEGACY_REGION_PROTOCOL *This,\r
41 IN UINT32 Start,\r
42 IN UINT32 Length,\r
43 IN BOOLEAN *On\r
44 )\r
45{\r
46 return EFI_SUCCESS;\r
47}\r
48\r
49/**\r
50 Sets a region to read only.\r
51\r
52 @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance\r
53 @param Start Start of region to lock.\r
54 @param Length Size in bytes of the region.\r
55 @param Granularity Lock attribute affects this granularity in bytes.\r
56\r
57 @retval EFI_SUCCESS The region was made read only.\r
58\r
59**/\r
60EFI_STATUS\r
61EFIAPI\r
62LegacyRegionLock (\r
63 IN EFI_LEGACY_REGION_PROTOCOL *This,\r
64 IN UINT32 Start,\r
65 IN UINT32 Length,\r
66 OUT UINT32 *Granularity OPTIONAL\r
67 )\r
68{\r
69 return EFI_SUCCESS;\r
70}\r
71\r
72/**\r
73 Sets a region to read only and ensures that flash is locked from being\r
74 inadvertently modified.\r
75\r
76 @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance\r
77 @param Start Start of region to lock.\r
78 @param Length Size in bytes of the region.\r
79 @param Granularity Lock attribute affects this granularity in bytes.\r
80\r
81 @retval EFI_SUCCESS The region was made read only and flash is locked.\r
82\r
83**/\r
84EFI_STATUS\r
85EFIAPI\r
86LegacyRegionBootLock (\r
87 IN EFI_LEGACY_REGION_PROTOCOL *This,\r
88 IN UINT32 Start,\r
89 IN UINT32 Length,\r
90 OUT UINT32 *Granularity OPTIONAL\r
91 )\r
92{\r
93 return EFI_SUCCESS;\r
94}\r
95\r
96/**\r
97 Sets a region to read-write.\r
98\r
99 @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance\r
100 @param Start Start of region to lock.\r
101 @param Length Size in bytes of the region.\r
102 @param Granularity Lock attribute affects this granularity in bytes.\r
103\r
104 @retval EFI_SUCCESS The region was successfully made read-write.\r
105\r
106**/\r
107EFI_STATUS\r
108EFIAPI\r
109LegacyRegionUnlock (\r
110 IN EFI_LEGACY_REGION_PROTOCOL *This,\r
111 IN UINT32 Start,\r
112 IN UINT32 Length,\r
113 OUT UINT32 *Granularity OPTIONAL\r
114 )\r
115{\r
116 return EFI_SUCCESS;\r
117}\r
118\r
19bf20e1
LG
119//\r
120// Module global for the handle the Legacy Region Protocol is installed\r
121//\r
122EFI_HANDLE mLegacyRegionHandle = NULL;\r
123\r
124//\r
125// Module global for the Legacy Region Protocol instance that is installed onto\r
126// mLegacyRegionHandle\r
127//\r
128EFI_LEGACY_REGION_PROTOCOL mLegacyRegion = {\r
129 LegacyRegionDecode,\r
130 LegacyRegionLock,\r
131 LegacyRegionBootLock,\r
132 LegacyRegionUnlock\r
133};\r
134\r
78d6366d 135/**\r
136 The user Entry Point for module LegacyRegionDxe. The user code starts with this function.\r
137\r
0a6f4824 138 @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
78d6366d 139 @param[in] SystemTable A pointer to the EFI System Table.\r
0a6f4824 140\r
78d6366d 141 @retval EFI_SUCCESS The entry point is executed successfully.\r
142 @retval other Some error occurs when executing this entry point.\r
143\r
144**/\r
145EFI_STATUS\r
146EFIAPI\r
147LegacyRegionInstall (\r
148 IN EFI_HANDLE ImageHandle,\r
149 IN EFI_SYSTEM_TABLE *SystemTable\r
150 )\r
151{\r
152 EFI_STATUS Status;\r
0a6f4824 153\r
78d6366d 154 //\r
155 // Make sure the Legacy Region Protocol is not already installed in the system\r
156 //\r
157 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiLegacyRegionProtocolGuid);\r
0a6f4824 158\r
78d6366d 159 //\r
160 // Install the protocol on a new handle.\r
161 //\r
162 Status = gBS->InstallMultipleProtocolInterfaces (\r
163 &mLegacyRegionHandle,\r
164 &gEfiLegacyRegionProtocolGuid, &mLegacyRegion,\r
165 NULL\r
166 );\r
167 ASSERT_EFI_ERROR (Status);\r
168\r
169 return Status;\r
170}\r