Updated for new core subsystem header filenames

date	2000.02.10.18.58.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 19:01:01 +00:00
parent 01798226b2
commit 8c88b818ec
7 changed files with 762 additions and 854 deletions

View File

@ -117,8 +117,8 @@
#include <acpi.h>
#include <parser.h>
#include <interpreter.h>
#include <namespace.h>
#include <interp.h>
#include <namesp.h>
#include <globals.h>
#define _COMPONENT MISCELLANEOUS
@ -565,6 +565,16 @@ _CmAllocate (
FUNCTION_TRACE_U32 ("_CmAllocate", Size);
/* Check for an inadvertent size of zero bytes */
if (!Size)
{
DEBUG_PRINT (ACPI_ERROR, ("CmAllocate: ** ERROR: Attempt to allocate zero bytes! (%s line %d)\n",
Module, Line));
REPORT_ERROR ("CmAllocate: Attempt to allocate zero bytes");
Size = 1;
}
Address = OsdAllocate (Size);
if (!Address)
{
@ -613,8 +623,18 @@ _CmCallocate (
FUNCTION_TRACE_U32 ("_CmCallocate", Size);
/* Check for an inadvertent size of zero bytes */
if (!Size)
{
DEBUG_PRINT (ACPI_ERROR, ("CmCallocate: ** ERROR: Attempt to allocate zero bytes! (%s line %d)\n",
Module, Line));
REPORT_ERROR ("CmCallocate: Attempt to allocate zero bytes");
Size = 1;
}
Address = OsdCallocate (Size);
if (!Address)

View File

@ -120,24 +120,29 @@
#include <acpi.h>
#include <events.h>
#include <hardware.h>
#include <namespace.h>
#include <interpreter.h>
#include <namesp.h>
#include <interp.h>
#include <amlcode.h>
/*
* These implementations of standard C Library routines can optionally be
* used if a C library is not available. In general, they are less efficient
* than an inline or assembly implementation
*/
#define _THIS_MODULE "cmclib.c"
#define _COMPONENT MISCELLANEOUS
MODULE_NAME ("cmclib");
/*******************************************************************************
*
* FUNCTION:
* FUNCTION: strlen
*
* PARAMETERS: None
* PARAMETERS: String - Null terminated string
*
* RETURN: Status
* RETURN: Length
*
* DESCRIPTION:
* DESCRIPTION: Returns the length of the input string
*
******************************************************************************/
@ -159,23 +164,22 @@ _strlen (
}
return Length;
}
/*******************************************************************************
*
* FUNCTION:
* FUNCTION: strcpy
*
* PARAMETERS: None
* PARAMETERS: DstString - Target of the copy
* SrcString - The source string to copy
*
* RETURN: Status
* RETURN: DstString
*
* DESCRIPTION:
* DESCRIPTION: Copy a null terminated string
*
******************************************************************************/
char *
_strcpy (
char *DstString,
@ -205,13 +209,15 @@ _strcpy (
/*******************************************************************************
*
* FUNCTION:
* FUNCTION: strncpy
*
* PARAMETERS: None
* PARAMETERS: DstString - Target of the copy
* SrcString - The source string to copy
* Count - Maximum # of bytes to copy
*
* RETURN: Status
* RETURN: DstString
*
* DESCRIPTION:
* DESCRIPTION: Copy a null terminated string, with a maximum length
*
******************************************************************************/
@ -246,45 +252,14 @@ _strncpy (
/*******************************************************************************
*
* FUNCTION:
* FUNCTION: strcmp
*
* PARAMETERS: None
* PARAMETERS: String1 - First string
* String2 - Second string
*
* RETURN: Status
* RETURN: Index where strings mismatched, or 0 if strings matched
*
* DESCRIPTION:
*
******************************************************************************/
UINT32
_strncmp (
const char *String1,
const char *String2,
ACPI_SIZE Count)
{
for ( ; Count-- && (*String1 == *String2); String2++)
{
if (!*String1++)
{
return 0;
}
}
return (Count == -1) ? 0 : ((unsigned char) *String1 - (unsigned char) *String2);
}
/*******************************************************************************
*
* FUNCTION:
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION:
* DESCRIPTION: Compare two null terminated strings
*
******************************************************************************/
@ -310,13 +285,48 @@ _strcmp (
/*******************************************************************************
*
* FUNCTION:
* FUNCTION: strncmp
*
* PARAMETERS: None
* PARAMETERS: String1 - First string
* String2 - Second string
* Count - Maximum # of bytes to compare
*
* RETURN: Status
* RETURN: Index where strings mismatched, or 0 if strings matched
*
* DESCRIPTION:
* DESCRIPTION: Compare two null terminated strings, with a maximum length
*
******************************************************************************/
UINT32
_strncmp (
const char *String1,
const char *String2,
ACPI_SIZE Count)
{
for ( ; Count-- && (*String1 == *String2); String2++)
{
if (!*String1++)
{
return 0;
}
}
return (Count == -1) ? 0 : ((unsigned char) *String1 - (unsigned char) *String2);
}
/*******************************************************************************
*
* FUNCTION: Strcat
*
* PARAMETERS: DstString - Target of the copy
* SrcString - The source string to copy
*
* RETURN: DstString
*
* DESCRIPTION: Append a null terminated string to a null terminated string
*
******************************************************************************/
@ -345,13 +355,16 @@ _strcat (
/*******************************************************************************
*
* FUNCTION:
* FUNCTION: strncat
*
* PARAMETERS: None
* PARAMETERS: DstString - Target of the copy
* SrcString - The source string to copy
* Count - Maximum # of bytes to copy
*
* RETURN: Status
* RETURN: DstString
*
* DESCRIPTION:
* DESCRIPTION: Append a null terminated string to a null terminated string,
* with a maximum count.
*
******************************************************************************/
@ -391,13 +404,15 @@ _strncat (
/*******************************************************************************
*
* FUNCTION:
* FUNCTION: memcpy
*
* PARAMETERS: None
* PARAMETERS: Dest - Target of the copy
* Src - Source buffer to copy
* Count - Number of bytes to copy
*
* RETURN: Status
* RETURN: Dest
*
* DESCRIPTION:
* DESCRIPTION: Copy arbitrary bytes of memory
*
******************************************************************************/
@ -426,13 +441,15 @@ _memcpy (
/*******************************************************************************
*
* FUNCTION:
* FUNCTION: memset
*
* PARAMETERS: None
* PARAMETERS: Dest - Buffer to set
* Value - Value to set each byte of memory
* Count - Number of bytes to set
*
* RETURN: Status
* RETURN: Dest
*
* DESCRIPTION:
* DESCRIPTION: Initialize a buffer to a known value.
*
******************************************************************************/
@ -618,8 +635,6 @@ const unsigned char _ctype[257] = {
#define IS_LOWER(c) (_ctype[(unsigned char)(c)] & (_LO))
#define IS_DIGIT(c) (_ctype[(unsigned char)(c)] & (_DI))
#define IS_SPACE(c) (_ctype[(unsigned char)(c)] & (_SP))
//#define ToUpper(c) (IS_LOWER(c) ? ((c)-0x20) : (c))
//#define ToLower(c) (IS_UPPER(c) ? ((c)+0x20) : (c))
INT32
ToUpper (INT32 c)
@ -634,15 +649,18 @@ ToLower (INT32 c)
return (IS_UPPER(c) ? ((c)+0x20) : (c));
}
/*******************************************************************************
*
* FUNCTION:
* FUNCTION: strtoul
*
* PARAMETERS: None
* PARAMETERS: String - Null terminated string
* Terminater - Where a pointer to the terminating byte is returned
* Base - Radix of the string
*
* RETURN: Status
* RETURN: Converted value
*
* DESCRIPTION:
* DESCRIPTION: Convert a string into an unsigned value.
*
******************************************************************************/
@ -775,7 +793,7 @@ _strtoul (
* Check to see if value is out of range:
*/
if (ReturnValue > ((ACPI_UINT_MAX - (UINT32) index) /
if (ReturnValue > ((ACPI_UINT32_MAX - (UINT32) index) /
(UINT32) Base))
{
Status = AE_ERROR;
@ -812,7 +830,7 @@ done:
if (Status == AE_ERROR)
{
ReturnValue = ACPI_UINT_MAX;
ReturnValue = ACPI_UINT32_MAX;
}
/*
@ -820,7 +838,7 @@ done:
*/
if (sign == NEGATIVE)
{
ReturnValue = (ACPI_UINT_MAX - ReturnValue) + 1;
ReturnValue = (ACPI_UINT32_MAX - ReturnValue) + 1;
}
return (ReturnValue);

View File

@ -117,14 +117,14 @@
#define __CMOBJECT_C__
#include <acpi.h>
#include <interpreter.h>
#include <namespace.h>
#include <acpiobj.h>
#include <acobject.h>
#include <interp.h>
#include <namesp.h>
#include <pnp.h>
#define _THIS_MODULE "cmobject.c"
#define _COMPONENT MISCELLANEOUS
MODULE_NAME ("cmobject");
typedef struct Search_st
@ -303,7 +303,7 @@ CmBuildExternalPackageObject (
ThisInternalObj = (ACPI_OBJECT_INTERNAL *) LevelPtr->InternalObj->Package.Elements[ThisIndex];
ThisExternalObj = (ACPI_OBJECT *) &LevelPtr->ExternalObj->Package.Elements[ThisIndex];
if (VALID_OBJECT_TYPE (ThisInternalObj, ACPI_TYPE_Package))
if (IS_THIS_OBJECT_TYPE (ThisInternalObj, ACPI_TYPE_Package))
{
/*
* If this object is a package then we go one deeper
@ -417,7 +417,7 @@ CmBuildExternalObject (
FUNCTION_TRACE ("CmBuildExternalObject");
if (VALID_OBJECT_TYPE (InternalObj, ACPI_TYPE_Package))
if (IS_THIS_OBJECT_TYPE (InternalObj, ACPI_TYPE_Package))
{
/*
* Package objects contain other objects (which can be objects)
@ -591,7 +591,7 @@ CmBuildInternalPackageObject (
ThisInternalObj = (ACPI_OBJECT_INTERNAL *) &LevelPtr->InternalObj->Package.Elements[ThisIndex];
ThisExternalObj = (ACPI_OBJECT *) &LevelPtr->ExternalObj->Package.Elements[ThisIndex];
if (VALID_OBJECT_TYPE (ThisInternalObj, ACPI_TYPE_Package))
if (IS_THIS_OBJECT_TYPE (ThisInternalObj, ACPI_TYPE_Package))
{
/*
* If this object is a package then we go one deeper

View File

@ -27,7 +27,7 @@
* Code in any form, with the right to sublicense such rights; and
*
* 2.3. Intel grants Licensee a non-exclusive and non-transferable patent
* license (without the right to sublicense), under only those claims of Intel
* license (with the right to sublicense), under only those claims of Intel
* patents that are infringed by the Original Intel Code, to make, use, sell,
* offer to sell, and import the Covered Code and derivative works thereof
* solely to the minimum extent necessary to exercise the above copyright
@ -118,9 +118,8 @@
#include <acpi.h>
#define _THIS_MODULE "cmdebug.c"
#define _COMPONENT MISCELLANEOUS
MODULE_NAME ("cmdebug");
@ -174,10 +173,110 @@ FunctionTrace (
INT32 ComponentId,
char *FunctionName)
{
NestingLevel++;
Gbl_NestingLevel++;
DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS,
" %2.2d Entered Function: %s\n", NestingLevel, FunctionName);
" %2.2ld Entered Function: %s\n", Gbl_NestingLevel, FunctionName);
}
/*****************************************************************************
*
* FUNCTION: FunctionTracePtr
*
* PARAMETERS: ModuleName - Caller's module name (for error output)
* LineNumber - Caller's line number (for error output)
* ComponentId - Caller's component ID (for error output)
* FunctionName - Name of Caller's function
* Pointer - Pointer to display
*
* RETURN: None
*
* DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
* set in DebugLevel
*
****************************************************************************/
void
FunctionTracePtr (
char *ModuleName,
INT32 LineNumber,
INT32 ComponentId,
char *FunctionName,
void *Pointer)
{
Gbl_NestingLevel++;
DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS,
" %2.2ld Entered Function: %s, 0x%p\n",
Gbl_NestingLevel, FunctionName, Pointer);
}
/*****************************************************************************
*
* FUNCTION: FunctionTraceStr
*
* PARAMETERS: ModuleName - Caller's module name (for error output)
* LineNumber - Caller's line number (for error output)
* ComponentId - Caller's component ID (for error output)
* FunctionName - Name of Caller's function
* String - Additional string to display
*
* RETURN: None
*
* DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
* set in DebugLevel
*
****************************************************************************/
void
FunctionTraceStr (
char *ModuleName,
INT32 LineNumber,
INT32 ComponentId,
char *FunctionName,
char *String)
{
Gbl_NestingLevel++;
DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS,
" %2.2ld Entered Function: %s, %s\n",
Gbl_NestingLevel, FunctionName, String);
}
/*****************************************************************************
*
* FUNCTION: FunctionTraceU32
*
* PARAMETERS: ModuleName - Caller's module name (for error output)
* LineNumber - Caller's line number (for error output)
* ComponentId - Caller's component ID (for error output)
* FunctionName - Name of Caller's function
* Integer - Integer to display
*
* RETURN: None
*
* DESCRIPTION: Function entry trace. Prints only if TRACE_FUNCTIONS bit is
* set in DebugLevel
*
****************************************************************************/
void
FunctionTraceU32 (
char *ModuleName,
INT32 LineNumber,
INT32 ComponentId,
char *FunctionName,
UINT32 Integer)
{
Gbl_NestingLevel++;
DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS,
" %2.2ld Entered Function: %s, 0x%lX\n",
Gbl_NestingLevel, FunctionName, Integer);
}
@ -206,8 +305,8 @@ FunctionExit (
{
DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS,
" %2.2d Exiting Function: %s\n", NestingLevel, FunctionName);
NestingLevel--;
" %2.2ld Exiting Function: %s\n", Gbl_NestingLevel, FunctionName);
Gbl_NestingLevel--;
}
@ -239,13 +338,85 @@ FunctionStatusExit (
if (Status > ACPI_MAX_STATUS)
{
Status = AE_UNKNOWN_STATUS;
DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS,
" %2.2ld Exiting Function: %s, [Unknown Status] 0x%X\n",
Gbl_NestingLevel, FunctionName, Status);
}
else
{
DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS,
" %2.2ld Exiting Function: %s, %s\n",
Gbl_NestingLevel, FunctionName, Gbl_ExceptionNames[Status]);
}
Gbl_NestingLevel--;
}
/*****************************************************************************
*
* FUNCTION: FunctionValueExit
*
* PARAMETERS: ModuleName - Caller's module name (for error output)
* LineNumber - Caller's line number (for error output)
* ComponentId - Caller's component ID (for error output)
* FunctionName - Name of Caller's function
* Value - Value to be printed with exit msg
*
* RETURN: None
*
* DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
* set in DebugLevel. Prints exit value also.
*
****************************************************************************/
void
FunctionValueExit (
char *ModuleName,
INT32 LineNumber,
INT32 ComponentId,
char *FunctionName,
NATIVE_UINT Value)
{
DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS,
" %2.2d Exiting Function: %s, %s\n",
NestingLevel, FunctionName, ExceptionNames[Status]);
NestingLevel--;
" %2.2ld Exiting Function: %s, 0x%X\n",
Gbl_NestingLevel, FunctionName, Value);
Gbl_NestingLevel--;
}
/*****************************************************************************
*
* FUNCTION: FunctionPtrExit
*
* PARAMETERS: ModuleName - Caller's module name (for error output)
* LineNumber - Caller's line number (for error output)
* ComponentId - Caller's component ID (for error output)
* FunctionName - Name of Caller's function
* Value - Value to be printed with exit msg
*
* RETURN: None
*
* DESCRIPTION: Function exit trace. Prints only if TRACE_FUNCTIONS bit is
* set in DebugLevel. Prints exit value also.
*
****************************************************************************/
void
FunctionPtrExit (
char *ModuleName,
INT32 LineNumber,
INT32 ComponentId,
char *FunctionName,
char *Ptr)
{
DebugPrint (ModuleName, LineNumber, ComponentId, TRACE_FUNCTIONS,
" %2.2ld Exiting Function: %s, 0x%p\n",
Gbl_NestingLevel, FunctionName, Ptr);
Gbl_NestingLevel--;
}
@ -277,19 +448,16 @@ DebugPrint (
...)
{
va_list args;
/* Both the level and the component must be enabled */
if ((PrintLevel & DebugLevel) && (ComponentId & DebugLayer))
{
va_start (args, Format);
OsdPrintf (NULL, "%10s(%04d): ", ModuleName, LineNumber);
OsdVprintf (NULL, Format, args);
va_end (args);
OsdPrintf ("%8s-%04d: ", ModuleName, LineNumber);
OsdVprintf (Format, args);
}
}
@ -317,7 +485,7 @@ DebugPrintPrefix (
{
OsdPrintf (NULL, "%10s(%04d): ", ModuleName, LineNumber);
OsdPrintf ("%8s-%04d: ", ModuleName, LineNumber);
}
@ -344,7 +512,7 @@ DebugPrintRaw (
va_start (args, Format);
OsdVprintf (NULL, Format, args);
OsdVprintf (Format, args);
va_end (args);
}

View File

@ -117,16 +117,40 @@
#define __CMDELETE_C__
#include <acpi.h>
#include <acpiobj.h>
#include <interpreter.h>
#include <namespace.h>
#include <acobject.h>
#include <interp.h>
#include <namesp.h>
#include <tables.h>
#include <parser.h>
#define _THIS_MODULE "cmdelete.c"
#define _COMPONENT MISCELLANEOUS
MODULE_NAME ("cmdelete");
/******************************************************************************
*
* FUNCTION: CmDeleteOperand
*
* PARAMETERS: Operand - Pointer to the object to be deleted
*
* RETURN: Delete an operand object, clear stack entry
*
*****************************************************************************/
void
CmDeleteOperand (
ACPI_OBJECT_INTERNAL **Operand)
{
CmDeleteInternalObject (*Operand);
/* Clear the stack slot to prevent multiple deletions */
*Operand = NULL;
}
/******************************************************************************
*
* FUNCTION: CmUpdateRefCount
@ -233,6 +257,7 @@ CmUpdateObjectReference (
INT32 Action)
{
UINT32 i;
ACPI_OBJECT_INTERNAL *Next;
FUNCTION_TRACE_PTR ("CmUpdateObjectReference", Object);
@ -250,14 +275,14 @@ CmUpdateObjectReference (
* Make sure that this isn't a namespace handle or an AML pointer
*/
if (IS_NS_HANDLE ((NAME_TABLE_ENTRY *) Object))
if (VALID_DESCRIPTOR_TYPE (Object, DESC_TYPE_NTE))
{
DEBUG_PRINT (ACPI_INFO, ("CmUpdateObjectReference: Object %p is NS handle\n",
Object));
return_ACPI_STATUS (AE_OK);
}
if (NsIsInSystemTable (Object))
if (TbSystemTablePointer (Object))
{
DEBUG_PRINT (ACPI_INFO, ("CmUpdateObjectReference: **** Object %p is Pcode Ptr\n",
Object));
@ -272,7 +297,32 @@ CmUpdateObjectReference (
switch (Object->Common.Type)
{
case TYPE_Package:
case ACPI_TYPE_Device:
/* TBD:
CmUpdateObjectReference (Object->Device.AddrHandler, Action);
*/
CmUpdateObjectReference (Object->Device.SysHandler, Action);
CmUpdateObjectReference (Object->Device.DrvHandler, Action);
break;
case INTERNAL_TYPE_AddressHandler:
/* Must walk list of address handlers */
Next = Object->AddrHandler.Link;
while (Next)
{
Next->Common.ReferenceCount = CmUpdateRefCount (Next,
Next->Common.ReferenceCount, Action);
Next = Next->AddrHandler.Link;
}
break;
case ACPI_TYPE_Package:
/*
* We must update all the sub-objects of the package
@ -292,32 +342,35 @@ CmUpdateObjectReference (
break;
case TYPE_FieldUnit:
case ACPI_TYPE_FieldUnit:
CmUpdateObjectReference (Object->FieldUnit.Container, Action);
break;
case TYPE_DefField:
case INTERNAL_TYPE_DefField:
CmUpdateObjectReference (Object->Field.Container, Action);
break;
case TYPE_BankField:
case INTERNAL_TYPE_BankField:
CmUpdateObjectReference (Object->BankField.Container, Action);
CmUpdateObjectReference (Object->BankField.BankSelect, Action);
break;
case TYPE_Region:
case ACPI_TYPE_Region:
CmUpdateObjectReference (Object->Region.AddressLocation, Action);
CmUpdateObjectReference (Object->Region.Method, Action);
/* TBD:
CmUpdateObjectReference (Object->Region.AddrHandler, Action);
*/
break;
case TYPE_Lvalue:
case INTERNAL_TYPE_Lvalue:
break;
}
@ -353,10 +406,17 @@ CmDeleteInternalObj (
{
void *ObjPointer = NULL;
UINT32 i;
ACPI_OBJECT_INTERNAL *Next;
ACPI_OBJECT_INTERNAL *New;
FUNCTION_TRACE_PTR ("CmDeleteInternalObj", Object);
if (!Object)
{
return_VOID;
}
/* Only delete the object when the reference count reaches zero */
@ -374,7 +434,39 @@ CmDeleteInternalObj (
switch (Object->Common.Type)
{
case TYPE_String:
case ACPI_TYPE_Device:
DEBUG_PRINT (ACPI_INFO, ("CmDeleteInternalObj: **** Device %p\n",
Object));
/* TBD: temp fix for handler ref count issues */
CmUpdateObjectReference (Object->Device.AddrHandler, REF_DECREMENT);
CmDeleteInternalObj (Object->Device.AddrHandler);
CmDeleteInternalObj (Object->Device.SysHandler);
CmDeleteInternalObj (Object->Device.DrvHandler);
break;
case INTERNAL_TYPE_AddressHandler:
DEBUG_PRINT (ACPI_INFO, ("CmDeleteInternalObj: **** AddressHandler %p\n",
Object));
Next = Object->AddrHandler.Link;
while (Next)
{
New = Next->AddrHandler.Link;
if (!(Next->Common.Flags & AO_STATIC_ALLOCATION))
{
CmFree (Next);
}
Next = New;
}
break;
case ACPI_TYPE_String:
DEBUG_PRINT (ACPI_INFO, ("CmDeleteInternalObj: **** String %p, ptr %p\n",
Object, Object->String.Pointer));
@ -385,7 +477,7 @@ CmDeleteInternalObj (
break;
case TYPE_Buffer:
case ACPI_TYPE_Buffer:
DEBUG_PRINT (ACPI_INFO, ("CmDeleteInternalObj: **** Buffer %p, ptr %p\n",
Object, Object->Buffer.Pointer));
@ -396,7 +488,7 @@ CmDeleteInternalObj (
break;
case TYPE_Package:
case ACPI_TYPE_Package:
DEBUG_PRINT (ACPI_INFO, ("CmDeleteInternalObj: **** Package of count %d\n",
Object->Package.Count));
@ -421,13 +513,13 @@ CmDeleteInternalObj (
break;
case TYPE_FieldUnit:
case ACPI_TYPE_FieldUnit:
CmDeleteInternalObj (Object->FieldUnit.Container);
break;
case TYPE_DefField:
case INTERNAL_TYPE_DefField:
DEBUG_PRINT (ACPI_INFO, ("CmDeleteInternalObj: **** Field %p, container %p\n",
Object, Object->Field.Container));
@ -436,26 +528,48 @@ CmDeleteInternalObj (
break;
case TYPE_BankField:
case INTERNAL_TYPE_BankField:
CmDeleteInternalObj (Object->BankField.Container);
CmDeleteInternalObj (Object->BankField.BankSelect); /* TBD: is this necessary? */
break;
case TYPE_Region:
case ACPI_TYPE_Region:
DEBUG_PRINT (ACPI_INFO, ("CmDeleteInternalObj: ***** Region %p, method %p\n",
Object, Object->Region.AddressLocation));
Object, Object->Region.Method));
CmDeleteInternalObj (Object->Region.AddressLocation);
CmDeleteInternalObj (Object->Region.Method);
/* TBD
CmDeleteInternalObj (Object->Region.AddrHandler);
*/
break;
case TYPE_Lvalue:
case ACPI_TYPE_Method:
DEBUG_PRINT (ACPI_INFO, ("CmDeleteInternalObj: ***** Method %p, ParserOp %p\n",
Object, Object->Method.ParserOp));
/* TBD: Remove ifdef when RPARSER is obsoleted */
#ifndef _RPARSER
if (Object->Method.ParserOp)
{
PsDeleteParseTree (Object->Method.ParserOp);
Object->Method.ParserOp = NULL;
}
#endif
break;
case INTERNAL_TYPE_Lvalue:
if ((Object->Lvalue.Object) &&
(!IS_NS_HANDLE (Object->Lvalue.Object)))
(!VALID_DESCRIPTOR_TYPE (Object->Lvalue.Object, DESC_TYPE_NTE)))
{
DEBUG_PRINT (ACPI_INFO, ("CmDeleteInternalObj: ***** Lvalue: %p\n",
Object->Lvalue.Object));
@ -478,7 +592,7 @@ CmDeleteInternalObj (
if (ObjPointer)
{
if (!NsIsInSystemTable (ObjPointer))
if (!TbSystemTablePointer (ObjPointer))
{
DEBUG_PRINT (ACPI_INFO, ("CmDeleteInternalObj: Deleting Obj Ptr %p \n",
ObjPointer));
@ -501,7 +615,13 @@ CmDeleteInternalObj (
DEBUG_PRINT (ACPI_INFO, ("CmDeleteInternalObj: Deleting Obj %p [%s]\n",
Object, Gbl_NsTypeNames[Object->Common.Type]));
/* Memory allocation metrics. Call the macro here since we only
* care about dynamically allocated objects.
*/
DECREMENT_OBJECT_METRICS(Object->Common.Size);
CmFree (Object);
}
return_VOID;
@ -539,14 +659,14 @@ CmDeleteInternalObject (
return_VOID;
}
if (NsIsInSystemTable (Object))
if (TbSystemTablePointer (Object))
{
DEBUG_PRINT (ACPI_INFO, ("CmDeleteInternalObject: **** Object %p is Pcode Ptr\n",
Object));
return_VOID;
}
if (IS_NS_HANDLE (Object))
if (VALID_DESCRIPTOR_TYPE (Object, DESC_TYPE_NTE))
{
DEBUG_PRINT (ACPI_INFO, ("CmDeleteInternalObject: **** Object %p is NS handle\n",
Object));
@ -606,7 +726,7 @@ CmDeleteInternalObjectList (
* need to be deleted separately.
*/
if ((*InternalObj)->Common.Type == TYPE_Package)
if (IS_THIS_OBJECT_TYPE ((*InternalObj), ACPI_TYPE_Package))
{
/* Delete the package */

View File

@ -119,12 +119,20 @@
#include <acpi.h>
#include <events.h>
#include <namespace.h>
#include <interpreter.h>
#include <namesp.h>
#include <interp.h>
#define _THIS_MODULE "cmglobal.c"
#define _COMPONENT MISCELLANEOUS
MODULE_NAME ("cmglobal");
/******************************************************************************
*
* Static global variable initialization.
*
******************************************************************************/
/*
@ -143,13 +151,13 @@ UINT32 DebugLevel = NORMAL_DEFAULT;
/* Debug switch - layer (component) mask */
UINT32 DebugLayer = ALL_COMPONENTS;
UINT32 NestingLevel = 0;
UINT32 Gbl_NestingLevel = 0;
/* System flags */
UINT32 SystemFlags = 0;
UINT32 StartupFlags = 0;
UINT32 Gbl_SystemFlags = 0;
UINT32 Gbl_StartupFlags = 0;
/*
* Human-readable decode of exception codes, mostly for debugging
@ -157,7 +165,7 @@ UINT32 StartupFlags = 0;
* Note that AE_PENDING is not an error, but indicates
* that other alternatives should be checked.
*/
char *ExceptionNames[] =
char *Gbl_ExceptionNames[] =
{
"AE_OK",
"AE_PENDING",
@ -188,11 +196,19 @@ char *ExceptionNames[] =
"AE_SHARE",
"AE_LIMIT",
"AE_TIME",
"AE_TERMINATE",
"AE_DEPTH",
"AE_TRUE",
"AE_FALSE",
"AE_UNKNOWN_STATUS"
};
ACPI_TABLE_INFO AcpiTables[NUM_ACPI_TABLES];
/* Message strings */
char *MsgAcpiErrorBreak = "*** Break on ACPI_ERROR ***\n";
char *Gbl_AcpiCaVersion = ACPI_CA_VERSION;
/******************************************************************************
@ -202,13 +218,6 @@ ACPI_TABLE_INFO AcpiTables[NUM_ACPI_TABLES];
******************************************************************************/
/* Scope stack */
SCOPE_STACK ScopeStack[MAX_SCOPE_NESTING];
SCOPE_STACK *CurrentScope;
/*
* Names built-in to the interpreter
*
@ -216,84 +225,95 @@ SCOPE_STACK *CurrentScope;
* To avoid type punning, both are specified as strings in this table.
*/
PREDEFINED_NAMES PreDefinedNames[] = {
{"_GPE", TYPE_DefAny},
{"_PR_", TYPE_DefAny},
{"_SB_", TYPE_DefAny},
{"_SI_", TYPE_DefAny},
{"_TZ_", TYPE_DefAny},
{"_REV", TYPE_Number, "2"},
{"_OS_", TYPE_String, "Intel AML interpreter"},
{"_GL_", TYPE_Mutex},
PREDEFINED_NAMES Gbl_PreDefinedNames[] =
{
{"_GPE", INTERNAL_TYPE_DefAny},
{"_PR_", INTERNAL_TYPE_DefAny},
{"_SB_", INTERNAL_TYPE_DefAny},
{"_SI_", INTERNAL_TYPE_DefAny},
{"_TZ_", INTERNAL_TYPE_DefAny},
{"_REV", ACPI_TYPE_Number, "2"},
{"_OS_", ACPI_TYPE_String, "Intel AML interpreter"},
{"_GL_", ACPI_TYPE_Mutex, "0"},
/* Table terminator */
/* Table terminator */
{(char *)0, TYPE_Any}
{NULL, ACPI_TYPE_Any}
};
/*
* Properties of the ACPI Object Types, both internal and external.
*
* Elements of NsProperties are bit significant
* and should be one-to-one with values of NsType in acpinmsp.h
* and the table is indexed by values of ACPI_OBJECT_TYPE
*/
INT32 NsProperties[] = { /* properties of types */
0, /* Any */
0, /* Number */
0, /* String */
0, /* Buffer */
LOCAL, /* Package */
0, /* FieldUnit */
NEWSCOPE | LOCAL, /* Device */
LOCAL, /* Event */
NEWSCOPE | LOCAL, /* Method */
LOCAL, /* Mutex */
LOCAL, /* Region */
NEWSCOPE | LOCAL, /* Power */
NEWSCOPE | LOCAL, /* Processor */
NEWSCOPE | LOCAL, /* Thermal */
0, /* Alias */
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0, /* DefField */
0, /* BankField */
0, /* IndexField */
0, /* DefFieldDefn */
0, /* BankFieldDefn */
0, /* IndexFieldDefn */
0, /* If */
0, /* Else */
0, /* While */
NEWSCOPE, /* Scope */
LOCAL, /* DefAny */
0 /* Lvalue */
UINT8 Gbl_NsProperties[] =
{
NSP_NORMAL, /* 00 Any */
NSP_NORMAL, /* 01 Number */
NSP_NORMAL, /* 02 String */
NSP_NORMAL, /* 03 Buffer */
NSP_LOCAL, /* 04 Package */
NSP_NORMAL, /* 05 FieldUnit */
NSP_NEWSCOPE | NSP_LOCAL, /* 06 Device */
NSP_LOCAL, /* 07 Event */
NSP_NEWSCOPE | NSP_LOCAL, /* 08 Method */
NSP_LOCAL, /* 09 Mutex */
NSP_LOCAL, /* 10 Region */
NSP_NEWSCOPE | NSP_LOCAL, /* 11 Power */
NSP_NEWSCOPE | NSP_LOCAL, /* 12 Processor */
NSP_NEWSCOPE | NSP_LOCAL, /* 13 Thermal */
NSP_NORMAL, /* 14 BufferField */
NSP_NORMAL, /* 15 DdbHandle */
NSP_NORMAL, /* 16 reserved */
NSP_NORMAL, /* 17 reserved */
NSP_NORMAL, /* 18 reserved */
NSP_NORMAL, /* 19 reserved */
NSP_NORMAL, /* 20 reserved */
NSP_NORMAL, /* 21 reserved */
NSP_NORMAL, /* 22 reserved */
NSP_NORMAL, /* 23 reserved */
NSP_NORMAL, /* 24 reserved */
NSP_NORMAL, /* 25 DefField */
NSP_NORMAL, /* 26 BankField */
NSP_NORMAL, /* 27 IndexField */
NSP_NORMAL, /* 28 DefFieldDefn */
NSP_NORMAL, /* 29 BankFieldDefn */
NSP_NORMAL, /* 30 IndexFieldDefn */
NSP_NORMAL, /* 31 If */
NSP_NORMAL, /* 32 Else */
NSP_NORMAL, /* 33 While */
NSP_NEWSCOPE, /* 34 Scope */
NSP_LOCAL, /* 35 DefAny */
NSP_NORMAL, /* 36 Lvalue */
NSP_NORMAL, /* 37 Alias */
NSP_NORMAL, /* 38 Notify */
NSP_NORMAL, /* 39 Address Handler */
NSP_NORMAL /* 40 Invalid */
};
char BadType[] = "ERROR: unused type encoding found in table";
#ifdef ACPI_DEBUG
char Gbl_BadType[] = "UNDEFINED";
#define TYPE_NAME_LENGTH 9 /* Maximum length of each string */
/*
* Elements of NsTypeNames should be
* one-to-one with values of NsType in acpinmsp.h
* Elements of Gbl_NsTypeNames below must match
* one-to-one with values of ACPI_OBJECT_TYPE
*
* The type ACPI_TYPE_Any (Untyped) is used as a "don't care" when searching; when
* stored in a table it really means that we have thus far seen no evidence to
* indicatewhat type is actually going to be stored for this entry.
*/
/*
* The type Any is used as a "don't care" when searching; when stored in a
* table it really means that we have thus far seen no evidence to indicate
* what type is actually going to be stored for this entry.
*/
char *NsTypeNames[] = { /* printable names of types */
"Unknown",
char *Gbl_NsTypeNames[] = /* printable names of types */
{
"Untyped",
"Number",
"String",
"Buffer",
@ -307,85 +327,63 @@ char *NsTypeNames[] = { /* printable names of types */
"Power",
"Processor",
"Thermal",
"Alias",
BadType,
BadType,
BadType,
BadType,
BadType,
BadType,
BadType,
BadType,
BadType,
BadType,
"BufferFld",
"DdbHandle",
Gbl_BadType,
Gbl_BadType,
Gbl_BadType,
Gbl_BadType,
Gbl_BadType,
Gbl_BadType,
Gbl_BadType,
Gbl_BadType,
Gbl_BadType,
"DefField",
"BankField",
"IndexField",
"DefFieldDefn",
"BankFieldDefn",
"IndexFieldDefn",
"BnkField",
"IdxField",
"DefFldDfn",
"BnkFldDfn",
"IdxFldDfn",
"If",
"Else",
"While",
"Scope",
"ERROR: DefAny found in table", /* should never happen */
"ERROR: Lvalue found in table" /* should never happen */
"DefAny",
"Lvalue",
"Alias",
"Notify",
"AddrHndlr",
"Invalid"
};
/******************************************************************************
*
* Interpreter globals
*
******************************************************************************/
/*
* Method Stack, containing locals and args
* per level, 0-7 are Local# and 8-14 are Arg#
*/
ACPI_OBJECT_INTERNAL *MethodStack[AML_METHOD_MAX_NEST][MTH_ENTRY_SIZE];
INT32 MethodStackTop = -1;
/*
* Package stack, used for keeping track of nested AML packages.
* Grows upwards.
*/
INT32 PkgStackLevel;
INT32 PkgStack_Len[AML_PKG_MAX_NEST];
UINT8 *PkgStack_Code[AML_PKG_MAX_NEST];
/* Object Stack */
/* values are NsHandle or ObjHandle */
void *ObjStack[AML_EXPR_MAX_NEST];
INT32 ObjStackTop = 0;
/******************************************************************************
*
* Event globals
*
******************************************************************************/
UINT32 SciHandle;
FIXED_EVENT_HANDLER FixedEventHandlers[NUM_FIXED_EVENTS];
#ifdef ACPI_DEBUG
UINT32 EventCount[NUM_FIXED_EVENTS];
#endif
/******************************************************************************
*
* Table globals
*
******************************************************************************/
ACPI_TABLE_DESC Gbl_AcpiTables[NUM_ACPI_TABLES];
ACPI_TABLE_SUPPORT Gbl_AcpiTableData[NUM_ACPI_TABLES] =
{
/* Name, Signature, Signature size, How many allowed?, Supported? Global typed pointer */
/* RSDP */ {"RSDP", RSDP_SIG, sizeof (RSDP_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, NULL},
/* APIC */ {APIC_SIG, APIC_SIG, sizeof (APIC_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &Gbl_APIC},
/* DSDT */ {DSDT_SIG, DSDT_SIG, sizeof (DSDT_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &Gbl_DSDT},
/* FACP */ {FACP_SIG, FACP_SIG, sizeof (FACP_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &Gbl_FACP},
/* FACS */ {FACS_SIG, FACS_SIG, sizeof (FACS_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &Gbl_FACS},
/* PSDT */ {PSDT_SIG, PSDT_SIG, sizeof (PSDT_SIG)-1, ACPI_TABLE_MULTIPLE, AE_OK, NULL},
/* RSDT */ {RSDT_SIG, RSDT_SIG, sizeof (RSDT_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, NULL},
/* SSDT */ {SSDT_SIG, SSDT_SIG, sizeof (SSDT_SIG)-1, ACPI_TABLE_MULTIPLE, AE_OK, NULL},
/* SBST */ {SBST_SIG, SBST_SIG, sizeof (SBST_SIG)-1, ACPI_TABLE_SINGLE, AE_OK, (void **) &Gbl_SBST},
/* BOOT */ {BOOT_SIG, BOOT_SIG, sizeof (BOOT_SIG)-1, ACPI_TABLE_SINGLE, AE_SUPPORT, NULL}
};
/****************************************************************************
@ -403,129 +401,103 @@ void
CmInitGlobals (void)
{
UINT32 i;
char * TblNames[] = {
"RSDP",
APIC_SIG,
DSDT_SIG,
FACP_SIG,
FACS_SIG,
PSDT_SIG,
RSDT_SIG,
SSDT_SIG,
SBDT_SIG
};
FUNCTION_TRACE ("CmInitGlobals");
/* TBD: Remove rparser globals */
#ifdef _RPARSER
Gbl_PkgStackLevel = 0;
Gbl_ObjStackTop = 0;
Gbl_MthStackHead = NULL;
Gbl_MethodStackTop = -1;
#endif
/* ACPI table structure */
for (i = 0; i < ACPI_TABLE_MAX; i++)
{
AcpiTables[i].Pointer = NULL;
AcpiTables[i].Allocation = ACPI_MEM_NOT_ALLOCATED;
AcpiTables[i].Length = 0;
strncpy(&AcpiTables[i].Name[0], TblNames[i], sizeof(AcpiTables[0].Name));
Gbl_AcpiTables[i].Prev = &Gbl_AcpiTables[i];
Gbl_AcpiTables[i].Next = &Gbl_AcpiTables[i];
Gbl_AcpiTables[i].Pointer = NULL;
Gbl_AcpiTables[i].Length = 0;
Gbl_AcpiTables[i].Allocation = ACPI_MEM_NOT_ALLOCATED;
Gbl_AcpiTables[i].Count = 0;
}
/* Address Space handler array */
for (i = 0; i < ACPI_MAX_ADDRESS_SPACE; i++)
{
AddressSpaces[i].Handler = NULL;
AddressSpaces[i].Context = NULL;
Gbl_AddressSpaces[i].Handler = NULL;
Gbl_AddressSpaces[i].Context = NULL;
}
/* Global notify handlers */
Gbl_SysNotify.Handler = NULL;
Gbl_DrvNotify.Handler = NULL;
/* Global "typed" ACPI table pointers */
RSDP = NULL;
RSDT = NULL;
FACS = NULL;
FACP = NULL;
APIC = NULL;
DSDT = NULL;
PSDT = NULL;
SSDT = NULL;
SBDT = NULL;
Gbl_RSDP = NULL;
Gbl_RSDT = NULL;
Gbl_FACS = NULL;
Gbl_FACP = NULL;
Gbl_APIC = NULL;
Gbl_DSDT = NULL;
Gbl_SBST = NULL;
/* Miscellaneous variables */
SystemFlags = 0;
StartupFlags = 0;
GlobalLockSet = FALSE;
RsdpOriginalLocation = 0;
Allocations = 0;
Deallocations = 0;
Allocs = 0;
Callocs = 0;
Maps = 0;
Unmaps = 0;
Gbl_SystemFlags = 0;
Gbl_StartupFlags = 0;
Gbl_GlobalLockSet = FALSE;
Gbl_RsdpOriginalLocation = 0;
/* Stack pointers */
Gbl_CurrentScope = NULL;
/* Interpreter */
BufSeq = 0;
NamedObjectErr = FALSE;
Gbl_BufSeq = 0;
Gbl_NamedObjectErr = FALSE;
/* Parser */
Gbl_ParsedNamespaceRoot = NULL;
/* Hardware oriented */
Gpe0EnableRegisterSave = NULL;
Gpe1EnableRegisterSave = NULL;
OriginalMode = SYS_MODE_UNKNOWN; /* original ACPI/legacy mode */
SciHandle = 0;
GpeRegisters = NULL;
GpeInfo = NULL;
Gbl_Gpe0EnableRegisterSave = NULL;
Gbl_Gpe1EnableRegisterSave = NULL;
Gbl_OriginalMode = SYS_MODE_UNKNOWN; /* original ACPI/legacy mode */
Gbl_GpeRegisters = NULL;
Gbl_GpeInfo = NULL;
/* Namespace */
RootObject = &RootObjStruct;
Gbl_RootObject = &Gbl_RootObjStruct;
RootObject->Name = NS_ROOT;
RootObject->Scope = NULL;
RootObject->ParentScope = NULL;
RootObject->ParentEntry = NULL;
RootObject->NextEntry = NULL;
RootObject->PrevEntry = NULL;
RootObject->Type = TYPE_Any;
RootObject->Value = NULL;
Gbl_RootObject->DataType = DESC_TYPE_NTE;
Gbl_RootObject->Type = ACPI_TYPE_Any;
Gbl_RootObject->Fill1 = 0;
Gbl_RootObject->Name = * (UINT32 *) NS_ROOT;
Gbl_RootObject->Scope = NULL;
Gbl_RootObject->ParentEntry = NULL;
Gbl_RootObject->NextEntry = NULL;
Gbl_RootObject->PrevEntry = NULL;
Gbl_RootObject->Object = NULL;
/* Memory allocation metrics - compiled out in non-debug mode. */
INITIALIZE_ALLOCATION_METRICS();
return_VOID;
}
/******************************************************************************
*
* FUNCTION: CmTerminate
*
* PARAMETERS: none
*
* RETURN: none
*
* DESCRIPTION: free memory allocated for table storage.
*
******************************************************************************/
void
CmTerminate (void)
{
FUNCTION_TRACE ("CmTerminate");
/* Free global tables, etc. */
if (Gpe0EnableRegisterSave)
{
CmFree (Gpe0EnableRegisterSave);
}
if (Gpe1EnableRegisterSave)
{
CmFree (Gpe1EnableRegisterSave);
}
return_VOID;
}

View File

@ -119,445 +119,13 @@
#include <acpi.h>
#include <hardware.h>
#include <namespace.h>
#include <namesp.h>
#define _THIS_MODULE "cminit.c"
#define _COMPONENT MISCELLANEOUS
MODULE_NAME ("cminit");
/******************************************************************************
*
* FUNCTION: CmGetTableRsdt
*
* PARAMETERS: NumberOfTables - Where the table count is placed
* TablePtr - Input buffer pointer, optional
*
* RETURN: Status
*
* DESCRIPTION: Load and validate the RSDP (ptr) and RSDT (table)
*
******************************************************************************/
ACPI_STATUS
CmGetTableRsdt (
UINT32 *NumberOfTables,
char **TablePtr)
{
ACPI_STATUS Status = AE_OK;
UINT32 VersionLength;
ACPI_TABLE_INFO TableInfo;
FUNCTION_TRACE ("CmGetTableRsdt");
if (*TablePtr)
{
/* Get the RSDP from a buffer */
VersionLength = strlen (ACPILIB_DATA_FILE_VERSION);
if (strncmp (ACPILIB_DATA_FILE_VERSION, *TablePtr, VersionLength))
{
/* data file version mismatch */
REPORT_ERROR ("Data file version mismatch");
DEBUG_PRINT (ACPI_INFO,
("ACPICA version %s expects a data file version string of"
"\n \"%s\"", ACPI_LIB_VER, ACPILIB_DATA_FILE_VERSION));
DEBUG_PRINT (ACPI_INFO,
("version string is \"%s\"\n", *TablePtr));
return_ACPI_STATUS (AE_VERSION_MISMATCH);
}
else
{
*TablePtr += VersionLength;
memcpy (&RsdpOriginalLocation, *TablePtr, (ACPI_SIZE) 4);
*TablePtr += 4;
}
}
/* Get the RSDP */
Status = NsFindRsdp (TablePtr, &TableInfo);
if (ACPI_FAILURE (Status))
{
REPORT_WARNING ("RSDP structure not found");
return_ACPI_STATUS (AE_NO_ACPI_TABLES);
}
/* Save the table pointers and allocation info */
RSDP = (ROOT_SYSTEM_DESCRIPTOR_POINTER *) TableInfo.Pointer;
AcpiTables[TABLE_RSDP].Pointer = TableInfo.Pointer;
AcpiTables[TABLE_RSDP].Length = TableInfo.Length;
AcpiTables[TABLE_RSDP].Allocation = TableInfo.Allocation;
/* RSDP structure was found */
if (!*TablePtr)
{
DEBUG_PRINT (ACPI_INFO, ("RSDP located at %p\n", RSDP));
}
else
{
DEBUG_PRINT (ACPI_INFO,
("RSDP located at %lX\n", RsdpOriginalLocation));
/*
* Since we're working from an input buffer, assume we're running on
* legacy hardware. This is intended to prevent any accesses to the
* hardware since the ACPI tables are probably not valid for the
* current hardware
*/
SystemFlags &= ~SYS_MODE_ACPI;
SystemFlags |= SYS_MODE_LEGACY;
}
/* Get the RSDT */
Status = NsGetTable ((void *) RSDP->RsdtPhysicalAddress,
TablePtr, &TableInfo);
if (Status != AE_OK)
{
return_ACPI_STATUS (Status);
}
/* Save the table pointers and allocation info */
RSDT = (ROOT_SYSTEM_DESCRIPTION_TABLE *) TableInfo.Pointer;
AcpiTables[TABLE_RSDT].Pointer = TableInfo.Pointer;
AcpiTables[TABLE_RSDT].Length = TableInfo.Length;
AcpiTables[TABLE_RSDT].Allocation = TableInfo.Allocation;
/* Valid RSDT pointer */
if (strncmp (RSDT->header.Signature, RSDT_SIG, 4))
{
/* Invalid RSDT signature */
REPORT_ERROR ("Invalid signature where RSDP indicates RSDT should be located");
DEBUG_PRINT (ACPI_INFO,
("RSDP indicates RSDT should be located at %lXh, however the table\n"
" signature at %lXh is incorrect.\n"
" Expected signature: 'RSDT' Actual signature: '%4.4s'\n",
RSDP->RsdtPhysicalAddress, RSDP->RsdtPhysicalAddress,
RSDT->header.Signature));
return_ACPI_STATUS (AE_BAD_SIGNATURE);
}
/* Valid RSDT signature, verify the checksum */
DEBUG_PRINT (ACPI_INFO, ("RSDT located at %p, physical address %lX\n",
RSDT, RSDP->RsdtPhysicalAddress));
Status = NsVerifyTableChecksum (RSDT);
/* Determine the number of tables pointed to by the RSDT */
*NumberOfTables = (INT32) (RSDT->header.Length - sizeof (ACPI_TABLE_HEADER)) / 4;
return_ACPI_STATUS (Status);
}
/******************************************************************************
*
* FUNCTION: CmInstallTable
*
* PARAMETERS: TablePtr - Input buffer pointer, optional
* TableInfo - Return value from NsGetTable
*
* RETURN: Status
*
* DESCRIPTION: Load and validate all tables other than the RSDT. The RSDT must
* already be loaded and validated.
*
******************************************************************************/
ACPI_STATUS
CmInstallTable (
char **TablePtr,
ACPI_TABLE_INFO *TableInfo)
{
ACPI_TABLE_HEADER *TableHeader = NULL;
ACPI_STATUS Status = AE_OK;
ACPI_TABLE_TYPE TableType;
char *TableName;
void **TableGlobalPtr;
FUNCTION_TRACE ("CmInstallTable");
/* Ensure that we have a valid table pointer */
TableHeader = (ACPI_TABLE_HEADER *) TableInfo->Pointer;
if (!TableHeader)
{
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
/*
* Determine the table type from the 4-character signature
*/
if (!strncmp (TableHeader->Signature, FACP_SIG, 4))
{
TableType = TABLE_FACP;
TableName = FACP_SIG;
TableGlobalPtr = (void **) &FACP;
}
else if (!strncmp (TableHeader->Signature, FACS_SIG, 4))
{
TableType = TABLE_FACS;
TableName = FACS_SIG;
TableGlobalPtr = (void **) &FACS;
}
else if (!strncmp (TableHeader->Signature, DSDT_SIG, 4))
{
TableType = TABLE_DSDT;
TableName = DSDT_SIG;
TableGlobalPtr = (void **) &DSDT;
}
else if (!strncmp (TableHeader->Signature, APIC_SIG, 4))
{
/* APIC table */
TableType = TABLE_APIC;
TableName = APIC_SIG;
TableGlobalPtr = (void **) &APIC;
}
else if (!strncmp (TableHeader->Signature, PSDT_SIG, 4))
{
/* PSDT table */
TableType = TABLE_PSDT;
TableName = PSDT_SIG;
TableGlobalPtr = (void **) &PSDT;
}
else if (!strncmp (TableHeader->Signature, SSDT_SIG, 4))
{
/* SSDT table */
/* TBD - need to be able to deal with multiple SSDTs */
TableType = TABLE_SSDT;
TableName = SSDT_SIG;
TableGlobalPtr = (void **) &SSDT;
}
else if (!strncmp (TableHeader->Signature, SBDT_SIG, 4))
{
/* SBDT table */
TableType = TABLE_SBDT;
TableName = SBDT_SIG;
TableGlobalPtr = (void **) &SBDT;
}
else
{
/* Unknown table */
DEBUG_PRINT (ACPI_ERROR, ("Unknown table at %x in RSDT with signature '%4.4s'\n",
TableHeader, TableHeader->Signature));
REPORT_ERROR ("Unknown table in the RSDT");
NsVerifyTableChecksum (TableHeader);
/*
* TBD: - need to be able to handle multiple unknown tables. Error should be
* displayed when table is displayed, Displaying it here for now
*/
DUMP_BUFFER (TableHeader, 32, 0);
return_ACPI_STATUS (AE_BAD_SIGNATURE);
}
/*
* Common table installation code
*/
if (ACPI_SUCCESS (Status))
{
/* Delete existing table if there is one */
NsDeleteAcpiTable (TableType);
/* Save the table pointers and allocation info */
*TableGlobalPtr = TableHeader;
AcpiTables[TableType].Pointer = TableInfo->Pointer;
AcpiTables[TableType].Length = TableInfo->Length;
AcpiTables[TableType].Allocation = TableInfo->Allocation;
DEBUG_PRINT (ACPI_INFO, ("%s located at %p\n", TableName, TableHeader));
/* Validate checksum for _most_ tables */
if (TableType != TABLE_FACS)
{
NsVerifyTableChecksum (TableHeader);
}
}
return_ACPI_STATUS (Status);
}
/******************************************************************************
*
* FUNCTION: CmGetAllTables
*
* PARAMETERS: NumberOfTables - Number of tables to get
* TablePtr - Input buffer pointer, optional
*
* RETURN: Status
*
* DESCRIPTION: Load and validate all tables other than the RSDT. The RSDT must
* already be loaded and validated.
*
******************************************************************************/
ACPI_STATUS
CmGetAllTables (
UINT32 NumberOfTables,
char **TablePtr)
{
ACPI_STATUS Status = AE_OK;
UINT32 Index;
ACPI_TABLE_INFO TableInfo;
FUNCTION_TRACE ("CmGetAllTables");
DEBUG_PRINT (ACPI_INFO, ("Number of tables: %d\n", NumberOfTables));
/*
* Loop through all table pointers found in RSDT.
* This will NOT include the FACS and DSDT - we must get
* them after the loop
*/
for (Index = 0; Index < NumberOfTables; Index++)
{
/* Get the table via the RSDT */
Status = NsGetTable ((void *) RSDT->TableOffsetEntry[Index],
TablePtr, &TableInfo);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
/* Recognize and install the table */
Status = CmInstallTable (TablePtr, &TableInfo);
if (ACPI_FAILURE (Status))
{
if (Status == AE_BAD_SIGNATURE)
{
/* Unrecognized table, just delete it and ignore the error */
NsFreeAcpiTable (&TableInfo);
}
else
{
/* Abort on a serious error */
return_ACPI_STATUS (Status);
}
}
}
/*
* Get the FACS (must have the FACP first, from loop above)
* NsGetTableFacs will fail if FACP pointer is not valid
*/
Status = NsGetTableFacs (TablePtr, &TableInfo);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
/* Install the FACS */
Status = CmInstallTable (TablePtr, &TableInfo);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
/* Get the DSDT (must have the FACP first, from loop above) */
Status = NsGetTable ((void *) FACP->Dsdt, TablePtr, &TableInfo);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
/* Install the DSDT */
Status = CmInstallTable (TablePtr, &TableInfo);
if (ACPI_FAILURE (Status))
{
return_ACPI_STATUS (Status);
}
/* Dump the DSDT Header */
DEBUG_PRINT (TRACE_TABLES, ("Hex dump of DSDT Header:\n"));
DUMP_BUFFER ((UINT8 *) DSDT,
(ACPI_SIZE) sizeof (ACPI_TABLE_HEADER), HEX | ASCII);
/* Dump the entire DSDT */
DEBUG_PRINT (TRACE_TABLES,
("Hex dump of DSDT (After header), size %d (0x%x)\n",
(ACPI_SIZE)DSDT->Length, (ACPI_SIZE)DSDT->Length));
DUMP_BUFFER ((UINT8 *) (DSDT + 1),
(ACPI_SIZE)DSDT->Length, HEX | ASCII);
/*
* Initialize the capabilities flags.
* Assumes that platform supports ACPI_MODE since we have tables!
*/
SystemFlags |= HwGetModeCapabilities ();
return_ACPI_STATUS (Status);
}
/*******************************************************************************
*
* FUNCTION: CmFacpRegisterError
@ -613,9 +181,9 @@ CmHardwareInitialize (void)
/* We must have an the ACPI tables by the time we get here */
if (!FACP)
if (!Gbl_FACP)
{
RestoreAcpiChipset = FALSE;
Gbl_RestoreAcpiChipset = FALSE;
DEBUG_PRINT (ACPI_ERROR, ("CmHardwareInitialize: No FACP!\n"));
@ -635,20 +203,20 @@ CmHardwareInitialize (void)
*/
switch (SystemFlags & SYS_MODES_MASK)
switch (Gbl_SystemFlags & SYS_MODES_MASK)
{
/* Identify current ACPI/legacy mode */
case (SYS_MODE_ACPI):
OriginalMode = SYS_MODE_ACPI;
Gbl_OriginalMode = SYS_MODE_ACPI;
DEBUG_PRINT (ACPI_INFO, ("System supports ACPI mode only.\n"));
break;
case (SYS_MODE_LEGACY):
OriginalMode = SYS_MODE_LEGACY;
Gbl_OriginalMode = SYS_MODE_LEGACY;
DEBUG_PRINT (ACPI_INFO,
("Tables loaded from buffer, hardware assumed to support LEGACY mode only.\n"));
break;
@ -658,22 +226,22 @@ CmHardwareInitialize (void)
if (HwGetMode () == SYS_MODE_ACPI)
{
OriginalMode = SYS_MODE_ACPI;
Gbl_OriginalMode = SYS_MODE_ACPI;
}
else
{
OriginalMode = SYS_MODE_LEGACY;
Gbl_OriginalMode = SYS_MODE_LEGACY;
}
DEBUG_PRINT (ACPI_INFO, ("System supports both ACPI and LEGACY modes.\n"));
DEBUG_PRINT (ACPI_INFO, ("System is currently in %s mode.\n",
(OriginalMode == SYS_MODE_ACPI) ? "ACPI" : "LEGACY"));
(Gbl_OriginalMode == SYS_MODE_ACPI) ? "ACPI" : "LEGACY"));
break;
}
if (SystemFlags & SYS_MODE_ACPI)
if (Gbl_SystemFlags & SYS_MODE_ACPI)
{
/* Target system supports ACPI mode */
@ -692,10 +260,10 @@ CmHardwareInitialize (void)
* be modified. The PM1bEvtBlk behaves as expected.
*/
Pm1EnableRegisterSave = OsdIn16 ((UINT16) (FACP->Pm1aEvtBlk + 2));
if (FACP->Pm1bEvtBlk)
Gbl_Pm1EnableRegisterSave = OsdIn16 ((Gbl_FACP->Pm1aEvtBlk + 2));
if (Gbl_FACP->Pm1bEvtBlk)
{
Pm1EnableRegisterSave |= OsdIn16 ((UINT16) (FACP->Pm1bEvtBlk + 2));
Gbl_Pm1EnableRegisterSave |= OsdIn16 ((Gbl_FACP->Pm1bEvtBlk + 2));
}
@ -704,52 +272,52 @@ CmHardwareInitialize (void)
* block is not fixed, so the buffer must be allocated with malloc
*/
if (FACP->Gpe0Blk && FACP->Gpe0BlkLen)
if (Gbl_FACP->Gpe0Blk && Gbl_FACP->Gpe0BlkLen)
{
/* GPE0 specified in FACP */
Gpe0EnableRegisterSave = CmAllocate ((ACPI_SIZE) (FACP->Gpe0BlkLen / 2));
if (!Gpe0EnableRegisterSave)
Gbl_Gpe0EnableRegisterSave = CmAllocate ((ACPI_SIZE) (Gbl_FACP->Gpe0BlkLen / 2));
if (!Gbl_Gpe0EnableRegisterSave)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
/* Save state of GPE0 enable bits */
for (Index = 0; Index < FACP->Gpe0BlkLen / 2; Index++)
for (Index = 0; Index < Gbl_FACP->Gpe0BlkLen / 2; Index++)
{
Gpe0EnableRegisterSave[Index] =
OsdIn8 ((UINT16) (FACP->Gpe0Blk + FACP->Gpe0BlkLen / 2));
Gbl_Gpe0EnableRegisterSave[Index] =
OsdIn8 ((Gbl_FACP->Gpe0Blk + Gbl_FACP->Gpe0BlkLen / 2));
}
}
else
{
Gpe0EnableRegisterSave = NULL;
Gbl_Gpe0EnableRegisterSave = NULL;
}
if (FACP->Gpe1Blk && FACP->Gpe1BlkLen)
if (Gbl_FACP->Gpe1Blk && Gbl_FACP->Gpe1BlkLen)
{
/* GPE1 defined */
Gpe1EnableRegisterSave = CmAllocate ((ACPI_SIZE) (FACP->Gpe1BlkLen / 2));
if (!Gpe1EnableRegisterSave)
Gbl_Gpe1EnableRegisterSave = CmAllocate ((ACPI_SIZE) (Gbl_FACP->Gpe1BlkLen / 2));
if (!Gbl_Gpe1EnableRegisterSave)
{
return_ACPI_STATUS (AE_NO_MEMORY);
}
/* save state of GPE1 enable bits */
for (Index = 0; Index < FACP->Gpe1BlkLen / 2; Index++)
for (Index = 0; Index < Gbl_FACP->Gpe1BlkLen / 2; Index++)
{
Gpe1EnableRegisterSave[Index] =
OsdIn8 ((UINT16) (FACP->Gpe1Blk + FACP->Gpe1BlkLen / 2));
Gbl_Gpe1EnableRegisterSave[Index] =
OsdIn8 ((Gbl_FACP->Gpe1Blk + Gbl_FACP->Gpe1BlkLen / 2));
}
}
else
{
Gpe1EnableRegisterSave = NULL;
Gbl_Gpe1EnableRegisterSave = NULL;
}
@ -758,40 +326,40 @@ CmHardwareInitialize (void)
* 4.7.1.2 and 5.2.5 (assertions #410, 415, 435-440)
*/
if (FACP->Pm1EvtLen < 4)
CmFacpRegisterError ("PM1_EVT_LEN", (UINT32) FACP->Pm1EvtLen,
if (Gbl_FACP->Pm1EvtLen < 4)
CmFacpRegisterError ("PM1_EVT_LEN", (UINT32) Gbl_FACP->Pm1EvtLen,
ACPI_TABLE_NAMESPACE_SECTION, 410); /* #410 == #435 */
if (!FACP->Pm1CntLen)
CmFacpRegisterError ("PM1_CNT_LEN", (UINT32) FACP->Pm1CntLen,
if (!Gbl_FACP->Pm1CntLen)
CmFacpRegisterError ("PM1_CNT_LEN", (UINT32) Gbl_FACP->Pm1CntLen,
ACPI_TABLE_NAMESPACE_SECTION, 415); /* #415 == #436 */
if (!FACP->Pm1aEvtBlk)
CmFacpRegisterError ("PM1a_EVT_BLK", FACP->Pm1aEvtBlk,
if (!Gbl_FACP->Pm1aEvtBlk)
CmFacpRegisterError ("PM1a_EVT_BLK", Gbl_FACP->Pm1aEvtBlk,
ACPI_TABLE_NAMESPACE_SECTION, 432);
if (!FACP->Pm1aCntBlk)
CmFacpRegisterError ("PM1a_CNT_BLK", FACP->Pm1aCntBlk,
if (!Gbl_FACP->Pm1aCntBlk)
CmFacpRegisterError ("PM1a_CNT_BLK", Gbl_FACP->Pm1aCntBlk,
ACPI_TABLE_NAMESPACE_SECTION, 433);
if (!FACP->PmTmrBlk)
CmFacpRegisterError ("PM_TMR_BLK", FACP->PmTmrBlk,
if (!Gbl_FACP->PmTmrBlk)
CmFacpRegisterError ("PM_TMR_BLK", Gbl_FACP->PmTmrBlk,
ACPI_TABLE_NAMESPACE_SECTION, 434);
if (FACP->Pm2CntBlk && !FACP->Pm2CntLen)
CmFacpRegisterError ("PM2_CNT_LEN", (UINT32) FACP->Pm2CntLen,
if (Gbl_FACP->Pm2CntBlk && !Gbl_FACP->Pm2CntLen)
CmFacpRegisterError ("PM2_CNT_LEN", (UINT32) Gbl_FACP->Pm2CntLen,
ACPI_TABLE_NAMESPACE_SECTION, 437);
if (FACP->PmTmLen < 4)
CmFacpRegisterError ("PM_TM_LEN", (UINT32) FACP->PmTmLen,
if (Gbl_FACP->PmTmLen < 4)
CmFacpRegisterError ("PM_TM_LEN", (UINT32) Gbl_FACP->PmTmLen,
ACPI_TABLE_NAMESPACE_SECTION, 438);
if (FACP->Gpe0Blk && (FACP->Gpe0BlkLen & 1)) /* length not multiple of 2 */
CmFacpRegisterError ("GPE0_BLK_LEN", (UINT32) FACP->Gpe0BlkLen,
if (Gbl_FACP->Gpe0Blk && (Gbl_FACP->Gpe0BlkLen & 1)) /* length not multiple of 2 */
CmFacpRegisterError ("GPE0_BLK_LEN", (UINT32) Gbl_FACP->Gpe0BlkLen,
ACPI_TABLE_NAMESPACE_SECTION, 439);
if (FACP->Gpe1Blk && (FACP->Gpe1BlkLen & 1)) /* length not multiple of 2 */
CmFacpRegisterError ("GPE1_BLK_LEN", (UINT32) FACP->Gpe1BlkLen,
if (Gbl_FACP->Gpe1Blk && (Gbl_FACP->Gpe1BlkLen & 1)) /* length not multiple of 2 */
CmFacpRegisterError ("GPE1_BLK_LEN", (UINT32) Gbl_FACP->Gpe1BlkLen,
ACPI_TABLE_NAMESPACE_SECTION, 440);
}
@ -801,5 +369,47 @@ BREAKPOINT3;
}
/******************************************************************************
*
* FUNCTION: CmTerminate
*
* PARAMETERS: none
*
* RETURN: none
*
* DESCRIPTION: free memory allocated for table storage.
*
******************************************************************************/
void
CmTerminate (void)
{
FUNCTION_TRACE ("CmTerminate");
/* Free global tables, etc. */
if (Gbl_Gpe0EnableRegisterSave)
{
CmFree (Gbl_Gpe0EnableRegisterSave);
}
if (Gbl_Gpe1EnableRegisterSave)
{
CmFree (Gbl_Gpe1EnableRegisterSave);
}
/* Free the mutex objects */
CmMutexTerminate ();
return_VOID;
}