| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 |  | 
 | 2 | /****************************************************************************** | 
 | 3 |  * | 
 | 4 |  * Module Name: exregion - ACPI default op_region (address space) handlers | 
 | 5 |  * | 
 | 6 |  *****************************************************************************/ | 
 | 7 |  | 
 | 8 | /* | 
| Len Brown | 75a44ce | 2008-04-23 23:00:13 -0400 | [diff] [blame] | 9 |  * Copyright (C) 2000 - 2008, Intel Corp. | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 10 |  * All rights reserved. | 
 | 11 |  * | 
 | 12 |  * Redistribution and use in source and binary forms, with or without | 
 | 13 |  * modification, are permitted provided that the following conditions | 
 | 14 |  * are met: | 
 | 15 |  * 1. Redistributions of source code must retain the above copyright | 
 | 16 |  *    notice, this list of conditions, and the following disclaimer, | 
 | 17 |  *    without modification. | 
 | 18 |  * 2. Redistributions in binary form must reproduce at minimum a disclaimer | 
 | 19 |  *    substantially similar to the "NO WARRANTY" disclaimer below | 
 | 20 |  *    ("Disclaimer") and any redistribution must be conditioned upon | 
 | 21 |  *    including a substantially similar Disclaimer requirement for further | 
 | 22 |  *    binary redistribution. | 
 | 23 |  * 3. Neither the names of the above-listed copyright holders nor the names | 
 | 24 |  *    of any contributors may be used to endorse or promote products derived | 
 | 25 |  *    from this software without specific prior written permission. | 
 | 26 |  * | 
 | 27 |  * Alternatively, this software may be distributed under the terms of the | 
 | 28 |  * GNU General Public License ("GPL") version 2 as published by the Free | 
 | 29 |  * Software Foundation. | 
 | 30 |  * | 
 | 31 |  * NO WARRANTY | 
 | 32 |  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | 
 | 33 |  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | 
 | 34 |  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR | 
 | 35 |  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 
 | 36 |  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 
 | 37 |  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | 
 | 38 |  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | 
 | 39 |  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 
 | 40 |  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING | 
 | 41 |  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | 
 | 42 |  * POSSIBILITY OF SUCH DAMAGES. | 
 | 43 |  */ | 
 | 44 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | #include <acpi/acpi.h> | 
| Len Brown | e2f7a77 | 2009-01-09 00:30:03 -0500 | [diff] [blame] | 46 | #include "accommon.h" | 
 | 47 | #include "acinterp.h" | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 49 | #define _COMPONENT          ACPI_EXECUTER | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 50 | ACPI_MODULE_NAME("exregion") | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 |  | 
 | 52 | /******************************************************************************* | 
 | 53 |  * | 
 | 54 |  * FUNCTION:    acpi_ex_system_memory_space_handler | 
 | 55 |  * | 
 | 56 |  * PARAMETERS:  Function            - Read or Write operation | 
 | 57 |  *              Address             - Where in the space to read or write | 
 | 58 |  *              bit_width           - Field width in bits (8, 16, or 32) | 
 | 59 |  *              Value               - Pointer to in or out value | 
 | 60 |  *              handler_context     - Pointer to Handler's context | 
 | 61 |  *              region_context      - Pointer to context specific to the | 
 | 62 |  *                                    accessed region | 
 | 63 |  * | 
 | 64 |  * RETURN:      Status | 
 | 65 |  * | 
 | 66 |  * DESCRIPTION: Handler for the System Memory address space (Op Region) | 
 | 67 |  * | 
 | 68 |  ******************************************************************************/ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 70 | acpi_ex_system_memory_space_handler(u32 function, | 
 | 71 | 				    acpi_physical_address address, | 
 | 72 | 				    u32 bit_width, | 
 | 73 | 				    acpi_integer * value, | 
 | 74 | 				    void *handler_context, void *region_context) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 75 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 76 | 	acpi_status status = AE_OK; | 
 | 77 | 	void *logical_addr_ptr = NULL; | 
 | 78 | 	struct acpi_mem_space_context *mem_info = region_context; | 
 | 79 | 	u32 length; | 
 | 80 | 	acpi_size window_size; | 
| Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 81 | #ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 82 | 	u32 remainder; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | #endif | 
 | 84 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 85 | 	ACPI_FUNCTION_TRACE(ex_system_memory_space_handler); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 |  | 
 | 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 Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 107 | 		ACPI_ERROR((AE_INFO, "Invalid SystemMemory width %d", | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 108 | 			    bit_width)); | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 109 | 		return_ACPI_STATUS(AE_AML_OPERAND_VALUE); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 110 | 	} | 
 | 111 |  | 
| Bob Moore | 0897831 | 2005-10-21 00:00:00 -0400 | [diff] [blame] | 112 | #ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 113 | 	/* | 
 | 114 | 	 * Hardware does not support non-aligned data transfers, we must verify | 
 | 115 | 	 * the request. | 
 | 116 | 	 */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 117 | 	(void)acpi_ut_short_divide((acpi_integer) address, length, NULL, | 
 | 118 | 				   &remainder); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | 	if (remainder != 0) { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 120 | 		return_ACPI_STATUS(AE_AML_ALIGNMENT); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 121 | 	} | 
 | 122 | #endif | 
 | 123 |  | 
 | 124 | 	/* | 
 | 125 | 	 * Does the request fit into the cached memory mapping? | 
 | 126 | 	 * Is 1) Address below the current mapping? OR | 
 | 127 | 	 *    2) Address beyond the current mapping? | 
 | 128 | 	 */ | 
 | 129 | 	if ((address < mem_info->mapped_physical_address) || | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 130 | 	    (((acpi_integer) address + length) > ((acpi_integer) | 
 | 131 | 						  mem_info-> | 
 | 132 | 						  mapped_physical_address + | 
 | 133 | 						  mem_info->mapped_length))) { | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | 		/* | 
 | 135 | 		 * The request cannot be resolved by the current memory mapping; | 
 | 136 | 		 * Delete the existing mapping and create a new one. | 
 | 137 | 		 */ | 
 | 138 | 		if (mem_info->mapped_length) { | 
| Bob Moore | 52fc0b0 | 2006-10-02 00:00:00 -0400 | [diff] [blame] | 139 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 140 | 			/* Valid mapping, delete it */ | 
 | 141 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 142 | 			acpi_os_unmap_memory(mem_info->mapped_logical_address, | 
 | 143 | 					     mem_info->mapped_length); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 144 | 		} | 
 | 145 |  | 
 | 146 | 		/* | 
 | 147 | 		 * Don't attempt to map memory beyond the end of the region, and | 
 | 148 | 		 * constrain the maximum mapping size to something reasonable. | 
 | 149 | 		 */ | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 150 | 		window_size = (acpi_size) | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 151 | 		    ((mem_info->address + mem_info->length) - address); | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 152 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | 		if (window_size > ACPI_SYSMEM_REGION_WINDOW_SIZE) { | 
 | 154 | 			window_size = ACPI_SYSMEM_REGION_WINDOW_SIZE; | 
 | 155 | 		} | 
 | 156 |  | 
 | 157 | 		/* Create a new mapping starting at the address given */ | 
 | 158 |  | 
| Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 159 | 		mem_info->mapped_logical_address = | 
| Bob Moore | 67a119f | 2008-06-10 13:42:13 +0800 | [diff] [blame] | 160 | 			acpi_os_map_memory((acpi_physical_address) address, window_size); | 
| Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 161 | 		if (!mem_info->mapped_logical_address) { | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 162 | 			ACPI_ERROR((AE_INFO, | 
 | 163 | 				    "Could not map memory at %8.8X%8.8X, size %X", | 
| Bob Moore | b7f9f04 | 2008-04-10 19:06:40 +0400 | [diff] [blame] | 164 | 				    ACPI_FORMAT_NATIVE_UINT(address), | 
| Bob Moore | b8e4d89 | 2006-01-27 16:43:00 -0500 | [diff] [blame] | 165 | 				    (u32) window_size)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | 			mem_info->mapped_length = 0; | 
| Bob Moore | f3d2e78 | 2007-02-02 19:48:18 +0300 | [diff] [blame] | 167 | 			return_ACPI_STATUS(AE_NO_MEMORY); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 168 | 		} | 
 | 169 |  | 
 | 170 | 		/* Save the physical address and mapping size */ | 
 | 171 |  | 
 | 172 | 		mem_info->mapped_physical_address = address; | 
 | 173 | 		mem_info->mapped_length = window_size; | 
 | 174 | 	} | 
 | 175 |  | 
 | 176 | 	/* | 
 | 177 | 	 * Generate a logical pointer corresponding to the address we want to | 
 | 178 | 	 * access | 
 | 179 | 	 */ | 
 | 180 | 	logical_addr_ptr = mem_info->mapped_logical_address + | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 181 | 	    ((acpi_integer) address - | 
 | 182 | 	     (acpi_integer) mem_info->mapped_physical_address); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 183 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 184 | 	ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 185 | 			  "System-Memory (width %d) R/W %d Address=%8.8X%8.8X\n", | 
| Bob Moore | b7f9f04 | 2008-04-10 19:06:40 +0400 | [diff] [blame] | 186 | 			  bit_width, function, | 
 | 187 | 			  ACPI_FORMAT_NATIVE_UINT(address))); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 188 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 189 | 	/* | 
 | 190 | 	 * Perform the memory read or write | 
 | 191 | 	 * | 
 | 192 | 	 * Note: For machines that do not support non-aligned transfers, the target | 
 | 193 | 	 * address was checked for alignment above.  We do not attempt to break the | 
 | 194 | 	 * transfer up into smaller (byte-size) chunks because the AML specifically | 
 | 195 | 	 * asked for a transfer width that the hardware may require. | 
 | 196 | 	 */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 197 | 	switch (function) { | 
 | 198 | 	case ACPI_READ: | 
 | 199 |  | 
 | 200 | 		*value = 0; | 
 | 201 | 		switch (bit_width) { | 
 | 202 | 		case 8: | 
| Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 203 | 			*value = (acpi_integer) ACPI_GET8(logical_addr_ptr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | 			break; | 
 | 205 |  | 
 | 206 | 		case 16: | 
| Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 207 | 			*value = (acpi_integer) ACPI_GET16(logical_addr_ptr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 208 | 			break; | 
 | 209 |  | 
 | 210 | 		case 32: | 
| Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 211 | 			*value = (acpi_integer) ACPI_GET32(logical_addr_ptr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 212 | 			break; | 
 | 213 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 214 | 		case 64: | 
| Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 215 | 			*value = (acpi_integer) ACPI_GET64(logical_addr_ptr); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 216 | 			break; | 
| Bob Moore | 59fa850 | 2007-02-02 19:48:23 +0300 | [diff] [blame] | 217 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 218 | 		default: | 
 | 219 | 			/* bit_width was already validated */ | 
 | 220 | 			break; | 
 | 221 | 		} | 
 | 222 | 		break; | 
 | 223 |  | 
 | 224 | 	case ACPI_WRITE: | 
 | 225 |  | 
 | 226 | 		switch (bit_width) { | 
 | 227 | 		case 8: | 
| Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 228 | 			ACPI_SET8(logical_addr_ptr) = (u8) * value; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 229 | 			break; | 
 | 230 |  | 
 | 231 | 		case 16: | 
| Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 232 | 			ACPI_SET16(logical_addr_ptr) = (u16) * value; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | 			break; | 
 | 234 |  | 
 | 235 | 		case 32: | 
| Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 236 | 			ACPI_SET32(logical_addr_ptr) = (u32) * value; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | 			break; | 
 | 238 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 239 | 		case 64: | 
| Bob Moore | c51a4de | 2005-11-17 13:07:00 -0500 | [diff] [blame] | 240 | 			ACPI_SET64(logical_addr_ptr) = (u64) * value; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 241 | 			break; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 |  | 
 | 243 | 		default: | 
 | 244 | 			/* bit_width was already validated */ | 
 | 245 | 			break; | 
 | 246 | 		} | 
 | 247 | 		break; | 
 | 248 |  | 
 | 249 | 	default: | 
 | 250 | 		status = AE_BAD_PARAMETER; | 
 | 251 | 		break; | 
 | 252 | 	} | 
 | 253 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 254 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 255 | } | 
 | 256 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 257 | /******************************************************************************* | 
 | 258 |  * | 
 | 259 |  * FUNCTION:    acpi_ex_system_io_space_handler | 
 | 260 |  * | 
 | 261 |  * PARAMETERS:  Function            - Read or Write operation | 
 | 262 |  *              Address             - Where in the space to read or write | 
 | 263 |  *              bit_width           - Field width in bits (8, 16, or 32) | 
 | 264 |  *              Value               - Pointer to in or out value | 
 | 265 |  *              handler_context     - Pointer to Handler's context | 
 | 266 |  *              region_context      - Pointer to context specific to the | 
 | 267 |  *                                    accessed region | 
 | 268 |  * | 
 | 269 |  * RETURN:      Status | 
 | 270 |  * | 
 | 271 |  * DESCRIPTION: Handler for the System IO address space (Op Region) | 
 | 272 |  * | 
 | 273 |  ******************************************************************************/ | 
 | 274 |  | 
 | 275 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 276 | acpi_ex_system_io_space_handler(u32 function, | 
 | 277 | 				acpi_physical_address address, | 
 | 278 | 				u32 bit_width, | 
 | 279 | 				acpi_integer * value, | 
 | 280 | 				void *handler_context, void *region_context) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 281 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 282 | 	acpi_status status = AE_OK; | 
 | 283 | 	u32 value32; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 285 | 	ACPI_FUNCTION_TRACE(ex_system_io_space_handler); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 287 | 	ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 288 | 			  "System-IO (width %d) R/W %d Address=%8.8X%8.8X\n", | 
| Bob Moore | b7f9f04 | 2008-04-10 19:06:40 +0400 | [diff] [blame] | 289 | 			  bit_width, function, | 
 | 290 | 			  ACPI_FORMAT_NATIVE_UINT(address))); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 |  | 
 | 292 | 	/* Decode the function parameter */ | 
 | 293 |  | 
 | 294 | 	switch (function) { | 
 | 295 | 	case ACPI_READ: | 
 | 296 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 297 | 		status = acpi_os_read_port((acpi_io_address) address, | 
 | 298 | 					   &value32, bit_width); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | 		*value = value32; | 
 | 300 | 		break; | 
 | 301 |  | 
 | 302 | 	case ACPI_WRITE: | 
 | 303 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 304 | 		status = acpi_os_write_port((acpi_io_address) address, | 
 | 305 | 					    (u32) * value, bit_width); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | 		break; | 
 | 307 |  | 
 | 308 | 	default: | 
 | 309 | 		status = AE_BAD_PARAMETER; | 
 | 310 | 		break; | 
 | 311 | 	} | 
 | 312 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 313 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 314 | } | 
 | 315 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | /******************************************************************************* | 
 | 317 |  * | 
 | 318 |  * FUNCTION:    acpi_ex_pci_config_space_handler | 
 | 319 |  * | 
 | 320 |  * PARAMETERS:  Function            - Read or Write operation | 
 | 321 |  *              Address             - Where in the space to read or write | 
 | 322 |  *              bit_width           - Field width in bits (8, 16, or 32) | 
 | 323 |  *              Value               - Pointer to in or out value | 
 | 324 |  *              handler_context     - Pointer to Handler's context | 
 | 325 |  *              region_context      - Pointer to context specific to the | 
 | 326 |  *                                    accessed region | 
 | 327 |  * | 
 | 328 |  * RETURN:      Status | 
 | 329 |  * | 
 | 330 |  * DESCRIPTION: Handler for the PCI Config address space (Op Region) | 
 | 331 |  * | 
 | 332 |  ******************************************************************************/ | 
 | 333 |  | 
 | 334 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 335 | acpi_ex_pci_config_space_handler(u32 function, | 
 | 336 | 				 acpi_physical_address address, | 
 | 337 | 				 u32 bit_width, | 
 | 338 | 				 acpi_integer * value, | 
 | 339 | 				 void *handler_context, void *region_context) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 341 | 	acpi_status status = AE_OK; | 
 | 342 | 	struct acpi_pci_id *pci_id; | 
 | 343 | 	u16 pci_register; | 
| Ming Lin | 1186974 | 2008-02-21 02:01:30 -0500 | [diff] [blame] | 344 | 	u32 value32; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 345 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 346 | 	ACPI_FUNCTION_TRACE(ex_pci_config_space_handler); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 347 |  | 
 | 348 | 	/* | 
 | 349 | 	 *  The arguments to acpi_os(Read|Write)pci_configuration are: | 
 | 350 | 	 * | 
 | 351 | 	 *  pci_segment is the PCI bus segment range 0-31 | 
 | 352 | 	 *  pci_bus     is the PCI bus number range 0-255 | 
 | 353 | 	 *  pci_device  is the PCI device number range 0-31 | 
 | 354 | 	 *  pci_function is the PCI device function number | 
 | 355 | 	 *  pci_register is the Config space register range 0-255 bytes | 
 | 356 | 	 * | 
 | 357 | 	 *  Value - input value for write, output address for read | 
 | 358 | 	 * | 
 | 359 | 	 */ | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 360 | 	pci_id = (struct acpi_pci_id *)region_context; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 361 | 	pci_register = (u16) (u32) address; | 
 | 362 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 363 | 	ACPI_DEBUG_PRINT((ACPI_DB_INFO, | 
| Bob Moore | 8313524 | 2006-10-03 00:00:00 -0400 | [diff] [blame] | 364 | 			  "Pci-Config %d (%d) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n", | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 365 | 			  function, bit_width, pci_id->segment, pci_id->bus, | 
 | 366 | 			  pci_id->device, pci_id->function, pci_register)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 367 |  | 
 | 368 | 	switch (function) { | 
 | 369 | 	case ACPI_READ: | 
 | 370 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 371 | 		status = acpi_os_read_pci_configuration(pci_id, pci_register, | 
| Ming Lin | 1186974 | 2008-02-21 02:01:30 -0500 | [diff] [blame] | 372 | 							&value32, bit_width); | 
 | 373 | 		*value = value32; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 374 | 		break; | 
 | 375 |  | 
 | 376 | 	case ACPI_WRITE: | 
 | 377 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 378 | 		status = acpi_os_write_pci_configuration(pci_id, pci_register, | 
 | 379 | 							 *value, bit_width); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 380 | 		break; | 
 | 381 |  | 
 | 382 | 	default: | 
 | 383 |  | 
 | 384 | 		status = AE_BAD_PARAMETER; | 
 | 385 | 		break; | 
 | 386 | 	} | 
 | 387 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 388 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | } | 
 | 390 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 391 | /******************************************************************************* | 
 | 392 |  * | 
 | 393 |  * FUNCTION:    acpi_ex_cmos_space_handler | 
 | 394 |  * | 
 | 395 |  * PARAMETERS:  Function            - Read or Write operation | 
 | 396 |  *              Address             - Where in the space to read or write | 
 | 397 |  *              bit_width           - Field width in bits (8, 16, or 32) | 
 | 398 |  *              Value               - Pointer to in or out value | 
 | 399 |  *              handler_context     - Pointer to Handler's context | 
 | 400 |  *              region_context      - Pointer to context specific to the | 
 | 401 |  *                                    accessed region | 
 | 402 |  * | 
 | 403 |  * RETURN:      Status | 
 | 404 |  * | 
 | 405 |  * DESCRIPTION: Handler for the CMOS address space (Op Region) | 
 | 406 |  * | 
 | 407 |  ******************************************************************************/ | 
 | 408 |  | 
 | 409 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 410 | acpi_ex_cmos_space_handler(u32 function, | 
 | 411 | 			   acpi_physical_address address, | 
 | 412 | 			   u32 bit_width, | 
 | 413 | 			   acpi_integer * value, | 
 | 414 | 			   void *handler_context, void *region_context) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 415 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 416 | 	acpi_status status = AE_OK; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 418 | 	ACPI_FUNCTION_TRACE(ex_cmos_space_handler); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 420 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 421 | } | 
 | 422 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 423 | /******************************************************************************* | 
 | 424 |  * | 
 | 425 |  * FUNCTION:    acpi_ex_pci_bar_space_handler | 
 | 426 |  * | 
 | 427 |  * PARAMETERS:  Function            - Read or Write operation | 
 | 428 |  *              Address             - Where in the space to read or write | 
 | 429 |  *              bit_width           - Field width in bits (8, 16, or 32) | 
 | 430 |  *              Value               - Pointer to in or out value | 
 | 431 |  *              handler_context     - Pointer to Handler's context | 
 | 432 |  *              region_context      - Pointer to context specific to the | 
 | 433 |  *                                    accessed region | 
 | 434 |  * | 
 | 435 |  * RETURN:      Status | 
 | 436 |  * | 
 | 437 |  * DESCRIPTION: Handler for the PCI bar_target address space (Op Region) | 
 | 438 |  * | 
 | 439 |  ******************************************************************************/ | 
 | 440 |  | 
 | 441 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 442 | acpi_ex_pci_bar_space_handler(u32 function, | 
 | 443 | 			      acpi_physical_address address, | 
 | 444 | 			      u32 bit_width, | 
 | 445 | 			      acpi_integer * value, | 
 | 446 | 			      void *handler_context, void *region_context) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 447 | { | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 448 | 	acpi_status status = AE_OK; | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 449 |  | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 450 | 	ACPI_FUNCTION_TRACE(ex_pci_bar_space_handler); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 451 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 452 | 	return_ACPI_STATUS(status); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | } | 
 | 454 |  | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | /******************************************************************************* | 
 | 456 |  * | 
 | 457 |  * FUNCTION:    acpi_ex_data_table_space_handler | 
 | 458 |  * | 
 | 459 |  * PARAMETERS:  Function            - Read or Write operation | 
 | 460 |  *              Address             - Where in the space to read or write | 
 | 461 |  *              bit_width           - Field width in bits (8, 16, or 32) | 
 | 462 |  *              Value               - Pointer to in or out value | 
 | 463 |  *              handler_context     - Pointer to Handler's context | 
 | 464 |  *              region_context      - Pointer to context specific to the | 
 | 465 |  *                                    accessed region | 
 | 466 |  * | 
 | 467 |  * RETURN:      Status | 
 | 468 |  * | 
 | 469 |  * DESCRIPTION: Handler for the Data Table address space (Op Region) | 
 | 470 |  * | 
 | 471 |  ******************************************************************************/ | 
 | 472 |  | 
 | 473 | acpi_status | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 474 | acpi_ex_data_table_space_handler(u32 function, | 
 | 475 | 				 acpi_physical_address address, | 
 | 476 | 				 u32 bit_width, | 
 | 477 | 				 acpi_integer * value, | 
 | 478 | 				 void *handler_context, void *region_context) | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 479 | { | 
| Bob Moore | b229cf9 | 2006-04-21 17:15:00 -0400 | [diff] [blame] | 480 | 	ACPI_FUNCTION_TRACE(ex_data_table_space_handler); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 481 |  | 
| Robert Moore | 44f6c01 | 2005-04-18 22:49:35 -0400 | [diff] [blame] | 482 | 	/* Perform the memory read or write */ | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 483 |  | 
 | 484 | 	switch (function) { | 
 | 485 | 	case ACPI_READ: | 
 | 486 |  | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 487 | 		ACPI_MEMCPY(ACPI_CAST_PTR(char, value), | 
 | 488 | 			    ACPI_PHYSADDR_TO_PTR(address), | 
 | 489 | 			    ACPI_DIV_8(bit_width)); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | 		break; | 
 | 491 |  | 
 | 492 | 	case ACPI_WRITE: | 
 | 493 | 	default: | 
 | 494 |  | 
| Len Brown | 4be44fc | 2005-08-05 00:44:28 -0400 | [diff] [blame] | 495 | 		return_ACPI_STATUS(AE_SUPPORT); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 496 | 	} | 
 | 497 |  | 
| Bob Moore | 4119532 | 2006-05-26 16:36:00 -0400 | [diff] [blame] | 498 | 	return_ACPI_STATUS(AE_OK); | 
| Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 499 | } |