blob: 2b8cae62529ae67b9fa7515a01731c59d32fe5f4 [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/*
David E. Box82a80942015-02-05 15:20:45 +08008 * Copyright (C) 2000 - 2015, 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:
Chao Guan1d1ea1b72013-06-08 00:58:14 +000091
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 length = 1;
93 break;
94
95 case 16:
Chao Guan1d1ea1b72013-06-08 00:58:14 +000096
Linus Torvalds1da177e2005-04-16 15:20:36 -070097 length = 2;
98 break;
99
100 case 32:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000101
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 length = 4;
103 break;
104
105 case 64:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000106
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107 length = 8;
108 break;
109
110 default:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000111
Bob Mooref6a22b02010-03-05 17:56:40 +0800112 ACPI_ERROR((AE_INFO, "Invalid SystemMemory width %u",
Bob Mooreb8e4d892006-01-27 16:43:00 -0500113 bit_width));
Len Brown4be44fc2005-08-05 00:44:28 -0400114 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115 }
116
Bob Moore08978312005-10-21 00:00:00 -0400117#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118 /*
119 * Hardware does not support non-aligned data transfers, we must verify
120 * the request.
121 */
Bob Moore5df7e6c2010-01-21 10:06:32 +0800122 (void)acpi_ut_short_divide((u64) address, length, NULL, &remainder);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 if (remainder != 0) {
Len Brown4be44fc2005-08-05 00:44:28 -0400124 return_ACPI_STATUS(AE_AML_ALIGNMENT);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 }
126#endif
127
128 /*
129 * Does the request fit into the cached memory mapping?
130 * Is 1) Address below the current mapping? OR
131 * 2) Address beyond the current mapping?
132 */
133 if ((address < mem_info->mapped_physical_address) ||
Bob Moore5df7e6c2010-01-21 10:06:32 +0800134 (((u64) address + length) > ((u64)
135 mem_info->mapped_physical_address +
136 mem_info->mapped_length))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 /*
138 * The request cannot be resolved by the current memory mapping;
139 * Delete the existing mapping and create a new one.
140 */
141 if (mem_info->mapped_length) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400142
Linus Torvalds1da177e2005-04-16 15:20:36 -0700143 /* Valid mapping, delete it */
144
Len Brown4be44fc2005-08-05 00:44:28 -0400145 acpi_os_unmap_memory(mem_info->mapped_logical_address,
146 mem_info->mapped_length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700147 }
148
149 /*
Lv Zheng75c80442012-12-19 05:36:49 +0000150 * October 2009: Attempt to map from the requested address to the
151 * end of the region. However, we will never map more than one
152 * page, nor will we cross a page boundary.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 */
Bob Moored410ee52009-10-22 09:11:11 +0800154 map_length = (acpi_size)
Len Brown4be44fc2005-08-05 00:44:28 -0400155 ((mem_info->address + mem_info->length) - address);
Robert Moore44f6c012005-04-18 22:49:35 -0400156
Bob Moored410ee52009-10-22 09:11:11 +0800157 /*
158 * If mapping the entire remaining portion of the region will cross
159 * a page boundary, just map up to the page boundary, do not cross.
160 * On some systems, crossing a page boundary while mapping regions
161 * can cause warnings if the pages have different attributes
Lv Zheng75c80442012-12-19 05:36:49 +0000162 * due to resource management.
163 *
164 * This has the added benefit of constraining a single mapping to
165 * one page, which is similar to the original code that used a 4k
166 * maximum window.
Bob Moored410ee52009-10-22 09:11:11 +0800167 */
168 page_boundary_map_length =
169 ACPI_ROUND_UP(address, ACPI_DEFAULT_PAGE_SIZE) - address;
Lv Zheng739dcbb2012-12-20 01:07:26 +0000170 if (page_boundary_map_length == 0) {
Bob Moored410ee52009-10-22 09:11:11 +0800171 page_boundary_map_length = ACPI_DEFAULT_PAGE_SIZE;
172 }
173
174 if (map_length > page_boundary_map_length) {
175 map_length = page_boundary_map_length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700176 }
177
178 /* Create a new mapping starting at the address given */
179
Lv Zhengea284922015-04-13 11:48:31 +0800180 mem_info->mapped_logical_address =
181 acpi_os_map_memory(address, map_length);
Bob Mooref3d2e782007-02-02 19:48:18 +0300182 if (!mem_info->mapped_logical_address) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500183 ACPI_ERROR((AE_INFO,
Bob Mooref6a22b02010-03-05 17:56:40 +0800184 "Could not map memory at 0x%8.8X%8.8X, size %u",
Bob Mooreb7f9f042008-04-10 19:06:40 +0400185 ACPI_FORMAT_NATIVE_UINT(address),
Lv Zheng18ae9022015-04-13 11:48:12 +0800186 (u32)map_length));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187 mem_info->mapped_length = 0;
Bob Mooref3d2e782007-02-02 19:48:18 +0300188 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 }
190
191 /* Save the physical address and mapping size */
192
193 mem_info->mapped_physical_address = address;
Bob Moored410ee52009-10-22 09:11:11 +0800194 mem_info->mapped_length = map_length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 }
196
197 /*
198 * Generate a logical pointer corresponding to the address we want to
199 * access
200 */
201 logical_addr_ptr = mem_info->mapped_logical_address +
Bob Moore5df7e6c2010-01-21 10:06:32 +0800202 ((u64) address - (u64) mem_info->mapped_physical_address);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203
Len Brown4be44fc2005-08-05 00:44:28 -0400204 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Bob Mooreb27d6592010-05-26 11:47:13 +0800205 "System-Memory (width %u) R/W %u Address=%8.8X%8.8X\n",
Bob Mooreb7f9f042008-04-10 19:06:40 +0400206 bit_width, function,
207 ACPI_FORMAT_NATIVE_UINT(address)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700208
Len Brown4be44fc2005-08-05 00:44:28 -0400209 /*
210 * Perform the memory read or write
211 *
212 * Note: For machines that do not support non-aligned transfers, the target
Bob Moore73a30902012-10-31 02:26:55 +0000213 * address was checked for alignment above. We do not attempt to break the
Len Brown4be44fc2005-08-05 00:44:28 -0400214 * transfer up into smaller (byte-size) chunks because the AML specifically
215 * asked for a transfer width that the hardware may require.
216 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700217 switch (function) {
218 case ACPI_READ:
219
220 *value = 0;
221 switch (bit_width) {
222 case 8:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000223
224 *value = (u64)ACPI_GET8(logical_addr_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700225 break;
226
227 case 16:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000228
229 *value = (u64)ACPI_GET16(logical_addr_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 break;
231
232 case 32:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000233
234 *value = (u64)ACPI_GET32(logical_addr_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 break;
236
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 case 64:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000238
239 *value = (u64)ACPI_GET64(logical_addr_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 break;
Bob Moore59fa8502007-02-02 19:48:23 +0300241
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 default:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000243
Linus Torvalds1da177e2005-04-16 15:20:36 -0700244 /* bit_width was already validated */
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000245
Linus Torvalds1da177e2005-04-16 15:20:36 -0700246 break;
247 }
248 break;
249
250 case ACPI_WRITE:
251
252 switch (bit_width) {
253 case 8:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000254
Lv Zheng57bf6ae2012-12-19 05:38:24 +0000255 ACPI_SET8(logical_addr_ptr, *value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700256 break;
257
258 case 16:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000259
Lv Zheng57bf6ae2012-12-19 05:38:24 +0000260 ACPI_SET16(logical_addr_ptr, *value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 break;
262
263 case 32:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000264
Lv Zheng57bf6ae2012-12-19 05:38:24 +0000265 ACPI_SET32(logical_addr_ptr, *value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700266 break;
267
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 case 64:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000269
Lv Zheng57bf6ae2012-12-19 05:38:24 +0000270 ACPI_SET64(logical_addr_ptr, *value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700271 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700272
273 default:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000274
Linus Torvalds1da177e2005-04-16 15:20:36 -0700275 /* bit_width was already validated */
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000276
Linus Torvalds1da177e2005-04-16 15:20:36 -0700277 break;
278 }
279 break;
280
281 default:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000282
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283 status = AE_BAD_PARAMETER;
284 break;
285 }
286
Len Brown4be44fc2005-08-05 00:44:28 -0400287 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288}
289
Linus Torvalds1da177e2005-04-16 15:20:36 -0700290/*******************************************************************************
291 *
292 * FUNCTION: acpi_ex_system_io_space_handler
293 *
Bob Mooreba494be2012-07-12 09:40:10 +0800294 * PARAMETERS: function - Read or Write operation
295 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800297 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700298 * handler_context - Pointer to Handler's context
299 * region_context - Pointer to context specific to the
300 * accessed region
301 *
302 * RETURN: Status
303 *
304 * DESCRIPTION: Handler for the System IO address space (Op Region)
305 *
306 ******************************************************************************/
307
308acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400309acpi_ex_system_io_space_handler(u32 function,
310 acpi_physical_address address,
311 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800312 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400313 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700314{
Len Brown4be44fc2005-08-05 00:44:28 -0400315 acpi_status status = AE_OK;
316 u32 value32;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700317
Bob Mooreb229cf92006-04-21 17:15:00 -0400318 ACPI_FUNCTION_TRACE(ex_system_io_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700319
Len Brown4be44fc2005-08-05 00:44:28 -0400320 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Bob Mooreb27d6592010-05-26 11:47:13 +0800321 "System-IO (width %u) R/W %u Address=%8.8X%8.8X\n",
Bob Mooreb7f9f042008-04-10 19:06:40 +0400322 bit_width, function,
323 ACPI_FORMAT_NATIVE_UINT(address)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324
325 /* Decode the function parameter */
326
327 switch (function) {
328 case ACPI_READ:
329
Bob Moore7f071902009-03-19 09:37:47 +0800330 status = acpi_hw_read_port((acpi_io_address) address,
Len Brown4be44fc2005-08-05 00:44:28 -0400331 &value32, bit_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700332 *value = value32;
333 break;
334
335 case ACPI_WRITE:
336
Bob Moore7f071902009-03-19 09:37:47 +0800337 status = acpi_hw_write_port((acpi_io_address) address,
Len Brown4be44fc2005-08-05 00:44:28 -0400338 (u32) * value, bit_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339 break;
340
341 default:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000342
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343 status = AE_BAD_PARAMETER;
344 break;
345 }
346
Len Brown4be44fc2005-08-05 00:44:28 -0400347 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700348}
349
Linus Torvalds1da177e2005-04-16 15:20:36 -0700350/*******************************************************************************
351 *
352 * FUNCTION: acpi_ex_pci_config_space_handler
353 *
Bob Mooreba494be2012-07-12 09:40:10 +0800354 * PARAMETERS: function - Read or Write operation
355 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800357 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700358 * handler_context - Pointer to Handler's context
359 * region_context - Pointer to context specific to the
360 * accessed region
361 *
362 * RETURN: Status
363 *
364 * DESCRIPTION: Handler for the PCI Config address space (Op Region)
365 *
366 ******************************************************************************/
367
368acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400369acpi_ex_pci_config_space_handler(u32 function,
370 acpi_physical_address address,
371 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800372 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400373 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374{
Len Brown4be44fc2005-08-05 00:44:28 -0400375 acpi_status status = AE_OK;
376 struct acpi_pci_id *pci_id;
377 u16 pci_register;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700378
Bob Mooreb229cf92006-04-21 17:15:00 -0400379 ACPI_FUNCTION_TRACE(ex_pci_config_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700380
381 /*
382 * The arguments to acpi_os(Read|Write)pci_configuration are:
383 *
384 * pci_segment is the PCI bus segment range 0-31
385 * pci_bus is the PCI bus number range 0-255
386 * pci_device is the PCI device number range 0-31
387 * pci_function is the PCI device function number
388 * pci_register is the Config space register range 0-255 bytes
389 *
Bob Mooreba494be2012-07-12 09:40:10 +0800390 * value - input value for write, output address for read
Linus Torvalds1da177e2005-04-16 15:20:36 -0700391 *
392 */
Len Brown4be44fc2005-08-05 00:44:28 -0400393 pci_id = (struct acpi_pci_id *)region_context;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394 pci_register = (u16) (u32) address;
395
Len Brown4be44fc2005-08-05 00:44:28 -0400396 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Bob Mooreb27d6592010-05-26 11:47:13 +0800397 "Pci-Config %u (%u) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400398 function, bit_width, pci_id->segment, pci_id->bus,
399 pci_id->device, pci_id->function, pci_register));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700400
401 switch (function) {
402 case ACPI_READ:
403
Lv Zhengbb42cc22013-10-31 09:29:49 +0800404 *value = 0;
Len Brown4be44fc2005-08-05 00:44:28 -0400405 status = acpi_os_read_pci_configuration(pci_id, pci_register,
Bob Moorec5f02312010-08-06 08:57:53 +0800406 value, bit_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700407 break;
408
409 case ACPI_WRITE:
410
Len Brown4be44fc2005-08-05 00:44:28 -0400411 status = acpi_os_write_pci_configuration(pci_id, pci_register,
412 *value, bit_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700413 break;
414
415 default:
416
417 status = AE_BAD_PARAMETER;
418 break;
419 }
420
Len Brown4be44fc2005-08-05 00:44:28 -0400421 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700422}
423
Linus Torvalds1da177e2005-04-16 15:20:36 -0700424/*******************************************************************************
425 *
426 * FUNCTION: acpi_ex_cmos_space_handler
427 *
Bob Mooreba494be2012-07-12 09:40:10 +0800428 * PARAMETERS: function - Read or Write operation
429 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700430 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800431 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 * handler_context - Pointer to Handler's context
433 * region_context - Pointer to context specific to the
434 * accessed region
435 *
436 * RETURN: Status
437 *
438 * DESCRIPTION: Handler for the CMOS address space (Op Region)
439 *
440 ******************************************************************************/
441
442acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400443acpi_ex_cmos_space_handler(u32 function,
444 acpi_physical_address address,
445 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800446 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400447 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700448{
Len Brown4be44fc2005-08-05 00:44:28 -0400449 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450
Bob Mooreb229cf92006-04-21 17:15:00 -0400451 ACPI_FUNCTION_TRACE(ex_cmos_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452
Len Brown4be44fc2005-08-05 00:44:28 -0400453 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454}
455
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456/*******************************************************************************
457 *
458 * FUNCTION: acpi_ex_pci_bar_space_handler
459 *
Bob Mooreba494be2012-07-12 09:40:10 +0800460 * PARAMETERS: function - Read or Write operation
461 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800463 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700464 * handler_context - Pointer to Handler's context
465 * region_context - Pointer to context specific to the
466 * accessed region
467 *
468 * RETURN: Status
469 *
470 * DESCRIPTION: Handler for the PCI bar_target address space (Op Region)
471 *
472 ******************************************************************************/
473
474acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400475acpi_ex_pci_bar_space_handler(u32 function,
476 acpi_physical_address address,
477 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800478 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400479 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480{
Len Brown4be44fc2005-08-05 00:44:28 -0400481 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482
Bob Mooreb229cf92006-04-21 17:15:00 -0400483 ACPI_FUNCTION_TRACE(ex_pci_bar_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484
Len Brown4be44fc2005-08-05 00:44:28 -0400485 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486}
487
Linus Torvalds1da177e2005-04-16 15:20:36 -0700488/*******************************************************************************
489 *
490 * FUNCTION: acpi_ex_data_table_space_handler
491 *
Bob Mooreba494be2012-07-12 09:40:10 +0800492 * PARAMETERS: function - Read or Write operation
493 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700494 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800495 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496 * handler_context - Pointer to Handler's context
497 * region_context - Pointer to context specific to the
498 * accessed region
499 *
500 * RETURN: Status
501 *
502 * DESCRIPTION: Handler for the Data Table address space (Op Region)
503 *
504 ******************************************************************************/
505
506acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400507acpi_ex_data_table_space_handler(u32 function,
508 acpi_physical_address address,
509 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800510 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400511 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700512{
Bob Mooreb229cf92006-04-21 17:15:00 -0400513 ACPI_FUNCTION_TRACE(ex_data_table_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700514
Bob Moorec1637e92010-04-01 11:09:00 +0800515 /*
516 * Perform the memory read or write. The bit_width was already
517 * validated.
518 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700519 switch (function) {
520 case ACPI_READ:
521
Bob Moore41195322006-05-26 16:36:00 -0400522 ACPI_MEMCPY(ACPI_CAST_PTR(char, value),
523 ACPI_PHYSADDR_TO_PTR(address),
524 ACPI_DIV_8(bit_width));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700525 break;
526
527 case ACPI_WRITE:
Bob Moorec1637e92010-04-01 11:09:00 +0800528
529 ACPI_MEMCPY(ACPI_PHYSADDR_TO_PTR(address),
530 ACPI_CAST_PTR(char, value), ACPI_DIV_8(bit_width));
531 break;
532
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533 default:
534
Bob Moorec1637e92010-04-01 11:09:00 +0800535 return_ACPI_STATUS(AE_BAD_PARAMETER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700536 }
537
Bob Moore41195322006-05-26 16:36:00 -0400538 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700539}