void
AcpiDmEmitExternals (
void)
{
ACPI_EXTERNAL_LIST *NextExternal;
if (!AcpiGbl_ExternalList)
{
return;
}
/*
* Determine the number of control methods in the external list, and
* also how many of those externals were resolved via the namespace.
*/
NextExternal = AcpiGbl_ExternalList;
while (NextExternal)
{
if (NextExternal->Type == ACPI_TYPE_METHOD)
{
AcpiGbl_NumExternalMethods++;
if (NextExternal->Flags & ACPI_EXT_RESOLVED_REFERENCE)
{
AcpiGbl_ResolvedExternalMethods++;
}
}
NextExternal = NextExternal->Next;
}
/* Check if any control methods were unresolved */
AcpiDmUnresolvedWarning (1);
/* Emit any unresolved method externals in a single text block */
NextExternal = AcpiGbl_ExternalList;
while (NextExternal)
{
if ((NextExternal->Type == ACPI_TYPE_METHOD) &&
(!(NextExternal->Flags & ACPI_EXT_RESOLVED_REFERENCE)))
{
AcpiOsPrintf (" External (%s%s",
NextExternal->Path,
AcpiDmGetObjectTypeName (NextExternal->Type));
AcpiOsPrintf (") // Warning: Unresolved method, "
"guessing %u arguments\n",
NextExternal->Value);
NextExternal->Flags |= ACPI_EXT_EXTERNAL_EMITTED;
}
NextExternal = NextExternal->Next;
}
AcpiOsPrintf ("\n");
/* Emit externals that were imported from a file */
if (Gbl_ExternalRefFilename)
{
AcpiOsPrintf (
" /*\n * External declarations that were imported from\n"
" * the reference file [%s]\n */\n",
Gbl_ExternalRefFilename);
NextExternal = AcpiGbl_ExternalList;
while (NextExternal)
{
if (!(NextExternal->Flags & ACPI_EXT_EXTERNAL_EMITTED) &&
(NextExternal->Flags & ACPI_EXT_ORIGIN_FROM_FILE))
{
AcpiOsPrintf (" External (%s%s",
NextExternal->Path,
AcpiDmGetObjectTypeName (NextExternal->Type));
if (NextExternal->Type == ACPI_TYPE_METHOD)
{
AcpiOsPrintf (") // %u Arguments\n",
NextExternal->Value);
}
else
{
AcpiOsPrintf (")\n");
}
NextExternal->Flags |= ACPI_EXT_EXTERNAL_EMITTED;
}
NextExternal = NextExternal->Next;
}
AcpiOsPrintf ("\n");
}
/*
* Walk the list of externals found during the AML parsing
*/
//.........这里部分代码省略.........
ACPI_STATUS
AdGetLocalTables (
char *Filename,
BOOLEAN GetAllTables)
{
ACPI_STATUS Status;
ACPI_TABLE_HEADER TableHeader;
ACPI_TABLE_HEADER *NewTable;
UINT32 NumTables;
UINT32 PointerSize;
UINT32 TableIndex;
if (GetAllTables)
{
ACPI_MOVE_32_TO_32 (TableHeader.Signature, ACPI_SIG_RSDT);
AcpiOsTableOverride (&TableHeader, &NewTable);
if (!NewTable)
{
fprintf (stderr, "Could not obtain RSDT\n");
return AE_NO_ACPI_TABLES;
}
else
{
AdWriteTable (NewTable, NewTable->Length,
ACPI_SIG_RSDT, NewTable->OemTableId);
}
if (ACPI_COMPARE_NAME (NewTable->Signature, ACPI_SIG_RSDT))
{
PointerSize = sizeof (UINT32);
}
else
{
PointerSize = sizeof (UINT64);
}
/*
* Determine the number of tables pointed to by the RSDT/XSDT.
* This is defined by the ACPI Specification to be the number of
* pointers contained within the RSDT/XSDT. The size of the pointers
* is architecture-dependent.
*/
NumTables = (NewTable->Length - sizeof (ACPI_TABLE_HEADER)) / PointerSize;
AcpiOsPrintf ("There are %u tables defined in the %4.4s\n\n",
NumTables, NewTable->Signature);
/* Get the FADT */
ACPI_MOVE_32_TO_32 (TableHeader.Signature, ACPI_SIG_FADT);
AcpiOsTableOverride (&TableHeader, &NewTable);
if (NewTable)
{
AdWriteTable (NewTable, NewTable->Length,
ACPI_SIG_FADT, NewTable->OemTableId);
}
AcpiOsPrintf ("\n");
/* Don't bother with FACS, it is usually all zeros */
}
/* Always get the DSDT */
ACPI_MOVE_32_TO_32 (TableHeader.Signature, ACPI_SIG_DSDT);
AcpiOsTableOverride (&TableHeader, &NewTable);
if (NewTable)
{
AdWriteTable (NewTable, NewTable->Length,
ACPI_SIG_DSDT, NewTable->OemTableId);
/* Store DSDT in the Table Manager */
Status = AcpiTbStoreTable (0, NewTable, NewTable->Length,
0, &TableIndex);
if (ACPI_FAILURE (Status))
{
fprintf (stderr, "Could not store DSDT\n");
return AE_NO_ACPI_TABLES;
}
}
else
{
fprintf (stderr, "Could not obtain DSDT\n");
return AE_NO_ACPI_TABLES;
}
#if 0
/* TBD: Future implementation */
AcpiOsPrintf ("\n");
/* Get all SSDTs */
ACPI_MOVE_32_TO_32 (TableHeader.Signature, ACPI_SIG_SSDT);
do
{
NewTable = NULL;
Status = AcpiOsTableOverride (&TableHeader, &NewTable);
} while (NewTable);
//.........这里部分代码省略.........
static ACPI_STATUS
AcpiDbTestBufferType (
ACPI_NAMESPACE_NODE *Node,
UINT32 BitLength)
{
ACPI_OBJECT *Temp1 = NULL;
ACPI_OBJECT *Temp2 = NULL;
ACPI_OBJECT *Temp3 = NULL;
UINT8 *Buffer;
ACPI_OBJECT WriteValue;
ACPI_STATUS Status;
UINT32 ByteLength;
UINT32 i;
UINT8 ExtraBits;
ByteLength = ACPI_ROUND_BITS_UP_TO_BYTES (BitLength);
if (ByteLength == 0)
{
AcpiOsPrintf (" Ignoring zero length buffer");
return (AE_OK);
}
/* Allocate a local buffer */
Buffer = ACPI_ALLOCATE_ZEROED (ByteLength);
if (!Buffer)
{
return (AE_NO_MEMORY);
}
/* Read the original value */
Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp1);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
/* Emit a few bytes of the buffer */
AcpiOsPrintf (" (%4.4X/%3.3X)", BitLength, Temp1->Buffer.Length);
for (i = 0; ((i < 4) && (i < ByteLength)); i++)
{
AcpiOsPrintf (" %2.2X", Temp1->Buffer.Pointer[i]);
}
AcpiOsPrintf ("... ");
/*
* Write a new value.
*
* Handle possible extra bits at the end of the buffer. Can
* happen for FieldUnits larger than an integer, but the bit
* count is not an integral number of bytes. Zero out the
* unused bits.
*/
memset (Buffer, BUFFER_FILL_VALUE, ByteLength);
ExtraBits = BitLength % 8;
if (ExtraBits)
{
Buffer [ByteLength - 1] = ACPI_MASK_BITS_ABOVE (ExtraBits);
}
WriteValue.Type = ACPI_TYPE_BUFFER;
WriteValue.Buffer.Length = ByteLength;
WriteValue.Buffer.Pointer = Buffer;
Status = AcpiDbWriteToObject (Node, &WriteValue);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
/* Ensure that we can read back the new value */
Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp2);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
if (memcmp (Temp2->Buffer.Pointer, Buffer, ByteLength))
{
AcpiOsPrintf (" MISMATCH 2: New buffer value");
}
/* Write back the original value */
WriteValue.Buffer.Length = ByteLength;
WriteValue.Buffer.Pointer = Temp1->Buffer.Pointer;
Status = AcpiDbWriteToObject (Node, &WriteValue);
if (ACPI_FAILURE (Status))
{
goto Exit;
}
/* Ensure that we can read back the original value */
Status = AcpiDbReadFromObject (Node, ACPI_TYPE_BUFFER, &Temp3);
//.........这里部分代码省略.........
static ACPI_STATUS
AcpiDbTestOneObject (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue)
{
ACPI_NAMESPACE_NODE *Node;
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_OPERAND_OBJECT *RegionObj;
ACPI_OBJECT_TYPE LocalType;
UINT32 BitLength = 0;
UINT32 ByteLength = 0;
ACPI_STATUS Status = AE_OK;
Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
ObjDesc = Node->Object;
/*
* For the supported types, get the actual bit length or
* byte length. Map the type to one of Integer/String/Buffer.
*/
switch (Node->Type)
{
case ACPI_TYPE_INTEGER:
/* Integer width is either 32 or 64 */
LocalType = ACPI_TYPE_INTEGER;
BitLength = AcpiGbl_IntegerBitWidth;
break;
case ACPI_TYPE_STRING:
LocalType = ACPI_TYPE_STRING;
ByteLength = ObjDesc->String.Length;
break;
case ACPI_TYPE_BUFFER:
LocalType = ACPI_TYPE_BUFFER;
ByteLength = ObjDesc->Buffer.Length;
BitLength = ByteLength * 8;
break;
case ACPI_TYPE_FIELD_UNIT:
case ACPI_TYPE_BUFFER_FIELD:
case ACPI_TYPE_LOCAL_REGION_FIELD:
case ACPI_TYPE_LOCAL_INDEX_FIELD:
case ACPI_TYPE_LOCAL_BANK_FIELD:
LocalType = ACPI_TYPE_INTEGER;
if (ObjDesc)
{
/*
* Returned object will be a Buffer if the field length
* is larger than the size of an Integer (32 or 64 bits
* depending on the DSDT version).
*/
BitLength = ObjDesc->CommonField.BitLength;
ByteLength = ACPI_ROUND_BITS_UP_TO_BYTES (BitLength);
if (BitLength > AcpiGbl_IntegerBitWidth)
{
LocalType = ACPI_TYPE_BUFFER;
}
}
break;
default:
/* Ignore all other types */
return (AE_OK);
}
/* Emit the common prefix: Type:Name */
AcpiOsPrintf ("%14s: %4.4s",
AcpiUtGetTypeName (Node->Type), Node->Name.Ascii);
if (!ObjDesc)
{
AcpiOsPrintf (" Ignoring, no attached object\n");
return (AE_OK);
}
/*
* Check for unsupported region types. Note: AcpiExec simulates
* access to SystemMemory, SystemIO, PCI_Config, and EC.
*/
switch (Node->Type)
{
case ACPI_TYPE_LOCAL_REGION_FIELD:
RegionObj = ObjDesc->Field.RegionObj;
switch (RegionObj->Region.SpaceId)
{
case ACPI_ADR_SPACE_SYSTEM_MEMORY:
case ACPI_ADR_SPACE_SYSTEM_IO:
case ACPI_ADR_SPACE_PCI_CONFIG:
//.........这里部分代码省略.........
//.........这里部分代码省略.........
/* Get the object info for number of method parameters */
Status = AcpiGetObjectInfo (ObjHandle, &ObjInfo);
if (ACPI_FAILURE (Status))
{
ACPI_FREE (Pathname);
return (Status);
}
ParamObjects.Count = 0;
ParamObjects.Pointer = NULL;
if (ObjInfo->Type == ACPI_TYPE_METHOD)
{
/* Setup default parameters (with proper types) */
ArgTypeList = Predefined->Info.ArgumentList;
ArgCount = METHOD_GET_ARG_COUNT (ArgTypeList);
/*
* Setup the ACPI-required number of arguments, regardless of what
* the actual method defines. If there is a difference, then the
* method is wrong and a warning will be issued during execution.
*/
ThisParam = Params;
for (i = 0; i < ArgCount; i++)
{
ArgType = METHOD_GET_NEXT_TYPE (ArgTypeList);
ThisParam->Type = ArgType;
switch (ArgType)
{
case ACPI_TYPE_INTEGER:
ThisParam->Integer.Value = 1;
break;
case ACPI_TYPE_STRING:
ThisParam->String.Pointer =
"This is the default argument string";
ThisParam->String.Length =
strlen (ThisParam->String.Pointer);
break;
case ACPI_TYPE_BUFFER:
ThisParam->Buffer.Pointer = (UINT8 *) Params; /* just a garbage buffer */
ThisParam->Buffer.Length = 48;
break;
case ACPI_TYPE_PACKAGE:
ThisParam->Package.Elements = NULL;
ThisParam->Package.Count = 0;
break;
default:
AcpiOsPrintf ("%s: Unsupported argument type: %u\n",
Pathname, ArgType);
break;
}
ThisParam++;
}
ParamObjects.Count = ArgCount;
ParamObjects.Pointer = Params;
}
ACPI_FREE (ObjInfo);
ReturnObj.Pointer = NULL;
ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
/* Do the actual method execution */
AcpiGbl_MethodExecuting = TRUE;
Status = AcpiEvaluateObject (Node, NULL, &ParamObjects, &ReturnObj);
AcpiOsPrintf ("%-32s returned %s\n",
Pathname, AcpiFormatException (Status));
AcpiGbl_MethodExecuting = FALSE;
ACPI_FREE (Pathname);
/* Ignore status from method execution */
Status = AE_OK;
/* Update count, check if we have executed enough methods */
Info->Count++;
if (Info->Count >= Info->MaxCount)
{
Status = AE_CTRL_TERMINATE;
}
return (Status);
}
void
AcpiExDoDebugObject (
ACPI_OPERAND_OBJECT *SourceDesc,
UINT32 Level,
UINT32 Index)
{
UINT32 i;
UINT32 Timer;
ACPI_OPERAND_OBJECT *ObjectDesc;
UINT32 Value;
ACPI_FUNCTION_TRACE_PTR (ExDoDebugObject, SourceDesc);
/* Output must be enabled via the DebugObject global or the DbgLevel */
if (!AcpiGbl_EnableAmlDebugObject &&
!(AcpiDbgLevel & ACPI_LV_DEBUG_OBJECT))
{
return_VOID;
}
/* Newline -- don't emit the line header */
if (SourceDesc &&
(ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND) &&
(SourceDesc->Common.Type == ACPI_TYPE_STRING))
{
if ((SourceDesc->String.Length == 1) &&
(*SourceDesc->String.Pointer == '\n'))
{
AcpiOsPrintf ("\n");
return_VOID;
}
}
/*
* Print line header as long as we are not in the middle of an
* object display
*/
if (!((Level > 0) && Index == 0))
{
if (AcpiGbl_DisplayDebugTimer)
{
/*
* We will emit the current timer value (in microseconds) with each
* debug output. Only need the lower 26 bits. This allows for 67
* million microseconds or 67 seconds before rollover.
*
* Convert 100 nanosecond units to microseconds
*/
Timer = ((UINT32) AcpiOsGetTimer () / 10);
Timer &= 0x03FFFFFF;
AcpiOsPrintf ("ACPI Debug: T=0x%8.8X %*s", Timer, Level, " ");
}
else
{
AcpiOsPrintf ("ACPI Debug: %*s", Level, " ");
}
}
/* Display the index for package output only */
if (Index > 0)
{
AcpiOsPrintf ("(%.2u) ", Index - 1);
}
if (!SourceDesc)
{
AcpiOsPrintf ("[Null Object]\n");
return_VOID;
}
if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_OPERAND)
{
/* No object type prefix needed for integers and strings */
if ((SourceDesc->Common.Type != ACPI_TYPE_INTEGER) &&
(SourceDesc->Common.Type != ACPI_TYPE_STRING))
{
AcpiOsPrintf ("%s ", AcpiUtGetObjectTypeName (SourceDesc));
}
if (!AcpiUtValidInternalObject (SourceDesc))
{
AcpiOsPrintf ("%p, Invalid Internal Object!\n", SourceDesc);
return_VOID;
}
}
else if (ACPI_GET_DESCRIPTOR_TYPE (SourceDesc) == ACPI_DESC_TYPE_NAMED)
{
AcpiOsPrintf ("%s (Node %p)\n",
AcpiUtGetTypeName (((ACPI_NAMESPACE_NODE *) SourceDesc)->Type),
SourceDesc);
return_VOID;
}
else
//.........这里部分代码省略.........
请发表评论