blob: c08521194b297f2d210bf654e3abf5886d83f9fa [file] [log] [blame]
Erik Schmauss95857632018-03-14 16:13:07 -07001// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/******************************************************************************
3 *
4 * Module Name: exregion - ACPI default op_region (address space) handlers
5 *
Bob Moore840c02c2019-01-14 09:55:25 -08006 * Copyright (C) 2000 - 2019, Intel Corp.
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 *
Erik Schmauss95857632018-03-14 16:13:07 -07008 *****************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
Linus Torvalds1da177e2005-04-16 15:20:36 -070010#include <acpi/acpi.h>
Len Browne2f7a772009-01-09 00:30:03 -050011#include "accommon.h"
12#include "acinterp.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070013
Linus Torvalds1da177e2005-04-16 15:20:36 -070014#define _COMPONENT ACPI_EXECUTER
Len Brown4be44fc2005-08-05 00:44:28 -040015ACPI_MODULE_NAME("exregion")
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
17/*******************************************************************************
18 *
19 * FUNCTION: acpi_ex_system_memory_space_handler
20 *
Bob Mooreba494be2012-07-12 09:40:10 +080021 * PARAMETERS: function - Read or Write operation
22 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -070023 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +080024 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -070025 * handler_context - Pointer to Handler's context
26 * region_context - Pointer to context specific to the
27 * accessed region
28 *
29 * RETURN: Status
30 *
31 * DESCRIPTION: Handler for the System Memory address space (Op Region)
32 *
33 ******************************************************************************/
Linus Torvalds1da177e2005-04-16 15:20:36 -070034acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -040035acpi_ex_system_memory_space_handler(u32 function,
36 acpi_physical_address address,
37 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +080038 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -040039 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -070040{
Len Brown4be44fc2005-08-05 00:44:28 -040041 acpi_status status = AE_OK;
42 void *logical_addr_ptr = NULL;
43 struct acpi_mem_space_context *mem_info = region_context;
44 u32 length;
Bob Moored410ee52009-10-22 09:11:11 +080045 acpi_size map_length;
46 acpi_size page_boundary_map_length;
Bob Moore08978312005-10-21 00:00:00 -040047#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
Len Brown4be44fc2005-08-05 00:44:28 -040048 u32 remainder;
Linus Torvalds1da177e2005-04-16 15:20:36 -070049#endif
50
Bob Mooreb229cf92006-04-21 17:15:00 -040051 ACPI_FUNCTION_TRACE(ex_system_memory_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -070052
53 /* Validate and translate the bit width */
54
55 switch (bit_width) {
56 case 8:
Chao Guan1d1ea1b72013-06-08 00:58:14 +000057
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 length = 1;
59 break;
60
61 case 16:
Chao Guan1d1ea1b72013-06-08 00:58:14 +000062
Linus Torvalds1da177e2005-04-16 15:20:36 -070063 length = 2;
64 break;
65
66 case 32:
Chao Guan1d1ea1b72013-06-08 00:58:14 +000067
Linus Torvalds1da177e2005-04-16 15:20:36 -070068 length = 4;
69 break;
70
71 case 64:
Chao Guan1d1ea1b72013-06-08 00:58:14 +000072
Linus Torvalds1da177e2005-04-16 15:20:36 -070073 length = 8;
74 break;
75
76 default:
Chao Guan1d1ea1b72013-06-08 00:58:14 +000077
Bob Mooref6a22b02010-03-05 17:56:40 +080078 ACPI_ERROR((AE_INFO, "Invalid SystemMemory width %u",
Bob Mooreb8e4d892006-01-27 16:43:00 -050079 bit_width));
Len Brown4be44fc2005-08-05 00:44:28 -040080 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070081 }
82
Bob Moore08978312005-10-21 00:00:00 -040083#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
Linus Torvalds1da177e2005-04-16 15:20:36 -070084 /*
85 * Hardware does not support non-aligned data transfers, we must verify
86 * the request.
87 */
Bob Moore5df7e6c2010-01-21 10:06:32 +080088 (void)acpi_ut_short_divide((u64) address, length, NULL, &remainder);
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 if (remainder != 0) {
Len Brown4be44fc2005-08-05 00:44:28 -040090 return_ACPI_STATUS(AE_AML_ALIGNMENT);
Linus Torvalds1da177e2005-04-16 15:20:36 -070091 }
92#endif
93
94 /*
95 * Does the request fit into the cached memory mapping?
96 * Is 1) Address below the current mapping? OR
97 * 2) Address beyond the current mapping?
98 */
99 if ((address < mem_info->mapped_physical_address) ||
Bob Moore5df7e6c2010-01-21 10:06:32 +0800100 (((u64) address + length) > ((u64)
101 mem_info->mapped_physical_address +
102 mem_info->mapped_length))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 /*
104 * The request cannot be resolved by the current memory mapping;
105 * Delete the existing mapping and create a new one.
106 */
107 if (mem_info->mapped_length) {
Bob Moore52fc0b02006-10-02 00:00:00 -0400108
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109 /* Valid mapping, delete it */
110
Len Brown4be44fc2005-08-05 00:44:28 -0400111 acpi_os_unmap_memory(mem_info->mapped_logical_address,
112 mem_info->mapped_length);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113 }
114
115 /*
Lv Zheng75c80442012-12-19 05:36:49 +0000116 * October 2009: Attempt to map from the requested address to the
117 * end of the region. However, we will never map more than one
118 * page, nor will we cross a page boundary.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700119 */
Bob Moored410ee52009-10-22 09:11:11 +0800120 map_length = (acpi_size)
Len Brown4be44fc2005-08-05 00:44:28 -0400121 ((mem_info->address + mem_info->length) - address);
Robert Moore44f6c012005-04-18 22:49:35 -0400122
Bob Moored410ee52009-10-22 09:11:11 +0800123 /*
124 * If mapping the entire remaining portion of the region will cross
125 * a page boundary, just map up to the page boundary, do not cross.
126 * On some systems, crossing a page boundary while mapping regions
127 * can cause warnings if the pages have different attributes
Lv Zheng75c80442012-12-19 05:36:49 +0000128 * due to resource management.
129 *
130 * This has the added benefit of constraining a single mapping to
131 * one page, which is similar to the original code that used a 4k
132 * maximum window.
Bob Moored410ee52009-10-22 09:11:11 +0800133 */
Bob Moore938ed102015-04-13 11:49:54 +0800134 page_boundary_map_length = (acpi_size)
135 (ACPI_ROUND_UP(address, ACPI_DEFAULT_PAGE_SIZE) - address);
Lv Zheng739dcbb2012-12-20 01:07:26 +0000136 if (page_boundary_map_length == 0) {
Bob Moored410ee52009-10-22 09:11:11 +0800137 page_boundary_map_length = ACPI_DEFAULT_PAGE_SIZE;
138 }
139
140 if (map_length > page_boundary_map_length) {
141 map_length = page_boundary_map_length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700142 }
143
144 /* Create a new mapping starting at the address given */
145
Lv Zhengea284922015-04-13 11:48:31 +0800146 mem_info->mapped_logical_address =
147 acpi_os_map_memory(address, map_length);
Bob Mooref3d2e782007-02-02 19:48:18 +0300148 if (!mem_info->mapped_logical_address) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500149 ACPI_ERROR((AE_INFO,
Bob Mooref6a22b02010-03-05 17:56:40 +0800150 "Could not map memory at 0x%8.8X%8.8X, size %u",
Lv Zheng1d0a0b22015-04-13 11:48:52 +0800151 ACPI_FORMAT_UINT64(address),
Lv Zheng18ae9022015-04-13 11:48:12 +0800152 (u32)map_length));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700153 mem_info->mapped_length = 0;
Bob Mooref3d2e782007-02-02 19:48:18 +0300154 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700155 }
156
157 /* Save the physical address and mapping size */
158
159 mem_info->mapped_physical_address = address;
Bob Moored410ee52009-10-22 09:11:11 +0800160 mem_info->mapped_length = map_length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700161 }
162
163 /*
164 * Generate a logical pointer corresponding to the address we want to
165 * access
166 */
167 logical_addr_ptr = mem_info->mapped_logical_address +
Bob Moore5df7e6c2010-01-21 10:06:32 +0800168 ((u64) address - (u64) mem_info->mapped_physical_address);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169
Len Brown4be44fc2005-08-05 00:44:28 -0400170 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Bob Mooreb27d6592010-05-26 11:47:13 +0800171 "System-Memory (width %u) R/W %u Address=%8.8X%8.8X\n",
Lv Zheng1d0a0b22015-04-13 11:48:52 +0800172 bit_width, function, ACPI_FORMAT_UINT64(address)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700173
Len Brown4be44fc2005-08-05 00:44:28 -0400174 /*
175 * Perform the memory read or write
176 *
177 * Note: For machines that do not support non-aligned transfers, the target
Bob Moore73a30902012-10-31 02:26:55 +0000178 * address was checked for alignment above. We do not attempt to break the
Len Brown4be44fc2005-08-05 00:44:28 -0400179 * transfer up into smaller (byte-size) chunks because the AML specifically
180 * asked for a transfer width that the hardware may require.
181 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182 switch (function) {
183 case ACPI_READ:
184
185 *value = 0;
186 switch (bit_width) {
187 case 8:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000188
189 *value = (u64)ACPI_GET8(logical_addr_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 break;
191
192 case 16:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000193
194 *value = (u64)ACPI_GET16(logical_addr_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700195 break;
196
197 case 32:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000198
199 *value = (u64)ACPI_GET32(logical_addr_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700200 break;
201
Linus Torvalds1da177e2005-04-16 15:20:36 -0700202 case 64:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000203
204 *value = (u64)ACPI_GET64(logical_addr_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205 break;
Bob Moore59fa8502007-02-02 19:48:23 +0300206
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207 default:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000208
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209 /* bit_width was already validated */
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000210
Linus Torvalds1da177e2005-04-16 15:20:36 -0700211 break;
212 }
213 break;
214
215 case ACPI_WRITE:
216
217 switch (bit_width) {
218 case 8:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000219
Lv Zheng57bf6ae2012-12-19 05:38:24 +0000220 ACPI_SET8(logical_addr_ptr, *value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221 break;
222
223 case 16:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000224
Lv Zheng57bf6ae2012-12-19 05:38:24 +0000225 ACPI_SET16(logical_addr_ptr, *value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226 break;
227
228 case 32:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000229
Lv Zheng57bf6ae2012-12-19 05:38:24 +0000230 ACPI_SET32(logical_addr_ptr, *value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700231 break;
232
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 case 64:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000234
Lv Zheng57bf6ae2012-12-19 05:38:24 +0000235 ACPI_SET64(logical_addr_ptr, *value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700236 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237
238 default:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000239
Linus Torvalds1da177e2005-04-16 15:20:36 -0700240 /* bit_width was already validated */
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000241
Linus Torvalds1da177e2005-04-16 15:20:36 -0700242 break;
243 }
244 break;
245
246 default:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000247
Linus Torvalds1da177e2005-04-16 15:20:36 -0700248 status = AE_BAD_PARAMETER;
249 break;
250 }
251
Len Brown4be44fc2005-08-05 00:44:28 -0400252 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700253}
254
Linus Torvalds1da177e2005-04-16 15:20:36 -0700255/*******************************************************************************
256 *
257 * FUNCTION: acpi_ex_system_io_space_handler
258 *
Bob Mooreba494be2012-07-12 09:40:10 +0800259 * PARAMETERS: function - Read or Write operation
260 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800262 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700263 * handler_context - Pointer to Handler's context
264 * region_context - Pointer to context specific to the
265 * accessed region
266 *
267 * RETURN: Status
268 *
269 * DESCRIPTION: Handler for the System IO address space (Op Region)
270 *
271 ******************************************************************************/
272
273acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400274acpi_ex_system_io_space_handler(u32 function,
275 acpi_physical_address address,
276 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800277 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400278 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700279{
Len Brown4be44fc2005-08-05 00:44:28 -0400280 acpi_status status = AE_OK;
281 u32 value32;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700282
Bob Mooreb229cf92006-04-21 17:15:00 -0400283 ACPI_FUNCTION_TRACE(ex_system_io_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700284
Len Brown4be44fc2005-08-05 00:44:28 -0400285 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Bob Mooreb27d6592010-05-26 11:47:13 +0800286 "System-IO (width %u) R/W %u Address=%8.8X%8.8X\n",
Lv Zheng1d0a0b22015-04-13 11:48:52 +0800287 bit_width, function, ACPI_FORMAT_UINT64(address)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700288
289 /* Decode the function parameter */
290
291 switch (function) {
292 case ACPI_READ:
293
Lv Zhengf5c1e1c2016-05-05 12:57:53 +0800294 status = acpi_hw_read_port((acpi_io_address)address,
Len Brown4be44fc2005-08-05 00:44:28 -0400295 &value32, bit_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700296 *value = value32;
297 break;
298
299 case ACPI_WRITE:
300
Lv Zhengf5c1e1c2016-05-05 12:57:53 +0800301 status = acpi_hw_write_port((acpi_io_address)address,
302 (u32)*value, bit_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700303 break;
304
305 default:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000306
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307 status = AE_BAD_PARAMETER;
308 break;
309 }
310
Len Brown4be44fc2005-08-05 00:44:28 -0400311 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312}
313
Sinan Kayabd23fac2018-12-19 22:46:55 +0000314#ifdef ACPI_PCI_CONFIGURED
Linus Torvalds1da177e2005-04-16 15:20:36 -0700315/*******************************************************************************
316 *
317 * FUNCTION: acpi_ex_pci_config_space_handler
318 *
Bob Mooreba494be2012-07-12 09:40:10 +0800319 * PARAMETERS: function - Read or Write operation
320 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700321 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800322 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700323 * handler_context - Pointer to Handler's context
324 * region_context - Pointer to context specific to the
325 * accessed region
326 *
327 * RETURN: Status
328 *
329 * DESCRIPTION: Handler for the PCI Config address space (Op Region)
330 *
331 ******************************************************************************/
332
333acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400334acpi_ex_pci_config_space_handler(u32 function,
335 acpi_physical_address address,
336 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800337 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400338 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700339{
Len Brown4be44fc2005-08-05 00:44:28 -0400340 acpi_status status = AE_OK;
341 struct acpi_pci_id *pci_id;
342 u16 pci_register;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343
Bob Mooreb229cf92006-04-21 17:15:00 -0400344 ACPI_FUNCTION_TRACE(ex_pci_config_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700345
346 /*
347 * The arguments to acpi_os(Read|Write)pci_configuration are:
348 *
349 * pci_segment is the PCI bus segment range 0-31
350 * pci_bus is the PCI bus number range 0-255
351 * pci_device is the PCI device number range 0-31
352 * pci_function is the PCI device function number
353 * pci_register is the Config space register range 0-255 bytes
354 *
Bob Mooreba494be2012-07-12 09:40:10 +0800355 * value - input value for write, output address for read
Linus Torvalds1da177e2005-04-16 15:20:36 -0700356 *
357 */
Len Brown4be44fc2005-08-05 00:44:28 -0400358 pci_id = (struct acpi_pci_id *)region_context;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700359 pci_register = (u16) (u32) address;
360
Len Brown4be44fc2005-08-05 00:44:28 -0400361 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Bob Moore1fad8732015-12-29 13:54:36 +0800362 "Pci-Config %u (%u) Seg(%04x) Bus(%04x) "
363 "Dev(%04x) Func(%04x) Reg(%04x)\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400364 function, bit_width, pci_id->segment, pci_id->bus,
365 pci_id->device, pci_id->function, pci_register));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366
367 switch (function) {
368 case ACPI_READ:
369
Lv Zhengbb42cc22013-10-31 09:29:49 +0800370 *value = 0;
Bob Moore1fad8732015-12-29 13:54:36 +0800371 status =
372 acpi_os_read_pci_configuration(pci_id, pci_register, value,
373 bit_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700374 break;
375
376 case ACPI_WRITE:
377
Bob Moore1fad8732015-12-29 13:54:36 +0800378 status =
379 acpi_os_write_pci_configuration(pci_id, pci_register,
380 *value, bit_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700381 break;
382
383 default:
384
385 status = AE_BAD_PARAMETER;
386 break;
387 }
388
Len Brown4be44fc2005-08-05 00:44:28 -0400389 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700390}
Sinan Kayabd23fac2018-12-19 22:46:55 +0000391#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700392
Linus Torvalds1da177e2005-04-16 15:20:36 -0700393/*******************************************************************************
394 *
395 * FUNCTION: acpi_ex_cmos_space_handler
396 *
Bob Mooreba494be2012-07-12 09:40:10 +0800397 * PARAMETERS: function - Read or Write operation
398 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700399 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800400 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700401 * handler_context - Pointer to Handler's context
402 * region_context - Pointer to context specific to the
403 * accessed region
404 *
405 * RETURN: Status
406 *
407 * DESCRIPTION: Handler for the CMOS address space (Op Region)
408 *
409 ******************************************************************************/
410
411acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400412acpi_ex_cmos_space_handler(u32 function,
413 acpi_physical_address address,
414 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800415 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400416 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700417{
Len Brown4be44fc2005-08-05 00:44:28 -0400418 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700419
Bob Mooreb229cf92006-04-21 17:15:00 -0400420 ACPI_FUNCTION_TRACE(ex_cmos_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421
Len Brown4be44fc2005-08-05 00:44:28 -0400422 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700423}
424
Sinan Kayabd23fac2018-12-19 22:46:55 +0000425#ifdef ACPI_PCI_CONFIGURED
Linus Torvalds1da177e2005-04-16 15:20:36 -0700426/*******************************************************************************
427 *
428 * FUNCTION: acpi_ex_pci_bar_space_handler
429 *
Bob Mooreba494be2012-07-12 09:40:10 +0800430 * PARAMETERS: function - Read or Write operation
431 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800433 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434 * handler_context - Pointer to Handler's context
435 * region_context - Pointer to context specific to the
436 * accessed region
437 *
438 * RETURN: Status
439 *
440 * DESCRIPTION: Handler for the PCI bar_target address space (Op Region)
441 *
442 ******************************************************************************/
443
444acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400445acpi_ex_pci_bar_space_handler(u32 function,
446 acpi_physical_address address,
447 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800448 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400449 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450{
Len Brown4be44fc2005-08-05 00:44:28 -0400451 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452
Bob Mooreb229cf92006-04-21 17:15:00 -0400453 ACPI_FUNCTION_TRACE(ex_pci_bar_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454
Len Brown4be44fc2005-08-05 00:44:28 -0400455 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700456}
Sinan Kayabd23fac2018-12-19 22:46:55 +0000457#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700458
Linus Torvalds1da177e2005-04-16 15:20:36 -0700459/*******************************************************************************
460 *
461 * FUNCTION: acpi_ex_data_table_space_handler
462 *
Bob Mooreba494be2012-07-12 09:40:10 +0800463 * PARAMETERS: function - Read or Write operation
464 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800466 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467 * handler_context - Pointer to Handler's context
468 * region_context - Pointer to context specific to the
469 * accessed region
470 *
471 * RETURN: Status
472 *
473 * DESCRIPTION: Handler for the Data Table address space (Op Region)
474 *
475 ******************************************************************************/
476
477acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400478acpi_ex_data_table_space_handler(u32 function,
479 acpi_physical_address address,
480 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800481 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400482 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700483{
Bob Mooreb229cf92006-04-21 17:15:00 -0400484 ACPI_FUNCTION_TRACE(ex_data_table_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485
Bob Moorec1637e92010-04-01 11:09:00 +0800486 /*
487 * Perform the memory read or write. The bit_width was already
488 * validated.
489 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700490 switch (function) {
491 case ACPI_READ:
492
Bob Moore4fa46162015-07-01 14:45:11 +0800493 memcpy(ACPI_CAST_PTR(char, value),
494 ACPI_PHYSADDR_TO_PTR(address), ACPI_DIV_8(bit_width));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 break;
496
497 case ACPI_WRITE:
Bob Moorec1637e92010-04-01 11:09:00 +0800498
Bob Moore4fa46162015-07-01 14:45:11 +0800499 memcpy(ACPI_PHYSADDR_TO_PTR(address),
500 ACPI_CAST_PTR(char, value), ACPI_DIV_8(bit_width));
Bob Moorec1637e92010-04-01 11:09:00 +0800501 break;
502
Linus Torvalds1da177e2005-04-16 15:20:36 -0700503 default:
504
Bob Moorec1637e92010-04-01 11:09:00 +0800505 return_ACPI_STATUS(AE_BAD_PARAMETER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700506 }
507
Bob Moore41195322006-05-26 16:36:00 -0400508 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700509}