Print this page
update to acpica-unix2-20140114
acpica-unix2-20130823
PANKOVs restructure
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/intel/io/acpica/executer/exregion.c
+++ new/usr/src/common/acpica/components/executer/exregion.c
1 -
2 1 /******************************************************************************
3 2 *
4 3 * Module Name: exregion - ACPI default OpRegion (address space) handlers
5 4 *
6 5 *****************************************************************************/
7 6
8 7 /*
9 - * Copyright (C) 2000 - 2011, Intel Corp.
8 + * Copyright (C) 2000 - 2014, Intel Corp.
10 9 * All rights reserved.
11 10 *
12 11 * Redistribution and use in source and binary forms, with or without
13 12 * modification, are permitted provided that the following conditions
14 13 * are met:
15 14 * 1. Redistributions of source code must retain the above copyright
16 15 * notice, this list of conditions, and the following disclaimer,
17 16 * without modification.
18 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19 18 * substantially similar to the "NO WARRANTY" disclaimer below
20 19 * ("Disclaimer") and any redistribution must be conditioned upon
21 20 * including a substantially similar Disclaimer requirement for further
22 21 * binary redistribution.
23 22 * 3. Neither the names of the above-listed copyright holders nor the names
24 23 * of any contributors may be used to endorse or promote products derived
25 24 * from this software without specific prior written permission.
26 25 *
27 26 * Alternatively, this software may be distributed under the terms of the
28 27 * GNU General Public License ("GPL") version 2 as published by the Free
29 28 * Software Foundation.
30 29 *
31 30 * NO WARRANTY
32 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42 41 * POSSIBILITY OF SUCH DAMAGES.
43 42 */
44 43
45 44
46 45 #define __EXREGION_C__
47 46
48 47 #include "acpi.h"
49 48 #include "accommon.h"
50 49 #include "acinterp.h"
51 50
52 51
53 52 #define _COMPONENT ACPI_EXECUTER
54 53 ACPI_MODULE_NAME ("exregion")
55 54
56 55
57 56 /*******************************************************************************
58 57 *
59 58 * FUNCTION: AcpiExSystemMemorySpaceHandler
60 59 *
61 60 * PARAMETERS: Function - Read or Write operation
62 61 * Address - Where in the space to read or write
63 62 * BitWidth - Field width in bits (8, 16, or 32)
64 63 * Value - Pointer to in or out value
65 64 * HandlerContext - Pointer to Handler's context
66 65 * RegionContext - Pointer to context specific to the
67 66 * accessed region
68 67 *
69 68 * RETURN: Status
70 69 *
71 70 * DESCRIPTION: Handler for the System Memory address space (Op Region)
72 71 *
73 72 ******************************************************************************/
74 73
75 74 ACPI_STATUS
76 75 AcpiExSystemMemorySpaceHandler (
77 76 UINT32 Function,
78 77 ACPI_PHYSICAL_ADDRESS Address,
79 78 UINT32 BitWidth,
80 79 UINT64 *Value,
81 80 void *HandlerContext,
82 81 void *RegionContext)
83 82 {
84 83 ACPI_STATUS Status = AE_OK;
85 84 void *LogicalAddrPtr = NULL;
86 85 ACPI_MEM_SPACE_CONTEXT *MemInfo = RegionContext;
87 86 UINT32 Length;
88 87 ACPI_SIZE MapLength;
89 88 ACPI_SIZE PageBoundaryMapLength;
90 89 #ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
91 90 UINT32 Remainder;
92 91 #endif
↓ open down ↓ |
73 lines elided |
↑ open up ↑ |
93 92
94 93
95 94 ACPI_FUNCTION_TRACE (ExSystemMemorySpaceHandler);
96 95
97 96
98 97 /* Validate and translate the bit width */
99 98
100 99 switch (BitWidth)
101 100 {
102 101 case 8:
102 +
103 103 Length = 1;
104 104 break;
105 105
106 106 case 16:
107 +
107 108 Length = 2;
108 109 break;
109 110
110 111 case 32:
112 +
111 113 Length = 4;
112 114 break;
113 115
114 116 case 64:
117 +
115 118 Length = 8;
116 119 break;
117 120
118 121 default:
122 +
119 123 ACPI_ERROR ((AE_INFO, "Invalid SystemMemory width %u",
120 124 BitWidth));
121 125 return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
122 126 }
123 127
124 128 #ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
125 129 /*
126 130 * Hardware does not support non-aligned data transfers, we must verify
127 131 * the request.
128 132 */
129 133 (void) AcpiUtShortDivide ((UINT64) Address, Length, NULL, &Remainder);
130 134 if (Remainder != 0)
131 135 {
132 136 return_ACPI_STATUS (AE_AML_ALIGNMENT);
133 137 }
134 138 #endif
135 139
136 140 /*
137 141 * Does the request fit into the cached memory mapping?
138 142 * Is 1) Address below the current mapping? OR
139 143 * 2) Address beyond the current mapping?
140 144 */
141 145 if ((Address < MemInfo->MappedPhysicalAddress) ||
142 146 (((UINT64) Address + Length) >
143 147 ((UINT64)
144 148 MemInfo->MappedPhysicalAddress + MemInfo->MappedLength)))
145 149 {
146 150 /*
147 151 * The request cannot be resolved by the current memory mapping;
148 152 * Delete the existing mapping and create a new one.
149 153 */
150 154 if (MemInfo->MappedLength)
151 155 {
152 156 /* Valid mapping, delete it */
153 157
154 158 AcpiOsUnmapMemory (MemInfo->MappedLogicalAddress,
155 159 MemInfo->MappedLength);
156 160 }
157 161
158 162 /*
159 163 * October 2009: Attempt to map from the requested address to the
160 164 * end of the region. However, we will never map more than one
161 165 * page, nor will we cross a page boundary.
162 166 */
163 167 MapLength = (ACPI_SIZE)
164 168 ((MemInfo->Address + MemInfo->Length) - Address);
165 169
166 170 /*
167 171 * If mapping the entire remaining portion of the region will cross
168 172 * a page boundary, just map up to the page boundary, do not cross.
169 173 * On some systems, crossing a page boundary while mapping regions
170 174 * can cause warnings if the pages have different attributes
171 175 * due to resource management.
172 176 *
173 177 * This has the added benefit of constraining a single mapping to
174 178 * one page, which is similar to the original code that used a 4k
175 179 * maximum window.
176 180 */
177 181 PageBoundaryMapLength =
178 182 ACPI_ROUND_UP (Address, ACPI_DEFAULT_PAGE_SIZE) - Address;
179 183 if (PageBoundaryMapLength == 0)
180 184 {
181 185 PageBoundaryMapLength = ACPI_DEFAULT_PAGE_SIZE;
182 186 }
183 187
184 188 if (MapLength > PageBoundaryMapLength)
185 189 {
186 190 MapLength = PageBoundaryMapLength;
187 191 }
188 192
189 193 /* Create a new mapping starting at the address given */
190 194
191 195 MemInfo->MappedLogicalAddress = AcpiOsMapMemory (
192 196 (ACPI_PHYSICAL_ADDRESS) Address, MapLength);
193 197 if (!MemInfo->MappedLogicalAddress)
194 198 {
195 199 ACPI_ERROR ((AE_INFO,
196 200 "Could not map memory at 0x%8.8X%8.8X, size %u",
197 201 ACPI_FORMAT_NATIVE_UINT (Address), (UINT32) MapLength));
198 202 MemInfo->MappedLength = 0;
199 203 return_ACPI_STATUS (AE_NO_MEMORY);
200 204 }
201 205
202 206 /* Save the physical address and mapping size */
203 207
204 208 MemInfo->MappedPhysicalAddress = Address;
205 209 MemInfo->MappedLength = MapLength;
206 210 }
207 211
208 212 /*
209 213 * Generate a logical pointer corresponding to the address we want to
210 214 * access
211 215 */
212 216 LogicalAddrPtr = MemInfo->MappedLogicalAddress +
↓ open down ↓ |
84 lines elided |
↑ open up ↑ |
213 217 ((UINT64) Address - (UINT64) MemInfo->MappedPhysicalAddress);
214 218
215 219 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
216 220 "System-Memory (width %u) R/W %u Address=%8.8X%8.8X\n",
217 221 BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address)));
218 222
219 223 /*
220 224 * Perform the memory read or write
221 225 *
222 226 * Note: For machines that do not support non-aligned transfers, the target
223 - * address was checked for alignment above. We do not attempt to break the
227 + * address was checked for alignment above. We do not attempt to break the
224 228 * transfer up into smaller (byte-size) chunks because the AML specifically
225 229 * asked for a transfer width that the hardware may require.
226 230 */
227 231 switch (Function)
228 232 {
229 233 case ACPI_READ:
230 234
231 235 *Value = 0;
232 236 switch (BitWidth)
233 237 {
234 238 case 8:
239 +
235 240 *Value = (UINT64) ACPI_GET8 (LogicalAddrPtr);
236 241 break;
237 242
238 243 case 16:
244 +
239 245 *Value = (UINT64) ACPI_GET16 (LogicalAddrPtr);
240 246 break;
241 247
242 248 case 32:
249 +
243 250 *Value = (UINT64) ACPI_GET32 (LogicalAddrPtr);
244 251 break;
245 252
246 253 case 64:
254 +
247 255 *Value = (UINT64) ACPI_GET64 (LogicalAddrPtr);
248 256 break;
249 257
250 258 default:
259 +
251 260 /* BitWidth was already validated */
261 +
252 262 break;
253 263 }
254 264 break;
255 265
256 266 case ACPI_WRITE:
257 267
258 268 switch (BitWidth)
259 269 {
260 270 case 8:
261 - ACPI_SET8 (LogicalAddrPtr) = (UINT8) *Value;
271 +
272 + ACPI_SET8 (LogicalAddrPtr, *Value);
262 273 break;
263 274
264 275 case 16:
265 - ACPI_SET16 (LogicalAddrPtr) = (UINT16) *Value;
276 +
277 + ACPI_SET16 (LogicalAddrPtr, *Value);
266 278 break;
267 279
268 280 case 32:
269 - ACPI_SET32 ( LogicalAddrPtr) = (UINT32) *Value;
281 +
282 + ACPI_SET32 (LogicalAddrPtr, *Value);
270 283 break;
271 284
272 285 case 64:
273 - ACPI_SET64 (LogicalAddrPtr) = (UINT64) *Value;
286 +
287 + ACPI_SET64 (LogicalAddrPtr, *Value);
274 288 break;
275 289
276 290 default:
291 +
277 292 /* BitWidth was already validated */
293 +
278 294 break;
279 295 }
280 296 break;
281 297
282 298 default:
299 +
283 300 Status = AE_BAD_PARAMETER;
284 301 break;
285 302 }
286 303
287 304 return_ACPI_STATUS (Status);
288 305 }
289 306
290 307
291 308 /*******************************************************************************
292 309 *
293 310 * FUNCTION: AcpiExSystemIoSpaceHandler
294 311 *
295 312 * PARAMETERS: Function - Read or Write operation
296 313 * Address - Where in the space to read or write
297 314 * BitWidth - Field width in bits (8, 16, or 32)
298 315 * Value - Pointer to in or out value
299 316 * HandlerContext - Pointer to Handler's context
300 317 * RegionContext - Pointer to context specific to the
301 318 * accessed region
302 319 *
303 320 * RETURN: Status
304 321 *
305 322 * DESCRIPTION: Handler for the System IO address space (Op Region)
306 323 *
307 324 ******************************************************************************/
308 325
309 326 ACPI_STATUS
310 327 AcpiExSystemIoSpaceHandler (
311 328 UINT32 Function,
312 329 ACPI_PHYSICAL_ADDRESS Address,
313 330 UINT32 BitWidth,
314 331 UINT64 *Value,
315 332 void *HandlerContext,
316 333 void *RegionContext)
317 334 {
318 335 ACPI_STATUS Status = AE_OK;
319 336 UINT32 Value32;
320 337
321 338
322 339 ACPI_FUNCTION_TRACE (ExSystemIoSpaceHandler);
323 340
324 341
325 342 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
326 343 "System-IO (width %u) R/W %u Address=%8.8X%8.8X\n",
327 344 BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address)));
328 345
329 346 /* Decode the function parameter */
330 347
331 348 switch (Function)
332 349 {
333 350 case ACPI_READ:
334 351
335 352 Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) Address,
336 353 &Value32, BitWidth);
↓ open down ↓ |
44 lines elided |
↑ open up ↑ |
337 354 *Value = Value32;
338 355 break;
339 356
340 357 case ACPI_WRITE:
341 358
342 359 Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) Address,
343 360 (UINT32) *Value, BitWidth);
344 361 break;
345 362
346 363 default:
364 +
347 365 Status = AE_BAD_PARAMETER;
348 366 break;
349 367 }
350 368
351 369 return_ACPI_STATUS (Status);
352 370 }
353 371
354 372
355 373 /*******************************************************************************
356 374 *
357 375 * FUNCTION: AcpiExPciConfigSpaceHandler
358 376 *
359 377 * PARAMETERS: Function - Read or Write operation
360 378 * Address - Where in the space to read or write
361 379 * BitWidth - Field width in bits (8, 16, or 32)
362 380 * Value - Pointer to in or out value
363 381 * HandlerContext - Pointer to Handler's context
364 382 * RegionContext - Pointer to context specific to the
365 383 * accessed region
366 384 *
367 385 * RETURN: Status
368 386 *
369 387 * DESCRIPTION: Handler for the PCI Config address space (Op Region)
370 388 *
371 389 ******************************************************************************/
372 390
373 391 ACPI_STATUS
374 392 AcpiExPciConfigSpaceHandler (
375 393 UINT32 Function,
376 394 ACPI_PHYSICAL_ADDRESS Address,
377 395 UINT32 BitWidth,
378 396 UINT64 *Value,
379 397 void *HandlerContext,
380 398 void *RegionContext)
381 399 {
382 400 ACPI_STATUS Status = AE_OK;
383 401 ACPI_PCI_ID *PciId;
384 402 UINT16 PciRegister;
385 403
386 404
387 405 ACPI_FUNCTION_TRACE (ExPciConfigSpaceHandler);
388 406
389 407
390 408 /*
391 409 * The arguments to AcpiOs(Read|Write)PciConfiguration are:
392 410 *
393 411 * PciSegment is the PCI bus segment range 0-31
394 412 * PciBus is the PCI bus number range 0-255
395 413 * PciDevice is the PCI device number range 0-31
396 414 * PciFunction is the PCI device function number
397 415 * PciRegister is the Config space register range 0-255 bytes
398 416 *
399 417 * Value - input value for write, output address for read
400 418 *
401 419 */
402 420 PciId = (ACPI_PCI_ID *) RegionContext;
403 421 PciRegister = (UINT16) (UINT32) Address;
404 422
405 423 ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
406 424 "Pci-Config %u (%u) Seg(%04x) Bus(%04x) Dev(%04x) Func(%04x) Reg(%04x)\n",
407 425 Function, BitWidth, PciId->Segment, PciId->Bus, PciId->Device,
408 426 PciId->Function, PciRegister));
409 427
410 428 switch (Function)
411 429 {
412 430 case ACPI_READ:
413 431
414 432 *Value = 0;
415 433 Status = AcpiOsReadPciConfiguration (PciId, PciRegister,
416 434 Value, BitWidth);
417 435 break;
418 436
419 437 case ACPI_WRITE:
420 438
421 439 Status = AcpiOsWritePciConfiguration (PciId, PciRegister,
422 440 *Value, BitWidth);
423 441 break;
424 442
425 443 default:
426 444
427 445 Status = AE_BAD_PARAMETER;
428 446 break;
429 447 }
430 448
431 449 return_ACPI_STATUS (Status);
432 450 }
433 451
434 452
435 453 /*******************************************************************************
436 454 *
437 455 * FUNCTION: AcpiExCmosSpaceHandler
438 456 *
439 457 * PARAMETERS: Function - Read or Write operation
440 458 * Address - Where in the space to read or write
441 459 * BitWidth - Field width in bits (8, 16, or 32)
442 460 * Value - Pointer to in or out value
443 461 * HandlerContext - Pointer to Handler's context
444 462 * RegionContext - Pointer to context specific to the
445 463 * accessed region
446 464 *
447 465 * RETURN: Status
448 466 *
449 467 * DESCRIPTION: Handler for the CMOS address space (Op Region)
450 468 *
451 469 ******************************************************************************/
452 470
453 471 ACPI_STATUS
454 472 AcpiExCmosSpaceHandler (
455 473 UINT32 Function,
456 474 ACPI_PHYSICAL_ADDRESS Address,
457 475 UINT32 BitWidth,
458 476 UINT64 *Value,
459 477 void *HandlerContext,
460 478 void *RegionContext)
461 479 {
462 480 ACPI_STATUS Status = AE_OK;
463 481
464 482
465 483 ACPI_FUNCTION_TRACE (ExCmosSpaceHandler);
466 484
467 485
468 486 return_ACPI_STATUS (Status);
469 487 }
470 488
471 489
472 490 /*******************************************************************************
473 491 *
474 492 * FUNCTION: AcpiExPciBarSpaceHandler
475 493 *
476 494 * PARAMETERS: Function - Read or Write operation
477 495 * Address - Where in the space to read or write
478 496 * BitWidth - Field width in bits (8, 16, or 32)
479 497 * Value - Pointer to in or out value
480 498 * HandlerContext - Pointer to Handler's context
481 499 * RegionContext - Pointer to context specific to the
482 500 * accessed region
483 501 *
484 502 * RETURN: Status
485 503 *
486 504 * DESCRIPTION: Handler for the PCI BarTarget address space (Op Region)
487 505 *
488 506 ******************************************************************************/
489 507
490 508 ACPI_STATUS
491 509 AcpiExPciBarSpaceHandler (
492 510 UINT32 Function,
493 511 ACPI_PHYSICAL_ADDRESS Address,
494 512 UINT32 BitWidth,
495 513 UINT64 *Value,
496 514 void *HandlerContext,
497 515 void *RegionContext)
498 516 {
499 517 ACPI_STATUS Status = AE_OK;
500 518
501 519
502 520 ACPI_FUNCTION_TRACE (ExPciBarSpaceHandler);
503 521
504 522
505 523 return_ACPI_STATUS (Status);
506 524 }
507 525
508 526
509 527 /*******************************************************************************
510 528 *
511 529 * FUNCTION: AcpiExDataTableSpaceHandler
512 530 *
513 531 * PARAMETERS: Function - Read or Write operation
514 532 * Address - Where in the space to read or write
515 533 * BitWidth - Field width in bits (8, 16, or 32)
516 534 * Value - Pointer to in or out value
517 535 * HandlerContext - Pointer to Handler's context
518 536 * RegionContext - Pointer to context specific to the
519 537 * accessed region
520 538 *
521 539 * RETURN: Status
522 540 *
523 541 * DESCRIPTION: Handler for the Data Table address space (Op Region)
524 542 *
525 543 ******************************************************************************/
526 544
527 545 ACPI_STATUS
528 546 AcpiExDataTableSpaceHandler (
529 547 UINT32 Function,
530 548 ACPI_PHYSICAL_ADDRESS Address,
531 549 UINT32 BitWidth,
532 550 UINT64 *Value,
533 551 void *HandlerContext,
534 552 void *RegionContext)
535 553 {
536 554 ACPI_FUNCTION_TRACE (ExDataTableSpaceHandler);
537 555
538 556
539 557 /*
540 558 * Perform the memory read or write. The BitWidth was already
541 559 * validated.
542 560 */
543 561 switch (Function)
544 562 {
545 563 case ACPI_READ:
546 564
547 565 ACPI_MEMCPY (ACPI_CAST_PTR (char, Value), ACPI_PHYSADDR_TO_PTR (Address),
548 566 ACPI_DIV_8 (BitWidth));
549 567 break;
550 568
551 569 case ACPI_WRITE:
552 570
553 571 ACPI_MEMCPY (ACPI_PHYSADDR_TO_PTR (Address), ACPI_CAST_PTR (char, Value),
↓ open down ↓ |
197 lines elided |
↑ open up ↑ |
554 572 ACPI_DIV_8 (BitWidth));
555 573 break;
556 574
557 575 default:
558 576
559 577 return_ACPI_STATUS (AE_BAD_PARAMETER);
560 578 }
561 579
562 580 return_ACPI_STATUS (AE_OK);
563 581 }
564 -
565 -
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX