blob: 82b713a9a1939a7c25f196fe1a58d3f0a503d488 [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 Moore4441e552021-01-15 10:48:25 -08006 * Copyright (C) 2000 - 2021, 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;
Rafael J. Wysockib8fcd0e2020-06-30 13:40:59 +020044 struct acpi_mem_mapping *mm = mem_info->cur_mm;
Len Brown4be44fc2005-08-05 00:44:28 -040045 u32 length;
Bob Moored410ee52009-10-22 09:11:11 +080046 acpi_size map_length;
47 acpi_size page_boundary_map_length;
Bob Moore08978312005-10-21 00:00:00 -040048#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
Len Brown4be44fc2005-08-05 00:44:28 -040049 u32 remainder;
Linus Torvalds1da177e2005-04-16 15:20:36 -070050#endif
51
Bob Mooreb229cf92006-04-21 17:15:00 -040052 ACPI_FUNCTION_TRACE(ex_system_memory_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -070053
54 /* Validate and translate the bit width */
55
56 switch (bit_width) {
57 case 8:
Chao Guan1d1ea1b72013-06-08 00:58:14 +000058
Linus Torvalds1da177e2005-04-16 15:20:36 -070059 length = 1;
60 break;
61
62 case 16:
Chao Guan1d1ea1b72013-06-08 00:58:14 +000063
Linus Torvalds1da177e2005-04-16 15:20:36 -070064 length = 2;
65 break;
66
67 case 32:
Chao Guan1d1ea1b72013-06-08 00:58:14 +000068
Linus Torvalds1da177e2005-04-16 15:20:36 -070069 length = 4;
70 break;
71
72 case 64:
Chao Guan1d1ea1b72013-06-08 00:58:14 +000073
Linus Torvalds1da177e2005-04-16 15:20:36 -070074 length = 8;
75 break;
76
77 default:
Chao Guan1d1ea1b72013-06-08 00:58:14 +000078
Bob Mooref6a22b02010-03-05 17:56:40 +080079 ACPI_ERROR((AE_INFO, "Invalid SystemMemory width %u",
Bob Mooreb8e4d892006-01-27 16:43:00 -050080 bit_width));
Len Brown4be44fc2005-08-05 00:44:28 -040081 return_ACPI_STATUS(AE_AML_OPERAND_VALUE);
Linus Torvalds1da177e2005-04-16 15:20:36 -070082 }
83
Bob Moore08978312005-10-21 00:00:00 -040084#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
Linus Torvalds1da177e2005-04-16 15:20:36 -070085 /*
86 * Hardware does not support non-aligned data transfers, we must verify
87 * the request.
88 */
Bob Moore5df7e6c2010-01-21 10:06:32 +080089 (void)acpi_ut_short_divide((u64) address, length, NULL, &remainder);
Linus Torvalds1da177e2005-04-16 15:20:36 -070090 if (remainder != 0) {
Len Brown4be44fc2005-08-05 00:44:28 -040091 return_ACPI_STATUS(AE_AML_ALIGNMENT);
Linus Torvalds1da177e2005-04-16 15:20:36 -070092 }
93#endif
94
95 /*
96 * Does the request fit into the cached memory mapping?
97 * Is 1) Address below the current mapping? OR
98 * 2) Address beyond the current mapping?
99 */
Rafael J. Wysockib8fcd0e2020-06-30 13:40:59 +0200100 if (!mm || (address < mm->physical_address) ||
101 ((u64) address + length > (u64) mm->physical_address + mm->length)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700102 /*
Rafael J. Wysockib8fcd0e2020-06-30 13:40:59 +0200103 * The request cannot be resolved by the current memory mapping.
104 *
105 * Look for an existing saved mapping covering the address range
106 * at hand. If found, save it as the current one and carry out
107 * the access.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700108 */
Rafael J. Wysockib8fcd0e2020-06-30 13:40:59 +0200109 for (mm = mem_info->first_mm; mm; mm = mm->next_mm) {
110 if (mm == mem_info->cur_mm)
111 continue;
Bob Moore52fc0b02006-10-02 00:00:00 -0400112
Rafael J. Wysockib8fcd0e2020-06-30 13:40:59 +0200113 if (address < mm->physical_address)
114 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700115
Rafael J. Wysockib8fcd0e2020-06-30 13:40:59 +0200116 if ((u64) address + length >
117 (u64) mm->physical_address + mm->length)
118 continue;
119
120 mem_info->cur_mm = mm;
121 goto access;
122 }
123
124 /* Create a new mappings list entry */
125 mm = ACPI_ALLOCATE_ZEROED(sizeof(*mm));
126 if (!mm) {
127 ACPI_ERROR((AE_INFO,
128 "Unable to save memory mapping at 0x%8.8X%8.8X, size %u",
129 ACPI_FORMAT_UINT64(address), length));
130 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700131 }
132
133 /*
Lv Zheng75c80442012-12-19 05:36:49 +0000134 * October 2009: Attempt to map from the requested address to the
135 * end of the region. However, we will never map more than one
136 * page, nor will we cross a page boundary.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700137 */
Bob Moored410ee52009-10-22 09:11:11 +0800138 map_length = (acpi_size)
Len Brown4be44fc2005-08-05 00:44:28 -0400139 ((mem_info->address + mem_info->length) - address);
Robert Moore44f6c012005-04-18 22:49:35 -0400140
Bob Moored410ee52009-10-22 09:11:11 +0800141 /*
142 * If mapping the entire remaining portion of the region will cross
143 * a page boundary, just map up to the page boundary, do not cross.
144 * On some systems, crossing a page boundary while mapping regions
145 * can cause warnings if the pages have different attributes
Lv Zheng75c80442012-12-19 05:36:49 +0000146 * due to resource management.
147 *
148 * This has the added benefit of constraining a single mapping to
149 * one page, which is similar to the original code that used a 4k
150 * maximum window.
Bob Moored410ee52009-10-22 09:11:11 +0800151 */
Bob Moore938ed102015-04-13 11:49:54 +0800152 page_boundary_map_length = (acpi_size)
153 (ACPI_ROUND_UP(address, ACPI_DEFAULT_PAGE_SIZE) - address);
Lv Zheng739dcbb2012-12-20 01:07:26 +0000154 if (page_boundary_map_length == 0) {
Bob Moored410ee52009-10-22 09:11:11 +0800155 page_boundary_map_length = ACPI_DEFAULT_PAGE_SIZE;
156 }
157
158 if (map_length > page_boundary_map_length) {
159 map_length = page_boundary_map_length;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700160 }
161
162 /* Create a new mapping starting at the address given */
163
Rafael J. Wysockib8fcd0e2020-06-30 13:40:59 +0200164 logical_addr_ptr = acpi_os_map_memory(address, map_length);
165 if (!logical_addr_ptr) {
Bob Mooreb8e4d892006-01-27 16:43:00 -0500166 ACPI_ERROR((AE_INFO,
Bob Mooref6a22b02010-03-05 17:56:40 +0800167 "Could not map memory at 0x%8.8X%8.8X, size %u",
Lv Zheng1d0a0b22015-04-13 11:48:52 +0800168 ACPI_FORMAT_UINT64(address),
Lv Zheng18ae9022015-04-13 11:48:12 +0800169 (u32)map_length));
Rafael J. Wysockib8fcd0e2020-06-30 13:40:59 +0200170 ACPI_FREE(mm);
Bob Mooref3d2e782007-02-02 19:48:18 +0300171 return_ACPI_STATUS(AE_NO_MEMORY);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700172 }
173
174 /* Save the physical address and mapping size */
175
Rafael J. Wysockib8fcd0e2020-06-30 13:40:59 +0200176 mm->logical_address = logical_addr_ptr;
177 mm->physical_address = address;
178 mm->length = map_length;
179
180 /*
181 * Add the new entry to the mappigs list and save it as the
182 * current mapping.
183 */
184 mm->next_mm = mem_info->first_mm;
185 mem_info->first_mm = mm;
186
187 mem_info->cur_mm = mm;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700188 }
189
Rafael J. Wysockib8fcd0e2020-06-30 13:40:59 +0200190access:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700191 /*
192 * Generate a logical pointer corresponding to the address we want to
193 * access
194 */
Rafael J. Wysockib8fcd0e2020-06-30 13:40:59 +0200195 logical_addr_ptr = mm->logical_address +
196 ((u64) address - (u64) mm->physical_address);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197
Len Brown4be44fc2005-08-05 00:44:28 -0400198 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Bob Mooreb27d6592010-05-26 11:47:13 +0800199 "System-Memory (width %u) R/W %u Address=%8.8X%8.8X\n",
Lv Zheng1d0a0b22015-04-13 11:48:52 +0800200 bit_width, function, ACPI_FORMAT_UINT64(address)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201
Len Brown4be44fc2005-08-05 00:44:28 -0400202 /*
203 * Perform the memory read or write
204 *
205 * Note: For machines that do not support non-aligned transfers, the target
Bob Moore73a30902012-10-31 02:26:55 +0000206 * address was checked for alignment above. We do not attempt to break the
Len Brown4be44fc2005-08-05 00:44:28 -0400207 * transfer up into smaller (byte-size) chunks because the AML specifically
208 * asked for a transfer width that the hardware may require.
209 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 switch (function) {
211 case ACPI_READ:
212
213 *value = 0;
214 switch (bit_width) {
215 case 8:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000216
217 *value = (u64)ACPI_GET8(logical_addr_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218 break;
219
220 case 16:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000221
222 *value = (u64)ACPI_GET16(logical_addr_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223 break;
224
225 case 32:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000226
227 *value = (u64)ACPI_GET32(logical_addr_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700228 break;
229
Linus Torvalds1da177e2005-04-16 15:20:36 -0700230 case 64:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000231
232 *value = (u64)ACPI_GET64(logical_addr_ptr);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233 break;
Bob Moore59fa8502007-02-02 19:48:23 +0300234
Linus Torvalds1da177e2005-04-16 15:20:36 -0700235 default:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000236
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237 /* bit_width was already validated */
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000238
Linus Torvalds1da177e2005-04-16 15:20:36 -0700239 break;
240 }
241 break;
242
243 case ACPI_WRITE:
244
245 switch (bit_width) {
246 case 8:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000247
Lv Zheng57bf6ae2012-12-19 05:38:24 +0000248 ACPI_SET8(logical_addr_ptr, *value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700249 break;
250
251 case 16:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000252
Lv Zheng57bf6ae2012-12-19 05:38:24 +0000253 ACPI_SET16(logical_addr_ptr, *value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700254 break;
255
256 case 32:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000257
Lv Zheng57bf6ae2012-12-19 05:38:24 +0000258 ACPI_SET32(logical_addr_ptr, *value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700259 break;
260
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261 case 64:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000262
Lv Zheng57bf6ae2012-12-19 05:38:24 +0000263 ACPI_SET64(logical_addr_ptr, *value);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700264 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700265
266 default:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000267
Linus Torvalds1da177e2005-04-16 15:20:36 -0700268 /* bit_width was already validated */
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000269
Linus Torvalds1da177e2005-04-16 15:20:36 -0700270 break;
271 }
272 break;
273
274 default:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000275
Linus Torvalds1da177e2005-04-16 15:20:36 -0700276 status = AE_BAD_PARAMETER;
277 break;
278 }
279
Len Brown4be44fc2005-08-05 00:44:28 -0400280 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700281}
282
Linus Torvalds1da177e2005-04-16 15:20:36 -0700283/*******************************************************************************
284 *
285 * FUNCTION: acpi_ex_system_io_space_handler
286 *
Bob Mooreba494be2012-07-12 09:40:10 +0800287 * PARAMETERS: function - Read or Write operation
288 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800290 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 * handler_context - Pointer to Handler's context
292 * region_context - Pointer to context specific to the
293 * accessed region
294 *
295 * RETURN: Status
296 *
297 * DESCRIPTION: Handler for the System IO address space (Op Region)
298 *
299 ******************************************************************************/
300
301acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400302acpi_ex_system_io_space_handler(u32 function,
303 acpi_physical_address address,
304 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800305 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400306 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700307{
Len Brown4be44fc2005-08-05 00:44:28 -0400308 acpi_status status = AE_OK;
309 u32 value32;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700310
Bob Mooreb229cf92006-04-21 17:15:00 -0400311 ACPI_FUNCTION_TRACE(ex_system_io_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700312
Len Brown4be44fc2005-08-05 00:44:28 -0400313 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Bob Mooreb27d6592010-05-26 11:47:13 +0800314 "System-IO (width %u) R/W %u Address=%8.8X%8.8X\n",
Lv Zheng1d0a0b22015-04-13 11:48:52 +0800315 bit_width, function, ACPI_FORMAT_UINT64(address)));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700316
317 /* Decode the function parameter */
318
319 switch (function) {
320 case ACPI_READ:
321
Lv Zhengf5c1e1c2016-05-05 12:57:53 +0800322 status = acpi_hw_read_port((acpi_io_address)address,
Len Brown4be44fc2005-08-05 00:44:28 -0400323 &value32, bit_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700324 *value = value32;
325 break;
326
327 case ACPI_WRITE:
328
Lv Zhengf5c1e1c2016-05-05 12:57:53 +0800329 status = acpi_hw_write_port((acpi_io_address)address,
330 (u32)*value, bit_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700331 break;
332
333 default:
Chao Guan1d1ea1b72013-06-08 00:58:14 +0000334
Linus Torvalds1da177e2005-04-16 15:20:36 -0700335 status = AE_BAD_PARAMETER;
336 break;
337 }
338
Len Brown4be44fc2005-08-05 00:44:28 -0400339 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700340}
341
Sinan Kayabd23fac2018-12-19 22:46:55 +0000342#ifdef ACPI_PCI_CONFIGURED
Linus Torvalds1da177e2005-04-16 15:20:36 -0700343/*******************************************************************************
344 *
345 * FUNCTION: acpi_ex_pci_config_space_handler
346 *
Bob Mooreba494be2012-07-12 09:40:10 +0800347 * PARAMETERS: function - Read or Write operation
348 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700349 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800350 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700351 * handler_context - Pointer to Handler's context
352 * region_context - Pointer to context specific to the
353 * accessed region
354 *
355 * RETURN: Status
356 *
357 * DESCRIPTION: Handler for the PCI Config address space (Op Region)
358 *
359 ******************************************************************************/
360
361acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400362acpi_ex_pci_config_space_handler(u32 function,
363 acpi_physical_address address,
364 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800365 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400366 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700367{
Len Brown4be44fc2005-08-05 00:44:28 -0400368 acpi_status status = AE_OK;
369 struct acpi_pci_id *pci_id;
370 u16 pci_register;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700371
Bob Mooreb229cf92006-04-21 17:15:00 -0400372 ACPI_FUNCTION_TRACE(ex_pci_config_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700373
374 /*
375 * The arguments to acpi_os(Read|Write)pci_configuration are:
376 *
377 * pci_segment is the PCI bus segment range 0-31
378 * pci_bus is the PCI bus number range 0-255
379 * pci_device is the PCI device number range 0-31
380 * pci_function is the PCI device function number
381 * pci_register is the Config space register range 0-255 bytes
382 *
Bob Mooreba494be2012-07-12 09:40:10 +0800383 * value - input value for write, output address for read
Linus Torvalds1da177e2005-04-16 15:20:36 -0700384 *
385 */
Len Brown4be44fc2005-08-05 00:44:28 -0400386 pci_id = (struct acpi_pci_id *)region_context;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387 pci_register = (u16) (u32) address;
388
Len Brown4be44fc2005-08-05 00:44:28 -0400389 ACPI_DEBUG_PRINT((ACPI_DB_INFO,
Bob Moore1fad8732015-12-29 13:54:36 +0800390 "Pci-Config %u (%u) Seg(%04x) Bus(%04x) "
391 "Dev(%04x) Func(%04x) Reg(%04x)\n",
Len Brown4be44fc2005-08-05 00:44:28 -0400392 function, bit_width, pci_id->segment, pci_id->bus,
393 pci_id->device, pci_id->function, pci_register));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700394
395 switch (function) {
396 case ACPI_READ:
397
Lv Zhengbb42cc22013-10-31 09:29:49 +0800398 *value = 0;
Bob Moore1fad8732015-12-29 13:54:36 +0800399 status =
400 acpi_os_read_pci_configuration(pci_id, pci_register, value,
401 bit_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700402 break;
403
404 case ACPI_WRITE:
405
Bob Moore1fad8732015-12-29 13:54:36 +0800406 status =
407 acpi_os_write_pci_configuration(pci_id, pci_register,
408 *value, bit_width);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700409 break;
410
411 default:
412
413 status = AE_BAD_PARAMETER;
414 break;
415 }
416
Len Brown4be44fc2005-08-05 00:44:28 -0400417 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700418}
Sinan Kayabd23fac2018-12-19 22:46:55 +0000419#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700420
Linus Torvalds1da177e2005-04-16 15:20:36 -0700421/*******************************************************************************
422 *
423 * FUNCTION: acpi_ex_cmos_space_handler
424 *
Bob Mooreba494be2012-07-12 09:40:10 +0800425 * PARAMETERS: function - Read or Write operation
426 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700427 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800428 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700429 * handler_context - Pointer to Handler's context
430 * region_context - Pointer to context specific to the
431 * accessed region
432 *
433 * RETURN: Status
434 *
435 * DESCRIPTION: Handler for the CMOS address space (Op Region)
436 *
437 ******************************************************************************/
438
439acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400440acpi_ex_cmos_space_handler(u32 function,
441 acpi_physical_address address,
442 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800443 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400444 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700445{
Len Brown4be44fc2005-08-05 00:44:28 -0400446 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700447
Bob Mooreb229cf92006-04-21 17:15:00 -0400448 ACPI_FUNCTION_TRACE(ex_cmos_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700449
Len Brown4be44fc2005-08-05 00:44:28 -0400450 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700451}
452
Sinan Kayabd23fac2018-12-19 22:46:55 +0000453#ifdef ACPI_PCI_CONFIGURED
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454/*******************************************************************************
455 *
456 * FUNCTION: acpi_ex_pci_bar_space_handler
457 *
Bob Mooreba494be2012-07-12 09:40:10 +0800458 * PARAMETERS: function - Read or Write operation
459 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700460 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800461 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462 * handler_context - Pointer to Handler's context
463 * region_context - Pointer to context specific to the
464 * accessed region
465 *
466 * RETURN: Status
467 *
468 * DESCRIPTION: Handler for the PCI bar_target address space (Op Region)
469 *
470 ******************************************************************************/
471
472acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400473acpi_ex_pci_bar_space_handler(u32 function,
474 acpi_physical_address address,
475 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800476 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400477 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700478{
Len Brown4be44fc2005-08-05 00:44:28 -0400479 acpi_status status = AE_OK;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700480
Bob Mooreb229cf92006-04-21 17:15:00 -0400481 ACPI_FUNCTION_TRACE(ex_pci_bar_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700482
Len Brown4be44fc2005-08-05 00:44:28 -0400483 return_ACPI_STATUS(status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700484}
Sinan Kayabd23fac2018-12-19 22:46:55 +0000485#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700486
Linus Torvalds1da177e2005-04-16 15:20:36 -0700487/*******************************************************************************
488 *
489 * FUNCTION: acpi_ex_data_table_space_handler
490 *
Bob Mooreba494be2012-07-12 09:40:10 +0800491 * PARAMETERS: function - Read or Write operation
492 * address - Where in the space to read or write
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 * bit_width - Field width in bits (8, 16, or 32)
Bob Mooreba494be2012-07-12 09:40:10 +0800494 * value - Pointer to in or out value
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495 * handler_context - Pointer to Handler's context
496 * region_context - Pointer to context specific to the
497 * accessed region
498 *
499 * RETURN: Status
500 *
501 * DESCRIPTION: Handler for the Data Table address space (Op Region)
502 *
503 ******************************************************************************/
504
505acpi_status
Len Brown4be44fc2005-08-05 00:44:28 -0400506acpi_ex_data_table_space_handler(u32 function,
507 acpi_physical_address address,
508 u32 bit_width,
Bob Moore5df7e6c2010-01-21 10:06:32 +0800509 u64 *value,
Len Brown4be44fc2005-08-05 00:44:28 -0400510 void *handler_context, void *region_context)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700511{
Bob Mooreb229cf92006-04-21 17:15:00 -0400512 ACPI_FUNCTION_TRACE(ex_data_table_space_handler);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700513
Bob Moorec1637e92010-04-01 11:09:00 +0800514 /*
515 * Perform the memory read or write. The bit_width was already
516 * validated.
517 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700518 switch (function) {
519 case ACPI_READ:
520
Bob Moore4fa46162015-07-01 14:45:11 +0800521 memcpy(ACPI_CAST_PTR(char, value),
522 ACPI_PHYSADDR_TO_PTR(address), ACPI_DIV_8(bit_width));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700523 break;
524
525 case ACPI_WRITE:
Bob Moorec1637e92010-04-01 11:09:00 +0800526
Bob Moore4fa46162015-07-01 14:45:11 +0800527 memcpy(ACPI_PHYSADDR_TO_PTR(address),
528 ACPI_CAST_PTR(char, value), ACPI_DIV_8(bit_width));
Bob Moorec1637e92010-04-01 11:09:00 +0800529 break;
530
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531 default:
532
Bob Moorec1637e92010-04-01 11:09:00 +0800533 return_ACPI_STATUS(AE_BAD_PARAMETER);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700534 }
535
Bob Moore41195322006-05-26 16:36:00 -0400536 return_ACPI_STATUS(AE_OK);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700537}