blob: 044d44141be6e918a2b26a6f1067fa2ab9779c03 [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 /*
Lv Zheng75c80442012-12-19 05:36:49 +0000145 * October 2009: Attempt to map from the requested address to the
146 * end of the region. However, we will never map more than one
147 * page, nor will we cross 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
Lv Zheng75c80442012-12-19 05:36:49 +0000157 * due to resource management.
158 *
159 * This has the added benefit of constraining a single mapping to
160 * one page, which is similar to the original code that used a 4k
161 * maximum window.
Bob Moored410ee52009-10-22 09:11:11 +0800162 */
163 page_boundary_map_length =
164 ACPI_ROUND_UP(address, ACPI_DEFAULT_PAGE_SIZE) - address;
165
Lv Zheng739dcbb2012-12-20 01:07:26 +0000166 if (page_boundary_map_length == 0) {
Bob Moored410ee52009-10-22 09:11:11 +0800167 page_boundary_map_length = ACPI_DEFAULT_PAGE_SIZE;
168 }
169
170 if (map_length > page_boundary_map_length) {
171 map_length = page_boundary_map_length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 }
173
174 /* Create a new mapping starting at the address given */
175
Bob Moored410ee52009-10-22 09:11:11 +0800176 mem_info->mapped_logical_address = acpi_os_map_memory((acpi_physical_address) address, map_length);
Bob Mooref3d2e782007-02-02 19:48:18 +0300177 if (!mem_info->mapped_logical_address) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500178 ACPI_ERROR((AE_INFO,
Bob Mooref6a22b02010-03-05 17:56:40 +0800179 "Could not map memory at 0x%8.8X%8.8X, size %u",
Bob Mooreb7f9f042008-04-10 19:06:40 +0400180 ACPI_FORMAT_NATIVE_UINT(address),
Bob Moored410ee52009-10-22 09:11:11 +0800181 (u32) map_length));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 mem_info->mapped_length = 0;
Bob Mooref3d2e782007-02-02 19:48:18 +0300183 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184 }
185
186 /* Save the physical address and mapping size */
187
188 mem_info->mapped_physical_address = address;
Bob Moored410ee52009-10-22 09:11:11 +0800189 mem_info->mapped_length = map_length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 }
191
192 /*
193 * Generate a logical pointer corresponding to the address we want to
194 * access
195 */
196 logical_addr_ptr = mem_info->mapped_logical_address +
Bob Moore5df7e6c2010-01-21 10:06:32 +0800197 ((u64) address - (u64) mem_info->mapped_physical_address);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
Len Brown4be44fc2005-08-05 00:44:28 -0400199 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Bob Mooreb27d6592010-05-26 11:47:13 +0800200 "System-Memory (width %u) R/W %u Address=%8.8X%8.8X\n",
Bob Mooreb7f9f042008-04-10 19:06:40 +0400201 bit_width, function,
202 ACPI_FORMAT_NATIVE_UINT(address)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203
Len Brown4be44fc2005-08-05 00:44:28 -0400204 /*
205 * Perform the memory read or write
206 *
207 * Note: For machines that do not support non-aligned transfers, the target
Bob Moore73a30902012-10-31 02:26:55 +0000208 * address was checked for alignment above. We do not attempt to break the
Len Brown4be44fc2005-08-05 00:44:28 -0400209 * transfer up into smaller (byte-size) chunks because the AML specifically
210 * asked for a transfer width that the hardware may require.
211 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212 switch (function) {
213 case ACPI_READ:
214
215 *value = 0;
216 switch (bit_width) {
217 case 8:
Bob Moore5df7e6c2010-01-21 10:06:32 +0800218 *value = (u64) ACPI_GET8(logical_addr_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219 break;
220
221 case 16:
Bob Moore5df7e6c2010-01-21 10:06:32 +0800222 *value = (u64) ACPI_GET16(logical_addr_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 break;
224
225 case 32:
Bob Moore5df7e6c2010-01-21 10:06:32 +0800226 *value = (u64) ACPI_GET32(logical_addr_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700227 break;
228
Linus Torvalds1da177e2005-04-16 15:20:36 -0700229 case 64:
Bob Moore5df7e6c2010-01-21 10:06:32 +0800230 *value = (u64) ACPI_GET64(logical_addr_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 break;
Bob Moore59fa8502007-02-02 19:48:23 +0300232
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 default:
234 /* bit_width was already validated */
235 break;
236 }
237 break;
238
239 case ACPI_WRITE:
240
241 switch (bit_width) {
242 case 8:
Bob Moorec51a4de2005-11-17 13:07:00 -0500243 ACPI_SET8(logical_addr_ptr) = (u8) * value;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 break;
245
246 case 16:
Bob Moorec51a4de2005-11-17 13:07:00 -0500247 ACPI_SET16(logical_addr_ptr) = (u16) * value;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 break;
249
250 case 32:
Bob Moorec51a4de2005-11-17 13:07:00 -0500251 ACPI_SET32(logical_addr_ptr) = (u32) * value;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252 break;
253
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 case 64:
Bob Moorec51a4de2005-11-17 13:07:00 -0500255 ACPI_SET64(logical_addr_ptr) = (u64) * value;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700257
258 default:
259 /* bit_width was already validated */
260 break;
261 }
262 break;
263
264 default:
265 status = AE_BAD_PARAMETER;
266 break;
267 }
268
Len Brown4be44fc2005-08-05 00:44:28 -0400269 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270}
271
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272/*******************************************************************************
273 *
274 * FUNCTION: acpi_ex_system_io_space_handler
275 *
Bob Mooreba494be2012-07-12 09:40:10 +0800276 * PARAMETERS: function - Read or Write operation
277 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700278 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800279 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700280 * handler_context - Pointer to Handler's context
281 * region_context - Pointer to context specific to the
282 * accessed region
283 *
284 * RETURN: Status
285 *
286 * DESCRIPTION: Handler for the System IO address space (Op Region)
287 *
288 ******************************************************************************/
289
290acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400291acpi_ex_system_io_space_handler(u32 function,
292 acpi_physical_address address,
293 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800294 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400295 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296{
Len Brown4be44fc2005-08-05 00:44:28 -0400297 acpi_status status = AE_OK;
298 u32 value32;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700299
Bob Mooreb229cf92006-04-21 17:15:00 -0400300 ACPI_FUNCTION_TRACE(ex_system_io_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700301
Len Brown4be44fc2005-08-05 00:44:28 -0400302 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Bob Mooreb27d6592010-05-26 11:47:13 +0800303 "System-IO (width %u) R/W %u Address=%8.8X%8.8X\n",
Bob Mooreb7f9f042008-04-10 19:06:40 +0400304 bit_width, function,
305 ACPI_FORMAT_NATIVE_UINT(address)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700306
307 /* Decode the function parameter */
308
309 switch (function) {
310 case ACPI_READ:
311
Bob Moore7f071902009-03-19 09:37:47 +0800312 status = acpi_hw_read_port((acpi_io_address) address,
Len Brown4be44fc2005-08-05 00:44:28 -0400313 &value32, bit_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314 *value = value32;
315 break;
316
317 case ACPI_WRITE:
318
Bob Moore7f071902009-03-19 09:37:47 +0800319 status = acpi_hw_write_port((acpi_io_address) address,
Len Brown4be44fc2005-08-05 00:44:28 -0400320 (u32) * value, bit_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 break;
322
323 default:
324 status = AE_BAD_PARAMETER;
325 break;
326 }
327
Len Brown4be44fc2005-08-05 00:44:28 -0400328 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700329}
330
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331/*******************************************************************************
332 *
333 * FUNCTION: acpi_ex_pci_config_space_handler
334 *
Bob Mooreba494be2012-07-12 09:40:10 +0800335 * PARAMETERS: function - Read or Write operation
336 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700337 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800338 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 * handler_context - Pointer to Handler's context
340 * region_context - Pointer to context specific to the
341 * accessed region
342 *
343 * RETURN: Status
344 *
345 * DESCRIPTION: Handler for the PCI Config address space (Op Region)
346 *
347 ******************************************************************************/
348
349acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400350acpi_ex_pci_config_space_handler(u32 function,
351 acpi_physical_address address,
352 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800353 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400354 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700355{
Len Brown4be44fc2005-08-05 00:44:28 -0400356 acpi_status status = AE_OK;
357 struct acpi_pci_id *pci_id;
358 u16 pci_register;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359
Bob Mooreb229cf92006-04-21 17:15:00 -0400360 ACPI_FUNCTION_TRACE(ex_pci_config_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700361
362 /*
363 * The arguments to acpi_os(Read|Write)pci_configuration are:
364 *
365 * pci_segment is the PCI bus segment range 0-31
366 * pci_bus is the PCI bus number range 0-255
367 * pci_device is the PCI device number range 0-31
368 * pci_function is the PCI device function number
369 * pci_register is the Config space register range 0-255 bytes
370 *
Bob Mooreba494be2012-07-12 09:40:10 +0800371 * value - input value for write, output address for read
Linus Torvalds1da177e2005-04-16 15:20:36 -0700372 *
373 */
Len Brown4be44fc2005-08-05 00:44:28 -0400374 pci_id = (struct acpi_pci_id *)region_context;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700375 pci_register = (u16) (u32) address;
376
Len Brown4be44fc2005-08-05 00:44:28 -0400377 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Bob Mooreb27d6592010-05-26 11:47:13 +0800378 "Pci-Config %u (%u) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400379 function, bit_width, pci_id->segment, pci_id->bus,
380 pci_id->device, pci_id->function, pci_register));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381
382 switch (function) {
383 case ACPI_READ:
384
Len Brown4be44fc2005-08-05 00:44:28 -0400385 status = acpi_os_read_pci_configuration(pci_id, pci_register,
Bob Moorec5f02312010-08-06 08:57:53 +0800386 value, bit_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 break;
388
389 case ACPI_WRITE:
390
Len Brown4be44fc2005-08-05 00:44:28 -0400391 status = acpi_os_write_pci_configuration(pci_id, pci_register,
392 *value, bit_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393 break;
394
395 default:
396
397 status = AE_BAD_PARAMETER;
398 break;
399 }
400
Len Brown4be44fc2005-08-05 00:44:28 -0400401 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402}
403
Linus Torvalds1da177e2005-04-16 15:20:36 -0700404/*******************************************************************************
405 *
406 * FUNCTION: acpi_ex_cmos_space_handler
407 *
Bob Mooreba494be2012-07-12 09:40:10 +0800408 * PARAMETERS: function - Read or Write operation
409 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700410 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800411 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700412 * handler_context - Pointer to Handler's context
413 * region_context - Pointer to context specific to the
414 * accessed region
415 *
416 * RETURN: Status
417 *
418 * DESCRIPTION: Handler for the CMOS address space (Op Region)
419 *
420 ******************************************************************************/
421
422acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400423acpi_ex_cmos_space_handler(u32 function,
424 acpi_physical_address address,
425 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800426 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400427 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700428{
Len Brown4be44fc2005-08-05 00:44:28 -0400429 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430
Bob Mooreb229cf92006-04-21 17:15:00 -0400431 ACPI_FUNCTION_TRACE(ex_cmos_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432
Len Brown4be44fc2005-08-05 00:44:28 -0400433 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434}
435
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436/*******************************************************************************
437 *
438 * FUNCTION: acpi_ex_pci_bar_space_handler
439 *
Bob Mooreba494be2012-07-12 09:40:10 +0800440 * PARAMETERS: function - Read or Write operation
441 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700442 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800443 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700444 * handler_context - Pointer to Handler's context
445 * region_context - Pointer to context specific to the
446 * accessed region
447 *
448 * RETURN: Status
449 *
450 * DESCRIPTION: Handler for the PCI bar_target address space (Op Region)
451 *
452 ******************************************************************************/
453
454acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400455acpi_ex_pci_bar_space_handler(u32 function,
456 acpi_physical_address address,
457 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800458 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400459 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460{
Len Brown4be44fc2005-08-05 00:44:28 -0400461 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462
Bob Mooreb229cf92006-04-21 17:15:00 -0400463 ACPI_FUNCTION_TRACE(ex_pci_bar_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464
Len Brown4be44fc2005-08-05 00:44:28 -0400465 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466}
467
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468/*******************************************************************************
469 *
470 * FUNCTION: acpi_ex_data_table_space_handler
471 *
Bob Mooreba494be2012-07-12 09:40:10 +0800472 * PARAMETERS: function - Read or Write operation
473 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700474 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800475 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700476 * handler_context - Pointer to Handler's context
477 * region_context - Pointer to context specific to the
478 * accessed region
479 *
480 * RETURN: Status
481 *
482 * DESCRIPTION: Handler for the Data Table address space (Op Region)
483 *
484 ******************************************************************************/
485
486acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400487acpi_ex_data_table_space_handler(u32 function,
488 acpi_physical_address address,
489 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800490 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400491 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700492{
Bob Mooreb229cf92006-04-21 17:15:00 -0400493 ACPI_FUNCTION_TRACE(ex_data_table_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494
Bob Moorec1637e92010-04-01 11:09:00 +0800495 /*
496 * Perform the memory read or write. The bit_width was already
497 * validated.
498 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700499 switch (function) {
500 case ACPI_READ:
501
Bob Moore41195322006-05-26 16:36:00 -0400502 ACPI_MEMCPY(ACPI_CAST_PTR(char, value),
503 ACPI_PHYSADDR_TO_PTR(address),
504 ACPI_DIV_8(bit_width));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700505 break;
506
507 case ACPI_WRITE:
Bob Moorec1637e92010-04-01 11:09:00 +0800508
509 ACPI_MEMCPY(ACPI_PHYSADDR_TO_PTR(address),
510 ACPI_CAST_PTR(char, value), ACPI_DIV_8(bit_width));
511 break;
512
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513 default:
514
Bob Moorec1637e92010-04-01 11:09:00 +0800515 return_ACPI_STATUS(AE_BAD_PARAMETER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700516 }
517
Bob Moore41195322006-05-26 16:36:00 -0400518 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519}