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