mirror of
https://github.com/acpica/acpica/
synced 2025-02-28 19:35:03 +03:00
Automated cleanup
date 2005.06.17.20.23.00; author rmoore1; state Exp;
This commit is contained in:
parent
85b109816c
commit
1ce577536e
@ -2,7 +2,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Module Name: abcompare - compare AML files
|
||||
* $Revision: 1.20 $
|
||||
* $Revision: 1.21 $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
@ -532,7 +532,7 @@ AbCompareAmlFiles (
|
||||
{
|
||||
if (Char1 != Char2)
|
||||
{
|
||||
printf ("Error - Byte mismatch at offset %8.8X: 0x%2.2X 0x%2.2X\n",
|
||||
printf ("Error - Byte mismatch at offset %8.8X: 0x%2.2X 0x%2.2X\n",
|
||||
Offset, Char1, Char2);
|
||||
Mismatches++;
|
||||
if (Mismatches > 100)
|
||||
@ -746,7 +746,7 @@ AbExtractAmlFile (
|
||||
{
|
||||
printf ("Found table [%4.4s]\n", TableSig);
|
||||
|
||||
/*
|
||||
/*
|
||||
* Eat all lines in the table, of the form:
|
||||
* <offset>: <16 bytes of hex data, separated by spaces> <ASCII representation> <newline>
|
||||
*
|
||||
|
@ -2,7 +2,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Module Name: abmain - Main module for the acpi binary utility
|
||||
* $Revision: 1.11 $
|
||||
* $Revision: 1.12 $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
@ -147,7 +147,7 @@ AbDisplayUsage (
|
||||
}
|
||||
|
||||
printf ("Usage: acpibin [options]\n\n");
|
||||
printf ("Options:\n\n");
|
||||
printf ("Options:\n\n");
|
||||
printf (" -c <File1> <File2> Compare two AML files\n");
|
||||
printf (" -d <InFile> <OutFile> Dump AML binary to text file\n");
|
||||
printf (" -e <Sig> <InFile> <OutFile> Extract binary AML table from AcpiDmp file\n\n");
|
||||
|
@ -1,7 +1,7 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Module Name: aeexec - Top level parse and execute routines
|
||||
* $Revision: 1.38 $
|
||||
* Module Name: aeexec - Support routines for AcpiExec utility
|
||||
* $Revision: 1.86 $
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
*
|
||||
* 1. Copyright Notice
|
||||
*
|
||||
* Some or all of this work - Copyright (c) 1999, 2000, 2001, Intel Corp.
|
||||
* Some or all of this work - Copyright (c) 1999 - 2005, Intel Corp.
|
||||
* All rights reserved.
|
||||
*
|
||||
* 2. License
|
||||
@ -114,71 +114,318 @@
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#include "acpi.h"
|
||||
#include "acparser.h"
|
||||
#include "amlcode.h"
|
||||
#include "acnamesp.h"
|
||||
#include "acdebug.h"
|
||||
#include "aecommon.h"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#define _COMPONENT ACPI_TOOLS
|
||||
MODULE_NAME ("aeexec")
|
||||
ACPI_MODULE_NAME ("aeexec")
|
||||
|
||||
|
||||
ACPI_PARSE_OBJECT *AcpiGbl_ParsedNamespaceRoot;
|
||||
ACPI_PARSE_OBJECT *root;
|
||||
UINT8 *AmlPtr;
|
||||
UINT8 *AmlStart;
|
||||
UINT32 AmlLength;
|
||||
UINT8 *DsdtPtr;
|
||||
UINT32 AcpiDsdtLength;
|
||||
|
||||
DEBUG_REGIONS Regions;
|
||||
DEBUG_REGIONS AeRegions;
|
||||
RSDP_DESCRIPTOR LocalRsdp;
|
||||
|
||||
|
||||
static char *AcpiGbl_RegionNames[] = /* printable names of ACPI region types */
|
||||
/*
|
||||
* Misc ACPI tables to be installed
|
||||
*/
|
||||
unsigned char Ssdt1Code[] =
|
||||
{
|
||||
"SystemMemory",
|
||||
"SystemIO",
|
||||
"PciConfig",
|
||||
"EmbeddedControl",
|
||||
"SMBus"
|
||||
0x53,0x53,0x44,0x54,0x30,0x00,0x00,0x00, /* 00000000 "SSDT0..." */
|
||||
0x01,0xB8,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
|
||||
0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */
|
||||
0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
|
||||
0x24,0x04,0x03,0x20,0x14,0x0B,0x5F,0x54, /* 00000020 "$.. .._T" */
|
||||
0x39,0x38,0x00,0x70,0x0A,0x04,0x60,0xA4, /* 00000028 "98.p..`." */
|
||||
};
|
||||
|
||||
#define ACPI_MAX_SPACE_ID 4
|
||||
unsigned char Ssdt2Code[] =
|
||||
{
|
||||
0x53,0x53,0x44,0x54,0x30,0x00,0x00,0x00, /* 00000000 "SSDT0..." */
|
||||
0x01,0xB7,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 "..Intel." */
|
||||
0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */
|
||||
0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
|
||||
0x24,0x04,0x03,0x20,0x14,0x0B,0x5F,0x54, /* 00000020 "$.. .._T" */
|
||||
0x39,0x39,0x00,0x70,0x0A,0x04,0x60,0xA4, /* 00000028 "99.p..`." */
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
*
|
||||
* FUNCTION: AcpiUtFormatSpaceId
|
||||
*
|
||||
* PARAMETERS: Status - Acpi status to be formatted
|
||||
*
|
||||
* RETURN: Formatted status string
|
||||
*
|
||||
* DESCRIPTION: Convert an ACPI exception to a string
|
||||
*
|
||||
****************************************************************************/
|
||||
unsigned char Oem1Code[] =
|
||||
{
|
||||
0x4F,0x45,0x4D,0x31,0x38,0x00,0x00,0x00, /* 00000000 "OEM18..." */
|
||||
0x01,0x4B,0x49,0x6E,0x74,0x65,0x6C,0x00, /* 00000008 ".KIntel." */
|
||||
0x4D,0x61,0x6E,0x79,0x00,0x00,0x00,0x00, /* 00000010 "Many...." */
|
||||
0x01,0x00,0x00,0x00,0x49,0x4E,0x54,0x4C, /* 00000018 "....INTL" */
|
||||
0x18,0x09,0x03,0x20,0x08,0x5F,0x58,0x54, /* 00000020 "... ._XT" */
|
||||
0x32,0x0A,0x04,0x14,0x0C,0x5F,0x58,0x54, /* 00000028 "2...._XT" */
|
||||
0x31,0x00,0x70,0x01,0x5F,0x58,0x54,0x32, /* 00000030 "1.p._XT2" */
|
||||
|
||||
char *
|
||||
AcpiUtFormatSpaceId (
|
||||
UINT32 SpaceId)
|
||||
};
|
||||
|
||||
/*
|
||||
* We need a local FADT so that the hardware subcomponent will function,
|
||||
* even though the underlying OSD HW access functions don't do
|
||||
* anything.
|
||||
*/
|
||||
RSDP_DESCRIPTOR LocalRSDP;
|
||||
FADT_DESCRIPTOR_REV1 LocalFADT;
|
||||
FACS_DESCRIPTOR_REV1 LocalFACS;
|
||||
ACPI_TABLE_HEADER LocalDSDT;
|
||||
ACPI_TABLE_HEADER LocalTEST;
|
||||
ACPI_TABLE_HEADER LocalBADTABLE;
|
||||
|
||||
RSDT_DESCRIPTOR_REV1 *LocalRSDT;
|
||||
|
||||
#define RSDT_TABLES 7
|
||||
#define RSDT_SIZE (sizeof (RSDT_DESCRIPTOR_REV1) + ((RSDT_TABLES -1) * sizeof (UINT32)))
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* FUNCTION: AeCtrlCHandler
|
||||
*
|
||||
* PARAMETERS: Sig
|
||||
*
|
||||
* RETURN: none
|
||||
*
|
||||
* DESCRIPTION: Control-C handler. Abort running control method if any.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
void __cdecl
|
||||
AeCtrlCHandler (
|
||||
int Sig)
|
||||
{
|
||||
|
||||
if (SpaceId > ACPI_MAX_SPACE_ID)
|
||||
{
|
||||
return "UNKNOWN_REGION_SPACE_ID";
|
||||
}
|
||||
signal (SIGINT, SIG_IGN);
|
||||
|
||||
return (AcpiGbl_RegionNames [SpaceId]);
|
||||
AcpiOsPrintf ("Caught a ctrl-c\n\n");
|
||||
|
||||
if (AcpiGbl_MethodExecuting)
|
||||
{
|
||||
AcpiGbl_AbortMethod = TRUE;
|
||||
signal (SIGINT, AeCtrlCHandler);
|
||||
}
|
||||
else
|
||||
{
|
||||
exit (0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* FUNCTION: RegionHandler
|
||||
* FUNCTION: AeBuildLocalTables
|
||||
*
|
||||
* PARAMETERS:
|
||||
*
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION:
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
ACPI_STATUS
|
||||
AeBuildLocalTables (
|
||||
ACPI_TABLE_HEADER *UserTable)
|
||||
{
|
||||
|
||||
|
||||
/* Build an RSDT */
|
||||
|
||||
LocalRSDT = AcpiOsAllocate (RSDT_SIZE);
|
||||
if (!LocalRSDT)
|
||||
{
|
||||
return AE_NO_MEMORY;
|
||||
}
|
||||
|
||||
ACPI_MEMSET (LocalRSDT, 0, RSDT_SIZE);
|
||||
ACPI_STRNCPY (LocalRSDT->Signature, RSDT_SIG, 4);
|
||||
LocalRSDT->Length = RSDT_SIZE;
|
||||
|
||||
LocalRSDT->TableOffsetEntry[0] = ACPI_PTR_TO_PHYSADDR (&LocalTEST);
|
||||
LocalRSDT->TableOffsetEntry[1] = ACPI_PTR_TO_PHYSADDR (&LocalBADTABLE);
|
||||
LocalRSDT->TableOffsetEntry[2] = ACPI_PTR_TO_PHYSADDR (&LocalFADT);
|
||||
LocalRSDT->TableOffsetEntry[3] = ACPI_PTR_TO_PHYSADDR (&LocalTEST); /* Just a placeholder for a user SSDT */
|
||||
|
||||
/* Install two SSDTs to test multiple table support */
|
||||
|
||||
LocalRSDT->TableOffsetEntry[4] = ACPI_PTR_TO_PHYSADDR (&Ssdt1Code);
|
||||
LocalRSDT->TableOffsetEntry[5] = ACPI_PTR_TO_PHYSADDR (&Ssdt2Code);
|
||||
|
||||
/* Install the OEM1 table to test LoadTable */
|
||||
|
||||
LocalRSDT->TableOffsetEntry[6] = ACPI_PTR_TO_PHYSADDR (&Oem1Code);
|
||||
|
||||
/* Build an RSDP */
|
||||
|
||||
ACPI_MEMSET (&LocalRSDP, 0, sizeof (RSDP_DESCRIPTOR));
|
||||
ACPI_STRNCPY (LocalRSDP.Signature, RSDP_SIG, 8);
|
||||
LocalRSDP.Revision = 1;
|
||||
LocalRSDP.RsdtPhysicalAddress = ACPI_PTR_TO_PHYSADDR (LocalRSDT);
|
||||
|
||||
AcpiGbl_RSDP = &LocalRSDP;
|
||||
|
||||
/*
|
||||
* Examine the incoming user table. At this point, it has been verified
|
||||
* to be either a DSDT, SSDT, or a PSDT, but they must be handled differently
|
||||
*/
|
||||
if (!ACPI_STRNCMP ((char *) UserTable->Signature, DSDT_SIG, 4))
|
||||
{
|
||||
/* User DSDT is installed directly into the FADT */
|
||||
|
||||
AcpiGbl_DSDT = UserTable;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Build a local DSDT because incoming table is an SSDT or PSDT */
|
||||
|
||||
ACPI_MEMSET (&LocalDSDT, 0, sizeof (ACPI_TABLE_HEADER));
|
||||
ACPI_STRNCPY (LocalDSDT.Signature, DSDT_SIG, 4);
|
||||
LocalDSDT.Revision = 1;
|
||||
LocalDSDT.Length = sizeof (ACPI_TABLE_HEADER);
|
||||
LocalDSDT.Checksum = (UINT8) (0 - AcpiTbChecksum (&LocalDSDT, LocalDSDT.Length));
|
||||
|
||||
AcpiGbl_DSDT = &LocalDSDT;
|
||||
|
||||
/* Install incoming table (SSDT or PSDT) directly into the RSDT */
|
||||
|
||||
LocalRSDT->TableOffsetEntry[3] = ACPI_PTR_TO_PHYSADDR (UserTable);
|
||||
}
|
||||
|
||||
/* Set checksums for both RSDT and RSDP */
|
||||
|
||||
LocalRSDT->Checksum = (UINT8) (0 - AcpiTbChecksum (LocalRSDT, LocalRSDT->Length));
|
||||
LocalRSDP.Checksum = (UINT8) (0 - AcpiTbChecksum (&LocalRSDP, ACPI_RSDP_CHECKSUM_LENGTH));
|
||||
|
||||
/* Build a FADT so we can test the hardware/event init */
|
||||
|
||||
ACPI_MEMSET (&LocalFADT, 0, sizeof (FADT_DESCRIPTOR_REV1));
|
||||
ACPI_STRNCPY (LocalFADT.Signature, FADT_SIG, 4);
|
||||
|
||||
LocalFADT.FirmwareCtrl = ACPI_PTR_TO_PHYSADDR (&LocalFACS);
|
||||
LocalFADT.Dsdt = ACPI_PTR_TO_PHYSADDR (AcpiGbl_DSDT);
|
||||
LocalFADT.Revision = 1;
|
||||
LocalFADT.Length = sizeof (FADT_DESCRIPTOR_REV1);
|
||||
LocalFADT.Gpe0BlkLen = 16;
|
||||
LocalFADT.Gpe1BlkLen = 6;
|
||||
LocalFADT.Gpe1Base = 96;
|
||||
|
||||
LocalFADT.Pm1EvtLen = 4;
|
||||
LocalFADT.Pm1CntLen = 4;
|
||||
LocalFADT.PmTmLen = 8;
|
||||
|
||||
LocalFADT.Gpe0Blk = 0x12340000;
|
||||
LocalFADT.Gpe1Blk = 0x56780000;
|
||||
|
||||
LocalFADT.Pm1aEvtBlk = 0x1aaa0000;
|
||||
LocalFADT.Pm1bEvtBlk = 0;
|
||||
LocalFADT.PmTmrBlk = 0xA0;
|
||||
LocalFADT.Pm1aCntBlk = 0xB0;
|
||||
|
||||
/* Complete the FADT with the checksum */
|
||||
|
||||
LocalFADT.Checksum = (UINT8) (0 - AcpiTbChecksum (&LocalFADT, LocalFADT.Length));
|
||||
|
||||
/* Build a FACS */
|
||||
|
||||
ACPI_MEMSET (&LocalFACS, 0, sizeof (FACS_DESCRIPTOR_REV1));
|
||||
ACPI_STRNCPY (LocalFACS.Signature, FACS_SIG, 4);
|
||||
LocalFACS.Length = sizeof (FACS_DESCRIPTOR_REV1);
|
||||
LocalFACS.GlobalLock = 0x11AA0011;
|
||||
|
||||
/* Build a fake table so that we make sure that the CA core ignores it */
|
||||
|
||||
ACPI_MEMSET (&LocalTEST, 0, sizeof (ACPI_TABLE_HEADER));
|
||||
ACPI_STRNCPY (LocalTEST.Signature, "TEST", 4);
|
||||
|
||||
LocalTEST.Revision = 1;
|
||||
LocalTEST.Length = sizeof (ACPI_TABLE_HEADER);
|
||||
|
||||
/* Build a fake table with a bad signature so that we make sure that the CA core ignores it */
|
||||
|
||||
ACPI_MEMSET (&LocalBADTABLE, 0, sizeof (ACPI_TABLE_HEADER));
|
||||
ACPI_STRNCPY (LocalBADTABLE.Signature, "BAD!", 4);
|
||||
|
||||
LocalBADTABLE.Revision = 1;
|
||||
LocalBADTABLE.Length = sizeof (ACPI_TABLE_HEADER);
|
||||
|
||||
return (AE_OK);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* FUNCTION: AeInstallTables
|
||||
*
|
||||
* PARAMETERS: None
|
||||
*
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: Install the various ACPI tables
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
ACPI_STATUS
|
||||
AeInstallTables (void)
|
||||
{
|
||||
ACPI_STATUS Status;
|
||||
|
||||
|
||||
Status = AcpiLoadTables ();
|
||||
|
||||
#if 0
|
||||
Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) &LocalFADT);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
printf ("**** Could not load local FADT, %s\n", AcpiFormatException (Status));
|
||||
return (Status);
|
||||
}
|
||||
|
||||
Status = AcpiLoadTable ((ACPI_TABLE_HEADER *) &LocalFACS);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
printf ("**** Could not load local FACS, %s\n", AcpiFormatException (Status));
|
||||
return (Status);
|
||||
}
|
||||
#endif
|
||||
|
||||
return (Status);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* FUNCTION: AeLocalGetRootPointer
|
||||
*
|
||||
* PARAMETERS: Flags - not used
|
||||
* Address - Where the root pointer is returned
|
||||
*
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: Return a local RSDP, used to dynamically load tables via the
|
||||
* standard ACPI mechanism.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
ACPI_STATUS
|
||||
AeLocalGetRootPointer (
|
||||
UINT32 Flags,
|
||||
ACPI_POINTER *Address)
|
||||
{
|
||||
|
||||
Address->PointerType = ACPI_LOGICAL_POINTER;
|
||||
Address->Pointer.Logical = &LocalRSDP;
|
||||
return (AE_OK);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* FUNCTION: AeRegionHandler
|
||||
*
|
||||
* PARAMETERS: Standard region handler parameters
|
||||
*
|
||||
@ -190,24 +437,27 @@ AcpiUtFormatSpaceId (
|
||||
*****************************************************************************/
|
||||
|
||||
ACPI_STATUS
|
||||
RegionHandler (
|
||||
AeRegionHandler (
|
||||
UINT32 Function,
|
||||
ACPI_PHYSICAL_ADDRESS Address,
|
||||
UINT32 BitWidth,
|
||||
UINT32 *Value,
|
||||
ACPI_INTEGER *Value,
|
||||
void *HandlerContext,
|
||||
void *RegionContext)
|
||||
{
|
||||
|
||||
ACPI_OPERAND_OBJECT *RegionObject = (ACPI_OPERAND_OBJECT*) RegionContext;
|
||||
ACPI_PHYSICAL_ADDRESS BaseAddress;
|
||||
UINT32 Length;
|
||||
ACPI_SIZE Length;
|
||||
BOOLEAN BufferExists;
|
||||
REGION *RegionElement;
|
||||
void *BufferValue;
|
||||
UINT32 ByteWidth;
|
||||
UINT32 i;
|
||||
|
||||
|
||||
ACPI_FUNCTION_NAME ("AeRegionHandler");
|
||||
|
||||
/*
|
||||
* If the object is not a region, simply return
|
||||
*/
|
||||
@ -216,25 +466,93 @@ RegionHandler (
|
||||
return AE_OK;
|
||||
}
|
||||
|
||||
DEBUG_PRINT (TRACE_OPREGION, ("Operation Region request on %s at 0x%X\n",
|
||||
AcpiUtFormatSpaceId (RegionObject->Region.SpaceId),
|
||||
Address));
|
||||
|
||||
|
||||
/*
|
||||
* Find the region's address space and length before searching
|
||||
* the linked list.
|
||||
* the linked list.
|
||||
*/
|
||||
BaseAddress = RegionObject->Region.Address;
|
||||
Length = RegionObject->Region.Length;
|
||||
Length = (ACPI_SIZE) RegionObject->Region.Length;
|
||||
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_OPREGION, "Operation Region request on %s at 0x%X\n",
|
||||
AcpiUtGetRegionName (RegionObject->Region.SpaceId),
|
||||
(UINT32) Address));
|
||||
|
||||
if (RegionObject->Region.SpaceId == ACPI_ADR_SPACE_SMBUS)
|
||||
{
|
||||
Length = 0;
|
||||
|
||||
switch (Function & ACPI_IO_MASK)
|
||||
{
|
||||
case ACPI_READ:
|
||||
switch (Function >> 16)
|
||||
{
|
||||
case AML_FIELD_ATTRIB_SMB_QUICK:
|
||||
case AML_FIELD_ATTRIB_SMB_SEND_RCV:
|
||||
case AML_FIELD_ATTRIB_SMB_BYTE:
|
||||
Length = 1;
|
||||
break;
|
||||
|
||||
case AML_FIELD_ATTRIB_SMB_WORD:
|
||||
case AML_FIELD_ATTRIB_SMB_WORD_CALL:
|
||||
Length = 2;
|
||||
break;
|
||||
|
||||
case AML_FIELD_ATTRIB_SMB_BLOCK:
|
||||
case AML_FIELD_ATTRIB_SMB_BLOCK_CALL:
|
||||
Length = 32;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case ACPI_WRITE:
|
||||
switch (Function >> 16)
|
||||
{
|
||||
case AML_FIELD_ATTRIB_SMB_QUICK:
|
||||
case AML_FIELD_ATTRIB_SMB_SEND_RCV:
|
||||
case AML_FIELD_ATTRIB_SMB_BYTE:
|
||||
case AML_FIELD_ATTRIB_SMB_WORD:
|
||||
case AML_FIELD_ATTRIB_SMB_BLOCK:
|
||||
Length = 0;
|
||||
break;
|
||||
|
||||
case AML_FIELD_ATTRIB_SMB_WORD_CALL:
|
||||
Length = 2;
|
||||
break;
|
||||
|
||||
case AML_FIELD_ATTRIB_SMB_BLOCK_CALL:
|
||||
Length = 32;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
for (i = 0; i < Length; i++)
|
||||
{
|
||||
((UINT8 *) Value)[i+2] = (UINT8) (0xA0 + i);
|
||||
}
|
||||
|
||||
((UINT8 *) Value)[0] = 0x7A;
|
||||
((UINT8 *) Value)[1] = (UINT8) Length;
|
||||
|
||||
return AE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Search through the linked list for this region's buffer
|
||||
*/
|
||||
BufferExists = FALSE;
|
||||
RegionElement = Regions.RegionList;
|
||||
RegionElement = AeRegions.RegionList;
|
||||
|
||||
if (0 != Regions.NumberOfRegions)
|
||||
if (AeRegions.NumberOfRegions)
|
||||
{
|
||||
while (!BufferExists && RegionElement)
|
||||
{
|
||||
@ -253,42 +571,42 @@ RegionHandler (
|
||||
/*
|
||||
* If the Region buffer does not exist, create it now
|
||||
*/
|
||||
if (FALSE == BufferExists)
|
||||
if (!BufferExists)
|
||||
{
|
||||
/*
|
||||
* Do the memory allocations first
|
||||
*/
|
||||
RegionElement = AcpiOsAllocate (sizeof(REGION));
|
||||
RegionElement = AcpiOsAllocate (sizeof (REGION));
|
||||
if (!RegionElement)
|
||||
{
|
||||
return AE_NO_MEMORY;
|
||||
}
|
||||
|
||||
RegionElement->Buffer = AcpiOsCallocate (Length);
|
||||
RegionElement->Buffer = AcpiOsAllocate (Length);
|
||||
if (!RegionElement->Buffer)
|
||||
{
|
||||
AcpiOsFree (RegionElement);
|
||||
return AE_NO_MEMORY;
|
||||
}
|
||||
|
||||
ACPI_MEMSET (RegionElement->Buffer, 0, Length);
|
||||
RegionElement->Address = BaseAddress;
|
||||
RegionElement->Length = Length;
|
||||
RegionElement->NextRegion = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* Increment the number of regions and put this one
|
||||
* at the head of the list as it will probably get accessed
|
||||
* more often anyway.
|
||||
*/
|
||||
Regions.NumberOfRegions += 1;
|
||||
AeRegions.NumberOfRegions += 1;
|
||||
|
||||
if (NULL != Regions.RegionList)
|
||||
if (NULL != AeRegions.RegionList)
|
||||
{
|
||||
RegionElement->NextRegion = Regions.RegionList->NextRegion;
|
||||
RegionElement->NextRegion = AeRegions.RegionList->NextRegion;
|
||||
}
|
||||
|
||||
Regions.RegionList = RegionElement;
|
||||
AeRegions.RegionList = RegionElement;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -311,9 +629,11 @@ RegionHandler (
|
||||
if (((ACPI_INTEGER) Address + ByteWidth) >
|
||||
((ACPI_INTEGER)(RegionElement->Address) + RegionElement->Length))
|
||||
{
|
||||
DEBUG_PRINT (ACPI_WARN, ("Request on [%4.4s] is beyond region limit Req-%lX+%lX, Base=%lX, Len-%lX\n",
|
||||
&((RegionObject->Region.Node)->Name), (UINT32) Address, ByteWidth, (UINT32)(RegionElement->Address),
|
||||
RegionElement->Length));
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_WARN,
|
||||
"Request on [%4.4s] is beyond region limit Req-%X+%X, Base=%X, Len-%X\n",
|
||||
(RegionObject->Region.Node)->Name.Ascii, (UINT32) Address,
|
||||
ByteWidth, (UINT32)(RegionElement->Address),
|
||||
RegionElement->Length));
|
||||
|
||||
return AE_AML_REGION_LIMIT;
|
||||
}
|
||||
@ -329,31 +649,30 @@ RegionHandler (
|
||||
*/
|
||||
switch (Function)
|
||||
{
|
||||
case ACPI_READ_ADR_SPACE:
|
||||
case ACPI_READ:
|
||||
/*
|
||||
* Set the pointer Value to whatever is in the buffer
|
||||
*/
|
||||
MEMCPY (Value, BufferValue, ByteWidth);
|
||||
ACPI_MEMCPY (Value, BufferValue, ByteWidth);
|
||||
break;
|
||||
|
||||
case ACPI_WRITE_ADR_SPACE:
|
||||
case ACPI_WRITE:
|
||||
/*
|
||||
* Write the contents of Value to the buffer
|
||||
*/
|
||||
MEMCPY (BufferValue, Value, ByteWidth);
|
||||
ACPI_MEMCPY (BufferValue, Value, ByteWidth);
|
||||
break;
|
||||
|
||||
default:
|
||||
return AE_BAD_PARAMETER;
|
||||
}
|
||||
|
||||
return AE_OK;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* FUNCTION: RegionInit
|
||||
* FUNCTION: AeRegionInit
|
||||
*
|
||||
* PARAMETERS: None
|
||||
*
|
||||
@ -364,7 +683,7 @@ RegionHandler (
|
||||
*****************************************************************************/
|
||||
|
||||
ACPI_STATUS
|
||||
RegionInit (
|
||||
AeRegionInit (
|
||||
ACPI_HANDLE RegionHandle,
|
||||
UINT32 Function,
|
||||
void *HandlerContext,
|
||||
@ -381,7 +700,7 @@ RegionInit (
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* FUNCTION: NotifyHandler
|
||||
* FUNCTION: AeNotifyHandler
|
||||
*
|
||||
* PARAMETERS: Standard notify handler parameters
|
||||
*
|
||||
@ -394,7 +713,7 @@ RegionInit (
|
||||
*****************************************************************************/
|
||||
|
||||
void
|
||||
NotifyHandler (
|
||||
AeNotifyHandler (
|
||||
ACPI_HANDLE Device,
|
||||
UINT32 Value,
|
||||
void *Context)
|
||||
@ -402,9 +721,10 @@ NotifyHandler (
|
||||
|
||||
switch (Value)
|
||||
{
|
||||
#if 0
|
||||
case 0:
|
||||
printf ("**** Method Error 0x%X: Results not equal\n", Value);
|
||||
if (DebugFile)
|
||||
if (AcpiGbl_DebugFile)
|
||||
{
|
||||
AcpiOsPrintf ("**** Method Error: Results not equal\n");
|
||||
}
|
||||
@ -413,7 +733,7 @@ NotifyHandler (
|
||||
|
||||
case 1:
|
||||
printf ("**** Method Error: Incorrect numeric result\n");
|
||||
if (DebugFile)
|
||||
if (AcpiGbl_DebugFile)
|
||||
{
|
||||
AcpiOsPrintf ("**** Method Error: Incorrect numeric result\n");
|
||||
}
|
||||
@ -422,16 +742,18 @@ NotifyHandler (
|
||||
|
||||
case 2:
|
||||
printf ("**** Method Error: An operand was overwritten\n");
|
||||
if (DebugFile)
|
||||
if (AcpiGbl_DebugFile)
|
||||
{
|
||||
AcpiOsPrintf ("**** Method Error: An operand was overwritten\n");
|
||||
}
|
||||
break;
|
||||
|
||||
#endif
|
||||
|
||||
default:
|
||||
printf ("**** Received a notify, value 0x%X\n", Value);
|
||||
if (DebugFile)
|
||||
printf ("**** Received a Notify on Device [%4.4s] %p value 0x%X\n",
|
||||
AcpiUtGetNodeName (Device), Device, Value);
|
||||
if (AcpiGbl_DebugFile)
|
||||
{
|
||||
AcpiOsPrintf ("**** Received a notify, value 0x%X\n", Value);
|
||||
}
|
||||
@ -441,6 +763,73 @@ NotifyHandler (
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* FUNCTION: AeExceptionHandler
|
||||
*
|
||||
* PARAMETERS: Standard exception handler parameters
|
||||
*
|
||||
* RETURN: Status
|
||||
*
|
||||
* DESCRIPTION: System exception handler for AcpiExec utility.
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
ACPI_STATUS
|
||||
AeExceptionHandler (
|
||||
ACPI_STATUS AmlStatus,
|
||||
ACPI_NAME Name,
|
||||
UINT16 Opcode,
|
||||
UINT32 AmlOffset,
|
||||
void *Context)
|
||||
{
|
||||
ACPI_STATUS Status;
|
||||
ACPI_BUFFER ReturnObj;
|
||||
ACPI_OBJECT_LIST ArgList;
|
||||
ACPI_OBJECT Arg[2];
|
||||
const char *Exception;
|
||||
|
||||
|
||||
Exception = AcpiFormatException (AmlStatus);
|
||||
AcpiOsPrintf (
|
||||
"**** AcpiExec Exception: %s during execution of method [%4.4s] Opcode [%s] @%X\n",
|
||||
Exception, (char *) &Name, AcpiPsGetOpcodeName (Opcode), AmlOffset);
|
||||
|
||||
/*
|
||||
* Invoke the _ERR method if present
|
||||
*
|
||||
* Setup parameter object
|
||||
*/
|
||||
ArgList.Count = 2;
|
||||
ArgList.Pointer = Arg;
|
||||
|
||||
Arg[0].Type = ACPI_TYPE_INTEGER;
|
||||
Arg[0].Integer.Value = AmlStatus;
|
||||
|
||||
Arg[1].Type = ACPI_TYPE_STRING;
|
||||
Arg[1].String.Pointer = (char *) Exception;
|
||||
Arg[1].String.Length = ACPI_STRLEN (Exception);
|
||||
|
||||
/* Setup return buffer */
|
||||
|
||||
ReturnObj.Pointer = NULL;
|
||||
ReturnObj.Length = ACPI_ALLOCATE_BUFFER;
|
||||
|
||||
Status = AcpiEvaluateObject (NULL, "\\_ERR", &ArgList, &ReturnObj);
|
||||
if (ACPI_SUCCESS (Status) &&
|
||||
ReturnObj.Pointer)
|
||||
{
|
||||
/* Override original status */
|
||||
|
||||
AmlStatus = (ACPI_STATUS)
|
||||
((ACPI_OBJECT *) ReturnObj.Pointer)->Integer.Value;
|
||||
|
||||
AcpiOsFree (ReturnObj.Pointer);
|
||||
}
|
||||
return (AmlStatus);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* FUNCTION: AeInstallHandlers
|
||||
@ -454,33 +843,90 @@ NotifyHandler (
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
ACPI_ADR_SPACE_TYPE SpaceId[] = {0, 1, 2, 3, 4, 0x80};
|
||||
#define AEXEC_NUM_REGIONS 6
|
||||
|
||||
ACPI_STATUS
|
||||
AeInstallHandlers (void)
|
||||
{
|
||||
ACPI_STATUS Status;
|
||||
UINT32 i;
|
||||
ACPI_HANDLE Handle;
|
||||
|
||||
|
||||
Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY,
|
||||
NotifyHandler, NULL);
|
||||
ACPI_FUNCTION_NAME ("AeInstallHandlers");
|
||||
|
||||
|
||||
Status = AcpiInstallExceptionHandler (AeExceptionHandler);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
printf ("Could not install a global notify handler\n");
|
||||
printf ("Could not install exception handler, %s\n",
|
||||
AcpiFormatException (Status));
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++)
|
||||
Status = AcpiInstallNotifyHandler (ACPI_ROOT_OBJECT, ACPI_SYSTEM_NOTIFY,
|
||||
AeNotifyHandler, NULL);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
printf ("Could not install a global notify handler, %s\n",
|
||||
AcpiFormatException (Status));
|
||||
}
|
||||
|
||||
Status = AcpiGetHandle (NULL, "\\_SB_", &Handle);
|
||||
if (ACPI_SUCCESS (Status))
|
||||
{
|
||||
Status = AcpiInstallNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
|
||||
AeNotifyHandler, NULL);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
printf ("Could not install a notify handler, %s\n",
|
||||
AcpiFormatException (Status));
|
||||
}
|
||||
|
||||
Status = AcpiRemoveNotifyHandler (Handle, ACPI_SYSTEM_NOTIFY,
|
||||
AeNotifyHandler);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
printf ("Could not remove a notify handler, %s\n",
|
||||
AcpiFormatException (Status));
|
||||
}
|
||||
|
||||
Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
|
||||
AeNotifyHandler, NULL);
|
||||
Status = AcpiRemoveNotifyHandler (Handle, ACPI_ALL_NOTIFY,
|
||||
AeNotifyHandler);
|
||||
Status = AcpiInstallNotifyHandler (Handle, ACPI_ALL_NOTIFY,
|
||||
AeNotifyHandler, NULL);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
printf ("Could not install a notify handler, %s\n",
|
||||
AcpiFormatException (Status));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for (i = 0; i < AEXEC_NUM_REGIONS; i++)
|
||||
{
|
||||
if (i == 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Status = AcpiRemoveAddressSpaceHandler (AcpiGbl_RootNode,
|
||||
(ACPI_ADR_SPACE_TYPE) i, RegionHandler);
|
||||
SpaceId[i], AeRegionHandler);
|
||||
|
||||
/* Install handler at the root object.
|
||||
* TBD: all default handlers should be installed here!
|
||||
*/
|
||||
Status = AcpiInstallAddressSpaceHandler (AcpiGbl_RootNode,
|
||||
(ACPI_ADR_SPACE_TYPE) i, RegionHandler, RegionInit, NULL);
|
||||
SpaceId[i], AeRegionHandler, AeRegionInit, NULL);
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
printf ("Could not install an OpRegion handler\n");
|
||||
ACPI_DEBUG_PRINT ((ACPI_DB_ERROR,
|
||||
"Could not install an OpRegion handler for %s space(%d), %s\n",
|
||||
AcpiUtGetRegionName((UINT8) SpaceId[i]), SpaceId[i],
|
||||
AcpiFormatException (Status)));
|
||||
return (Status);
|
||||
}
|
||||
}
|
||||
|
||||
@ -488,77 +934,8 @@ AeInstallHandlers (void)
|
||||
* Initialize the global Region Handler space
|
||||
* MCW 3/23/00
|
||||
*/
|
||||
Regions.NumberOfRegions = 0;
|
||||
Regions.RegionList = NULL;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* FUNCTION: AdSecondPassParse
|
||||
*
|
||||
* PARAMETERS: Root - Root of the parse tree
|
||||
*
|
||||
* RETURN: None
|
||||
*
|
||||
* DESCRIPTION: Need to wait until second pass to parse the control methods
|
||||
*
|
||||
*****************************************************************************/
|
||||
|
||||
ACPI_STATUS
|
||||
AdSecondPassParse (
|
||||
ACPI_PARSE_OBJECT *Root)
|
||||
{
|
||||
ACPI_PARSE_OBJECT *Op = Root;
|
||||
ACPI_PARSE2_OBJECT *Method;
|
||||
ACPI_PARSE_OBJECT *SearchOp;
|
||||
ACPI_PARSE_OBJECT *StartOp;
|
||||
ACPI_STATUS Status = AE_OK;
|
||||
UINT32 BaseAmlOffset;
|
||||
|
||||
|
||||
/* Walk entire tree */
|
||||
|
||||
while (Op)
|
||||
{
|
||||
/* We are looking for control methods */
|
||||
|
||||
if (Op->Opcode == AML_METHOD_OP)
|
||||
{
|
||||
Method = (ACPI_PARSE2_OBJECT *) Op;
|
||||
Status = AcpiPsParseAml (Op, Method->Data, Method->Length, 0,
|
||||
NULL, NULL, NULL, NULL, NULL);
|
||||
|
||||
|
||||
BaseAmlOffset = (Method->Value.Arg)->AmlOffset + 1;
|
||||
StartOp = (Method->Value.Arg)->Next;
|
||||
SearchOp = StartOp;
|
||||
|
||||
while (SearchOp)
|
||||
{
|
||||
SearchOp->AmlOffset += BaseAmlOffset;
|
||||
SearchOp = AcpiPsGetDepthNext (StartOp, SearchOp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (Op->Opcode == AML_REGION_OP)
|
||||
{
|
||||
/* TBD: this isn't quite the right thing to do! */
|
||||
|
||||
// Method = (ACPI_PARSE2_OBJECT *) Op;
|
||||
// Status = AcpiPsParseAml (Op, Method->Body, Method->BodyLength);
|
||||
}
|
||||
|
||||
if (ACPI_FAILURE (Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
Op = AcpiPsGetDepthNext (Root, Op);
|
||||
}
|
||||
AeRegions.NumberOfRegions = 0;
|
||||
AeRegions.RegionList = NULL;
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user