exregion.c revision 1.1.1.2.2.2 1 1.1.1.2.2.2 bouyer
2 1.1.1.2.2.2 bouyer /******************************************************************************
3 1.1.1.2.2.2 bouyer *
4 1.1.1.2.2.2 bouyer * Module Name: exregion - ACPI default OpRegion (address space) handlers
5 1.1.1.2.2.2 bouyer *
6 1.1.1.2.2.2 bouyer *****************************************************************************/
7 1.1.1.2.2.2 bouyer
8 1.1.1.2.2.2 bouyer /*
9 1.1.1.2.2.2 bouyer * Copyright (C) 2000 - 2011, Intel Corp.
10 1.1.1.2.2.2 bouyer * All rights reserved.
11 1.1.1.2.2.2 bouyer *
12 1.1.1.2.2.2 bouyer * Redistribution and use in source and binary forms, with or without
13 1.1.1.2.2.2 bouyer * modification, are permitted provided that the following conditions
14 1.1.1.2.2.2 bouyer * are met:
15 1.1.1.2.2.2 bouyer * 1. Redistributions of source code must retain the above copyright
16 1.1.1.2.2.2 bouyer * notice, this list of conditions, and the following disclaimer,
17 1.1.1.2.2.2 bouyer * without modification.
18 1.1.1.2.2.2 bouyer * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 1.1.1.2.2.2 bouyer * substantially similar to the "NO WARRANTY" disclaimer below
20 1.1.1.2.2.2 bouyer * ("Disclaimer") and any redistribution must be conditioned upon
21 1.1.1.2.2.2 bouyer * including a substantially similar Disclaimer requirement for further
22 1.1.1.2.2.2 bouyer * binary redistribution.
23 1.1.1.2.2.2 bouyer * 3. Neither the names of the above-listed copyright holders nor the names
24 1.1.1.2.2.2 bouyer * of any contributors may be used to endorse or promote products derived
25 1.1.1.2.2.2 bouyer * from this software without specific prior written permission.
26 1.1.1.2.2.2 bouyer *
27 1.1.1.2.2.2 bouyer * Alternatively, this software may be distributed under the terms of the
28 1.1.1.2.2.2 bouyer * GNU General Public License ("GPL") version 2 as published by the Free
29 1.1.1.2.2.2 bouyer * Software Foundation.
30 1.1.1.2.2.2 bouyer *
31 1.1.1.2.2.2 bouyer * NO WARRANTY
32 1.1.1.2.2.2 bouyer * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 1.1.1.2.2.2 bouyer * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 1.1.1.2.2.2 bouyer * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 1.1.1.2.2.2 bouyer * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 1.1.1.2.2.2 bouyer * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 1.1.1.2.2.2 bouyer * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 1.1.1.2.2.2 bouyer * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 1.1.1.2.2.2 bouyer * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 1.1.1.2.2.2 bouyer * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 1.1.1.2.2.2 bouyer * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 1.1.1.2.2.2 bouyer * POSSIBILITY OF SUCH DAMAGES.
43 1.1.1.2.2.2 bouyer */
44 1.1.1.2.2.2 bouyer
45 1.1.1.2.2.2 bouyer
46 1.1.1.2.2.2 bouyer #define __EXREGION_C__
47 1.1.1.2.2.2 bouyer
48 1.1.1.2.2.2 bouyer #include "acpi.h"
49 1.1.1.2.2.2 bouyer #include "accommon.h"
50 1.1.1.2.2.2 bouyer #include "acinterp.h"
51 1.1.1.2.2.2 bouyer
52 1.1.1.2.2.2 bouyer
53 1.1.1.2.2.2 bouyer #define _COMPONENT ACPI_EXECUTER
54 1.1.1.2.2.2 bouyer ACPI_MODULE_NAME ("exregion")
55 1.1.1.2.2.2 bouyer
56 1.1.1.2.2.2 bouyer
57 1.1.1.2.2.2 bouyer /*******************************************************************************
58 1.1.1.2.2.2 bouyer *
59 1.1.1.2.2.2 bouyer * FUNCTION: AcpiExSystemMemorySpaceHandler
60 1.1.1.2.2.2 bouyer *
61 1.1.1.2.2.2 bouyer * PARAMETERS: Function - Read or Write operation
62 1.1.1.2.2.2 bouyer * Address - Where in the space to read or write
63 1.1.1.2.2.2 bouyer * BitWidth - Field width in bits (8, 16, or 32)
64 1.1.1.2.2.2 bouyer * Value - Pointer to in or out value
65 1.1.1.2.2.2 bouyer * HandlerContext - Pointer to Handler's context
66 1.1.1.2.2.2 bouyer * RegionContext - Pointer to context specific to the
67 1.1.1.2.2.2 bouyer * accessed region
68 1.1.1.2.2.2 bouyer *
69 1.1.1.2.2.2 bouyer * RETURN: Status
70 1.1.1.2.2.2 bouyer *
71 1.1.1.2.2.2 bouyer * DESCRIPTION: Handler for the System Memory address space (Op Region)
72 1.1.1.2.2.2 bouyer *
73 1.1.1.2.2.2 bouyer ******************************************************************************/
74 1.1.1.2.2.2 bouyer
75 1.1.1.2.2.2 bouyer ACPI_STATUS
76 1.1.1.2.2.2 bouyer AcpiExSystemMemorySpaceHandler (
77 1.1.1.2.2.2 bouyer UINT32 Function,
78 1.1.1.2.2.2 bouyer ACPI_PHYSICAL_ADDRESS Address,
79 1.1.1.2.2.2 bouyer UINT32 BitWidth,
80 1.1.1.2.2.2 bouyer UINT64 *Value,
81 1.1.1.2.2.2 bouyer void *HandlerContext,
82 1.1.1.2.2.2 bouyer void *RegionContext)
83 1.1.1.2.2.2 bouyer {
84 1.1.1.2.2.2 bouyer ACPI_STATUS Status = AE_OK;
85 1.1.1.2.2.2 bouyer void *LogicalAddrPtr = NULL;
86 1.1.1.2.2.2 bouyer ACPI_MEM_SPACE_CONTEXT *MemInfo = RegionContext;
87 1.1.1.2.2.2 bouyer UINT32 Length;
88 1.1.1.2.2.2 bouyer ACPI_SIZE MapLength;
89 1.1.1.2.2.2 bouyer ACPI_SIZE PageBoundaryMapLength;
90 1.1.1.2.2.2 bouyer #ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
91 1.1.1.2.2.2 bouyer UINT32 Remainder;
92 1.1.1.2.2.2 bouyer #endif
93 1.1.1.2.2.2 bouyer
94 1.1.1.2.2.2 bouyer
95 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE (ExSystemMemorySpaceHandler);
96 1.1.1.2.2.2 bouyer
97 1.1.1.2.2.2 bouyer
98 1.1.1.2.2.2 bouyer /* Validate and translate the bit width */
99 1.1.1.2.2.2 bouyer
100 1.1.1.2.2.2 bouyer switch (BitWidth)
101 1.1.1.2.2.2 bouyer {
102 1.1.1.2.2.2 bouyer case 8:
103 1.1.1.2.2.2 bouyer Length = 1;
104 1.1.1.2.2.2 bouyer break;
105 1.1.1.2.2.2 bouyer
106 1.1.1.2.2.2 bouyer case 16:
107 1.1.1.2.2.2 bouyer Length = 2;
108 1.1.1.2.2.2 bouyer break;
109 1.1.1.2.2.2 bouyer
110 1.1.1.2.2.2 bouyer case 32:
111 1.1.1.2.2.2 bouyer Length = 4;
112 1.1.1.2.2.2 bouyer break;
113 1.1.1.2.2.2 bouyer
114 1.1.1.2.2.2 bouyer case 64:
115 1.1.1.2.2.2 bouyer Length = 8;
116 1.1.1.2.2.2 bouyer break;
117 1.1.1.2.2.2 bouyer
118 1.1.1.2.2.2 bouyer default:
119 1.1.1.2.2.2 bouyer ACPI_ERROR ((AE_INFO, "Invalid SystemMemory width %u",
120 1.1.1.2.2.2 bouyer BitWidth));
121 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
122 1.1.1.2.2.2 bouyer }
123 1.1.1.2.2.2 bouyer
124 1.1.1.2.2.2 bouyer #ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
125 1.1.1.2.2.2 bouyer /*
126 1.1.1.2.2.2 bouyer * Hardware does not support non-aligned data transfers, we must verify
127 1.1.1.2.2.2 bouyer * the request.
128 1.1.1.2.2.2 bouyer */
129 1.1.1.2.2.2 bouyer (void) AcpiUtShortDivide ((UINT64) Address, Length, NULL, &Remainder);
130 1.1.1.2.2.2 bouyer if (Remainder != 0)
131 1.1.1.2.2.2 bouyer {
132 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_AML_ALIGNMENT);
133 1.1.1.2.2.2 bouyer }
134 1.1.1.2.2.2 bouyer #endif
135 1.1.1.2.2.2 bouyer
136 1.1.1.2.2.2 bouyer /*
137 1.1.1.2.2.2 bouyer * Does the request fit into the cached memory mapping?
138 1.1.1.2.2.2 bouyer * Is 1) Address below the current mapping? OR
139 1.1.1.2.2.2 bouyer * 2) Address beyond the current mapping?
140 1.1.1.2.2.2 bouyer */
141 1.1.1.2.2.2 bouyer if ((Address < MemInfo->MappedPhysicalAddress) ||
142 1.1.1.2.2.2 bouyer (((UINT64) Address + Length) >
143 1.1.1.2.2.2 bouyer ((UINT64)
144 1.1.1.2.2.2 bouyer MemInfo->MappedPhysicalAddress + MemInfo->MappedLength)))
145 1.1.1.2.2.2 bouyer {
146 1.1.1.2.2.2 bouyer /*
147 1.1.1.2.2.2 bouyer * The request cannot be resolved by the current memory mapping;
148 1.1.1.2.2.2 bouyer * Delete the existing mapping and create a new one.
149 1.1.1.2.2.2 bouyer */
150 1.1.1.2.2.2 bouyer if (MemInfo->MappedLength)
151 1.1.1.2.2.2 bouyer {
152 1.1.1.2.2.2 bouyer /* Valid mapping, delete it */
153 1.1.1.2.2.2 bouyer
154 1.1.1.2.2.2 bouyer AcpiOsUnmapMemory (MemInfo->MappedLogicalAddress,
155 1.1.1.2.2.2 bouyer MemInfo->MappedLength);
156 1.1.1.2.2.2 bouyer }
157 1.1.1.2.2.2 bouyer
158 1.1.1.2.2.2 bouyer /*
159 1.1.1.2.2.2 bouyer * October 2009: Attempt to map from the requested address to the
160 1.1.1.2.2.2 bouyer * end of the region. However, we will never map more than one
161 1.1.1.2.2.2 bouyer * page, nor will we cross a page boundary.
162 1.1.1.2.2.2 bouyer */
163 1.1.1.2.2.2 bouyer MapLength = (ACPI_SIZE)
164 1.1.1.2.2.2 bouyer ((MemInfo->Address + MemInfo->Length) - Address);
165 1.1.1.2.2.2 bouyer
166 1.1.1.2.2.2 bouyer /*
167 1.1.1.2.2.2 bouyer * If mapping the entire remaining portion of the region will cross
168 1.1.1.2.2.2 bouyer * a page boundary, just map up to the page boundary, do not cross.
169 1.1.1.2.2.2 bouyer * On some systems, crossing a page boundary while mapping regions
170 1.1.1.2.2.2 bouyer * can cause warnings if the pages have different attributes
171 1.1.1.2.2.2 bouyer * due to resource management.
172 1.1.1.2.2.2 bouyer *
173 1.1.1.2.2.2 bouyer * This has the added benefit of constraining a single mapping to
174 1.1.1.2.2.2 bouyer * one page, which is similar to the original code that used a 4k
175 1.1.1.2.2.2 bouyer * maximum window.
176 1.1.1.2.2.2 bouyer */
177 1.1.1.2.2.2 bouyer PageBoundaryMapLength =
178 1.1.1.2.2.2 bouyer ACPI_ROUND_UP (Address, ACPI_DEFAULT_PAGE_SIZE) - Address;
179 1.1.1.2.2.2 bouyer if (PageBoundaryMapLength == 0)
180 1.1.1.2.2.2 bouyer {
181 1.1.1.2.2.2 bouyer PageBoundaryMapLength = ACPI_DEFAULT_PAGE_SIZE;
182 1.1.1.2.2.2 bouyer }
183 1.1.1.2.2.2 bouyer
184 1.1.1.2.2.2 bouyer if (MapLength > PageBoundaryMapLength)
185 1.1.1.2.2.2 bouyer {
186 1.1.1.2.2.2 bouyer MapLength = PageBoundaryMapLength;
187 1.1.1.2.2.2 bouyer }
188 1.1.1.2.2.2 bouyer
189 1.1.1.2.2.2 bouyer /* Create a new mapping starting at the address given */
190 1.1.1.2.2.2 bouyer
191 1.1.1.2.2.2 bouyer MemInfo->MappedLogicalAddress = AcpiOsMapMemory (
192 1.1.1.2.2.2 bouyer (ACPI_PHYSICAL_ADDRESS) Address, MapLength);
193 1.1.1.2.2.2 bouyer if (!MemInfo->MappedLogicalAddress)
194 1.1.1.2.2.2 bouyer {
195 1.1.1.2.2.2 bouyer ACPI_ERROR ((AE_INFO,
196 1.1.1.2.2.2 bouyer "Could not map memory at 0x%8.8X%8.8X, size %u",
197 1.1.1.2.2.2 bouyer ACPI_FORMAT_NATIVE_UINT (Address), (UINT32) MapLength));
198 1.1.1.2.2.2 bouyer MemInfo->MappedLength = 0;
199 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_NO_MEMORY);
200 1.1.1.2.2.2 bouyer }
201 1.1.1.2.2.2 bouyer
202 1.1.1.2.2.2 bouyer /* Save the physical address and mapping size */
203 1.1.1.2.2.2 bouyer
204 1.1.1.2.2.2 bouyer MemInfo->MappedPhysicalAddress = Address;
205 1.1.1.2.2.2 bouyer MemInfo->MappedLength = MapLength;
206 1.1.1.2.2.2 bouyer }
207 1.1.1.2.2.2 bouyer
208 1.1.1.2.2.2 bouyer /*
209 1.1.1.2.2.2 bouyer * Generate a logical pointer corresponding to the address we want to
210 1.1.1.2.2.2 bouyer * access
211 1.1.1.2.2.2 bouyer */
212 1.1.1.2.2.2 bouyer LogicalAddrPtr = MemInfo->MappedLogicalAddress +
213 1.1.1.2.2.2 bouyer ((UINT64) Address - (UINT64) MemInfo->MappedPhysicalAddress);
214 1.1.1.2.2.2 bouyer
215 1.1.1.2.2.2 bouyer ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
216 1.1.1.2.2.2 bouyer "System-Memory (width %u) R/W %u Address=%8.8X%8.8X\n",
217 1.1.1.2.2.2 bouyer BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address)));
218 1.1.1.2.2.2 bouyer
219 1.1.1.2.2.2 bouyer /*
220 1.1.1.2.2.2 bouyer * Perform the memory read or write
221 1.1.1.2.2.2 bouyer *
222 1.1.1.2.2.2 bouyer * Note: For machines that do not support non-aligned transfers, the target
223 1.1.1.2.2.2 bouyer * address was checked for alignment above. We do not attempt to break the
224 1.1.1.2.2.2 bouyer * transfer up into smaller (byte-size) chunks because the AML specifically
225 1.1.1.2.2.2 bouyer * asked for a transfer width that the hardware may require.
226 1.1.1.2.2.2 bouyer */
227 1.1.1.2.2.2 bouyer switch (Function)
228 1.1.1.2.2.2 bouyer {
229 1.1.1.2.2.2 bouyer case ACPI_READ:
230 1.1.1.2.2.2 bouyer
231 1.1.1.2.2.2 bouyer *Value = 0;
232 1.1.1.2.2.2 bouyer switch (BitWidth)
233 1.1.1.2.2.2 bouyer {
234 1.1.1.2.2.2 bouyer case 8:
235 1.1.1.2.2.2 bouyer *Value = (UINT64) ACPI_GET8 (LogicalAddrPtr);
236 1.1.1.2.2.2 bouyer break;
237 1.1.1.2.2.2 bouyer
238 1.1.1.2.2.2 bouyer case 16:
239 1.1.1.2.2.2 bouyer *Value = (UINT64) ACPI_GET16 (LogicalAddrPtr);
240 1.1.1.2.2.2 bouyer break;
241 1.1.1.2.2.2 bouyer
242 1.1.1.2.2.2 bouyer case 32:
243 1.1.1.2.2.2 bouyer *Value = (UINT64) ACPI_GET32 (LogicalAddrPtr);
244 1.1.1.2.2.2 bouyer break;
245 1.1.1.2.2.2 bouyer
246 1.1.1.2.2.2 bouyer case 64:
247 1.1.1.2.2.2 bouyer *Value = (UINT64) ACPI_GET64 (LogicalAddrPtr);
248 1.1.1.2.2.2 bouyer break;
249 1.1.1.2.2.2 bouyer
250 1.1.1.2.2.2 bouyer default:
251 1.1.1.2.2.2 bouyer /* BitWidth was already validated */
252 1.1.1.2.2.2 bouyer break;
253 1.1.1.2.2.2 bouyer }
254 1.1.1.2.2.2 bouyer break;
255 1.1.1.2.2.2 bouyer
256 1.1.1.2.2.2 bouyer case ACPI_WRITE:
257 1.1.1.2.2.2 bouyer
258 1.1.1.2.2.2 bouyer switch (BitWidth)
259 1.1.1.2.2.2 bouyer {
260 1.1.1.2.2.2 bouyer case 8:
261 1.1.1.2.2.2 bouyer ACPI_SET8 (LogicalAddrPtr) = (UINT8) *Value;
262 1.1.1.2.2.2 bouyer break;
263 1.1.1.2.2.2 bouyer
264 1.1.1.2.2.2 bouyer case 16:
265 1.1.1.2.2.2 bouyer ACPI_SET16 (LogicalAddrPtr) = (UINT16) *Value;
266 1.1.1.2.2.2 bouyer break;
267 1.1.1.2.2.2 bouyer
268 1.1.1.2.2.2 bouyer case 32:
269 1.1.1.2.2.2 bouyer ACPI_SET32 ( LogicalAddrPtr) = (UINT32) *Value;
270 1.1.1.2.2.2 bouyer break;
271 1.1.1.2.2.2 bouyer
272 1.1.1.2.2.2 bouyer case 64:
273 1.1.1.2.2.2 bouyer ACPI_SET64 (LogicalAddrPtr) = (UINT64) *Value;
274 1.1.1.2.2.2 bouyer break;
275 1.1.1.2.2.2 bouyer
276 1.1.1.2.2.2 bouyer default:
277 1.1.1.2.2.2 bouyer /* BitWidth was already validated */
278 1.1.1.2.2.2 bouyer break;
279 1.1.1.2.2.2 bouyer }
280 1.1.1.2.2.2 bouyer break;
281 1.1.1.2.2.2 bouyer
282 1.1.1.2.2.2 bouyer default:
283 1.1.1.2.2.2 bouyer Status = AE_BAD_PARAMETER;
284 1.1.1.2.2.2 bouyer break;
285 1.1.1.2.2.2 bouyer }
286 1.1.1.2.2.2 bouyer
287 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
288 1.1.1.2.2.2 bouyer }
289 1.1.1.2.2.2 bouyer
290 1.1.1.2.2.2 bouyer
291 1.1.1.2.2.2 bouyer /*******************************************************************************
292 1.1.1.2.2.2 bouyer *
293 1.1.1.2.2.2 bouyer * FUNCTION: AcpiExSystemIoSpaceHandler
294 1.1.1.2.2.2 bouyer *
295 1.1.1.2.2.2 bouyer * PARAMETERS: Function - Read or Write operation
296 1.1.1.2.2.2 bouyer * Address - Where in the space to read or write
297 1.1.1.2.2.2 bouyer * BitWidth - Field width in bits (8, 16, or 32)
298 1.1.1.2.2.2 bouyer * Value - Pointer to in or out value
299 1.1.1.2.2.2 bouyer * HandlerContext - Pointer to Handler's context
300 1.1.1.2.2.2 bouyer * RegionContext - Pointer to context specific to the
301 1.1.1.2.2.2 bouyer * accessed region
302 1.1.1.2.2.2 bouyer *
303 1.1.1.2.2.2 bouyer * RETURN: Status
304 1.1.1.2.2.2 bouyer *
305 1.1.1.2.2.2 bouyer * DESCRIPTION: Handler for the System IO address space (Op Region)
306 1.1.1.2.2.2 bouyer *
307 1.1.1.2.2.2 bouyer ******************************************************************************/
308 1.1.1.2.2.2 bouyer
309 1.1.1.2.2.2 bouyer ACPI_STATUS
310 1.1.1.2.2.2 bouyer AcpiExSystemIoSpaceHandler (
311 1.1.1.2.2.2 bouyer UINT32 Function,
312 1.1.1.2.2.2 bouyer ACPI_PHYSICAL_ADDRESS Address,
313 1.1.1.2.2.2 bouyer UINT32 BitWidth,
314 1.1.1.2.2.2 bouyer UINT64 *Value,
315 1.1.1.2.2.2 bouyer void *HandlerContext,
316 1.1.1.2.2.2 bouyer void *RegionContext)
317 1.1.1.2.2.2 bouyer {
318 1.1.1.2.2.2 bouyer ACPI_STATUS Status = AE_OK;
319 1.1.1.2.2.2 bouyer UINT32 Value32;
320 1.1.1.2.2.2 bouyer
321 1.1.1.2.2.2 bouyer
322 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE (ExSystemIoSpaceHandler);
323 1.1.1.2.2.2 bouyer
324 1.1.1.2.2.2 bouyer
325 1.1.1.2.2.2 bouyer ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
326 1.1.1.2.2.2 bouyer "System-IO (width %u) R/W %u Address=%8.8X%8.8X\n",
327 1.1.1.2.2.2 bouyer BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address)));
328 1.1.1.2.2.2 bouyer
329 1.1.1.2.2.2 bouyer /* Decode the function parameter */
330 1.1.1.2.2.2 bouyer
331 1.1.1.2.2.2 bouyer switch (Function)
332 1.1.1.2.2.2 bouyer {
333 1.1.1.2.2.2 bouyer case ACPI_READ:
334 1.1.1.2.2.2 bouyer
335 1.1.1.2.2.2 bouyer Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) Address,
336 1.1.1.2.2.2 bouyer &Value32, BitWidth);
337 1.1.1.2.2.2 bouyer *Value = Value32;
338 1.1.1.2.2.2 bouyer break;
339 1.1.1.2.2.2 bouyer
340 1.1.1.2.2.2 bouyer case ACPI_WRITE:
341 1.1.1.2.2.2 bouyer
342 1.1.1.2.2.2 bouyer Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) Address,
343 1.1.1.2.2.2 bouyer (UINT32) *Value, BitWidth);
344 1.1.1.2.2.2 bouyer break;
345 1.1.1.2.2.2 bouyer
346 1.1.1.2.2.2 bouyer default:
347 1.1.1.2.2.2 bouyer Status = AE_BAD_PARAMETER;
348 1.1.1.2.2.2 bouyer break;
349 1.1.1.2.2.2 bouyer }
350 1.1.1.2.2.2 bouyer
351 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
352 1.1.1.2.2.2 bouyer }
353 1.1.1.2.2.2 bouyer
354 1.1.1.2.2.2 bouyer
355 1.1.1.2.2.2 bouyer /*******************************************************************************
356 1.1.1.2.2.2 bouyer *
357 1.1.1.2.2.2 bouyer * FUNCTION: AcpiExPciConfigSpaceHandler
358 1.1.1.2.2.2 bouyer *
359 1.1.1.2.2.2 bouyer * PARAMETERS: Function - Read or Write operation
360 1.1.1.2.2.2 bouyer * Address - Where in the space to read or write
361 1.1.1.2.2.2 bouyer * BitWidth - Field width in bits (8, 16, or 32)
362 1.1.1.2.2.2 bouyer * Value - Pointer to in or out value
363 1.1.1.2.2.2 bouyer * HandlerContext - Pointer to Handler's context
364 1.1.1.2.2.2 bouyer * RegionContext - Pointer to context specific to the
365 1.1.1.2.2.2 bouyer * accessed region
366 1.1.1.2.2.2 bouyer *
367 1.1.1.2.2.2 bouyer * RETURN: Status
368 1.1.1.2.2.2 bouyer *
369 1.1.1.2.2.2 bouyer * DESCRIPTION: Handler for the PCI Config address space (Op Region)
370 1.1.1.2.2.2 bouyer *
371 1.1.1.2.2.2 bouyer ******************************************************************************/
372 1.1.1.2.2.2 bouyer
373 1.1.1.2.2.2 bouyer ACPI_STATUS
374 1.1.1.2.2.2 bouyer AcpiExPciConfigSpaceHandler (
375 1.1.1.2.2.2 bouyer UINT32 Function,
376 1.1.1.2.2.2 bouyer ACPI_PHYSICAL_ADDRESS Address,
377 1.1.1.2.2.2 bouyer UINT32 BitWidth,
378 1.1.1.2.2.2 bouyer UINT64 *Value,
379 1.1.1.2.2.2 bouyer void *HandlerContext,
380 1.1.1.2.2.2 bouyer void *RegionContext)
381 1.1.1.2.2.2 bouyer {
382 1.1.1.2.2.2 bouyer ACPI_STATUS Status = AE_OK;
383 1.1.1.2.2.2 bouyer ACPI_PCI_ID *PciId;
384 1.1.1.2.2.2 bouyer UINT16 PciRegister;
385 1.1.1.2.2.2 bouyer
386 1.1.1.2.2.2 bouyer
387 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE (ExPciConfigSpaceHandler);
388 1.1.1.2.2.2 bouyer
389 1.1.1.2.2.2 bouyer
390 1.1.1.2.2.2 bouyer /*
391 1.1.1.2.2.2 bouyer * The arguments to AcpiOs(Read|Write)PciConfiguration are:
392 1.1.1.2.2.2 bouyer *
393 1.1.1.2.2.2 bouyer * PciSegment is the PCI bus segment range 0-31
394 1.1.1.2.2.2 bouyer * PciBus is the PCI bus number range 0-255
395 1.1.1.2.2.2 bouyer * PciDevice is the PCI device number range 0-31
396 1.1.1.2.2.2 bouyer * PciFunction is the PCI device function number
397 1.1.1.2.2.2 bouyer * PciRegister is the Config space register range 0-255 bytes
398 1.1.1.2.2.2 bouyer *
399 1.1.1.2.2.2 bouyer * Value - input value for write, output address for read
400 1.1.1.2.2.2 bouyer *
401 1.1.1.2.2.2 bouyer */
402 1.1.1.2.2.2 bouyer PciId = (ACPI_PCI_ID *) RegionContext;
403 1.1.1.2.2.2 bouyer PciRegister = (UINT16) (UINT32) Address;
404 1.1.1.2.2.2 bouyer
405 1.1.1.2.2.2 bouyer ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
406 1.1.1.2.2.2 bouyer "Pci-Config %u (%u) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n",
407 1.1.1.2.2.2 bouyer Function, BitWidth, PciId->Segment, PciId->Bus, PciId->Device,
408 1.1.1.2.2.2 bouyer PciId->Function, PciRegister));
409 1.1.1.2.2.2 bouyer
410 1.1.1.2.2.2 bouyer switch (Function)
411 1.1.1.2.2.2 bouyer {
412 1.1.1.2.2.2 bouyer case ACPI_READ:
413 1.1.1.2.2.2 bouyer
414 1.1.1.2.2.2 bouyer *Value = 0;
415 1.1.1.2.2.2 bouyer Status = AcpiOsReadPciConfiguration (PciId, PciRegister,
416 1.1.1.2.2.2 bouyer Value, BitWidth);
417 1.1.1.2.2.2 bouyer break;
418 1.1.1.2.2.2 bouyer
419 1.1.1.2.2.2 bouyer case ACPI_WRITE:
420 1.1.1.2.2.2 bouyer
421 1.1.1.2.2.2 bouyer Status = AcpiOsWritePciConfiguration (PciId, PciRegister,
422 1.1.1.2.2.2 bouyer *Value, BitWidth);
423 1.1.1.2.2.2 bouyer break;
424 1.1.1.2.2.2 bouyer
425 1.1.1.2.2.2 bouyer default:
426 1.1.1.2.2.2 bouyer
427 1.1.1.2.2.2 bouyer Status = AE_BAD_PARAMETER;
428 1.1.1.2.2.2 bouyer break;
429 1.1.1.2.2.2 bouyer }
430 1.1.1.2.2.2 bouyer
431 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
432 1.1.1.2.2.2 bouyer }
433 1.1.1.2.2.2 bouyer
434 1.1.1.2.2.2 bouyer
435 1.1.1.2.2.2 bouyer /*******************************************************************************
436 1.1.1.2.2.2 bouyer *
437 1.1.1.2.2.2 bouyer * FUNCTION: AcpiExCmosSpaceHandler
438 1.1.1.2.2.2 bouyer *
439 1.1.1.2.2.2 bouyer * PARAMETERS: Function - Read or Write operation
440 1.1.1.2.2.2 bouyer * Address - Where in the space to read or write
441 1.1.1.2.2.2 bouyer * BitWidth - Field width in bits (8, 16, or 32)
442 1.1.1.2.2.2 bouyer * Value - Pointer to in or out value
443 1.1.1.2.2.2 bouyer * HandlerContext - Pointer to Handler's context
444 1.1.1.2.2.2 bouyer * RegionContext - Pointer to context specific to the
445 1.1.1.2.2.2 bouyer * accessed region
446 1.1.1.2.2.2 bouyer *
447 1.1.1.2.2.2 bouyer * RETURN: Status
448 1.1.1.2.2.2 bouyer *
449 1.1.1.2.2.2 bouyer * DESCRIPTION: Handler for the CMOS address space (Op Region)
450 1.1.1.2.2.2 bouyer *
451 1.1.1.2.2.2 bouyer ******************************************************************************/
452 1.1.1.2.2.2 bouyer
453 1.1.1.2.2.2 bouyer ACPI_STATUS
454 1.1.1.2.2.2 bouyer AcpiExCmosSpaceHandler (
455 1.1.1.2.2.2 bouyer UINT32 Function,
456 1.1.1.2.2.2 bouyer ACPI_PHYSICAL_ADDRESS Address,
457 1.1.1.2.2.2 bouyer UINT32 BitWidth,
458 1.1.1.2.2.2 bouyer UINT64 *Value,
459 1.1.1.2.2.2 bouyer void *HandlerContext,
460 1.1.1.2.2.2 bouyer void *RegionContext)
461 1.1.1.2.2.2 bouyer {
462 1.1.1.2.2.2 bouyer ACPI_STATUS Status = AE_OK;
463 1.1.1.2.2.2 bouyer
464 1.1.1.2.2.2 bouyer
465 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE (ExCmosSpaceHandler);
466 1.1.1.2.2.2 bouyer
467 1.1.1.2.2.2 bouyer
468 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
469 1.1.1.2.2.2 bouyer }
470 1.1.1.2.2.2 bouyer
471 1.1.1.2.2.2 bouyer
472 1.1.1.2.2.2 bouyer /*******************************************************************************
473 1.1.1.2.2.2 bouyer *
474 1.1.1.2.2.2 bouyer * FUNCTION: AcpiExPciBarSpaceHandler
475 1.1.1.2.2.2 bouyer *
476 1.1.1.2.2.2 bouyer * PARAMETERS: Function - Read or Write operation
477 1.1.1.2.2.2 bouyer * Address - Where in the space to read or write
478 1.1.1.2.2.2 bouyer * BitWidth - Field width in bits (8, 16, or 32)
479 1.1.1.2.2.2 bouyer * Value - Pointer to in or out value
480 1.1.1.2.2.2 bouyer * HandlerContext - Pointer to Handler's context
481 1.1.1.2.2.2 bouyer * RegionContext - Pointer to context specific to the
482 1.1.1.2.2.2 bouyer * accessed region
483 1.1.1.2.2.2 bouyer *
484 1.1.1.2.2.2 bouyer * RETURN: Status
485 1.1.1.2.2.2 bouyer *
486 1.1.1.2.2.2 bouyer * DESCRIPTION: Handler for the PCI BarTarget address space (Op Region)
487 1.1.1.2.2.2 bouyer *
488 1.1.1.2.2.2 bouyer ******************************************************************************/
489 1.1.1.2.2.2 bouyer
490 1.1.1.2.2.2 bouyer ACPI_STATUS
491 1.1.1.2.2.2 bouyer AcpiExPciBarSpaceHandler (
492 1.1.1.2.2.2 bouyer UINT32 Function,
493 1.1.1.2.2.2 bouyer ACPI_PHYSICAL_ADDRESS Address,
494 1.1.1.2.2.2 bouyer UINT32 BitWidth,
495 1.1.1.2.2.2 bouyer UINT64 *Value,
496 1.1.1.2.2.2 bouyer void *HandlerContext,
497 1.1.1.2.2.2 bouyer void *RegionContext)
498 1.1.1.2.2.2 bouyer {
499 1.1.1.2.2.2 bouyer ACPI_STATUS Status = AE_OK;
500 1.1.1.2.2.2 bouyer
501 1.1.1.2.2.2 bouyer
502 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE (ExPciBarSpaceHandler);
503 1.1.1.2.2.2 bouyer
504 1.1.1.2.2.2 bouyer
505 1.1.1.2.2.2 bouyer return_ACPI_STATUS (Status);
506 1.1.1.2.2.2 bouyer }
507 1.1.1.2.2.2 bouyer
508 1.1.1.2.2.2 bouyer
509 1.1.1.2.2.2 bouyer /*******************************************************************************
510 1.1.1.2.2.2 bouyer *
511 1.1.1.2.2.2 bouyer * FUNCTION: AcpiExDataTableSpaceHandler
512 1.1.1.2.2.2 bouyer *
513 1.1.1.2.2.2 bouyer * PARAMETERS: Function - Read or Write operation
514 1.1.1.2.2.2 bouyer * Address - Where in the space to read or write
515 1.1.1.2.2.2 bouyer * BitWidth - Field width in bits (8, 16, or 32)
516 1.1.1.2.2.2 bouyer * Value - Pointer to in or out value
517 1.1.1.2.2.2 bouyer * HandlerContext - Pointer to Handler's context
518 1.1.1.2.2.2 bouyer * RegionContext - Pointer to context specific to the
519 1.1.1.2.2.2 bouyer * accessed region
520 1.1.1.2.2.2 bouyer *
521 1.1.1.2.2.2 bouyer * RETURN: Status
522 1.1.1.2.2.2 bouyer *
523 1.1.1.2.2.2 bouyer * DESCRIPTION: Handler for the Data Table address space (Op Region)
524 1.1.1.2.2.2 bouyer *
525 1.1.1.2.2.2 bouyer ******************************************************************************/
526 1.1.1.2.2.2 bouyer
527 1.1.1.2.2.2 bouyer ACPI_STATUS
528 1.1.1.2.2.2 bouyer AcpiExDataTableSpaceHandler (
529 1.1.1.2.2.2 bouyer UINT32 Function,
530 1.1.1.2.2.2 bouyer ACPI_PHYSICAL_ADDRESS Address,
531 1.1.1.2.2.2 bouyer UINT32 BitWidth,
532 1.1.1.2.2.2 bouyer UINT64 *Value,
533 1.1.1.2.2.2 bouyer void *HandlerContext,
534 1.1.1.2.2.2 bouyer void *RegionContext)
535 1.1.1.2.2.2 bouyer {
536 1.1.1.2.2.2 bouyer ACPI_FUNCTION_TRACE (ExDataTableSpaceHandler);
537 1.1.1.2.2.2 bouyer
538 1.1.1.2.2.2 bouyer
539 1.1.1.2.2.2 bouyer /*
540 1.1.1.2.2.2 bouyer * Perform the memory read or write. The BitWidth was already
541 1.1.1.2.2.2 bouyer * validated.
542 1.1.1.2.2.2 bouyer */
543 1.1.1.2.2.2 bouyer switch (Function)
544 1.1.1.2.2.2 bouyer {
545 1.1.1.2.2.2 bouyer case ACPI_READ:
546 1.1.1.2.2.2 bouyer
547 1.1.1.2.2.2 bouyer ACPI_MEMCPY (ACPI_CAST_PTR (char, Value), ACPI_PHYSADDR_TO_PTR (Address),
548 1.1.1.2.2.2 bouyer ACPI_DIV_8 (BitWidth));
549 1.1.1.2.2.2 bouyer break;
550 1.1.1.2.2.2 bouyer
551 1.1.1.2.2.2 bouyer case ACPI_WRITE:
552 1.1.1.2.2.2 bouyer
553 1.1.1.2.2.2 bouyer ACPI_MEMCPY (ACPI_PHYSADDR_TO_PTR (Address), ACPI_CAST_PTR (char, Value),
554 1.1.1.2.2.2 bouyer ACPI_DIV_8 (BitWidth));
555 1.1.1.2.2.2 bouyer break;
556 1.1.1.2.2.2 bouyer
557 1.1.1.2.2.2 bouyer default:
558 1.1.1.2.2.2 bouyer
559 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_BAD_PARAMETER);
560 1.1.1.2.2.2 bouyer }
561 1.1.1.2.2.2 bouyer
562 1.1.1.2.2.2 bouyer return_ACPI_STATUS (AE_OK);
563 1.1.1.2.2.2 bouyer }
564 1.1.1.2.2.2 bouyer
565 1.1.1.2.2.2 bouyer
566