]> git.proxmox.com Git - mirror_edk2.git/blame - IntelFrameworkModulePkg/Universal/LegacyRegionDxe/LegacyRegion.c
IntelFrameworkModulePkg: Replace BSD License with BSD+Patent License
[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
c0a00b14 11SPDX-License-Identifier: BSD-2-Clause-Patent\r
78d6366d 12\r
13**/\r
14\r
15#include <PiDxe.h>\r
16#include <Protocol/LegacyRegion.h>\r
17#include <Library/DebugLib.h>\r
18#include <Library/UefiBootServicesTableLib.h>\r
19\r
78d6366d 20/**\r
21 Sets hardware to decode or not decode a region.\r
22\r
23 @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance\r
24 @param Start Start of region to decode.\r
25 @param Length Size in bytes of the region.\r
26 @param On Decode/nondecode flag.\r
27\r
28 @retval EFI_SUCCESS Decode range successfully changed.\r
29\r
30**/\r
31EFI_STATUS\r
32EFIAPI\r
33LegacyRegionDecode (\r
34 IN EFI_LEGACY_REGION_PROTOCOL *This,\r
35 IN UINT32 Start,\r
36 IN UINT32 Length,\r
37 IN BOOLEAN *On\r
38 )\r
39{\r
40 return EFI_SUCCESS;\r
41}\r
42\r
43/**\r
44 Sets a region to read only.\r
45\r
46 @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance\r
47 @param Start Start of region to lock.\r
48 @param Length Size in bytes of the region.\r
49 @param Granularity Lock attribute affects this granularity in bytes.\r
50\r
51 @retval EFI_SUCCESS The region was made read only.\r
52\r
53**/\r
54EFI_STATUS\r
55EFIAPI\r
56LegacyRegionLock (\r
57 IN EFI_LEGACY_REGION_PROTOCOL *This,\r
58 IN UINT32 Start,\r
59 IN UINT32 Length,\r
60 OUT UINT32 *Granularity OPTIONAL\r
61 )\r
62{\r
63 return EFI_SUCCESS;\r
64}\r
65\r
66/**\r
67 Sets a region to read only and ensures that flash is locked from being\r
68 inadvertently modified.\r
69\r
70 @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance\r
71 @param Start Start of region to lock.\r
72 @param Length Size in bytes of the region.\r
73 @param Granularity Lock attribute affects this granularity in bytes.\r
74\r
75 @retval EFI_SUCCESS The region was made read only and flash is locked.\r
76\r
77**/\r
78EFI_STATUS\r
79EFIAPI\r
80LegacyRegionBootLock (\r
81 IN EFI_LEGACY_REGION_PROTOCOL *This,\r
82 IN UINT32 Start,\r
83 IN UINT32 Length,\r
84 OUT UINT32 *Granularity OPTIONAL\r
85 )\r
86{\r
87 return EFI_SUCCESS;\r
88}\r
89\r
90/**\r
91 Sets a region to read-write.\r
92\r
93 @param This Indicates the EFI_LEGACY_REGION_PROTOCOL instance\r
94 @param Start Start of region to lock.\r
95 @param Length Size in bytes of the region.\r
96 @param Granularity Lock attribute affects this granularity in bytes.\r
97\r
98 @retval EFI_SUCCESS The region was successfully made read-write.\r
99\r
100**/\r
101EFI_STATUS\r
102EFIAPI\r
103LegacyRegionUnlock (\r
104 IN EFI_LEGACY_REGION_PROTOCOL *This,\r
105 IN UINT32 Start,\r
106 IN UINT32 Length,\r
107 OUT UINT32 *Granularity OPTIONAL\r
108 )\r
109{\r
110 return EFI_SUCCESS;\r
111}\r
112\r
19bf20e1
LG
113//\r
114// Module global for the handle the Legacy Region Protocol is installed\r
115//\r
116EFI_HANDLE mLegacyRegionHandle = NULL;\r
117\r
118//\r
119// Module global for the Legacy Region Protocol instance that is installed onto\r
120// mLegacyRegionHandle\r
121//\r
122EFI_LEGACY_REGION_PROTOCOL mLegacyRegion = {\r
123 LegacyRegionDecode,\r
124 LegacyRegionLock,\r
125 LegacyRegionBootLock,\r
126 LegacyRegionUnlock\r
127};\r
128\r
78d6366d 129/**\r
130 The user Entry Point for module LegacyRegionDxe. The user code starts with this function.\r
131\r
0a6f4824 132 @param[in] ImageHandle The firmware allocated handle for the EFI image.\r
78d6366d 133 @param[in] SystemTable A pointer to the EFI System Table.\r
0a6f4824 134\r
78d6366d 135 @retval EFI_SUCCESS The entry point is executed successfully.\r
136 @retval other Some error occurs when executing this entry point.\r
137\r
138**/\r
139EFI_STATUS\r
140EFIAPI\r
141LegacyRegionInstall (\r
142 IN EFI_HANDLE ImageHandle,\r
143 IN EFI_SYSTEM_TABLE *SystemTable\r
144 )\r
145{\r
146 EFI_STATUS Status;\r
0a6f4824 147\r
78d6366d 148 //\r
149 // Make sure the Legacy Region Protocol is not already installed in the system\r
150 //\r
151 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiLegacyRegionProtocolGuid);\r
0a6f4824 152\r
78d6366d 153 //\r
154 // Install the protocol on a new handle.\r
155 //\r
156 Status = gBS->InstallMultipleProtocolInterfaces (\r
157 &mLegacyRegionHandle,\r
158 &gEfiLegacyRegionProtocolGuid, &mLegacyRegion,\r
159 NULL\r
160 );\r
161 ASSERT_EFI_ERROR (Status);\r
162\r
163 return Status;\r
164}\r