]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Csm/CsmSupportLib/LegacyRegion.h
BaseTools: Support recent versions of cx_freeze.
[mirror_edk2.git] / OvmfPkg / Csm / CsmSupportLib / LegacyRegion.h
CommitLineData
8016da21 1/** @file\r
2 Legacy Region Support\r
3\r
4 Copyright (c) 2008 - 2011, Intel Corporation. All rights reserved.<BR>\r
5\r
6 This program and the accompanying materials are\r
7 licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
13\r
14**/\r
15\r
16#ifndef _LEGACY_REGION_DXE_H_\r
17#define _LEGACY_REGION_DXE_H_\r
18\r
19#include <PiDxe.h>\r
20\r
21#include <Protocol/LegacyRegion2.h>\r
22\r
23#include <IndustryStandard/Pci.h>\r
24\r
25#include <Library/PciLib.h>\r
26#include <Library/PcdLib.h>\r
27#include <Library/DebugLib.h>\r
28#include <Library/MemoryAllocationLib.h>\r
29#include <Library/UefiBootServicesTableLib.h>\r
30\r
31#define PAM_PCI_BUS 0\r
32#define PAM_PCI_DEV 0\r
33#define PAM_PCI_FUNC 0\r
34\r
35#define REG_PAM0_OFFSET 0x59 // Programmable Attribute Map 0\r
36#define REG_PAM1_OFFSET 0x5a // Programmable Attribute Map 1\r
37#define REG_PAM2_OFFSET 0x5b // Programmable Attribute Map 2\r
38#define REG_PAM3_OFFSET 0x5c // Programmable Attribute Map 3\r
39#define REG_PAM4_OFFSET 0x5d // Programmable Attribute Map 4\r
40#define REG_PAM5_OFFSET 0x5e // Programmable Attribute Map 5\r
41#define REG_PAM6_OFFSET 0x5f // Programmable Attribute Map 6\r
42\r
43#define PAM_BASE_ADDRESS 0xc0000\r
44#define PAM_LIMIT_ADDRESS BASE_1MB\r
45\r
46//\r
47// Describes Legacy Region blocks and status.\r
48//\r
49typedef struct {\r
50 UINT32 Start;\r
51 UINT32 Length;\r
52 BOOLEAN ReadEnabled;\r
53 BOOLEAN WriteEnabled;\r
54} LEGACY_MEMORY_SECTION_INFO;\r
55\r
56//\r
57// Provides a map of the PAM registers and bits used to set Read/Write access.\r
58//\r
59typedef struct {\r
60 UINT8 PAMRegOffset;\r
61 UINT8 ReadEnableData;\r
62 UINT8 WriteEnableData;\r
63} PAM_REGISTER_VALUE;\r
64\r
65/**\r
66 Modify the hardware to allow (decode) or disallow (not decode) memory reads in a region.\r
67\r
68 If the On parameter evaluates to TRUE, this function enables memory reads in the address range\r
69 Start to (Start + Length - 1).\r
70 If the On parameter evaluates to FALSE, this function disables memory reads in the address range\r
71 Start to (Start + Length - 1).\r
72\r
73 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r
74 @param Start[in] The beginning of the physical address of the region whose attributes\r
75 should be modified.\r
76 @param Length[in] The number of bytes of memory whose attributes should be modified.\r
77 The actual number of bytes modified may be greater than the number\r
78 specified.\r
79 @param Granularity[out] The number of bytes in the last region affected. This may be less\r
80 than the total number of bytes affected if the starting address\r
81 was not aligned to a region's starting address or if the length\r
82 was greater than the number of bytes in the first region.\r
83 @param On[in] Decode / Non-Decode flag.\r
84\r
85 @retval EFI_SUCCESS The region's attributes were successfully modified.\r
86 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r
87\r
88**/\r
89EFI_STATUS\r
90EFIAPI\r
91LegacyRegion2Decode (\r
92 IN EFI_LEGACY_REGION2_PROTOCOL *This,\r
93 IN UINT32 Start,\r
94 IN UINT32 Length,\r
95 OUT UINT32 *Granularity,\r
96 IN BOOLEAN *On\r
97 );\r
98\r
99/**\r
100 Modify the hardware to disallow memory writes in a region.\r
101\r
102 This function changes the attributes of a memory range to not allow writes.\r
103\r
104 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r
105 @param Start[in] The beginning of the physical address of the region whose\r
106 attributes should be modified.\r
107 @param Length[in] The number of bytes of memory whose attributes should be modified.\r
108 The actual number of bytes modified may be greater than the number\r
109 specified.\r
110 @param Granularity[out] The number of bytes in the last region affected. This may be less\r
111 than the total number of bytes affected if the starting address was\r
112 not aligned to a region's starting address or if the length was\r
113 greater than the number of bytes in the first region.\r
114\r
115 @retval EFI_SUCCESS The region's attributes were successfully modified.\r
116 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r
117\r
118**/\r
119EFI_STATUS\r
120EFIAPI\r
121LegacyRegion2Lock (\r
122 IN EFI_LEGACY_REGION2_PROTOCOL *This,\r
123 IN UINT32 Start,\r
124 IN UINT32 Length,\r
125 OUT UINT32 *Granularity\r
126 );\r
127\r
128/**\r
129 Modify the hardware to disallow memory attribute changes in a region.\r
130\r
131 This function makes the attributes of a region read only. Once a region is boot-locked with this\r
132 function, the read and write attributes of that region cannot be changed until a power cycle has\r
133 reset the boot-lock attribute. Calls to Decode(), Lock() and Unlock() will have no effect.\r
134\r
135 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r
136 @param Start[in] The beginning of the physical address of the region whose\r
137 attributes should be modified.\r
138 @param Length[in] The number of bytes of memory whose attributes should be modified.\r
139 The actual number of bytes modified may be greater than the number\r
140 specified.\r
141 @param Granularity[out] The number of bytes in the last region affected. This may be less\r
142 than the total number of bytes affected if the starting address was\r
143 not aligned to a region's starting address or if the length was\r
144 greater than the number of bytes in the first region.\r
145\r
146 @retval EFI_SUCCESS The region's attributes were successfully modified.\r
147 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r
148 @retval EFI_UNSUPPORTED The chipset does not support locking the configuration registers in\r
149 a way that will not affect memory regions outside the legacy memory\r
150 region.\r
151\r
152**/\r
153EFI_STATUS\r
154EFIAPI\r
155LegacyRegion2BootLock (\r
156 IN EFI_LEGACY_REGION2_PROTOCOL *This,\r
157 IN UINT32 Start,\r
158 IN UINT32 Length,\r
159 OUT UINT32 *Granularity\r
160 );\r
161\r
162/**\r
163 Modify the hardware to allow memory writes in a region.\r
164\r
165 This function changes the attributes of a memory range to allow writes.\r
166\r
167 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r
168 @param Start[in] The beginning of the physical address of the region whose\r
169 attributes should be modified.\r
170 @param Length[in] The number of bytes of memory whose attributes should be modified.\r
171 The actual number of bytes modified may be greater than the number\r
172 specified.\r
173 @param Granularity[out] The number of bytes in the last region affected. This may be less\r
174 than the total number of bytes affected if the starting address was\r
175 not aligned to a region's starting address or if the length was\r
176 greater than the number of bytes in the first region.\r
177\r
178 @retval EFI_SUCCESS The region's attributes were successfully modified.\r
179 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r
180\r
181**/\r
182EFI_STATUS\r
183EFIAPI\r
184LegacyRegion2Unlock (\r
185 IN EFI_LEGACY_REGION2_PROTOCOL *This,\r
186 IN UINT32 Start,\r
187 IN UINT32 Length,\r
188 OUT UINT32 *Granularity\r
189 );\r
190\r
191/**\r
192 Get region information for the attributes of the Legacy Region.\r
193\r
194 This function is used to discover the granularity of the attributes for the memory in the legacy\r
195 region. Each attribute may have a different granularity and the granularity may not be the same\r
196 for all memory ranges in the legacy region.\r
197\r
198 @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r
199 @param DescriptorCount[out] The number of region descriptor entries returned in the Descriptor\r
200 buffer.\r
201 @param Descriptor[out] A pointer to a pointer used to return a buffer where the legacy\r
202 region information is deposited. This buffer will contain a list of\r
203 DescriptorCount number of region descriptors. This function will\r
204 provide the memory for the buffer.\r
205\r
206 @retval EFI_SUCCESS The region's attributes were successfully modified.\r
207 @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r
208\r
209**/\r
210EFI_STATUS\r
211EFIAPI\r
212LegacyRegionGetInfo (\r
213 IN EFI_LEGACY_REGION2_PROTOCOL *This,\r
214 OUT UINT32 *DescriptorCount,\r
215 OUT EFI_LEGACY_REGION_DESCRIPTOR **Descriptor\r
216 );\r
217\r
218#endif\r
219\r