]>
Commit | Line | Data |
---|---|---|
8016da21 | 1 | /** @file\r |
2 | Legacy Region Support\r | |
3 | \r | |
db27e9f3 | 4 | Copyright (c) 2008 - 2016, Intel Corporation. All rights reserved.<BR>\r |
8016da21 | 5 | \r |
b26f0cf9 | 6 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
8016da21 | 7 | \r |
8 | **/\r | |
9 | \r | |
10 | #ifndef _LEGACY_REGION_DXE_H_\r | |
11 | #define _LEGACY_REGION_DXE_H_\r | |
12 | \r | |
13 | #include <PiDxe.h>\r | |
14 | \r | |
15 | #include <Protocol/LegacyRegion2.h>\r | |
16 | \r | |
17 | #include <IndustryStandard/Pci.h>\r | |
db27e9f3 RN |
18 | #include <IndustryStandard/Q35MchIch9.h>\r |
19 | #include <IndustryStandard/I440FxPiix4.h>\r | |
8016da21 | 20 | \r |
21 | #include <Library/PciLib.h>\r | |
22 | #include <Library/PcdLib.h>\r | |
23 | #include <Library/DebugLib.h>\r | |
24 | #include <Library/MemoryAllocationLib.h>\r | |
25 | #include <Library/UefiBootServicesTableLib.h>\r | |
26 | \r | |
8016da21 | 27 | #define PAM_BASE_ADDRESS 0xc0000\r |
28 | #define PAM_LIMIT_ADDRESS BASE_1MB\r | |
29 | \r | |
30 | //\r | |
31 | // Describes Legacy Region blocks and status.\r | |
32 | //\r | |
33 | typedef struct {\r | |
34 | UINT32 Start;\r | |
35 | UINT32 Length;\r | |
36 | BOOLEAN ReadEnabled;\r | |
37 | BOOLEAN WriteEnabled;\r | |
38 | } LEGACY_MEMORY_SECTION_INFO;\r | |
39 | \r | |
40 | //\r | |
41 | // Provides a map of the PAM registers and bits used to set Read/Write access.\r | |
42 | //\r | |
43 | typedef struct {\r | |
ba1d245f | 44 | UINTN PAMRegPciLibAddress;\r |
8016da21 | 45 | UINT8 ReadEnableData;\r |
46 | UINT8 WriteEnableData;\r | |
47 | } PAM_REGISTER_VALUE;\r | |
48 | \r | |
49 | /**\r | |
50 | Modify the hardware to allow (decode) or disallow (not decode) memory reads in a region.\r | |
51 | \r | |
52 | If the On parameter evaluates to TRUE, this function enables memory reads in the address range\r | |
53 | Start to (Start + Length - 1).\r | |
54 | If the On parameter evaluates to FALSE, this function disables memory reads in the address range\r | |
55 | Start to (Start + Length - 1).\r | |
56 | \r | |
57 | @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r | |
58 | @param Start[in] The beginning of the physical address of the region whose attributes\r | |
59 | should be modified.\r | |
60 | @param Length[in] The number of bytes of memory whose attributes should be modified.\r | |
61 | The actual number of bytes modified may be greater than the number\r | |
62 | specified.\r | |
63 | @param Granularity[out] The number of bytes in the last region affected. This may be less\r | |
64 | than the total number of bytes affected if the starting address\r | |
65 | was not aligned to a region's starting address or if the length\r | |
66 | was greater than the number of bytes in the first region.\r | |
67 | @param On[in] Decode / Non-Decode flag.\r | |
68 | \r | |
69 | @retval EFI_SUCCESS The region's attributes were successfully modified.\r | |
70 | @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r | |
71 | \r | |
72 | **/\r | |
73 | EFI_STATUS\r | |
74 | EFIAPI\r | |
75 | LegacyRegion2Decode (\r | |
76 | IN EFI_LEGACY_REGION2_PROTOCOL *This,\r | |
77 | IN UINT32 Start,\r | |
78 | IN UINT32 Length,\r | |
79 | OUT UINT32 *Granularity,\r | |
80 | IN BOOLEAN *On\r | |
81 | );\r | |
82 | \r | |
83 | /**\r | |
84 | Modify the hardware to disallow memory writes in a region.\r | |
85 | \r | |
86 | This function changes the attributes of a memory range to not allow writes.\r | |
87 | \r | |
88 | @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r | |
89 | @param Start[in] The beginning of the physical address of the region whose\r | |
90 | attributes should be modified.\r | |
91 | @param Length[in] The number of bytes of memory whose attributes should be modified.\r | |
92 | The actual number of bytes modified may be greater than the number\r | |
93 | specified.\r | |
94 | @param Granularity[out] The number of bytes in the last region affected. This may be less\r | |
95 | than the total number of bytes affected if the starting address was\r | |
96 | not aligned to a region's starting address or if the length was\r | |
97 | greater than the number of bytes in the first region.\r | |
98 | \r | |
99 | @retval EFI_SUCCESS The region's attributes were successfully modified.\r | |
100 | @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r | |
101 | \r | |
102 | **/\r | |
103 | EFI_STATUS\r | |
104 | EFIAPI\r | |
105 | LegacyRegion2Lock (\r | |
106 | IN EFI_LEGACY_REGION2_PROTOCOL *This,\r | |
107 | IN UINT32 Start,\r | |
108 | IN UINT32 Length,\r | |
109 | OUT UINT32 *Granularity\r | |
110 | );\r | |
111 | \r | |
112 | /**\r | |
113 | Modify the hardware to disallow memory attribute changes in a region.\r | |
114 | \r | |
115 | This function makes the attributes of a region read only. Once a region is boot-locked with this\r | |
116 | function, the read and write attributes of that region cannot be changed until a power cycle has\r | |
117 | reset the boot-lock attribute. Calls to Decode(), Lock() and Unlock() will have no effect.\r | |
118 | \r | |
119 | @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r | |
120 | @param Start[in] The beginning of the physical address of the region whose\r | |
121 | attributes should be modified.\r | |
122 | @param Length[in] The number of bytes of memory whose attributes should be modified.\r | |
123 | The actual number of bytes modified may be greater than the number\r | |
124 | specified.\r | |
125 | @param Granularity[out] The number of bytes in the last region affected. This may be less\r | |
126 | than the total number of bytes affected if the starting address was\r | |
127 | not aligned to a region's starting address or if the length was\r | |
128 | greater than the number of bytes in the first region.\r | |
129 | \r | |
130 | @retval EFI_SUCCESS The region's attributes were successfully modified.\r | |
131 | @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r | |
132 | @retval EFI_UNSUPPORTED The chipset does not support locking the configuration registers in\r | |
133 | a way that will not affect memory regions outside the legacy memory\r | |
134 | region.\r | |
135 | \r | |
136 | **/\r | |
137 | EFI_STATUS\r | |
138 | EFIAPI\r | |
139 | LegacyRegion2BootLock (\r | |
140 | IN EFI_LEGACY_REGION2_PROTOCOL *This,\r | |
141 | IN UINT32 Start,\r | |
142 | IN UINT32 Length,\r | |
143 | OUT UINT32 *Granularity\r | |
144 | );\r | |
145 | \r | |
146 | /**\r | |
147 | Modify the hardware to allow memory writes in a region.\r | |
148 | \r | |
149 | This function changes the attributes of a memory range to allow writes.\r | |
150 | \r | |
151 | @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r | |
152 | @param Start[in] The beginning of the physical address of the region whose\r | |
153 | attributes should be modified.\r | |
154 | @param Length[in] The number of bytes of memory whose attributes should be modified.\r | |
155 | The actual number of bytes modified may be greater than the number\r | |
156 | specified.\r | |
157 | @param Granularity[out] The number of bytes in the last region affected. This may be less\r | |
158 | than the total number of bytes affected if the starting address was\r | |
159 | not aligned to a region's starting address or if the length was\r | |
160 | greater than the number of bytes in the first region.\r | |
161 | \r | |
162 | @retval EFI_SUCCESS The region's attributes were successfully modified.\r | |
163 | @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r | |
164 | \r | |
165 | **/\r | |
166 | EFI_STATUS\r | |
167 | EFIAPI\r | |
168 | LegacyRegion2Unlock (\r | |
169 | IN EFI_LEGACY_REGION2_PROTOCOL *This,\r | |
170 | IN UINT32 Start,\r | |
171 | IN UINT32 Length,\r | |
172 | OUT UINT32 *Granularity\r | |
173 | );\r | |
174 | \r | |
175 | /**\r | |
176 | Get region information for the attributes of the Legacy Region.\r | |
177 | \r | |
178 | This function is used to discover the granularity of the attributes for the memory in the legacy\r | |
179 | region. Each attribute may have a different granularity and the granularity may not be the same\r | |
180 | for all memory ranges in the legacy region.\r | |
181 | \r | |
182 | @param This[in] Indicates the EFI_LEGACY_REGION_PROTOCOL instance.\r | |
183 | @param DescriptorCount[out] The number of region descriptor entries returned in the Descriptor\r | |
184 | buffer.\r | |
185 | @param Descriptor[out] A pointer to a pointer used to return a buffer where the legacy\r | |
186 | region information is deposited. This buffer will contain a list of\r | |
187 | DescriptorCount number of region descriptors. This function will\r | |
188 | provide the memory for the buffer.\r | |
189 | \r | |
190 | @retval EFI_SUCCESS The region's attributes were successfully modified.\r | |
191 | @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.\r | |
192 | \r | |
193 | **/\r | |
194 | EFI_STATUS\r | |
195 | EFIAPI\r | |
196 | LegacyRegionGetInfo (\r | |
197 | IN EFI_LEGACY_REGION2_PROTOCOL *This,\r | |
198 | OUT UINT32 *DescriptorCount,\r | |
199 | OUT EFI_LEGACY_REGION_DESCRIPTOR **Descriptor\r | |
200 | );\r | |
201 | \r | |
202 | #endif\r | |
203 | \r |