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