Print this page
update to acpica-unix2-20140114
acpica-unix2-20130823
PANKOVs restructure
   1 /*******************************************************************************
   2  *
   3  * Module Name: dbutils - AML debugger utilities
   4  *
   5  ******************************************************************************/
   6 
   7 /*
   8  * Copyright (C) 2000 - 2011, 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.


  68 
  69 static char                 *Converter = "0123456789ABCDEF";
  70 
  71 
  72 /*******************************************************************************
  73  *
  74  * FUNCTION:    AcpiDbMatchArgument
  75  *
  76  * PARAMETERS:  UserArgument            - User command line
  77  *              Arguments               - Array of commands to match against
  78  *
  79  * RETURN:      Index into command array or ACPI_TYPE_NOT_FOUND if not found
  80  *
  81  * DESCRIPTION: Search command array for a command match
  82  *
  83  ******************************************************************************/
  84 
  85 ACPI_OBJECT_TYPE
  86 AcpiDbMatchArgument (
  87     char                    *UserArgument,
  88     ARGUMENT_INFO           *Arguments)
  89 {
  90     UINT32                  i;
  91 
  92 
  93     if (!UserArgument || UserArgument[0] == 0)
  94     {
  95         return (ACPI_TYPE_NOT_FOUND);
  96     }
  97 
  98     for (i = 0; Arguments[i].Name; i++)
  99     {
 100         if (ACPI_STRSTR (Arguments[i].Name, UserArgument) == Arguments[i].Name)
 101         {
 102             return (i);
 103         }
 104     }
 105 
 106     /* Argument not recognized */
 107 
 108     return (ACPI_TYPE_NOT_FOUND);


 162 
 163 
 164     if (!ObjDesc)
 165     {
 166         AcpiOsPrintf ("[Null Object]\n");
 167         return;
 168     }
 169 
 170     for (i = 0; i < Level; i++)
 171     {
 172         AcpiOsPrintf ("  ");
 173     }
 174 
 175     switch (ObjDesc->Type)
 176     {
 177     case ACPI_TYPE_ANY:
 178 
 179         AcpiOsPrintf ("[Null Object] (Type=0)\n");
 180         break;
 181 
 182 
 183     case ACPI_TYPE_INTEGER:
 184 
 185         AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n",
 186                     ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
 187         break;
 188 
 189 
 190     case ACPI_TYPE_STRING:
 191 
 192         AcpiOsPrintf ("[String] Length %.2X = ", ObjDesc->String.Length);
 193         for (i = 0; i < ObjDesc->String.Length; i++)
 194         {
 195             AcpiOsPrintf ("%c", ObjDesc->String.Pointer[i]);
 196         }
 197         AcpiOsPrintf ("\n");
 198         break;
 199 
 200 
 201     case ACPI_TYPE_BUFFER:
 202 
 203         AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length);
 204         if (ObjDesc->Buffer.Length)
 205         {
 206             if (ObjDesc->Buffer.Length > 16)
 207             {
 208                 AcpiOsPrintf ("\n");
 209             }
 210             AcpiUtDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer),
 211                     ObjDesc->Buffer.Length, DB_DWORD_DISPLAY, _COMPONENT);
 212         }
 213         else
 214         {
 215             AcpiOsPrintf ("\n");
 216         }
 217         break;
 218 
 219 
 220     case ACPI_TYPE_PACKAGE:
 221 
 222         AcpiOsPrintf ("[Package] Contains %u Elements:\n",
 223                 ObjDesc->Package.Count);
 224 
 225         for (i = 0; i < ObjDesc->Package.Count; i++)
 226         {
 227             AcpiDbDumpExternalObject (&ObjDesc->Package.Elements[i], Level+1);
 228         }
 229         break;
 230 
 231 
 232     case ACPI_TYPE_LOCAL_REFERENCE:
 233 
 234         AcpiOsPrintf ("[Object Reference] = ");
 235         AcpiDmDisplayInternalObject (ObjDesc->Reference.Handle, NULL);
 236         break;
 237 
 238 
 239     case ACPI_TYPE_PROCESSOR:
 240 
 241         AcpiOsPrintf ("[Processor]\n");
 242         break;
 243 
 244 
 245     case ACPI_TYPE_POWER:
 246 
 247         AcpiOsPrintf ("[Power Resource]\n");
 248         break;
 249 
 250 
 251     default:
 252 
 253         AcpiOsPrintf ("[Unknown Type] %X\n", ObjDesc->Type);
 254         break;
 255     }
 256 }
 257 
 258 
 259 /*******************************************************************************
 260  *
 261  * FUNCTION:    AcpiDbPrepNamestring
 262  *
 263  * PARAMETERS:  Name            - String to prepare
 264  *
 265  * RETURN:      None
 266  *
 267  * DESCRIPTION: Translate all forward slashes and dots to backslashes.
 268  *
 269  ******************************************************************************/
 270 


 272 AcpiDbPrepNamestring (
 273     char                    *Name)
 274 {
 275 
 276     if (!Name)
 277     {
 278         return;
 279     }
 280 
 281     AcpiUtStrupr (Name);
 282 
 283     /* Convert a leading forward slash to a backslash */
 284 
 285     if (*Name == '/')
 286     {
 287         *Name = '\\';
 288     }
 289 
 290     /* Ignore a leading backslash, this is the root prefix */
 291 
 292     if (*Name == '\\')
 293     {
 294         Name++;
 295     }
 296 
 297     /* Convert all slash path separators to dots */
 298 
 299     while (*Name)
 300     {
 301         if ((*Name == '/') ||
 302             (*Name == '\\'))
 303         {
 304             *Name = '.';
 305         }
 306 
 307         Name++;
 308     }
 309 }
 310 
 311 
 312 /*******************************************************************************


 346 
 347     /*
 348      * Lookup the name.
 349      * (Uses root node as the search starting point)
 350      */
 351     Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
 352                     ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node);
 353     if (ACPI_FAILURE (Status))
 354     {
 355         AcpiOsPrintf ("Could not locate name: %s, %s\n",
 356                 Name, AcpiFormatException (Status));
 357     }
 358 
 359     ACPI_FREE (InternalPath);
 360     return (Node);
 361 }
 362 
 363 
 364 /*******************************************************************************
 365  *
 366  * FUNCTION:    AcpiDbUInt32ToHexString
 367  *
 368  * PARAMETERS:  Value           - The value to be converted to string
 369  *              Buffer          - Buffer for result (not less than 11 bytes)
 370  *
 371  * RETURN:      None
 372  *
 373  * DESCRIPTION: Convert the unsigned 32-bit value to the hexadecimal image
 374  *
 375  * NOTE: It is the caller's responsibility to ensure that the length of buffer
 376  *       is sufficient.
 377  *
 378  ******************************************************************************/
 379 
 380 void
 381 AcpiDbUInt32ToHexString (
 382     UINT32                  Value,
 383     char                    *Buffer)
 384 {
 385     int                     i;
 386 
 387 
 388     if (Value == 0)
 389     {
 390         ACPI_STRCPY (Buffer, "0");
 391         return;
 392     }
 393 
 394     Buffer[8] = '\0';
 395 
 396     for (i = 7; i >= 0; i--)
 397     {
 398         Buffer[i] = Converter [Value & 0x0F];
 399         Value = Value >> 4;
 400     }
 401 }


 499 /*******************************************************************************
 500  *
 501  * FUNCTION:    AcpiDbDumpBuffer
 502  *
 503  * PARAMETERS:  Address             - Pointer to the buffer
 504  *
 505  * RETURN:      None
 506  *
 507  * DESCRIPTION: Print a portion of a buffer
 508  *
 509  ******************************************************************************/
 510 
 511 void
 512 AcpiDbDumpBuffer (
 513     UINT32                  Address)
 514 {
 515 
 516     AcpiOsPrintf ("\nLocation %X:\n", Address);
 517 
 518     AcpiDbgLevel |= ACPI_LV_TABLES;
 519     AcpiUtDumpBuffer (ACPI_TO_POINTER (Address), 64, DB_BYTE_DISPLAY,
 520             ACPI_UINT32_MAX);
 521 }
 522 #endif
 523 
 524 #endif /* ACPI_DEBUGGER */
 525 
 526 
   1 /*******************************************************************************
   2  *
   3  * Module Name: dbutils - AML debugger 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.


  68 
  69 static char                 *Converter = "0123456789ABCDEF";
  70 
  71 
  72 /*******************************************************************************
  73  *
  74  * FUNCTION:    AcpiDbMatchArgument
  75  *
  76  * PARAMETERS:  UserArgument            - User command line
  77  *              Arguments               - Array of commands to match against
  78  *
  79  * RETURN:      Index into command array or ACPI_TYPE_NOT_FOUND if not found
  80  *
  81  * DESCRIPTION: Search command array for a command match
  82  *
  83  ******************************************************************************/
  84 
  85 ACPI_OBJECT_TYPE
  86 AcpiDbMatchArgument (
  87     char                    *UserArgument,
  88     ACPI_DB_ARGUMENT_INFO   *Arguments)
  89 {
  90     UINT32                  i;
  91 
  92 
  93     if (!UserArgument || UserArgument[0] == 0)
  94     {
  95         return (ACPI_TYPE_NOT_FOUND);
  96     }
  97 
  98     for (i = 0; Arguments[i].Name; i++)
  99     {
 100         if (ACPI_STRSTR (Arguments[i].Name, UserArgument) == Arguments[i].Name)
 101         {
 102             return (i);
 103         }
 104     }
 105 
 106     /* Argument not recognized */
 107 
 108     return (ACPI_TYPE_NOT_FOUND);


 162 
 163 
 164     if (!ObjDesc)
 165     {
 166         AcpiOsPrintf ("[Null Object]\n");
 167         return;
 168     }
 169 
 170     for (i = 0; i < Level; i++)
 171     {
 172         AcpiOsPrintf ("  ");
 173     }
 174 
 175     switch (ObjDesc->Type)
 176     {
 177     case ACPI_TYPE_ANY:
 178 
 179         AcpiOsPrintf ("[Null Object] (Type=0)\n");
 180         break;
 181 

 182     case ACPI_TYPE_INTEGER:
 183 
 184         AcpiOsPrintf ("[Integer] = %8.8X%8.8X\n",
 185                     ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
 186         break;
 187 

 188     case ACPI_TYPE_STRING:
 189 
 190         AcpiOsPrintf ("[String] Length %.2X = ", ObjDesc->String.Length);
 191         AcpiUtPrintString (ObjDesc->String.Pointer, ACPI_UINT8_MAX);



 192         AcpiOsPrintf ("\n");
 193         break;
 194 

 195     case ACPI_TYPE_BUFFER:
 196 
 197         AcpiOsPrintf ("[Buffer] Length %.2X = ", ObjDesc->Buffer.Length);
 198         if (ObjDesc->Buffer.Length)
 199         {
 200             if (ObjDesc->Buffer.Length > 16)
 201             {
 202                 AcpiOsPrintf ("\n");
 203             }
 204             AcpiUtDebugDumpBuffer (ACPI_CAST_PTR (UINT8, ObjDesc->Buffer.Pointer),
 205                     ObjDesc->Buffer.Length, DB_BYTE_DISPLAY, _COMPONENT);
 206         }
 207         else
 208         {
 209             AcpiOsPrintf ("\n");
 210         }
 211         break;
 212 

 213     case ACPI_TYPE_PACKAGE:
 214 
 215         AcpiOsPrintf ("[Package] Contains %u Elements:\n",
 216                 ObjDesc->Package.Count);
 217 
 218         for (i = 0; i < ObjDesc->Package.Count; i++)
 219         {
 220             AcpiDbDumpExternalObject (&ObjDesc->Package.Elements[i], Level+1);
 221         }
 222         break;
 223 

 224     case ACPI_TYPE_LOCAL_REFERENCE:
 225 
 226         AcpiOsPrintf ("[Object Reference] = ");
 227         AcpiDmDisplayInternalObject (ObjDesc->Reference.Handle, NULL);
 228         break;
 229 

 230     case ACPI_TYPE_PROCESSOR:
 231 
 232         AcpiOsPrintf ("[Processor]\n");
 233         break;
 234 

 235     case ACPI_TYPE_POWER:
 236 
 237         AcpiOsPrintf ("[Power Resource]\n");
 238         break;
 239 

 240     default:
 241 
 242         AcpiOsPrintf ("[Unknown Type] %X\n", ObjDesc->Type);
 243         break;
 244     }
 245 }
 246 
 247 
 248 /*******************************************************************************
 249  *
 250  * FUNCTION:    AcpiDbPrepNamestring
 251  *
 252  * PARAMETERS:  Name            - String to prepare
 253  *
 254  * RETURN:      None
 255  *
 256  * DESCRIPTION: Translate all forward slashes and dots to backslashes.
 257  *
 258  ******************************************************************************/
 259 


 261 AcpiDbPrepNamestring (
 262     char                    *Name)
 263 {
 264 
 265     if (!Name)
 266     {
 267         return;
 268     }
 269 
 270     AcpiUtStrupr (Name);
 271 
 272     /* Convert a leading forward slash to a backslash */
 273 
 274     if (*Name == '/')
 275     {
 276         *Name = '\\';
 277     }
 278 
 279     /* Ignore a leading backslash, this is the root prefix */
 280 
 281     if (ACPI_IS_ROOT_PREFIX (*Name))
 282     {
 283         Name++;
 284     }
 285 
 286     /* Convert all slash path separators to dots */
 287 
 288     while (*Name)
 289     {
 290         if ((*Name == '/') ||
 291             (*Name == '\\'))
 292         {
 293             *Name = '.';
 294         }
 295 
 296         Name++;
 297     }
 298 }
 299 
 300 
 301 /*******************************************************************************


 335 
 336     /*
 337      * Lookup the name.
 338      * (Uses root node as the search starting point)
 339      */
 340     Status = AcpiNsLookup (NULL, InternalPath, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
 341                     ACPI_NS_NO_UPSEARCH | ACPI_NS_DONT_OPEN_SCOPE, NULL, &Node);
 342     if (ACPI_FAILURE (Status))
 343     {
 344         AcpiOsPrintf ("Could not locate name: %s, %s\n",
 345                 Name, AcpiFormatException (Status));
 346     }
 347 
 348     ACPI_FREE (InternalPath);
 349     return (Node);
 350 }
 351 
 352 
 353 /*******************************************************************************
 354  *
 355  * FUNCTION:    AcpiDbUint32ToHexString
 356  *
 357  * PARAMETERS:  Value           - The value to be converted to string
 358  *              Buffer          - Buffer for result (not less than 11 bytes)
 359  *
 360  * RETURN:      None
 361  *
 362  * DESCRIPTION: Convert the unsigned 32-bit value to the hexadecimal image
 363  *
 364  * NOTE: It is the caller's responsibility to ensure that the length of buffer
 365  *       is sufficient.
 366  *
 367  ******************************************************************************/
 368 
 369 void
 370 AcpiDbUint32ToHexString (
 371     UINT32                  Value,
 372     char                    *Buffer)
 373 {
 374     int                     i;
 375 
 376 
 377     if (Value == 0)
 378     {
 379         ACPI_STRCPY (Buffer, "0");
 380         return;
 381     }
 382 
 383     Buffer[8] = '\0';
 384 
 385     for (i = 7; i >= 0; i--)
 386     {
 387         Buffer[i] = Converter [Value & 0x0F];
 388         Value = Value >> 4;
 389     }
 390 }


 488 /*******************************************************************************
 489  *
 490  * FUNCTION:    AcpiDbDumpBuffer
 491  *
 492  * PARAMETERS:  Address             - Pointer to the buffer
 493  *
 494  * RETURN:      None
 495  *
 496  * DESCRIPTION: Print a portion of a buffer
 497  *
 498  ******************************************************************************/
 499 
 500 void
 501 AcpiDbDumpBuffer (
 502     UINT32                  Address)
 503 {
 504 
 505     AcpiOsPrintf ("\nLocation %X:\n", Address);
 506 
 507     AcpiDbgLevel |= ACPI_LV_TABLES;
 508     AcpiUtDebugDumpBuffer (ACPI_TO_POINTER (Address), 64, DB_BYTE_DISPLAY,
 509             ACPI_UINT32_MAX);
 510 }
 511 #endif
 512 
 513 #endif /* ACPI_DEBUGGER */