Print this page
update to acpica-unix2-20140114
acpica-unix2-20130823
PANKOVs restructure
   1 
   2 /******************************************************************************
   3  *
   4  * Module Name: exutils - interpreter/scanner utilities
   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.


 104     Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
 105     if (ACPI_FAILURE (Status))
 106     {
 107         ACPI_ERROR ((AE_INFO, "Could not acquire AML Interpreter mutex"));
 108     }
 109 
 110     return_VOID;
 111 }
 112 
 113 
 114 /*******************************************************************************
 115  *
 116  * FUNCTION:    AcpiExReacquireInterpreter
 117  *
 118  * PARAMETERS:  None
 119  *
 120  * RETURN:      None
 121  *
 122  * DESCRIPTION: Reacquire the interpreter execution region from within the
 123  *              interpreter code. Failure to enter the interpreter region is a
 124  *              fatal system error. Used in  conjuction with
 125  *              RelinquishInterpreter
 126  *
 127  ******************************************************************************/
 128 
 129 void
 130 AcpiExReacquireInterpreter (
 131     void)
 132 {
 133     ACPI_FUNCTION_TRACE (ExReacquireInterpreter);
 134 
 135 
 136     /*
 137      * If the global serialized flag is set, do not release the interpreter,
 138      * since it was not actually released by AcpiExRelinquishInterpreter.
 139      * This forces the interpreter to be single threaded.
 140      */
 141     if (!AcpiGbl_AllMethodsSerialized)
 142     {
 143         AcpiExEnterInterpreter ();
 144     }


 213 
 214     /*
 215      * If the global serialized flag is set, do not release the interpreter.
 216      * This forces the interpreter to be single threaded.
 217      */
 218     if (!AcpiGbl_AllMethodsSerialized)
 219     {
 220         AcpiExExitInterpreter ();
 221     }
 222 
 223     return_VOID;
 224 }
 225 
 226 
 227 /*******************************************************************************
 228  *
 229  * FUNCTION:    AcpiExTruncateFor32bitTable
 230  *
 231  * PARAMETERS:  ObjDesc         - Object to be truncated
 232  *
 233  * RETURN:      none
 234  *
 235  * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is
 236  *              32-bit, as determined by the revision of the DSDT.
 237  *
 238  ******************************************************************************/
 239 
 240 void
 241 AcpiExTruncateFor32bitTable (
 242     ACPI_OPERAND_OBJECT     *ObjDesc)
 243 {
 244 
 245     ACPI_FUNCTION_ENTRY ();
 246 
 247 
 248     /*
 249      * Object must be a valid number and we must be executing
 250      * a control method. NS node could be there for AML_INT_NAMEPATH_OP.
 251      */
 252     if ((!ObjDesc) ||
 253         (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) ||
 254         (ObjDesc->Common.Type != ACPI_TYPE_INTEGER))
 255     {
 256         return;
 257     }
 258 
 259     if (AcpiGbl_IntegerByteWidth == 4)

 260     {
 261         /*
 262          * We are running a method that exists in a 32-bit ACPI table.
 263          * Truncate the value to 32 bits by zeroing out the upper 32-bit field
 264          */
 265         ObjDesc->Integer.Value &= (UINT64) ACPI_UINT32_MAX;

 266     }


 267 }
 268 
 269 
 270 /*******************************************************************************
 271  *
 272  * FUNCTION:    AcpiExAcquireGlobalLock
 273  *
 274  * PARAMETERS:  FieldFlags            - Flags with Lock rule:
 275  *                                      AlwaysLock or NeverLock
 276  *
 277  * RETURN:      None
 278  *
 279  * DESCRIPTION: Obtain the ACPI hardware Global Lock, only if the field
 280  *              flags specifiy that it is to be obtained before field access.
 281  *
 282  ******************************************************************************/
 283 
 284 void
 285 AcpiExAcquireGlobalLock (
 286     UINT32                  FieldFlags)


 482     UINT64                  Value)
 483 {
 484     UINT32                  Count;
 485     UINT32                  DigitsNeeded;
 486     UINT32                  Remainder;
 487 
 488 
 489     ACPI_FUNCTION_ENTRY ();
 490 
 491 
 492     DigitsNeeded = AcpiExDigitsNeeded (Value, 10);
 493     OutString[DigitsNeeded] = 0;
 494 
 495     for (Count = DigitsNeeded; Count > 0; Count--)
 496     {
 497         (void) AcpiUtShortDivide (Value, 10, &Value, &Remainder);
 498         OutString[Count-1] = (char) ('0' + Remainder);\
 499     }
 500 }
 501 






























 502 #endif

   1 /******************************************************************************
   2  *
   3  * Module Name: exutils - interpreter/scanner utilities
   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.


 103     Status = AcpiUtAcquireMutex (ACPI_MTX_INTERPRETER);
 104     if (ACPI_FAILURE (Status))
 105     {
 106         ACPI_ERROR ((AE_INFO, "Could not acquire AML Interpreter mutex"));
 107     }
 108 
 109     return_VOID;
 110 }
 111 
 112 
 113 /*******************************************************************************
 114  *
 115  * FUNCTION:    AcpiExReacquireInterpreter
 116  *
 117  * PARAMETERS:  None
 118  *
 119  * RETURN:      None
 120  *
 121  * DESCRIPTION: Reacquire the interpreter execution region from within the
 122  *              interpreter code. Failure to enter the interpreter region is a
 123  *              fatal system error. Used in conjunction with
 124  *              RelinquishInterpreter
 125  *
 126  ******************************************************************************/
 127 
 128 void
 129 AcpiExReacquireInterpreter (
 130     void)
 131 {
 132     ACPI_FUNCTION_TRACE (ExReacquireInterpreter);
 133 
 134 
 135     /*
 136      * If the global serialized flag is set, do not release the interpreter,
 137      * since it was not actually released by AcpiExRelinquishInterpreter.
 138      * This forces the interpreter to be single threaded.
 139      */
 140     if (!AcpiGbl_AllMethodsSerialized)
 141     {
 142         AcpiExEnterInterpreter ();
 143     }


 212 
 213     /*
 214      * If the global serialized flag is set, do not release the interpreter.
 215      * This forces the interpreter to be single threaded.
 216      */
 217     if (!AcpiGbl_AllMethodsSerialized)
 218     {
 219         AcpiExExitInterpreter ();
 220     }
 221 
 222     return_VOID;
 223 }
 224 
 225 
 226 /*******************************************************************************
 227  *
 228  * FUNCTION:    AcpiExTruncateFor32bitTable
 229  *
 230  * PARAMETERS:  ObjDesc         - Object to be truncated
 231  *
 232  * RETURN:      TRUE if a truncation was performed, FALSE otherwise.
 233  *
 234  * DESCRIPTION: Truncate an ACPI Integer to 32 bits if the execution mode is
 235  *              32-bit, as determined by the revision of the DSDT.
 236  *
 237  ******************************************************************************/
 238 
 239 BOOLEAN
 240 AcpiExTruncateFor32bitTable (
 241     ACPI_OPERAND_OBJECT     *ObjDesc)
 242 {
 243 
 244     ACPI_FUNCTION_ENTRY ();
 245 
 246 
 247     /*
 248      * Object must be a valid number and we must be executing
 249      * a control method. Object could be NS node for AML_INT_NAMEPATH_OP.
 250      */
 251     if ((!ObjDesc) ||
 252         (ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) != ACPI_DESC_TYPE_OPERAND) ||
 253         (ObjDesc->Common.Type != ACPI_TYPE_INTEGER))
 254     {
 255         return (FALSE);
 256     }
 257 
 258     if ((AcpiGbl_IntegerByteWidth == 4) &&
 259         (ObjDesc->Integer.Value > (UINT64) ACPI_UINT32_MAX))
 260     {
 261         /*
 262          * We are executing in a 32-bit ACPI table.
 263          * Truncate the value to 32 bits by zeroing out the upper 32-bit field
 264          */
 265         ObjDesc->Integer.Value &= (UINT64) ACPI_UINT32_MAX;
 266         return (TRUE);
 267     }
 268 
 269     return (FALSE);
 270 }
 271 
 272 
 273 /*******************************************************************************
 274  *
 275  * FUNCTION:    AcpiExAcquireGlobalLock
 276  *
 277  * PARAMETERS:  FieldFlags            - Flags with Lock rule:
 278  *                                      AlwaysLock or NeverLock
 279  *
 280  * RETURN:      None
 281  *
 282  * DESCRIPTION: Obtain the ACPI hardware Global Lock, only if the field
 283  *              flags specifiy that it is to be obtained before field access.
 284  *
 285  ******************************************************************************/
 286 
 287 void
 288 AcpiExAcquireGlobalLock (
 289     UINT32                  FieldFlags)


 485     UINT64                  Value)
 486 {
 487     UINT32                  Count;
 488     UINT32                  DigitsNeeded;
 489     UINT32                  Remainder;
 490 
 491 
 492     ACPI_FUNCTION_ENTRY ();
 493 
 494 
 495     DigitsNeeded = AcpiExDigitsNeeded (Value, 10);
 496     OutString[DigitsNeeded] = 0;
 497 
 498     for (Count = DigitsNeeded; Count > 0; Count--)
 499     {
 500         (void) AcpiUtShortDivide (Value, 10, &Value, &Remainder);
 501         OutString[Count-1] = (char) ('0' + Remainder);\
 502     }
 503 }
 504 
 505 
 506 /*******************************************************************************
 507  *
 508  * FUNCTION:    AcpiIsValidSpaceId
 509  *
 510  * PARAMETERS:  SpaceId             - ID to be validated
 511  *
 512  * RETURN:      TRUE if valid/supported ID.
 513  *
 514  * DESCRIPTION: Validate an operation region SpaceID.
 515  *
 516  ******************************************************************************/
 517 
 518 BOOLEAN
 519 AcpiIsValidSpaceId (
 520     UINT8                   SpaceId)
 521 {
 522 
 523     if ((SpaceId >= ACPI_NUM_PREDEFINED_REGIONS) &&
 524         (SpaceId < ACPI_USER_REGION_BEGIN) &&
 525         (SpaceId != ACPI_ADR_SPACE_DATA_TABLE) &&
 526         (SpaceId != ACPI_ADR_SPACE_FIXED_HARDWARE))
 527     {
 528         return (FALSE);
 529     }
 530 
 531     return (TRUE);
 532 }
 533 
 534 
 535 #endif