blob: 1db2c0bfde0b22f31aa7c88dc190bd48455faaf2 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/******************************************************************************
2 *
3 * Module Name: exregion - ACPI default op_region (address space) handlers
4 *
5 *****************************************************************************/
6
7/*
Bob Moore77848132012-01-12 13:27:23 +08008 * Copyright (C) 2000 - 2012, Intel Corp.
Linus Torvalds1da177e2005-04-16 15:20:36 -07009 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions, and the following disclaimer,
16 * without modification.
17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
18 * substantially similar to the "NO WARRANTY" disclaimer below
19 * ("Disclaimer") and any redistribution must be conditioned upon
20 * including a substantially similar Disclaimer requirement for further
21 * binary redistribution.
22 * 3. Neither the names of the above-listed copyright holders nor the names
23 * of any contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * Alternatively, this software may be distributed under the terms of the
27 * GNU General Public License ("GPL") version 2 as published by the Free
28 * Software Foundation.
29 *
30 * NO WARRANTY
31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
41 * POSSIBILITY OF SUCH DAMAGES.
42 */
43
Linus Torvalds1da177e2005-04-16 15:20:36 -070044#include <acpi/acpi.h>
Len Browne2f7a772009-01-09 00:30:03 -050045#include "accommon.h"
46#include "acinterp.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070047
Linus Torvalds1da177e2005-04-16 15:20:36 -070048#define _COMPONENT ACPI_EXECUTER
Len Brown4be44fc2005-08-05 00:44:28 -040049ACPI_MODULE_NAME("exregion")
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51/*******************************************************************************
52 *
53 * FUNCTION: acpi_ex_system_memory_space_handler
54 *
Bob Mooreba494be2012-07-12 09:40:10 +080055 * PARAMETERS: function - Read or Write operation
56 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -070057 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +080058 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 * handler_context - Pointer to Handler's context
60 * region_context - Pointer to context specific to the
61 * accessed region
62 *
63 * RETURN: Status
64 *
65 * DESCRIPTION: Handler for the System Memory address space (Op Region)
66 *
67 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070068acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040069acpi_ex_system_memory_space_handler(u32 function,
70 acpi_physical_address address,
71 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +080072 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -040073 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -070074{
Len Brown4be44fc2005-08-05 00:44:28 -040075 acpi_status status = AE_OK;
76 void *logical_addr_ptr = NULL;
77 struct acpi_mem_space_context *mem_info = region_context;
78 u32 length;
Bob Moored410ee52009-10-22 09:11:11 +080079 acpi_size map_length;
80 acpi_size page_boundary_map_length;
Bob Moore08978312005-10-21 00:00:00 -040081#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
Len Brown4be44fc2005-08-05 00:44:28 -040082 u32 remainder;
Linus Torvalds1da177e2005-04-16 15:20:36 -070083#endif
84
Bob Mooreb229cf92006-04-21 17:15:00 -040085 ACPI_FUNCTION_TRACE(ex_system_memory_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -070086
87 /* Validate and translate the bit width */
88
89 switch (bit_width) {
90 case 8:
91 length = 1;
92 break;
93
94 case 16:
95 length = 2;
96 break;
97
98 case 32:
99 length = 4;
100 break;
101
102 case 64:
103 length = 8;
104 break;
105
106 default:
Bob Mooref6a22b02010-03-05 17:56:40 +0800107 ACPI_ERROR((AE_INFO, "Invalid SystemMemory width %u",
Bob Mooreb8e4d892006-01-27 16:43:00 -0500108 bit_width));
Len Brown4be44fc2005-08-05 00:44:28 -0400109 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700110 }
111
Bob Moore08978312005-10-21 00:00:00 -0400112#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 /*
114 * Hardware does not support non-aligned data transfers, we must verify
115 * the request.
116 */
Bob Moore5df7e6c2010-01-21 10:06:32 +0800117 (void)acpi_ut_short_divide((u64) address, length, NULL, &remainder);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 if (remainder != 0) {
Len Brown4be44fc2005-08-05 00:44:28 -0400119 return_ACPI_STATUS(AE_AML_ALIGNMENT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700120 }
121#endif
122
123 /*
124 * Does the request fit into the cached memory mapping?
125 * Is 1) Address below the current mapping? OR
126 * 2) Address beyond the current mapping?
127 */
128 if ((address < mem_info->mapped_physical_address) ||
Bob Moore5df7e6c2010-01-21 10:06:32 +0800129 (((u64) address + length) > ((u64)
130 mem_info->mapped_physical_address +
131 mem_info->mapped_length))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700132 /*
133 * The request cannot be resolved by the current memory mapping;
134 * Delete the existing mapping and create a new one.
135 */
136 if (mem_info->mapped_length) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400137
Linus Torvalds1da177e2005-04-16 15:20:36 -0700138 /* Valid mapping, delete it */
139
Len Brown4be44fc2005-08-05 00:44:28 -0400140 acpi_os_unmap_memory(mem_info->mapped_logical_address,
141 mem_info->mapped_length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 }
143
144 /*
Bob Moored410ee52009-10-22 09:11:11 +0800145 * Attempt to map from the requested address to the end of the region.
146 * However, we will never map more than one page, nor will we cross
147 * a page boundary.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700148 */
Bob Moored410ee52009-10-22 09:11:11 +0800149 map_length = (acpi_size)
Len Brown4be44fc2005-08-05 00:44:28 -0400150 ((mem_info->address + mem_info->length) - address);
Robert Moore44f6c012005-04-18 22:49:35 -0400151
Bob Moored410ee52009-10-22 09:11:11 +0800152 /*
153 * If mapping the entire remaining portion of the region will cross
154 * a page boundary, just map up to the page boundary, do not cross.
155 * On some systems, crossing a page boundary while mapping regions
156 * can cause warnings if the pages have different attributes
157 * due to resource management
158 */
159 page_boundary_map_length =
160 ACPI_ROUND_UP(address, ACPI_DEFAULT_PAGE_SIZE) - address;
161
162 if (!page_boundary_map_length) {
163 page_boundary_map_length = ACPI_DEFAULT_PAGE_SIZE;
164 }
165
166 if (map_length > page_boundary_map_length) {
167 map_length = page_boundary_map_length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700168 }
169
170 /* Create a new mapping starting at the address given */
171
Bob Moored410ee52009-10-22 09:11:11 +0800172 mem_info->mapped_logical_address = acpi_os_map_memory((acpi_physical_address) address, map_length);
Bob Mooref3d2e782007-02-02 19:48:18 +0300173 if (!mem_info->mapped_logical_address) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500174 ACPI_ERROR((AE_INFO,
Bob Mooref6a22b02010-03-05 17:56:40 +0800175 "Could not map memory at 0x%8.8X%8.8X, size %u",
Bob Mooreb7f9f042008-04-10 19:06:40 +0400176 ACPI_FORMAT_NATIVE_UINT(address),
Bob Moored410ee52009-10-22 09:11:11 +0800177 (u32) map_length));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700178 mem_info->mapped_length = 0;
Bob Mooref3d2e782007-02-02 19:48:18 +0300179 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180 }
181
182 /* Save the physical address and mapping size */
183
184 mem_info->mapped_physical_address = address;
Bob Moored410ee52009-10-22 09:11:11 +0800185 mem_info->mapped_length = map_length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700186 }
187
188 /*
189 * Generate a logical pointer corresponding to the address we want to
190 * access
191 */
192 logical_addr_ptr = mem_info->mapped_logical_address +
Bob Moore5df7e6c2010-01-21 10:06:32 +0800193 ((u64) address - (u64) mem_info->mapped_physical_address);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700194
Len Brown4be44fc2005-08-05 00:44:28 -0400195 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Bob Mooreb27d6592010-05-26 11:47:13 +0800196 "System-Memory (width %u) R/W %u Address=%8.8X%8.8X\n",
Bob Mooreb7f9f042008-04-10 19:06:40 +0400197 bit_width, function,
198 ACPI_FORMAT_NATIVE_UINT(address)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199
Len Brown4be44fc2005-08-05 00:44:28 -0400200 /*
201 * Perform the memory read or write
202 *
203 * Note: For machines that do not support non-aligned transfers, the target
Bob Moore73a30902012-10-31 02:26:55 +0000204 * address was checked for alignment above. We do not attempt to break the
Len Brown4be44fc2005-08-05 00:44:28 -0400205 * transfer up into smaller (byte-size) chunks because the AML specifically
206 * asked for a transfer width that the hardware may require.
207 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208 switch (function) {
209 case ACPI_READ:
210
211 *value = 0;
212 switch (bit_width) {
213 case 8:
Bob Moore5df7e6c2010-01-21 10:06:32 +0800214 *value = (u64) ACPI_GET8(logical_addr_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 break;
216
217 case 16:
Bob Moore5df7e6c2010-01-21 10:06:32 +0800218 *value = (u64) ACPI_GET16(logical_addr_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 break;
220
221 case 32:
Bob Moore5df7e6c2010-01-21 10:06:32 +0800222 *value = (u64) ACPI_GET32(logical_addr_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 break;
224
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 case 64:
Bob Moore5df7e6c2010-01-21 10:06:32 +0800226 *value = (u64) ACPI_GET64(logical_addr_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 break;
Bob Moore59fa8502007-02-02 19:48:23 +0300228
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 default:
230 /* bit_width was already validated */
231 break;
232 }
233 break;
234
235 case ACPI_WRITE:
236
237 switch (bit_width) {
238 case 8:
Bob Moorec51a4de2005-11-17 13:07:00 -0500239 ACPI_SET8(logical_addr_ptr) = (u8) * value;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 break;
241
242 case 16:
Bob Moorec51a4de2005-11-17 13:07:00 -0500243 ACPI_SET16(logical_addr_ptr) = (u16) * value;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 break;
245
246 case 32:
Bob Moorec51a4de2005-11-17 13:07:00 -0500247 ACPI_SET32(logical_addr_ptr) = (u32) * value;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 break;
249
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250 case 64:
Bob Moorec51a4de2005-11-17 13:07:00 -0500251 ACPI_SET64(logical_addr_ptr) = (u64) * value;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253
254 default:
255 /* bit_width was already validated */
256 break;
257 }
258 break;
259
260 default:
261 status = AE_BAD_PARAMETER;
262 break;
263 }
264
Len Brown4be44fc2005-08-05 00:44:28 -0400265 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266}
267
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268/*******************************************************************************
269 *
270 * FUNCTION: acpi_ex_system_io_space_handler
271 *
Bob Mooreba494be2012-07-12 09:40:10 +0800272 * PARAMETERS: function - Read or Write operation
273 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700274 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800275 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 * handler_context - Pointer to Handler's context
277 * region_context - Pointer to context specific to the
278 * accessed region
279 *
280 * RETURN: Status
281 *
282 * DESCRIPTION: Handler for the System IO address space (Op Region)
283 *
284 ******************************************************************************/
285
286acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400287acpi_ex_system_io_space_handler(u32 function,
288 acpi_physical_address address,
289 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800290 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400291 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700292{
Len Brown4be44fc2005-08-05 00:44:28 -0400293 acpi_status status = AE_OK;
294 u32 value32;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700295
Bob Mooreb229cf92006-04-21 17:15:00 -0400296 ACPI_FUNCTION_TRACE(ex_system_io_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700297
Len Brown4be44fc2005-08-05 00:44:28 -0400298 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Bob Mooreb27d6592010-05-26 11:47:13 +0800299 "System-IO (width %u) R/W %u Address=%8.8X%8.8X\n",
Bob Mooreb7f9f042008-04-10 19:06:40 +0400300 bit_width, function,
301 ACPI_FORMAT_NATIVE_UINT(address)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700302
303 /* Decode the function parameter */
304
305 switch (function) {
306 case ACPI_READ:
307
Bob Moore7f071902009-03-19 09:37:47 +0800308 status = acpi_hw_read_port((acpi_io_address) address,
Len Brown4be44fc2005-08-05 00:44:28 -0400309 &value32, bit_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310 *value = value32;
311 break;
312
313 case ACPI_WRITE:
314
Bob Moore7f071902009-03-19 09:37:47 +0800315 status = acpi_hw_write_port((acpi_io_address) address,
Len Brown4be44fc2005-08-05 00:44:28 -0400316 (u32) * value, bit_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317 break;
318
319 default:
320 status = AE_BAD_PARAMETER;
321 break;
322 }
323
Len Brown4be44fc2005-08-05 00:44:28 -0400324 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700325}
326
Linus Torvalds1da177e2005-04-16 15:20:36 -0700327/*******************************************************************************
328 *
329 * FUNCTION: acpi_ex_pci_config_space_handler
330 *
Bob Mooreba494be2012-07-12 09:40:10 +0800331 * PARAMETERS: function - Read or Write operation
332 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700333 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800334 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 * handler_context - Pointer to Handler's context
336 * region_context - Pointer to context specific to the
337 * accessed region
338 *
339 * RETURN: Status
340 *
341 * DESCRIPTION: Handler for the PCI Config address space (Op Region)
342 *
343 ******************************************************************************/
344
345acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400346acpi_ex_pci_config_space_handler(u32 function,
347 acpi_physical_address address,
348 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800349 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400350 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351{
Len Brown4be44fc2005-08-05 00:44:28 -0400352 acpi_status status = AE_OK;
353 struct acpi_pci_id *pci_id;
354 u16 pci_register;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355
Bob Mooreb229cf92006-04-21 17:15:00 -0400356 ACPI_FUNCTION_TRACE(ex_pci_config_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700357
358 /*
359 * The arguments to acpi_os(Read|Write)pci_configuration are:
360 *
361 * pci_segment is the PCI bus segment range 0-31
362 * pci_bus is the PCI bus number range 0-255
363 * pci_device is the PCI device number range 0-31
364 * pci_function is the PCI device function number
365 * pci_register is the Config space register range 0-255 bytes
366 *
Bob Mooreba494be2012-07-12 09:40:10 +0800367 * value - input value for write, output address for read
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 *
369 */
Len Brown4be44fc2005-08-05 00:44:28 -0400370 pci_id = (struct acpi_pci_id *)region_context;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371 pci_register = (u16) (u32) address;
372
Len Brown4be44fc2005-08-05 00:44:28 -0400373 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Bob Mooreb27d6592010-05-26 11:47:13 +0800374 "Pci-Config %u (%u) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400375 function, bit_width, pci_id->segment, pci_id->bus,
376 pci_id->device, pci_id->function, pci_register));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700377
378 switch (function) {
379 case ACPI_READ:
380
Len Brown4be44fc2005-08-05 00:44:28 -0400381 status = acpi_os_read_pci_configuration(pci_id, pci_register,
Bob Moorec5f02312010-08-06 08:57:53 +0800382 value, bit_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700383 break;
384
385 case ACPI_WRITE:
386
Len Brown4be44fc2005-08-05 00:44:28 -0400387 status = acpi_os_write_pci_configuration(pci_id, pci_register,
388 *value, bit_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 break;
390
391 default:
392
393 status = AE_BAD_PARAMETER;
394 break;
395 }
396
Len Brown4be44fc2005-08-05 00:44:28 -0400397 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700398}
399
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400/*******************************************************************************
401 *
402 * FUNCTION: acpi_ex_cmos_space_handler
403 *
Bob Mooreba494be2012-07-12 09:40:10 +0800404 * PARAMETERS: function - Read or Write operation
405 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700406 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800407 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700408 * handler_context - Pointer to Handler's context
409 * region_context - Pointer to context specific to the
410 * accessed region
411 *
412 * RETURN: Status
413 *
414 * DESCRIPTION: Handler for the CMOS address space (Op Region)
415 *
416 ******************************************************************************/
417
418acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400419acpi_ex_cmos_space_handler(u32 function,
420 acpi_physical_address address,
421 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800422 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400423 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424{
Len Brown4be44fc2005-08-05 00:44:28 -0400425 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426
Bob Mooreb229cf92006-04-21 17:15:00 -0400427 ACPI_FUNCTION_TRACE(ex_cmos_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428
Len Brown4be44fc2005-08-05 00:44:28 -0400429 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430}
431
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432/*******************************************************************************
433 *
434 * FUNCTION: acpi_ex_pci_bar_space_handler
435 *
Bob Mooreba494be2012-07-12 09:40:10 +0800436 * PARAMETERS: function - Read or Write operation
437 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700438 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800439 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700440 * handler_context - Pointer to Handler's context
441 * region_context - Pointer to context specific to the
442 * accessed region
443 *
444 * RETURN: Status
445 *
446 * DESCRIPTION: Handler for the PCI bar_target address space (Op Region)
447 *
448 ******************************************************************************/
449
450acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400451acpi_ex_pci_bar_space_handler(u32 function,
452 acpi_physical_address address,
453 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800454 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400455 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456{
Len Brown4be44fc2005-08-05 00:44:28 -0400457 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458
Bob Mooreb229cf92006-04-21 17:15:00 -0400459 ACPI_FUNCTION_TRACE(ex_pci_bar_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460
Len Brown4be44fc2005-08-05 00:44:28 -0400461 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462}
463
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464/*******************************************************************************
465 *
466 * FUNCTION: acpi_ex_data_table_space_handler
467 *
Bob Mooreba494be2012-07-12 09:40:10 +0800468 * PARAMETERS: function - Read or Write operation
469 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700470 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800471 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472 * handler_context - Pointer to Handler's context
473 * region_context - Pointer to context specific to the
474 * accessed region
475 *
476 * RETURN: Status
477 *
478 * DESCRIPTION: Handler for the Data Table address space (Op Region)
479 *
480 ******************************************************************************/
481
482acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400483acpi_ex_data_table_space_handler(u32 function,
484 acpi_physical_address address,
485 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800486 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400487 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488{
Bob Mooreb229cf92006-04-21 17:15:00 -0400489 ACPI_FUNCTION_TRACE(ex_data_table_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490
Bob Moorec1637e92010-04-01 11:09:00 +0800491 /*
492 * Perform the memory read or write. The bit_width was already
493 * validated.
494 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 switch (function) {
496 case ACPI_READ:
497
Bob Moore41195322006-05-26 16:36:00 -0400498 ACPI_MEMCPY(ACPI_CAST_PTR(char, value),
499 ACPI_PHYSADDR_TO_PTR(address),
500 ACPI_DIV_8(bit_width));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700501 break;
502
503 case ACPI_WRITE:
Bob Moorec1637e92010-04-01 11:09:00 +0800504
505 ACPI_MEMCPY(ACPI_PHYSADDR_TO_PTR(address),
506 ACPI_CAST_PTR(char, value), ACPI_DIV_8(bit_width));
507 break;
508
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509 default:
510
Bob Moorec1637e92010-04-01 11:09:00 +0800511 return_ACPI_STATUS(AE_BAD_PARAMETER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512 }
513
Bob Moore41195322006-05-26 16:36:00 -0400514 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700515}