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