Print this page
update to acpica-unix2-20140114
acpica-unix2-20130823
PANKOVs restructure
   1 
   2 /******************************************************************************
   3  *
   4  * Module Name: exregion - ACPI default OpRegion (address space) handlers
   5  *
   6  *****************************************************************************/
   7 
   8 /*
   9  * Copyright (C) 2000 - 2011, Intel Corp.
  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.


  83 {
  84     ACPI_STATUS             Status = AE_OK;
  85     void                    *LogicalAddrPtr = NULL;
  86     ACPI_MEM_SPACE_CONTEXT  *MemInfo = RegionContext;
  87     UINT32                  Length;
  88     ACPI_SIZE               MapLength;
  89     ACPI_SIZE               PageBoundaryMapLength;
  90 #ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
  91     UINT32                  Remainder;
  92 #endif
  93 
  94 
  95     ACPI_FUNCTION_TRACE (ExSystemMemorySpaceHandler);
  96 
  97 
  98     /* Validate and translate the bit width */
  99 
 100     switch (BitWidth)
 101     {
 102     case 8:

 103         Length = 1;
 104         break;
 105 
 106     case 16:

 107         Length = 2;
 108         break;
 109 
 110     case 32:

 111         Length = 4;
 112         break;
 113 
 114     case 64:

 115         Length = 8;
 116         break;
 117 
 118     default:

 119         ACPI_ERROR ((AE_INFO, "Invalid SystemMemory width %u",
 120             BitWidth));
 121         return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
 122     }
 123 
 124 #ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
 125     /*
 126      * Hardware does not support non-aligned data transfers, we must verify
 127      * the request.
 128      */
 129     (void) AcpiUtShortDivide ((UINT64) Address, Length, NULL, &Remainder);
 130     if (Remainder != 0)
 131     {
 132         return_ACPI_STATUS (AE_AML_ALIGNMENT);
 133     }
 134 #endif
 135 
 136     /*
 137      * Does the request fit into the cached memory mapping?
 138      * Is 1) Address below the current mapping? OR


 215     ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
 216         "System-Memory (width %u) R/W %u Address=%8.8X%8.8X\n",
 217         BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address)));
 218 
 219     /*
 220      * Perform the memory read or write
 221      *
 222      * 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
 224      * transfer up into smaller (byte-size) chunks because the AML specifically
 225      * asked for a transfer width that the hardware may require.
 226      */
 227     switch (Function)
 228     {
 229     case ACPI_READ:
 230 
 231         *Value = 0;
 232         switch (BitWidth)
 233         {
 234         case 8:

 235             *Value = (UINT64) ACPI_GET8 (LogicalAddrPtr);
 236             break;
 237 
 238         case 16:

 239             *Value = (UINT64) ACPI_GET16 (LogicalAddrPtr);
 240             break;
 241 
 242         case 32:

 243             *Value = (UINT64) ACPI_GET32 (LogicalAddrPtr);
 244             break;
 245 
 246         case 64:

 247             *Value = (UINT64) ACPI_GET64 (LogicalAddrPtr);
 248             break;
 249 
 250         default:

 251             /* BitWidth was already validated */

 252             break;
 253         }
 254         break;
 255 
 256     case ACPI_WRITE:
 257 
 258         switch (BitWidth)
 259         {
 260         case 8:
 261             ACPI_SET8 (LogicalAddrPtr) = (UINT8) *Value;

 262             break;
 263 
 264         case 16:
 265             ACPI_SET16 (LogicalAddrPtr) = (UINT16) *Value;

 266             break;
 267 
 268         case 32:
 269             ACPI_SET32 ( LogicalAddrPtr) = (UINT32) *Value;

 270             break;
 271 
 272         case 64:
 273             ACPI_SET64 (LogicalAddrPtr) = (UINT64) *Value;

 274             break;
 275 
 276         default:

 277             /* BitWidth was already validated */

 278             break;
 279         }
 280         break;
 281 
 282     default:

 283         Status = AE_BAD_PARAMETER;
 284         break;
 285     }
 286 
 287     return_ACPI_STATUS (Status);
 288 }
 289 
 290 
 291 /*******************************************************************************
 292  *
 293  * FUNCTION:    AcpiExSystemIoSpaceHandler
 294  *
 295  * PARAMETERS:  Function            - Read or Write operation
 296  *              Address             - Where in the space to read or write
 297  *              BitWidth            - Field width in bits (8, 16, or 32)
 298  *              Value               - Pointer to in or out value
 299  *              HandlerContext      - Pointer to Handler's context
 300  *              RegionContext       - Pointer to context specific to the
 301  *                                    accessed region
 302  *


 327         BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address)));
 328 
 329     /* Decode the function parameter */
 330 
 331     switch (Function)
 332     {
 333     case ACPI_READ:
 334 
 335         Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) Address,
 336                     &Value32, BitWidth);
 337         *Value = Value32;
 338         break;
 339 
 340     case ACPI_WRITE:
 341 
 342         Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) Address,
 343                     (UINT32) *Value, BitWidth);
 344         break;
 345 
 346     default:

 347         Status = AE_BAD_PARAMETER;
 348         break;
 349     }
 350 
 351     return_ACPI_STATUS (Status);
 352 }
 353 
 354 
 355 /*******************************************************************************
 356  *
 357  * FUNCTION:    AcpiExPciConfigSpaceHandler
 358  *
 359  * PARAMETERS:  Function            - Read or Write operation
 360  *              Address             - Where in the space to read or write
 361  *              BitWidth            - Field width in bits (8, 16, or 32)
 362  *              Value               - Pointer to in or out value
 363  *              HandlerContext      - Pointer to Handler's context
 364  *              RegionContext       - Pointer to context specific to the
 365  *                                    accessed region
 366  *


 544     {
 545     case ACPI_READ:
 546 
 547         ACPI_MEMCPY (ACPI_CAST_PTR (char, Value), ACPI_PHYSADDR_TO_PTR (Address),
 548             ACPI_DIV_8 (BitWidth));
 549         break;
 550 
 551     case ACPI_WRITE:
 552 
 553         ACPI_MEMCPY (ACPI_PHYSADDR_TO_PTR (Address), ACPI_CAST_PTR (char, Value),
 554             ACPI_DIV_8 (BitWidth));
 555         break;
 556 
 557     default:
 558 
 559         return_ACPI_STATUS (AE_BAD_PARAMETER);
 560     }
 561 
 562     return_ACPI_STATUS (AE_OK);
 563 }
 564 
 565 

   1 /******************************************************************************
   2  *
   3  * Module Name: exregion - ACPI default OpRegion (address space) handlers
   4  *
   5  *****************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2014, Intel Corp.
   9  * All rights reserved.
  10  *
  11  * Redistribution and use in source and binary forms, with or without
  12  * modification, are permitted provided that the following conditions
  13  * are met:
  14  * 1. Redistributions of source code must retain the above copyright
  15  *    notice, this list of conditions, and the following disclaimer,
  16  *    without modification.
  17  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
  18  *    substantially similar to the "NO WARRANTY" disclaimer below
  19  *    ("Disclaimer") and any redistribution must be conditioned upon
  20  *    including a substantially similar Disclaimer requirement for further
  21  *    binary redistribution.
  22  * 3. Neither the names of the above-listed copyright holders nor the names
  23  *    of any contributors may be used to endorse or promote products derived
  24  *    from this software without specific prior written permission.
  25  *
  26  * Alternatively, this software may be distributed under the terms of the
  27  * GNU General Public License ("GPL") version 2 as published by the Free
  28  * Software Foundation.


  82 {
  83     ACPI_STATUS             Status = AE_OK;
  84     void                    *LogicalAddrPtr = NULL;
  85     ACPI_MEM_SPACE_CONTEXT  *MemInfo = RegionContext;
  86     UINT32                  Length;
  87     ACPI_SIZE               MapLength;
  88     ACPI_SIZE               PageBoundaryMapLength;
  89 #ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
  90     UINT32                  Remainder;
  91 #endif
  92 
  93 
  94     ACPI_FUNCTION_TRACE (ExSystemMemorySpaceHandler);
  95 
  96 
  97     /* Validate and translate the bit width */
  98 
  99     switch (BitWidth)
 100     {
 101     case 8:
 102 
 103         Length = 1;
 104         break;
 105 
 106     case 16:
 107 
 108         Length = 2;
 109         break;
 110 
 111     case 32:
 112 
 113         Length = 4;
 114         break;
 115 
 116     case 64:
 117 
 118         Length = 8;
 119         break;
 120 
 121     default:
 122 
 123         ACPI_ERROR ((AE_INFO, "Invalid SystemMemory width %u",
 124             BitWidth));
 125         return_ACPI_STATUS (AE_AML_OPERAND_VALUE);
 126     }
 127 
 128 #ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
 129     /*
 130      * Hardware does not support non-aligned data transfers, we must verify
 131      * the request.
 132      */
 133     (void) AcpiUtShortDivide ((UINT64) Address, Length, NULL, &Remainder);
 134     if (Remainder != 0)
 135     {
 136         return_ACPI_STATUS (AE_AML_ALIGNMENT);
 137     }
 138 #endif
 139 
 140     /*
 141      * Does the request fit into the cached memory mapping?
 142      * Is 1) Address below the current mapping? OR


 219     ACPI_DEBUG_PRINT ((ACPI_DB_INFO,
 220         "System-Memory (width %u) R/W %u Address=%8.8X%8.8X\n",
 221         BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address)));
 222 
 223     /*
 224      * Perform the memory read or write
 225      *
 226      * Note: For machines that do not support non-aligned transfers, the target
 227      * address was checked for alignment above. We do not attempt to break the
 228      * transfer up into smaller (byte-size) chunks because the AML specifically
 229      * asked for a transfer width that the hardware may require.
 230      */
 231     switch (Function)
 232     {
 233     case ACPI_READ:
 234 
 235         *Value = 0;
 236         switch (BitWidth)
 237         {
 238         case 8:
 239 
 240             *Value = (UINT64) ACPI_GET8 (LogicalAddrPtr);
 241             break;
 242 
 243         case 16:
 244 
 245             *Value = (UINT64) ACPI_GET16 (LogicalAddrPtr);
 246             break;
 247 
 248         case 32:
 249 
 250             *Value = (UINT64) ACPI_GET32 (LogicalAddrPtr);
 251             break;
 252 
 253         case 64:
 254 
 255             *Value = (UINT64) ACPI_GET64 (LogicalAddrPtr);
 256             break;
 257 
 258         default:
 259 
 260             /* BitWidth was already validated */
 261 
 262             break;
 263         }
 264         break;
 265 
 266     case ACPI_WRITE:
 267 
 268         switch (BitWidth)
 269         {
 270         case 8:
 271 
 272             ACPI_SET8 (LogicalAddrPtr, *Value);
 273             break;
 274 
 275         case 16:
 276 
 277             ACPI_SET16 (LogicalAddrPtr, *Value);
 278             break;
 279 
 280         case 32:
 281 
 282             ACPI_SET32 (LogicalAddrPtr, *Value);
 283             break;
 284 
 285         case 64:
 286 
 287             ACPI_SET64 (LogicalAddrPtr, *Value);
 288             break;
 289 
 290         default:
 291 
 292             /* BitWidth was already validated */
 293 
 294             break;
 295         }
 296         break;
 297 
 298     default:
 299 
 300         Status = AE_BAD_PARAMETER;
 301         break;
 302     }
 303 
 304     return_ACPI_STATUS (Status);
 305 }
 306 
 307 
 308 /*******************************************************************************
 309  *
 310  * FUNCTION:    AcpiExSystemIoSpaceHandler
 311  *
 312  * PARAMETERS:  Function            - Read or Write operation
 313  *              Address             - Where in the space to read or write
 314  *              BitWidth            - Field width in bits (8, 16, or 32)
 315  *              Value               - Pointer to in or out value
 316  *              HandlerContext      - Pointer to Handler's context
 317  *              RegionContext       - Pointer to context specific to the
 318  *                                    accessed region
 319  *


 344         BitWidth, Function, ACPI_FORMAT_NATIVE_UINT (Address)));
 345 
 346     /* Decode the function parameter */
 347 
 348     switch (Function)
 349     {
 350     case ACPI_READ:
 351 
 352         Status = AcpiHwReadPort ((ACPI_IO_ADDRESS) Address,
 353                     &Value32, BitWidth);
 354         *Value = Value32;
 355         break;
 356 
 357     case ACPI_WRITE:
 358 
 359         Status = AcpiHwWritePort ((ACPI_IO_ADDRESS) Address,
 360                     (UINT32) *Value, BitWidth);
 361         break;
 362 
 363     default:
 364 
 365         Status = AE_BAD_PARAMETER;
 366         break;
 367     }
 368 
 369     return_ACPI_STATUS (Status);
 370 }
 371 
 372 
 373 /*******************************************************************************
 374  *
 375  * FUNCTION:    AcpiExPciConfigSpaceHandler
 376  *
 377  * PARAMETERS:  Function            - Read or Write operation
 378  *              Address             - Where in the space to read or write
 379  *              BitWidth            - Field width in bits (8, 16, or 32)
 380  *              Value               - Pointer to in or out value
 381  *              HandlerContext      - Pointer to Handler's context
 382  *              RegionContext       - Pointer to context specific to the
 383  *                                    accessed region
 384  *


 562     {
 563     case ACPI_READ:
 564 
 565         ACPI_MEMCPY (ACPI_CAST_PTR (char, Value), ACPI_PHYSADDR_TO_PTR (Address),
 566             ACPI_DIV_8 (BitWidth));
 567         break;
 568 
 569     case ACPI_WRITE:
 570 
 571         ACPI_MEMCPY (ACPI_PHYSADDR_TO_PTR (Address), ACPI_CAST_PTR (char, Value),
 572             ACPI_DIV_8 (BitWidth));
 573         break;
 574 
 575     default:
 576 
 577         return_ACPI_STATUS (AE_BAD_PARAMETER);
 578     }
 579 
 580     return_ACPI_STATUS (AE_OK);
 581 }