1 /** @file
2   Internal include file for the Legacy Region 2 Protocol thunk driver.
3 
4 Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution.  The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9 
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 
13 **/
14 
15 #ifndef __LEGACY_REGION2_ON_LEGACY_REGION_H__
16 #define __LEGACY_REGION2_ON_LEGACY_REGION_H__
17 
18 #include <Protocol/LegacyRegion2.h>
19 #include <Protocol/LegacyRegion.h>
20 
21 #include <Library/DebugLib.h>
22 #include <Library/UefiBootServicesTableLib.h>
23 
24 /**
25   Modify the hardware to allow (decode) or disallow (not decode) memory reads in a region.
26 
27   If the On parameter evaluates to TRUE, this function enables memory reads in the address range
28   Start to (Start + Length - 1).
29   If the On parameter evaluates to FALSE, this function disables memory reads in the address range
30   Start to (Start + Length - 1).
31 
32   @param  This[in]              Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
33   @param  Start[in]             The beginning of the physical address of the region whose attributes
34                                 should be modified.
35   @param  Length[in]            The number of bytes of memory whose attributes should be modified.
36                                 The actual number of bytes modified may be greater than the number
37                                 specified.
38   @param  Granularity[out]      The number of bytes in the last region affected. This may be less
39                                 than the total number of bytes affected if the starting address
40                                 was not aligned to a region's starting address or if the length
41                                 was greater than the number of bytes in the first region.
42   @param  On[in]                Decode / Non-Decode flag.
43 
44   @retval EFI_SUCCESS           The region's attributes were successfully modified.
45   @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
46 
47 **/
48 EFI_STATUS
49 EFIAPI
50 LegacyRegion2Decode (
51   IN  EFI_LEGACY_REGION2_PROTOCOL  *This,
52   IN  UINT32                       Start,
53   IN  UINT32                       Length,
54   OUT UINT32                       *Granularity,
55   IN  BOOLEAN                      *On
56   );
57 
58 /**
59   Modify the hardware to disallow memory writes in a region.
60 
61   This function changes the attributes of a memory range to not allow writes.
62 
63   @param  This[in]              Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
64   @param  Start[in]             The beginning of the physical address of the region whose
65                                 attributes should be modified.
66   @param  Length[in]            The number of bytes of memory whose attributes should be modified.
67                                 The actual number of bytes modified may be greater than the number
68                                 specified.
69   @param  Granularity[out]      The number of bytes in the last region affected. This may be less
70                                 than the total number of bytes affected if the starting address was
71                                 not aligned to a region's starting address or if the length was
72                                 greater than the number of bytes in the first region.
73 
74   @retval EFI_SUCCESS           The region's attributes were successfully modified.
75   @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
76 
77 **/
78 EFI_STATUS
79 EFIAPI
80 LegacyRegion2Lock (
81   IN  EFI_LEGACY_REGION2_PROTOCOL *This,
82   IN  UINT32                      Start,
83   IN  UINT32                      Length,
84   OUT UINT32                      *Granularity
85   );
86 
87 /**
88   Modify the hardware to disallow memory attribute changes in a region.
89 
90   This function makes the attributes of a region read only. Once a region is boot-locked with this
91   function, the read and write attributes of that region cannot be changed until a power cycle has
92   reset the boot-lock attribute. Calls to Decode(), Lock() and Unlock() will have no effect.
93 
94   @param  This[in]              Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
95   @param  Start[in]             The beginning of the physical address of the region whose
96                                 attributes should be modified.
97   @param  Length[in]            The number of bytes of memory whose attributes should be modified.
98                                 The actual number of bytes modified may be greater than the number
99                                 specified.
100   @param  Granularity[out]      The number of bytes in the last region affected. This may be less
101                                 than the total number of bytes affected if the starting address was
102                                 not aligned to a region's starting address or if the length was
103                                 greater than the number of bytes in the first region.
104 
105   @retval EFI_SUCCESS           The region's attributes were successfully modified.
106   @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
107   @retval EFI_UNSUPPORTED       The chipset does not support locking the configuration registers in
108                                 a way that will not affect memory regions outside the legacy memory
109                                 region.
110 
111 **/
112 EFI_STATUS
113 EFIAPI
114 LegacyRegion2BootLock (
115   IN EFI_LEGACY_REGION2_PROTOCOL          *This,
116   IN  UINT32                              Start,
117   IN  UINT32                              Length,
118   OUT UINT32                              *Granularity
119   );
120 
121 /**
122   Modify the hardware to allow memory writes in a region.
123 
124   This function changes the attributes of a memory range to allow writes.
125 
126   @param  This[in]              Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
127   @param  Start[in]             The beginning of the physical address of the region whose
128                                 attributes should be modified.
129   @param  Length[in]            The number of bytes of memory whose attributes should be modified.
130                                 The actual number of bytes modified may be greater than the number
131                                 specified.
132   @param  Granularity[out]      The number of bytes in the last region affected. This may be less
133                                 than the total number of bytes affected if the starting address was
134                                 not aligned to a region's starting address or if the length was
135                                 greater than the number of bytes in the first region.
136 
137   @retval EFI_SUCCESS           The region's attributes were successfully modified.
138   @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
139 
140 **/
141 EFI_STATUS
142 EFIAPI
143 LegacyRegion2Unlock (
144   IN  EFI_LEGACY_REGION2_PROTOCOL  *This,
145   IN  UINT32                       Start,
146   IN  UINT32                       Length,
147   OUT UINT32                       *Granularity
148   );
149 
150 /**
151   Get region information for the attributes of the Legacy Region.
152 
153   This function is used to discover the granularity of the attributes for the memory in the legacy
154   region. Each attribute may have a different granularity and the granularity may not be the same
155   for all memory ranges in the legacy region.
156 
157   @param  This[in]              Indicates the EFI_LEGACY_REGION_PROTOCOL instance.
158   @param  DescriptorCount[out]  The number of region descriptor entries returned in the Descriptor
159                                 buffer.
160   @param  Descriptor[out]       A pointer to a pointer used to return a buffer where the legacy
161                                 region information is deposited. This buffer will contain a list of
162                                 DescriptorCount number of region descriptors.  This function will
163                                 provide the memory for the buffer.
164 
165   @retval EFI_SUCCESS           The region's attributes were successfully modified.
166   @retval EFI_INVALID_PARAMETER If Start or Length describe an address not in the Legacy Region.
167 
168 **/
169 EFI_STATUS
170 EFIAPI
171 LegacyRegionGetInfo (
172   IN  EFI_LEGACY_REGION2_PROTOCOL   *This,
173   OUT UINT32                        *DescriptorCount,
174   OUT EFI_LEGACY_REGION_DESCRIPTOR  **Descriptor
175   );
176 
177 #endif
178