Global rename of identifiers and constants

date	2000.06.13.18.22.00;	author rmoore1;	state Exp;
This commit is contained in:
aystarik 2005-06-29 20:39:02 +00:00
parent 078edf2bae
commit e421b43c53
3 changed files with 150 additions and 461 deletions

View File

@ -123,11 +123,11 @@
#include <stdio.h>
extern UINT8 *DsdtPtr;
extern UINT32 DsdtLength;
extern UINT32 AcpiDsdtLength;
extern int optind;
extern char *optarg;
extern UINT8 *AmlPtr;
extern UINT32 AmlLength;
extern UINT32 AcpiAmlLength;
extern char LineBuf[80];
extern char CommandBuf[40];
@ -188,7 +188,7 @@ typedef union ptr_ovl
#define TEST_OUTPUT_LEVEL(lvl) if ((lvl) & OutputLevel)
#define OSD_PRINT(lvl,fp) TEST_OUTPUT_LEVEL(lvl) {\
OsdPrintf PARAM_LIST(fp);}
AcpiOsdPrintf PARAM_LIST(fp);}
int
getopt (

View File

@ -114,11 +114,11 @@
*****************************************************************************/
#include <acpi.h>
#include <parser.h>
#include <amlcode.h>
#include <namesp.h>
#include <debugger.h>
#include "acpi.h"
#include "parser.h"
#include "amlcode.h"
#include "namesp.h"
#include "debugger.h"
#include "aecommon.h"
#include <stdio.h>
@ -130,12 +130,12 @@
ACPI_GENERIC_OP *Gbl_ParsedNamespaceRoot;
ACPI_GENERIC_OP *Acpi_GblParsedNamespaceRoot;
ACPI_GENERIC_OP *root;
UINT8 *AmlPtr;
UINT32 AmlLength;
UINT32 AcpiAmlLength;
UINT8 *DsdtPtr;
UINT32 DsdtLength;
UINT32 AcpiDsdtLength;
DEBUG_REGIONS Regions;
@ -175,7 +175,7 @@ RegionHandler (
/*
* If the object is not a region, simply return
*/
if (RegionObject->Region.Type != ACPI_TYPE_Region)
if (RegionObject->Region.Type != ACPI_TYPE_REGION)
{
return AE_OK;
}
@ -218,16 +218,16 @@ RegionHandler (
/*
* Do the memory allocations first
*/
RegionElement = malloc (sizeof(REGION));
RegionElement = AcpiOsdAllocate (sizeof(REGION));
if (!RegionElement)
{
return AE_NO_MEMORY;
}
RegionElement->Buffer = malloc (Length);
RegionElement->Buffer = AcpiOsdAllocate (Length);
if (!RegionElement->Buffer)
{
free(RegionElement);
AcpiOsdFree (RegionElement);
return AE_NO_MEMORY;
}
@ -257,8 +257,11 @@ RegionHandler (
/*
* The buffer exists and is pointed to by RegionElement.
* We now need to verify the request is valid and perform the operation.
*
* NOTE: RegionElement->Length is in bytes, therefore it is multiplied by
* the bitwidth of a byte.
*/
if (RegionElement->Address + RegionElement->Length < Address + BitWidth)
if ((Address + BitWidth) > (RegionElement->Address + (RegionElement->Length * 8)))
{
return AE_BUFFER_OVERFLOW;
}
@ -305,6 +308,34 @@ RegionHandler (
}
/******************************************************************************
*
* FUNCTION: RegionInit
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Opregion init function.
*
*****************************************************************************/
ACPI_STATUS
RegionInit (
ACPI_HANDLE RegionHandle,
UINT32 Function,
void *HandlerContext,
void **ReturnContext)
{
/*
* Real simple, set the ReturnContext to the RegionHandle
*/
*ReturnContext = RegionHandle;
return AE_OK;
}
/******************************************************************************
*
* FUNCTION: NotifyHandler
@ -329,10 +360,10 @@ NotifyHandler (
switch (Value)
{
case 0:
printf ("**** Method Error: Results not equal\n");
printf ("**** Method Error 0x%X: Results not equal\n", Value);
if (DebugFile)
{
OsdPrintf ("**** Method Error: Results not equal\n");
AcpiOsdPrintf ("**** Method Error: Results not equal\n");
}
break;
@ -341,7 +372,7 @@ NotifyHandler (
printf ("**** Method Error: Incorrect numeric result\n");
if (DebugFile)
{
OsdPrintf ("**** Method Error: Incorrect numeric result\n");
AcpiOsdPrintf ("**** Method Error: Incorrect numeric result\n");
}
break;
@ -350,16 +381,16 @@ NotifyHandler (
printf ("**** Method Error: An operand was overwritten\n");
if (DebugFile)
{
OsdPrintf ("**** Method Error: An operand was overwritten\n");
AcpiOsdPrintf ("**** Method Error: An operand was overwritten\n");
}
break;
default:
printf ("**** Unknown notify value=%d\n", Value);
printf ("**** Received a notify, value 0x%X\n", Value);
if (DebugFile)
{
OsdPrintf ("**** Unknown notify value=%d\n", Value);
AcpiOsdPrintf ("**** Received a notify, value 0x%X\n", Value);
}
break;
}
@ -396,12 +427,12 @@ AeInstallHandlers (void)
for (i = 0; i < 3; i++)
{
Status = AcpiRemoveAddressSpaceHandler (Gbl_RootObject, i, RegionHandler);
Status = AcpiRemoveAddressSpaceHandler (Acpi_GblRootObject, i, RegionHandler);
/* Install handler at the root object.
* TBD: all default handlers should be installed here!
*/
Status = AcpiInstallAddressSpaceHandler (Gbl_RootObject, i, RegionHandler, NULL);
Status = AcpiInstallAddressSpaceHandler (Acpi_GblRootObject, i, RegionHandler, RegionInit, NULL);
if (ACPI_FAILURE (Status))
{
printf ("Could not install an OpRegion handler\n");
@ -419,70 +450,6 @@ AeInstallHandlers (void)
}
/****************************************************************************
*
* FUNCTION: TbDeleteAcpiTables
*
* PARAMETERS: None.
*
* RETURN: None.
*
* DESCRIPTION: Placeholder, required for linking
*
***************************************************************************/
void
TbDeleteAcpiTables (void)
{
}
/*****************************************************************************
*
* FUNCTION: TbSystemTablePointer
*
* PARAMETERS: *Where - Pointer to be examined
*
* RETURN: TRUE if Where is within the AML stream (in one of the ACPI
* system tables such as the DSDT or an SSDT.)
* FALSE otherwise
*
****************************************************************************/
BOOLEAN
TbSystemTablePointer (
void *Where)
{
/* No function trace, called too often! */
/* Ignore null pointer */
if (!Where)
{
return (FALSE);
}
/* Check for a pointer within the DSDT */
if (IS_IN_ACPI_TABLE (Where, Gbl_DSDT))
{
return (TRUE);
}
return (FALSE);
}
/******************************************************************************
*
* FUNCTION: AdSecondPassParse
@ -507,14 +474,16 @@ AdSecondPassParse (
UINT32 BaseAmlOffset;
printf ("Pass two parse ....\n");
/* Walk entire tree */
while (Op)
{
if (Op->Opcode == AML_MethodOp)
/* We are looking for control methods */
if (Op->Opcode == AML_METHOD_OP)
{
Method = (ACPI_DEFERRED_OP *) Op;
Status = PsParseAml (Op, Method->Body, Method->BodyLength);
Status = AcpiPsParseAml (Op, Method->Body, Method->BodyLength, 0);
BaseAmlOffset = (Method->Value.Arg)->AmlOffset + 1;
@ -524,17 +493,17 @@ AdSecondPassParse (
while (SearchOp)
{
SearchOp->AmlOffset += BaseAmlOffset;
SearchOp = PsGetDepthNext (StartOp, SearchOp);
SearchOp = AcpiPsGetDepthNext (StartOp, SearchOp);
}
}
if (Op->Opcode == AML_RegionOp)
if (Op->Opcode == AML_REGION_OP)
{
/* TBD: this isn't quite the right thing to do! */
// Method = (ACPI_DEFERRED_OP *) Op;
// Status = PsParseAml (Op, Method->Body, Method->BodyLength);
// Status = AcpiPsParseAml (Op, Method->Body, Method->BodyLength);
}
if (ACPI_FAILURE (Status))
@ -542,7 +511,7 @@ AdSecondPassParse (
return Status;
}
Op = PsGetDepthNext (Root, Op);
Op = AcpiPsGetDepthNext (Root, Op);
}
return Status;
@ -563,66 +532,17 @@ AdSecondPassParse (
*****************************************************************************/
ACPI_STATUS
AdGetTables (
xxxAdGetTables (
char *Filename)
{
ACPI_STATUS Status;
Status = DbLoadAcpiTable (Filename);
return Status;
}
/******************************************************************************
*
* FUNCTION: AdParseTable
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Parse all supported tables
*
*****************************************************************************/
ACPI_STATUS
AdParseTables (void)
{
ACPI_STATUS Status;
if (!DsdtPtr)
{
return AE_NOT_EXIST;
}
AmlPtr = DsdtPtr + sizeof (ACPI_TABLE_HEADER);
AmlLength = DsdtLength - sizeof (ACPI_TABLE_HEADER);
// Status = PsParseTable (PcodeAddr, PcodeLength, PsxLoadBeginOp, PsxLoadEndOp, NULL);
// Status = PsParseTable (AmlPtr, AmlLength, PsxLoadBeginOp, PsxLoadEndOp, &root);
Status = NsSetup ();
if (ACPI_FAILURE (Status))
{
return (Status);
}
Status = PsxLoadTable (AmlPtr, AmlLength);
if (ACPI_SUCCESS (Status))
{
Status = AdSecondPassParse (root);
}
Status = AcpiDbLoadAcpiTable (Filename);
return Status;
}

View File

@ -1,4 +1,4 @@
/******************************************************************************
/******************************************************************************
*
* Module Name: aemain - Main routine for the AcpiExec utility
*
@ -117,12 +117,14 @@
#include <stdlib.h>
#include <string.h>
#include <acpi.h>
#include <acapi.h>
#include <amlcode.h>
#include <parser.h>
#include <tables.h>
#include <namesp.h>
#include "acpi.h"
#include "acapi.h"
#include "amlcode.h"
#include "parser.h"
#include "tables.h"
#include "namesp.h"
#include "interp.h"
#include "debugger.h"
#include "aecommon.h"
@ -131,60 +133,9 @@
MODULE_NAME ("aemain");
char *Version = "X002";
char LineBuf[80];
char CommandBuf[40];
char ArgBuf[40];
char ScopeBuf[40];
char DebugFilename[40];
FILE *DebugFile = NULL;
char *Buffer;
char *Filename = NULL;
int opt_tables = FALSE;
int opt_disasm = FALSE;
int opt_stats = FALSE;
char *Version = "X004";
/*
* AcpiExec commands
*/
#define CMD_NULL 0
#define CMD_ALLOCATIONS 1
#define CMD_CLOSE 2
#define CMD_DEBUG 3
#define CMD_DUMP 4
#define CMD_EXECUTE 5
#define CMD_EXIT 6
#define CMD_HELP 7
#define CMD_HELP2 8
#define CMD_METHODS 9
#define CMD_NAMESPACE 10
#define CMD_OPEN 11
#define CMD_QUIT 12
#define CMD_SCOPE 13
#define CMD_NOT_FOUND (-1)
#define NUM_COMMANDS 13
char *Commands[NUM_COMMANDS] = {
"ALLOCATIONS",
"CLOSE",
"DEBUG",
"DUMP",
"EXECUTE",
"EXIT",
"HELP",
"?",
"METHODS",
"NAMESPACE",
"OPEN",
"QUIT",
"SCOPE"};
/******************************************************************************
*
* FUNCTION: usage
@ -200,261 +151,17 @@ char *Commands[NUM_COMMANDS] = {
void
usage (void)
{
printf ("Usage: acpiexec [-dgs] [-l DebugLevel] [-o OutputFile] [AcpiTableFile]\n");
printf ("Usage: acpiexec [-dgjs] [-l DebugLevel] [-o OutputFile] [AcpiTableFile]\n");
printf ("Where:\n");
printf (" Input Options\n");
printf (" AcpiTableFile Get ACPI tables from this file\n");
printf (" Output Options\n");
printf (" Miscellaneous Options\n");
printf (" -j Just-in-time method parsing\n");
printf (" -l DebugLevel Specify debug output level\n");
}
/******************************************************************************
*
* FUNCTION: AeDisplayHelp
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Print a usage message
*
*****************************************************************************/
void
AeDisplayHelp (void)
{
printf ("AcpiExec command line interpreter\n\n");
printf ("Allocations Display memory allocation info\n");
printf ("Close Close debug output file\n");
printf ("Debug <DebugLevel> Set level of debug output\n");
printf ("Execute <Method Path> Execute control method (full pathname)\n");
printf ("Help This help screen\n");
printf ("Methods [<lines per screen>] Display list of loaded control methods\n");
printf ("Open <Debug Filename> Open a file for debug output\n");
printf ("Quit Exit this command\n");
printf ("Scope <Scope Path> Set or Get current scope\n");
}
/******************************************************************************
*
* FUNCTION: GetLine
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Get the next command line from the user. Gets entire line
* up to the next newline
*
*****************************************************************************/
void
GetLine (void)
{
UINT32 Temp;
UINT32 i;
CommandBuf[0] = 0;
ArgBuf[0] = 0;
for (i = 0; ; i++)
{
Temp = getchar ();
if (!Temp || Temp == '\n')
{
break;
}
LineBuf [i] = (char) Temp;
}
LineBuf [i] = 0;
strupr (LineBuf);
sscanf (LineBuf, "%s %s", CommandBuf, ArgBuf);
}
/******************************************************************************
*
* FUNCTION: AeMatchCommand
*
* PARAMETERS: UserCommand - User command line
*
* RETURN: Index into command array, -1 if not found
*
* DESCRIPTION: Search command array for a command match
*
*****************************************************************************/
INT32
AeMatchCommand (
char *UserCommand)
{
UINT32 i;
if (UserCommand[0] == 0)
{
return 0;
}
for (i = 0; i < NUM_COMMANDS; i++)
{
if (strstr (Commands[i], UserCommand) == Commands[i])
{
return i + 1;
}
}
/* Command not recognized */
return -1;
}
/******************************************************************************
*
* FUNCTION: AeExecuter
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Command line execution for AcpiExec utility. Commands are
* matched and dispatched here.
*
*****************************************************************************/
void
AeExecuter (void)
{
UINT32 Temp;
INT32 CommandIndex;
ACPI_STATUS Status;
AcpiInitialize (NULL);
/* Always have to get the tables! */
Status = AdGetTables (Filename);
if (ACPI_FAILURE (Status))
{
printf ("Could not get ACPI tables (Exception %s)\n", Gbl_ExceptionNames[Status]);
goto Cleanup;
}
/* Always parse the tables, only option is what to display */
Status = AdParseTables ();
if (ACPI_FAILURE (Status))
{
printf ("Could not parse ACPI tables (Exception %s)\n", Gbl_ExceptionNames[Status]);
goto Cleanup;
}
Status = AeInstallHandlers ();
/*
Status = AcpiLoadNamespace ();
if (ACPI_FAILURE (Status))
{
printf ("Could not load the namespace (Exception %s)\n", Gbl_ExceptionNames[Status]);
goto Cleanup;
}
*/
setvbuf (stdin, NULL, _IONBF, 0);
ScopeBuf [0] = '\\';
ScopeBuf [1] = 0;
for (; ;)
{
printf ("- ");
GetLine ();
CommandIndex = AeMatchCommand (CommandBuf);
switch (CommandIndex)
{
case CMD_NULL:
break;
case CMD_ALLOCATIONS:
CmDumpAllocationInfo ();
break;
case CMD_OPEN:
DebugLevel = 0x0FFFFFFF;
AeOpenDebugFile (ArgBuf);
break;
case CMD_CLOSE:
AeCloseDebugFile ();
break;
case CMD_DEBUG:
DebugLevel = strtoul (ArgBuf, NULL, 0);
printf ("Debug Level: %0lX\n", DebugLevel);
break;
case CMD_DUMP:
AeDumpBuffer (strtoul (ArgBuf, NULL, 0));
break;
case CMD_EXECUTE:
if (DebugFile && !DebugLevel)
{
printf ("Debug output is not enabled!\n");
}
AeExecute (ArgBuf);
break;
case CMD_HELP:
case CMD_HELP2:
AeDisplayHelp ();
break;
case CMD_METHODS:
Temp = strtoul (ArgBuf, NULL, 0);
AeDisplayAllMethods (Temp);
break;
case CMD_NAMESPACE:
AeDumpNamespace ();
break;
case CMD_SCOPE:
AeSetScope (ArgBuf);
break;
case CMD_EXIT:
case CMD_QUIT:
if (!DebugFile)
{
DebugLevel = DEBUG_DEFAULT;
}
AcpiTerminate ();
AeCloseDebugFile ();
return;
case CMD_NOT_FOUND:
printf ("Unknown Command\n");
}
}
Cleanup:
if (DsdtPtr)
free (DsdtPtr);
}
/******************************************************************************
*
@ -474,25 +181,29 @@ main (
char **argv)
{
int j;
ACPI_STATUS Status;
/* Init globals */
Buffer = malloc (BUFFER_SIZE);
DebugLevel = DEBUG_DEFAULT;
DebugLevel = DEBUG_DEFAULT & (~TRACE_TABLES);
DebugLayer = 0xFFFFFFFF;
printf ("ACPI AML Execution Utility version %s\n", Version);
if (argc < 2)
{
usage ();
return 0;
}
printf ("ACPI AML Execution/Debug Utility ");
#ifdef _IA16
printf ("16-bit ");
#else
printf ("32-bit ");
#endif
printf ("version [%s]\n", __DATE__);
/* Get the command line options */
while ((j = getopt (argc, argv, "dgl:o:s")) != EOF) switch(j)
while ((j = getopt (argc, argv, "dgjl:o:s")) != EOF) switch(j)
{
case 'd':
opt_disasm = TRUE;
@ -504,6 +215,10 @@ main (
Filename = NULL;
break;
case 'j':
opt_parse_jit = TRUE;
break;
case 'l':
DebugLevel = strtoul (optarg, NULL, 0);
printf ("Debug Level: %lX\n", DebugLevel);
@ -522,16 +237,70 @@ main (
return -1;
}
/* Init ACPI and start debugger thread */
AcpiInitialize (NULL);
/* Standalone filename is the only argument */
if (argv[optind])
{
opt_tables = TRUE;
Filename = argv[optind];
Status = AcpiDbLoadAcpiTable (Filename);
if (ACPI_FAILURE (Status))
{
goto enterloop;
}
AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT);
Status = AcpiLoadNamespace ();
AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT);
if (ACPI_FAILURE (Status))
{
goto enterloop;
}
/* TBD:
* Need a way to call this after the "LOAD" command
*/
AeInstallHandlers ();
}
#ifdef _IA16
else
{
Status = AdFindDsdt (NULL, NULL);
if (ACPI_FAILURE (Status))
{
goto enterloop;
}
AcpiDbSetOutputDestination (DB_REDIRECTABLE_OUTPUT);
Status = AcpiLoadNamespace ();
AcpiDbSetOutputDestination (DB_CONSOLE_OUTPUT);
if (ACPI_FAILURE (Status))
{
goto enterloop;
}
AeExecuter ();
/* TBD:
* Need a way to call this after the "LOAD" command
*/
AeInstallHandlers ();
}
#endif
enterloop:
/* Enter the debugger command loop */
AcpiDbUserCommands (DB_COMMAND_PROMPT, NULL);
return 0;
}