l4re-base-25.08.0

This commit is contained in:
2025-09-12 15:55:45 +02:00
commit d959eaab98
37938 changed files with 9382688 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
provides: acpica
requires: l4re libc
maintainer: warg@os.inf.tu-dresden.de

View File

@@ -0,0 +1,23 @@
## This file states the license of this package and possibly its subpackages
## in machine and human readable format. The PackageName refers to the package
## whose license is defined by PackageLicenseConcluded.
## For more information about this file format visit the SPDX website at
## https://spdx.org
SPDXVersion: SPDX-2.3
DataLicense: CC0-1.0
SPDXID: SPDXRef-DOCUMENT
DocumentNamespace: spdx:kernkonzept/acpica-0556455a-e7e7-11e8-856f-28d24461b5b9
DocumentName: acpica
Creator: Organization: Kernkonzept GmbH (info@kernkonzept.com)
Created: 2018-11-13T00:00:00Z
## Package Information
PackageName: acpica
SPDXID: SPDXRef-acpica
PackageOriginator: Organization: Kernkonzept GmbH (info@kernkonzept.com)
PackageLicenseDeclared: (GPL-2.0-only OR BSD-3-Clause OR Intel-ACPI)
PackageLicenseConcluded: (GPL-2.0-only OR BSD-3-Clause OR Intel-ACPI)
FilesAnalyzed: false
PackageCopyrightText: NOASSERTION
PackageDownloadLocation: NOASSERTION

View File

@@ -0,0 +1,7 @@
PKGDIR = .
L4DIR ?= $(PKGDIR)/../..
TARGET = lib-acpi
include $(L4DIR)/mk/subdir.mk

View File

@@ -0,0 +1,18 @@
# Lib-acpi for L4Re
This package contains the acpica libraries together with make files for
building them inside the L4Re tree.
The original acpica library is available at
[https://acpica.org](https://acpica.org/downloads).
# Documentation
This package is part of the L4Re operating system. For documentation and
build instructions see the
[L4Re wiki](https://kernkonzept.com/L4Re/guides/l4re).
# License
Detailed licensing and copyright information can be found in
the [LICENSE](LICENSE.spdx) file.

View File

@@ -0,0 +1,8 @@
PKGDIR ?= ..
L4DIR ?= $(PKGDIR)/../..
TARGET := include include-acpica src
include $(L4DIR)/mk/subdir.mk
src: include include-acpica

View File

@@ -0,0 +1,8 @@
PKGDIR ?= ../..
L4DIR ?= $(PKGDIR)/../..
CONTRIB_HEADERS = y
INCSRC_DIR = $(SRC_DIR)/../src/acpica/include
include $(L4DIR)/mk/include.mk

View File

@@ -0,0 +1,7 @@
PKGDIR ?= ../..
L4DIR ?= $(PKGDIR)/../..
CONTRIB_HEADERS = y
include $(L4DIR)/mk/include.mk

View File

@@ -0,0 +1,9 @@
#pragma once
#include <l4/sys/compiler.h>
__BEGIN_DECLS
void acpi_print_system_info(void * sys_info_p);
__END_DECLS

View File

@@ -0,0 +1,23 @@
#pragma once
#include <l4/sys/l4int.h>
#include <pthread.h>
#define ACPI_MACHINE_WIDTH L4_MWORD_BITS
#define COMPILER_DEPENDENT_INT64 l4_int64_t
#define COMPILER_DEPENDENT_UINT64 l4_uint64_t
#define ACPI_FLUSH_CPU_CACHE()
#define ACPI_USE_SYSTEM_CLIBRARY 1
#define ACPI_USE_STANDARD_HEADERS 1
#ifndef ACPI_USE_NATIVE_DIVIDE
#define ACPI_USE_NATIVE_DIVIDE
#endif
#define ACPI_DEBUG_OUTPUT 1
#define ACPI_USE_LOCAL_CACHE
//#define ACPI_DEBUGGER 1
//#define ACPI_DISASSEMBLER 1
#include "platform/acgcc.h"

View File

@@ -0,0 +1,214 @@
PKGDIR ?= ../..
L4DIR ?= $(PKGDIR)/../..
TARGET = libacpica.a libacpica.so
CONTRIB_INCDIR = acpica
IASL ?= iasl
ACPICA_SRC_C_DISASM = \
disassembler/dmbuffer.c \
disassembler/dmcstyle.c \
disassembler/dmdeferred.c \
disassembler/dmnames.c \
disassembler/dmopcode.c \
disassembler/dmresrc.c \
disassembler/dmresrcl.c \
disassembler/dmresrcl2.c \
disassembler/dmresrcs.c \
disassembler/dmutils.c \
disassembler/dmwalk.c \
ACPICA_SRC_C = \
dispatcher/dsargs.c \
dispatcher/dscontrol.c \
dispatcher/dsdebug.c \
dispatcher/dsfield.c \
dispatcher/dsinit.c \
dispatcher/dsmethod.c \
dispatcher/dsmthdat.c \
dispatcher/dsobject.c \
dispatcher/dsopcode.c \
dispatcher/dspkginit.c \
dispatcher/dsutils.c \
dispatcher/dswexec.c \
dispatcher/dswload.c \
dispatcher/dswload2.c \
dispatcher/dswscope.c \
dispatcher/dswstate.c \
events/evevent.c \
events/evglock.c \
events/evgpe.c \
events/evgpeblk.c \
events/evgpeinit.c \
events/evgpeutil.c \
events/evhandler.c \
events/evmisc.c \
events/evregion.c \
events/evrgnini.c \
events/evsci.c \
events/evxface.c \
events/evxfevnt.c \
events/evxfgpe.c \
events/evxfregn.c \
executer/exconcat.c \
executer/exconfig.c \
executer/exconvrt.c \
executer/excreate.c \
executer/exdebug.c \
executer/exdump.c \
executer/exfield.c \
executer/exfldio.c \
executer/exmisc.c \
executer/exmutex.c \
executer/exnames.c \
executer/exoparg1.c \
executer/exoparg2.c \
executer/exoparg3.c \
executer/exoparg6.c \
executer/exprep.c \
executer/exregion.c \
executer/exresnte.c \
executer/exresolv.c \
executer/exresop.c \
executer/exserial.c \
executer/exstore.c \
executer/exstoren.c \
executer/exstorob.c \
executer/exsystem.c \
executer/extrace.c \
executer/exutils.c \
hardware/hwacpi.c \
hardware/hwgpe.c \
hardware/hwpci.c \
hardware/hwregs.c \
hardware/hwtimer.c \
hardware/hwsleep.c \
hardware/hwesleep.c \
hardware/hwvalid.c \
hardware/hwxface.c \
hardware/hwxfsleep.c \
namespace/nsaccess.c \
namespace/nsalloc.c \
namespace/nsarguments.c \
namespace/nsconvert.c \
namespace/nsdump.c \
namespace/nsdumpdv.c \
namespace/nseval.c \
namespace/nsinit.c \
namespace/nsload.c \
namespace/nsnames.c \
namespace/nsobject.c \
namespace/nsparse.c \
namespace/nspredef.c \
namespace/nsprepkg.c \
namespace/nsrepair.c \
namespace/nsrepair2.c \
namespace/nssearch.c \
namespace/nsutils.c \
namespace/nswalk.c \
namespace/nsxfeval.c \
namespace/nsxfname.c \
namespace/nsxfobj.c \
parser/psargs.c \
parser/psloop.c \
parser/psobject.c \
parser/psopcode.c \
parser/psopinfo.c \
parser/psparse.c \
parser/psscope.c \
parser/pstree.c \
parser/psutils.c \
parser/pswalk.c \
parser/psxface.c \
resources/rsaddr.c \
resources/rscalc.c \
resources/rscreate.c \
resources/rsdump.c \
resources/rsdumpinfo.c \
resources/rsinfo.c \
resources/rsio.c \
resources/rsirq.c \
resources/rslist.c \
resources/rsmemory.c \
resources/rsmisc.c \
resources/rsserial.c \
resources/rsutils.c \
resources/rsxface.c \
tables/tbdata.c \
tables/tbfadt.c \
tables/tbfind.c \
tables/tbinstal.c \
tables/tbprint.c \
tables/tbutils.c \
tables/tbxface.c \
tables/tbxfload.c \
tables/tbxfroot.c \
utilities/utaddress.c \
utilities/utalloc.c \
utilities/utascii.c \
utilities/utbuffer.c \
utilities/utcache.c \
utilities/utcksum.c \
utilities/utclib.c \
utilities/utcopy.c \
utilities/utdebug.c \
utilities/utdecode.c \
utilities/utdelete.c \
utilities/uterror.c \
utilities/uteval.c \
utilities/utexcep.c \
utilities/utglobal.c \
utilities/uthex.c \
utilities/utids.c \
utilities/utinit.c \
utilities/utlock.c \
utilities/utmath.c \
utilities/utmisc.c \
utilities/utmutex.c \
utilities/utnonansi.c \
utilities/utobject.c \
utilities/utosi.c \
utilities/utownerid.c \
utilities/utpredef.c \
utilities/utresdecode.c \
utilities/utresrc.c \
utilities/utstate.c \
utilities/utstring.c \
utilities/utstrsuppt.c \
utilities/utstrtoul64.c \
utilities/uttrack.c \
utilities/utuuid.c \
utilities/utxface.c \
utilities/utxferror.c \
utilities/utxfinit.c \
utilities/utxfmutex.c \
SRC_C := $(addprefix acpica/components/,$(ACPICA_SRC_C))
SRC_C += osl-stdio.c debug.c
SRC_CC+= osl-basic.cc
DEFINES += -DL4_ACPICA
include $(L4DIR)/mk/lib.mk
WARNINGS += -Wno-unused-parameter -Wno-null-pointer-subtraction
WARNINGS += $(GCCWNOUNTERMINATEDSTRINGINITIALIZATION)
main.o: dsdt-static.hex
vpath dsdt-static.dsl $(PKGDIR)/server/lib-acpi/src/
dsdt-static.hex: dsdt-static.dsl
$(VERBOSE)echo -e " ... Generating dsdt-static.hex"
$(VERBOSE)$(IASL) -tc $<
extract_infos.o: isaids.h
vpath isaids.txt $(PKGDIR)/server/lib-acpi/src/
vpath generate_isaids.sh $(PKGDIR)/server/lib-acpi/src/
isaids.h: isaids.txt generate_isaids.sh
$(VERBOSE)echo -e " ... Generating isaids.h"
$(VERBOSE)$(PKGDIR)/server/lib-acpi/src/generate_isaids.sh $< $@
clean::
$(VERBOSE)$(RM) dsdt-static.hex
$(VERBOSE)$(RM) acpi-dsdt.aml
$(VERBOSE)$(RM) isaids.h

View File

@@ -0,0 +1,2 @@
https://github.com/acpica/acpica.git
R2025_04_04

View File

@@ -0,0 +1,779 @@
/******************************************************************************
*
* Module Name: acfileio - Get ACPI tables from file
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "acpi.h"
#include "accommon.h"
#include "actables.h"
#include "acutils.h"
#include "acapps.h"
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("acfileio")
/* Local prototypes */
static ACPI_STATUS
AcGetOneTableFromFile (
char *Filename,
FILE *File,
UINT8 GetOnlyAmlTables,
ACPI_TABLE_HEADER **Table);
static ACPI_STATUS
AcCheckTextModeCorruption (
ACPI_TABLE_HEADER *Table);
/*******************************************************************************
*
* FUNCTION: AcDeleteTableList
*
* PARAMETERS: ListHead - List to delete
*
* RETURN: Status
*
* DESCRIPTION: Delete a list of tables. This is useful for removing memory
* allocated by AcGetAllTablesFromFile
*
******************************************************************************/
void
AcDeleteTableList (
ACPI_NEW_TABLE_DESC *ListHead)
{
ACPI_NEW_TABLE_DESC *Current = ListHead;
ACPI_NEW_TABLE_DESC *Previous = Current;
while (Current)
{
Current = Current->Next;
AcpiOsFree (Previous);
Previous = Current;
}
}
/*******************************************************************************
*
* FUNCTION: AcGetAllTablesFromFile
*
* PARAMETERS: Filename - Table filename
* GetOnlyAmlTables - TRUE if the tables must be AML tables
* ReturnListHead - Where table list is returned
*
* RETURN: Status
*
* DESCRIPTION: Get all ACPI tables from within a single file.
*
******************************************************************************/
ACPI_STATUS
AcGetAllTablesFromFile (
char *Filename,
UINT8 GetOnlyAmlTables,
ACPI_NEW_TABLE_DESC **ReturnListHead)
{
ACPI_NEW_TABLE_DESC *ListHead = NULL;
ACPI_NEW_TABLE_DESC *ListTail = NULL;
ACPI_NEW_TABLE_DESC *TableDesc;
FILE *File;
ACPI_TABLE_HEADER *Table = NULL;
UINT32 FileSize;
ACPI_STATUS Status = AE_OK;
File = fopen (Filename, "rb");
if (!File)
{
fprintf (stderr, "Could not open input file: %s\n", Filename);
if (errno == ENOENT)
{
return (AE_NOT_EXIST);
}
return (AE_ERROR);
}
/* Get the file size */
FileSize = CmGetFileSize (File);
if (FileSize == ACPI_UINT32_MAX)
{
Status = AE_ERROR;
goto Exit;
}
fprintf (stderr,
"Input file %s, Length 0x%X (%u) bytes\n",
Filename, FileSize, FileSize);
/* We must have at least one ACPI table header */
if (FileSize < sizeof (ACPI_TABLE_HEADER))
{
Status = AE_BAD_HEADER;
goto Exit;
}
/* Check for an non-binary file */
if (!AcIsFileBinary (File))
{
fprintf (stderr,
" %s: File does not appear to contain a valid AML table\n",
Filename);
Status = AE_TYPE;
goto Exit;
}
/* Read all tables within the file */
while (ACPI_SUCCESS (Status))
{
/* Get one entire ACPI table */
Status = AcGetOneTableFromFile (
Filename, File, GetOnlyAmlTables, &Table);
if (Status == AE_CTRL_TERMINATE)
{
Status = AE_OK;
break;
}
else if (Status == AE_TYPE)
{
Status = AE_OK;
goto Exit;
}
else if (ACPI_FAILURE (Status))
{
goto Exit;
}
/* Print table header for iASL/disassembler only */
#ifdef ACPI_ASL_COMPILER
AcpiTbPrintTableHeader (0, Table);
#endif
/* Allocate and link a table descriptor */
TableDesc = AcpiOsAllocate (sizeof (ACPI_NEW_TABLE_DESC));
if (!TableDesc)
{
AcpiOsFree (Table);
Status = AE_NO_MEMORY;
goto Exit;
}
TableDesc->Table = Table;
TableDesc->Next = NULL;
/* Link at the end of the local table list */
if (!ListHead)
{
ListHead = TableDesc;
ListTail = TableDesc;
}
else
{
ListTail->Next = TableDesc;
ListTail = TableDesc;
}
}
/* Add the local table list to the end of the global list */
if (*ReturnListHead)
{
ListTail = *ReturnListHead;
while (ListTail->Next)
{
ListTail = ListTail->Next;
}
ListTail->Next = ListHead;
}
else
{
*ReturnListHead = ListHead;
}
Exit:
fclose(File);
return (Status);
}
/*******************************************************************************
*
* FUNCTION: AcGetOneTableFromFile
*
* PARAMETERS: Filename - File where table is located
* File - Open FILE pointer to Filename
* GetOnlyAmlTables - TRUE if the tables must be AML tables.
* ReturnTable - Where a pointer to the table is returned
*
* RETURN: Status
*
* DESCRIPTION: Read the next ACPI table from a file. Implements support
* for multiple tables within a single file. File must already
* be open.
*
* Note: Loading an RSDP is not supported.
*
******************************************************************************/
static ACPI_STATUS
AcGetOneTableFromFile (
char *Filename,
FILE *File,
UINT8 GetOnlyAmlTables,
ACPI_TABLE_HEADER **ReturnTable)
{
ACPI_STATUS Status = AE_OK;
ACPI_TABLE_HEADER TableHeader;
ACPI_TABLE_HEADER *Table;
INT32 Count;
UINT32 TableLength;
UINT32 HeaderLength;
long TableOffset = 0;
*ReturnTable = NULL;
/* Get the table header to examine signature and length */
/*
* Special handling for the CDAT table (both the Length field
* and the Checksum field are not in the standard positions).
* (The table header is non-standard).
*/
if (AcpiGbl_CDAT)
{
HeaderLength = sizeof (ACPI_TABLE_CDAT);
}
else
{
HeaderLength = sizeof (ACPI_TABLE_HEADER);
}
Status = AcValidateTableHeader (File, TableOffset);
if (ACPI_FAILURE (Status))
{
return (Status);
}
TableOffset = ftell (File);
Count = fread (&TableHeader, 1, HeaderLength, File);
if (Count != (INT32) HeaderLength)
{
return (AE_CTRL_TERMINATE);
}
if (GetOnlyAmlTables)
{
/* Validate the table signature/header (limited ASCII chars) */
/*
* Table must be an AML table (DSDT/SSDT).
* Used for iASL -e option only.
*/
if (!AcpiUtIsAmlTable (&TableHeader))
{
fprintf (stderr,
" %s: Table [%4.4s] is not an AML table - ignoring\n",
Filename, TableHeader.Signature);
return (AE_TYPE);
}
}
/*
* Special handling for the CDAT table (both the Length field
* and the Checksum field are not in the standard positions).
*/
if (AcpiGbl_CDAT)
{
TableLength = ACPI_CAST_PTR (ACPI_TABLE_CDAT, &TableHeader)->Length;
}
else
{
TableLength = TableHeader.Length;
}
/* Allocate a buffer for the entire table */
Table = AcpiOsAllocate ((ACPI_SIZE) TableLength);
if (!Table)
{
return (AE_NO_MEMORY);
}
/* Read the entire ACPI table, including header */
fseek (File, TableOffset, SEEK_SET);
Count = fread (Table, 1, TableLength, File);
/*
* Checks for data table headers happen later in the execution. Only verify
* for Aml tables at this point in the code.
*/
if (GetOnlyAmlTables && Count != (INT32) TableLength)
{
Status = AE_ERROR;
goto ErrorExit;
}
/*
* Validate the checksum (just issue a warning if incorrect).
* Note: CDAT is special cased here because the table does
* not have the checksum field in the standard position.
*/
if (AcpiGbl_CDAT)
{
Status = AcpiUtVerifyCdatChecksum ((ACPI_TABLE_CDAT *) Table, TableLength);
} else
{
Status = AcpiUtVerifyChecksum (Table, TableLength);
}
if (ACPI_FAILURE (Status))
{
Status = AcCheckTextModeCorruption (Table);
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
}
*ReturnTable = Table;
return (AE_OK);
ErrorExit:
AcpiOsFree (Table);
return (Status);
}
/*******************************************************************************
*
* FUNCTION: AcIsFileBinary
*
* PARAMETERS: File - Open input file
*
* RETURN: TRUE if file appears to be binary
*
* DESCRIPTION: Scan a file for any non-ASCII bytes.
*
* Note: Maintains current file position.
*
******************************************************************************/
BOOLEAN
AcIsFileBinary (
FILE *File)
{
UINT8 Byte;
BOOLEAN IsBinary = FALSE;
long FileOffset;
/* Scan entire file for any non-ASCII bytes */
FileOffset = ftell (File);
while (fread (&Byte, 1, 1, File) == 1)
{
if (!isprint (Byte) && !isspace (Byte))
{
IsBinary = TRUE;
goto Exit;
}
}
Exit:
fseek (File, FileOffset, SEEK_SET);
return (IsBinary);
}
/*******************************************************************************
*
* FUNCTION: AcValidateTableHeader
*
* PARAMETERS: File - Open input file
*
* RETURN: Status
*
* DESCRIPTION: Determine if a file seems to contain one or more binary ACPI
* tables, via the
* following checks on what would be the table header:
* 1) File must be at least as long as an ACPI_TABLE_HEADER
* 2) There must be enough room in the file to hold entire table
* 3) Signature, OemId, OemTableId, AslCompilerId must be ASCII
*
* Note: There can be multiple definition blocks per file, so we cannot
* expect/compare the file size to be equal to the table length. 12/2015.
*
* Note: Maintains current file position.
*
******************************************************************************/
ACPI_STATUS
AcValidateTableHeader (
FILE *File,
long TableOffset)
{
ACPI_TABLE_HEADER TableHeader;
ACPI_TABLE_CDAT *CdatTableHeader = ACPI_CAST_PTR (ACPI_TABLE_CDAT, &TableHeader);
UINT32 HeaderLength;
ACPI_SIZE Actual;
long OriginalOffset;
UINT32 FileSize;
UINT32 i;
ACPI_FUNCTION_TRACE (AcValidateTableHeader);
/* Determine the type of table header */
if (AcpiGbl_CDAT)
{
HeaderLength = sizeof (ACPI_TABLE_CDAT);
}
else
{
HeaderLength = sizeof (ACPI_TABLE_HEADER);
}
/* Read a potential table header */
OriginalOffset = ftell (File);
if (fseek (File, TableOffset, SEEK_SET))
{
fprintf (stderr, "SEEK error\n");
}
Actual = fread (&TableHeader, 1, HeaderLength, File);
if (fseek (File, OriginalOffset, SEEK_SET))
{
fprintf (stderr, "SEEK error\n");
}
if (Actual < HeaderLength)
{
fprintf (stderr,
"Could not read entire table header: Actual %u, Requested %u\n",
(UINT32) Actual, HeaderLength);
return (AE_ERROR);
}
/* Validate the signature (limited ASCII chars) */
if (!AcpiGbl_CDAT && !AcpiUtValidNameseg (TableHeader.Signature))
{
/*
* The "-ds cdat" option was not used, and the signature is not valid.
*
* For CDAT we are assuming that there should be at least one non-ASCII
* byte in the (normally) 4-character Signature field (at least the
* high-order byte should be zero). Otherwise, this is OK.
*/
fprintf (stderr,
"\nTable appears to be a CDAT table, which has no signature.\n"
"If this is in fact a CDAT table, use the -ds option on the\n"
"command line to specify the table type (signature):\n"
"\"iasl -d -ds CDAT <file>\" or \"iasl -ds CDAT -T CDAT\"\n\n");
return (AE_BAD_SIGNATURE);
}
/* Validate table length against bytes remaining in the file */
FileSize = CmGetFileSize (File);
if (!AcpiGbl_CDAT)
{
/* Standard ACPI table header */
if (TableHeader.Length > (UINT32) (FileSize - TableOffset))
{
fprintf (stderr, "Table [%4.4s] is too long for file - "
"needs: 0x%.2X, remaining in file: 0x%.2X\n",
TableHeader.Signature, TableHeader.Length,
(UINT32) (FileSize - TableOffset));
return (AE_BAD_HEADER);
}
}
else if (CdatTableHeader->Length > (UINT32) (FileSize - TableOffset))
{
/* Special header for CDAT table */
fprintf (stderr, "Table [CDAT] is too long for file - "
"needs: 0x%.2X, remaining in file: 0x%.2X\n",
CdatTableHeader->Length,
(UINT32) (FileSize - TableOffset));
return (AE_BAD_HEADER);
}
/* For CDAT table, there are no ASCII fields in the header, we are done */
if (AcpiGbl_CDAT)
{
return (AE_OK);
}
/*
* These standard fields must be ASCII: OemId, OemTableId, AslCompilerId.
* We allow a NULL terminator in OemId and OemTableId.
*/
for (i = 0; i < ACPI_NAMESEG_SIZE; i++)
{
if (!ACPI_IS_ASCII ((UINT8) TableHeader.AslCompilerId[i]))
{
goto BadCharacters;
}
}
for (i = 0; (i < ACPI_OEM_ID_SIZE) && (TableHeader.OemId[i]); i++)
{
if (!ACPI_IS_ASCII ((UINT8) TableHeader.OemId[i]))
{
goto BadCharacters;
}
}
for (i = 0; (i < ACPI_OEM_TABLE_ID_SIZE) && (TableHeader.OemTableId[i]); i++)
{
if (!ACPI_IS_ASCII ((UINT8) TableHeader.OemTableId[i]))
{
goto BadCharacters;
}
}
return (AE_OK);
BadCharacters:
ACPI_WARNING ((AE_INFO,
"Table header for [%4.4s] has invalid ASCII character(s)",
TableHeader.Signature));
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcCheckTextModeCorruption
*
* PARAMETERS: Table - Table buffer starting with table header
*
* RETURN: Status
*
* DESCRIPTION: Check table for text mode file corruption where all linefeed
* characters (LF) have been replaced by carriage return linefeed
* pairs (CR/LF).
*
******************************************************************************/
static ACPI_STATUS
AcCheckTextModeCorruption (
ACPI_TABLE_HEADER *Table)
{
UINT32 i;
UINT32 Pairs = 0;
UINT8 *Buffer = ACPI_CAST_PTR (UINT8, Table);
/* Scan entire table to determine if each LF has been prefixed with a CR */
for (i = 1; i < Table->Length; i++)
{
if (Buffer[i] == 0x0A)
{
if (Buffer[i - 1] != 0x0D)
{
/* The LF does not have a preceding CR, table not corrupted */
return (AE_OK);
}
else
{
/* Found a CR/LF pair */
Pairs++;
}
i++;
}
}
if (!Pairs)
{
return (AE_OK);
}
/*
* Entire table scanned, each CR is part of a CR/LF pair --
* meaning that the table was treated as a text file somewhere.
*
* NOTE: We can't "fix" the table, because any existing CR/LF pairs in the
* original table are left untouched by the text conversion process --
* meaning that we cannot simply replace CR/LF pairs with LFs.
*/
AcpiOsPrintf ("Table has been corrupted by text mode conversion\n");
AcpiOsPrintf ("All LFs (%u) were changed to CR/LF pairs\n", Pairs);
AcpiOsPrintf ("Table cannot be repaired!\n");
return (AE_BAD_VALUE);
}

View File

@@ -0,0 +1,545 @@
/******************************************************************************
*
* Module Name: acgetline - local line editing
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "acpi.h"
#include "accommon.h"
#include "amlcode.h"
#include "acparser.h"
#include "acdebug.h"
/*
* This is an os-independent implementation of line-editing services needed
* by the AcpiExec utility. It uses getchar() and putchar() and the existing
* history support provided by the AML debugger. It assumes that the terminal
* is in the correct line-editing mode such as raw and noecho. The OSL
* interface AcpiOsInitialize should do this. AcpiOsTerminate should put the
* terminal back into the original mode.
*/
#define _COMPONENT ACPI_OS_SERVICES
ACPI_MODULE_NAME ("acgetline")
/* Local prototypes */
static void
AcpiAcClearLine (
UINT32 EndOfLine,
UINT32 CursorPosition);
/* Various ASCII constants */
#define _ASCII_NUL 0
#define _ASCII_BACKSPACE 0x08
#define _ASCII_TAB 0x09
#define _ASCII_ESCAPE 0x1B
#define _ASCII_SPACE 0x20
#define _ASCII_LEFT_BRACKET 0x5B
#define _ASCII_DEL 0x7F
#define _ASCII_UP_ARROW 'A'
#define _ASCII_DOWN_ARROW 'B'
#define _ASCII_RIGHT_ARROW 'C'
#define _ASCII_LEFT_ARROW 'D'
#define _ASCII_NEWLINE '\n'
/* Erase a single character on the input command line */
#define ACPI_CLEAR_CHAR() \
putchar (_ASCII_BACKSPACE); \
putchar (_ASCII_SPACE); \
putchar (_ASCII_BACKSPACE);
/* Backup cursor by Count positions */
#define ACPI_BACKUP_CURSOR(i, Count) \
for (i = 0; i < (Count); i++) \
{putchar (_ASCII_BACKSPACE);}
/******************************************************************************
*
* FUNCTION: AcpiAcClearLine
*
* PARAMETERS: EndOfLine - Current end-of-line index
* CursorPosition - Current cursor position within line
*
* RETURN: None
*
* DESCRIPTION: Clear the entire command line the hard way, but probably the
* most portable.
*
*****************************************************************************/
static void
AcpiAcClearLine (
UINT32 EndOfLine,
UINT32 CursorPosition)
{
UINT32 i;
if (CursorPosition < EndOfLine)
{
/* Clear line from current position to end of line */
for (i = 0; i < (EndOfLine - CursorPosition); i++)
{
putchar (' ');
}
}
/* Clear the entire line */
for (; EndOfLine > 0; EndOfLine--)
{
ACPI_CLEAR_CHAR ();
}
}
/******************************************************************************
*
* FUNCTION: AcpiOsGetLine
*
* PARAMETERS: Buffer - Where to return the command line
* BufferLength - Maximum length of Buffer
* BytesRead - Where the actual byte count is returned
*
* RETURN: Status and actual bytes read
*
* DESCRIPTION: Get the next input line from the terminal. NOTE: terminal
* is expected to be in a mode that supports line-editing (raw,
* noecho). This function is intended to be very portable. Also,
* it uses the history support implemented in the AML debugger.
*
*****************************************************************************/
ACPI_STATUS
AcpiOsGetLine (
char *Buffer,
UINT32 BufferLength,
UINT32 *BytesRead)
{
char *NextCommand;
UINT32 MaxCommandIndex = AcpiGbl_NextCmdNum - 1;
UINT32 CurrentCommandIndex = MaxCommandIndex;
UINT32 PreviousCommandIndex = MaxCommandIndex;
int InputChar;
UINT32 CursorPosition = 0;
UINT32 EndOfLine = 0;
UINT32 i;
/* Always clear the line buffer before we read a new line */
memset (Buffer, 0, BufferLength);
/*
* This loop gets one character at a time (except for esc sequences)
* until a newline or error is detected.
*
* Note: Don't attempt to write terminal control ESC sequences, even
* though it makes certain things more difficult.
*/
while (1)
{
if (EndOfLine >= (BufferLength - 1))
{
return (AE_BUFFER_OVERFLOW);
}
InputChar = getchar ();
switch (InputChar)
{
default: /* This is the normal character case */
/* Echo the character (at EOL) and copy it to the line buffer */
if (EndOfLine == CursorPosition)
{
putchar (InputChar);
Buffer[EndOfLine] = (char) InputChar;
EndOfLine++;
CursorPosition++;
Buffer[EndOfLine] = 0;
continue;
}
/* Insert character into the middle of the buffer */
memmove (&Buffer[CursorPosition + 1], &Buffer[CursorPosition],
(EndOfLine - CursorPosition + 1));
Buffer [CursorPosition] = (char) InputChar;
Buffer [EndOfLine + 1] = 0;
/* Display the new part of line starting at the new character */
fprintf (stdout, "%s", &Buffer[CursorPosition]);
/* Restore cursor */
ACPI_BACKUP_CURSOR (i, EndOfLine - CursorPosition);
CursorPosition++;
EndOfLine++;
continue;
case _ASCII_DEL: /* Backspace key */
if (!EndOfLine) /* Any characters on the command line? */
{
continue;
}
if (EndOfLine == CursorPosition) /* Erase the final character */
{
ACPI_CLEAR_CHAR ();
EndOfLine--;
CursorPosition--;
continue;
}
if (!CursorPosition) /* Do not backup beyond start of line */
{
continue;
}
/* Remove the character from the line */
memmove (&Buffer[CursorPosition - 1], &Buffer[CursorPosition],
(EndOfLine - CursorPosition + 1));
/* Display the new part of line starting at the new character */
putchar (_ASCII_BACKSPACE);
fprintf (stdout, "%s ", &Buffer[CursorPosition - 1]);
/* Restore cursor */
ACPI_BACKUP_CURSOR (i, EndOfLine - CursorPosition + 1);
EndOfLine--;
if (CursorPosition > 0)
{
CursorPosition--;
}
continue;
case _ASCII_NEWLINE: /* Normal exit case at end of command line */
case _ASCII_NUL:
/* Return the number of bytes in the command line string */
if (BytesRead)
{
*BytesRead = EndOfLine;
}
/* Echo, terminate string buffer, and exit */
putchar (InputChar);
Buffer[EndOfLine] = 0;
return (AE_OK);
case _ASCII_TAB:
/* Ignore */
continue;
case EOF:
return (AE_ERROR);
case _ASCII_ESCAPE:
/* Check for escape sequences of the form "ESC[x" */
InputChar = getchar ();
if (InputChar != _ASCII_LEFT_BRACKET)
{
continue; /* Ignore this ESC, does not have the '[' */
}
/* Get the code following the ESC [ */
InputChar = getchar (); /* Backup one character */
switch (InputChar)
{
case _ASCII_LEFT_ARROW:
if (CursorPosition > 0)
{
putchar (_ASCII_BACKSPACE);
CursorPosition--;
}
continue;
case _ASCII_RIGHT_ARROW:
/*
* Move one character forward. Do this without sending
* ESC sequence to the terminal for max portability.
*/
if (CursorPosition < EndOfLine)
{
/* Backup to start of line and print the entire line */
ACPI_BACKUP_CURSOR (i, CursorPosition);
fprintf (stdout, "%s", Buffer);
/* Backup to where the cursor should be */
CursorPosition++;
ACPI_BACKUP_CURSOR (i, EndOfLine - CursorPosition);
}
continue;
case _ASCII_UP_ARROW:
/* If no commands available or at start of history list, ignore */
if (!CurrentCommandIndex)
{
continue;
}
/* Manage our up/down progress */
if (CurrentCommandIndex > PreviousCommandIndex)
{
CurrentCommandIndex = PreviousCommandIndex;
}
/* Get the historical command from the debugger */
NextCommand = AcpiDbGetHistoryByIndex (CurrentCommandIndex);
if (!NextCommand)
{
return (AE_ERROR);
}
/* Make this the active command and echo it */
AcpiAcClearLine (EndOfLine, CursorPosition);
strcpy (Buffer, NextCommand);
fprintf (stdout, "%s", Buffer);
EndOfLine = CursorPosition = strlen (Buffer);
PreviousCommandIndex = CurrentCommandIndex;
CurrentCommandIndex--;
continue;
case _ASCII_DOWN_ARROW:
if (!MaxCommandIndex) /* Any commands available? */
{
continue;
}
/* Manage our up/down progress */
if (CurrentCommandIndex < PreviousCommandIndex)
{
CurrentCommandIndex = PreviousCommandIndex;
}
/* If we are the end of the history list, output a clear new line */
if ((CurrentCommandIndex + 1) > MaxCommandIndex)
{
AcpiAcClearLine (EndOfLine, CursorPosition);
EndOfLine = CursorPosition = 0;
PreviousCommandIndex = CurrentCommandIndex;
continue;
}
PreviousCommandIndex = CurrentCommandIndex;
CurrentCommandIndex++;
/* Get the historical command from the debugger */
NextCommand = AcpiDbGetHistoryByIndex (CurrentCommandIndex);
if (!NextCommand)
{
return (AE_ERROR);
}
/* Make this the active command and echo it */
AcpiAcClearLine (EndOfLine, CursorPosition);
strcpy (Buffer, NextCommand);
fprintf (stdout, "%s", Buffer);
EndOfLine = CursorPosition = strlen (Buffer);
continue;
case 0x31:
case 0x32:
case 0x33:
case 0x34:
case 0x35:
case 0x36:
/*
* Ignore the various keys like insert/delete/home/end, etc.
* But we must eat the final character of the ESC sequence.
*/
(void) getchar ();
continue;
default:
/* Ignore random escape sequences that we don't care about */
continue;
}
continue;
}
}
}

View File

@@ -0,0 +1,512 @@
/******************************************************************************
*
* Module Name: adfile - Application-level disassembler file support routines
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "acpi.h"
#include "accommon.h"
#include "acapps.h"
#include <stdio.h>
#define _COMPONENT ACPI_TOOLS
ACPI_MODULE_NAME ("adfile")
/* Local prototypes */
static INT32
AdWriteBuffer (
char *Filename,
char *Buffer,
UINT32 Length);
static char FilenameBuf[20];
/******************************************************************************
*
* FUNCTION: AfGenerateFilename
*
* PARAMETERS: Prefix - prefix string
* TableId - The table ID
*
* RETURN: Pointer to the completed string
*
* DESCRIPTION: Build an output filename from an ACPI table ID string
*
******************************************************************************/
char *
AdGenerateFilename (
char *Prefix,
char *TableId)
{
UINT32 i;
UINT32 j;
for (i = 0; Prefix[i]; i++)
{
FilenameBuf[i] = Prefix[i];
}
FilenameBuf[i] = '_';
i++;
for (j = 0; j < 8 && (TableId[j] != ' ') && (TableId[j] != 0); i++, j++)
{
FilenameBuf[i] = TableId[j];
}
FilenameBuf[i] = 0;
strcat (FilenameBuf, FILE_SUFFIX_BINARY_TABLE);
return (FilenameBuf);
}
/******************************************************************************
*
* FUNCTION: AfWriteBuffer
*
* PARAMETERS: Filename - name of file
* Buffer - data to write
* Length - length of data
*
* RETURN: Actual number of bytes written
*
* DESCRIPTION: Open a file and write out a single buffer
*
******************************************************************************/
static INT32
AdWriteBuffer (
char *Filename,
char *Buffer,
UINT32 Length)
{
FILE *File;
ACPI_SIZE Actual;
File = fopen (Filename, "wb");
if (!File)
{
printf ("Could not open file %s\n", Filename);
return (-1);
}
Actual = fwrite (Buffer, 1, (size_t) Length, File);
if (Actual != Length)
{
printf ("Could not write to file %s\n", Filename);
}
fclose (File);
return ((INT32) Actual);
}
/******************************************************************************
*
* FUNCTION: AfWriteTable
*
* PARAMETERS: Table - pointer to the ACPI table
* Length - length of the table
* TableName - the table signature
* OemTableID - from the table header
*
* RETURN: None
*
* DESCRIPTION: Dump the loaded tables to a file (or files)
*
******************************************************************************/
void
AdWriteTable (
ACPI_TABLE_HEADER *Table,
UINT32 Length,
char *TableName,
char *OemTableId)
{
char *Filename;
Filename = AdGenerateFilename (TableName, OemTableId);
AdWriteBuffer (Filename, (char *) Table, Length);
AcpiOsPrintf ("Table [%s] written to \"%s\"\n", TableName, Filename);
}
/*******************************************************************************
*
* FUNCTION: FlGenerateFilename
*
* PARAMETERS: InputFilename - Original ASL source filename
* Suffix - New extension.
*
* RETURN: New filename containing the original base + the new suffix
*
* DESCRIPTION: Generate a new filename from the ASL source filename and a new
* extension. Used to create the *.LST, *.TXT, etc. files.
*
******************************************************************************/
char *
FlGenerateFilename (
char *InputFilename,
char *Suffix)
{
char *Position;
char *NewFilename;
char *DirectoryPosition;
/*
* Copy the original filename to a new buffer. Leave room for the worst
* case where we append the suffix, an added dot and the null terminator.
*/
NewFilename = UtLocalCacheCalloc ((ACPI_SIZE)
strlen (InputFilename) + strlen (Suffix) + 2);
strcpy (NewFilename, InputFilename);
/* Try to find the last dot in the filename */
DirectoryPosition = strrchr (NewFilename, '/');
Position = strrchr (NewFilename, '.');
if (Position && (Position > DirectoryPosition))
{
/* Tack on the new suffix */
Position++;
*Position = 0;
strcat (Position, Suffix);
}
else
{
/* No dot, add one and then the suffix */
strcat (NewFilename, ".");
strcat (NewFilename, Suffix);
}
return (NewFilename);
}
/*******************************************************************************
*
* FUNCTION: FlStrdup
*
* DESCRIPTION: Local strdup function
*
******************************************************************************/
static char *
FlStrdup (
char *String)
{
char *NewString;
NewString = UtLocalCacheCalloc ((ACPI_SIZE) strlen (String) + 1);
strcpy (NewString, String);
return (NewString);
}
/*******************************************************************************
*
* FUNCTION: FlSplitInputPathname
*
* PARAMETERS: InputFilename - The user-specified ASL source file to be
* compiled
* OutDirectoryPath - Where the directory path prefix is
* returned
* OutFilename - Where the filename part is returned
*
* RETURN: Status
*
* DESCRIPTION: Split the input path into a directory and filename part
* 1) Directory part used to open include files
* 2) Filename part used to generate output filenames
*
******************************************************************************/
ACPI_STATUS
FlSplitInputPathname (
char *InputPath,
char **OutDirectoryPath,
char **OutFilename)
{
char *Substring;
char *DirectoryPath;
char *Filename;
if (OutDirectoryPath)
{
*OutDirectoryPath = NULL;
}
if (!InputPath)
{
return (AE_OK);
}
/* Get the path to the input filename's directory */
DirectoryPath = FlStrdup (InputPath);
if (!DirectoryPath)
{
return (AE_NO_MEMORY);
}
/* Convert backslashes to slashes in the entire path */
UtConvertBackslashes (DirectoryPath);
/* Backup to last slash or colon */
Substring = strrchr (DirectoryPath, '/');
if (!Substring)
{
Substring = strrchr (DirectoryPath, ':');
}
/* Extract the simple filename */
if (!Substring)
{
Filename = FlStrdup (DirectoryPath);
DirectoryPath[0] = 0;
}
else
{
Filename = FlStrdup (Substring + 1);
*(Substring+1) = 0;
}
if (!Filename)
{
return (AE_NO_MEMORY);
}
if (OutDirectoryPath)
{
*OutDirectoryPath = DirectoryPath;
}
if (OutFilename)
{
*OutFilename = Filename;
return (AE_OK);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: FlGetFileBasename
*
* PARAMETERS: FilePathname - File path to be split
*
* RETURN: The extracted base name of the file, in upper case
*
* DESCRIPTION: Extract the file base name (the file name with no extension)
* from the input pathname.
*
* Note: Any backslashes in the pathname should be previously
* converted to forward slashes before calling this function.
*
******************************************************************************/
char *
FlGetFileBasename (
char *FilePathname)
{
char *FileBasename;
char *Substring;
/* Backup to last slash or colon */
Substring = strrchr (FilePathname, '/');
if (!Substring)
{
Substring = strrchr (FilePathname, ':');
}
/* Extract the full filename (base + extension) */
if (Substring)
{
FileBasename = FlStrdup (Substring + 1);
}
else
{
FileBasename = FlStrdup (FilePathname);
}
/* Remove the filename extension if present */
Substring = strchr (FileBasename, '.');
if (Substring)
{
*Substring = 0;
}
AcpiUtStrupr (FileBasename);
return (FileBasename);
}

View File

@@ -0,0 +1,820 @@
/******************************************************************************
*
* Module Name: adisasm - Application-level disassembler routines
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "amlcode.h"
#include "acdisasm.h"
#include "acdispat.h"
#include "acnamesp.h"
#include "acparser.h"
#include "acapps.h"
#include "acconvert.h"
#define _COMPONENT ACPI_TOOLS
ACPI_MODULE_NAME ("adisasm")
/* Local prototypes */
static ACPI_STATUS
AdDoExternalFileList (
char *Filename);
static ACPI_STATUS
AdDisassembleOneTable (
ACPI_TABLE_HEADER *Table,
FILE *File,
char *Filename,
char *DisasmFilename);
static ACPI_STATUS
AdReparseOneTable (
ACPI_TABLE_HEADER *Table,
FILE *File,
ACPI_OWNER_ID OwnerId);
ACPI_TABLE_DESC LocalTables[1];
ACPI_PARSE_OBJECT *AcpiGbl_ParseOpRoot;
/* Stubs for everything except ASL compiler */
#ifndef ACPI_ASL_COMPILER
BOOLEAN
AcpiDsIsResultUsed (
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState)
{
return (TRUE);
}
ACPI_STATUS
AcpiDsMethodError (
ACPI_STATUS Status,
ACPI_WALK_STATE *WalkState)
{
return (Status);
}
#endif
/*******************************************************************************
*
* FUNCTION: AdInitialize
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: ACPICA and local initialization
*
******************************************************************************/
ACPI_STATUS
AdInitialize (
void)
{
ACPI_STATUS Status;
/* ACPICA subsystem initialization */
Status = AcpiOsInitialize ();
if (ACPI_FAILURE (Status))
{
fprintf (stderr, "Could not initialize ACPICA subsystem: %s\n",
AcpiFormatException (Status));
return (Status);
}
Status = AcpiUtInitGlobals ();
if (ACPI_FAILURE (Status))
{
fprintf (stderr, "Could not initialize ACPICA globals: %s\n",
AcpiFormatException (Status));
return (Status);
}
Status = AcpiUtMutexInitialize ();
if (ACPI_FAILURE (Status))
{
fprintf (stderr, "Could not initialize ACPICA mutex objects: %s\n",
AcpiFormatException (Status));
return (Status);
}
Status = AcpiNsRootInitialize ();
if (ACPI_FAILURE (Status))
{
fprintf (stderr, "Could not initialize ACPICA namespace: %s\n",
AcpiFormatException (Status));
return (Status);
}
/* Setup the Table Manager (cheat - there is no RSDT) */
AcpiGbl_RootTableList.MaxTableCount = 1;
AcpiGbl_RootTableList.CurrentTableCount = 0;
AcpiGbl_RootTableList.Tables = LocalTables;
return (AE_OK);
}
/******************************************************************************
*
* FUNCTION: AdAmlDisassemble
*
* PARAMETERS: Filename - AML input filename
* OutToFile - TRUE if output should go to a file
* Prefix - Path prefix for output
* OutFilename - where the filename is returned
*
* RETURN: Status
*
* DESCRIPTION: Disassembler entry point. Disassemble an entire ACPI table.
*
*****************************************************************************/
ACPI_STATUS
AdAmlDisassemble (
BOOLEAN OutToFile,
char *Filename,
char *Prefix,
char **OutFilename)
{
ACPI_STATUS Status;
char *DisasmFilename = NULL;
FILE *File = NULL;
ACPI_TABLE_HEADER *Table = NULL;
ACPI_NEW_TABLE_DESC *ListHead = NULL;
/*
* Input: AML code from either a file or via GetTables (memory or
* registry)
*/
if (Filename)
{
/* Get the list of all AML tables in the file */
Status = AcGetAllTablesFromFile (Filename,
ACPI_GET_ALL_TABLES, &ListHead);
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not get ACPI tables from %s, %s\n",
Filename, AcpiFormatException (Status));
return (Status);
}
/* Process any user-specified files for external objects */
Status = AdDoExternalFileList (Filename);
if (ACPI_FAILURE (Status))
{
return (Status);
}
}
else
{
Status = AdGetLocalTables ();
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not get ACPI tables, %s\n",
AcpiFormatException (Status));
return (Status);
}
if (!AcpiGbl_DmOpt_Disasm)
{
return (AE_OK);
}
/* Obtained the local tables, just disassemble the DSDT */
Status = AcpiGetTable (ACPI_SIG_DSDT, 0, &Table);
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not get DSDT, %s\n",
AcpiFormatException (Status));
return (Status);
}
AcpiOsPrintf ("\nDisassembly of DSDT\n");
Prefix = AdGenerateFilename ("dsdt", Table->OemTableId);
}
/*
* Output: ASL code. Redirect to a file if requested
*/
if (OutToFile)
{
/* Create/Open a disassembly output file */
DisasmFilename = FlGenerateFilename (Prefix, FILE_SUFFIX_DISASSEMBLY);
if (!DisasmFilename)
{
fprintf (stderr, "Could not generate output filename\n");
Status = AE_ERROR;
goto Cleanup;
}
File = fopen (DisasmFilename, "w+");
if (!File)
{
fprintf (stderr, "Could not open output file %s\n",
DisasmFilename);
Status = AE_ERROR;
goto Cleanup;
}
}
*OutFilename = DisasmFilename;
/* Disassemble all AML tables within the file */
while (ListHead)
{
Status = AdDisassembleOneTable (ListHead->Table,
File, Filename, DisasmFilename);
if (ACPI_FAILURE (Status))
{
break;
}
ListHead = ListHead->Next;
}
Cleanup:
if (Table &&
!AcpiGbl_ForceAmlDisassembly &&
!AcpiUtIsAmlTable (Table))
{
ACPI_FREE (Table);
}
AcDeleteTableList (ListHead);
if (File)
{
fclose (File);
AcpiOsRedirectOutput (stdout);
}
AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot);
AcpiGbl_ParseOpRoot = NULL;
return (Status);
}
/******************************************************************************
*
* FUNCTION: AdDisassembleOneTable
*
* PARAMETERS: Table - Raw AML table
* File - Pointer for the input file
* Filename - AML input filename
* DisasmFilename - Output filename
*
* RETURN: Status
*
* DESCRIPTION: Disassemble a single ACPI table. AML or data table.
*
*****************************************************************************/
static ACPI_STATUS
AdDisassembleOneTable (
ACPI_TABLE_HEADER *Table,
FILE *File,
char *Filename,
char *DisasmFilename)
{
ACPI_STATUS Status;
ACPI_OWNER_ID OwnerId;
#ifdef ACPI_ASL_COMPILER
/*
* For ASL-/ASL+ converter: replace the temporary "XXXX"
* table signature with the original. This "XXXX" makes
* it harder for the AML interpreter to run the badaml
* (.xxx) file produced from the converter in case if
* it fails to get deleted.
*/
if (AcpiGbl_CaptureComments)
{
memcpy (Table->Signature, AcpiGbl_TableSig, ACPI_NAMESEG_SIZE);
}
#endif
/* ForceAmlDisassembly means to assume the table contains valid AML */
if (!AcpiGbl_ForceAmlDisassembly && !AcpiUtIsAmlTable (Table))
{
if (File)
{
AcpiOsRedirectOutput (File);
}
AdDisassemblerHeader (Filename, ACPI_IS_DATA_TABLE);
/* This is a "Data Table" (non-AML table) */
AcpiOsPrintf (" * ACPI Data Table [%4.4s]\n *\n",
AcpiGbl_CDAT ? (char *) AcpiGbl_CDAT : Table->Signature);
AcpiOsPrintf (" * Format: [HexOffset DecimalOffset ByteLength] "
"FieldName : FieldValue (in hex)\n */\n\n");
AcpiDmDumpDataTable (Table);
fprintf (stderr, "Acpi Data Table [%4.4s] decoded\n",
AcpiGbl_CDAT ? (char *) AcpiGbl_CDAT : Table->Signature);
if (File)
{
fprintf (stderr, "Formatted output: %s - %u bytes\n",
DisasmFilename, CmGetFileSize (File));
}
return (AE_OK);
}
/* Initialize the converter output file */
ASL_CV_INIT_FILETREE(Table, File);
/*
* This is an AML table (DSDT or SSDT).
* Always parse the tables, only option is what to display
*/
Status = AdParseTable (Table, &OwnerId, TRUE, FALSE);
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not parse ACPI tables, %s\n",
AcpiFormatException (Status));
return (Status);
}
/* Redirect output for code generation and debugging output */
if (File)
{
AcpiOsRedirectOutput (File);
}
/* Debug output, namespace and parse tree */
if (AslCompilerdebug && File)
{
AcpiOsPrintf ("/**** Before second load\n");
NsSetupNamespaceListing (File);
NsDisplayNamespace ();
AcpiOsPrintf ("*****/\n");
}
/* Load namespace from names created within control methods */
AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot,
AcpiGbl_RootNode, OwnerId);
/*
* Cross reference the namespace here, in order to
* generate External() statements
*/
AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot,
AcpiGbl_RootNode, OwnerId);
if (AslCompilerdebug)
{
AcpiDmDumpTree (AcpiGbl_ParseOpRoot);
}
/* Find possible calls to external control methods */
AcpiDmFindOrphanMethods (AcpiGbl_ParseOpRoot);
/*
* If we found any external control methods, we must reparse
* the entire tree with the new information (namely, the
* number of arguments per method)
*/
if (AcpiDmGetUnresolvedExternalMethodCount ())
{
Status = AdReparseOneTable (Table, File, OwnerId);
if (ACPI_FAILURE (Status))
{
return (Status);
}
}
/*
* Now that the namespace is finalized, we can perform namespace
* transforms.
*
* 1) Convert fixed-offset references to resource descriptors
* to symbolic references (Note: modifies namespace)
*/
AcpiDmConvertParseObjects (AcpiGbl_ParseOpRoot, AcpiGbl_RootNode);
/* Optional displays */
if (AcpiGbl_DmOpt_Disasm)
{
/* This is the real disassembly */
AdDisplayTables (Filename, Table);
/* Dump hex table if requested (-vt) */
AcpiDmDumpDataTable (Table);
fprintf (stderr, "Disassembly completed\n");
if (File)
{
fprintf (stderr, "ASL Output: %s - %u bytes\n",
DisasmFilename, CmGetFileSize (File));
}
if (AslGbl_MapfileFlag)
{
fprintf (stderr, "%14s %s - %u bytes\n",
AslGbl_FileDescs[ASL_FILE_MAP_OUTPUT].ShortDescription,
AslGbl_Files[ASL_FILE_MAP_OUTPUT].Filename,
FlGetFileSize (ASL_FILE_MAP_OUTPUT));
}
}
return (AE_OK);
}
/******************************************************************************
*
* FUNCTION: AdReparseOneTable
*
* PARAMETERS: Table - Raw AML table
* File - Pointer for the input file
* OwnerId - ID for this table
*
* RETURN: Status
*
* DESCRIPTION: Reparse a table that has already been loaded. Used to
* integrate information about external control methods.
* These methods may have been previously parsed incorrectly.
*
*****************************************************************************/
static ACPI_STATUS
AdReparseOneTable (
ACPI_TABLE_HEADER *Table,
FILE *File,
ACPI_OWNER_ID OwnerId)
{
ACPI_STATUS Status;
ACPI_COMMENT_ADDR_NODE *AddrListHead;
fprintf (stderr,
"\nFound %u external control methods, "
"reparsing with new information\n",
AcpiDmGetUnresolvedExternalMethodCount ());
/* Reparse, rebuild namespace */
AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot);
AcpiGbl_ParseOpRoot = NULL;
AcpiNsDeleteNamespaceSubtree (AcpiGbl_RootNode);
AcpiGbl_RootNode = NULL;
AcpiGbl_RootNodeStruct.Name.Integer = ACPI_ROOT_NAME;
AcpiGbl_RootNodeStruct.DescriptorType = ACPI_DESC_TYPE_NAMED;
AcpiGbl_RootNodeStruct.Type = ACPI_TYPE_DEVICE;
AcpiGbl_RootNodeStruct.Parent = NULL;
AcpiGbl_RootNodeStruct.Child = NULL;
AcpiGbl_RootNodeStruct.Peer = NULL;
AcpiGbl_RootNodeStruct.Object = NULL;
AcpiGbl_RootNodeStruct.Flags = 0;
Status = AcpiNsRootInitialize ();
if (ACPI_FAILURE (Status))
{
return (Status);
}
/* New namespace, add the external definitions first */
AcpiDmAddExternalListToNamespace ();
/* For -ca option: clear the list of comment addresses. */
while (AcpiGbl_CommentAddrListHead)
{
AddrListHead= AcpiGbl_CommentAddrListHead;
AcpiGbl_CommentAddrListHead = AcpiGbl_CommentAddrListHead->Next;
AcpiOsFree(AddrListHead);
}
/* Parse the table again. No need to reload it, however */
Status = AdParseTable (Table, NULL, FALSE, FALSE);
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not parse ACPI tables, %s\n",
AcpiFormatException (Status));
return (Status);
}
/* Cross reference the namespace again */
AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot,
AcpiGbl_RootNode, OwnerId);
AcpiDmCrossReferenceNamespace (AcpiGbl_ParseOpRoot,
AcpiGbl_RootNode, OwnerId);
/* Debug output - namespace and parse tree */
if (AslCompilerdebug)
{
AcpiOsPrintf ("/**** After second load and resource conversion\n");
if (File)
{
NsSetupNamespaceListing (File);
NsDisplayNamespace ();
}
AcpiOsPrintf ("*****/\n");
AcpiDmDumpTree (AcpiGbl_ParseOpRoot);
}
return (AE_OK);
}
/******************************************************************************
*
* FUNCTION: AdDoExternalFileList
*
* PARAMETERS: Filename - Input file for the table
*
* RETURN: Status
*
* DESCRIPTION: Process all tables found in the -e external files list
*
*****************************************************************************/
static ACPI_STATUS
AdDoExternalFileList (
char *Filename)
{
ACPI_EXTERNAL_FILE *ExternalFileList;
char *ExternalFilename;
ACPI_NEW_TABLE_DESC *ExternalListHead = NULL;
ACPI_STATUS Status;
ACPI_STATUS GlobalStatus = AE_OK;
ACPI_OWNER_ID OwnerId;
/*
* External filenames are specified on the command line like this:
* Example: iasl -e file1,file2,file3 -d xxx.aml
*/
ExternalFileList = AcpiGbl_ExternalFileList;
/* Process each external file */
while (ExternalFileList)
{
ExternalFilename = ExternalFileList->Path;
if (!strcmp (ExternalFilename, Filename))
{
/* Next external file */
ExternalFileList = ExternalFileList->Next;
continue;
}
AcpiOsPrintf ("External object resolution file %16s\n",
ExternalFilename);
Status = AcGetAllTablesFromFile (
ExternalFilename, ACPI_GET_ONLY_AML_TABLES, &ExternalListHead);
if (ACPI_FAILURE (Status))
{
if (Status == AE_TYPE)
{
ExternalFileList = ExternalFileList->Next;
GlobalStatus = AE_TYPE;
continue;
}
AcDeleteTableList (ExternalListHead);
return (Status);
}
/* Load external tables for symbol resolution */
while (ExternalListHead)
{
Status = AdParseTable (
ExternalListHead->Table, &OwnerId, TRUE, TRUE);
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not parse external ACPI tables, %s\n",
AcpiFormatException (Status));
AcDeleteTableList (ExternalListHead);
return (Status);
}
/*
* Load namespace from names created within control methods
* Set owner id of nodes in external table
*/
AcpiDmFinishNamespaceLoad (AcpiGbl_ParseOpRoot,
AcpiGbl_RootNode, OwnerId);
AcpiPsDeleteParseTree (AcpiGbl_ParseOpRoot);
AcpiGbl_ParseOpRoot = NULL;
ExternalListHead = ExternalListHead->Next;
}
/* Next external file */
ExternalFileList = ExternalFileList->Next;
}
AcDeleteTableList (ExternalListHead);
if (ACPI_FAILURE (GlobalStatus))
{
return (GlobalStatus);
}
/* Clear external list generated by Scope in external tables */
if (AcpiGbl_ExternalFileList)
{
AcpiDmClearExternalList ();
}
/* Load any externals defined in the optional external ref file */
AcpiDmGetExternalsFromFile ();
return (AE_OK);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,356 @@
/******************************************************************************
*
* Module Name: ahids - Table of ACPI/PNP _HID/_CID values
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "acpi.h"
#include "accommon.h"
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("ahids")
/*
* ACPI/PNP Device IDs with description strings
*/
const AH_DEVICE_ID AslDeviceIds[] =
{
{"10EC5640", "Realtek I2S Audio Codec"},
{"80860F09", "Intel PWM Controller"},
{"80860F0A", "Intel Atom UART Controller"},
{"80860F0E", "Intel SPI Controller"},
{"80860F14", "Intel Baytrail SDIO/MMC Host Controller"},
{"80860F28", "Intel SST Audio DSP"},
{"80860F41", "Intel Baytrail I2C Host Controller"},
{"ACPI0001", "SMBus 1.0 Host Controller"},
{"ACPI0002", "Smart Battery Subsystem"},
{"ACPI0003", "Power Source Device"},
{"ACPI0004", "Module Device"},
{"ACPI0005", "SMBus 2.0 Host Controller"},
{"ACPI0006", "GPE Block Device"},
{"ACPI0007", "Processor Device"},
{"ACPI0008", "Ambient Light Sensor Device"},
{"ACPI0009", "I/O xAPIC Device"},
{"ACPI000A", "I/O APIC Device"},
{"ACPI000B", "I/O SAPIC Device"},
{"ACPI000C", "Processor Aggregator Device"},
{"ACPI000D", "Power Meter Device"},
{"ACPI000E", "Time and Alarm Device"},
{"ACPI000F", "User Presence Detection Device"},
{"ACPI0010", "Processor Container Device"},
{"ACPI0011", "Generic Buttons Device"},
{"ACPI0012", "NVDIMM Root Device"},
{"ACPI0013", "Generic Event Device"},
{"ACPI0014", "Wireless Power Calibration Device"},
{"ACPI0015", "USB4 host interface device"},
{"ACPI0016", "Compute Express Link Host Bridge"},
{"ADMA0F28", "Intel Audio DMA"},
{"AMCR0F28", "Intel Audio Machine Driver"},
{"ATK4001", "Asus Radio Control Button"},
{"ATML1000", "Atmel Touchscreen Controller"},
{"AUTH2750", "AuthenTec AES2750"},
{"BCM2E39", "Broadcom BT Serial Bus Driver over UART Bus Enumerator"},
{"BCM4752E", "Broadcom GPS Controller"},
{"BMG0160", "Bosch Gyro Sensor"},
{"CPLM3218", "Capella Micro CM3218x Ambient Light Sensor"},
{"DELLABCE", "Dell Airplane Mode Switch Driver"},
{"DLAC3002", "Qualcomm Atheros Bluetooth UART Transport"},
{"FTTH5506", "FocalTech 5506 Touch Controller"},
{"HAD0F28", "Intel HDMI Audio Driver"},
{"INBC0000", "GPIO Expander"},
{"INT0002", "Virtual GPIO Controller"},
{"INT0800", "Intel 82802 Firmware Hub Device"},
{"INT3394", "ACPI System Fan"},
{"INT3396", "Standard Power Management Controller"},
{"INT33A0", "Intel Smart Connect Technology Device"},
{"INT33A1", "Intel Power Engine"},
{"INT33BB", "Intel Baytrail SD Host Controller"},
{"INT33BD", "Intel Baytrail Mailbox Device"},
{"INT33BE", "Camera Sensor OV5693"},
{"INT33C0", "Intel Serial I/O SPI Host Controller"},
{"INT33C1", "Intel Serial I/O SPI Host Controller"},
{"INT33C2", "Intel Serial I/O I2C Host Controller"},
{"INT33C3", "Intel Serial I/O I2C Host Controller"},
{"INT33C4", "Intel Serial I/O UART Host Controller"},
{"INT33C5", "Intel Serial I/O UART Host Controller"},
{"INT33C6", "Intel SD Host Controller"},
{"INT33C7", "Intel Serial I/O GPIO Host Controller"},
{"INT33C8", "Intel Smart Sound Technology Host Controller"},
{"INT33C9", "Wolfson Microelectronics Audio WM5102"},
{"INT33CA", "Intel SPB Peripheral"},
{"INT33CB", "Intel Smart Sound Technology Audio Codec"},
{"INT33D1", "Intel GPIO Buttons"},
{"INT33D2", "Intel GPIO Buttons"},
{"INT33D3", "Intel GPIO Buttons"},
{"INT33D4", "Intel GPIO Buttons"},
{"INT33D6", "Intel Virtual Buttons Device"},
{"INT33F0", "Camera Sensor MT9M114"},
{"INT33F4", "XPOWER PMIC Controller"},
{"INT33F5", "TI PMIC Controller"},
{"INT33FB", "MIPI-CSI Camera Sensor OV2722"},
{"INT33FC", "Intel Baytrail GPIO Controller"},
{"INT33FD", "Intel Baytrail Power Management IC"},
{"INT33FE", "XPOWER Battery Device"},
{"INT3400", "Intel Dynamic Power Performance Management"},
{"INT3401", "Intel Extended Thermal Model CPU"},
{"INT3403", "DPTF Temperature Sensor"},
{"INT3406", "Intel Dynamic Platform & Thermal Framework Display Participant"},
{"INT3407", "DPTF Platform Power Meter"},
{"INT340E", "Motherboard Resources"},
{"INT3420", "Intel Bluetooth RF Kill"},
{"INT3F0D", "ACPI Motherboard Resources"},
{"INTCF1A", "Sony IMX175 Camera Sensor"},
{"INTCFD9", "Intel Baytrail SOC GPIO Controller"},
{"INTL9C60", "Intel Baytrail SOC DMA Controller"},
{"INVN6500", "InvenSense MPU-6500 Six Axis Gyroscope and Accelerometer"},
{"LNXCPU", "Linux Logical CPU"},
{"LNXPOWER", "ACPI Power Resource (power gating)"},
{"LNXPWRBN", "System Power Button"},
{"LNXSYBUS", "System Bus"},
{"LNXSYSTM", "ACPI Root Node"},
{"LNXTHERM", "ACPI Thermal Zone"},
{"LNXVIDEO", "ACPI Video Controller"},
{"MAX17047", "Fuel Gauge Controller"},
{"MSFT0101", "TPM 2.0 Security Device"},
{"NXP5442", "NXP 5442 Near Field Communications Controller"},
{"NXP5472", "NXP NFC"},
{"PNP0000", "8259-compatible Programmable Interrupt Controller"},
{"PNP0001", "EISA Interrupt Controller"},
{"PNP0002", "MCA Interrupt Controller"},
{"PNP0003", "IO-APIC Interrupt Controller"},
{"PNP0100", "PC-class System Timer"},
{"PNP0103", "HPET System Timer"},
{"PNP0200", "PC-class DMA Controller"},
{"PNP0300", "IBM PC/XT Keyboard Controller (83 key)"},
{"PNP0301", "IBM PC/XT Keyboard Controller (86 key)"},
{"PNP0302", "IBM PC/XT Keyboard Controller (84 key)"},
{"PNP0303", "IBM Enhanced Keyboard (101/102-key, PS/2 Mouse)"},
{"PNP0400", "Standard LPT Parallel Port"},
{"PNP0401", "ECP Parallel Port"},
{"PNP0500", "Standard PC COM Serial Port"},
{"PNP0501", "16550A-compatible COM Serial Port"},
{"PNP0510", "Generic IRDA-compatible Device"},
{"PNP0800", "Microsoft Sound System Compatible Device"},
{"PNP0A03", "PCI Bus"},
{"PNP0A05", "Generic Container Device"},
{"PNP0A06", "Generic Container Device"},
{"PNP0A08", "PCI Express Bus"},
{"PNP0B00", "AT Real-Time Clock"},
{"PNP0B01", "Intel PIIX4-compatible RTC/CMOS Device"},
{"PNP0B02", "Dallas Semiconductor-compatible RTC/CMOS Device"},
{"PNP0C01", "System Board"},
{"PNP0C02", "PNP Motherboard Resources"},
{"PNP0C04", "x87-compatible Floating Point Processing Unit"},
{"PNP0C08", "ACPI Core Hardware"},
{"PNP0C09", "Embedded Controller Device"},
{"PNP0C0A", "Control Method Battery"},
{"PNP0C0B", "Fan (Thermal Solution)"},
{"PNP0C0C", "Power Button Device"},
{"PNP0C0D", "Lid Device"},
{"PNP0C0E", "Sleep Button Device"},
{"PNP0C0F", "PCI Interrupt Link Device"},
{"PNP0C10", "System Indicator Device"},
{"PNP0C11", "Thermal Zone"},
{"PNP0C12", "Device Bay Controller"},
{"PNP0C14", "Windows Management Instrumentation Device"},
{"PNP0C15", "Docking Station"},
{"PNP0C33", "Error Device"},
{"PNP0C40", "Standard Button Controller"},
{"PNP0C50", "HID Protocol Device (I2C bus)"},
{"PNP0C60", "Display Sensor Device"},
{"PNP0C70", "Dock Sensor Device"},
{"PNP0C80", "Memory Device"},
{"PNP0D10", "XHCI USB Controller with debug"},
{"PNP0D15", "XHCI USB Controller without debug"},
{"PNP0D20", "EHCI USB Controller without debug"},
{"PNP0D25", "EHCI USB Controller with debug"},
{"PNP0D40", "SDA Standard Compliant SD Host Controller"},
{"PNP0D80", "Windows-compatible System Power Management Controller"},
{"PNP0F03", "Microsoft PS/2-style Mouse"},
{"PNP0F13", "PS/2 Mouse"},
{"RTL8723", "Realtek Wireless Controller"},
{"SMB0349", "Charger"},
{"SMO91D0", "Sensor Hub"},
{"SMSC3750", "SMSC 3750 USB MUX"},
{"SSPX0000", "Intel SSP Device"},
{"TBQ24296", "Charger"},
{NULL, NULL}
};
/*******************************************************************************
*
* FUNCTION: AcpiAhMatchHardwareId
*
* PARAMETERS: HardwareId - String representation of an _HID or _CID
*
* RETURN: ID info struct. NULL if HardwareId is not found
*
* DESCRIPTION: Lookup an _HID/_CID in the device ID table
*
******************************************************************************/
const AH_DEVICE_ID *
AcpiAhMatchHardwareId (
char *HardwareId)
{
const AH_DEVICE_ID *Info;
for (Info = AslDeviceIds; Info->Name; Info++)
{
if (!strcmp (HardwareId, Info->Name))
{
return (Info);
}
}
return (NULL);
}

View File

@@ -0,0 +1,510 @@
/******************************************************************************
*
* Module Name: ahpredef - Table of all known ACPI predefined names
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "acpi.h"
#include "accommon.h"
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("ahpredef")
/*
* iASL only needs a partial table (short descriptions only).
* AcpiHelp needs the full table.
*/
#ifdef ACPI_ASL_COMPILER
#define AH_PREDEF(Name, ShortDesc, LongDesc) {Name, ShortDesc}
#else
#define AH_PREDEF(Name, ShortDesc, LongDesc) {Name, ShortDesc, LongDesc}
#endif
/*
* Predefined ACPI names, with short description and return value.
* This table was extracted directly from the ACPI specification.
*/
const AH_PREDEFINED_NAME AslPredefinedInfo[] =
{
AH_PREDEF ("_ACx", "Active Cooling, x=0-9", "Returns the active cooling policy threshold values"),
AH_PREDEF ("_ADR", "Address", "Returns address of a device on parent bus, and resource field"),
AH_PREDEF ("_AEI", "ACPI Event Interrupts", "Returns a list of GPIO events to be used as ACPI events"),
AH_PREDEF ("_ALC", "Ambient Light Chromaticity", "Returns the ambient light color chromaticity"),
AH_PREDEF ("_ALI", "Ambient Light Illuminance", "Returns the ambient light brightness"),
AH_PREDEF ("_ALN", "Alignment", "Base alignment, Resource Descriptor field"),
AH_PREDEF ("_ALP", "Ambient Light Polling", "Returns the ambient light sensor polling frequency"),
AH_PREDEF ("_ALR", "Ambient Light Response", "Returns the ambient light brightness to display brightness mappings"),
AH_PREDEF ("_ALT", "Ambient Light Temperature", "Returns the ambient light color temperature"),
AH_PREDEF ("_ALx", "Active List, x=0-9", "Returns a list of active cooling device objects"),
AH_PREDEF ("_ART", "Active Cooling Relationship Table", "Returns thermal relationship information between platform devices and fan devices"),
AH_PREDEF ("_ASI", "Address Space Id", "Resource Descriptor field"),
AH_PREDEF ("_ASZ", "Access Size", "Resource Descriptor field"),
AH_PREDEF ("_ATT", "Type-Specific Attribute", "Resource Descriptor field"),
AH_PREDEF ("_BAS", "Base Address", "Range base address, Resource Descriptor field"),
AH_PREDEF ("_BBN", "BIOS Bus Number", "Returns the PCI bus number returned by the BIOS"),
AH_PREDEF ("_BCL", "Brightness Control Levels", "Returns a list of supported brightness control levels"),
AH_PREDEF ("_BCM", "Brightness Control Method", "Sets the brightness level of the display device"),
AH_PREDEF ("_BCT", "Battery Charge Time", "Returns time remaining to complete charging battery"),
AH_PREDEF ("_BDN", "BIOS Dock Name", "Returns the Dock ID returned by the BIOS"),
AH_PREDEF ("_BFS", "Back From Sleep", "Inform AML of a wake event"),
AH_PREDEF ("_BIF", "Battery Information", "Returns a Control Method Battery information block"),
AH_PREDEF ("_BIX", "Battery Information Extended", "Returns a Control Method Battery extended information block"),
AH_PREDEF ("_BLT", "Battery Level Threshold", "Set battery level threshold preferences"),
AH_PREDEF ("_BM_", "Bus Master", "Resource Descriptor field"),
AH_PREDEF ("_BMA", "Battery Measurement Averaging Interval", "Sets battery measurement averaging interval"),
AH_PREDEF ("_BMC", "Battery Maintenance Control", "Sets battery maintenance and control features"),
AH_PREDEF ("_BMD", "Battery Maintenance Data", "Returns battery maintenance, control, and state data"),
AH_PREDEF ("_BMS", "Battery Measurement Sampling Time", "Sets the battery measurement sampling time"),
AH_PREDEF ("_BPC", "Battery Power Characteristics", "Returns static values used to configure power threshold support in the platform firmware"),
AH_PREDEF ("_BPS", "Battery Power State", "Returns the power delivery capabilities of the battery at the present time"),
AH_PREDEF ("_BPT", "Battery Power Threshold", "Set a relative battery peak power capability change threshold"),
AH_PREDEF ("_BQC", "Brightness Query Current", "Returns the current display brightness level"),
AH_PREDEF ("_BST", "Battery Status", "Returns a Control Method Battery status block"),
AH_PREDEF ("_BTH", "Battery Throttle Limit", "Thermal limit for charging and discharging"),
AH_PREDEF ("_BTM", "Battery Time", "Returns the battery runtime"),
AH_PREDEF ("_BTP", "Battery Trip Point", "Sets a Control Method Battery trip point"),
AH_PREDEF ("_CBA", "Configuration Base Address", "Sets the base address for a PCI Express host bridge"),
AH_PREDEF ("_CBR", "CXL Host Bridge Register Info", "Get the memory location of CXL Host Bridge Registers"),
AH_PREDEF ("_CCA", "Cache Coherency Attribute", "Returns a device's support level for cache coherency"),
AH_PREDEF ("_CDM", "Clock Domain", "Returns a logical processor's clock domain identifier"),
AH_PREDEF ("_CID", "Compatible ID", "Returns a device's Plug and Play Compatible ID list"),
AH_PREDEF ("_CLS", "Class Code", "Returns PCI class code and subclass"),
AH_PREDEF ("_CPC", "Continuous Performance Control", "Returns a list of performance control interfaces"),
AH_PREDEF ("_CR3", "Warm/Standby Temperature", "Temperature for a fast low power state"),
AH_PREDEF ("_CRS", "Current Resource Settings", "Returns the current resource settings for a device"),
AH_PREDEF ("_CRT", "Critical Temperature", "Returns the shutdown critical temperature"),
AH_PREDEF ("_CSD", "C-State Dependencies", "Returns a list of C-state dependencies"),
AH_PREDEF ("_CST", "C-States", "Returns a list of supported C-states"),
AH_PREDEF ("_CWS", "Clear Wake Alarm Status", "Clear the status of wake alarms"),
AH_PREDEF ("_DBT", "Debounce Timeout", "Timeout value, Resource Descriptor field"),
AH_PREDEF ("_DCK", "Dock Present", "Sets docking isolation. Presence indicates device is a docking station"),
AH_PREDEF ("_DCS", "Display Current Status", "Returns status of the display output device"),
AH_PREDEF ("_DDC", "Display Data Current", "Returns the EDID for the display output device"),
AH_PREDEF ("_DDN", "DOS Device Name", "Returns a device logical name"),
AH_PREDEF ("_DEC", "Decode", "Device decoding type, Resource Descriptor field"),
AH_PREDEF ("_DEP", "Dependencies", "Returns a list of operation region dependencies"),
AH_PREDEF ("_DGS", "Display Graphics State", "Return the current state of the output device"),
AH_PREDEF ("_DIS", "Disable Device", "Disables a device"),
AH_PREDEF ("_DLM", "Device Lock Mutex", "Defines mutex for OS/AML sharing"),
AH_PREDEF ("_DMA", "Direct Memory Access", "Returns device current resources for DMA transactions, and resource field"),
AH_PREDEF ("_DOD", "Display Output Devices", "Enumerate all devices attached to the display adapter"),
AH_PREDEF ("_DOS", "Disable Output Switching", "Sets the display output switching mode"),
AH_PREDEF ("_DSC", "Deepest State for Configuration", "Returns the deepest D-state of the device to the OSPM"),
AH_PREDEF ("_DPL", "Device Selection Polarity", "Polarity of Device Selection signal, Resource Descriptor field"),
AH_PREDEF ("_DRS", "Drive Strength", "Drive Strength setting for GPIO connection, Resource Descriptor field"),
AH_PREDEF ("_DSD", "Device-Specific Data", "Returns a list of device property information"),
AH_PREDEF ("_DSM", "Device-Specific Method", "Executes device-specific functions"),
AH_PREDEF ("_DSS", "Device Set State", "Sets the display device state"),
AH_PREDEF ("_DSW", "Device Sleep Wake", "Sets the sleep and wake transition states for a device"),
AH_PREDEF ("_DTI", "Device Temperature Indication", "Conveys native device temperature to the platform"),
AH_PREDEF ("_Exx", "Edge-Triggered GPE, xx=0x00-0xFF", "Method executed as a result of a general-purpose event"),
AH_PREDEF ("_EC_", "Embedded Controller", "returns EC offset and query information"),
AH_PREDEF ("_EDL", "Eject Device List", "Returns a list of devices that are dependent on a device (docking)"),
AH_PREDEF ("_EJD", "Ejection Dependent Device", "Returns the name of dependent (parent) device (docking)"),
AH_PREDEF ("_EJx", "Eject Device, x=0-9", "Begin or cancel a device ejection request (docking)"),
AH_PREDEF ("_END", "Endianness", "Endian orientation, Resource Descriptor field"),
AH_PREDEF ("_EVT", "Event", "Event method for GPIO events"),
AH_PREDEF ("_FDE", "Floppy Disk Enumerate", "Returns floppy disk configuration information"),
AH_PREDEF ("_FDI", "Floppy Drive Information", "Returns a floppy drive information block"),
AH_PREDEF ("_FDM", "Floppy Drive Mode", "Sets a floppy drive speed"),
AH_PREDEF ("_FIF", "Fan Information", "Returns fan device information"),
AH_PREDEF ("_FIT", "Firmware Interface Table", "Returns a list of NFIT structures"),
AH_PREDEF ("_FIX", "Fixed Register Resource Provider", "Returns a list of devices that implement FADT register blocks"),
AH_PREDEF ("_FLC", "Flow Control", "Flow control, Resource Descriptor field"),
AH_PREDEF ("_FPS", "Fan Performance States", "Returns a list of supported fan performance states"),
AH_PREDEF ("_FSL", "Fan Set Level", "Control method that sets the fan device's speed level (performance state)"),
AH_PREDEF ("_FST", "Fan Status", "Returns current status information for a fan device"),
AH_PREDEF ("_FUN", "Function Number", "Resource descriptor field"),
AH_PREDEF ("_GAI", "Get Averaging Interval", "Returns the power meter averaging interval"),
AH_PREDEF ("_GCP", "Get Capabilities", "Get device time capabilities"),
AH_PREDEF ("_GHL", "Get Hardware Limit", "Returns the hardware limit enforced by the power meter"),
AH_PREDEF ("_GL_", "Global Lock", "OS-defined Global Lock mutex object"),
AH_PREDEF ("_GLK", "Get Global Lock Requirement", "Returns a device's Global Lock requirement for device access"),
AH_PREDEF ("_GPD", "Get Post Data", "Returns the value of the VGA device that will be posted at boot"),
AH_PREDEF ("_GPE", "General Purpose Events", "Predefined scope (\\_GPE) or SCI number for EC"),
AH_PREDEF ("_GRA", "Granularity", "Address space granularity, Resource Descriptor field"),
AH_PREDEF ("_GRT", "Get Real Time", "Returns current time-of-day from a time/alarm device"),
AH_PREDEF ("_GSB", "Global System Interrupt Base", "Returns the GSB for a I/O APIC device"),
AH_PREDEF ("_GTF", "Get Task File", "Returns a list of ATA commands to restore a drive to default state"),
AH_PREDEF ("_GTM", "Get Timing Mode", "Returns a list of IDE controller timing information"),
AH_PREDEF ("_GTS", "Going To Sleep", "Inform AML of pending sleep"),
AH_PREDEF ("_GWS", "Get Wake Status", "Return status of wake alarms"),
AH_PREDEF ("_HE_", "High-Edge", "Interrupt triggering, Resource Descriptor field"),
AH_PREDEF ("_HID", "Hardware ID", "Returns a device's Plug and Play Hardware ID"),
AH_PREDEF ("_HMA", "Heterogeneous Memory Attributes", "Returns a list of HMAT structures."),
AH_PREDEF ("_HOT", "Hot Temperature", "Returns the critical temperature for sleep (entry to S4)"),
AH_PREDEF ("_HPP", "Hot Plug Parameters", "Returns a list of hot-plug information for a PCI device"),
AH_PREDEF ("_HPX", "Hot Plug Parameter Extensions", "Returns a list of hot-plug information for a PCI device. Supersedes _HPP"),
AH_PREDEF ("_HRV", "Hardware Revision", "Returns a hardware revision value"),
AH_PREDEF ("_IFT", "IPMI Interface Type", "See the Intelligent Platform Management Interface Specification"),
AH_PREDEF ("_INI", "Initialize", "Performs device specific initialization"),
AH_PREDEF ("_INT", "Interrupts", "Interrupt mask bits, Resource Descriptor field"),
AH_PREDEF ("_IOR", "I/O Restriction", "Restriction type, Resource Descriptor field"),
AH_PREDEF ("_IRC", "Inrush Current", "Presence indicates that a device has a significant inrush current draw"),
AH_PREDEF ("_Lxx", "Level-Triggered GPE, xx=0x00-0xFF", "Control method executed as a result of a general-purpose event"),
AH_PREDEF ("_LCK", "Lock Device", "Locks or unlocks a device (docking)"),
AH_PREDEF ("_LEN", "Length", "Range length, Resource Descriptor field"),
AH_PREDEF ("_LID", "Lid Status", "Returns the open/closed status of the lid on a mobile system"),
AH_PREDEF ("_LIN", "Lines In Use", "Handshake lines, Resource Descriptor field"),
AH_PREDEF ("_LL_", "Low Level", "Interrupt polarity, Resource Descriptor field"),
AH_PREDEF ("_LPD", "Low Power Dependencies", "Returns a list of dependencies for low power idle entry"),
AH_PREDEF ("_LPI", "Low Power Idle States", "Returns a list of supported low power idle states"),
AH_PREDEF ("_LSI", "Label Storage Information", "Returns information about the Label Storage Area associated with the NVDIMM object."),
AH_PREDEF ("_LSR", "Label Storage Read", "Returns label data from the Label Storage Area of the NVDIMM object."),
AH_PREDEF ("_LSW", "Label Storage Write", "Writes label data in to the Label Storage Area of the NVDIMM object."),
AH_PREDEF ("_MAF", "Maximum Address Fixed", "Resource Descriptor field"),
AH_PREDEF ("_MAT", "Multiple APIC Table Entry", "Returns a list of MADT APIC structure entries"),
AH_PREDEF ("_MAX", "Maximum Base Address", "Resource Descriptor field"),
AH_PREDEF ("_MBM", "Memory Bandwidth Monitoring Data", "Returns bandwidth monitoring data for a memory device"),
AH_PREDEF ("_MEM", "Memory Attributes", "Resource Descriptor field"),
AH_PREDEF ("_MIF", "Minimum Address Fixed", "Resource Descriptor field"),
AH_PREDEF ("_MIN", "Minimum Base Address", "Resource Descriptor field"),
AH_PREDEF ("_MLS", "Multiple Language String", "Returns a device description in multiple languages"),
AH_PREDEF ("_MOD", "Mode", "Interrupt mode, Resource Descriptor field"),
AH_PREDEF ("_MSG", "Message", "Sets the system message waiting status indicator"),
AH_PREDEF ("_MSM", "Memory Set Monitoring", "Sets bandwidth monitoring parameters for a memory device"),
AH_PREDEF ("_MTL", "Minimum Throttle Limit", "Returns the minimum throttle limit for a thermal zone"),
AH_PREDEF ("_MTP", "Memory Type", "Resource Descriptor field"),
AH_PREDEF ("_NBS", "NVDIMM Boot Status", "Returns information about NVDIMM devices status at boot time"),
AH_PREDEF ("_NCH", "NVDIMM Current Health Information", "Returns current health information of the NVDIMM device"),
AH_PREDEF ("_NIC", "NVDIMM Health Error Injection Capabilities", "Returns health error injection capabilities that are supported by the platform"),
AH_PREDEF ("_NIG", "NVDIMM Inject Health Error Status","Returns currently active health errors and their error attributes that are injected by _NIH"),
AH_PREDEF ("_NIH", "NVDIMM Inject/Clear Health Errors", "Returns the status of injecting or clearing Health Errors"),
AH_PREDEF ("_NTT", "Notification Temperature Threshold", "Returns a threshold for device temperature change that requires platform notification"),
AH_PREDEF ("_OFF", "Power Off", "Sets a power resource to the off state"),
AH_PREDEF ("_ON_", "Power On", "Sets a power resource to the on state"),
AH_PREDEF ("_OS_", "Operating System", "Returns a string that identifies the operating system"),
AH_PREDEF ("_OSC", "Operating System Capabilities", "Inform AML of host features and capabilities"),
AH_PREDEF ("_OSI", "Operating System Interfaces", "Returns supported interfaces, behaviors, and features"),
AH_PREDEF ("_OST", "OSPM Status Indication", "Inform AML of event processing status"),
AH_PREDEF ("_PAI", "Power Averaging Interval", "Sets the averaging interval for a power meter"),
AH_PREDEF ("_PAR", "Parity", "Parity bits, Resource Descriptor field"),
AH_PREDEF ("_PCL", "Power Consumer List", "Returns a list of devices powered by a power source"),
AH_PREDEF ("_PCT", "Performance Control", "Returns processor performance control and status registers"),
AH_PREDEF ("_PDC", "Processor Driver Capabilities", "Inform AML of processor driver capabilities"),
AH_PREDEF ("_PDL", "P-state Depth Limit", "Returns the lowest available performance P-state"),
AH_PREDEF ("_PHA", "Clock Phase", "Clock phase, Resource Descriptor field"),
AH_PREDEF ("_PIC", "Interrupt Model", "Inform AML of the interrupt model in use"),
AH_PREDEF ("_PIF", "Power Source Information", "Returns a Power Source information block"),
AH_PREDEF ("_PIN", "Pin List", "Pin list, Resource Descriptor field"),
AH_PREDEF ("_PLD", "Physical Location of Device", "Returns a device's physical location information"),
AH_PREDEF ("_PMC", "Power Meter Capabilities", "Returns a list of Power Meter capabilities info"),
AH_PREDEF ("_PMD", "Power Metered Devices", "Returns a list of devices that are measured by the power meter device"),
AH_PREDEF ("_PMM", "Power Meter Measurement", "Returns the current value of the Power Meter"),
AH_PREDEF ("_POL", "Polarity", "Interrupt polarity, Resource Descriptor field"),
AH_PREDEF ("_PPC", "Performance Present Capabilities", "Returns a list of the performance states currently supported by the platform"),
AH_PREDEF ("_PPE", "Polling for Platform Error", "Returns the polling interval to retrieve Corrected Platform Error information"),
AH_PREDEF ("_PPI", "Pin Configuration", "Resource Descriptor field"),
AH_PREDEF ("_PR", "Processor", "Predefined scope for processor objects"),
AH_PREDEF ("_PR0", "Power Resources for D0", "Returns a list of dependent power resources to enter state D0 (fully on)"),
AH_PREDEF ("_PR1", "Power Resources for D1", "Returns a list of dependent power resources to enter state D1"),
AH_PREDEF ("_PR2", "Power Resources for D2", "Returns a list of dependent power resources to enter state D2"),
AH_PREDEF ("_PR3", "Power Resources for D3hot", "Returns a list of dependent power resources to enter state D3hot"),
AH_PREDEF ("_PRE", "Power Resources for Enumeration", "Returns a list of dependent power resources to enumerate devices on a bus"),
AH_PREDEF ("_PRL", "Power Source Redundancy List", "Returns a list of power source devices in the same redundancy grouping"),
AH_PREDEF ("_PRR", "Power Resource for Reset", "Execute a reset on a device"),
AH_PREDEF ("_PRS", "Possible Resource Settings", "Returns a list of a device's possible resource settings"),
AH_PREDEF ("_PRT", "PCI Routing Table", "Returns a list of PCI interrupt mappings"),
AH_PREDEF ("_PRW", "Power Resources for Wake", "Returns a list of dependent power resources for waking"),
AH_PREDEF ("_PS0", "Power State 0", "Sets a device's power state to D0 (device fully on)"),
AH_PREDEF ("_PS1", "Power State 1", "Sets a device's power state to D1"),
AH_PREDEF ("_PS2", "Power State 2", "Sets a device's power state to D2"),
AH_PREDEF ("_PS3", "Power State 3", "Sets a device's power state to D3 (device off)"),
AH_PREDEF ("_PSC", "Power State Current", "Returns a device's current power state"),
AH_PREDEF ("_PSD", "Power State Dependencies", "Returns processor P-State dependencies"),
AH_PREDEF ("_PSE", "Power State for Enumeration", "Put a bus into enumeration power mode"),
AH_PREDEF ("_PSL", "Passive List", "Returns a list of passive cooling device objects"),
AH_PREDEF ("_PSR", "Power Source", "Returns the power source device currently in use"),
AH_PREDEF ("_PSS", "Performance Supported States", "Returns a list of supported processor performance states"),
AH_PREDEF ("_PSV", "Passive Temperature", "Returns the passive trip point temperature"),
AH_PREDEF ("_PSW", "Power State Wake", "Sets a device's wake function"),
AH_PREDEF ("_PTC", "Processor Throttling Control", "Returns throttling control and status registers"),
AH_PREDEF ("_PTP", "Power Trip Points", "Sets trip points for the Power Meter device"),
AH_PREDEF ("_PTS", "Prepare To Sleep", "Inform the platform of an impending sleep transition"),
AH_PREDEF ("_PUR", "Processor Utilization Request", "Returns the number of processors that the platform would like to idle"),
AH_PREDEF ("_PXM", "Device Proximity", "Returns a device's proximity domain identifier"),
AH_PREDEF ("_Qxx", "EC Query, xx=0x00-0xFF", "Embedded Controller query and SMBus Alarm control method"),
AH_PREDEF ("_RBO", "Register Bit Offset", "Resource Descriptor field"),
AH_PREDEF ("_RBW", "Register Bit Width", "Resource Descriptor field"),
AH_PREDEF ("_RDI", "Resource Dependencies for Idle", "Returns a list of dependencies for idle states"),
AH_PREDEF ("_REG", "Region Availability", "Inform AML code of an operation region availability change"),
AH_PREDEF ("_REV", "Supported Integer Width", "Returns the supported integer width (<= 1: 32 bits only, >=2: both 32 and 64 bits"),
AH_PREDEF ("_RMV", "Removal Status", "Returns a device's removal ability status (docking)"),
AH_PREDEF ("_RNG", "Range", "Memory range type, Resource Descriptor field"),
AH_PREDEF ("_RST", "Device Reset", "Executes a reset on a device"),
AH_PREDEF ("_ROM", "Read-Only Memory", "Returns a copy of the ROM data for a display device"),
AH_PREDEF ("_RT_", "Resource Type", "Resource Descriptor field"),
AH_PREDEF ("_RTV", "Relative Temperature Values", "Returns temperature value information"),
AH_PREDEF ("_RW_", "Read-Write Status", "Resource Descriptor field"),
AH_PREDEF ("_RXL", "Receive Buffer Size", "Serial channel buffer, Resource Descriptor field"),
AH_PREDEF ("_S0_", "S0 System State", "Returns values to enter the system into the S0 state"),
AH_PREDEF ("_S1_", "S1 System State", "Returns values to enter the system into the S1 state"),
AH_PREDEF ("_S2_", "S2 System State", "Returns values to enter the system into the S2 state"),
AH_PREDEF ("_S3_", "S3 System State", "Returns values to enter the system into the S3 state"),
AH_PREDEF ("_S4_", "S4 System State", "Returns values to enter the system into the S4 state"),
AH_PREDEF ("_S5_", "S5 System State", "Returns values to enter the system into the S5 state"),
AH_PREDEF ("_S1D", "S1 Device State", "Returns the highest D-state supported by a device when in the S1 state"),
AH_PREDEF ("_S2D", "S2 Device State", "Returns the highest D-state supported by a device when in the S2 state"),
AH_PREDEF ("_S3D", "S3 Device State", "Returns the highest D-state supported by a device when in the S3 state"),
AH_PREDEF ("_S4D", "S4 Device State", "Returns the highest D-state supported by a device when in the S4 state"),
AH_PREDEF ("_S0W", "S0 Device Wake State", "Returns the lowest D-state that the device can wake itself from S0"),
AH_PREDEF ("_S1W", "S1 Device Wake State", "Returns the lowest D-state for this device that can wake the system from S1"),
AH_PREDEF ("_S2W", "S2 Device Wake State", "Returns the lowest D-state for this device that can wake the system from S2"),
AH_PREDEF ("_S3W", "S3 Device Wake State", "Returns the lowest D-state for this device that can wake the system from S3"),
AH_PREDEF ("_S4W", "S4 Device Wake State", "Returns the lowest D-state for this device that can wake the system from S4"),
AH_PREDEF ("_SB_", "System Bus", "Predefined scope for device and bus objects"),
AH_PREDEF ("_SBA", "SM Bus Alert information", "Returns info on an SMBus alert"),
AH_PREDEF ("_SBI", "SM Bus General information", "Returns info on an SMBus segment"),
AH_PREDEF ("_SBR", "SM Bus Data read", "Reads Byte, Word, or Block data from an SMBus segment"),
AH_PREDEF ("_SBT", "SM Bus Data transfer", "Performs data transfer to/from an SMBus segment. Implements ProcessCall protocol"),
AH_PREDEF ("_SBW", "SM Bus Data write", "Writes Byte, Word, or Block data to an SMBus segment"),
AH_PREDEF ("_SBS", "Smart Battery Subsystem", "Returns the subsystem configuration"),
AH_PREDEF ("_SCP", "Set Cooling Policy", "Sets the cooling policy (active or passive)"),
AH_PREDEF ("_SDD", "Set Device Data", "Sets data for a SATA device"),
AH_PREDEF ("_SEG", "PCI Segment", "Returns a device's PCI Segment Group number"),
AH_PREDEF ("_SHL", "Set Hardware Limit", "Sets the hardware limit enforced by the Power Meter"),
AH_PREDEF ("_SHR", "Shareable", "Interrupt share status, Resource Descriptor field"),
AH_PREDEF ("_SI_", "System Indicators", "Predefined scope"),
AH_PREDEF ("_SIZ", "Size", "DMA transfer size, Resource Descriptor field"),
AH_PREDEF ("_SLI", "System Locality Information", "Returns a list of NUMA system localities"),
AH_PREDEF ("_SLV", "Slave Mode", "Mode setting, Resource Descriptor field"),
AH_PREDEF ("_SPD", "Set Post Device", "Sets which video device will be posted at boot"),
AH_PREDEF ("_SPE", "Speed", "Connection speed, Resource Descriptor field"),
AH_PREDEF ("_SRS", "Set Resource Settings", "Sets a device's resource allocation"),
AH_PREDEF ("_SRT", "Set Real Time", "Sets the current time for a time/alarm device"),
AH_PREDEF ("_SRV", "IPMI Spec Revision", "See the Intelligent Platform Management Interface Specification"),
AH_PREDEF ("_SST", "System Status", "Sets the system status indicator"),
AH_PREDEF ("_STA", "Status", "Returns the current status of a Device or Power Resource"),
AH_PREDEF ("_STB", "Stop Bits", "Serial channel stop bits, Resource Descriptor field"),
AH_PREDEF ("_STM", "Set Timing Mode", "Sets an IDE controller transfer timings"),
AH_PREDEF ("_STP", "Set Expired Timer Wake Policy", "Sets expired timer policies of the wake alarm device"),
AH_PREDEF ("_STR", "Description String", "Returns a device's description string"),
AH_PREDEF ("_STV", "Set Timer Value", "Set timer values of the wake alarm device"),
AH_PREDEF ("_SUB", "Subsystem ID", "Returns the subsystem ID for a device"),
AH_PREDEF ("_SUN", "Slot User Number", "Returns the slot unique ID number"),
AH_PREDEF ("_SWS", "System Wake Source", "Returns the source event that caused the system to wake"),
AH_PREDEF ("_T_x", "Emitted by ASL Compiler, x=0-9, A-Z", "Reserved for use by ASL compilers"),
AH_PREDEF ("_TC1", "Thermal Constant 1", "Returns TC1 for the passive cooling formula"),
AH_PREDEF ("_TC2", "Thermal Constant 2", "Returns TC2 for the passive cooling formula"),
AH_PREDEF ("_TDL", "T-State Depth Limit", "Returns the _TSS entry number of the lowest power throttling state"),
AH_PREDEF ("_TFP", "Thermal Fast Sampling Period", "Returns the sampling period for passive cooling"),
AH_PREDEF ("_TIP", "Expired Timer Wake Policy", "Returns timer policies of the wake alarm device"),
AH_PREDEF ("_TIV", "Timer Values", "Returns remaining time of the wake alarm device"),
AH_PREDEF ("_TMP", "Temperature", "Returns a thermal zone's current temperature"),
AH_PREDEF ("_TPC", "Throttling Present Capabilities", "Returns the current number of supported throttling states"),
AH_PREDEF ("_TPT", "Trip Point Temperature", "Inform AML that a device's embedded temperature sensor has crossed a temperature trip point"),
AH_PREDEF ("_TRA", "Translation", "Address translation offset, Resource Descriptor field"),
AH_PREDEF ("_TRS", "Translation Sparse", "Sparse/dense flag, Resource Descriptor field"),
AH_PREDEF ("_TRT", "Thermal Relationship Table", "Returns thermal relationships between platform devices"),
AH_PREDEF ("_TSD", "Throttling State Dependencies", "Returns a list of T-state dependencies"),
AH_PREDEF ("_TSF", "Type-Specific Flags", "Resource Descriptor field"),
AH_PREDEF ("_TSN", "Thermal Sensor Device", "Returns a reference to a thermal sensor"),
AH_PREDEF ("_TSP", "Thermal Sampling Period", "Returns the thermal sampling period for passive cooling"),
AH_PREDEF ("_TSS", "Throttling Supported States", "Returns supported throttling state information"),
AH_PREDEF ("_TST", "Temperature Sensor Threshold", "Returns the minimum separation for a device's temperature trip points"),
AH_PREDEF ("_TTP", "Translation Type", "Translation/static flag, Resource Descriptor field"),
AH_PREDEF ("_TTS", "Transition To State", "Inform AML of an S-state transition"),
AH_PREDEF ("_TXL", "Transmit Buffer Size", "Serial Channel buffer, Resource Descriptor field"),
AH_PREDEF ("_TYP", "Type", "DMA channel type (speed), Resource Descriptor field"),
AH_PREDEF ("_TZ_", "Thermal Zone", "Predefined scope: ACPI 1.0"),
AH_PREDEF ("_TZD", "Thermal Zone Devices", "Returns a list of device names associated with a Thermal Zone"),
AH_PREDEF ("_TZM", "Thermal Zone Member", "Returns a reference to the thermal zone of which a device is a member"),
AH_PREDEF ("_TZP", "Thermal Zone Polling", "Returns a Thermal zone's polling frequency"),
AH_PREDEF ("_UID", "Unique ID", "Return a device's unique persistent ID"),
AH_PREDEF ("_UPC", "USB Port Capabilities", "Returns a list of USB port capabilities"),
AH_PREDEF ("_UPD", "User Presence Detect", "Returns user detection information"),
AH_PREDEF ("_UPP", "User Presence Polling", "Returns the recommended user presence polling interval"),
AH_PREDEF ("_VAL", "Pin Configuration Value", "Resource Descriptor field"),
AH_PREDEF ("_VEN", "Vendor Data", "Resource Descriptor field"),
AH_PREDEF ("_VPO", "Video Post Options", "Returns the implemented video post options"),
AH_PREDEF ("_Wxx", "Wake Event, xx=0x00-0xFF", "Method executed as a result of a wake event"),
AH_PREDEF ("_WAK", "Wake", "Inform AML that the system has just awakened"),
AH_PREDEF ("_WPC", "Wireless Power Calibration", "Calibrate power and notify wireless device"),
AH_PREDEF ("_WPP", "Wireless Power Polling", "Get recommended polling interval"),
AH_PREDEF (NULL, NULL, NULL)
};
/*******************************************************************************
*
* FUNCTION: AcpiAhMatchPredefinedName
*
* PARAMETERS: Nameseg - Predefined name string
*
* RETURN: ID info struct. NULL if Nameseg not found
*
* DESCRIPTION: Lookup a predefined name.
*
******************************************************************************/
const AH_PREDEFINED_NAME *
AcpiAhMatchPredefinedName (
char *Nameseg)
{
const AH_PREDEFINED_NAME *Info;
/* Nameseg must start with an underscore */
if (*Nameseg != '_')
{
return (NULL);
}
/* Search for a match in the predefined name table */
for (Info = AslPredefinedInfo; Info->Name; Info++)
{
if (ACPI_COMPARE_NAMESEG (Nameseg, Info->Name))
{
return (Info);
}
}
return (NULL);
}

View File

@@ -0,0 +1,282 @@
/******************************************************************************
*
* Module Name: ahtable - Table of known ACPI tables with descriptions
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "acpi.h"
#include "accommon.h"
/* Local prototypes */
const AH_TABLE *
AcpiAhGetTableInfo (
char *Signature);
extern const AH_TABLE AcpiGbl_SupportedTables[];
/*******************************************************************************
*
* FUNCTION: AcpiAhGetTableInfo
*
* PARAMETERS: Signature - ACPI signature (4 chars) to match
*
* RETURN: Pointer to a valid AH_TABLE. Null if no match found.
*
* DESCRIPTION: Find a match in the "help" table of supported ACPI tables
*
******************************************************************************/
const AH_TABLE *
AcpiAhGetTableInfo (
char *Signature)
{
const AH_TABLE *Info;
for (Info = AcpiGbl_SupportedTables; Info->Signature; Info++)
{
if (ACPI_COMPARE_NAMESEG (Signature, Info->Signature))
{
return (Info);
}
}
return (NULL);
}
/*
* Note: Any tables added here should be duplicated within AcpiDmTableData
* in the file common/dmtable.c
*/
const AH_TABLE AcpiGbl_SupportedTables[] =
{
{ACPI_SIG_AEST, "Arm Error Source Table"},
{ACPI_SIG_AGDI, "Arm Generic Diagnostic Dump and Reset Device Interface Table"},
{ACPI_SIG_ASF, "Alert Standard Format Table"},
{ACPI_SIG_ASPT, "AMD Secure Processor Table"},
{ACPI_SIG_BDAT, "BIOS Data ACPI Table"},
{ACPI_SIG_BERT, "Boot Error Record Table"},
{ACPI_SIG_BGRT, "Boot Graphics Resource Table"},
{ACPI_SIG_BOOT, "Simple Boot Flag Table"},
{ACPI_SIG_CCEL, "CC-Event Log Table"},
{ACPI_SIG_CDAT, "Coherent Device Attribute Table"},
{ACPI_SIG_CEDT, "CXL Early Discovery Table"},
{ACPI_SIG_CPEP, "Corrected Platform Error Polling Table"},
{ACPI_SIG_CSRT, "Core System Resource Table"},
{ACPI_SIG_DBG2, "Debug Port Table type 2"},
{ACPI_SIG_DBGP, "Debug Port Table"},
{ACPI_SIG_DMAR, "DMA Remapping Table"},
{ACPI_SIG_DRTM, "Dynamic Root of Trust for Measurement Table"},
{ACPI_SIG_DSDT, "Differentiated System Description Table (AML table)"},
{ACPI_SIG_ECDT, "Embedded Controller Boot Resources Table"},
{ACPI_SIG_EINJ, "Error Injection Table"},
{ACPI_SIG_ERDT, "Enhanced Resource Director Technology Table"},
{ACPI_SIG_ERST, "Error Record Serialization Table"},
{ACPI_SIG_FACS, "Firmware ACPI Control Structure"},
{ACPI_SIG_FADT, "Fixed ACPI Description Table (FADT)"},
{ACPI_SIG_FPDT, "Firmware Performance Data Table"},
{ACPI_SIG_GTDT, "Generic Timer Description Table"},
{ACPI_SIG_HEST, "Hardware Error Source Table"},
{ACPI_SIG_HMAT, "Heterogeneous Memory Attributes Table"},
{ACPI_SIG_HPET, "High Precision Event Timer Table"},
{ACPI_SIG_IORT, "IO Remapping Table"},
{ACPI_SIG_IVRS, "I/O Virtualization Reporting Structure"},
{ACPI_SIG_LPIT, "Low Power Idle Table"},
{ACPI_SIG_MADT, "Multiple APIC Description Table (MADT)"},
{ACPI_SIG_MCFG, "Memory Mapped Configuration Table"},
{ACPI_SIG_MCHI, "Management Controller Host Interface Table"},
{ACPI_SIG_MPAM, "Memory System Resource Partitioning and Monitoring Table"},
{ACPI_SIG_MPST, "Memory Power State Table"},
{ACPI_SIG_MRRM, "Memory Range and Region Mapping Table"},
{ACPI_SIG_MSCT, "Maximum System Characteristics Table"},
{ACPI_SIG_MSDM, "Microsoft Data Management Table"},
{ACPI_SIG_NFIT, "NVDIMM Firmware Interface Table"},
{ACPI_SIG_NHLT, "Non HD Audio Link Table"},
{ACPI_SIG_PCCT, "Platform Communications Channel Table"},
{ACPI_SIG_PDTT, "Platform Debug Trigger Table"},
{ACPI_SIG_PHAT, "Platform Health Assessment Table"},
{ACPI_SIG_PMTT, "Platform Memory Topology Table"},
{ACPI_SIG_PPTT, "Processor Properties Topology Table"},
{ACPI_SIG_PRMT, "Platform Runtime Mechanism Table"},
{ACPI_SIG_RASF, "RAS Features Table"},
{ACPI_SIG_RAS2, "RAS2 Features Table"},
{ACPI_SIG_RHCT, "RISC-V Hart Capabilities Table"},
{ACPI_SIG_RGRT, "Regulatory Graphics Resource Table"},
{ACPI_RSDP_NAME,"Root System Description Pointer"},
{ACPI_SIG_RSDT, "Root System Description Table"},
{ACPI_SIG_S3PT, "S3 Performance Table"},
{ACPI_SIG_SBST, "Smart Battery Specification Table"},
{ACPI_SIG_SDEI, "Software Delegated Exception Interface Table"},
{ACPI_SIG_SDEV, "Secure Devices Table"},
{ACPI_SIG_SLIC, "Software Licensing Description Table"},
{ACPI_SIG_SLIT, "System Locality Information Table"},
{ACPI_SIG_SPCR, "Serial Port Console Redirection Table"},
{ACPI_SIG_SPMI, "Server Platform Management Interface Table"},
{ACPI_SIG_SRAT, "System Resource Affinity Table"},
{ACPI_SIG_SSDT, "Secondary System Description Table (AML table)"},
{ACPI_SIG_STAO, "Status Override Table"},
{ACPI_SIG_SVKL, "Storage Volume Key Location Table"},
{ACPI_SIG_TCPA, "Trusted Computing Platform Alliance Table"},
{ACPI_SIG_TDEL, "TD-Event Log Table"},
{ACPI_SIG_TPM2, "Trusted Platform Module hardware interface Table"},
{ACPI_SIG_UEFI, "UEFI Boot Optimization Table"},
{ACPI_SIG_VIOT, "Virtual I/O Translation Table"},
{ACPI_SIG_WAET, "Windows ACPI Emulated Devices Table"},
{ACPI_SIG_WDAT, "Watchdog Action Table"},
{ACPI_SIG_WDDT, "Watchdog Description Table"},
{ACPI_SIG_WDRT, "Watchdog Resource Table"},
{ACPI_SIG_WPBT, "Windows Platform Binary Table"},
{ACPI_SIG_WSMT, "Windows SMM Security Mitigations Table"},
{ACPI_SIG_XENV, "Xen Environment Table"},
{ACPI_SIG_XSDT, "Extended System Description Table"},
{NULL, NULL}
};

View File

@@ -0,0 +1,260 @@
/******************************************************************************
*
* Module Name: ahuuids - Table of known ACPI-related UUIDs
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "acpi.h"
#include "accommon.h"
#include "acuuid.h"
#define _COMPONENT ACPI_UTILITIES
ACPI_MODULE_NAME ("ahuuids")
/*
* Table of "known" (ACPI-related) UUIDs
*/
const AH_UUID Gbl_AcpiUuids[] =
{
{"[Controllers]", NULL},
{"GPIO Controller", UUID_GPIO_CONTROLLER},
{"USB Controller", UUID_USB_CONTROLLER},
{"SATA Controller", UUID_SATA_CONTROLLER},
{"[Devices]", NULL},
{"PCI Host Bridge Device", UUID_PCI_HOST_BRIDGE},
{"HID I2C Device", UUID_I2C_DEVICE},
{"Power Button Device", UUID_POWER_BUTTON},
{"Memory Device", UUID_MEMORY_DEVICE},
{"Generic Buttons Device", UUID_GENERIC_BUTTONS_DEVICE},
{"NVDIMM Root Device", UUID_NVDIMM_ROOT_DEVICE},
{"Control Method Battery", UUID_CONTROL_METHOD_BATTERY},
{"[Interfaces]", NULL},
{"Device Labeling Interface", UUID_DEVICE_LABELING},
{"Physical Presence Interface", UUID_PHYSICAL_PRESENCE},
{"[Non-volatile DIMM and NFIT table]", NULL},
{"NVDIMM Device", UUID_NFIT_DIMM},
{"Volatile Memory Region", UUID_VOLATILE_MEMORY},
{"Persistent Memory Region", UUID_PERSISTENT_MEMORY},
{"NVDIMM Control Region", UUID_CONTROL_REGION},
{"NVDIMM Data Region", UUID_DATA_REGION},
{"Volatile Virtual Disk", UUID_VOLATILE_VIRTUAL_DISK},
{"Volatile Virtual CD", UUID_VOLATILE_VIRTUAL_CD},
{"Persistent Virtual Disk", UUID_PERSISTENT_VIRTUAL_DISK},
{"Persistent Virtual CD", UUID_PERSISTENT_VIRTUAL_CD},
{"Microsoft NVDIMM Command set",UUID_NFIT_DIMM_N_MSFT},
{"HP NDIMM HPE1", UUID_NFIT_DIMM_N_HPE1},
{"HP NDIMM HPE2", UUID_NFIT_DIMM_N_HPE2},
{"Virtual NVDIMM", UUID_NFIT_DIMM_N_HYPERV},
{"[Processor Properties]", NULL},
{"Cache Properties", UUID_CACHE_PROPERTIES},
{"Physical Package Property", UUID_PHYSICAL_PROPERTY},
{"[Miscellaneous]", NULL},
{"Platform-wide Capabilities", UUID_PLATFORM_CAPABILITIES},
{"Dynamic Enumeration", UUID_DYNAMIC_ENUMERATION},
{"Battery Thermal Limit", UUID_BATTERY_THERMAL_LIMIT},
{"Thermal Extensions", UUID_THERMAL_EXTENSIONS},
{"Device Properties for _DSD", UUID_DEVICE_PROPERTIES},
{"Device Graphs for _DSD", UUID_DEVICE_GRAPHS},
{"Hierarchical Data Extension", UUID_HIERARCHICAL_DATA_EXTENSION},
{"ARM Coresight Graph", UUID_CORESIGHT_GRAPH},
{"USB4 Capabilities", UUID_USB4_CAPABILITIES},
{"First Function ID for _DSM", UUID_1ST_FUNCTION_ID},
{"Second Function ID for _DSM", UUID_2ND_FUNCTION_ID},
{NULL, NULL}
};
/*******************************************************************************
*
* FUNCTION: AcpiAhMatchUuid
*
* PARAMETERS: Data - Data buffer containing a UUID
*
* RETURN: ASCII description string for the UUID if it is found.
*
* DESCRIPTION: Returns a description string for "known" UUIDs, which are
* are UUIDs that are related to ACPI in some way.
*
******************************************************************************/
const char *
AcpiAhMatchUuid (
UINT8 *Data)
{
const AH_UUID *Info;
UINT8 UuidBuffer[UUID_BUFFER_LENGTH];
/* Walk the table of known ACPI-related UUIDs */
for (Info = Gbl_AcpiUuids; Info->Description; Info++)
{
/* Null string means description is a UUID class */
if (!Info->String)
{
continue;
}
AcpiUtConvertStringToUuid (Info->String, UuidBuffer);
if (!memcmp (Data, UuidBuffer, UUID_BUFFER_LENGTH))
{
return (Info->Description);
}
}
return (NULL);
}

View File

@@ -0,0 +1,220 @@
/******************************************************************************
*
* Module Name: cmfsize - Common get file size function
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "acpi.h"
#include "accommon.h"
#include "acapps.h"
#define _COMPONENT ACPI_TOOLS
ACPI_MODULE_NAME ("cmfsize")
/*******************************************************************************
*
* FUNCTION: CmGetFileSize
*
* PARAMETERS: File - Open file descriptor
*
* RETURN: File Size. On error, -1 (ACPI_UINT32_MAX)
*
* DESCRIPTION: Get the size of a file. Uses seek-to-EOF. File must be open.
* Does not disturb the current file pointer.
*
******************************************************************************/
UINT32
CmGetFileSize (
ACPI_FILE File)
{
long FileSize;
long CurrentOffset;
ACPI_STATUS Status;
/* Save the current file pointer, seek to EOF to obtain file size */
CurrentOffset = ftell (File);
if (CurrentOffset < 0)
{
goto OffsetError;
}
Status = fseek (File, 0, SEEK_END);
if (ACPI_FAILURE (Status))
{
goto SeekError;
}
FileSize = ftell (File);
if (FileSize < 0)
{
goto OffsetError;
}
/* Restore original file pointer */
Status = fseek (File, CurrentOffset, SEEK_SET);
if (ACPI_FAILURE (Status))
{
goto SeekError;
}
return ((UINT32) FileSize);
OffsetError:
fprintf (stderr, "Could not get file offset\n");
return (ACPI_UINT32_MAX);
SeekError:
fprintf (stderr, "Could not set file offset\n");
return (ACPI_UINT32_MAX);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,689 @@
/******************************************************************************
*
* Module Name: adwalk - Disassembler routines for switch statements
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "acpi.h"
#include "accommon.h"
#include "acparser.h"
#include "amlcode.h"
#include "acdisasm.h"
#include "acdispat.h"
#include "acnamesp.h"
#include "acapps.h"
#define _COMPONENT ACPI_CA_DISASSEMBLER
ACPI_MODULE_NAME ("dmswitch")
static BOOLEAN
AcpiDmIsSwitchBlock (
ACPI_PARSE_OBJECT *Op,
char **Temp);
static BOOLEAN
AcpiDmIsCaseBlock (
ACPI_PARSE_OBJECT *Op);
/*******************************************************************************
*
* FUNCTION: AcpiDmProcessSwitch
*
* PARAMETERS: Op - Object to be examined
*
* RETURN: ACPI_STATUS
*
* DESCRIPTION: Walk function to create a list of all temporary (_T_) objects.
* If a While loop is found that can be converted to a Switch, do
* the conversion, remove the temporary name from the list, and
* mark the parse op with an IGNORE flag.
*
******************************************************************************/
ACPI_STATUS
AcpiDmProcessSwitch (
ACPI_PARSE_OBJECT *Op)
{
char *Temp = NULL;
ACPI_PARSE_OBJECT_LIST *NewTemp;
ACPI_PARSE_OBJECT_LIST *Current;
ACPI_PARSE_OBJECT_LIST *Previous;
BOOLEAN FoundTemp = FALSE;
switch (Op->Common.AmlOpcode)
{
case AML_NAME_OP:
Temp = (char *) (&Op->Named.Name);
if (!strncmp(Temp, "_T_", 3))
{
/* Allocate and init a new Temp List node */
NewTemp = ACPI_ALLOCATE_ZEROED (sizeof (ACPI_PARSE_OBJECT_LIST));
if (!NewTemp)
{
return (AE_NO_MEMORY);
}
if (AcpiGbl_TempListHead)
{
Current = AcpiGbl_TempListHead;
AcpiGbl_TempListHead = NewTemp;
AcpiGbl_TempListHead->Op = Op;
AcpiGbl_TempListHead->Next = Current;
}
else
{
AcpiGbl_TempListHead = NewTemp;
AcpiGbl_TempListHead->Op = Op;
AcpiGbl_TempListHead->Next = NULL;
}
}
break;
case AML_WHILE_OP:
if (!AcpiDmIsSwitchBlock (Op, &Temp))
{
break;
}
/* Found a Switch */
Op->Common.DisasmOpcode = ACPI_DASM_SWITCH;
Previous = Current = AcpiGbl_TempListHead;
while (Current)
{
/* Note, if we get here Temp is not NULL */
if (!strncmp(Temp, (char *) (&Current->Op->Named.Name), 4))
{
/* Match found. Ignore disassembly */
Current->Op->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
/* Remove from list */
if (Current == AcpiGbl_TempListHead)
{
AcpiGbl_TempListHead = Current->Next;
}
else
{
Previous->Next = Current->Next;
}
Current->Op = NULL;
Current->Next = NULL;
ACPI_FREE (Current);
FoundTemp = TRUE;
break;
}
Previous = Current;
Current = Current->Next;
}
if (!FoundTemp)
{
fprintf (stderr,
"Warning: Declaration for temp name %.4s not found\n", Temp);
}
break;
default:
break;
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AcpiDmClearTempList
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Removes any remaining temporary objects from global list and
* frees
*
******************************************************************************/
void
AcpiDmClearTempList (
void)
{
ACPI_PARSE_OBJECT_LIST *Current;
while (AcpiGbl_TempListHead)
{
Current = AcpiGbl_TempListHead;
AcpiGbl_TempListHead = AcpiGbl_TempListHead->Next;
Current->Op = NULL;
Current->Next = NULL;
ACPI_FREE (Current);
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDmIsSwitchBlock
*
* PARAMETERS: Op - While Object
* Temp - Where the compiler temp name is returned
* (_T_x)
*
* RETURN: TRUE if While block can be converted to a Switch/Case block
*
* DESCRIPTION: Determines if While block is a Switch/Case statement. Modifies
* parse tree to allow for Switch/Case disassembly during walk.
*
* EXAMPLE: Example of parse tree to be converted
*
* While
* One
* Store
* ByteConst
* -NamePath-
* If
* LEqual
* -NamePath-
* Zero
* Return
* One
* Else
* Return
* WordConst
* Break
*
******************************************************************************/
BOOLEAN
AcpiDmIsSwitchBlock (
ACPI_PARSE_OBJECT *Op,
char **Temp)
{
ACPI_PARSE_OBJECT *OneOp;
ACPI_PARSE_OBJECT *StoreOp;
ACPI_PARSE_OBJECT *NamePathOp;
ACPI_PARSE_OBJECT *PredicateOp;
ACPI_PARSE_OBJECT *CurrentOp;
ACPI_PARSE_OBJECT *TempOp;
/* Check for One Op Predicate */
OneOp = AcpiPsGetArg (Op, 0);
if (!OneOp || (OneOp->Common.AmlOpcode != AML_ONE_OP))
{
return (FALSE);
}
/* Check for Store Op */
StoreOp = OneOp->Common.Next;
if (!StoreOp || (StoreOp->Common.AmlOpcode != AML_STORE_OP))
{
return (FALSE);
}
/* Check for Name Op with _T_ string */
NamePathOp = AcpiPsGetArg (StoreOp, 1);
if (!NamePathOp ||
(NamePathOp->Common.AmlOpcode != AML_INT_NAMEPATH_OP))
{
return (FALSE);
}
if (strncmp ((char *) (NamePathOp->Common.Value.Name), "_T_", 3))
{
return (FALSE);
}
*Temp = (char *) (NamePathOp->Common.Value.Name);
/* This is a Switch/Case control block */
/* Ignore the One Op Predicate */
OneOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
/* Ignore the Store Op, but not the children */
StoreOp->Common.DisasmOpcode = ACPI_DASM_IGNORE_SINGLE;
/*
* First arg of Store Op is the Switch condition.
* Mark it as a Switch predicate and as a parameter list for paren
* closing and correct indentation.
*/
PredicateOp = AcpiPsGetArg (StoreOp, 0);
PredicateOp->Common.DisasmOpcode = ACPI_DASM_SWITCH_PREDICATE;
PredicateOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
/* Ignore the Name Op */
NamePathOp->Common.DisasmFlags = ACPI_PARSEOP_IGNORE;
/* Remaining opcodes are the Case statements (If/ElseIf's) */
CurrentOp = StoreOp->Common.Next;
while (AcpiDmIsCaseBlock (CurrentOp))
{
/* Block is a Case structure */
if (CurrentOp->Common.AmlOpcode == AML_ELSE_OP)
{
/* ElseIf */
CurrentOp->Common.DisasmOpcode = ACPI_DASM_CASE;
CurrentOp = AcpiPsGetArg (CurrentOp, 0);
}
/* If */
CurrentOp->Common.DisasmOpcode = ACPI_DASM_CASE;
/*
* Mark the parse tree for Case disassembly. There are two
* types of Case statements. The first type of statement begins with
* an LEqual. The second starts with an LNot and uses a Match statement
* on a Package of constants.
*/
TempOp = AcpiPsGetArg (CurrentOp, 0);
switch (TempOp->Common.AmlOpcode)
{
case (AML_LOGICAL_EQUAL_OP):
/* Ignore just the LEqual Op */
TempOp->Common.DisasmOpcode = ACPI_DASM_IGNORE_SINGLE;
/* Ignore the NamePath Op */
TempOp = AcpiPsGetArg (TempOp, 0);
TempOp->Common.DisasmFlags = ACPI_PARSEOP_IGNORE;
/*
* Second arg of LEqual will be the Case predicate.
* Mark it as a predicate and also as a parameter list for paren
* closing and correct indentation.
*/
PredicateOp = TempOp->Common.Next;
PredicateOp->Common.DisasmOpcode = ACPI_DASM_SWITCH_PREDICATE;
PredicateOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
break;
case (AML_LOGICAL_NOT_OP):
/*
* The Package will be the predicate of the Case statement.
* It's under:
* LNOT
* LEQUAL
* MATCH
* PACKAGE
*/
/* Get the LEqual Op from LNot */
TempOp = AcpiPsGetArg (TempOp, 0);
/* Get the Match Op from LEqual */
TempOp = AcpiPsGetArg (TempOp, 0);
/* Get the Package Op from Match */
PredicateOp = AcpiPsGetArg (TempOp, 0);
/* Mark as parameter list for paren closing */
PredicateOp->Common.DisasmFlags |= ACPI_PARSEOP_PARAMETER_LIST;
/*
* The Package list would be too deeply indented if we
* chose to simply ignore the all the parent opcodes, so
* we rearrange the parse tree instead.
*/
/*
* Save the second arg of the If/Else Op which is the
* block code of code for this Case statement.
*/
TempOp = AcpiPsGetArg (CurrentOp, 1);
/*
* Move the Package Op to the child (predicate) of the
* Case statement.
*/
CurrentOp->Common.Value.Arg = PredicateOp;
PredicateOp->Common.Parent = CurrentOp;
/* Add the block code */
PredicateOp->Common.Next = TempOp;
break;
default:
/* Should never get here */
break;
}
/* Advance to next Case block */
CurrentOp = CurrentOp->Common.Next;
}
/* If CurrentOp is now an Else, then this is a Default block */
if (CurrentOp && CurrentOp->Common.AmlOpcode == AML_ELSE_OP)
{
CurrentOp->Common.DisasmOpcode = ACPI_DASM_DEFAULT;
}
/*
* From the first If advance to the Break op. It's possible to
* have an Else (Default) op here when there is only one Case
* statement, so check for it.
*/
CurrentOp = StoreOp->Common.Next->Common.Next;
if (!CurrentOp)
{
return (FALSE);
}
if (CurrentOp->Common.AmlOpcode == AML_ELSE_OP)
{
CurrentOp = CurrentOp->Common.Next;
if (!CurrentOp)
{
return (FALSE);
}
}
/* Ignore the Break Op */
CurrentOp->Common.DisasmFlags |= ACPI_PARSEOP_IGNORE;
return (TRUE);
}
/*******************************************************************************
*
* FUNCTION: AcpiDmIsCaseBlock
*
* PARAMETERS: Op - Object to test
*
* RETURN: TRUE if Object is beginning of a Case block.
*
* DESCRIPTION: Determines if an Object is the beginning of a Case block for a
* Switch/Case statement. Parse tree must be one of the following
* forms:
*
* Else (Optional)
* If
* LEqual
* -NamePath- _T_x
*
* Else (Optional)
* If
* LNot
* LEqual
* Match
* Package
* ByteConst
* -NamePath- _T_x
*
******************************************************************************/
static BOOLEAN
AcpiDmIsCaseBlock (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *CurrentOp;
if (!Op)
{
return (FALSE);
}
/* Look for an If or ElseIf */
CurrentOp = Op;
if (CurrentOp->Common.AmlOpcode == AML_ELSE_OP)
{
CurrentOp = AcpiPsGetArg (CurrentOp, 0);
if (!CurrentOp)
{
return (FALSE);
}
}
if (!CurrentOp || CurrentOp->Common.AmlOpcode != AML_IF_OP)
{
return (FALSE);
}
/* Child must be LEqual or LNot */
CurrentOp = AcpiPsGetArg (CurrentOp, 0);
if (!CurrentOp)
{
return (FALSE);
}
switch (CurrentOp->Common.AmlOpcode)
{
case (AML_LOGICAL_EQUAL_OP):
/* Next child must be NamePath with string _T_ */
CurrentOp = AcpiPsGetArg (CurrentOp, 0);
if (!CurrentOp || !CurrentOp->Common.Value.Name ||
strncmp(CurrentOp->Common.Value.Name, "_T_", 3))
{
return (FALSE);
}
break;
case (AML_LOGICAL_NOT_OP):
/* Child of LNot must be LEqual op */
CurrentOp = AcpiPsGetArg (CurrentOp, 0);
if (!CurrentOp || (CurrentOp->Common.AmlOpcode != AML_LOGICAL_EQUAL_OP))
{
return (FALSE);
}
/* Child of LNot must be Match op */
CurrentOp = AcpiPsGetArg (CurrentOp, 0);
if (!CurrentOp || (CurrentOp->Common.AmlOpcode != AML_MATCH_OP))
{
return (FALSE);
}
/* First child of Match must be Package op */
CurrentOp = AcpiPsGetArg (CurrentOp, 0);
if (!CurrentOp || (CurrentOp->Common.AmlOpcode != AML_PACKAGE_OP))
{
return (FALSE);
}
/* Third child of Match must be NamePath with string _T_ */
CurrentOp = AcpiPsGetArg (CurrentOp->Common.Parent, 2);
if (!CurrentOp || !CurrentOp->Common.Value.Name ||
strncmp(CurrentOp->Common.Value.Name, "_T_", 3))
{
return (FALSE);
}
break;
default:
return (FALSE);
}
return (TRUE);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,619 @@
/******************************************************************************
*
* Module Name: dmtables - disassembler ACPI table support
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "acdispat.h"
#include "acnamesp.h"
#include "actables.h"
#include "acparser.h"
#include "acapps.h"
#include "acmacros.h"
#include "acconvert.h"
#define _COMPONENT ACPI_TOOLS
ACPI_MODULE_NAME ("dmtables")
/* Local prototypes */
static void
AdCreateTableHeader (
char *Filename,
ACPI_TABLE_HEADER *Table);
static ACPI_STATUS
AdStoreTable (
ACPI_TABLE_HEADER *Table,
UINT32 *TableIndex);
extern ACPI_TABLE_DESC LocalTables[1];
extern ACPI_PARSE_OBJECT *AcpiGbl_ParseOpRoot;
/******************************************************************************
*
* FUNCTION: AdDisassemblerHeader
*
* PARAMETERS: Filename - Input file for the table
* TableType - Either AML or DataTable
*
* RETURN: None
*
* DESCRIPTION: Create the disassembler header, including ACPICA signon with
* optional current time and date.
*
*****************************************************************************/
void
AdDisassemblerHeader (
char *Filename,
UINT8 TableType)
{
time_t Timer;
/* Header and input table info */
AcpiOsPrintf ("/*\n");
AcpiOsPrintf (ACPI_COMMON_HEADER (AML_DISASSEMBLER_NAME, " * "));
if (TableType == ACPI_IS_AML_TABLE)
{
if (AcpiGbl_CstyleDisassembly)
{
AcpiOsPrintf (
" * Disassembling to symbolic ASL+ operators\n"
" *\n");
}
else
{
AcpiOsPrintf (
" * Disassembling to non-symbolic legacy ASL operators\n"
" *\n");
}
}
if (AslGbl_Deterministic)
{
AcpiOsPrintf (" * Disassembly of %s\n", Filename);
}
else
{
time (&Timer);
AcpiOsPrintf (" * Disassembly of %s, %s", Filename, ctime (&Timer));
}
AcpiOsPrintf (" *\n");
}
/******************************************************************************
*
* FUNCTION: AdCreateTableHeader
*
* PARAMETERS: Filename - Input file for the table
* Table - Pointer to the raw table
*
* RETURN: None
*
* DESCRIPTION: Create the ASL table header, including ACPICA signon with
* current time and date.
*
*****************************************************************************/
static void
AdCreateTableHeader (
char *Filename,
ACPI_TABLE_HEADER *Table)
{
UINT8 Checksum;
/* Reset globals for External statements */
AcpiGbl_NumExternalMethods = 0;
AcpiGbl_ResolvedExternalMethods = 0;
/*
* Print file header and dump original table header
*/
AdDisassemblerHeader (Filename, ACPI_IS_AML_TABLE);
AcpiOsPrintf (" * Original Table Header:\n");
AcpiOsPrintf (" * Signature \"%4.4s\"\n", Table->Signature);
AcpiOsPrintf (" * Length 0x%8.8X (%u)\n", Table->Length, Table->Length);
/* Print and validate the revision */
AcpiOsPrintf (" * Revision 0x%2.2X", Table->Revision);
switch (Table->Revision)
{
case 0:
AcpiOsPrintf (" **** Invalid Revision");
break;
case 1:
/* Revision of DSDT controls the ACPI integer width */
if (ACPI_COMPARE_NAMESEG (Table->Signature, ACPI_SIG_DSDT))
{
AcpiOsPrintf (" **** 32-bit table (V1), no 64-bit math support");
}
break;
default:
break;
}
/* Print and validate the table checksum */
AcpiOsPrintf ("\n * Checksum 0x%2.2X", Table->Checksum);
Checksum = AcpiUtChecksum (ACPI_CAST_PTR (UINT8, Table), Table->Length);
if (Checksum)
{
AcpiOsPrintf (" **** Incorrect checksum, should be 0x%2.2X",
(UINT8) (Table->Checksum - Checksum));
}
AcpiOsPrintf ("\n");
AcpiOsPrintf (" * OEM ID \"%.6s\"\n", Table->OemId);
AcpiOsPrintf (" * OEM Table ID \"%.8s\"\n", Table->OemTableId);
AcpiOsPrintf (" * OEM Revision 0x%8.8X (%u)\n", Table->OemRevision, Table->OemRevision);
AcpiOsPrintf (" * Compiler ID \"%.4s\"\n", Table->AslCompilerId);
AcpiOsPrintf (" * Compiler Version 0x%8.8X (%u)\n", Table->AslCompilerRevision, Table->AslCompilerRevision);
AcpiOsPrintf (" */\n");
/*
* Print comments that come before this definition block.
*/
if (AcpiGbl_CaptureComments)
{
ASL_CV_PRINT_ONE_COMMENT(AcpiGbl_ParseOpRoot,AML_COMMENT_STANDARD, NULL, 0);
}
/*
* Open the ASL definition block.
*
* Note: the AMLFilename string is left zero-length in order to just let
* the compiler create it when the disassembled file is compiled. This
* makes it easier to rename the disassembled ASL file if needed.
*/
AcpiOsPrintf (
"DefinitionBlock (\"\", \"%4.4s\", %u, \"%.6s\", \"%.8s\", 0x%8.8X)\n",
Table->Signature, Table->Revision,
Table->OemId, Table->OemTableId, Table->OemRevision);
}
/******************************************************************************
*
* FUNCTION: AdDisplayTables
*
* PARAMETERS: Filename - Input file for the table
* Table - Pointer to the raw table
*
* RETURN: Status
*
* DESCRIPTION: Display (disassemble) loaded tables and dump raw tables
*
*****************************************************************************/
ACPI_STATUS
AdDisplayTables (
char *Filename,
ACPI_TABLE_HEADER *Table)
{
if (!AcpiGbl_ParseOpRoot)
{
return (AE_NOT_EXIST);
}
if (!AcpiGbl_DmOpt_Listing)
{
AdCreateTableHeader (Filename, Table);
}
AcpiDmDisassemble (NULL, AcpiGbl_ParseOpRoot, ACPI_UINT32_MAX);
MpEmitMappingInfo ();
if (AcpiGbl_DmOpt_Listing)
{
AcpiOsPrintf ("\n\nTable Header:\n");
AcpiUtDebugDumpBuffer ((UINT8 *) Table, sizeof (ACPI_TABLE_HEADER),
DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
AcpiOsPrintf ("Table Body (Length 0x%X)\n", Table->Length);
AcpiUtDebugDumpBuffer (((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER)),
Table->Length, DB_BYTE_DISPLAY, ACPI_UINT32_MAX);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AdStoreTable
*
* PARAMETERS: Table - Table header
* TableIndex - Where the table index is returned
*
* RETURN: Status and table index.
*
* DESCRIPTION: Add an ACPI table to the global table list
*
******************************************************************************/
static ACPI_STATUS
AdStoreTable (
ACPI_TABLE_HEADER *Table,
UINT32 *TableIndex)
{
ACPI_STATUS Status;
ACPI_TABLE_DESC *TableDesc;
Status = AcpiTbGetNextTableDescriptor (TableIndex, &TableDesc);
if (ACPI_FAILURE (Status))
{
return (Status);
}
/* Initialize added table */
AcpiTbInitTableDescriptor (TableDesc, ACPI_PTR_TO_PHYSADDR (Table),
ACPI_TABLE_ORIGIN_INTERNAL_VIRTUAL, Table);
Status = AcpiTbValidateTable (TableDesc);
return (Status);
}
/******************************************************************************
*
* FUNCTION: AdGetLocalTables
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Get the ACPI tables from either memory or a file
*
*****************************************************************************/
ACPI_STATUS
AdGetLocalTables (
void)
{
ACPI_STATUS Status;
ACPI_TABLE_HEADER TableHeader;
ACPI_TABLE_HEADER *NewTable;
UINT32 TableIndex;
/* Get the DSDT via table override */
ACPI_MOVE_32_TO_32 (TableHeader.Signature, ACPI_SIG_DSDT);
Status = AcpiOsTableOverride (&TableHeader, &NewTable);
if (ACPI_FAILURE (Status) || !NewTable)
{
fprintf (stderr, "Could not obtain DSDT\n");
return (AE_NO_ACPI_TABLES);
}
AdWriteTable (NewTable, NewTable->Length,
ACPI_SIG_DSDT, NewTable->OemTableId);
/* Store DSDT in the Table Manager */
Status = AdStoreTable (NewTable, &TableIndex);
if (ACPI_FAILURE (Status))
{
fprintf (stderr, "Could not store DSDT\n");
return (AE_NO_ACPI_TABLES);
}
return (AE_OK);
}
/******************************************************************************
*
* FUNCTION: AdParseTable
*
* PARAMETERS: Table - Pointer to the raw table
* OwnerId - Returned OwnerId of the table
* LoadTable - If add table to the global table list
* External - If this is an external table
*
* RETURN: Status
*
* DESCRIPTION: Parse an ACPI AML table
*
*****************************************************************************/
ACPI_STATUS
AdParseTable (
ACPI_TABLE_HEADER *Table,
ACPI_OWNER_ID *OwnerId,
BOOLEAN LoadTable,
BOOLEAN External)
{
ACPI_STATUS Status = AE_OK;
ACPI_WALK_STATE *WalkState;
UINT8 *AmlStart;
UINT32 AmlLength;
UINT32 TableIndex;
if (!Table)
{
return (AE_NOT_EXIST);
}
/* Pass 1: Parse everything except control method bodies */
fprintf (stderr, "Pass 1 parse of [%4.4s]\n", (char *) Table->Signature);
AmlLength = Table->Length - sizeof (ACPI_TABLE_HEADER);
AmlStart = ((UINT8 *) Table + sizeof (ACPI_TABLE_HEADER));
AcpiUtSetIntegerWidth (Table->Revision);
/* Create the root object */
AcpiGbl_ParseOpRoot = AcpiPsCreateScopeOp (AmlStart);
if (!AcpiGbl_ParseOpRoot)
{
return (AE_NO_MEMORY);
}
#ifdef ACPI_ASL_COMPILER
if (AcpiGbl_CaptureComments)
{
AcpiGbl_ParseOpRoot->Common.CvFilename = AcpiGbl_FileTreeRoot->Filename;
}
else
{
AcpiGbl_ParseOpRoot->Common.CvFilename = NULL;
}
#endif
/* Create and initialize a new walk state */
WalkState = AcpiDsCreateWalkState (0, AcpiGbl_ParseOpRoot, NULL, NULL);
if (!WalkState)
{
return (AE_NO_MEMORY);
}
Status = AcpiDsInitAmlWalk (WalkState, AcpiGbl_ParseOpRoot,
NULL, AmlStart, AmlLength, NULL, ACPI_IMODE_LOAD_PASS1);
if (ACPI_FAILURE (Status))
{
return (Status);
}
WalkState->ParseFlags &= ~ACPI_PARSE_DELETE_TREE;
Status = AcpiPsParseAml (WalkState);
if (ACPI_FAILURE (Status))
{
return (Status);
}
/* If LoadTable is FALSE, we are parsing the last loaded table */
TableIndex = AcpiGbl_RootTableList.CurrentTableCount - 1;
/* Pass 2 */
if (LoadTable)
{
Status = AdStoreTable (Table, &TableIndex);
if (ACPI_FAILURE (Status))
{
return (Status);
}
Status = AcpiTbAllocateOwnerId (TableIndex);
if (ACPI_FAILURE (Status))
{
return (Status);
}
if (OwnerId)
{
Status = AcpiTbGetOwnerId (TableIndex, OwnerId);
if (ACPI_FAILURE (Status))
{
return (Status);
}
}
}
fprintf (stderr, "Pass 2 parse of [%4.4s]\n", (char *) Table->Signature);
Status = AcpiNsOneCompleteParse (ACPI_IMODE_LOAD_PASS2, TableIndex, NULL);
if (ACPI_FAILURE (Status))
{
return (Status);
}
/* No need to parse control methods of external table */
if (External)
{
return (AE_OK);
}
/*
* Pass 3: Parse control methods and link their parse trees
* into the main parse tree
*/
fprintf (stderr,
"Parsing Deferred Opcodes (Methods/Buffers/Packages/Regions)\n");
(void) AcpiDmParseDeferredOps (AcpiGbl_ParseOpRoot);
fprintf (stderr, "\n");
/* Process Resource Templates */
AcpiDmFindResources (AcpiGbl_ParseOpRoot);
fprintf (stderr, "Parsing completed\n");
return (AE_OK);
}

View File

@@ -0,0 +1,657 @@
/******************************************************************************
*
* Module Name: dmtbdump - Dump ACPI data tables that contain no AML code
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "acpi.h"
#include "accommon.h"
#include "acdisasm.h"
#include "actables.h"
/* This module used for application-level code only */
#define _COMPONENT ACPI_CA_DISASSEMBLER
ACPI_MODULE_NAME ("dmtbdump")
/* Local prototypes */
static void
AcpiDmValidateFadtLength (
UINT32 Revision,
UINT32 Length);
/*******************************************************************************
*
* FUNCTION: AcpiDmDumpBuffer
*
* PARAMETERS: Table - ACPI Table or subtable
* BufferOffset - Offset of buffer from Table above
* Length - Length of the buffer
* AbsoluteOffset - Offset of buffer in the main ACPI table
* Header - Name of the buffer field (printed on the
* first line only.)
*
* RETURN: None
*
* DESCRIPTION: Format the contents of an arbitrary length data buffer (in the
* disassembler output format.)
*
******************************************************************************/
void
AcpiDmDumpBuffer (
void *Table,
UINT32 BufferOffset,
UINT32 Length,
UINT32 AbsoluteOffset,
char *Header)
{
UINT8 *Buffer;
UINT8 BufChar;
UINT32 i;
UINT32 j;
if (!Length)
{
return;
}
Buffer = ACPI_CAST_PTR (UINT8, Table) + BufferOffset;
i = 0;
while (i < Length)
{
if ((Length > 16) && (i != 0))
{
if ((Length - i) < 16)
AcpiOsPrintf ("\n/* %3.3Xh %4.4u %3u */ ", AbsoluteOffset, AbsoluteOffset, Length - i);
else
AcpiOsPrintf ("\n/* %3.3Xh %4.4u 16 */ ", AbsoluteOffset, AbsoluteOffset);
}
AbsoluteOffset += 16;
/* Emit the raw data bytes*/
for (j = 0; j < 16; j++)
{
if (i + j >= Length)
{
/* Dump fill spaces */
AcpiOsPrintf ("%*s", (48 - (3 * (Length -i))), " ");
break;
}
AcpiOsPrintf ("%.02X ", Buffer[(ACPI_SIZE) i + j]);
}
/* Emit the ASCII equivalent to the raw data bytes */
for (j = 0; j < 16; j++)
{
if (i + j >= Length)
{
AcpiOsPrintf (" */\\\n");
return;
}
/*
* Add comment characters so rest of line is ignored when
* compiled
*/
if (j == 0)
{
AcpiOsPrintf ("/* ");
}
BufChar = Buffer[(ACPI_SIZE) i + j];
if (isprint (BufChar))
{
AcpiOsPrintf ("%c", BufChar);
}
else
{
AcpiOsPrintf (".");
}
}
/* Done with that line. */
/* Close the comment and insert a backslash - line continuation character */
AcpiOsPrintf (" */\\");
i += 16; /* Point to next line */
}
AcpiOsPrintf ("\n");
}
/*******************************************************************************
*
* FUNCTION: AcpiDmDumpUnicode
*
* PARAMETERS: Table - ACPI Table or subtable
* BufferOffset - Offset of buffer from Table above
* ByteLength - Length of the buffer
*
* RETURN: None
*
* DESCRIPTION: Validate and dump the contents of a buffer that contains
* unicode data. The output is a standard ASCII string. If it
* appears that the data is not unicode, the buffer is dumped
* as hex characters.
*
******************************************************************************/
void
AcpiDmDumpUnicode (
void *Table,
UINT32 BufferOffset,
UINT32 ByteLength)
{
UINT8 *Buffer;
UINT32 Length;
UINT32 i;
Buffer = ((UINT8 *) Table) + BufferOffset;
Length = ByteLength - 2; /* Last two bytes are the null terminator */
/* Ensure all low bytes are entirely printable ASCII */
for (i = 0; i < Length; i += 2)
{
if (!isprint (Buffer[i]))
{
goto DumpRawBuffer;
}
}
/* Ensure all high bytes are zero */
for (i = 1; i < Length; i += 2)
{
if (Buffer[i])
{
goto DumpRawBuffer;
}
}
/* Dump the buffer as a normal string */
AcpiOsPrintf ("\"");
for (i = 0; i < Length; i += 2)
{
AcpiOsPrintf ("%c", Buffer[i]);
}
AcpiOsPrintf ("\"\n");
return;
DumpRawBuffer:
AcpiDmDumpBuffer (Table, BufferOffset, ByteLength,
BufferOffset, NULL);
AcpiOsPrintf ("\n");
}
/*******************************************************************************
*
* FUNCTION: AcpiDmDumpRsdp
*
* PARAMETERS: Table - A RSDP
*
* RETURN: Length of the table (there is not always a length field,
* use revision or length if available (ACPI 2.0+))
*
* DESCRIPTION: Format the contents of a RSDP
*
******************************************************************************/
UINT32
AcpiDmDumpRsdp (
ACPI_TABLE_HEADER *Table)
{
ACPI_TABLE_RSDP *Rsdp = ACPI_CAST_PTR (ACPI_TABLE_RSDP, Table);
UINT32 Length = sizeof (ACPI_RSDP_COMMON);
UINT8 Checksum;
ACPI_STATUS Status;
/* Dump the common ACPI 1.0 portion */
Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoRsdp1);
if (ACPI_FAILURE (Status))
{
return (Length);
}
/* Validate the first checksum */
Checksum = AcpiUtGenerateChecksum (Rsdp, sizeof (ACPI_RSDP_COMMON),
Rsdp->Checksum);
if (Checksum != Rsdp->Checksum)
{
AcpiOsPrintf ("/* Incorrect Checksum above, should be 0x%2.2X */\n",
Checksum);
}
/* The RSDP for ACPI 2.0+ contains more data and has a Length field */
if (Rsdp->Revision > 0)
{
Length = Rsdp->Length;
Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoRsdp2);
if (ACPI_FAILURE (Status))
{
return (Length);
}
/* Validate the extended checksum over entire RSDP */
Checksum = AcpiUtGenerateChecksum (Rsdp, sizeof (ACPI_TABLE_RSDP),
Rsdp->ExtendedChecksum);
if (Checksum != Rsdp->ExtendedChecksum)
{
AcpiOsPrintf (
"/* Incorrect Extended Checksum above, should be 0x%2.2X */\n",
Checksum);
}
}
return (Length);
}
/*******************************************************************************
*
* FUNCTION: AcpiDmDumpRsdt
*
* PARAMETERS: Table - A RSDT
*
* RETURN: None
*
* DESCRIPTION: Format the contents of a RSDT
*
******************************************************************************/
void
AcpiDmDumpRsdt (
ACPI_TABLE_HEADER *Table)
{
UINT32 *Array;
UINT32 Entries;
UINT32 Offset;
UINT32 i;
/* Point to start of table pointer array */
Array = ACPI_CAST_PTR (ACPI_TABLE_RSDT, Table)->TableOffsetEntry;
Offset = sizeof (ACPI_TABLE_HEADER);
/* RSDT uses 32-bit pointers */
Entries = (Table->Length - sizeof (ACPI_TABLE_HEADER)) / sizeof (UINT32);
for (i = 0; i < Entries; i++)
{
AcpiDmLineHeader2 (Offset, sizeof (UINT32), "ACPI Table Address", i);
AcpiOsPrintf ("%8.8X\n", Array[i]);
Offset += sizeof (UINT32);
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDmDumpXsdt
*
* PARAMETERS: Table - A XSDT
*
* RETURN: None
*
* DESCRIPTION: Format the contents of a XSDT
*
******************************************************************************/
void
AcpiDmDumpXsdt (
ACPI_TABLE_HEADER *Table)
{
UINT64 *Array;
UINT32 Entries;
UINT32 Offset;
UINT32 i;
/* Point to start of table pointer array */
Array = ACPI_CAST_PTR (ACPI_TABLE_XSDT, Table)->TableOffsetEntry;
Offset = sizeof (ACPI_TABLE_HEADER);
/* XSDT uses 64-bit pointers */
Entries = (Table->Length - sizeof (ACPI_TABLE_HEADER)) / sizeof (UINT64);
for (i = 0; i < Entries; i++)
{
AcpiDmLineHeader2 (Offset, sizeof (UINT64), "ACPI Table Address", i);
AcpiOsPrintf ("%8.8X%8.8X\n", ACPI_FORMAT_UINT64 (Array[i]));
Offset += sizeof (UINT64);
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDmDumpFadt
*
* PARAMETERS: Table - A FADT
*
* RETURN: None
*
* DESCRIPTION: Format the contents of a FADT
*
* NOTE: We cannot depend on the FADT version to indicate the actual
* contents of the FADT because of BIOS bugs. The table length
* is the only reliable indicator.
*
******************************************************************************/
void
AcpiDmDumpFadt (
ACPI_TABLE_HEADER *Table)
{
ACPI_STATUS Status;
/* Always dump the minimum FADT revision 1 fields (ACPI 1.0) */
Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
AcpiDmTableInfoFadt1);
if (ACPI_FAILURE (Status))
{
return;
}
/* Check for FADT revision 2 fields (ACPI 1.0B MS extensions) */
if ((Table->Length > ACPI_FADT_V1_SIZE) &&
(Table->Length <= ACPI_FADT_V2_SIZE))
{
Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
AcpiDmTableInfoFadt2);
if (ACPI_FAILURE (Status))
{
return;
}
}
/* Check for FADT revision 3/4 fields and up (ACPI 2.0+ extended data) */
else if (Table->Length > ACPI_FADT_V2_SIZE)
{
Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
AcpiDmTableInfoFadt3);
if (ACPI_FAILURE (Status))
{
return;
}
/* Check for FADT revision 5 fields and up (ACPI 5.0+) */
if (Table->Length > ACPI_FADT_V3_SIZE)
{
Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
AcpiDmTableInfoFadt5);
if (ACPI_FAILURE (Status))
{
return;
}
}
/* Check for FADT revision 6 fields and up (ACPI 6.0+) */
if (Table->Length > ACPI_FADT_V5_SIZE)
{
Status = AcpiDmDumpTable (Table->Length, 0, Table, 0,
AcpiDmTableInfoFadt6);
if (ACPI_FAILURE (Status))
{
return;
}
}
}
/* Validate various fields in the FADT, including length */
AcpiTbCreateLocalFadt (Table, Table->Length);
/* Validate FADT length against the revision */
AcpiDmValidateFadtLength (Table->Revision, Table->Length);
}
/*******************************************************************************
*
* FUNCTION: AcpiDmValidateFadtLength
*
* PARAMETERS: Revision - FADT revision (Header->Revision)
* Length - FADT length (Header->Length
*
* RETURN: None
*
* DESCRIPTION: Check the FADT revision against the expected table length for
* that revision. Issue a warning if the length is not what was
* expected. This seems to be such a common BIOS bug that the
* FADT revision has been rendered virtually meaningless.
*
******************************************************************************/
static void
AcpiDmValidateFadtLength (
UINT32 Revision,
UINT32 Length)
{
UINT32 ExpectedLength;
switch (Revision)
{
case 0:
AcpiOsPrintf ("// ACPI Warning: Invalid FADT revision: 0\n");
return;
case 1:
ExpectedLength = ACPI_FADT_V1_SIZE;
break;
case 2:
ExpectedLength = ACPI_FADT_V2_SIZE;
break;
case 3:
case 4:
ExpectedLength = ACPI_FADT_V3_SIZE;
break;
case 5:
ExpectedLength = ACPI_FADT_V5_SIZE;
break;
case 6:
ExpectedLength = ACPI_FADT_V6_SIZE;
break;
default:
return;
}
if (Length == ExpectedLength)
{
return;
}
AcpiOsPrintf (
"\n// ACPI Warning: FADT revision %X does not match length: "
"found %X expected %X\n",
Revision, Length, ExpectedLength);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,870 @@
/******************************************************************************
*
* Module Name: dmtbdump3 - Dump ACPI data tables that contain no AML code
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "acpi.h"
#include "accommon.h"
#include "acdisasm.h"
#include "actables.h"
/* This module used for application-level code only */
#define _COMPONENT ACPI_CA_DISASSEMBLER
ACPI_MODULE_NAME ("dmtbdump3")
/*******************************************************************************
*
* FUNCTION: AcpiDmDumpSlic
*
* PARAMETERS: Table - A SLIC table
*
* RETURN: None
*
* DESCRIPTION: Format the contents of a SLIC
*
******************************************************************************/
void
AcpiDmDumpSlic (
ACPI_TABLE_HEADER *Table)
{
(void) AcpiDmDumpTable (Table->Length, sizeof (ACPI_TABLE_HEADER),
(void *) ((UINT8 *)Table + sizeof (*Table)),
Table->Length - sizeof (*Table), AcpiDmTableInfoSlic);
}
/*******************************************************************************
*
* FUNCTION: AcpiDmDumpSlit
*
* PARAMETERS: Table - An SLIT
*
* RETURN: None
*
* DESCRIPTION: Format the contents of a SLIT
*
******************************************************************************/
void
AcpiDmDumpSlit (
ACPI_TABLE_HEADER *Table)
{
ACPI_STATUS Status;
UINT32 Offset;
UINT8 *Row;
UINT32 Localities;
UINT32 i;
UINT32 j;
/* Main table */
Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoSlit);
if (ACPI_FAILURE (Status))
{
return;
}
/* Display the Locality NxN Matrix */
Localities = (UINT32) ACPI_CAST_PTR (ACPI_TABLE_SLIT, Table)->LocalityCount;
Offset = ACPI_OFFSET (ACPI_TABLE_SLIT, Entry[0]);
Row = (UINT8 *) ACPI_CAST_PTR (ACPI_TABLE_SLIT, Table)->Entry;
for (i = 0; i < Localities; i++)
{
/* Display one row of the matrix */
AcpiDmLineHeader2 (Offset, Localities, "Locality", i);
for (j = 0; j < Localities; j++)
{
/* Check for beyond EOT */
if (Offset >= Table->Length)
{
AcpiOsPrintf (
"\n**** Not enough room in table for all localities\n");
return;
}
AcpiOsPrintf ("%2.2X", Row[j]);
Offset++;
/* Display up to 16 bytes per output row */
if ((j+1) < Localities)
{
AcpiOsPrintf (" ");
if (j && (((j+1) % 16) == 0))
{
AcpiOsPrintf ("\\\n"); /* With line continuation char */
AcpiDmLineHeader (Offset, 0, NULL);
}
}
}
/* Point to next row */
AcpiOsPrintf ("\n");
Row += Localities;
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDmDumpSrat
*
* PARAMETERS: Table - A SRAT table
*
* RETURN: None
*
* DESCRIPTION: Format the contents of a SRAT
*
******************************************************************************/
void
AcpiDmDumpSrat (
ACPI_TABLE_HEADER *Table)
{
ACPI_STATUS Status;
UINT32 Offset = sizeof (ACPI_TABLE_SRAT);
ACPI_SUBTABLE_HEADER *Subtable;
ACPI_DMTABLE_INFO *InfoTable;
/* Main table */
Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoSrat);
if (ACPI_FAILURE (Status))
{
return;
}
/* Subtables */
Subtable = ACPI_ADD_PTR (ACPI_SUBTABLE_HEADER, Table, Offset);
while (Offset < Table->Length)
{
/* Common subtable header */
AcpiOsPrintf ("\n");
Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
Subtable->Length, AcpiDmTableInfoSratHdr);
if (ACPI_FAILURE (Status))
{
return;
}
switch (Subtable->Type)
{
case ACPI_SRAT_TYPE_CPU_AFFINITY:
InfoTable = AcpiDmTableInfoSrat0;
break;
case ACPI_SRAT_TYPE_MEMORY_AFFINITY:
InfoTable = AcpiDmTableInfoSrat1;
break;
case ACPI_SRAT_TYPE_X2APIC_CPU_AFFINITY:
InfoTable = AcpiDmTableInfoSrat2;
break;
case ACPI_SRAT_TYPE_GICC_AFFINITY:
InfoTable = AcpiDmTableInfoSrat3;
break;
case ACPI_SRAT_TYPE_GIC_ITS_AFFINITY:
InfoTable = AcpiDmTableInfoSrat4;
break;
case ACPI_SRAT_TYPE_GENERIC_AFFINITY:
InfoTable = AcpiDmTableInfoSrat5;
break;
case ACPI_SRAT_TYPE_GENERIC_PORT_AFFINITY:
InfoTable = AcpiDmTableInfoSrat6;
break;
case ACPI_SRAT_TYPE_RINTC_AFFINITY:
InfoTable = AcpiDmTableInfoSrat7;
break;
default:
AcpiOsPrintf ("\n**** Unknown SRAT subtable type 0x%X\n",
Subtable->Type);
/* Attempt to continue */
if (!Subtable->Length)
{
AcpiOsPrintf ("Invalid zero length subtable\n");
return;
}
goto NextSubtable;
}
AcpiOsPrintf ("\n");
Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
Subtable->Length, InfoTable);
if (ACPI_FAILURE (Status))
{
return;
}
NextSubtable:
/* Point to next subtable */
Offset += Subtable->Length;
Subtable = ACPI_ADD_PTR (ACPI_SUBTABLE_HEADER, Subtable,
Subtable->Length);
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDmDumpStao
*
* PARAMETERS: Table - A STAO table
*
* RETURN: None
*
* DESCRIPTION: Format the contents of a STAO. This is a variable-length
* table that contains an open-ended number of ASCII strings
* at the end of the table.
*
******************************************************************************/
void
AcpiDmDumpStao (
ACPI_TABLE_HEADER *Table)
{
ACPI_STATUS Status;
char *Namepath;
UINT32 Length = Table->Length;
UINT32 StringLength;
UINT32 Offset = sizeof (ACPI_TABLE_STAO);
/* Main table */
Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoStao);
if (ACPI_FAILURE (Status))
{
return;
}
/* The rest of the table consists of Namepath strings */
while (Offset < Table->Length)
{
Namepath = ACPI_ADD_PTR (char, Table, Offset);
StringLength = strlen (Namepath) + 1;
AcpiDmLineHeader (Offset, StringLength, "Namepath");
AcpiOsPrintf ("\"%s\"\n", Namepath);
/* Point to next namepath */
Offset += StringLength;
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDmDumpSvkl
*
* PARAMETERS: Table - A SVKL table
*
* RETURN: None
*
* DESCRIPTION: Format the contents of a SVKL. This is a variable-length
* table that contains an open-ended number of key subtables at
* the end of the header.
*
* NOTES: SVKL is essentially a flat table, with a small main table and
* a variable number of a single type of subtable.
*
******************************************************************************/
void
AcpiDmDumpSvkl (
ACPI_TABLE_HEADER *Table)
{
ACPI_STATUS Status;
UINT32 Length = Table->Length;
UINT32 Offset = sizeof (ACPI_TABLE_SVKL);
ACPI_SVKL_KEY *Subtable;
/* Main table */
Status = AcpiDmDumpTable (Length, 0, Table, 0, AcpiDmTableInfoSvkl);
if (ACPI_FAILURE (Status))
{
return;
}
/* The rest of the table consists of subtables (single type) */
Subtable = ACPI_ADD_PTR (ACPI_SVKL_KEY, Table, Offset);
while (Offset < Table->Length)
{
/* Dump the subtable */
AcpiOsPrintf ("\n");
Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
sizeof (ACPI_SVKL_KEY), AcpiDmTableInfoSvkl0);
if (ACPI_FAILURE (Status))
{
return;
}
/* Point to next subtable */
Offset += sizeof (ACPI_SVKL_KEY);
Subtable = ACPI_ADD_PTR (ACPI_SVKL_KEY, Subtable,
sizeof (ACPI_SVKL_KEY));
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDmDumpTcpa
*
* PARAMETERS: Table - A TCPA table
*
* RETURN: None
*
* DESCRIPTION: Format the contents of a TCPA.
*
* NOTE: There are two versions of the table with the same signature:
* the client version and the server version. The common
* PlatformClass field is used to differentiate the two types of
* tables.
*
******************************************************************************/
void
AcpiDmDumpTcpa (
ACPI_TABLE_HEADER *Table)
{
UINT32 Offset = sizeof (ACPI_TABLE_TCPA_HDR);
ACPI_TABLE_TCPA_HDR *CommonHeader = ACPI_CAST_PTR (
ACPI_TABLE_TCPA_HDR, Table);
ACPI_TABLE_TCPA_HDR *Subtable = ACPI_ADD_PTR (
ACPI_TABLE_TCPA_HDR, Table, Offset);
ACPI_STATUS Status;
/* Main table */
Status = AcpiDmDumpTable (Table->Length, 0, Table,
0, AcpiDmTableInfoTcpaHdr);
if (ACPI_FAILURE (Status))
{
return;
}
/*
* Examine the PlatformClass field to determine the table type.
* Either a client or server table. Only one.
*/
switch (CommonHeader->PlatformClass)
{
case ACPI_TCPA_CLIENT_TABLE:
Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
Table->Length - Offset, AcpiDmTableInfoTcpaClient);
break;
case ACPI_TCPA_SERVER_TABLE:
Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
Table->Length - Offset, AcpiDmTableInfoTcpaServer);
break;
default:
AcpiOsPrintf ("\n**** Unknown TCPA Platform Class 0x%X\n",
CommonHeader->PlatformClass);
Status = AE_ERROR;
break;
}
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("\n**** Cannot disassemble TCPA table\n");
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDmDumpTpm2
*
* PARAMETERS: Table - A TPM2 table
*
* RETURN: None
*
* DESCRIPTION: Format the contents of a TPM2.
*
******************************************************************************/
static void
AcpiDmDumpTpm2Rev3 (
ACPI_TABLE_HEADER *Table)
{
UINT32 Offset = sizeof (ACPI_TABLE_TPM23);
ACPI_TABLE_TPM23 *CommonHeader = ACPI_CAST_PTR (ACPI_TABLE_TPM23, Table);
ACPI_TPM23_TRAILER *Subtable = ACPI_ADD_PTR (ACPI_TPM23_TRAILER, Table, Offset);
ACPI_STATUS Status;
/* Main table */
Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoTpm23);
if (ACPI_FAILURE (Status))
{
return;
}
/* Optional subtable if start method is ACPI start method */
switch (CommonHeader->StartMethod)
{
case ACPI_TPM23_ACPI_START_METHOD:
(void) AcpiDmDumpTable (Table->Length, Offset, Subtable,
Table->Length - Offset, AcpiDmTableInfoTpm23a);
break;
default:
break;
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDmDumpTpm2
*
* PARAMETERS: Table - A TPM2 table
*
* RETURN: None
*
* DESCRIPTION: Format the contents of a TPM2.
*
******************************************************************************/
void
AcpiDmDumpTpm2 (
ACPI_TABLE_HEADER *Table)
{
UINT32 Offset = sizeof (ACPI_TABLE_TPM2);
ACPI_TABLE_TPM2 *CommonHeader = ACPI_CAST_PTR (ACPI_TABLE_TPM2, Table);
ACPI_TPM2_TRAILER *Subtable = ACPI_ADD_PTR (ACPI_TPM2_TRAILER, Table, Offset);
ACPI_TPM2_ARM_SMC *ArmSubtable;
ACPI_STATUS Status;
if (Table->Revision == 3)
{
AcpiDmDumpTpm2Rev3(Table);
return;
}
/* Main table */
Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoTpm2);
if (ACPI_FAILURE (Status))
{
return;
}
AcpiOsPrintf ("\n");
Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
Table->Length - Offset, AcpiDmTableInfoTpm2a);
if (ACPI_FAILURE (Status))
{
return;
}
switch (CommonHeader->StartMethod)
{
case ACPI_TPM2_COMMAND_BUFFER_WITH_ARM_SMC:
ArmSubtable = ACPI_ADD_PTR (ACPI_TPM2_ARM_SMC, Subtable,
sizeof (ACPI_TPM2_TRAILER));
Offset += sizeof (ACPI_TPM2_TRAILER);
AcpiOsPrintf ("\n");
(void) AcpiDmDumpTable (Table->Length, Offset, ArmSubtable,
Table->Length - Offset, AcpiDmTableInfoTpm211);
break;
default:
break;
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDmDumpViot
*
* PARAMETERS: Table - A VIOT table
*
* RETURN: None
*
* DESCRIPTION: Format the contents of a VIOT
*
******************************************************************************/
void
AcpiDmDumpViot (
ACPI_TABLE_HEADER *Table)
{
ACPI_STATUS Status;
ACPI_TABLE_VIOT *Viot;
ACPI_VIOT_HEADER *ViotHeader;
UINT16 Length;
UINT32 Offset;
ACPI_DMTABLE_INFO *InfoTable;
/* Main table */
Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoViot);
if (ACPI_FAILURE (Status))
{
return;
}
Viot = ACPI_CAST_PTR (ACPI_TABLE_VIOT, Table);
Offset = Viot->NodeOffset;
while (Offset < Table->Length)
{
/* Common subtable header */
ViotHeader = ACPI_ADD_PTR (ACPI_VIOT_HEADER, Table, Offset);
AcpiOsPrintf ("\n");
Length = sizeof (ACPI_VIOT_HEADER);
Status = AcpiDmDumpTable (Table->Length, Offset, ViotHeader, Length,
AcpiDmTableInfoViotHeader);
if (ACPI_FAILURE (Status))
{
return;
}
Length = ViotHeader->Length;
switch (ViotHeader->Type)
{
case ACPI_VIOT_NODE_PCI_RANGE:
InfoTable = AcpiDmTableInfoViot1;
break;
case ACPI_VIOT_NODE_MMIO:
InfoTable = AcpiDmTableInfoViot2;
break;
case ACPI_VIOT_NODE_VIRTIO_IOMMU_PCI:
InfoTable = AcpiDmTableInfoViot3;
break;
case ACPI_VIOT_NODE_VIRTIO_IOMMU_MMIO:
InfoTable = AcpiDmTableInfoViot4;
break;
default:
AcpiOsPrintf ("\n*** Unknown VIOT node type 0x%X\n",
ViotHeader->Type);
/* Attempt to continue */
if (!Length)
{
AcpiOsPrintf ("Invalid zero length VIOT node\n");
return;
}
goto NextSubtable;
}
AcpiOsPrintf ("\n");
Status = AcpiDmDumpTable (Table->Length, Offset, ViotHeader, Length,
InfoTable);
if (ACPI_FAILURE (Status))
{
return;
}
NextSubtable:
Offset += Length;
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDmDumpWdat
*
* PARAMETERS: Table - A WDAT table
*
* RETURN: None
*
* DESCRIPTION: Format the contents of a WDAT
*
******************************************************************************/
void
AcpiDmDumpWdat (
ACPI_TABLE_HEADER *Table)
{
ACPI_STATUS Status;
UINT32 Offset = sizeof (ACPI_TABLE_WDAT);
ACPI_WDAT_ENTRY *Subtable;
/* Main table */
Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoWdat);
if (ACPI_FAILURE (Status))
{
return;
}
/* Subtables */
Subtable = ACPI_ADD_PTR (ACPI_WDAT_ENTRY, Table, Offset);
while (Offset < Table->Length)
{
/* Common subtable header */
AcpiOsPrintf ("\n");
Status = AcpiDmDumpTable (Table->Length, Offset, Subtable,
sizeof (ACPI_WDAT_ENTRY), AcpiDmTableInfoWdat0);
if (ACPI_FAILURE (Status))
{
return;
}
/* Point to next subtable */
Offset += sizeof (ACPI_WDAT_ENTRY);
Subtable = ACPI_ADD_PTR (ACPI_WDAT_ENTRY, Subtable,
sizeof (ACPI_WDAT_ENTRY));
}
}
/*******************************************************************************
*
* FUNCTION: AcpiDmDumpWpbt
*
* PARAMETERS: Table - A WPBT table
*
* RETURN: None
*
* DESCRIPTION: Format the contents of a WPBT. This table type consists
* of an open-ended arguments buffer at the end of the table.
*
******************************************************************************/
void
AcpiDmDumpWpbt (
ACPI_TABLE_HEADER *Table)
{
ACPI_STATUS Status;
ACPI_TABLE_WPBT *Subtable;
UINT16 ArgumentsLength;
/* Dump the main table */
Status = AcpiDmDumpTable (Table->Length, 0, Table, 0, AcpiDmTableInfoWpbt);
if (ACPI_FAILURE (Status))
{
return;
}
/* Extract the arguments buffer length from the main table */
Subtable = ACPI_CAST_PTR (ACPI_TABLE_WPBT, Table);
ArgumentsLength = Subtable->ArgumentsLength;
/* Dump the arguments buffer if present */
if (ArgumentsLength)
{
(void) AcpiDmDumpTable (Table->Length, 0, Table, ArgumentsLength,
AcpiDmTableInfoWpbt0);
}
}

View File

@@ -0,0 +1,426 @@
/******************************************************************************
*
* Module Name: dmtbinfo - Table info for non-AML tables
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "acpi.h"
#include "accommon.h"
#include "acdisasm.h"
#include "actbinfo.h"
/* This module used for application-level code only */
#define _COMPONENT ACPI_CA_DISASSEMBLER
ACPI_MODULE_NAME ("dmtbinfo")
/*
* How to add a new table:
*
* - Add the C table definition to the actbl1.h or actbl2.h header.
* - Add ACPI_xxxx_OFFSET macro(s) for the table (and subtables) to list below.
* - Define the table in this file (for the disassembler). If any
* new data types are required (ACPI_DMT_*), see below.
* - Add an external declaration for the new table definition (AcpiDmTableInfo*)
* in acdisam.h
* - Add new table definition to the dispatch table in dmtable.c (AcpiDmTableData)
* If a simple table (with no subtables), no disassembly code is needed.
* Otherwise, create the AcpiDmDump* function for to disassemble the table
* and add it to the dmtbdump.c file.
* - Add an external declaration for the new AcpiDmDump* function in acdisasm.h
* - Add the new AcpiDmDump* function to the dispatch table in dmtable.c
* - Create a template for the new table
* - Add data table compiler support
*
* How to add a new data type (ACPI_DMT_*):
*
* - Add new type at the end of the ACPI_DMT list in acdisasm.h
* - Add length and implementation cases in dmtable.c (disassembler)
* - Add type and length cases in dtutils.c (DT compiler)
*/
/*
* ACPI Table Information, used to dump formatted ACPI tables
*
* Each entry is of the form: <Field Type, Field Offset, Field Name>
*/
/*******************************************************************************
*
* Common ACPI table header
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoHeader[] =
{
{ACPI_DMT_SIG, ACPI_HDR_OFFSET (Signature[0]), "Signature", 0},
{ACPI_DMT_UINT32, ACPI_HDR_OFFSET (Length), "Table Length", DT_LENGTH},
{ACPI_DMT_UINT8, ACPI_HDR_OFFSET (Revision), "Revision", 0},
{ACPI_DMT_CHKSUM, ACPI_HDR_OFFSET (Checksum), "Checksum", 0},
{ACPI_DMT_NAME6, ACPI_HDR_OFFSET (OemId[0]), "Oem ID", 0},
{ACPI_DMT_NAME8, ACPI_HDR_OFFSET (OemTableId[0]), "Oem Table ID", 0},
{ACPI_DMT_UINT32, ACPI_HDR_OFFSET (OemRevision), "Oem Revision", 0},
{ACPI_DMT_NAME4, ACPI_HDR_OFFSET (AslCompilerId[0]), "Asl Compiler ID", 0},
{ACPI_DMT_UINT32, ACPI_HDR_OFFSET (AslCompilerRevision), "Asl Compiler Revision", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* GAS - Generic Address Structure
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoGas[] =
{
{ACPI_DMT_SPACEID, ACPI_GAS_OFFSET (SpaceId), "Space ID", 0},
{ACPI_DMT_UINT8, ACPI_GAS_OFFSET (BitWidth), "Bit Width", 0},
{ACPI_DMT_UINT8, ACPI_GAS_OFFSET (BitOffset), "Bit Offset", 0},
{ACPI_DMT_ACCWIDTH, ACPI_GAS_OFFSET (AccessWidth), "Encoded Access Width", 0},
{ACPI_DMT_UINT64, ACPI_GAS_OFFSET (Address), "Address", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* RSDP - Root System Description Pointer (Signature is "RSD PTR ")
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp1[] =
{
{ACPI_DMT_NAME8, ACPI_RSDP_OFFSET (Signature[0]), "Signature", 0},
{ACPI_DMT_UINT8, ACPI_RSDP_OFFSET (Checksum), "Checksum", 0},
{ACPI_DMT_NAME6, ACPI_RSDP_OFFSET (OemId[0]), "Oem ID", 0},
{ACPI_DMT_UINT8, ACPI_RSDP_OFFSET (Revision), "Revision", 0},
{ACPI_DMT_UINT32, ACPI_RSDP_OFFSET (RsdtPhysicalAddress), "RSDT Address", 0},
ACPI_DMT_TERMINATOR
};
/* ACPI 2.0+ Extensions */
ACPI_DMTABLE_INFO AcpiDmTableInfoRsdp2[] =
{
{ACPI_DMT_UINT32, ACPI_RSDP_OFFSET (Length), "Length", DT_LENGTH},
{ACPI_DMT_UINT64, ACPI_RSDP_OFFSET (XsdtPhysicalAddress), "XSDT Address", 0},
{ACPI_DMT_UINT8, ACPI_RSDP_OFFSET (ExtendedChecksum), "Extended Checksum", 0},
{ACPI_DMT_UINT24, ACPI_RSDP_OFFSET (Reserved[0]), "Reserved", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* FACS - Firmware ACPI Control Structure
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoFacs[] =
{
{ACPI_DMT_NAME4, ACPI_FACS_OFFSET (Signature[0]), "Signature", 0},
{ACPI_DMT_UINT32, ACPI_FACS_OFFSET (Length), "Length", DT_LENGTH},
{ACPI_DMT_UINT32, ACPI_FACS_OFFSET (HardwareSignature), "Hardware Signature", 0},
{ACPI_DMT_UINT32, ACPI_FACS_OFFSET (FirmwareWakingVector), "32 Firmware Waking Vector", 0},
{ACPI_DMT_UINT32, ACPI_FACS_OFFSET (GlobalLock), "Global Lock", 0},
{ACPI_DMT_UINT32, ACPI_FACS_OFFSET (Flags), "Flags (decoded below)", DT_FLAG},
{ACPI_DMT_FLAG0, ACPI_FACS_FLAG_OFFSET (Flags,0), "S4BIOS Support Present", 0},
{ACPI_DMT_FLAG1, ACPI_FACS_FLAG_OFFSET (Flags,0), "64-bit Wake Supported (V2)", 0},
{ACPI_DMT_UINT64, ACPI_FACS_OFFSET (XFirmwareWakingVector), "64 Firmware Waking Vector", 0},
{ACPI_DMT_UINT8, ACPI_FACS_OFFSET (Version), "Version", 0},
{ACPI_DMT_UINT24, ACPI_FACS_OFFSET (Reserved[0]), "Reserved", 0},
{ACPI_DMT_UINT32, ACPI_FACS_OFFSET (OspmFlags), "OspmFlags (decoded below)", DT_FLAG},
{ACPI_DMT_FLAG0, ACPI_FACS_FLAG_OFFSET (OspmFlags,0), "64-bit Wake Env Required (V2)", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* FADT - Fixed ACPI Description Table (Signature is FACP)
*
******************************************************************************/
/* ACPI 1.0 FADT (Version 1) */
ACPI_DMTABLE_INFO AcpiDmTableInfoFadt1[] =
{
{ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Facs), "FACS Address", 0},
{ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Dsdt), "DSDT Address", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Model), "Model", 0},
{ACPI_DMT_FADTPM, ACPI_FADT_OFFSET (PreferredProfile), "PM Profile", 0},
{ACPI_DMT_UINT16, ACPI_FADT_OFFSET (SciInterrupt), "SCI Interrupt", 0},
{ACPI_DMT_UINT32, ACPI_FADT_OFFSET (SmiCommand), "SMI Command Port", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (AcpiEnable), "ACPI Enable Value", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (AcpiDisable), "ACPI Disable Value", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (S4BiosRequest), "S4BIOS Command", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (PstateControl), "P-State Control", 0},
{ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Pm1aEventBlock), "PM1A Event Block Address", 0},
{ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Pm1bEventBlock), "PM1B Event Block Address", 0},
{ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Pm1aControlBlock), "PM1A Control Block Address", 0},
{ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Pm1bControlBlock), "PM1B Control Block Address", 0},
{ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Pm2ControlBlock), "PM2 Control Block Address", 0},
{ACPI_DMT_UINT32, ACPI_FADT_OFFSET (PmTimerBlock), "PM Timer Block Address", 0},
{ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Gpe0Block), "GPE0 Block Address", 0},
{ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Gpe1Block), "GPE1 Block Address", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Pm1EventLength), "PM1 Event Block Length", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Pm1ControlLength), "PM1 Control Block Length", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Pm2ControlLength), "PM2 Control Block Length", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (PmTimerLength), "PM Timer Block Length", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Gpe0BlockLength), "GPE0 Block Length", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Gpe1BlockLength), "GPE1 Block Length", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Gpe1Base), "GPE1 Base Offset", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (CstControl), "_CST Support", 0},
{ACPI_DMT_UINT16, ACPI_FADT_OFFSET (C2Latency), "C2 Latency", 0},
{ACPI_DMT_UINT16, ACPI_FADT_OFFSET (C3Latency), "C3 Latency", 0},
{ACPI_DMT_UINT16, ACPI_FADT_OFFSET (FlushSize), "CPU Cache Size", 0},
{ACPI_DMT_UINT16, ACPI_FADT_OFFSET (FlushStride), "Cache Flush Stride", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (DutyOffset), "Duty Cycle Offset", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (DutyWidth), "Duty Cycle Width", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (DayAlarm), "RTC Day Alarm Index", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (MonthAlarm), "RTC Month Alarm Index", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Century), "RTC Century Index", 0},
{ACPI_DMT_UINT16, ACPI_FADT_OFFSET (BootFlags), "Boot Flags (decoded below)", DT_FLAG},
/* Boot Architecture Flags byte 0 */
{ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "Legacy Devices Supported (V2)", 0},
{ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "8042 Present on ports 60/64 (V2)", 0},
{ACPI_DMT_FLAG2, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "VGA Not Present (V4)", 0},
{ACPI_DMT_FLAG3, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "MSI Not Supported (V4)", 0},
{ACPI_DMT_FLAG4, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "PCIe ASPM Not Supported (V4)", 0},
{ACPI_DMT_FLAG5, ACPI_FADT_FLAG_OFFSET (BootFlags,0), "CMOS RTC Not Present (V5)", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (Reserved), "Reserved", 0},
{ACPI_DMT_UINT32, ACPI_FADT_OFFSET (Flags), "Flags (decoded below)", DT_FLAG},
/* Flags byte 0 */
{ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET (Flags,0), "WBINVD instruction is operational (V1)", 0},
{ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET (Flags,0), "WBINVD flushes all caches (V1)", 0},
{ACPI_DMT_FLAG2, ACPI_FADT_FLAG_OFFSET (Flags,0), "All CPUs support C1 (V1)", 0},
{ACPI_DMT_FLAG3, ACPI_FADT_FLAG_OFFSET (Flags,0), "C2 works on MP system (V1)", 0},
{ACPI_DMT_FLAG4, ACPI_FADT_FLAG_OFFSET (Flags,0), "Control Method Power Button (V1)", 0},
{ACPI_DMT_FLAG5, ACPI_FADT_FLAG_OFFSET (Flags,0), "Control Method Sleep Button (V1)", 0},
{ACPI_DMT_FLAG6, ACPI_FADT_FLAG_OFFSET (Flags,0), "RTC wake not in fixed reg space (V1)", 0},
{ACPI_DMT_FLAG7, ACPI_FADT_FLAG_OFFSET (Flags,0), "RTC can wake system from S4 (V1)", 0},
/* Flags byte 1 */
{ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET (Flags,1), "32-bit PM Timer (V1)", 0},
{ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET (Flags,1), "Docking Supported (V1)", 0},
{ACPI_DMT_FLAG2, ACPI_FADT_FLAG_OFFSET (Flags,1), "Reset Register Supported (V2)", 0},
{ACPI_DMT_FLAG3, ACPI_FADT_FLAG_OFFSET (Flags,1), "Sealed Case (V3)", 0},
{ACPI_DMT_FLAG4, ACPI_FADT_FLAG_OFFSET (Flags,1), "Headless - No Video (V3)", 0},
{ACPI_DMT_FLAG5, ACPI_FADT_FLAG_OFFSET (Flags,1), "Use native instr after SLP_TYPx (V3)", 0},
{ACPI_DMT_FLAG6, ACPI_FADT_FLAG_OFFSET (Flags,1), "PCIEXP_WAK Bits Supported (V4)", 0},
{ACPI_DMT_FLAG7, ACPI_FADT_FLAG_OFFSET (Flags,1), "Use Platform Timer (V4)", 0},
/* Flags byte 2 */
{ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET (Flags,2), "RTC_STS valid on S4 wake (V4)", 0},
{ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET (Flags,2), "Remote Power-on capable (V4)", 0},
{ACPI_DMT_FLAG2, ACPI_FADT_FLAG_OFFSET (Flags,2), "Use APIC Cluster Model (V4)", 0},
{ACPI_DMT_FLAG3, ACPI_FADT_FLAG_OFFSET (Flags,2), "Use APIC Physical Destination Mode (V4)", 0},
{ACPI_DMT_FLAG4, ACPI_FADT_FLAG_OFFSET (Flags,2), "Hardware Reduced (V5)", 0},
{ACPI_DMT_FLAG5, ACPI_FADT_FLAG_OFFSET (Flags,2), "Low Power S0 Idle (V5)", 0},
ACPI_DMT_TERMINATOR
};
/* ACPI 1.0 MS Extensions (FADT version 2) */
ACPI_DMTABLE_INFO AcpiDmTableInfoFadt2[] =
{
{ACPI_DMT_GAS, ACPI_FADT_OFFSET (ResetRegister), "Reset Register", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (ResetValue), "Value to cause reset", 0},
{ACPI_DMT_UINT16, ACPI_FADT_OFFSET (ArmBootFlags), "Reserved", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (MinorRevision), "Reserved", 0},
ACPI_DMT_TERMINATOR
};
/* ACPI 2.0+ Extensions (FADT version 3, 4, and 5) */
ACPI_DMTABLE_INFO AcpiDmTableInfoFadt3[] =
{
{ACPI_DMT_GAS, ACPI_FADT_OFFSET (ResetRegister), "Reset Register", 0},
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (ResetValue), "Value to cause reset", 0},
{ACPI_DMT_UINT16, ACPI_FADT_OFFSET (ArmBootFlags), "ARM Flags (decoded below)", DT_FLAG},
{ACPI_DMT_FLAG0, ACPI_FADT_FLAG_OFFSET(ArmBootFlags,0), "PSCI Compliant", 0},
{ACPI_DMT_FLAG1, ACPI_FADT_FLAG_OFFSET(ArmBootFlags,0), "Must use HVC for PSCI", 0},
ACPI_DMT_NEW_LINE,
{ACPI_DMT_UINT8, ACPI_FADT_OFFSET (MinorRevision), "FADT Minor Revision", 0},
{ACPI_DMT_UINT64, ACPI_FADT_OFFSET (XFacs), "FACS Address", 0},
{ACPI_DMT_UINT64, ACPI_FADT_OFFSET (XDsdt), "DSDT Address", 0},
{ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPm1aEventBlock), "PM1A Event Block", 0},
{ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPm1bEventBlock), "PM1B Event Block", 0},
{ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPm1aControlBlock), "PM1A Control Block", 0},
{ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPm1bControlBlock), "PM1B Control Block", 0},
{ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPm2ControlBlock), "PM2 Control Block", 0},
{ACPI_DMT_GAS, ACPI_FADT_OFFSET (XPmTimerBlock), "PM Timer Block", 0},
{ACPI_DMT_GAS, ACPI_FADT_OFFSET (XGpe0Block), "GPE0 Block", 0},
{ACPI_DMT_GAS, ACPI_FADT_OFFSET (XGpe1Block), "GPE1 Block", 0},
ACPI_DMT_TERMINATOR
};
/* Extensions for FADT version 5 */
ACPI_DMTABLE_INFO AcpiDmTableInfoFadt5[] =
{
{ACPI_DMT_GAS, ACPI_FADT_OFFSET (SleepControl), "Sleep Control Register", 0},
{ACPI_DMT_GAS, ACPI_FADT_OFFSET (SleepStatus), "Sleep Status Register", 0},
ACPI_DMT_TERMINATOR
};
/* Extensions for FADT version 6 */
ACPI_DMTABLE_INFO AcpiDmTableInfoFadt6[] =
{
{ACPI_DMT_UINT64, ACPI_FADT_OFFSET (HypervisorId), "Hypervisor ID", 0},
ACPI_DMT_TERMINATOR
};

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,903 @@
/******************************************************************************
*
* Module Name: dmtbinfo3 - Table info for non-AML tables
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "acpi.h"
#include "accommon.h"
#include "acdisasm.h"
#include "actbinfo.h"
/* This module used for application-level code only */
#define _COMPONENT ACPI_CA_DISASSEMBLER
ACPI_MODULE_NAME ("dmtbinfo3")
/*
* How to add a new table:
*
* - Add the C table definition to the actbl1.h or actbl2.h header.
* - Add ACPI_xxxx_OFFSET macro(s) for the table (and subtables) to list below.
* - Define the table in this file (for the disassembler). If any
* new data types are required (ACPI_DMT_*), see below.
* - Add an external declaration for the new table definition (AcpiDmTableInfo*)
* in acdisam.h
* - Add new table definition to the dispatch table in dmtable.c (AcpiDmTableData)
* If a simple table (with no subtables), no disassembly code is needed.
* Otherwise, create the AcpiDmDump* function for to disassemble the table
* and add it to the dmtbdump.c file.
* - Add an external declaration for the new AcpiDmDump* function in acdisasm.h
* - Add the new AcpiDmDump* function to the dispatch table in dmtable.c
* - Create a template for the new table
* - Add data table compiler support
*
* How to add a new data type (ACPI_DMT_*):
*
* - Add new type at the end of the ACPI_DMT list in acdisasm.h
* - Add length and implementation cases in dmtable.c (disassembler)
* - Add type and length cases in dtutils.c (DT compiler)
*/
/*
* ACPI Table Information, used to dump formatted ACPI tables
*
* Each entry is of the form: <Field Type, Field Offset, Field Name>
*/
/*******************************************************************************
*
* CCEL - CC-Event Log Table
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoCcel[] =
{
{ACPI_DMT_UINT8, ACPI_CCEL_OFFSET (CCType), "CC Type", 0},
{ACPI_DMT_UINT8, ACPI_CCEL_OFFSET (CCSubType), "CC Sub Type", 0},
{ACPI_DMT_UINT32, ACPI_CCEL_OFFSET (Reserved), "Reserved", 0},
{ACPI_DMT_UINT64, ACPI_CCEL_OFFSET (LogAreaMinimumLength), "Log Area Minimum Length", 0},
{ACPI_DMT_UINT64, ACPI_CCEL_OFFSET (LogAreaStartAddress), "Log Area Start Address", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* SLIC - Software Licensing Description Table. This table contains the standard
* ACPI header followed by proprietary data structures
*
******************************************************************************/
/* Single subtable, a proprietary format, so treat it as a buffer */
ACPI_DMTABLE_INFO AcpiDmTableInfoSlic[] =
{
{ACPI_DMT_RAW_BUFFER, 0, "Software Licensing Structure", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* SLIT - System Locality Information Table
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoSlit[] =
{
{ACPI_DMT_UINT64, ACPI_SLIT_OFFSET (LocalityCount), "Localities", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* SPCR - Serial Port Console Redirection table
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoSpcr[] =
{
{ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (InterfaceType), "Interface Type", 0},
{ACPI_DMT_UINT24, ACPI_SPCR_OFFSET (Reserved[0]), "Reserved", 0},
{ACPI_DMT_GAS, ACPI_SPCR_OFFSET (SerialPort), "Serial Port Register", 0},
{ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (InterruptType), "Interrupt Type", 0},
{ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (PcInterrupt), "PCAT-compatible IRQ", 0},
{ACPI_DMT_UINT32, ACPI_SPCR_OFFSET (Interrupt), "Interrupt", 0},
{ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (BaudRate), "Baud Rate", 0},
{ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (Parity), "Parity", 0},
{ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (StopBits), "Stop Bits", 0},
{ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (FlowControl), "Flow Control", 0},
{ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (TerminalType), "Terminal Type", 0},
{ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (Language), "Language", 0},
{ACPI_DMT_UINT16, ACPI_SPCR_OFFSET (PciDeviceId), "PCI Device ID", 0},
{ACPI_DMT_UINT16, ACPI_SPCR_OFFSET (PciVendorId), "PCI Vendor ID", 0},
{ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (PciBus), "PCI Bus", 0},
{ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (PciDevice), "PCI Device", 0},
{ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (PciFunction), "PCI Function", 0},
{ACPI_DMT_UINT32, ACPI_SPCR_OFFSET (PciFlags), "PCI Flags", 0},
{ACPI_DMT_UINT8, ACPI_SPCR_OFFSET (PciSegment), "PCI Segment", 0},
{ACPI_DMT_UINT32, ACPI_SPCR_OFFSET (UartClkFreq), "Uart Clock Freq", 0},
{ACPI_DMT_UINT32, ACPI_SPCR_OFFSET (PreciseBaudrate), "Precise Baud rate", 0},
{ACPI_DMT_UINT16, ACPI_SPCR_OFFSET (NameSpaceStringLength), "NameSpaceStringLength", 0},
{ACPI_DMT_UINT16, ACPI_SPCR_OFFSET (NameSpaceStringOffset), "NameSpaceStringOffset", 0},
{ACPI_DMT_STRING, ACPI_SPCR_OFFSET (NameSpaceString), "NamespaceString", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* SPMI - Server Platform Management Interface table
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoSpmi[] =
{
{ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (InterfaceType), "Interface Type", 0},
{ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (Reserved), "Reserved", DT_NON_ZERO}, /* Value must be 1 */
{ACPI_DMT_UINT16, ACPI_SPMI_OFFSET (SpecRevision), "IPMI Spec Version", 0},
{ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (InterruptType), "Interrupt Type", 0},
{ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (GpeNumber), "GPE Number", 0},
{ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (Reserved1), "Reserved", 0},
{ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (PciDeviceFlag), "PCI Device Flag", 0},
{ACPI_DMT_UINT32, ACPI_SPMI_OFFSET (Interrupt), "Interrupt", 0},
{ACPI_DMT_GAS, ACPI_SPMI_OFFSET (IpmiRegister), "IPMI Register", 0},
{ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (PciSegment), "PCI Segment", 0},
{ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (PciBus), "PCI Bus", 0},
{ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (PciDevice), "PCI Device", 0},
{ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (PciFunction), "PCI Function", 0},
{ACPI_DMT_UINT8, ACPI_SPMI_OFFSET (Reserved2), "Reserved", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* SRAT - System Resource Affinity Table and Subtables
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoSrat[] =
{
{ACPI_DMT_UINT32, ACPI_SRAT_OFFSET (TableRevision), "Table Revision", 0},
{ACPI_DMT_UINT64, ACPI_SRAT_OFFSET (Reserved), "Reserved", 0},
ACPI_DMT_TERMINATOR
};
/* Common Subtable header (one per Subtable) */
ACPI_DMTABLE_INFO AcpiDmTableInfoSratHdr[] =
{
{ACPI_DMT_SRAT, ACPI_SRATH_OFFSET (Type), "Subtable Type", 0},
{ACPI_DMT_UINT8, ACPI_SRATH_OFFSET (Length), "Length", DT_LENGTH},
ACPI_DMT_TERMINATOR
};
/* SRAT Subtables */
/* 0: Processor Local APIC/SAPIC Affinity */
ACPI_DMTABLE_INFO AcpiDmTableInfoSrat0[] =
{
{ACPI_DMT_UINT8, ACPI_SRAT0_OFFSET (ProximityDomainLo), "Proximity Domain Low(8)", 0},
{ACPI_DMT_UINT8, ACPI_SRAT0_OFFSET (ApicId), "Apic ID", 0},
{ACPI_DMT_UINT32, ACPI_SRAT0_OFFSET (Flags), "Flags (decoded below)", DT_FLAG},
{ACPI_DMT_FLAG0, ACPI_SRAT0_FLAG_OFFSET (Flags,0), "Enabled", 0},
{ACPI_DMT_UINT8, ACPI_SRAT0_OFFSET (LocalSapicEid), "Local Sapic EID", 0},
{ACPI_DMT_UINT24, ACPI_SRAT0_OFFSET (ProximityDomainHi[0]), "Proximity Domain High(24)", 0},
{ACPI_DMT_UINT32, ACPI_SRAT0_OFFSET (ClockDomain), "Clock Domain", 0},
ACPI_DMT_TERMINATOR
};
/* 1: Memory Affinity */
ACPI_DMTABLE_INFO AcpiDmTableInfoSrat1[] =
{
{ACPI_DMT_UINT32, ACPI_SRAT1_OFFSET (ProximityDomain), "Proximity Domain", 0},
{ACPI_DMT_UINT16, ACPI_SRAT1_OFFSET (Reserved), "Reserved1", 0},
{ACPI_DMT_UINT64, ACPI_SRAT1_OFFSET (BaseAddress), "Base Address", 0},
{ACPI_DMT_UINT64, ACPI_SRAT1_OFFSET (Length), "Address Length", 0},
{ACPI_DMT_UINT32, ACPI_SRAT1_OFFSET (Reserved1), "Reserved2", 0},
{ACPI_DMT_UINT32, ACPI_SRAT1_OFFSET (Flags), "Flags (decoded below)", DT_FLAG},
{ACPI_DMT_FLAG0, ACPI_SRAT1_FLAG_OFFSET (Flags,0), "Enabled", 0},
{ACPI_DMT_FLAG1, ACPI_SRAT1_FLAG_OFFSET (Flags,0), "Hot Pluggable", 0},
{ACPI_DMT_FLAG2, ACPI_SRAT1_FLAG_OFFSET (Flags,0), "Non-Volatile", 0},
{ACPI_DMT_UINT64, ACPI_SRAT1_OFFSET (Reserved2), "Reserved3", 0},
ACPI_DMT_TERMINATOR
};
/* 2: Processor Local X2_APIC Affinity (ACPI 4.0) */
ACPI_DMTABLE_INFO AcpiDmTableInfoSrat2[] =
{
{ACPI_DMT_UINT16, ACPI_SRAT2_OFFSET (Reserved), "Reserved1", 0},
{ACPI_DMT_UINT32, ACPI_SRAT2_OFFSET (ProximityDomain), "Proximity Domain", 0},
{ACPI_DMT_UINT32, ACPI_SRAT2_OFFSET (ApicId), "Apic ID", 0},
{ACPI_DMT_UINT32, ACPI_SRAT2_OFFSET (Flags), "Flags (decoded below)", DT_FLAG},
{ACPI_DMT_FLAG0, ACPI_SRAT2_FLAG_OFFSET (Flags,0), "Enabled", 0},
{ACPI_DMT_UINT32, ACPI_SRAT2_OFFSET (ClockDomain), "Clock Domain", 0},
{ACPI_DMT_UINT32, ACPI_SRAT2_OFFSET (Reserved2), "Reserved2", 0},
ACPI_DMT_TERMINATOR
};
/* 3: GICC Affinity (ACPI 5.1) */
ACPI_DMTABLE_INFO AcpiDmTableInfoSrat3[] =
{
{ACPI_DMT_UINT32, ACPI_SRAT3_OFFSET (ProximityDomain), "Proximity Domain", 0},
{ACPI_DMT_UINT32, ACPI_SRAT3_OFFSET (AcpiProcessorUid), "Acpi Processor UID", 0},
{ACPI_DMT_UINT32, ACPI_SRAT3_OFFSET (Flags), "Flags (decoded below)", DT_FLAG},
{ACPI_DMT_FLAG0, ACPI_SRAT3_FLAG_OFFSET (Flags,0), "Enabled", 0},
{ACPI_DMT_UINT32, ACPI_SRAT3_OFFSET (ClockDomain), "Clock Domain", 0},
ACPI_DMT_TERMINATOR
};
/* 4: GIC ITS Affinity (ACPI 6.2) */
ACPI_DMTABLE_INFO AcpiDmTableInfoSrat4[] =
{
{ACPI_DMT_UINT32, ACPI_SRAT4_OFFSET (ProximityDomain), "Proximity Domain", 0},
{ACPI_DMT_UINT16, ACPI_SRAT4_OFFSET (Reserved), "Reserved", 0},
{ACPI_DMT_UINT32, ACPI_SRAT4_OFFSET (ItsId), "ITS ID", 0},
ACPI_DMT_TERMINATOR
};
/* Common SRAT structure for Generic Affinity Subtables */
#define ACPI_DM_SRAT_GENERIC_AFFINITY \
{ACPI_DMT_UINT8, ACPI_SRAT5_OFFSET (Reserved), "Reserved1", 0}, \
{ACPI_DMT_UINT8, ACPI_SRAT5_OFFSET (DeviceHandleType), "Device Handle Type", 0}, \
{ACPI_DMT_UINT32, ACPI_SRAT5_OFFSET (ProximityDomain), "Proximity Domain", 0}, \
{ACPI_DMT_BUF16, ACPI_SRAT5_OFFSET (DeviceHandle), "Device Handle", 0}, \
{ACPI_DMT_UINT32, ACPI_SRAT5_OFFSET (Flags), "Flags (decoded below)", DT_FLAG}, \
{ACPI_DMT_FLAG0, ACPI_SRAT5_FLAG_OFFSET (Flags,0), "Enabled", 0}, \
{ACPI_DMT_FLAG1, ACPI_SRAT5_FLAG_OFFSET (Flags,0), "Architectural Transactions", 0}, \
{ACPI_DMT_UINT32, ACPI_SRAT5_OFFSET (Reserved1), "Reserved2", 0}
/* 5: Generic Initiator Affinity Structure (ACPI 6.3) */
ACPI_DMTABLE_INFO AcpiDmTableInfoSrat5[] =
{
ACPI_DM_SRAT_GENERIC_AFFINITY,
ACPI_DMT_TERMINATOR
};
/* 6: Generic Port Affinity Structure (ACPI 6.4) */
ACPI_DMTABLE_INFO AcpiDmTableInfoSrat6[] =
{
ACPI_DM_SRAT_GENERIC_AFFINITY,
ACPI_DMT_TERMINATOR
};
/* 7: RINTC Affinity Structure (ACPI 6.6) */
ACPI_DMTABLE_INFO AcpiDmTableInfoSrat7[] =
{
{ACPI_DMT_UINT16, ACPI_SRAT7_OFFSET (Reserved), "Reserved", 0},
{ACPI_DMT_UINT32, ACPI_SRAT7_OFFSET (ProximityDomain), "Proximity Domain", 0},
{ACPI_DMT_UINT32, ACPI_SRAT7_OFFSET (AcpiProcessorUid), "Acpi Processor UID", 0},
{ACPI_DMT_UINT32, ACPI_SRAT7_OFFSET (Flags), "Flags (decoded below)", DT_FLAG},
{ACPI_DMT_FLAG0, ACPI_SRAT7_FLAG_OFFSET (Flags,0), "Enabled", 0},
{ACPI_DMT_UINT32, ACPI_SRAT7_OFFSET (ClockDomain), "Clock Domain", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* STAO - Status Override Table (_STA override) - ACPI 6.0
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoStao[] =
{
{ACPI_DMT_UINT8, ACPI_STAO_OFFSET (IgnoreUart), "Ignore UART", 0},
ACPI_DMT_TERMINATOR
};
ACPI_DMTABLE_INFO AcpiDmTableInfoStaoStr[] =
{
{ACPI_DMT_STRING, 0, "Namepath", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* SVKL - Storage Volume Key Location table
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoSvkl[] =
{
{ACPI_DMT_UINT32, ACPI_SVKL_OFFSET (Count), "Key Count", 0},
ACPI_DMT_TERMINATOR
};
/* SVKL subtables */
ACPI_DMTABLE_INFO AcpiDmTableInfoSvkl0[] =
{
{ACPI_DMT_UINT16, ACPI_SVKL0_OFFSET (Type), "Key Type", 0},
{ACPI_DMT_UINT16, ACPI_SVKL0_OFFSET (Format), "Key Format", 0},
{ACPI_DMT_UINT32, ACPI_SVKL0_OFFSET (Size), "Key Size", 0},
{ACPI_DMT_UINT64, ACPI_SVKL0_OFFSET (Address), "Key Address", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* TCPA - Trusted Computing Platform Alliance table (Client)
*
* NOTE: There are two versions of the table with the same signature --
* the client version and the server version. The common PlatformClass
* field is used to differentiate the two types of tables.
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoTcpaHdr[] =
{
{ACPI_DMT_UINT16, ACPI_TCPA_OFFSET (PlatformClass), "Platform Class", 0},
ACPI_DMT_TERMINATOR
};
ACPI_DMTABLE_INFO AcpiDmTableInfoTcpaClient[] =
{
{ACPI_DMT_UINT32, ACPI_TCPA_CLIENT_OFFSET (MinimumLogLength), "Min Event Log Length", 0},
{ACPI_DMT_UINT64, ACPI_TCPA_CLIENT_OFFSET (LogAddress), "Event Log Address", 0},
ACPI_DMT_TERMINATOR
};
ACPI_DMTABLE_INFO AcpiDmTableInfoTcpaServer[] =
{
{ACPI_DMT_UINT16, ACPI_TCPA_SERVER_OFFSET (Reserved), "Reserved", 0},
{ACPI_DMT_UINT64, ACPI_TCPA_SERVER_OFFSET (MinimumLogLength), "Min Event Log Length", 0},
{ACPI_DMT_UINT64, ACPI_TCPA_SERVER_OFFSET (LogAddress), "Event Log Address", 0},
{ACPI_DMT_UINT16, ACPI_TCPA_SERVER_OFFSET (SpecRevision), "Specification Revision", 0},
{ACPI_DMT_UINT8, ACPI_TCPA_SERVER_OFFSET (DeviceFlags), "Device Flags (decoded below)", DT_FLAG},
{ACPI_DMT_FLAG0, ACPI_TCPA_SERVER_OFFSET (DeviceFlags), "Pci Device", 0},
{ACPI_DMT_FLAG1, ACPI_TCPA_SERVER_OFFSET (DeviceFlags), "Bus is Pnp", 0},
{ACPI_DMT_FLAG2, ACPI_TCPA_SERVER_OFFSET (DeviceFlags), "Address Valid", 0},
{ACPI_DMT_UINT8, ACPI_TCPA_SERVER_OFFSET (InterruptFlags), "Interrupt Flags (decoded below)", DT_FLAG},
{ACPI_DMT_FLAG0, ACPI_TCPA_SERVER_OFFSET (InterruptFlags), "Mode", 0},
{ACPI_DMT_FLAG1, ACPI_TCPA_SERVER_OFFSET (InterruptFlags), "Polarity", 0},
{ACPI_DMT_FLAG2, ACPI_TCPA_SERVER_OFFSET (InterruptFlags), "GPE SCI Triggered", 0},
{ACPI_DMT_FLAG3, ACPI_TCPA_SERVER_OFFSET (InterruptFlags), "Global System Interrupt", 0},
{ACPI_DMT_UINT8, ACPI_TCPA_SERVER_OFFSET (GpeNumber), "Gpe Number", 0},
{ACPI_DMT_UINT24, ACPI_TCPA_SERVER_OFFSET (Reserved2[0]), "Reserved", 0},
{ACPI_DMT_UINT32, ACPI_TCPA_SERVER_OFFSET (GlobalInterrupt), "Global Interrupt", 0},
{ACPI_DMT_GAS, ACPI_TCPA_SERVER_OFFSET (Address), "Address", 0},
{ACPI_DMT_UINT32, ACPI_TCPA_SERVER_OFFSET (Reserved3), "Reserved", 0},
{ACPI_DMT_GAS, ACPI_TCPA_SERVER_OFFSET (ConfigAddress), "Configuration Address", 0},
{ACPI_DMT_UINT8, ACPI_TCPA_SERVER_OFFSET (Group), "Pci Group", 0},
{ACPI_DMT_UINT8, ACPI_TCPA_SERVER_OFFSET (Bus), "Pci Bus", 0},
{ACPI_DMT_UINT8, ACPI_TCPA_SERVER_OFFSET (Device), "Pci Device", 0},
{ACPI_DMT_UINT8, ACPI_TCPA_SERVER_OFFSET (Function), "Pci Function", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* TDEL - TD-Event Log Table
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoTdel[] =
{
{ACPI_DMT_UINT32, ACPI_TDEL_OFFSET (Reserved), "Reserved", 0},
{ACPI_DMT_UINT64, ACPI_TDEL_OFFSET (LogAreaMinimumLength), "Log Area Minimum Length", 0},
{ACPI_DMT_UINT64, ACPI_TDEL_OFFSET (LogAreaStartAddress), "Log Area Start Address", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* TPM2 - Trusted Platform Module (TPM) 2.0 Hardware Interface Table
*
******************************************************************************/
/* TPM2 revision 3 */
ACPI_DMTABLE_INFO AcpiDmTableInfoTpm23[] =
{
{ACPI_DMT_UINT32, ACPI_TPM23_OFFSET (Reserved), "Reserved", 0},
{ACPI_DMT_UINT64, ACPI_TPM23_OFFSET (ControlAddress), "Control Address", 0},
{ACPI_DMT_UINT32, ACPI_TPM23_OFFSET (StartMethod), "Start Method", 0},
ACPI_DMT_TERMINATOR
};
/* Trailer in the case that StartMethod == 2 */
ACPI_DMTABLE_INFO AcpiDmTableInfoTpm23a[] =
{
{ACPI_DMT_UINT32, ACPI_TPM23A_OFFSET (Reserved), "Reserved", DT_OPTIONAL},
ACPI_DMT_TERMINATOR
};
/* TPM2 revision 4 */
ACPI_DMTABLE_INFO AcpiDmTableInfoTpm2[] =
{
{ACPI_DMT_UINT16, ACPI_TPM2_OFFSET (PlatformClass), "Platform Class", 0},
{ACPI_DMT_UINT16, ACPI_TPM2_OFFSET (Reserved), "Reserved", 0},
{ACPI_DMT_UINT64, ACPI_TPM2_OFFSET (ControlAddress), "Control Address", 0},
{ACPI_DMT_TPM2, ACPI_TPM2_OFFSET (StartMethod), "Start Method", 0},
ACPI_DMT_TERMINATOR
};
/* Optional trailer. LogLength and LogAddress are additionally optional */
ACPI_DMTABLE_INFO AcpiDmTableInfoTpm2a[] =
{
{ACPI_DMT_BUF12, ACPI_TPM2A_OFFSET (MethodParameters), "Method Parameters", DT_OPTIONAL},
{ACPI_DMT_UINT32, ACPI_TPM2A_OFFSET (MinimumLogLength), "Minimum Log Length", DT_OPTIONAL},
{ACPI_DMT_UINT64, ACPI_TPM2A_OFFSET (LogAddress), "Log Address", DT_OPTIONAL},
ACPI_DMT_TERMINATOR
};
/* 11: Start Method for ARM SMC */
ACPI_DMTABLE_INFO AcpiDmTableInfoTpm211[] =
{
{ACPI_DMT_UINT32, ACPI_TPM211_OFFSET (GlobalInterrupt), "Global Interrupt", 0},
{ACPI_DMT_UINT8, ACPI_TPM211_OFFSET (InterruptFlags), "Interrupt Flags", 0},
{ACPI_DMT_UINT8, ACPI_TPM211_OFFSET (OperationFlags), "Operation Flags", 0},
{ACPI_DMT_UINT16, ACPI_TPM211_OFFSET (Reserved), "Reserved", 0},
{ACPI_DMT_UINT32, ACPI_TPM211_OFFSET (FunctionId), "Function ID", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* UEFI - UEFI Boot optimization Table
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoUefi[] =
{
{ACPI_DMT_UUID, ACPI_UEFI_OFFSET (Identifier[0]), "UUID Identifier", 0},
{ACPI_DMT_UINT16, ACPI_UEFI_OFFSET (DataOffset), "Data Offset", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* VIOT - Virtual I/O Translation Table
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoViot[] =
{
{ACPI_DMT_UINT16, ACPI_VIOT_OFFSET (NodeCount), "Node count", 0},
{ACPI_DMT_UINT16, ACPI_VIOT_OFFSET (NodeOffset), "Node offset", 0},
{ACPI_DMT_UINT64, ACPI_VIOT_OFFSET (Reserved), "Reserved", 0},
ACPI_DMT_TERMINATOR
};
/* Common VIOT subtable header */
ACPI_DMTABLE_INFO AcpiDmTableInfoViotHeader[] =
{
{ACPI_DMT_VIOT, ACPI_VIOTH_OFFSET (Type), "Type", 0},
{ACPI_DMT_UINT8, ACPI_VIOTH_OFFSET (Reserved), "Reserved", 0},
{ACPI_DMT_UINT16, ACPI_VIOTH_OFFSET (Length), "Length", DT_LENGTH},
ACPI_DMT_TERMINATOR
};
/* VIOT Subtables */
/* 0x01: PCI Range Node */
ACPI_DMTABLE_INFO AcpiDmTableInfoViot1[] =
{
{ACPI_DMT_UINT32, ACPI_VIOT1_OFFSET (EndpointStart), "Endpoint start", 0},
{ACPI_DMT_UINT16, ACPI_VIOT1_OFFSET (SegmentStart), "PCI Segment start", 0},
{ACPI_DMT_UINT16, ACPI_VIOT1_OFFSET (SegmentEnd), "PCI Segment end", 0},
{ACPI_DMT_UINT16, ACPI_VIOT1_OFFSET (BdfStart), "PCI BDF start", 0},
{ACPI_DMT_UINT16, ACPI_VIOT1_OFFSET (BdfEnd), "PCI BDF end", 0},
{ACPI_DMT_UINT16, ACPI_VIOT1_OFFSET (OutputNode), "Output node", 0},
{ACPI_DMT_UINT48, ACPI_VIOT1_OFFSET (Reserved), "Reserved", 0},
ACPI_DMT_TERMINATOR
};
/* 0x02: MMIO Endpoint Node */
ACPI_DMTABLE_INFO AcpiDmTableInfoViot2[] =
{
{ACPI_DMT_UINT32, ACPI_VIOT2_OFFSET (Endpoint), "Endpoint", 0},
{ACPI_DMT_UINT64, ACPI_VIOT2_OFFSET (BaseAddress), "Base address", 0},
{ACPI_DMT_UINT16, ACPI_VIOT2_OFFSET (OutputNode), "Output node", 0},
{ACPI_DMT_UINT48, ACPI_VIOT2_OFFSET (Reserved), "Reserved", 0},
ACPI_DMT_TERMINATOR
};
/* 0x03: PCI Virtio-IOMMU Node */
ACPI_DMTABLE_INFO AcpiDmTableInfoViot3[] =
{
{ACPI_DMT_UINT16, ACPI_VIOT3_OFFSET (Segment), "PCI Segment", 0},
{ACPI_DMT_UINT16, ACPI_VIOT3_OFFSET (Bdf), "PCI BDF number", 0},
{ACPI_DMT_UINT64, ACPI_VIOT3_OFFSET (Reserved), "Reserved", 0},
ACPI_DMT_TERMINATOR
};
/* 0x04: MMIO Virtio-IOMMU Node */
ACPI_DMTABLE_INFO AcpiDmTableInfoViot4[] =
{
{ACPI_DMT_UINT32, ACPI_VIOT4_OFFSET (Reserved), "Reserved", 0},
{ACPI_DMT_UINT64, ACPI_VIOT4_OFFSET (BaseAddress), "Base address", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* WAET - Windows ACPI Emulated devices Table
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoWaet[] =
{
{ACPI_DMT_UINT32, ACPI_WAET_OFFSET (Flags), "Flags (decoded below)", DT_FLAG},
{ACPI_DMT_FLAG0, ACPI_WAET_OFFSET (Flags), "RTC needs no INT ack", 0},
{ACPI_DMT_FLAG1, ACPI_WAET_OFFSET (Flags), "PM timer, one read only", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* WDAT - Watchdog Action Table
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoWdat[] =
{
{ACPI_DMT_UINT32, ACPI_WDAT_OFFSET (HeaderLength), "Header Length", DT_LENGTH},
{ACPI_DMT_UINT16, ACPI_WDAT_OFFSET (PciSegment), "PCI Segment", 0},
{ACPI_DMT_UINT8, ACPI_WDAT_OFFSET (PciBus), "PCI Bus", 0},
{ACPI_DMT_UINT8, ACPI_WDAT_OFFSET (PciDevice), "PCI Device", 0},
{ACPI_DMT_UINT8, ACPI_WDAT_OFFSET (PciFunction), "PCI Function", 0},
{ACPI_DMT_UINT24, ACPI_WDAT_OFFSET (Reserved[0]), "Reserved", 0},
{ACPI_DMT_UINT32, ACPI_WDAT_OFFSET (TimerPeriod), "Timer Period", 0},
{ACPI_DMT_UINT32, ACPI_WDAT_OFFSET (MaxCount), "Max Count", 0},
{ACPI_DMT_UINT32, ACPI_WDAT_OFFSET (MinCount), "Min Count", 0},
{ACPI_DMT_UINT8, ACPI_WDAT_OFFSET (Flags), "Flags (decoded below)", DT_FLAG},
{ACPI_DMT_FLAG0, ACPI_WDAT_OFFSET (Flags), "Enabled", 0},
{ACPI_DMT_FLAG7, ACPI_WDAT_OFFSET (Flags), "Stopped When Asleep", 0},
{ACPI_DMT_UINT24, ACPI_WDAT_OFFSET (Reserved2[0]), "Reserved", 0},
{ACPI_DMT_UINT32, ACPI_WDAT_OFFSET (Entries), "Watchdog Entry Count", 0},
ACPI_DMT_TERMINATOR
};
/* WDAT Subtables - Watchdog Instruction Entries */
ACPI_DMTABLE_INFO AcpiDmTableInfoWdat0[] =
{
{ACPI_DMT_UINT8, ACPI_WDAT0_OFFSET (Action), "Watchdog Action", 0},
{ACPI_DMT_UINT8, ACPI_WDAT0_OFFSET (Instruction), "Instruction", 0},
{ACPI_DMT_UINT16, ACPI_WDAT0_OFFSET (Reserved), "Reserved", 0},
{ACPI_DMT_GAS, ACPI_WDAT0_OFFSET (RegisterRegion), "Register Region", 0},
{ACPI_DMT_UINT32, ACPI_WDAT0_OFFSET (Value), "Value", 0},
{ACPI_DMT_UINT32, ACPI_WDAT0_OFFSET (Mask), "Register Mask", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* WDDT - Watchdog Description Table
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoWddt[] =
{
{ACPI_DMT_UINT16, ACPI_WDDT_OFFSET (SpecVersion), "Specification Version", 0},
{ACPI_DMT_UINT16, ACPI_WDDT_OFFSET (TableVersion), "Table Version", 0},
{ACPI_DMT_UINT16, ACPI_WDDT_OFFSET (PciVendorId), "PCI Vendor ID", 0},
{ACPI_DMT_GAS, ACPI_WDDT_OFFSET (Address), "Timer Register", 0},
{ACPI_DMT_UINT16, ACPI_WDDT_OFFSET (MaxCount), "Max Count", 0},
{ACPI_DMT_UINT16, ACPI_WDDT_OFFSET (MinCount), "Min Count", 0},
{ACPI_DMT_UINT16, ACPI_WDDT_OFFSET (Period), "Period", 0},
{ACPI_DMT_UINT16, ACPI_WDDT_OFFSET (Status), "Status (decoded below)", 0},
/* Status Flags byte 0 */
{ACPI_DMT_FLAG0, ACPI_WDDT_FLAG_OFFSET (Status,0), "Available", 0},
{ACPI_DMT_FLAG1, ACPI_WDDT_FLAG_OFFSET (Status,0), "Active", 0},
{ACPI_DMT_FLAG2, ACPI_WDDT_FLAG_OFFSET (Status,0), "OS Owns", 0},
/* Status Flags byte 1 */
{ACPI_DMT_FLAG3, ACPI_WDDT_FLAG_OFFSET (Status,1), "User Reset", 0},
{ACPI_DMT_FLAG4, ACPI_WDDT_FLAG_OFFSET (Status,1), "Timeout Reset", 0},
{ACPI_DMT_FLAG5, ACPI_WDDT_FLAG_OFFSET (Status,1), "Power Fail Reset", 0},
{ACPI_DMT_FLAG6, ACPI_WDDT_FLAG_OFFSET (Status,1), "Unknown Reset", 0},
{ACPI_DMT_UINT16, ACPI_WDDT_OFFSET (Capability), "Capability (decoded below)", 0},
/* Capability Flags byte 0 */
{ACPI_DMT_FLAG0, ACPI_WDDT_FLAG_OFFSET (Capability,0), "Auto Reset", 0},
{ACPI_DMT_FLAG1, ACPI_WDDT_FLAG_OFFSET (Capability,0), "Timeout Alert", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* WDRT - Watchdog Resource Table
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoWdrt[] =
{
{ACPI_DMT_GAS, ACPI_WDRT_OFFSET (ControlRegister), "Control Register", 0},
{ACPI_DMT_GAS, ACPI_WDRT_OFFSET (CountRegister), "Count Register", 0},
{ACPI_DMT_UINT16, ACPI_WDRT_OFFSET (PciDeviceId), "PCI Device ID", 0},
{ACPI_DMT_UINT16, ACPI_WDRT_OFFSET (PciVendorId), "PCI Vendor ID", 0},
{ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (PciBus), "PCI Bus", 0},
{ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (PciDevice), "PCI Device", 0},
{ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (PciFunction), "PCI Function", 0},
{ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (PciSegment), "PCI Segment", 0},
{ACPI_DMT_UINT16, ACPI_WDRT_OFFSET (MaxCount), "Max Count", 0},
{ACPI_DMT_UINT8, ACPI_WDRT_OFFSET (Units), "Counter Units", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* WPBT - Windows Platform Environment Table (ACPI 6.0)
* Version 1
*
* Conforms to "Windows Platform Binary Table (WPBT)" 29 November 2011
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoWpbt[] =
{
{ACPI_DMT_UINT32, ACPI_WPBT_OFFSET (HandoffSize), "Handoff Size", 0},
{ACPI_DMT_UINT64, ACPI_WPBT_OFFSET (HandoffAddress), "Handoff Address", 0},
{ACPI_DMT_UINT8, ACPI_WPBT_OFFSET (Layout), "Layout", 0},
{ACPI_DMT_UINT8, ACPI_WPBT_OFFSET (Type), "Type", 0},
{ACPI_DMT_UINT16, ACPI_WPBT_OFFSET (ArgumentsLength), "Arguments Length", 0},
ACPI_DMT_TERMINATOR
};
ACPI_DMTABLE_INFO AcpiDmTableInfoWpbt0[] =
{
{ACPI_DMT_WPBT_UNICODE, ACPI_WPBT2_OFFSET (UnicodeString), "Command-line Arguments", DT_DESCRIBES_OPTIONAL},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* WSMT - Windows SMM Security Mitigations Table
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoWsmt[] =
{
{ACPI_DMT_UINT32, ACPI_WSMT_OFFSET (ProtectionFlags), "Protection Flags", 0},
{ACPI_DMT_FLAG0, ACPI_WSMT_FLAG_OFFSET (ProtectionFlags,0), "FIXED_COMM_BUFFERS", 0},
{ACPI_DMT_FLAG1, ACPI_WSMT_FLAG_OFFSET (ProtectionFlags,0), "COMM_BUFFER_NESTED_PTR_PROTECTION", 0},
{ACPI_DMT_FLAG2, ACPI_WSMT_FLAG_OFFSET (ProtectionFlags,0), "SYSTEM_RESOURCE_PROTECTION", 0},
ACPI_DMT_TERMINATOR
};
/*******************************************************************************
*
* XENV - Xen Environment table (ACPI 6.0)
*
******************************************************************************/
ACPI_DMTABLE_INFO AcpiDmTableInfoXenv[] =
{
{ACPI_DMT_UINT64, ACPI_XENV_OFFSET (GrantTableAddress), "Grant Table Address", 0},
{ACPI_DMT_UINT64, ACPI_XENV_OFFSET (GrantTableSize), "Grant Table Size", 0},
{ACPI_DMT_UINT32, ACPI_XENV_OFFSET (EventInterrupt), "Event Interrupt", 0},
{ACPI_DMT_UINT8, ACPI_XENV_OFFSET (EventFlags), "Event Flags", 0},
ACPI_DMT_TERMINATOR
};
/*! [Begin] no source code translation */
/*
* Generic types (used in UEFI and custom tables)
*
* Examples:
*
* Buffer : cc 04 ff bb
* UINT8 : 11
* UINT16 : 1122
* UINT24 : 112233
* UINT32 : 11223344
* UINT56 : 11223344556677
* UINT64 : 1122334455667788
*
* String : "This is string"
* Unicode : "This string encoded to Unicode"
*
* GUID : 11223344-5566-7788-99aa-bbccddeeff00
* DevicePath : "\PciRoot(0)\Pci(0x1f,1)\Usb(0,0)"
*/
#define ACPI_DM_GENERIC_ENTRY(FieldType, FieldName) \
{{FieldType, 0, FieldName, 0}, ACPI_DMT_TERMINATOR}
ACPI_DMTABLE_INFO AcpiDmTableInfoGeneric[][2] =
{
ACPI_DM_GENERIC_ENTRY (ACPI_DMT_UINT8, "UINT8"),
ACPI_DM_GENERIC_ENTRY (ACPI_DMT_UINT16, "UINT16"),
ACPI_DM_GENERIC_ENTRY (ACPI_DMT_UINT24, "UINT24"),
ACPI_DM_GENERIC_ENTRY (ACPI_DMT_UINT32, "UINT32"),
ACPI_DM_GENERIC_ENTRY (ACPI_DMT_UINT40, "UINT40"),
ACPI_DM_GENERIC_ENTRY (ACPI_DMT_UINT48, "UINT48"),
ACPI_DM_GENERIC_ENTRY (ACPI_DMT_UINT56, "UINT56"),
ACPI_DM_GENERIC_ENTRY (ACPI_DMT_UINT64, "UINT64"),
ACPI_DM_GENERIC_ENTRY (ACPI_DMT_STRING, "String"),
ACPI_DM_GENERIC_ENTRY (ACPI_DMT_UNICODE, "Unicode"),
ACPI_DM_GENERIC_ENTRY (ACPI_DMT_BUFFER, "Buffer"),
ACPI_DM_GENERIC_ENTRY (ACPI_DMT_BUF16, "BUF16"),
ACPI_DM_GENERIC_ENTRY (ACPI_DMT_UUID, "GUID"),
ACPI_DM_GENERIC_ENTRY (ACPI_DMT_STRING, "DevicePath"),
ACPI_DM_GENERIC_ENTRY (ACPI_DMT_LABEL, "Label"),
{ACPI_DMT_TERMINATOR}
};
/*! [End] no source code translation !*/

View File

@@ -0,0 +1,384 @@
/******************************************************************************
*
* Module Name: getopt
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
/*
* ACPICA getopt() implementation
*
* Option strings:
* "f" - Option has no arguments
* "f:" - Option requires an argument
* "f+" - Option has an optional argument
* "f^" - Option has optional single-char sub-options
* "f|" - Option has required single-char sub-options
*/
#include "acpi.h"
#include "accommon.h"
#include "acapps.h"
#define ACPI_OPTION_ERROR(msg, badchar) \
if (AcpiGbl_Opterr) {fprintf (stderr, "%s%c\n", msg, badchar);}
int AcpiGbl_Opterr = 1;
int AcpiGbl_Optind = 1;
int AcpiGbl_SubOptChar = 0;
char *AcpiGbl_Optarg;
static int CurrentCharPtr = 1;
/*******************************************************************************
*
* FUNCTION: AcpiGetoptArgument
*
* PARAMETERS: argc, argv - from main
*
* RETURN: 0 if an argument was found, -1 otherwise. Sets AcpiGbl_Optarg
* to point to the next argument.
*
* DESCRIPTION: Get the next argument. Used to obtain arguments for the
* two-character options after the original call to AcpiGetopt.
* Note: Either the argument starts at the next character after
* the option, or it is pointed to by the next argv entry.
* (After call to AcpiGetopt, we need to backup to the previous
* argv entry).
*
******************************************************************************/
int
AcpiGetoptArgument (
int argc,
char **argv)
{
AcpiGbl_Optind--;
CurrentCharPtr++;
if (argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)] != '\0')
{
AcpiGbl_Optarg = &argv[AcpiGbl_Optind++][(int) (CurrentCharPtr+1)];
}
else if (++AcpiGbl_Optind >= argc)
{
ACPI_OPTION_ERROR ("\nOption requires an argument", 0);
CurrentCharPtr = 1;
return (-1);
}
else
{
AcpiGbl_Optarg = argv[AcpiGbl_Optind++];
}
CurrentCharPtr = 1;
return (0);
}
/*******************************************************************************
*
* FUNCTION: AcpiGetopt
*
* PARAMETERS: argc, argv - from main
* opts - options info list
*
* RETURN: Option character or ACPI_OPT_END
*
* DESCRIPTION: Get the next option
*
******************************************************************************/
int
AcpiGetopt(
int argc,
char **argv,
char *opts)
{
int CurrentChar;
char *OptsPtr;
if (CurrentCharPtr == 1)
{
if (AcpiGbl_Optind >= argc ||
argv[AcpiGbl_Optind][0] != '-' ||
argv[AcpiGbl_Optind][1] == '\0')
{
return (ACPI_OPT_END);
}
else if (strcmp (argv[AcpiGbl_Optind], "--") == 0)
{
AcpiGbl_Optind++;
return (ACPI_OPT_END);
}
}
/* Get the option */
CurrentChar = argv[AcpiGbl_Optind][CurrentCharPtr];
/* Make sure that the option is legal */
if (CurrentChar == ':' ||
(OptsPtr = strchr (opts, CurrentChar)) == NULL)
{
ACPI_OPTION_ERROR ("Illegal option: -", CurrentChar);
if (argv[AcpiGbl_Optind][++CurrentCharPtr] == '\0')
{
AcpiGbl_Optind++;
CurrentCharPtr = 1;
}
return ('?');
}
/* Option requires an argument? */
if (*++OptsPtr == ':')
{
if (argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)] != '\0')
{
AcpiGbl_Optarg = &argv[AcpiGbl_Optind++][(int) (CurrentCharPtr+1)];
}
else if (++AcpiGbl_Optind >= argc)
{
ACPI_OPTION_ERROR (
"Option requires an argument: -", CurrentChar);
CurrentCharPtr = 1;
return ('?');
}
else
{
AcpiGbl_Optarg = argv[AcpiGbl_Optind++];
}
CurrentCharPtr = 1;
}
/* Option has an optional argument? */
else if (*OptsPtr == '+')
{
if (argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)] != '\0')
{
AcpiGbl_Optarg = &argv[AcpiGbl_Optind++][(int) (CurrentCharPtr+1)];
}
else if (++AcpiGbl_Optind >= argc)
{
AcpiGbl_Optarg = NULL;
}
else
{
AcpiGbl_Optarg = argv[AcpiGbl_Optind++];
}
CurrentCharPtr = 1;
}
/* Option has optional single-char arguments? */
else if (*OptsPtr == '^')
{
if (argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)] != '\0')
{
AcpiGbl_Optarg = &argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)];
}
else
{
AcpiGbl_Optarg = "^";
}
AcpiGbl_SubOptChar = AcpiGbl_Optarg[0];
AcpiGbl_Optind++;
CurrentCharPtr = 1;
}
/* Option has a required single-char argument? */
else if (*OptsPtr == '|')
{
if (argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)] != '\0')
{
AcpiGbl_Optarg = &argv[AcpiGbl_Optind][(int) (CurrentCharPtr+1)];
}
else
{
ACPI_OPTION_ERROR (
"Option requires a single-character suboption: -",
CurrentChar);
CurrentCharPtr = 1;
return ('?');
}
AcpiGbl_SubOptChar = AcpiGbl_Optarg[0];
AcpiGbl_Optind++;
CurrentCharPtr = 1;
}
/* Option with no arguments */
else
{
if (argv[AcpiGbl_Optind][++CurrentCharPtr] == '\0')
{
CurrentCharPtr = 1;
AcpiGbl_Optind++;
}
AcpiGbl_Optarg = NULL;
}
return (CurrentChar);
}

View File

@@ -0,0 +1,307 @@
/******************************************************************************
*
* Module Name: aslallocate -- Local memory allocation
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
/*
* Local heap allocation wrappers. See aslcache.c for allocation from local
* cache allocations
*/
/*******************************************************************************
*
* FUNCTION: UtLocalCalloc
*
* PARAMETERS: Size - Bytes to be allocated
*
* RETURN: Pointer to the allocated memory. If this function returns
* (the compiler is not aborted), the pointer is guaranteed to
* be valid.
*
* DESCRIPTION: Allocate zero-initialized memory. The point of this function
* is to abort the compile on an allocation failure, on the
* assumption that nothing more can be accomplished.
*
* NOTE: For allocation from the local caches, see aslcache.c
*
******************************************************************************/
void *
UtLocalCalloc (
UINT32 Size)
{
void *Allocated;
Allocated = ACPI_ALLOCATE_ZEROED (Size);
if (!Allocated)
{
AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION,
AslGbl_CurrentLineNumber, AslGbl_LogicalLineNumber,
AslGbl_InputByteCount, AslGbl_CurrentColumn,
AslGbl_Files[ASL_FILE_INPUT].Filename, NULL);
CmCleanupAndExit ();
exit (1);
}
AslGbl_TotalAllocations++;
AslGbl_TotalAllocated += Size;
return (Allocated);
}
/******************************************************************************
*
* FUNCTION: UtExpandLineBuffers
*
* PARAMETERS: None. Updates global line buffer pointers.
*
* RETURN: None. Reallocates the global line buffers
*
* DESCRIPTION: Called if the current line buffer becomes filled. Reallocates
* all global line buffers and updates AslGbl_LineBufferSize. NOTE:
* Also used for the initial allocation of the buffers, when
* all of the buffer pointers are NULL. Initial allocations are
* of size ASL_DEFAULT_LINE_BUFFER_SIZE
*
*****************************************************************************/
void
UtExpandLineBuffers (
void)
{
UINT32 NewSize;
/* Attempt to double the size of all line buffers */
NewSize = AslGbl_LineBufferSize * 2;
if (AslGbl_CurrentLineBuffer)
{
DbgPrint (ASL_DEBUG_OUTPUT,
"Increasing line buffer size from %u to %u\n",
AslGbl_LineBufferSize, NewSize);
}
UtReallocLineBuffers (&AslGbl_CurrentLineBuffer, AslGbl_LineBufferSize, NewSize);
UtReallocLineBuffers (&AslGbl_MainTokenBuffer, AslGbl_LineBufferSize, NewSize);
UtReallocLineBuffers (&AslGbl_MacroTokenBuffer, AslGbl_LineBufferSize, NewSize);
UtReallocLineBuffers (&AslGbl_ExpressionTokenBuffer, AslGbl_LineBufferSize, NewSize);
AslGbl_LineBufPtr = AslGbl_CurrentLineBuffer;
AslGbl_LineBufferSize = NewSize;
}
/******************************************************************************
*
* FUNCTION: UtReallocLineBuffers
*
* PARAMETERS: Buffer - Buffer to realloc
* OldSize - Old size of Buffer
* NewSize - New size of Buffer
*
* RETURN: none
*
* DESCRIPTION: Reallocate and initialize Buffer
*
*****************************************************************************/
void
UtReallocLineBuffers (
char **Buffer,
UINT32 OldSize,
UINT32 NewSize)
{
*Buffer = realloc (*Buffer, NewSize);
if (*Buffer)
{
memset (*Buffer + OldSize, 0, NewSize - OldSize);
return;
}
printf ("Could not increase line buffer size from %u to %u\n",
OldSize, NewSize);
AslError (ASL_ERROR, ASL_MSG_BUFFER_ALLOCATION, NULL, NULL);
AslAbort ();
}
/******************************************************************************
*
* FUNCTION: UtFreeLineBuffers
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Free all line buffers
*
*****************************************************************************/
void
UtFreeLineBuffers (
void)
{
free (AslGbl_CurrentLineBuffer);
free (AslGbl_MainTokenBuffer);
free (AslGbl_MacroTokenBuffer);
free (AslGbl_MacroTokenReplaceBuffer);
free (AslGbl_ExpressionTokenBuffer);
}

View File

@@ -0,0 +1,852 @@
/******************************************************************************
*
* Module Name: aslanalyze.c - Support functions for parse tree walks
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "acnamesp.h"
#include <string.h>
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslanalyze")
/* Local Prototypes */
static ACPI_STATUS
ApDeviceSubtreeWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context);
/*******************************************************************************
*
* FUNCTION: AnIsInternalMethod
*
* PARAMETERS: Op - Current op
*
* RETURN: Boolean
*
* DESCRIPTION: Check for an internal control method.
*
******************************************************************************/
BOOLEAN
AnIsInternalMethod (
ACPI_PARSE_OBJECT *Op)
{
if ((!strcmp (Op->Asl.ExternalName, "\\_OSI")) ||
(!strcmp (Op->Asl.ExternalName, "_OSI")))
{
return (TRUE);
}
return (FALSE);
}
/*******************************************************************************
*
* FUNCTION: AnGetInternalMethodReturnType
*
* PARAMETERS: Op - Current op
*
* RETURN: Btype
*
* DESCRIPTION: Get the return type of an internal method
*
******************************************************************************/
UINT32
AnGetInternalMethodReturnType (
ACPI_PARSE_OBJECT *Op)
{
if ((!strcmp (Op->Asl.ExternalName, "\\_OSI")) ||
(!strcmp (Op->Asl.ExternalName, "_OSI")))
{
return (ACPI_BTYPE_STRING);
}
return (0);
}
/*******************************************************************************
*
* FUNCTION: AnCheckId
*
* PARAMETERS: Op - Current parse op
* Type - HID or CID
*
* RETURN: None
*
* DESCRIPTION: Perform various checks on _HID and _CID strings. Only limited
* checks can be performed on _CID strings.
*
******************************************************************************/
void
AnCheckId (
ACPI_PARSE_OBJECT *Op,
ACPI_NAME Type)
{
UINT32 i;
ACPI_SIZE Length;
/* Only care about string versions of _HID/_CID (integers are legal) */
if (Op->Asl.ParseOpcode != PARSEOP_STRING_LITERAL)
{
return;
}
/* For both _HID and _CID, the string must be non-null */
Length = strlen (Op->Asl.Value.String);
if (!Length)
{
AslError (ASL_ERROR, ASL_MSG_NULL_STRING, Op, NULL);
return;
}
/*
* One of the things we want to catch here is the use of a leading
* asterisk in the string -- an odd construct that certain platform
* manufacturers are fond of. Technically, a leading asterisk is OK
* for _CID, but a valid use of this has not been seen.
*/
if (*Op->Asl.Value.String == '*')
{
AslError (ASL_ERROR, ASL_MSG_LEADING_ASTERISK,
Op, Op->Asl.Value.String);
return;
}
/* _CID strings are bus-specific, no more checks can be performed */
if (Type == ASL_TYPE_CID)
{
return;
}
/* For _HID, all characters must be alphanumeric */
for (i = 0; Op->Asl.Value.String[i]; i++)
{
if (!isalnum ((int) Op->Asl.Value.String[i]))
{
AslError (ASL_ERROR, ASL_MSG_ALPHANUMERIC_STRING,
Op, Op->Asl.Value.String);
return;
}
}
/*
* _HID String must be one of these forms:
*
* "AAA####" A is an uppercase letter and # is a hex digit
* "ACPI####" # is a hex digit
* "NNNN####" N is an uppercase letter or decimal digit (0-9)
* # is a hex digit (ACPI 5.0)
*/
if ((Length < 7) || (Length > 8))
{
AslError (ASL_ERROR, ASL_MSG_HID_LENGTH,
Op, Op->Asl.Value.String);
return;
}
/* _HID Length is valid (7 or 8), now check prefix (first 3 or 4 chars) */
if (Length == 7)
{
/* AAA####: Ensure the alphabetic prefix is all uppercase */
for (i = 0; i < 3; i++)
{
if (!isupper ((int) Op->Asl.Value.String[i]))
{
AslError (ASL_ERROR, ASL_MSG_UPPER_CASE,
Op, &Op->Asl.Value.String[i]);
return;
}
}
}
else /* Length == 8 */
{
/*
* ACPI#### or NNNN####:
* Ensure the prefix contains only uppercase alpha or decimal digits
*/
for (i = 0; i < 4; i++)
{
if (!isupper ((int) Op->Asl.Value.String[i]) &&
!isdigit ((int) Op->Asl.Value.String[i]))
{
AslError (ASL_ERROR, ASL_MSG_HID_PREFIX,
Op, &Op->Asl.Value.String[i]);
return;
}
}
}
/* Remaining characters (suffix) must be hex digits */
for (; i < Length; i++)
{
if (!isxdigit ((int) Op->Asl.Value.String[i]))
{
AslError (ASL_ERROR, ASL_MSG_HID_SUFFIX,
Op, &Op->Asl.Value.String[i]);
break;
}
}
}
/*******************************************************************************
*
* FUNCTION: AnLastStatementIsReturn
*
* PARAMETERS: Op - A method parse node
*
* RETURN: TRUE if last statement is an ASL RETURN. False otherwise
*
* DESCRIPTION: Walk down the list of top level statements within a method
* to find the last one. Check if that last statement is in
* fact a RETURN statement.
*
******************************************************************************/
BOOLEAN
AnLastStatementIsReturn (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *Next;
/* Check if last statement is a return */
Next = ASL_GET_CHILD_NODE (Op);
while (Next)
{
if ((!Next->Asl.Next) &&
(Next->Asl.ParseOpcode == PARSEOP_RETURN))
{
return (TRUE);
}
Next = ASL_GET_PEER_NODE (Next);
}
return (FALSE);
}
/*******************************************************************************
*
* FUNCTION: AnCheckMethodReturnValue
*
* PARAMETERS: Op - Parent
* OpInfo - Parent info
* ArgOp - Method invocation op
* RequiredBtypes - What caller requires
* ThisNodeBtype - What this node returns (if anything)
*
* RETURN: None
*
* DESCRIPTION: Check a method invocation for 1) A return value and if it does
* in fact return a value, 2) check the type of the return value.
*
******************************************************************************/
void
AnCheckMethodReturnValue (
ACPI_PARSE_OBJECT *Op,
const ACPI_OPCODE_INFO *OpInfo,
ACPI_PARSE_OBJECT *ArgOp,
UINT32 RequiredBtypes,
UINT32 ThisNodeBtype)
{
ACPI_PARSE_OBJECT *OwningOp;
ACPI_NAMESPACE_NODE *Node;
char *ExternalPath;
Node = ArgOp->Asl.Node;
if (!Node)
{
/* No error message, this can happen and is OK */
return;
}
/* Examine the parent op of this method */
OwningOp = Node->Op;
ExternalPath = AcpiNsGetNormalizedPathname (Node, TRUE);
if (OwningOp->Asl.CompileFlags & OP_METHOD_NO_RETVAL)
{
/* Method NEVER returns a value */
AslError (ASL_ERROR, ASL_MSG_NO_RETVAL, Op, ExternalPath);
}
else if (OwningOp->Asl.CompileFlags & OP_METHOD_SOME_NO_RETVAL)
{
/* Method SOMETIMES returns a value, SOMETIMES not */
AslError (ASL_WARNING, ASL_MSG_SOME_NO_RETVAL, Op, ExternalPath);
}
else if (!(ThisNodeBtype & RequiredBtypes))
{
/* Method returns a value, but the type is wrong */
AnFormatBtype (AslGbl_StringBuffer, ThisNodeBtype);
AnFormatBtype (AslGbl_StringBuffer2, RequiredBtypes);
/*
* The case where the method does not return any value at all
* was already handled in the namespace cross reference
* -- Only issue an error if the method in fact returns a value,
* but it is of the wrong type
*/
if (ThisNodeBtype != 0)
{
sprintf (AslGbl_MsgBuffer,
"Method returns [%s], %s operator requires [%s]",
AslGbl_StringBuffer, OpInfo->Name, AslGbl_StringBuffer2);
AslError (ASL_WARNING, ASL_MSG_INVALID_TYPE, ArgOp, AslGbl_MsgBuffer);
}
}
if (ExternalPath)
{
ACPI_FREE (ExternalPath);
}
}
/*******************************************************************************
*
* FUNCTION: AnIsResultUsed
*
* PARAMETERS: Op - Parent op for the operator
*
* RETURN: TRUE if result from this operation is actually consumed
*
* DESCRIPTION: Determine if the function result value from an operator is
* used.
*
******************************************************************************/
BOOLEAN
AnIsResultUsed (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *Parent;
switch (Op->Asl.ParseOpcode)
{
case PARSEOP_INCREMENT:
case PARSEOP_DECREMENT:
/* These are standalone operators, no return value */
return (TRUE);
default:
break;
}
/* Examine parent to determine if the return value is used */
Parent = Op->Asl.Parent;
switch (Parent->Asl.ParseOpcode)
{
/* If/While - check if the operator is the predicate */
case PARSEOP_IF:
case PARSEOP_WHILE:
/* First child is the predicate */
if (Parent->Asl.Child == Op)
{
return (TRUE);
}
return (FALSE);
/* Not used if one of these is the parent */
case PARSEOP_METHOD:
case PARSEOP_DEFINITION_BLOCK:
case PARSEOP_ELSE:
return (FALSE);
default:
/* Any other type of parent means that the result is used */
return (TRUE);
}
}
/*******************************************************************************
*
* FUNCTION: ApCheckForGpeNameConflict
*
* PARAMETERS: Op - Current parse op
*
* RETURN: None
*
* DESCRIPTION: Check for a conflict between GPE names within this scope.
* Conflict means two GPE names with the same GPE number, but
* different types -- such as _L1C and _E1C.
*
******************************************************************************/
void
ApCheckForGpeNameConflict (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *NextOp;
UINT32 GpeNumber;
char Name[ACPI_NAMESEG_SIZE + 1];
char Target[ACPI_NAMESEG_SIZE];
/* Need a null-terminated string version of NameSeg */
ACPI_MOVE_32_TO_32 (Name, Op->Asl.NameSeg);
Name[ACPI_NAMESEG_SIZE] = 0;
/*
* For a GPE method:
* 1st char must be underscore
* 2nd char must be L or E
* 3rd/4th chars must be a hex number
*/
if ((Name[0] != '_') ||
((Name[1] != 'L') && (Name[1] != 'E')))
{
return;
}
/* Verify 3rd/4th chars are a valid hex value */
GpeNumber = strtoul (&Name[2], NULL, 16);
if (GpeNumber == ACPI_UINT32_MAX)
{
return;
}
/*
* We are now sure we have an _Lxx or _Exx.
* Create the target name that would cause collision (Flip E/L)
*/
ACPI_MOVE_32_TO_32 (Target, Name);
/* Inject opposite letter ("L" versus "E") */
if (Name[1] == 'L')
{
Target[1] = 'E';
}
else /* Name[1] == 'E' */
{
Target[1] = 'L';
}
/* Search all peers (objects within this scope) for target match */
NextOp = Op->Asl.Next;
while (NextOp)
{
/*
* We mostly care about methods, but check Name() constructs also,
* even though they will get another error for not being a method.
* All GPE names must be defined as control methods.
*/
if ((NextOp->Asl.ParseOpcode == PARSEOP_METHOD) ||
(NextOp->Asl.ParseOpcode == PARSEOP_NAME))
{
if (ACPI_COMPARE_NAMESEG (Target, NextOp->Asl.NameSeg))
{
/* Found both _Exy and _Lxy in the same scope, error */
AslError (ASL_ERROR, ASL_MSG_GPE_NAME_CONFLICT, NextOp,
Name);
return;
}
}
NextOp = NextOp->Asl.Next;
}
/* OK, no conflict found */
return;
}
/*******************************************************************************
*
* FUNCTION: ApCheckRegMethod
*
* PARAMETERS: Op - Current parse op
*
* RETURN: None
*
* DESCRIPTION: Ensure that a _REG method has a corresponding Operation
* Region declaration within the same scope. Note: _REG is defined
* to have two arguments and must therefore be defined as a
* control method.
*
******************************************************************************/
void
ApCheckRegMethod (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *Next;
ACPI_PARSE_OBJECT *Parent;
/* We are only interested in _REG methods */
if (!ACPI_COMPARE_NAMESEG (METHOD_NAME__REG, &Op->Asl.NameSeg))
{
return;
}
/* Get the start of the current scope */
Parent = Op->Asl.Parent;
Next = Parent->Asl.Child;
/* Search entire scope for an operation region declaration */
while (Next)
{
if (Next->Asl.ParseOpcode == PARSEOP_OPERATIONREGION)
{
return; /* Found region, OK */
}
Next = Next->Asl.Next;
}
/* No region found, issue warning */
AslError (ASL_WARNING, ASL_MSG_NO_REGION, Op, NULL);
}
/*******************************************************************************
*
* FUNCTION: ApFindNameInDeviceTree
*
* PARAMETERS: Name - Name to search for
* Op - Current parse op
*
* RETURN: TRUE if name found in the same scope as Op.
*
* DESCRIPTION: Determine if a name appears in the same scope as Op, as either
* a Method() or a Name(). "Same scope" can mean under an If or
* Else statement.
*
* NOTE: Detects _HID/_ADR in this type of construct (legal in ACPI 6.1+)
*
* Scope (\_SB.PCI0)
* {
* Device (I2C0)
* {
* If (SMD0 != 4) {
* Name (_HID, "INT3442")
* } Else {
* Name (_ADR, 0x400)
* }
* }
* }
******************************************************************************/
BOOLEAN
ApFindNameInDeviceTree (
char *Name,
ACPI_PARSE_OBJECT *Op)
{
ACPI_STATUS Status;
Status = TrWalkParseTree (Op, ASL_WALK_VISIT_DOWNWARD,
ApDeviceSubtreeWalk, NULL, Name);
if (Status == AE_CTRL_TRUE)
{
return (TRUE); /* Found a match */
}
return (FALSE);
}
/* Callback function for interface above */
static ACPI_STATUS
ApDeviceSubtreeWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
char *Name = ACPI_CAST_PTR (char, Context);
switch (Op->Asl.ParseOpcode)
{
case PARSEOP_DEVICE:
/* Level 0 is the starting device, ignore it */
if (Level > 0)
{
/* Ignore sub-devices */
return (AE_CTRL_DEPTH);
}
break;
case PARSEOP_NAME:
case PARSEOP_METHOD:
/* These are what we are looking for */
if (ACPI_COMPARE_NAMESEG (Name, Op->Asl.NameSeg))
{
return (AE_CTRL_TRUE);
}
return (AE_CTRL_DEPTH);
case PARSEOP_SCOPE:
case PARSEOP_FIELD:
case PARSEOP_OPERATIONREGION:
/*
* We want to ignore these, because either they can be large
* subtrees or open a scope to somewhere else.
*/
return (AE_CTRL_DEPTH);
default:
break;
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: ApFindNameInScope
*
* PARAMETERS: Name - Name to search for
* Op - Current parse op
*
* RETURN: TRUE if name found in the same scope as Op.
*
* DESCRIPTION: Determine if a name appears in the same scope as Op, as either
* a Method() or a Name().
*
******************************************************************************/
BOOLEAN
ApFindNameInScope (
char *Name,
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *Next;
ACPI_PARSE_OBJECT *Parent;
/* Get the start of the current scope */
Parent = Op->Asl.Parent;
Next = Parent->Asl.Child;
/* Search entire scope for a match to the name */
while (Next)
{
if ((Next->Asl.ParseOpcode == PARSEOP_METHOD) ||
(Next->Asl.ParseOpcode == PARSEOP_NAME))
{
if (ACPI_COMPARE_NAMESEG (Name, Next->Asl.NameSeg))
{
return (TRUE);
}
}
Next = Next->Asl.Next;
}
return (FALSE);
}

View File

@@ -0,0 +1,399 @@
/******************************************************************************
*
* Module Name: aslascii - ASCII detection and support routines
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include <actables.h>
#include <acapps.h>
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslascii")
/* Local prototypes */
static void
FlConsumeAnsiComment (
FILE *Handle,
ASL_FILE_STATUS *Status);
static void
FlConsumeNewComment (
FILE *Handle,
ASL_FILE_STATUS *Status);
/*******************************************************************************
*
* FUNCTION: FlIsFileAsciiSource
*
* PARAMETERS: Filename - Full input filename
* DisplayErrors - TRUE if error messages desired
*
* RETURN: Status
*
* DESCRIPTION: Verify that the input file is entirely ASCII. Ignores characters
* within comments. Note: does not handle nested comments and does
* not handle comment delimiters within string literals. However,
* on the rare chance this happens and an invalid character is
* missed, the parser will catch the error by failing in some
* spectacular manner.
*
******************************************************************************/
ACPI_STATUS
FlIsFileAsciiSource (
char *Filename,
BOOLEAN DisplayErrors)
{
UINT8 Byte;
UINT32 BadBytes = 0;
BOOLEAN OpeningComment = FALSE;
ASL_FILE_STATUS Status;
FILE *Handle;
/* Open file in text mode so file offset is always accurate */
Handle = fopen (Filename, "rb");
if (!Handle)
{
perror ("Could not open input file");
return (AE_ERROR);
}
Status.Line = 1;
Status.Offset = 0;
/* Read the entire file */
while (fread (&Byte, 1, 1, Handle) == 1)
{
/* Ignore comment fields (allow non-ASCII within) */
if (OpeningComment)
{
/* Check for second comment open delimiter */
if (Byte == '*')
{
FlConsumeAnsiComment (Handle, &Status);
}
if (Byte == '/')
{
FlConsumeNewComment (Handle, &Status);
}
/* Reset */
OpeningComment = FALSE;
}
else if (Byte == '/')
{
OpeningComment = TRUE;
}
/* Check for an ASCII character */
if (!ACPI_IS_ASCII (Byte))
{
if ((BadBytes < 10) && (DisplayErrors))
{
AcpiOsPrintf (
"Found non-ASCII character in source text: "
"0x%2.2X in line %u, file offset 0x%2.2X\n",
Byte, Status.Line, Status.Offset);
}
BadBytes++;
}
/* Ensure character is either printable or a "space" char */
else if (!isprint (Byte) && !isspace (Byte))
{
if ((BadBytes < 10) && (DisplayErrors))
{
AcpiOsPrintf (
"Found invalid character in source text: "
"0x%2.2X in line %u, file offset 0x%2.2X\n",
Byte, Status.Line, Status.Offset);
}
BadBytes++;
}
/* Update line counter as necessary */
if (Byte == 0x0A)
{
Status.Line++;
}
Status.Offset++;
}
fclose (Handle);
/* Were there any non-ASCII characters in the file? */
if (BadBytes)
{
fprintf (stderr,
"File appears to be binary: found %u non-ASCII characters, disassembling\n",
BadBytes);
if (DisplayErrors)
{
AcpiOsPrintf (
"Total %u invalid characters found in input source text, "
"could be a binary file\n", BadBytes);
AslError (ASL_ERROR, ASL_MSG_NON_ASCII, NULL, Filename);
}
return (AE_BAD_CHARACTER);
}
/* File is OK (100% ASCII) */
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: FlConsumeAnsiComment
*
* PARAMETERS: Handle - Open input file
* Status - File current status struct
*
* RETURN: Number of lines consumed
*
* DESCRIPTION: Step over a normal slash-star type comment
*
******************************************************************************/
static void
FlConsumeAnsiComment (
FILE *Handle,
ASL_FILE_STATUS *Status)
{
UINT8 Byte;
BOOLEAN ClosingComment = FALSE;
while (fread (&Byte, 1, 1, Handle) == 1)
{
/* Scan until comment close is found */
if (ClosingComment)
{
if (Byte == '/')
{
Status->Offset++;
return;
}
if (Byte != '*')
{
/* Reset */
ClosingComment = FALSE;
}
}
else if (Byte == '*')
{
ClosingComment = TRUE;
}
/* Maintain line count */
if (Byte == 0x0A)
{
Status->Line++;
}
Status->Offset++;
}
}
/*******************************************************************************
*
* FUNCTION: FlConsumeNewComment
*
* PARAMETERS: Handle - Open input file
* Status - File current status struct
*
* RETURN: Number of lines consumed
*
* DESCRIPTION: Step over a slash-slash type of comment
*
******************************************************************************/
static void
FlConsumeNewComment (
FILE *Handle,
ASL_FILE_STATUS *Status)
{
UINT8 Byte;
while (fread (&Byte, 1, 1, Handle) == 1)
{
Status->Offset++;
/* Comment ends at newline */
if (Byte == 0x0A)
{
Status->Line++;
return;
}
}
}

View File

@@ -0,0 +1,703 @@
/******************************************************************************
*
* Module Name: aslbtypes - Support for bitfield types
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "amlcode.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslbtypes")
/* Local prototypes */
static UINT32
AnMapEtypeToBtype (
UINT32 Etype);
/*******************************************************************************
*
* FUNCTION: AnMapArgTypeToBtype
*
* PARAMETERS: ArgType - The ARGI required type(s) for this
* argument, from the opcode info table
*
* RETURN: The corresponding Bit-encoded types
*
* DESCRIPTION: Convert an encoded ARGI required argument type code into a
* bitfield type code. Implements the implicit source conversion
* rules.
*
******************************************************************************/
UINT32
AnMapArgTypeToBtype (
UINT32 ArgType)
{
switch (ArgType)
{
/* Simple types */
case ARGI_ANYTYPE:
return (ACPI_BTYPE_OBJECTS_AND_REFS);
case ARGI_PACKAGE:
return (ACPI_BTYPE_PACKAGE);
case ARGI_EVENT:
return (ACPI_BTYPE_EVENT);
case ARGI_MUTEX:
return (ACPI_BTYPE_MUTEX);
case ARGI_DDBHANDLE:
/*
* DDBHandleObject := SuperName
* ACPI_BTYPE_REFERENCE_OBJECT:
* Index reference as parameter of Load/Unload
*/
return (ACPI_BTYPE_DDB_HANDLE | ACPI_BTYPE_REFERENCE_OBJECT);
/* Interchangeable types */
/*
* Source conversion rules:
* Integer, String, and Buffer are all interchangeable
*/
case ARGI_INTEGER:
case ARGI_STRING:
case ARGI_BUFFER:
case ARGI_BUFFER_OR_STRING:
case ARGI_COMPUTEDATA:
return (ACPI_BTYPE_COMPUTE_DATA);
/* References */
case ARGI_INTEGER_REF:
return (ACPI_BTYPE_INTEGER);
case ARGI_OBJECT_REF:
return (ACPI_BTYPE_ALL_OBJECTS);
case ARGI_DEVICE_REF:
return (ACPI_BTYPE_DEVICE_OBJECTS);
case ARGI_REFERENCE:
return (ACPI_BTYPE_NAMED_REFERENCE); /* Name or Namestring */
case ARGI_TARGETREF:
/*
* Target operand for most math and logic operators.
* Package objects not allowed as target.
*/
return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_DEBUG_OBJECT |
ACPI_BTYPE_REFERENCE_OBJECT);
case ARGI_STORE_TARGET:
/* Special target for Store(), includes packages */
return (ACPI_BTYPE_DATA | ACPI_BTYPE_DEBUG_OBJECT |
ACPI_BTYPE_REFERENCE_OBJECT);
case ARGI_FIXED_TARGET:
case ARGI_SIMPLE_TARGET:
return (ACPI_BTYPE_OBJECTS_AND_REFS);
/* Complex types */
case ARGI_DATAOBJECT:
/*
* Buffer, string, package or reference to a Op -
* Used only by SizeOf operator
*/
return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER |
ACPI_BTYPE_PACKAGE | ACPI_BTYPE_REFERENCE_OBJECT);
case ARGI_COMPLEXOBJ:
/* Buffer, String, or package */
return (ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER |
ACPI_BTYPE_PACKAGE);
case ARGI_REF_OR_STRING:
/* Used by DeRefOf operator only */
return (ACPI_BTYPE_STRING | ACPI_BTYPE_REFERENCE_OBJECT);
case ARGI_REGION_OR_BUFFER:
/* Used by Load() only. Allow buffers in addition to regions/fields */
return (ACPI_BTYPE_REGION | ACPI_BTYPE_BUFFER |
ACPI_BTYPE_FIELD_UNIT);
case ARGI_DATAREFOBJ:
/* Used by Store() only, as the source operand */
return (ACPI_BTYPE_DATA_REFERENCE | ACPI_BTYPE_REFERENCE_OBJECT);
default:
break;
}
return (ACPI_BTYPE_OBJECTS_AND_REFS);
}
/*******************************************************************************
*
* FUNCTION: AnMapEtypeToBtype
*
* PARAMETERS: Etype - Encoded ACPI Type
*
* RETURN: Btype corresponding to the Etype
*
* DESCRIPTION: Convert an encoded ACPI type to a bitfield type applying the
* operand conversion rules. In other words, returns the type(s)
* this Etype is implicitly converted to during interpretation.
*
******************************************************************************/
static UINT32
AnMapEtypeToBtype (
UINT32 Etype)
{
if (Etype == ACPI_TYPE_ANY)
{
return (ACPI_BTYPE_OBJECTS_AND_REFS);
}
/* Try the standard ACPI data types */
if (Etype <= ACPI_TYPE_EXTERNAL_MAX)
{
/*
* This switch statement implements the allowed operand conversion
* rules as per the "ASL Data Types" section of the ACPI
* specification.
*/
switch (Etype)
{
case ACPI_TYPE_INTEGER:
return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_DDB_HANDLE);
case ACPI_TYPE_STRING:
case ACPI_TYPE_BUFFER:
return (ACPI_BTYPE_COMPUTE_DATA);
case ACPI_TYPE_PACKAGE:
return (ACPI_BTYPE_PACKAGE);
case ACPI_TYPE_FIELD_UNIT:
return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_FIELD_UNIT);
case ACPI_TYPE_BUFFER_FIELD:
return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_BUFFER_FIELD);
case ACPI_TYPE_DDB_HANDLE:
return (ACPI_BTYPE_INTEGER | ACPI_BTYPE_DDB_HANDLE);
case ACPI_TYPE_DEBUG_OBJECT:
/* Cannot be used as a source operand */
return (0);
default:
return (1 << (Etype - 1));
}
}
/* Try the internal data types */
switch (Etype)
{
case ACPI_TYPE_LOCAL_REGION_FIELD:
case ACPI_TYPE_LOCAL_BANK_FIELD:
case ACPI_TYPE_LOCAL_INDEX_FIELD:
/* Named fields can be either Integer/Buffer/String */
return (ACPI_BTYPE_COMPUTE_DATA | ACPI_BTYPE_FIELD_UNIT);
case ACPI_TYPE_LOCAL_ALIAS:
return (ACPI_BTYPE_INTEGER);
case ACPI_TYPE_LOCAL_RESOURCE:
case ACPI_TYPE_LOCAL_RESOURCE_FIELD:
return (ACPI_BTYPE_REFERENCE_OBJECT);
default:
printf ("Unhandled encoded type: %X\n", Etype);
return (0);
}
}
/*******************************************************************************
*
* FUNCTION: AnFormatBtype
*
* PARAMETERS: Btype - Bitfield of ACPI types
* Buffer - Where to put the ascii string
*
* RETURN: None.
*
* DESCRIPTION: Convert a Btype to a string of ACPI types
*
******************************************************************************/
void
AnFormatBtype (
char *Buffer,
UINT32 Btype)
{
UINT32 Type;
BOOLEAN First = TRUE;
*Buffer = 0;
if (Btype == 0)
{
strcat (Buffer, "NoReturnValue");
return;
}
for (Type = 1; Type <= ACPI_TYPE_EXTERNAL_MAX; Type++)
{
if (Btype & 0x00000001)
{
if (!First)
{
strcat (Buffer, "|");
}
First = FALSE;
strcat (Buffer, AcpiUtGetTypeName (Type));
}
Btype >>= 1;
}
if (Btype & 0x00000001)
{
if (!First)
{
strcat (Buffer, "|");
}
First = FALSE;
strcat (Buffer, "Reference");
}
Btype >>= 1;
if (Btype & 0x00000001)
{
if (!First)
{
strcat (Buffer, "|");
}
strcat (Buffer, "Resource");
}
}
/*******************************************************************************
*
* FUNCTION: AnGetBtype
*
* PARAMETERS: Op - Parse node whose type will be returned.
*
* RETURN: The Btype associated with the Op.
*
* DESCRIPTION: Get the (bitfield) ACPI type associated with the parse node.
* Handles the case where the node is a name or method call and
* the actual type must be obtained from the namespace node.
*
******************************************************************************/
UINT32
AnGetBtype (
ACPI_PARSE_OBJECT *Op)
{
ACPI_NAMESPACE_NODE *Node;
ACPI_PARSE_OBJECT *ReferencedNode;
UINT32 ThisNodeBtype = 0;
ACPI_FUNCTION_NAME (AnGetBtype);
if (!Op)
{
AcpiOsPrintf ("Null Op in %s\n", ACPI_GET_FUNCTION_NAME);
return (ACPI_UINT32_MAX);
}
if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
(Op->Asl.ParseOpcode == PARSEOP_NAMESTRING) ||
(Op->Asl.ParseOpcode == PARSEOP_METHODCALL))
{
Node = Op->Asl.Node;
if (!Node)
{
/* These are not expected to have a node at this time */
if ((Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CREATEWORDFIELD) ||
(Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CREATEDWORDFIELD) ||
(Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CREATEQWORDFIELD) ||
(Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CREATEBYTEFIELD) ||
(Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CREATEBITFIELD) ||
(Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CREATEFIELD) ||
(Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_CONDREFOF))
{
return (ACPI_UINT32_MAX - 1);
}
DbgPrint (ASL_DEBUG_OUTPUT,
"No attached Nsnode: [%s] at line %u name [%s], "
"ignoring typecheck. Parent [%s]\n",
Op->Asl.ParseOpName, Op->Asl.LineNumber,
Op->Asl.ExternalName, Op->Asl.Parent->Asl.ParseOpName);
return (ACPI_UINT32_MAX - 1);
}
ThisNodeBtype = AnMapEtypeToBtype (Node->Type);
if (!ThisNodeBtype)
{
AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op,
"could not map type");
}
if (Op->Asl.ParseOpcode == PARSEOP_METHODCALL)
{
ReferencedNode = Node->Op;
if (!ReferencedNode)
{
/* Check for an internal method */
if (AnIsInternalMethod (Op))
{
return (AnGetInternalMethodReturnType (Op));
}
AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op,
"null Op pointer");
return (ACPI_UINT32_MAX);
}
if (ReferencedNode->Asl.CompileFlags & OP_METHOD_TYPED)
{
ThisNodeBtype = ReferencedNode->Asl.AcpiBtype;
}
else
{
return (ACPI_UINT32_MAX -1);
}
}
}
else
{
ThisNodeBtype = Op->Asl.AcpiBtype;
}
return (ThisNodeBtype);
}
/*******************************************************************************
*
* FUNCTION: AnMapObjTypeToBtype
*
* PARAMETERS: Op - A parse node
*
* RETURN: A Btype
*
* DESCRIPTION: Map object to the associated "Btype"
*
******************************************************************************/
UINT32
AnMapObjTypeToBtype (
ACPI_PARSE_OBJECT *Op)
{
switch (Op->Asl.ParseOpcode)
{
case PARSEOP_OBJECTTYPE_BFF: /* "BuffFieldObj" */
return (ACPI_BTYPE_BUFFER_FIELD);
case PARSEOP_OBJECTTYPE_BUF: /* "BuffObj" */
return (ACPI_BTYPE_BUFFER);
case PARSEOP_OBJECTTYPE_DDB: /* "DDBHandleObj" */
return (ACPI_BTYPE_DDB_HANDLE);
case PARSEOP_OBJECTTYPE_DEV: /* "DeviceObj" */
return (ACPI_BTYPE_DEVICE);
case PARSEOP_OBJECTTYPE_EVT: /* "EventObj" */
return (ACPI_BTYPE_EVENT);
case PARSEOP_OBJECTTYPE_FLD: /* "FieldUnitObj" */
return (ACPI_BTYPE_FIELD_UNIT);
case PARSEOP_OBJECTTYPE_INT: /* "IntObj" */
return (ACPI_BTYPE_INTEGER);
case PARSEOP_OBJECTTYPE_MTH: /* "MethodObj" */
return (ACPI_BTYPE_METHOD);
case PARSEOP_OBJECTTYPE_MTX: /* "MutexObj" */
return (ACPI_BTYPE_MUTEX);
case PARSEOP_OBJECTTYPE_OPR: /* "OpRegionObj" */
return (ACPI_BTYPE_REGION);
case PARSEOP_OBJECTTYPE_PKG: /* "PkgObj" */
return (ACPI_BTYPE_PACKAGE);
case PARSEOP_OBJECTTYPE_POW: /* "PowerResObj" */
return (ACPI_BTYPE_POWER);
case PARSEOP_OBJECTTYPE_STR: /* "StrObj" */
return (ACPI_BTYPE_STRING);
case PARSEOP_OBJECTTYPE_THZ: /* "ThermalZoneObj" */
return (ACPI_BTYPE_THERMAL);
case PARSEOP_OBJECTTYPE_UNK: /* "UnknownObj" */
return (ACPI_BTYPE_OBJECTS_AND_REFS);
default:
return (0);
}
}
#ifdef ACPI_OBSOLETE_FUNCTIONS
/*******************************************************************************
*
* FUNCTION: AnMapBtypeToEtype
*
* PARAMETERS: Btype - Bitfield of ACPI types
*
* RETURN: The Etype corresponding the Btype
*
* DESCRIPTION: Convert a bitfield type to an encoded type
*
******************************************************************************/
UINT32
AnMapBtypeToEtype (
UINT32 Btype)
{
UINT32 i;
UINT32 Etype;
if (Btype == 0)
{
return (0);
}
Etype = 1;
for (i = 1; i < Btype; i *= 2)
{
Etype++;
}
return (Etype);
}
#endif

View File

@@ -0,0 +1,484 @@
/******************************************************************************
*
* Module Name: aslcache -- Local cache support for iASL
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
/*
* Local caches. The caches are fully deleted after the compilation/disassembly
* of each individual input file. Thus, individual allocations from the cache
* memory do not need to be freed or even released back into the cache.
*
* See aslallocate.c for standard heap allocations.
*/
/*******************************************************************************
*
* FUNCTION: UtLocalCacheCalloc
*
* PARAMETERS: Length - Size of buffer requested
*
* RETURN: Pointer to the buffer. Aborts compiler on allocation failure
*
* DESCRIPTION: Allocate a string buffer. Bypass the local
* dynamic memory manager for performance reasons (This has a
* major impact on the speed of the compiler.)
*
******************************************************************************/
char *
UtLocalCacheCalloc (
UINT32 Length)
{
char *Buffer;
ASL_CACHE_INFO *Cache;
UINT32 CacheSize = ASL_STRING_CACHE_SIZE;
#ifdef ACPI_MISALIGNMENT_NOT_SUPPORTED
/* Used for objects other than strings, so keep allocations aligned */
Length = ACPI_ROUND_UP_TO_NATIVE_WORD (Length);
#endif
if (Length > CacheSize)
{
CacheSize = Length;
if (AslGbl_StringCacheList)
{
Cache = UtLocalCalloc (sizeof (Cache->Next) + CacheSize);
/* Link new cache buffer just following head of list */
Cache->Next = AslGbl_StringCacheList->Next;
AslGbl_StringCacheList->Next = Cache;
/* Leave cache management pointers alone as they pertain to head */
AslGbl_StringCount++;
AslGbl_StringSize += Length;
return (Cache->Buffer);
}
}
if ((!AslGbl_StringCacheNext) ||
((AslGbl_StringCacheNext + Length) >= AslGbl_StringCacheLast))
{
/* Allocate a new buffer */
Cache = UtLocalCalloc (sizeof (Cache->Next) + CacheSize);
/* Link new cache buffer to head of list */
Cache->Next = AslGbl_StringCacheList;
AslGbl_StringCacheList = Cache;
/* Setup cache management pointers */
AslGbl_StringCacheNext = Cache->Buffer;
AslGbl_StringCacheLast = AslGbl_StringCacheNext + CacheSize;
}
AslGbl_StringCount++;
AslGbl_StringSize += Length;
Buffer = AslGbl_StringCacheNext;
AslGbl_StringCacheNext += Length;
return (Buffer);
}
/*******************************************************************************
*
* FUNCTION: UtParseOpCacheCalloc
*
* PARAMETERS: None
*
* RETURN: New parse op. Aborts on allocation failure
*
* DESCRIPTION: Allocate a new parse op for the parse tree. Bypass the local
* dynamic memory manager for performance reasons (This has a
* major impact on the speed of the compiler.)
*
******************************************************************************/
ACPI_PARSE_OBJECT *
UtParseOpCacheCalloc (
void)
{
ASL_CACHE_INFO *Cache;
if (AslGbl_ParseOpCacheNext >= AslGbl_ParseOpCacheLast)
{
/* Allocate a new buffer */
Cache = UtLocalCalloc (sizeof (Cache->Next) +
(sizeof (ACPI_PARSE_OBJECT) * ASL_PARSEOP_CACHE_SIZE));
/* Link new cache buffer to head of list */
Cache->Next = AslGbl_ParseOpCacheList;
AslGbl_ParseOpCacheList = Cache;
/* Setup cache management pointers */
AslGbl_ParseOpCacheNext = ACPI_CAST_PTR (ACPI_PARSE_OBJECT, Cache->Buffer);
AslGbl_ParseOpCacheLast = AslGbl_ParseOpCacheNext + ASL_PARSEOP_CACHE_SIZE;
}
AslGbl_ParseOpCount++;
return (AslGbl_ParseOpCacheNext++);
}
/*******************************************************************************
*
* FUNCTION: UtSubtableCacheCalloc - Data Table compiler
*
* PARAMETERS: None
*
* RETURN: Pointer to the buffer. Aborts on allocation failure
*
* DESCRIPTION: Allocate a subtable object buffer. Bypass the local
* dynamic memory manager for performance reasons (This has a
* major impact on the speed of the compiler.)
*
******************************************************************************/
DT_SUBTABLE *
UtSubtableCacheCalloc (
void)
{
ASL_CACHE_INFO *Cache;
if (AslGbl_SubtableCacheNext >= AslGbl_SubtableCacheLast)
{
/* Allocate a new buffer */
Cache = UtLocalCalloc (sizeof (Cache->Next) +
(sizeof (DT_SUBTABLE) * ASL_SUBTABLE_CACHE_SIZE));
/* Link new cache buffer to head of list */
Cache->Next = AslGbl_SubtableCacheList;
AslGbl_SubtableCacheList = Cache;
/* Setup cache management pointers */
AslGbl_SubtableCacheNext = ACPI_CAST_PTR (DT_SUBTABLE, Cache->Buffer);
AslGbl_SubtableCacheLast = AslGbl_SubtableCacheNext + ASL_SUBTABLE_CACHE_SIZE;
}
AslGbl_SubtableCount++;
return (AslGbl_SubtableCacheNext++);
}
/*******************************************************************************
*
* FUNCTION: UtFieldCacheCalloc - Data Table compiler
*
* PARAMETERS: None
*
* RETURN: Pointer to the buffer. Aborts on allocation failure
*
* DESCRIPTION: Allocate a field object buffer. Bypass the local
* dynamic memory manager for performance reasons (This has a
* major impact on the speed of the compiler.)
*
******************************************************************************/
DT_FIELD *
UtFieldCacheCalloc (
void)
{
ASL_CACHE_INFO *Cache;
if (AslGbl_FieldCacheNext >= AslGbl_FieldCacheLast)
{
/* Allocate a new buffer */
Cache = UtLocalCalloc (sizeof (Cache->Next) +
(sizeof (DT_FIELD) * ASL_FIELD_CACHE_SIZE));
/* Link new cache buffer to head of list */
Cache->Next = AslGbl_FieldCacheList;
AslGbl_FieldCacheList = Cache;
/* Setup cache management pointers */
AslGbl_FieldCacheNext = ACPI_CAST_PTR (DT_FIELD, Cache->Buffer);
AslGbl_FieldCacheLast =AslGbl_FieldCacheNext + ASL_FIELD_CACHE_SIZE;
}
AslGbl_FieldCount++;
return (AslGbl_FieldCacheNext++);
}
/*******************************************************************************
*
* FUNCTION: UtDeleteLocalCaches
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Delete all local cache buffer blocks
*
******************************************************************************/
void
UtDeleteLocalCaches (
void)
{
UINT32 BufferCount;
ASL_CACHE_INFO *Next;
/*
* Generic cache, arbitrary size allocations
*/
BufferCount = 0;
while (AslGbl_StringCacheList)
{
Next = AslGbl_StringCacheList->Next;
ACPI_FREE (AslGbl_StringCacheList);
AslGbl_StringCacheList = Next;
BufferCount++;
}
DbgPrint (ASL_DEBUG_OUTPUT,
"%u Strings (%u bytes), Buffer size: %u bytes, %u Buffers\n",
AslGbl_StringCount, AslGbl_StringSize, ASL_STRING_CACHE_SIZE, BufferCount);
/* Reset cache globals */
AslGbl_StringSize = 0;
AslGbl_StringCount = 0;
AslGbl_StringCacheNext = NULL;
AslGbl_StringCacheLast = NULL;
/*
* Parse Op cache
*/
BufferCount = 0;
while (AslGbl_ParseOpCacheList)
{
Next = AslGbl_ParseOpCacheList->Next;
ACPI_FREE (AslGbl_ParseOpCacheList);
AslGbl_ParseOpCacheList = Next;
BufferCount++;
}
DbgPrint (ASL_DEBUG_OUTPUT,
"%u ParseOps, Buffer size: %u ops (%u bytes), %u Buffers\n",
AslGbl_ParseOpCount, ASL_PARSEOP_CACHE_SIZE,
((UINT32) sizeof (ACPI_PARSE_OBJECT) * ASL_PARSEOP_CACHE_SIZE), BufferCount);
/* Reset cache globals */
AslGbl_ParseOpCount = 0;
AslGbl_ParseOpCacheNext = NULL;
AslGbl_ParseOpCacheLast = NULL;
AslGbl_ParseTreeRoot = NULL;
/*
* Table Compiler - Field cache
*/
BufferCount = 0;
while (AslGbl_FieldCacheList)
{
Next = AslGbl_FieldCacheList->Next;
ACPI_FREE (AslGbl_FieldCacheList);
AslGbl_FieldCacheList = Next;
BufferCount++;
}
DbgPrint (ASL_DEBUG_OUTPUT,
"%u Fields, Buffer size: %u fields (%u bytes), %u Buffers\n",
AslGbl_FieldCount, ASL_FIELD_CACHE_SIZE,
((UINT32) sizeof (DT_FIELD) * ASL_FIELD_CACHE_SIZE), BufferCount);
/* Reset cache globals */
AslGbl_FieldCount = 0;
AslGbl_FieldCacheNext = NULL;
AslGbl_FieldCacheLast = NULL;
/*
* Table Compiler - Subtable cache
*/
BufferCount = 0;
while (AslGbl_SubtableCacheList)
{
Next = AslGbl_SubtableCacheList->Next;
ACPI_FREE (AslGbl_SubtableCacheList);
AslGbl_SubtableCacheList = Next;
BufferCount++;
}
DbgPrint (ASL_DEBUG_OUTPUT,
"%u Subtables, Buffer size: %u subtables (%u bytes), %u Buffers\n",
AslGbl_SubtableCount, ASL_SUBTABLE_CACHE_SIZE,
((UINT32) sizeof (DT_SUBTABLE) * ASL_SUBTABLE_CACHE_SIZE), BufferCount);
/* Reset cache globals */
AslGbl_SubtableCount = 0;
AslGbl_SubtableCacheNext = NULL;
AslGbl_SubtableCacheLast = NULL;
}

View File

@@ -0,0 +1,891 @@
/******************************************************************************
*
* Module Name: aslcodegen - AML code generation
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "amlcode.h"
#include "acconvert.h"
#include "actbinfo.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslcodegen")
/* Local prototypes */
static ACPI_STATUS
CgAmlWriteWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context);
static void
CgWriteAmlOpcode (
ACPI_PARSE_OBJECT *Op);
static void
CgWriteTableHeader (
ACPI_PARSE_OBJECT *Op);
static void
CgWriteNode (
ACPI_PARSE_OBJECT *Op);
static void
CgUpdateHeader (
ACPI_PARSE_OBJECT *Op);
static void
CgUpdateCdatHeader (
ACPI_PARSE_OBJECT *Op);
/*******************************************************************************
*
* FUNCTION: CgGenerateAmlOutput
*
* PARAMETERS: None.
*
* RETURN: None
*
* DESCRIPTION: Generate AML code. Currently generates the listing file
* simultaneously.
*
******************************************************************************/
void
CgGenerateAmlOutput (
void)
{
/* Generate the AML output file */
TrWalkParseTree (AslGbl_CurrentDB,
ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_DB_SEPARATELY,
CgAmlWriteWalk, NULL, NULL);
DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_HEADER2);
if (AcpiGbl_CDAT)
{
CgUpdateCdatHeader (AslGbl_CurrentDB);
}
else
{
CgUpdateHeader (AslGbl_CurrentDB);
}
}
/*******************************************************************************
*
* FUNCTION: CgAmlWriteWalk
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Parse tree walk to generate the AML code.
*
******************************************************************************/
static ACPI_STATUS
CgAmlWriteWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
/* Generate the AML for this node */
CgWriteNode (Op);
if (!AslGbl_DebugFlag)
{
return (AE_OK);
}
/* Print header at level 0. Alignment assumes 32-bit pointers */
if (!Level)
{
DbgPrint (ASL_TREE_OUTPUT,
"\nFinal parse tree used for AML output:\n");
DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_HEADER2);
}
/* Dump ParseOp name and possible value */
switch (Op->Asl.ParseOpcode)
{
case PARSEOP_NAMESEG:
case PARSEOP_NAMESTRING:
case PARSEOP_METHODCALL:
case PARSEOP_STRING_LITERAL:
UtDumpStringOp (Op, Level);
break;
default:
UtDumpBasicOp (Op, Level);
break;
}
DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_DEBUG2,
/* 1 */ (UINT32) Op->Asl.Value.Integer,
/* 2 */ Op->Asl.ParseOpcode,
/* 3 */ Op->Asl.AmlOpcode,
/* 4 */ Op->Asl.AmlOpcodeLength,
/* 5 */ Op->Asl.AmlPkgLenBytes,
/* 6 */ Op->Asl.AmlLength,
/* 7 */ Op->Asl.AmlSubtreeLength,
/* 8 */ Op->Asl.Parent ? Op->Asl.Parent->Asl.AmlSubtreeLength : 0,
/* 9 */ Op,
/* 10 */ Op->Asl.Parent,
/* 11 */ Op->Asl.Child,
/* 12 */ Op->Asl.Next,
/* 13 */ Op->Asl.CompileFlags,
/* 14 */ Op->Asl.AcpiBtype,
/* 15 */ Op->Asl.FinalAmlLength,
/* 16 */ Op->Asl.Column,
/* 17 */ Op->Asl.LineNumber,
/* 18 */ Op->Asl.EndLine,
/* 19 */ Op->Asl.LogicalLineNumber,
/* 20 */ Op->Asl.EndLogicalLine);
TrPrintOpFlags (Op->Asl.CompileFlags, ASL_TREE_OUTPUT);
DbgPrint (ASL_TREE_OUTPUT, "\n");
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: CgLocalWriteAmlData
*
* PARAMETERS: Op - Current parse op
* Buffer - Buffer to write
* Length - Size of data in buffer
*
* RETURN: None
*
* DESCRIPTION: Write a buffer of AML data to the AML output file.
*
******************************************************************************/
void
CgLocalWriteAmlData (
ACPI_PARSE_OBJECT *Op,
void *Buffer,
UINT32 Length)
{
/* Write the raw data to the AML file */
FlWriteFile (ASL_FILE_AML_OUTPUT, Buffer, Length);
/* Update the final AML length for this node (used for listings) */
if (Op)
{
Op->Asl.FinalAmlLength += Length;
}
}
/*******************************************************************************
*
* FUNCTION: CgWriteAmlOpcode
*
* PARAMETERS: Op - Parse node with an AML opcode
*
* RETURN: None.
*
* DESCRIPTION: Write the AML opcode corresponding to a parse node.
*
******************************************************************************/
static void
CgWriteAmlOpcode (
ACPI_PARSE_OBJECT *Op)
{
UINT8 PkgLenFirstByte;
UINT32 i;
union {
UINT16 Opcode;
UINT8 OpcodeBytes[2];
} Aml;
union {
UINT32 Len;
UINT8 LenBytes[4];
} PkgLen;
/* We expect some DEFAULT_ARGs, just ignore them */
if (Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
{
return;
}
/*
* Before printing the bytecode, generate comment byte codes
* associated with this node.
*/
if (AcpiGbl_CaptureComments)
{
CgWriteAmlComment(Op);
}
switch (Op->Asl.AmlOpcode)
{
case AML_UNASSIGNED_OPCODE:
/* These opcodes should not get here */
printf ("Found a node with an unassigned AML opcode\n");
FlPrintFile (ASL_FILE_STDERR,
"Found a node with an unassigned AML opcode\n");
return;
case AML_INT_RESERVEDFIELD_OP:
/* Special opcodes for within a field definition */
Aml.Opcode = AML_FIELD_OFFSET_OP;
break;
case AML_INT_ACCESSFIELD_OP:
Aml.Opcode = AML_FIELD_ACCESS_OP;
break;
case AML_INT_CONNECTION_OP:
Aml.Opcode = AML_FIELD_CONNECTION_OP;
break;
default:
Aml.Opcode = Op->Asl.AmlOpcode;
break;
}
switch (Aml.Opcode)
{
case AML_PACKAGE_LENGTH:
/* Value is the length to be encoded (Used in field definitions) */
PkgLen.Len = (UINT32) Op->Asl.Value.Integer;
break;
default:
/* Check for two-byte opcode */
if (Aml.Opcode > 0x00FF)
{
/* Write the high byte first */
CgLocalWriteAmlData (Op, &Aml.OpcodeBytes[1], 1);
}
CgLocalWriteAmlData (Op, &Aml.OpcodeBytes[0], 1);
/* Subtreelength doesn't include length of package length bytes */
PkgLen.Len = Op->Asl.AmlSubtreeLength + Op->Asl.AmlPkgLenBytes;
break;
}
/* Does this opcode have an associated "PackageLength" field? */
if (Op->Asl.CompileFlags & OP_AML_PACKAGE)
{
if (Op->Asl.AmlPkgLenBytes == 1)
{
/* Simplest case -- no bytes to follow, just write the count */
CgLocalWriteAmlData (Op, &PkgLen.LenBytes[0], 1);
}
else if (Op->Asl.AmlPkgLenBytes != 0)
{
/*
* Encode the "bytes to follow" in the first byte, top two bits.
* The low-order nybble of the length is in the bottom 4 bits
*/
PkgLenFirstByte = (UINT8)
(((UINT32) (Op->Asl.AmlPkgLenBytes - 1) << 6) |
(PkgLen.LenBytes[0] & 0x0F));
CgLocalWriteAmlData (Op, &PkgLenFirstByte, 1);
/*
* Shift the length over by the 4 bits we just stuffed
* in the first byte
*/
PkgLen.Len >>= 4;
/*
* Now we can write the remaining bytes -
* either 1, 2, or 3 bytes
*/
for (i = 0; i < (UINT32) (Op->Asl.AmlPkgLenBytes - 1); i++)
{
CgLocalWriteAmlData (Op, &PkgLen.LenBytes[i], 1);
}
}
}
switch (Aml.Opcode)
{
case AML_BYTE_OP:
CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 1);
break;
case AML_WORD_OP:
CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 2);
break;
case AML_DWORD_OP:
CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 4);
break;
case AML_QWORD_OP:
CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, 8);
break;
case AML_STRING_OP:
CgLocalWriteAmlData (Op, Op->Asl.Value.String, Op->Asl.AmlLength);
break;
default:
/* All data opcodes must appear above */
break;
}
}
/*******************************************************************************
*
* FUNCTION: CgWriteTableHeader
*
* PARAMETERS: Op - The DEFINITIONBLOCK node
*
* RETURN: None
*
* DESCRIPTION: Write a table header corresponding to the DEFINITIONBLOCK
*
* NOTE: Input strings should be validated before this function is invoked.
*
******************************************************************************/
static void
CgWriteTableHeader (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *Child;
UINT32 CommentLength;
ACPI_COMMENT_NODE *Current;
memset (&AslGbl_TableHeader, 0, sizeof (ACPI_TABLE_HEADER));
/* AML filename */
Child = Op->Asl.Child;
/* Signature */
Child = Child->Asl.Next;
/*
* For ASL-/ASL+ converter: replace the table signature with
* "XXXX" and save the original table signature. This results in an AML
* file with the signature "XXXX". The converter should remove this AML
* file. In the event where this AML file does not get deleted, the
* "XXXX" table signature prevents this AML file from running on the AML
* interpreter.
*/
if (AcpiGbl_CaptureComments)
{
ACPI_COPY_NAMESEG (AcpiGbl_TableSig, Child->Asl.Value.String);
Child->Asl.Value.String = ACPI_SIG_XXXX;
}
ACPI_COPY_NAMESEG (AslGbl_TableHeader.Signature, Child->Asl.Value.String);
/* Revision */
Child = Child->Asl.Next;
AslGbl_TableHeader.Revision = (UINT8) Child->Asl.Value.Integer;
/* Command-line Revision override */
if (AslGbl_RevisionOverride)
{
AslGbl_TableHeader.Revision = AslGbl_RevisionOverride;
}
/* OEMID */
Child = Child->Asl.Next;
memcpy (AslGbl_TableHeader.OemId, Child->Asl.Value.String,
strlen (Child->Asl.Value.String));
/* OEM TableID */
Child = Child->Asl.Next;
memcpy (AslGbl_TableHeader.OemTableId, Child->Asl.Value.String,
strlen (Child->Asl.Value.String));
/* OEM Revision */
Child = Child->Asl.Next;
AslGbl_TableHeader.OemRevision = (UINT32) Child->Asl.Value.Integer;
/* Compiler ID */
ACPI_COPY_NAMESEG (AslGbl_TableHeader.AslCompilerId, ASL_CREATOR_ID);
/* Compiler version */
AslGbl_TableHeader.AslCompilerRevision = ACPI_CA_VERSION;
/* Table length. Checksum zero for now, will rewrite later */
AslGbl_TableHeader.Length = sizeof (ACPI_TABLE_HEADER) +
Op->Asl.AmlSubtreeLength;
/* Calculate the comment lengths for this definition block parseOp */
if (AcpiGbl_CaptureComments)
{
CvDbgPrint ("Calculating comment lengths for %s in write header\n",
Op->Asl.ParseOpName);
/*
* Take the filename without extensions, add 3 for the new extension
* and another 3 for the a908 bytecode and null terminator.
*/
AslGbl_TableHeader.Length += strrchr (AslGbl_ParseTreeRoot->Asl.Filename, '.')
- AslGbl_ParseTreeRoot->Asl.Filename + 1 + 3 + 3;
Op->Asl.AmlSubtreeLength +=
strlen (AslGbl_ParseTreeRoot->Asl.Filename) + 3;
CvDbgPrint (" Length: %u\n",
(UINT32) strlen (AslGbl_ParseTreeRoot->Asl.Filename) + 3);
if (Op->Asl.CommentList)
{
Current = Op->Asl.CommentList;
while (Current)
{
CommentLength = strlen (Current->Comment)+3;
CvDbgPrint ("Length of standard comment): %d\n", CommentLength);
CvDbgPrint (" Comment string: %s\n\n", Current->Comment);
AslGbl_TableHeader.Length += CommentLength;
Op->Asl.AmlSubtreeLength += CommentLength;
Current = Current->Next;
CvDbgPrint (" Length: %u\n", CommentLength);
}
}
if (Op->Asl.CloseBraceComment)
{
CommentLength = strlen (Op->Asl.CloseBraceComment)+3;
CvDbgPrint ("Length of inline comment +3: %d\n", CommentLength);
CvDbgPrint (" Comment string: %s\n\n", Op->Asl.CloseBraceComment);
AslGbl_TableHeader.Length += CommentLength;
Op->Asl.AmlSubtreeLength += CommentLength;
CvDbgPrint (" Length: %u\n", CommentLength);
}
}
AslGbl_TableHeader.Checksum = 0;
Op->Asl.FinalAmlOffset = ftell (AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle);
/* Write entire header and clear the table header global */
CgLocalWriteAmlData (Op, &AslGbl_TableHeader, sizeof (ACPI_TABLE_HEADER));
memset (&AslGbl_TableHeader, 0, sizeof (ACPI_TABLE_HEADER));
}
/*******************************************************************************
*
* FUNCTION: CgUpdateCdatHeader
*
* PARAMETERS: Op - Op for the Definition Block
*
* RETURN: None.
*
* DESCRIPTION: Complete the ACPI table by calculating the checksum and
* re-writing the header for the input definition block
*
******************************************************************************/
static void
CgUpdateCdatHeader (
ACPI_PARSE_OBJECT *Op)
{
signed char Sum;
UINT32 i;
UINT32 Length;
UINT8 FileByte;
UINT8 Checksum;
/* Calculate the checksum over the entire definition block */
Sum = 0;
Length = sizeof (ACPI_TABLE_CDAT) + Op->Asl.AmlSubtreeLength;
FlSeekFile (ASL_FILE_AML_OUTPUT, Op->Asl.FinalAmlOffset);
for (i = 0; i < Length; i++)
{
if (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1) != AE_OK)
{
AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, NULL,
"Table length is greater than size of the input file");
return;
}
Sum = (signed char) (Sum + FileByte);
}
Checksum = (UINT8) (0 - Sum);
DbgPrint (ASL_DEBUG_OUTPUT, "Computed checksum = %X\n", Checksum);
/* Re-write the checksum byte */
FlSeekFile (ASL_FILE_AML_OUTPUT, Op->Asl.FinalAmlOffset +
ACPI_CDAT_OFFSET (Checksum));
FlWriteFile (ASL_FILE_AML_OUTPUT, &Checksum, 1);
/*
* Seek to the end of the file. This is done to support multiple file
* compilation. Doing this simplifies other parts of the codebase because
* it eliminates the need to seek for a different starting place.
*/
FlSeekFile (ASL_FILE_AML_OUTPUT, Op->Asl.FinalAmlOffset + Length);
}
/*******************************************************************************
*
* FUNCTION: CgUpdateHeader
*
* PARAMETERS: Op - Op for the Definition Block
*
* RETURN: None.
*
* DESCRIPTION: Complete the ACPI table by calculating the checksum and
* re-writing the header for the input definition block
*
******************************************************************************/
static void
CgUpdateHeader (
ACPI_PARSE_OBJECT *Op)
{
signed char Sum;
UINT32 i;
UINT32 Length;
UINT8 FileByte;
UINT8 Checksum;
/* Calculate the checksum over the entire definition block */
Sum = 0;
Length = sizeof (ACPI_TABLE_HEADER) + Op->Asl.AmlSubtreeLength;
FlSeekFile (ASL_FILE_AML_OUTPUT, Op->Asl.FinalAmlOffset);
for (i = 0; i < Length; i++)
{
if (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1) != AE_OK)
{
AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, NULL,
"Table length is greater than size of the input file");
return;
}
Sum = (signed char) (Sum + FileByte);
}
Checksum = (UINT8) (0 - Sum);
/* Re-write the checksum byte */
FlSeekFile (ASL_FILE_AML_OUTPUT, Op->Asl.FinalAmlOffset +
ACPI_OFFSET (ACPI_TABLE_HEADER, Checksum));
FlWriteFile (ASL_FILE_AML_OUTPUT, &Checksum, 1);
/*
* Seek to the end of the file. This is done to support multiple file
* compilation. Doing this simplifies other parts of the codebase because
* it eliminates the need to seek for a different starting place.
*/
FlSeekFile (ASL_FILE_AML_OUTPUT, Op->Asl.FinalAmlOffset + Length);
}
/*******************************************************************************
*
* FUNCTION: CgWriteNode
*
* PARAMETERS: Op - Parse node to write.
*
* RETURN: None.
*
* DESCRIPTION: Write the AML that corresponds to a parse node.
*
******************************************************************************/
static void
CgWriteNode (
ACPI_PARSE_OBJECT *Op)
{
ASL_RESOURCE_NODE *Rnode;
/* Write all comments here. */
if (AcpiGbl_CaptureComments)
{
CgWriteAmlComment(Op);
}
/* Always check for DEFAULT_ARG and other "Noop" nodes */
/* TBD: this may not be the best place for this check */
if ((Op->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG) ||
(Op->Asl.ParseOpcode == PARSEOP_INCLUDE) ||
(Op->Asl.ParseOpcode == PARSEOP_INCLUDE_END))
{
return;
}
Op->Asl.FinalAmlLength = 0;
switch (Op->Asl.AmlOpcode)
{
case AML_RAW_DATA_BYTE:
case AML_RAW_DATA_WORD:
case AML_RAW_DATA_DWORD:
case AML_RAW_DATA_QWORD:
CgLocalWriteAmlData (Op, &Op->Asl.Value.Integer, Op->Asl.AmlLength);
return;
case AML_RAW_DATA_BUFFER:
CgLocalWriteAmlData (Op, Op->Asl.Value.Buffer, Op->Asl.AmlLength);
return;
case AML_RAW_DATA_CHAIN:
Rnode = ACPI_CAST_PTR (ASL_RESOURCE_NODE, Op->Asl.Value.Buffer);
while (Rnode)
{
CgLocalWriteAmlData (Op, Rnode->Buffer, Rnode->BufferLength);
Rnode = Rnode->Next;
}
return;
default:
/* Internal data opcodes must all appear above */
break;
}
switch (Op->Asl.ParseOpcode)
{
case PARSEOP_DEFAULT_ARG:
break;
case PARSEOP_DEFINITION_BLOCK:
CgWriteTableHeader (Op);
if (AcpiGbl_CaptureComments)
{
CgWriteAmlDefBlockComment (Op);
}
break;
case PARSEOP_NAMESEG:
case PARSEOP_NAMESTRING:
case PARSEOP_METHODCALL:
CgLocalWriteAmlData (Op, Op->Asl.Value.String, Op->Asl.AmlLength);
break;
default:
CgWriteAmlOpcode (Op);
break;
}
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,901 @@
%{
/******************************************************************************
*
* Module Name: aslcompiler.l - Flex/lex input file
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "acconvert.h"
#include <stdlib.h>
#include <string.h>
/*
* Generation: Use the following command line:
*
* flex.exe -PAslCompiler -i -o$(InputPath).c $(InputPath)
*
* -i: Scanner must be case-insensitive
*/
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslscanner")
/* Local prototypes */
static void
AslDoLineDirective (void);
static BOOLEAN
AslDoComment (void);
static BOOLEAN
AslDoCommentType2 (void);
static char
AslDoStringLiteral (void);
static void
count (int type);
/*! [Begin] no source code translation */
%}
/* Definitions */
LeadNameChar [A-Za-z_]
DigitChar [0-9]
ErrorCode [(][ ]*[1-9][0-9][0-9][0-9][ ]*[)]
OctalChar [0-7]
HexDigitChar [A-Fa-f0-9]
RootChar [\\]
Nothing []
NameChar [A-Za-z_0-9]
NameSeg1 {LeadNameChar}{NameChar}
NameSeg2 {LeadNameChar}{NameChar}{NameChar}
NameSeg3 {LeadNameChar}{NameChar}{NameChar}{NameChar}
NameSeg {LeadNameChar}|{NameSeg1}|{NameSeg2}|{NameSeg3}
NameString {RootChar}|{RootChar}{NamePath}|[\^]+{NamePath}|{NonEmptyNamePath}
NamePath {NonEmptyNamePath}?
NonEmptyNamePath {NameSeg}{NamePathTail}*
NamePathTail [.]{NameSeg}
%%
/* Rules */
[ ] { count (0); }
[\n] { count (0); } /* Handle files with both LF and CR/LF */
[\r] { count (0); } /* termination on both Unix and Windows */
[ \t] { count (0); }
"/*" { if (!AslDoComment ()) {yyterminate ();} }
"//" { if (!AslDoCommentType2 ()) {yyterminate ();} }
"\"" { if (AslDoStringLiteral ()) {return (PARSEOP_STRING_LITERAL);}
else {yyterminate ();} }
";" { count (0); return(';'); }
/* ASL Extension: Standard C operators */
"~" { count (3); return (PARSEOP_EXP_NOT); }
"!" { count (3); return (PARSEOP_EXP_LOGICAL_NOT); }
"*" { count (3); return (PARSEOP_EXP_MULTIPLY); }
"/" { count (3); return (PARSEOP_EXP_DIVIDE); }
"%" { count (3); return (PARSEOP_EXP_MODULO); }
"+" { count (3); return (PARSEOP_EXP_ADD); }
"-" { count (3); return (PARSEOP_EXP_SUBTRACT); }
">>" { count (3); return (PARSEOP_EXP_SHIFT_RIGHT); }
"<<" { count (3); return (PARSEOP_EXP_SHIFT_LEFT); }
"<" { count (3); return (PARSEOP_EXP_LESS); }
">" { count (3); return (PARSEOP_EXP_GREATER); }
"&" { count (3); return (PARSEOP_EXP_AND); }
"<=" { count (3); return (PARSEOP_EXP_LESS_EQUAL); }
">=" { count (3); return (PARSEOP_EXP_GREATER_EQUAL); }
"==" { count (3); return (PARSEOP_EXP_EQUAL); }
"!=" { count (3); return (PARSEOP_EXP_NOT_EQUAL); }
"|" { count (3); return (PARSEOP_EXP_OR); }
"&&" { count (3); return (PARSEOP_EXP_LOGICAL_AND); }
"||" { count (3); return (PARSEOP_EXP_LOGICAL_OR); }
"++" { count (3); return (PARSEOP_EXP_INCREMENT); }
"--" { count (3); return (PARSEOP_EXP_DECREMENT); }
"^ " { count (3); return (PARSEOP_EXP_XOR); }
/* ASL Extension: Standard C assignment operators */
"=" { count (3); return (PARSEOP_EXP_EQUALS); }
"+=" { count (3); return (PARSEOP_EXP_ADD_EQ); }
"-=" { count (3); return (PARSEOP_EXP_SUB_EQ); }
"*=" { count (3); return (PARSEOP_EXP_MUL_EQ); }
"/=" { count (3); return (PARSEOP_EXP_DIV_EQ); }
"%=" { count (3); return (PARSEOP_EXP_MOD_EQ); }
"<<=" { count (3); return (PARSEOP_EXP_SHL_EQ); }
">>=" { count (3); return (PARSEOP_EXP_SHR_EQ); }
"&=" { count (3); return (PARSEOP_EXP_AND_EQ); }
"^=" { count (3); return (PARSEOP_EXP_XOR_EQ); }
"|=" { count (3); return (PARSEOP_EXP_OR_EQ); }
"[" { count (3); return (PARSEOP_EXP_INDEX_LEFT); }
"]" { count (0); return (PARSEOP_EXP_INDEX_RIGHT); }
"(" { count (0); return (PARSEOP_OPEN_PAREN); }
")" { count (0); return (PARSEOP_CLOSE_PAREN); }
"{" { count (0); return ('{'); }
"}" { count (0); return ('}'); }
"," { count (0); return (','); }
/*
* Begin standard ASL grammar
*/
[0-9][a-zA-Z0-9]* { count (1); AslCompilerlval.i = UtDoConstant ((char *) AslCompilertext);
return (PARSEOP_INTEGER); }
"Include" { count (1); return (PARSEOP_INCLUDE); }
"External" { count (1); return (PARSEOP_EXTERNAL); }
/*
* The #line directive is emitted by the preprocessor and handled
* here in the main iASL lexer - simply set the line number and
* optionally the current filename.
*/
"#line" { AslDoLineDirective ();}
/****************************************************************************
*
* Main ASL operators
*
****************************************************************************/
"AccessAs" { count (1); return (PARSEOP_ACCESSAS); }
"Acquire" { count (3); return (PARSEOP_ACQUIRE); }
"Add" { count (3); return (PARSEOP_ADD); }
"Alias" { count (2); return (PARSEOP_ALIAS); }
"And" { count (3); return (PARSEOP_AND); }
"BankField" { count (2); return (PARSEOP_BANKFIELD); }
"Break" { count (3); return (PARSEOP_BREAK); }
"BreakPoint" { count (3); return (PARSEOP_BREAKPOINT); }
"Buffer" { count (1); return (PARSEOP_BUFFER); }
"Case" { count (3); return (PARSEOP_CASE); }
"Concatenate" { count (3); return (PARSEOP_CONCATENATE); }
"ConcatenateResTemplate" { count (3); return (PARSEOP_CONCATENATERESTEMPLATE); }
"CondRefOf" { count (3); return (PARSEOP_CONDREFOF); }
"Connection" { count (2); return (PARSEOP_CONNECTION); }
"Continue" { count (3); return (PARSEOP_CONTINUE); }
"CopyObject" { count (3); return (PARSEOP_COPYOBJECT); }
"CreateBitField" { count (2); return (PARSEOP_CREATEBITFIELD); }
"CreateByteField" { count (2); return (PARSEOP_CREATEBYTEFIELD); }
"CreateDWordField" { count (2); return (PARSEOP_CREATEDWORDFIELD); }
"CreateField" { count (2); return (PARSEOP_CREATEFIELD); }
"CreateQWordField" { count (2); return (PARSEOP_CREATEQWORDFIELD); }
"CreateWordField" { count (2); return (PARSEOP_CREATEWORDFIELD); }
"DataTableRegion" { count (2); return (PARSEOP_DATATABLEREGION); }
"Debug" { count (1); return (PARSEOP_DEBUG); }
"Decrement" { count (3); return (PARSEOP_DECREMENT); }
"Default" { count (3); return (PARSEOP_DEFAULT); }
"DefinitionBlock" { count (1); return (PARSEOP_DEFINITION_BLOCK); }
"DeRefOf" { count (3); return (PARSEOP_DEREFOF); }
"Device" { count (2); return (PARSEOP_DEVICE); }
"Divide" { count (3); return (PARSEOP_DIVIDE); }
"Eisaid" { count (1); return (PARSEOP_EISAID); }
"Else" { count (3); return (PARSEOP_ELSE); }
"ElseIf" { count (3); return (PARSEOP_ELSEIF); }
"Event" { count (2); return (PARSEOP_EVENT); }
"Fatal" { count (3); return (PARSEOP_FATAL); }
"Field" { count (2); return (PARSEOP_FIELD); }
"FindSetLeftBit" { count (3); return (PARSEOP_FINDSETLEFTBIT); }
"FindSetRightBit" { count (3); return (PARSEOP_FINDSETRIGHTBIT); }
"FromBcd" { count (3); return (PARSEOP_FROMBCD); }
"Function" { count (2); return (PARSEOP_FUNCTION); }
"If" { count (3); return (PARSEOP_IF); }
"Increment" { count (3); return (PARSEOP_INCREMENT); }
"Index" { count (3); return (PARSEOP_INDEX); }
"IndexField" { count (2); return (PARSEOP_INDEXFIELD); }
"LAnd" { count (3); return (PARSEOP_LAND); }
"LEqual" { count (3); return (PARSEOP_LEQUAL); }
"LGreater" { count (3); return (PARSEOP_LGREATER); }
"LGreaterEqual" { count (3); return (PARSEOP_LGREATEREQUAL); }
"LLess" { count (3); return (PARSEOP_LLESS); }
"LLessEqual" { count (3); return (PARSEOP_LLESSEQUAL); }
"LNot" { count (3); return (PARSEOP_LNOT); }
"LNotEqual" { count (3); return (PARSEOP_LNOTEQUAL); }
"Load" { count (3); return (PARSEOP_LOAD); }
"LoadTable" { count (3); return (PARSEOP_LOADTABLE); }
"LOr" { count (3); return (PARSEOP_LOR); }
"Match" { count (3); return (PARSEOP_MATCH); }
"Method" { count (2); return (PARSEOP_METHOD); }
"Mid" { count (3); return (PARSEOP_MID); }
"Mod" { count (3); return (PARSEOP_MOD); }
"Multiply" { count (3); return (PARSEOP_MULTIPLY); }
"Mutex" { count (2); return (PARSEOP_MUTEX); }
"Name" { count (2); return (PARSEOP_NAME); }
"NAnd" { count (3); return (PARSEOP_NAND); }
"Noop" { if (!AcpiGbl_IgnoreNoopOperator) {count (3); return (PARSEOP_NOOP);} }
"NOr" { count (3); return (PARSEOP_NOR); }
"Not" { count (3); return (PARSEOP_NOT); }
"Notify" { count (3); return (PARSEOP_NOTIFY); }
"ObjectType" { count (3); return (PARSEOP_OBJECTTYPE); }
"Offset" { count (1); return (PARSEOP_OFFSET); }
"One" { count (1); return (PARSEOP_ONE); }
"Ones" { count (1); return (PARSEOP_ONES); }
"OperationRegion" { count (2); return (PARSEOP_OPERATIONREGION); }
"Or" { count (3); return (PARSEOP_OR); }
"Package" { count (1); return (PARSEOP_PACKAGE); }
"PowerResource" { count (2); return (PARSEOP_POWERRESOURCE); }
"Processor" { count (2); return (PARSEOP_PROCESSOR); }
"RefOf" { count (3); return (PARSEOP_REFOF); }
"Release" { count (3); return (PARSEOP_RELEASE); }
"Reset" { count (3); return (PARSEOP_RESET); }
"Return" { count (3); return (PARSEOP_RETURN); }
"Revision" { count (1); return (PARSEOP_REVISION); }
"Scope" { count (2); return (PARSEOP_SCOPE); }
"ShiftLeft" { count (3); return (PARSEOP_SHIFTLEFT); }
"ShiftRight" { count (3); return (PARSEOP_SHIFTRIGHT); }
"Signal" { count (3); return (PARSEOP_SIGNAL); }
"SizeOf" { count (3); return (PARSEOP_SIZEOF); }
"Sleep" { count (3); return (PARSEOP_SLEEP); }
"Stall" { count (3); return (PARSEOP_STALL); }
"Store" { count (3); return (PARSEOP_STORE); }
"Subtract" { count (3); return (PARSEOP_SUBTRACT); }
"Switch" { count (3); return (PARSEOP_SWITCH); }
"ThermalZone" { count (2); return (PARSEOP_THERMALZONE); }
"Timer" { count (3); return (PARSEOP_TIMER); }
"ToBcd" { count (3); return (PARSEOP_TOBCD); }
"ToBuffer" { count (3); return (PARSEOP_TOBUFFER); }
"ToDecimalString" { count (3); return (PARSEOP_TODECIMALSTRING); }
"ToHexString" { count (3); return (PARSEOP_TOHEXSTRING); }
"ToInteger" { count (3); return (PARSEOP_TOINTEGER); }
"ToString" { count (3); return (PARSEOP_TOSTRING); }
"ToUuid" { count (1); return (PARSEOP_TOUUID); }
"Unicode" { count (1); return (PARSEOP_UNICODE); }
"Unload" { count (3); return (PARSEOP_UNLOAD); }
"Wait" { count (3); return (PARSEOP_WAIT); }
"While" { count (3); return (PARSEOP_WHILE); }
"XOr" { count (3); return (PARSEOP_XOR); }
"Zero" { count (1); return (PARSEOP_ZERO); }
/* Control method arguments and locals */
"Arg0" { count (1); return (PARSEOP_ARG0); }
"Arg1" { count (1); return (PARSEOP_ARG1); }
"Arg2" { count (1); return (PARSEOP_ARG2); }
"Arg3" { count (1); return (PARSEOP_ARG3); }
"Arg4" { count (1); return (PARSEOP_ARG4); }
"Arg5" { count (1); return (PARSEOP_ARG5); }
"Arg6" { count (1); return (PARSEOP_ARG6); }
"Local0" { count (1); return (PARSEOP_LOCAL0); }
"Local1" { count (1); return (PARSEOP_LOCAL1); }
"Local2" { count (1); return (PARSEOP_LOCAL2); }
"Local3" { count (1); return (PARSEOP_LOCAL3); }
"Local4" { count (1); return (PARSEOP_LOCAL4); }
"Local5" { count (1); return (PARSEOP_LOCAL5); }
"Local6" { count (1); return (PARSEOP_LOCAL6); }
"Local7" { count (1); return (PARSEOP_LOCAL7); }
/****************************************************************************
*
* Resource Descriptor macros
*
****************************************************************************/
"ResourceTemplate" { count (1); return (PARSEOP_RESOURCETEMPLATE); }
"RawDataBuffer" { count (1); return (PARSEOP_DATABUFFER); }
"Csi2Bus" { count (1); return (PARSEOP_CSI2_SERIALBUS); }
"DMA" { count (1); return (PARSEOP_DMA); }
"DWordIO" { count (1); return (PARSEOP_DWORDIO); }
"DWordMemory" { count (1); return (PARSEOP_DWORDMEMORY); }
"DWordPcc" { count (1); return (PARSEOP_DWORDPCC); }
"DWordSpace" { count (1); return (PARSEOP_DWORDSPACE); }
"EndDependentFn" { count (1); return (PARSEOP_ENDDEPENDENTFN); }
"ExtendedIO" { count (1); return (PARSEOP_EXTENDEDIO); }
"ExtendedMemory" { count (1); return (PARSEOP_EXTENDEDMEMORY); }
"ExtendedSpace" { count (1); return (PARSEOP_EXTENDEDSPACE); }
"FixedDma" { count (1); return (PARSEOP_FIXEDDMA); }
"FixedIO" { count (1); return (PARSEOP_FIXEDIO); }
"GpioInt" { count (1); return (PARSEOP_GPIO_INT); }
"GpioIo" { count (1); return (PARSEOP_GPIO_IO); }
"I2cSerialBus" { count (1); return (PARSEOP_I2C_SERIALBUS); }
"I2cSerialBusV2" { count (1); return (PARSEOP_I2C_SERIALBUS_V2); }
"Interrupt" { count (1); return (PARSEOP_INTERRUPT); }
"IO" { count (1); return (PARSEOP_IO); }
"IRQ" { count (1); return (PARSEOP_IRQ); }
"IRQNoFlags" { count (1); return (PARSEOP_IRQNOFLAGS); }
"Memory24" { count (1); return (PARSEOP_MEMORY24); }
"Memory32" { count (1); return (PARSEOP_MEMORY32); }
"Memory32Fixed" { count (1); return (PARSEOP_MEMORY32FIXED); }
"PinConfig" { count (1); return (PARSEOP_PINCONFIG); }
"PinFunction" { count (1); return (PARSEOP_PINFUNCTION); }
"PinGroup" { count (1); return (PARSEOP_PINGROUP); }
"PinGroupConfig" { count (1); return (PARSEOP_PINGROUPCONFIG); }
"PinGroupFunction" { count (1); return (PARSEOP_PINGROUPFUNCTION); }
"ClockInput" { count (1); return (PARSEOP_CLOCKINPUT); }
"QWordIO" { count (1); return (PARSEOP_QWORDIO); }
"QWordMemory" { count (1); return (PARSEOP_QWORDMEMORY); }
"QWordPcc" { count (1); return (PARSEOP_DWORDPCC); }
"QWordSpace" { count (1); return (PARSEOP_QWORDSPACE); }
"Register" { count (1); return (PARSEOP_REGISTER); }
"SpiSerialBus" { count (1); return (PARSEOP_SPI_SERIALBUS); }
"SpiSerialBusV2" { count (1); return (PARSEOP_SPI_SERIALBUS_V2); }
"StartDependentFn" { count (1); return (PARSEOP_STARTDEPENDENTFN); }
"StartDependentFnNoPri" { count (1); return (PARSEOP_STARTDEPENDENTFN_NOPRI); }
"UartSerialBus" { count (1); return (PARSEOP_UART_SERIALBUS); }
"UartSerialBusV2" { count (1); return (PARSEOP_UART_SERIALBUS_V2); }
"VendorLong" { count (1); return (PARSEOP_VENDORLONG); }
"VendorShort" { count (1); return (PARSEOP_VENDORSHORT); }
"WordBusNumber" { count (1); return (PARSEOP_WORDBUSNUMBER); }
"WordIO" { count (1); return (PARSEOP_WORDIO); }
"WordPcc" { count (1); return (PARSEOP_DWORDPCC); }
"WordSpace" { count (1); return (PARSEOP_WORDSPACE); }
/****************************************************************************
*
* Keywords used as arguments to ASL operators and macros
*
****************************************************************************/
/* AccessAttribKeyword: Serial Bus Attributes (ACPI 5.0) */
"AttribQuick" { count (0); return (PARSEOP_ACCESSATTRIB_QUICK); }
"AttribSendReceive" { count (0); return (PARSEOP_ACCESSATTRIB_SND_RCV); }
"AttribByte" { count (0); return (PARSEOP_ACCESSATTRIB_BYTE); }
"AttribWord" { count (0); return (PARSEOP_ACCESSATTRIB_WORD); }
"AttribBlock" { count (0); return (PARSEOP_ACCESSATTRIB_BLOCK); }
"AttribProcessCall" { count (0); return (PARSEOP_ACCESSATTRIB_WORD_CALL); }
"AttribBlockProcessCall" { count (0); return (PARSEOP_ACCESSATTRIB_BLOCK_CALL); }
/* AccessAttribKeyword: Legacy synonyms for above (pre-ACPI 5.0) */
"SMBQuick" { count (0); return (PARSEOP_ACCESSATTRIB_QUICK); }
"SMBSendReceive" { count (0); return (PARSEOP_ACCESSATTRIB_SND_RCV); }
"SMBByte" { count (0); return (PARSEOP_ACCESSATTRIB_BYTE); }
"SMBWord" { count (0); return (PARSEOP_ACCESSATTRIB_WORD); }
"SMBBlock" { count (0); return (PARSEOP_ACCESSATTRIB_BLOCK); }
"SMBProcessCall" { count (0); return (PARSEOP_ACCESSATTRIB_WORD_CALL); }
"SMBBlockProcessCall" { count (0); return (PARSEOP_ACCESSATTRIB_BLOCK_CALL); }
/* AccessTypeKeyword: Field Access Types */
"AnyAcc" { count (0); return (PARSEOP_ACCESSTYPE_ANY); }
"ByteAcc" { count (0); return (PARSEOP_ACCESSTYPE_BYTE); }
"WordAcc" { count (0); return (PARSEOP_ACCESSTYPE_WORD); }
"DWordAcc" { count (0); return (PARSEOP_ACCESSTYPE_DWORD); }
"QWordAcc" { count (0); return (PARSEOP_ACCESSTYPE_QWORD); }
"BufferAcc" { count (0); return (PARSEOP_ACCESSTYPE_BUF); }
/* AddressingModeKeyword: Mode - Resource Descriptors (ACPI 5.0) */
"AddressingMode7Bit" { count (0); return (PARSEOP_ADDRESSINGMODE_7BIT); }
"AddressingMode10Bit" { count (0); return (PARSEOP_ADDRESSINGMODE_10BIT); }
/* AddressKeyword: ACPI memory range types */
"AddressRangeMemory" { count (0); return (PARSEOP_ADDRESSTYPE_MEMORY); }
"AddressRangeReserved" { count (0); return (PARSEOP_ADDRESSTYPE_RESERVED); }
"AddressRangeNVS" { count (0); return (PARSEOP_ADDRESSTYPE_NVS); }
"AddressRangeACPI" { count (0); return (PARSEOP_ADDRESSTYPE_ACPI); }
/* BusMasterKeyword: DMA Bus Mastering */
"BusMaster" { count (0); return (PARSEOP_BUSMASTERTYPE_MASTER); }
"NotBusMaster" { count (0); return (PARSEOP_BUSMASTERTYPE_NOTMASTER); }
/* ByteLengthKeyword: Bits per Byte - Resource Descriptors (ACPI 5.0) */
"DataBitsFive" { count (0); return (PARSEOP_BITSPERBYTE_FIVE); }
"DataBitsSix" { count (0); return (PARSEOP_BITSPERBYTE_SIX); }
"DataBitsSeven" { count (0); return (PARSEOP_BITSPERBYTE_SEVEN); }
"DataBitsEight" { count (0); return (PARSEOP_BITSPERBYTE_EIGHT); }
"DataBitsNine" { count (0); return (PARSEOP_BITSPERBYTE_NINE); }
/* ClockPhaseKeyword: Resource Descriptors (ACPI 5.0) */
"ClockPhaseFirst" { count (0); return (PARSEOP_CLOCKPHASE_FIRST); }
"ClockPhaseSecond" { count (0); return (PARSEOP_CLOCKPHASE_SECOND); }
/* ClockPolarityKeyword: Resource Descriptors (ACPI 5.0) */
"ClockPolarityLow" { count (0); return (PARSEOP_CLOCKPOLARITY_LOW); }
"ClockPolarityHigh" { count (0); return (PARSEOP_CLOCKPOLARITY_HIGH); }
/* DecodeKeyword: Type of Memory Decoding - Resource Descriptors */
"PosDecode" { count (0); return (PARSEOP_DECODETYPE_POS); }
"SubDecode" { count (0); return (PARSEOP_DECODETYPE_SUB); }
/* DmaTypeKeyword: DMA Types - DMA Resource Descriptor */
"Compatibility" { count (0); return (PARSEOP_DMATYPE_COMPATIBILITY); }
"TypeA" { count (0); return (PARSEOP_DMATYPE_A); }
"TypeB" { count (0); return (PARSEOP_DMATYPE_B); }
"TypeF" { count (0); return (PARSEOP_DMATYPE_F); }
/* EndianKeyword: Endian type - Resource Descriptor (ACPI 5.0) */
"LittleEndian" { count (0); return (PARSEOP_ENDIAN_LITTLE); }
"BigEndian" { count (0); return (PARSEOP_ENDIAN_BIG); }
/* ExtendedAttribKeyword: Bus attributes, AccessAs operator (ACPI 5.0) */
"AttribBytes" { count (0); return (PARSEOP_ACCESSATTRIB_BYTES); }
"AttribRawBytes" { count (0); return (PARSEOP_ACCESSATTRIB_RAW_BYTES); }
"AttribRawProcessBytes" { count (0); return (PARSEOP_ACCESSATTRIB_RAW_PROCESS); }
/* FlowControlKeyword: Resource Descriptors (ACPI 5.0) */
"FlowControlHardware" { count (0); return (PARSEOP_FLOWCONTROL_HW); }
"FlowControlNone" { count (0); return (PARSEOP_FLOWCONTROL_NONE); }
"FlowControlXon" { count (0); return (PARSEOP_FLOWCONTROL_SW); }
/* InterruptLevelKeyword: Interrupt Active Types */
"ActiveBoth" { count (0); return (PARSEOP_INTLEVEL_ACTIVEBOTH); }
"ActiveHigh" { count (0); return (PARSEOP_INTLEVEL_ACTIVEHIGH); }
"ActiveLow" { count (0); return (PARSEOP_INTLEVEL_ACTIVELOW); }
/* InterruptTypeKeyword: Interrupt Types */
"Edge" { count (0); return (PARSEOP_INTTYPE_EDGE); }
"Level" { count (0); return (PARSEOP_INTTYPE_LEVEL); }
/* IoDecodeKeyword: Type of Memory Decoding - Resource Descriptors */
"Decode10" { count (0); return (PARSEOP_IODECODETYPE_10); }
"Decode16" { count (0); return (PARSEOP_IODECODETYPE_16); }
/* IoRestrictionKeyword: I/O Restriction - GPIO Resource Descriptors (ACPI 5.0) */
"IoRestrictionNone" { count (0); return (PARSEOP_IORESTRICT_NONE); }
"IoRestrictionInputOnly" { count (0); return (PARSEOP_IORESTRICT_IN); }
"IoRestrictionOutputOnly" { count (0); return (PARSEOP_IORESTRICT_OUT); }
"IoRestrictionNoneAndPreserve" { count (0); return (PARSEOP_IORESTRICT_PRESERVE); }
/* LockRuleKeyword: Global Lock use for Field Operator */
"Lock" { count (0); return (PARSEOP_LOCKRULE_LOCK); }
"NoLock" { count (0); return (PARSEOP_LOCKRULE_NOLOCK); }
/* MatchOpKeyword: Types for Match Operator */
"MTR" { count (0); return (PARSEOP_MATCHTYPE_MTR); }
"MEQ" { count (0); return (PARSEOP_MATCHTYPE_MEQ); }
"MLE" { count (0); return (PARSEOP_MATCHTYPE_MLE); }
"MLT" { count (0); return (PARSEOP_MATCHTYPE_MLT); }
"MGE" { count (0); return (PARSEOP_MATCHTYPE_MGE); }
"MGT" { count (0); return (PARSEOP_MATCHTYPE_MGT); }
/* MaxKeyword: Max Range Type - Resource Descriptors */
"MaxFixed" { count (0); return (PARSEOP_MAXTYPE_FIXED); }
"MaxNotFixed" { count (0); return (PARSEOP_MAXTYPE_NOTFIXED); }
/* MemTypeKeyword: Memory Types - Resource Descriptors */
"Cacheable" { count (0); return (PARSEOP_MEMTYPE_CACHEABLE); }
"WriteCombining" { count (0); return (PARSEOP_MEMTYPE_WRITECOMBINING); }
"Prefetchable" { count (0); return (PARSEOP_MEMTYPE_PREFETCHABLE); }
"NonCacheable" { count (0); return (PARSEOP_MEMTYPE_NONCACHEABLE); }
/* MinKeyword: Min Range Type - Resource Descriptors */
"MinFixed" { count (0); return (PARSEOP_MINTYPE_FIXED); }
"MinNotFixed" { count (0); return (PARSEOP_MINTYPE_NOTFIXED); }
/* ObjectTypeKeyword: ACPI Object Types */
"UnknownObj" { count (0); return (PARSEOP_OBJECTTYPE_UNK); }
"IntObj" { count (0); return (PARSEOP_OBJECTTYPE_INT); }
"StrObj" { count (0); return (PARSEOP_OBJECTTYPE_STR); }
"BuffObj" { count (0); return (PARSEOP_OBJECTTYPE_BUF); }
"PkgObj" { count (0); return (PARSEOP_OBJECTTYPE_PKG); }
"FieldUnitObj" { count (0); return (PARSEOP_OBJECTTYPE_FLD); }
"DeviceObj" { count (0); return (PARSEOP_OBJECTTYPE_DEV); }
"EventObj" { count (0); return (PARSEOP_OBJECTTYPE_EVT); }
"MethodObj" { count (0); return (PARSEOP_OBJECTTYPE_MTH); }
"MutexObj" { count (0); return (PARSEOP_OBJECTTYPE_MTX); }
"OpRegionObj" { count (0); return (PARSEOP_OBJECTTYPE_OPR); }
"PowerResObj" { count (0); return (PARSEOP_OBJECTTYPE_POW); }
"ProcessorObj" { count (0); return (PARSEOP_OBJECTTYPE_PRO); }
"ThermalZoneObj" { count (0); return (PARSEOP_OBJECTTYPE_THZ); }
"BuffFieldObj" { count (0); return (PARSEOP_OBJECTTYPE_BFF); }
"DDBHandleObj" { count (0); return (PARSEOP_OBJECTTYPE_DDB); }
/* ParityKeyword: Resource Descriptors (ACPI 5.0) */
"ParityTypeSpace" { count (0); return (PARSEOP_PARITYTYPE_SPACE); }
"ParityTypeMark" { count (0); return (PARSEOP_PARITYTYPE_MARK); }
"ParityTypeOdd" { count (0); return (PARSEOP_PARITYTYPE_ODD); }
"ParityTypeEven" { count (0); return (PARSEOP_PARITYTYPE_EVEN); }
"ParityTypeNone" { count (0); return (PARSEOP_PARITYTYPE_NONE); }
/* PinConfigKeyword: Pin Configuration - GPIO Resource Descriptors (ACPI 5.0) */
"PullDefault" { count (0); return (PARSEOP_PIN_PULLDEFAULT); }
"PullUp" { count (0); return (PARSEOP_PIN_PULLUP); }
"PullDown" { count (0); return (PARSEOP_PIN_PULLDOWN); }
"PullNone" { count (0); return (PARSEOP_PIN_NOPULL); }
/* ClockScaleKeyword: Resource Descriptors (ACPI 6.5) */
"Hz" { count (0); return (PARSEOP_CLOCK_HZ); }
"KHz" { count (0); return (PARSEOP_CLOCK_KHZ); }
"MHz" { count (0); return (PARSEOP_CLOCK_MHZ); }
/* ClockModeKeyword: Resource Descriptors (ACPI 6.5) */
"Fixed" { count (0); return (PARSEOP_CLOCK_FIXED); }
"Variable" { count (0); return (PARSEOP_CLOCK_VARIABLE); }
/* PolarityKeyword: Resource Descriptors (ACPI 5.0) */
"PolarityLow" { count (0); return (PARSEOP_DEVICEPOLARITY_LOW); }
"PolarityHigh" { count (0); return (PARSEOP_DEVICEPOLARITY_HIGH); }
/* RangeTypeKeyword: I/O Range Types - Resource Descriptors */
"ISAOnlyRanges" { count (0); return (PARSEOP_RANGETYPE_ISAONLY); }
"NonISAOnlyRanges" { count (0); return (PARSEOP_RANGETYPE_NONISAONLY); }
"EntireRange" { count (0); return (PARSEOP_RANGETYPE_ENTIRE); }
/* ReadWriteKeyword: Memory Access Types - Resource Descriptors */
"ReadWrite" { count (0); return (PARSEOP_READWRITETYPE_BOTH); }
"ReadOnly" { count (0); return (PARSEOP_READWRITETYPE_READONLY); }
/* RegionSpaceKeyword: Operation Region Address Space Types */
"SystemIO" { count (0); return (PARSEOP_REGIONSPACE_IO); }
"SystemMemory" { count (0); return (PARSEOP_REGIONSPACE_MEM); }
"PCI_Config" { count (0); return (PARSEOP_REGIONSPACE_PCI); }
"EmbeddedControl" { count (0); return (PARSEOP_REGIONSPACE_EC); }
"SMBus" { count (0); return (PARSEOP_REGIONSPACE_SMBUS); }
"SystemCMOS" { count (0); return (PARSEOP_REGIONSPACE_CMOS); }
"PciBarTarget" { count (0); return (PARSEOP_REGIONSPACE_PCIBAR); }
"IPMI" { count (0); return (PARSEOP_REGIONSPACE_IPMI); }
"GeneralPurposeIo" { count (0); return (PARSEOP_REGIONSPACE_GPIO); } /* ACPI 5.0 */
"GenericSerialBus" { count (0); return (PARSEOP_REGIONSPACE_GSBUS); } /* ACPI 5.0 */
"PCC" { count (0); return (PARSEOP_REGIONSPACE_PCC); } /* ACPI 5.0 */
"PlatformRtMechanism" { count (0); return (PARSEOP_REGIONSPACE_PRM); }
"FFixedHW" { count (0); return (PARSEOP_REGIONSPACE_FFIXEDHW); }
/* ResourceTypeKeyword: Resource Usage - Resource Descriptors */
"ResourceConsumer" { count (0); return (PARSEOP_RESOURCETYPE_CONSUMER); }
"ResourceProducer" { count (0); return (PARSEOP_RESOURCETYPE_PRODUCER); }
/* SerializeRuleKeyword: Control Method Serialization */
"Serialized" { count (0); return (PARSEOP_SERIALIZERULE_SERIAL); }
"NotSerialized" { count (0); return (PARSEOP_SERIALIZERULE_NOTSERIAL); }
/* ShareTypeKeyword: Interrupt Sharing - Resource Descriptors */
"Shared" { count (0); return (PARSEOP_SHARETYPE_SHARED); }
"Exclusive" { count (0); return (PARSEOP_SHARETYPE_EXCLUSIVE); }
"SharedAndWake" { count (0); return (PARSEOP_SHARETYPE_SHAREDWAKE); } /* ACPI 5.0 */
"ExclusiveAndWake" { count (0); return (PARSEOP_SHARETYPE_EXCLUSIVEWAKE); } /* ACPI 5.0 */
/* SlaveModeKeyword: Resource Descriptors (ACPI 5.0) */
"ControllerInitiated" { count (0); return (PARSEOP_SLAVEMODE_CONTROLLERINIT); }
"DeviceInitiated" { count (0); return (PARSEOP_SLAVEMODE_DEVICEINIT); }
/* StopBitsKeyword: Resource Descriptors (ACPI 5.0) */
"StopBitsOne" { count (0); return (PARSEOP_STOPBITS_ONE); }
"StopBitsOnePlusHalf" { count (0); return (PARSEOP_STOPBITS_ONEPLUSHALF); }
"StopBitsTwo" { count (0); return (PARSEOP_STOPBITS_TWO); }
"StopBitsZero" { count (0); return (PARSEOP_STOPBITS_ZERO); }
/* TransferWidthKeyword: DMA Widths - Fixed DMA Resource Descriptor (ACPI 5.0) */
"Width8bit" { count (0); return (PARSEOP_XFERSIZE_8); }
"Width16bit" { count (0); return (PARSEOP_XFERSIZE_16); }
"Width32bit" { count (0); return (PARSEOP_XFERSIZE_32); }
"Width64bit" { count (0); return (PARSEOP_XFERSIZE_64); }
"Width128bit" { count (0); return (PARSEOP_XFERSIZE_128); }
"Width256bit" { count (0); return (PARSEOP_XFERSIZE_256); }
/* TranslationKeyword: Translation Density Types - Resource Descriptors */
"SparseTranslation" { count (0); return (PARSEOP_TRANSLATIONTYPE_SPARSE); }
"DenseTranslation" { count (0); return (PARSEOP_TRANSLATIONTYPE_DENSE); }
/* TypeKeyword: Translation Types - Resource Descriptors */
"TypeTranslation" { count (0); return (PARSEOP_TYPE_TRANSLATION); }
"TypeStatic" { count (0); return (PARSEOP_TYPE_STATIC); }
/* UpdateRuleKeyword: Field Update Rules */
"Preserve" { count (0); return (PARSEOP_UPDATERULE_PRESERVE); }
"WriteAsOnes" { count (0); return (PARSEOP_UPDATERULE_ONES); }
"WriteAsZeros" { count (0); return (PARSEOP_UPDATERULE_ZEROS); }
/* WireModeKeyword: SPI Wire Mode - Resource Descriptors (ACPI 5.0) */
"FourWireMode" { count (0); return (PARSEOP_WIREMODE_FOUR); }
"ThreeWireMode" { count (0); return (PARSEOP_WIREMODE_THREE); }
/* XferTypeKeyword: DMA Transfer Types */
"Transfer8" { count (0); return (PARSEOP_XFERTYPE_8); }
"Transfer8_16" { count (0); return (PARSEOP_XFERTYPE_8_16); }
"Transfer16" { count (0); return (PARSEOP_XFERTYPE_16); }
/* ToPld macro */
"ToPLD" { count (0); return (PARSEOP_TOPLD); }
"PLD_Revision" { count (0); return (PARSEOP_PLD_REVISION); }
"PLD_IgnoreColor" { count (0); return (PARSEOP_PLD_IGNORECOLOR); }
"PLD_Red" { count (0); return (PARSEOP_PLD_RED); }
"PLD_Green" { count (0); return (PARSEOP_PLD_GREEN); }
"PLD_Blue" { count (0); return (PARSEOP_PLD_BLUE); }
"PLD_Width" { count (0); return (PARSEOP_PLD_WIDTH); }
"PLD_Height" { count (0); return (PARSEOP_PLD_HEIGHT); }
"PLD_UserVisible" { count (0); return (PARSEOP_PLD_USERVISIBLE); }
"PLD_Dock" { count (0); return (PARSEOP_PLD_DOCK); }
"PLD_Lid" { count (0); return (PARSEOP_PLD_LID); }
"PLD_Panel" { count (0); return (PARSEOP_PLD_PANEL); }
"PLD_VerticalPosition" { count (0); return (PARSEOP_PLD_VERTICALPOSITION); }
"PLD_HorizontalPosition" { count (0); return (PARSEOP_PLD_HORIZONTALPOSITION); }
"PLD_Shape" { count (0); return (PARSEOP_PLD_SHAPE); }
"PLD_GroupOrientation" { count (0); return (PARSEOP_PLD_GROUPORIENTATION); }
"PLD_GroupToken" { count (0); return (PARSEOP_PLD_GROUPTOKEN); }
"PLD_GroupPosition" { count (0); return (PARSEOP_PLD_GROUPPOSITION); }
"PLD_Bay" { count (0); return (PARSEOP_PLD_BAY); }
"PLD_Ejectable" { count (0); return (PARSEOP_PLD_EJECTABLE); }
"PLD_EjectRequired" { count (0); return (PARSEOP_PLD_EJECTREQUIRED); }
"PLD_CabinetNumber" { count (0); return (PARSEOP_PLD_CABINETNUMBER); }
"PLD_CardCageNumber" { count (0); return (PARSEOP_PLD_CARDCAGENUMBER); }
"PLD_Reference" { count (0); return (PARSEOP_PLD_REFERENCE); }
"PLD_Rotation" { count (0); return (PARSEOP_PLD_ROTATION); }
"PLD_Order" { count (0); return (PARSEOP_PLD_ORDER); }
"PLD_Reserved" { count (0); return (PARSEOP_PLD_RESERVED); }
"PLD_VerticalOffset" { count (0); return (PARSEOP_PLD_VERTICALOFFSET); }
"PLD_HorizontalOffset" { count (0); return (PARSEOP_PLD_HORIZONTALOFFSET); }
/* printf debug macros */
"printf" { count (0); return (PARSEOP_PRINTF); }
"fprintf" { count (0); return (PARSEOP_FPRINTF); }
/* Other macros */
"For" { count (0); return (PARSEOP_FOR); }
/* Predefined compiler names */
"__DATE__" { count (0); return (PARSEOP___DATE__); }
"__FILE__" { count (0); return (PARSEOP___FILE__); }
"__LINE__" { count (0); return (PARSEOP___LINE__); }
"__PATH__" { count (0); return (PARSEOP___PATH__); }
"__METHOD__" { count (0); return (PARSEOP___METHOD__); }
"__EXPECT__"{ErrorCode} { char *s;
unsigned int index = 0;
count (0);
while (!isdigit ((int) AslCompilertext[index]))
{
index++;
}
/*
* The error code is contained inside the
* {ErrorCode} pattern. Extract it and log it
* as the expected error code.
*/
s = UtLocalCacheCalloc (ASL_ERROR_CODE_LENGTH + 1);
memcpy (s, AslCompilertext + index, ASL_ERROR_CODE_LENGTH);
AslLogExpectedExceptionByLine (s); }
{NameSeg} { char *s;
count (0);
s=UtLocalCacheCalloc (ACPI_NAMESEG_SIZE + 1);
if (strcmp (AslCompilertext, "\\"))
{
/*
* According to the ACPI specification,
* NameSegments must have length of 4. If
* the NameSegment has length less than 4,
* they are padded with underscores to meet
* the required length.
*/
strcpy (s, "____");
}
memcpy (s, AslCompilertext, strlen (AslCompilertext));
AslCompilerlval.s = s;
DbgPrint (ASL_PARSE_OUTPUT, "NameSeg: %s\n", s);
return (PARSEOP_NAMESEG); }
{NameString} { char *s;
count (0);
s=UtLocalCacheCalloc (strlen (AslCompilertext)+1);
strcpy (s, AslCompilertext);
AslCompilerlval.s = s;
DbgPrint (ASL_PARSE_OUTPUT, "NameString: %s\n", s);
return (PARSEOP_NAMESTRING); }
. { count (1);
if (isprint ((int) *AslCompilertext))
{
sprintf (AslGbl_MsgBuffer,
"Invalid character (%c), expecting ASL keyword or name",
*AslCompilertext);
}
else
{
sprintf (AslGbl_MsgBuffer,
"Invalid character (0x%2.2X), expecting ASL keyword or name",
*AslCompilertext);
}
AslCompilererror (AslGbl_MsgBuffer);}
<<EOF>> { if (AslPopInputFileStack ())
{yyterminate();}
else
{return (PARSEOP_INCLUDE_END);} };
%%
/*! [End] no source code translation !*/
/*
* Bring in the scanner support routines
*/
#include "aslsupport.l"

View File

@@ -0,0 +1,358 @@
NoEcho('
/******************************************************************************
*
* Module Name: aslcstyle.y - Production rules for symbolic operators
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
')
/*******************************************************************************
*
* Production rules for the symbolic (c-style) operators
*
******************************************************************************/
/*
* ASL Extensions: C-style math/logical operators and expressions.
* The implementation transforms these operators into the standard
* AML opcodes and syntax.
*
* Supported operators and precedence rules (high-to-low)
*
* NOTE: The operator precedence and associativity rules are
* implemented by the tokens in asltokens.y
*
* (left-to-right):
* 1) ( ) expr++ expr--
*
* (right-to-left):
* 2) ! ~
*
* (left-to-right):
* 3) * / %
* 4) + -
* 5) >> <<
* 6) < > <= >=
* 7) == !=
* 8) &
* 9) ^
* 10) |
* 11) &&
* 12) ||
*
* (right-to-left):
* 13) = += -= *= /= %= <<= >>= &= ^= |=
*/
/*******************************************************************************
*
* Basic operations for math and logical expressions.
*
******************************************************************************/
Expression
/* Unary operators */
: PARSEOP_EXP_LOGICAL_NOT {$<n>$ = TrCreateLeafOp (PARSEOP_LNOT);}
TermArg {$$ = TrLinkOpChildren ($<n>2,1,$3);}
| PARSEOP_EXP_NOT {$<n>$ = TrCreateLeafOp (PARSEOP_NOT);}
TermArg {$$ = TrLinkOpChildren ($<n>2,2,$3,TrCreateNullTargetOp ());}
| SuperName PARSEOP_EXP_INCREMENT {$<n>$ = TrCreateLeafOp (PARSEOP_INCREMENT);}
{$$ = TrLinkOpChildren ($<n>3,1,$1);}
| SuperName PARSEOP_EXP_DECREMENT {$<n>$ = TrCreateLeafOp (PARSEOP_DECREMENT);}
{$$ = TrLinkOpChildren ($<n>3,1,$1);}
/* Binary operators: math and logical */
| TermArg PARSEOP_EXP_ADD {$<n>$ = TrCreateLeafOp (PARSEOP_ADD);}
TermArg {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,TrCreateNullTargetOp ());}
| TermArg PARSEOP_EXP_DIVIDE {$<n>$ = TrCreateLeafOp (PARSEOP_DIVIDE);}
TermArg {$$ = TrLinkOpChildren ($<n>3,4,$1,$4,TrCreateNullTargetOp (),
TrCreateNullTargetOp ());}
| TermArg PARSEOP_EXP_MODULO {$<n>$ = TrCreateLeafOp (PARSEOP_MOD);}
TermArg {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,TrCreateNullTargetOp ());}
| TermArg PARSEOP_EXP_MULTIPLY {$<n>$ = TrCreateLeafOp (PARSEOP_MULTIPLY);}
TermArg {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,TrCreateNullTargetOp ());}
| TermArg PARSEOP_EXP_SHIFT_LEFT {$<n>$ = TrCreateLeafOp (PARSEOP_SHIFTLEFT);}
TermArg {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,TrCreateNullTargetOp ());}
| TermArg PARSEOP_EXP_SHIFT_RIGHT {$<n>$ = TrCreateLeafOp (PARSEOP_SHIFTRIGHT);}
TermArg {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,TrCreateNullTargetOp ());}
| TermArg PARSEOP_EXP_SUBTRACT {$<n>$ = TrCreateLeafOp (PARSEOP_SUBTRACT);}
TermArg {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,TrCreateNullTargetOp ());}
| TermArg PARSEOP_EXP_AND {$<n>$ = TrCreateLeafOp (PARSEOP_AND);}
TermArg {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,TrCreateNullTargetOp ());}
| TermArg PARSEOP_EXP_OR {$<n>$ = TrCreateLeafOp (PARSEOP_OR);}
TermArg {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,TrCreateNullTargetOp ());}
| TermArg PARSEOP_EXP_XOR {$<n>$ = TrCreateLeafOp (PARSEOP_XOR);}
TermArg {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,TrCreateNullTargetOp ());}
| TermArg PARSEOP_EXP_GREATER {$<n>$ = TrCreateLeafOp (PARSEOP_LGREATER);}
TermArg {$$ = TrLinkOpChildren ($<n>3,2,$1,$4);}
| TermArg PARSEOP_EXP_GREATER_EQUAL {$<n>$ = TrCreateLeafOp (PARSEOP_LGREATEREQUAL);}
TermArg {$$ = TrLinkOpChildren ($<n>3,2,$1,$4);}
| TermArg PARSEOP_EXP_LESS {$<n>$ = TrCreateLeafOp (PARSEOP_LLESS);}
TermArg {$$ = TrLinkOpChildren ($<n>3,2,$1,$4);}
| TermArg PARSEOP_EXP_LESS_EQUAL {$<n>$ = TrCreateLeafOp (PARSEOP_LLESSEQUAL);}
TermArg {$$ = TrLinkOpChildren ($<n>3,2,$1,$4);}
| TermArg PARSEOP_EXP_EQUAL {$<n>$ = TrCreateLeafOp (PARSEOP_LEQUAL);}
TermArg {$$ = TrLinkOpChildren ($<n>3,2,$1,$4);}
| TermArg PARSEOP_EXP_NOT_EQUAL {$<n>$ = TrCreateLeafOp (PARSEOP_LNOTEQUAL);}
TermArg {$$ = TrLinkOpChildren ($<n>3,2,$1,$4);}
| TermArg PARSEOP_EXP_LOGICAL_AND {$<n>$ = TrCreateLeafOp (PARSEOP_LAND);}
TermArg {$$ = TrLinkOpChildren ($<n>3,2,$1,$4);}
| TermArg PARSEOP_EXP_LOGICAL_OR {$<n>$ = TrCreateLeafOp (PARSEOP_LOR);}
TermArg {$$ = TrLinkOpChildren ($<n>3,2,$1,$4);}
/* Parentheses */
| PARSEOP_OPEN_PAREN
Expression
PARSEOP_CLOSE_PAREN {$$ = $2;}
/* Index term -- "= BUF1[5]" on right-hand side of an equals (source) */
| IndexExpTerm
;
/*
* Index term -- "BUF1[5] = " or " = BUF1[5] on either the left side
* of an equals (target) or the right side (source)
* Currently used in these terms:
* Expression
* ObjectTypeSource
* DerefOfSource
* Type6Opcode
*/
IndexExpTerm
: SuperName
PARSEOP_EXP_INDEX_LEFT
TermArg
PARSEOP_EXP_INDEX_RIGHT {$$ = TrCreateLeafOp (PARSEOP_INDEX);
TrLinkOpChildren ($$,3,$1,$3,TrCreateNullTargetOp ());}
;
/*******************************************************************************
*
* All assignment-type operations -- math and logical. Includes simple
* assignment and compound assignments.
*
******************************************************************************/
EqualsTerm
/* Allow parens anywhere */
: PARSEOP_OPEN_PAREN
EqualsTerm
PARSEOP_CLOSE_PAREN {$$ = $2;}
/* Simple Store() operation */
| SuperName
PARSEOP_EXP_EQUALS
TermArg {$$ = TrCreateAssignmentOp ($1, $3);}
/* Chained equals: (a=RefOf)=b, a=b=c=d etc. */
| PARSEOP_OPEN_PAREN
EqualsTerm
PARSEOP_CLOSE_PAREN
PARSEOP_EXP_EQUALS
TermArg {$$ = TrCreateAssignmentOp ($2, $5);}
/* Compound assignments -- Add (operand, operand, target) */
| TermArg PARSEOP_EXP_ADD_EQ {$<n>$ = TrCreateLeafOp (PARSEOP_ADD);}
TermArg {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,
TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));}
| TermArg PARSEOP_EXP_DIV_EQ {$<n>$ = TrCreateLeafOp (PARSEOP_DIVIDE);}
TermArg {$$ = TrLinkOpChildren ($<n>3,4,$1,$4,TrCreateNullTargetOp (),
TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));}
| TermArg PARSEOP_EXP_MOD_EQ {$<n>$ = TrCreateLeafOp (PARSEOP_MOD);}
TermArg {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,
TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));}
| TermArg PARSEOP_EXP_MUL_EQ {$<n>$ = TrCreateLeafOp (PARSEOP_MULTIPLY);}
TermArg {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,
TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));}
| TermArg PARSEOP_EXP_SHL_EQ {$<n>$ = TrCreateLeafOp (PARSEOP_SHIFTLEFT);}
TermArg {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,
TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));}
| TermArg PARSEOP_EXP_SHR_EQ {$<n>$ = TrCreateLeafOp (PARSEOP_SHIFTRIGHT);}
TermArg {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,
TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));}
| TermArg PARSEOP_EXP_SUB_EQ {$<n>$ = TrCreateLeafOp (PARSEOP_SUBTRACT);}
TermArg {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,
TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));}
| TermArg PARSEOP_EXP_AND_EQ {$<n>$ = TrCreateLeafOp (PARSEOP_AND);}
TermArg {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,
TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));}
| TermArg PARSEOP_EXP_OR_EQ {$<n>$ = TrCreateLeafOp (PARSEOP_OR);}
TermArg {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,
TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));}
| TermArg PARSEOP_EXP_XOR_EQ {$<n>$ = TrCreateLeafOp (PARSEOP_XOR);}
TermArg {$$ = TrLinkOpChildren ($<n>3,3,$1,$4,
TrSetOpFlags (TrCreateTargetOp ($1, NULL), OP_IS_TARGET));}
;

View File

@@ -0,0 +1,480 @@
/******************************************************************************
*
* Module Name: asldebug -- Debug output support
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("asldebug")
/* Local prototypes */
static void
UtDumpParseOpName (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
UINT32 DataLength);
static char *
UtCreateEscapeSequences (
char *InString);
/*******************************************************************************
*
* FUNCTION: CvDbgPrint
*
* PARAMETERS: Type - Type of output
* Fmt - Printf format string
* ... - variable printf list
*
* RETURN: None
*
* DESCRIPTION: Print statement for debug messages within the converter.
*
******************************************************************************/
void
CvDbgPrint (
char *Fmt,
...)
{
va_list Args;
if (!AcpiGbl_CaptureComments || !AcpiGbl_DebugAslConversion)
{
return;
}
va_start (Args, Fmt);
(void) vfprintf (AcpiGbl_ConvDebugFile, Fmt, Args);
va_end (Args);
return;
}
/*******************************************************************************
*
* FUNCTION: UtDumpIntegerOp
*
* PARAMETERS: Op - Current parse op
* Level - Current output indentation level
* IntegerLength - Output length of the integer (2/4/8/16)
*
* RETURN: None
*
* DESCRIPTION: Emit formatted debug output for "integer" ops.
* Note: IntegerLength must be one of 2,4,8,16.
*
******************************************************************************/
void
UtDumpIntegerOp (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
UINT32 IntegerLength)
{
/* Emit the ParseOp name, leaving room for the integer */
UtDumpParseOpName (Op, Level, IntegerLength);
/* Emit the integer based upon length */
switch (IntegerLength)
{
case 2: /* Byte */
case 4: /* Word */
case 8: /* Dword */
DbgPrint (ASL_TREE_OUTPUT,
"%*.*X", IntegerLength, IntegerLength, (UINT32) Op->Asl.Value.Integer);
break;
case 16: /* Qword and Integer */
DbgPrint (ASL_TREE_OUTPUT,
"%8.8X%8.8X", ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer));
break;
default:
break;
}
}
/*******************************************************************************
*
* FUNCTION: UtDumpStringOp
*
* PARAMETERS: Op - Current parse op
* Level - Current output indentation level
*
* RETURN: None
*
* DESCRIPTION: Emit formatted debug output for String/Pathname ops.
*
******************************************************************************/
void
UtDumpStringOp (
ACPI_PARSE_OBJECT *Op,
UINT32 Level)
{
char *String;
String = Op->Asl.Value.String;
if (Op->Asl.ParseOpcode != PARSEOP_STRING_LITERAL)
{
/*
* For the "path" ops NAMEPATH, NAMESEG, METHODCALL -- if the
* ExternalName is valid, it takes precedence. In these cases the
* Value.String is the raw "internal" name from the AML code, which
* we don't want to use, because it contains non-ascii characters.
*/
if (Op->Asl.ExternalName)
{
String = Op->Asl.ExternalName;
}
}
if (!String)
{
DbgPrint (ASL_TREE_OUTPUT,
" ERROR: Could not find a valid String/Path pointer\n");
return;
}
String = UtCreateEscapeSequences (String);
/* Emit the ParseOp name, leaving room for the string */
UtDumpParseOpName (Op, Level, strlen (String));
DbgPrint (ASL_TREE_OUTPUT, "%s", String);
}
/*******************************************************************************
*
* FUNCTION: UtCreateEscapeSequences
*
* PARAMETERS: InString - ASCII string to be expanded
*
* RETURN: Expanded string
*
* DESCRIPTION: Expand all non-printable ASCII bytes (0-0x1F) to escape
* sequences. For example, hex 14 becomes \x14
*
* NOTE: Since this function is used for debug output only, it does
* not attempt to translate into the "known" escape sequences
* such as \a, \f, \t, etc.
*
******************************************************************************/
static char *
UtCreateEscapeSequences (
char *InString)
{
char *String = InString;
char *OutString;
char *OutStringPtr;
UINT32 InStringLength = 0;
UINT32 EscapeCount = 0;
/*
* Determine up front how many escapes are within the string.
* Obtain the input string length while doing so.
*/
while (*String)
{
if ((*String <= 0x1F) || (*String >= 0x7F))
{
EscapeCount++;
}
InStringLength++;
String++;
}
if (!EscapeCount)
{
return (InString); /* No escapes, nothing to do */
}
/* New string buffer, 3 extra chars per escape (4 total) */
OutString = UtLocalCacheCalloc (InStringLength + (EscapeCount * 3));
OutStringPtr = OutString;
/* Convert non-ascii or non-printable chars to escape sequences */
while (*InString)
{
if ((*InString <= 0x1F) || (*InString >= 0x7F))
{
/* Insert a \x hex escape sequence */
OutStringPtr[0] = '\\';
OutStringPtr[1] = 'x';
OutStringPtr[2] = AcpiUtHexToAsciiChar (*InString, 4);
OutStringPtr[3] = AcpiUtHexToAsciiChar (*InString, 0);
OutStringPtr += 4;
}
else /* Normal ASCII character */
{
*OutStringPtr = *InString;
OutStringPtr++;
}
InString++;
}
return (OutString);
}
/*******************************************************************************
*
* FUNCTION: UtDumpBasicOp
*
* PARAMETERS: Op - Current parse op
* Level - Current output indentation level
*
* RETURN: None
*
* DESCRIPTION: Generic formatted debug output for "basic" ops that have no
* associated strings or integer values.
*
******************************************************************************/
void
UtDumpBasicOp (
ACPI_PARSE_OBJECT *Op,
UINT32 Level)
{
/* Just print out the ParseOp name, there is no extra data */
UtDumpParseOpName (Op, Level, 0);
}
/*******************************************************************************
*
* FUNCTION: UtDumpParseOpName
*
* PARAMETERS: Op - Current parse op
* Level - Current output indentation level
* DataLength - Length of data to appear after the name
*
* RETURN: None
*
* DESCRIPTION: Indent and emit the ascii ParseOp name for the op
*
******************************************************************************/
static void
UtDumpParseOpName (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
UINT32 DataLength)
{
char *ParseOpName;
UINT32 IndentLength;
UINT32 NameLength;
UINT32 LineLength;
UINT32 PaddingLength;
/* Emit the LineNumber/IndentLevel prefix on each output line */
DbgPrint (ASL_TREE_OUTPUT,
"%5.5d [%2d]", Op->Asl.LogicalLineNumber, Level);
ParseOpName = UtGetOpName (Op->Asl.ParseOpcode);
/* Calculate various lengths for output alignment */
IndentLength = Level * DEBUG_SPACES_PER_INDENT;
NameLength = strlen (ParseOpName);
LineLength = IndentLength + 1 + NameLength + 1 + DataLength;
PaddingLength = (DEBUG_MAX_LINE_LENGTH + 1) - LineLength;
/* Parse tree indentation is based upon the nesting/indent level */
if (Level)
{
DbgPrint (ASL_TREE_OUTPUT, "%*s", IndentLength, " ");
}
/* Emit the actual name here */
DbgPrint (ASL_TREE_OUTPUT, " %s", ParseOpName);
/* Emit extra padding blanks for alignment of later data items */
if (LineLength > DEBUG_MAX_LINE_LENGTH)
{
/* Split a long line immediately after the ParseOpName string */
DbgPrint (ASL_TREE_OUTPUT, "\n%*s",
(DEBUG_FULL_LINE_LENGTH - DataLength), " ");
}
else
{
DbgPrint (ASL_TREE_OUTPUT, "%*s", PaddingLength, " ");
}
}

View File

@@ -0,0 +1,318 @@
/******************************************************************************
*
* Module Name: asldefine.h - Common defines for the iASL compiler
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#ifndef __ASLDEFINE_H
#define __ASLDEFINE_H
/*
* Compiler versions and names
*/
#define ASL_COMPILER_NAME "ASL+ Optimizing Compiler/Disassembler"
#define AML_DISASSEMBLER_NAME "AML/ASL+ Disassembler"
#define ASL_INVOCATION_NAME "iasl"
#define ASL_CREATOR_ID "INTL"
#define ASL_DEFINE "__IASL__"
#define ASL_PREFIX "iASL: "
#define ASL_COMPLIANCE "Supports ACPI Specification Revision 6.5"
/* Configuration constants */
#define ASL_MAX_ERROR_COUNT 200
#define ASL_PARSEOP_CACHE_SIZE (1024 * 16)
#define ASL_STRING_CACHE_SIZE (1024 * 64)
#define ASL_FIRST_PARSE_OPCODE PARSEOP_ACCESSAS
#define ASL_PARSE_OPCODE_BASE PARSEOP_ACCESSAS /* First Lex type */
/*
* Per-parser-generator configuration. These values are used to cheat and
* directly access the bison/yacc token name table (yyname or yytname).
* Note: These values are the index in yyname for the first lex token
* (PARSEOP_ACCCESSAS).
*/
#if defined (YYBISON)
#define ASL_YYTNAME_START 3 /* Bison */
#elif defined (YYBYACC)
#define ASL_YYTNAME_START 257 /* Berkeley yacc */
#endif
/*
* Macros
*/
#define ASL_RESDESC_OFFSET(m) ACPI_OFFSET (AML_RESOURCE, m)
#define ASL_PTR_DIFF(a,b) ((UINT8 *)(b) - (UINT8 *)(a))
#define ASL_PTR_ADD(a,b) ((UINT8 *)(a) = ((UINT8 *)(a) + (b)))
#define ASL_GET_CHILD_NODE(a) (a)->Asl.Child
#define ASL_GET_PEER_NODE(a) (a)->Asl.Next
#define OP_TABLE_ENTRY(a,b,c,d) {b,d,a,c}
/* Internal AML opcodes */
#define AML_RAW_DATA_BYTE (UINT16) 0xAA01 /* write one raw byte */
#define AML_RAW_DATA_WORD (UINT16) 0xAA02 /* write 2 raw bytes */
#define AML_RAW_DATA_DWORD (UINT16) 0xAA04 /* write 4 raw bytes */
#define AML_RAW_DATA_QWORD (UINT16) 0xAA08 /* write 8 raw bytes */
#define AML_RAW_DATA_BUFFER (UINT16) 0xAA0B /* raw buffer with length */
#define AML_RAW_DATA_CHAIN (UINT16) 0xAA0C /* chain of raw buffers */
#define AML_PACKAGE_LENGTH (UINT16) 0xAA10
#define AML_UNASSIGNED_OPCODE (UINT16) 0xEEEE
#define AML_DEFAULT_ARG_OP (UINT16) 0xDDDD
/* Types for input files */
#define ASL_INPUT_TYPE_BINARY 0
#define ASL_INPUT_TYPE_BINARY_ACPI_TABLE 1
#define ASL_INPUT_TYPE_ASCII_ASL 2
#define ASL_INPUT_TYPE_ASCII_DATA 3
/* Misc */
#define ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS 255
#define ASL_ABORT TRUE
#define ASL_NO_ABORT FALSE
#define ASL_EOF ACPI_UINT32_MAX
#define ASL_IGNORE_LINE (ACPI_UINT32_MAX -1)
#define ASL_ERROR_CODE_LENGTH 4
/* Listings */
#define ASL_LISTING_LINE_PREFIX ": "
/* Support for reserved method names */
#define ACPI_VALID_RESERVED_NAME_MAX 0x80000000
#define ACPI_NOT_RESERVED_NAME ACPI_UINT32_MAX
#define ACPI_PREDEFINED_NAME (ACPI_UINT32_MAX - 1)
#define ACPI_EVENT_RESERVED_NAME (ACPI_UINT32_MAX - 2)
#define ACPI_COMPILER_RESERVED_NAME (ACPI_UINT32_MAX - 3)
/* Helper macros for resource tag creation */
#define RsCreateMultiBitField \
RsCreateResourceField
#define RsCreateBitField(Op, Name, ByteOffset, BitOffset) \
RsCreateResourceField (Op, Name, ByteOffset, BitOffset, 1)
#define RsCreateByteField(Op, Name, ByteOffset) \
RsCreateResourceField (Op, Name, ByteOffset, 0, 8);
#define RsCreateWordField(Op, Name, ByteOffset) \
RsCreateResourceField (Op, Name, ByteOffset, 0, 16);
#define RsCreateDwordField(Op, Name, ByteOffset) \
RsCreateResourceField (Op, Name, ByteOffset, 0, 32);
#define RsCreateQwordField(Op, Name, ByteOffset) \
RsCreateResourceField (Op, Name, ByteOffset, 0, 64);
/*
* Macros for debug output
*/
#define DEBUG_MAX_LINE_LENGTH 61
#define DEBUG_SPACES_PER_INDENT 3
#define DEBUG_FULL_LINE_LENGTH 71
#define ASL_PARSE_TREE_FULL_LINE "\n%71.71s"
/* Header/Trailer for original parse tree directly from the parser */
#define ASL_PARSE_TREE_HEADER1 \
"%*s Value P_Op Flags Line# End# LogL# EndL#\n", 65, " "
#define ASL_PARSE_TREE_DEBUG1 \
" %4.4X %8.8X %5d %5d %5d %5d"
/* Header/Trailer for processed parse tree used for AML generation */
#define ASL_PARSE_TREE_HEADER2 \
"%*s NameString Value P_Op A_Op OpLen PByts Len SubLen PSubLen OpPtr"\
" Parent Child Next Flags AcTyp Final Col"\
" Line# End# LogL# EndL#\n", 60, " "
#define ASL_PARSE_TREE_DEBUG2 \
" %08X %04X %04X %01X %04X %04X %05X %05X "\
"%8p %8p %8p %8p %08X %08X %04X %02d %5d %5d %5d %5d"
/*
* Macros for ASL/ASL+ converter
*/
#define COMMENT_CAPTURE_ON AslGbl_CommentState.CaptureComments = TRUE;
#define COMMENT_CAPTURE_OFF AslGbl_CommentState.CaptureComments = FALSE;
/*
* Special name segments - these must only be declared at the root scope
*/
#define NAMESEG__PTS "_PTS"
#define NAMESEG__WAK "_WAK"
#define NAMESEG__S0 "_S0_"
#define NAMESEG__S1 "_S1_"
#define NAMESEG__S2 "_S2_"
#define NAMESEG__S3 "_S3_"
#define NAMESEG__S4 "_S4_"
#define NAMESEG__S5 "_S5_"
#define NAMESEG__TTS "_TTS"
#define MAX_SPECIAL_NAMES 9
#endif /* ASLDEFINE.H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,680 @@
/******************************************************************************
*
* Module Name: aslexternal - ASL External opcode compiler support
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "acparser.h"
#include "amlcode.h"
#include "acnamesp.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslexternal")
/* Local prototypes */
static void
ExInsertArgCount (
ACPI_PARSE_OBJECT *Op);
static void
ExMoveExternals (
ACPI_PARSE_OBJECT *DefinitionBlockOp);
/*******************************************************************************
*
* FUNCTION: ExDoExternal
*
* PARAMETERS: Op - Current Parse node
*
* RETURN: None
*
* DESCRIPTION: Add an External() definition to the global list. This list
* is used to generate External opcodes.
*
******************************************************************************/
void
ExDoExternal (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *ListOp;
ACPI_PARSE_OBJECT *Prev;
ACPI_PARSE_OBJECT *Next;
ACPI_PARSE_OBJECT *ArgCountOp;
ACPI_PARSE_OBJECT *TypeOp;
ACPI_PARSE_OBJECT *ExternTypeOp = Op->Asl.Child->Asl.Next;
UINT32 ExternType;
UINT8 ParamCount = ASL_EXTERNAL_METHOD_UNKNOWN_PARAMS;
UINT32 ParamTypes[ACPI_METHOD_NUM_ARGS];
ExternType = AnMapObjTypeToBtype (ExternTypeOp);
if (ExternType != ACPI_BTYPE_METHOD)
{
/*
* If this is not a method, it has zero parameters this local variable
* is used only for methods
*/
ParamCount = 0;
}
/*
* The parser allows optional parameter return types regardless of the
* type. Check object type keyword emit error if optional parameter/return
* types exist.
*
* Check the parameter return type
*/
TypeOp = ExternTypeOp->Asl.Next;
if (TypeOp->Asl.Child)
{
/* Ignore the return type for now. */
(void) MtProcessTypeOp (TypeOp->Asl.Child);
if (ExternType != ACPI_BTYPE_METHOD)
{
sprintf (AslGbl_MsgBuffer, "Found type [%s]", AcpiUtGetTypeName(ExternType));
AslError (ASL_ERROR, ASL_MSG_EXTERN_INVALID_RET_TYPE, TypeOp,
AslGbl_MsgBuffer);
}
}
/* Check the parameter types */
TypeOp = TypeOp->Asl.Next;
if (TypeOp->Asl.Child)
{
ParamCount = MtProcessParameterTypeList (TypeOp->Asl.Child, ParamTypes);
if (ExternType != ACPI_BTYPE_METHOD)
{
sprintf (AslGbl_MsgBuffer, "Found type [%s]", AcpiUtGetTypeName(ExternType));
AslError (ASL_ERROR, ASL_MSG_EXTERN_INVALID_PARAM_TYPE, TypeOp,
AslGbl_MsgBuffer);
}
}
ArgCountOp = Op->Asl.Child->Asl.Next->Asl.Next;
ArgCountOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
ArgCountOp->Asl.ParseOpcode = PARSEOP_BYTECONST;
ArgCountOp->Asl.Value.Integer = ParamCount;
UtSetParseOpName (ArgCountOp);
/* Create new list node of arbitrary type */
ListOp = TrAllocateOp (PARSEOP_DEFAULT_ARG);
/* Store External node as child */
ListOp->Asl.Child = Op;
ListOp->Asl.Next = NULL;
if (AslGbl_ExternalsListHead)
{
/* Link new External to end of list */
Prev = AslGbl_ExternalsListHead;
Next = Prev;
while (Next)
{
Prev = Next;
Next = Next->Asl.Next;
}
Prev->Asl.Next = ListOp;
}
else
{
AslGbl_ExternalsListHead = ListOp;
}
}
/*******************************************************************************
*
* FUNCTION: ExInsertArgCount
*
* PARAMETERS: Op - Op for a method invocation
*
* RETURN: None
*
* DESCRIPTION: Obtain the number of arguments for a control method -- from
* the actual invocation.
*
******************************************************************************/
static void
ExInsertArgCount (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *Next;
ACPI_PARSE_OBJECT *NameOp;
ACPI_PARSE_OBJECT *Child;
ACPI_PARSE_OBJECT *ArgCountOp;
char * ExternalName;
char * CallName;
UINT16 ArgCount = 0;
ACPI_STATUS Status;
CallName = AcpiNsGetNormalizedPathname (Op->Asl.Node, TRUE);
Next = AslGbl_ExternalsListHead;
while (Next)
{
ArgCount = 0;
/* Skip if External node already handled */
if (Next->Asl.Child->Asl.CompileFlags & OP_VISITED)
{
Next = Next->Asl.Next;
continue;
}
NameOp = Next->Asl.Child->Asl.Child;
ExternalName = AcpiNsGetNormalizedPathname (NameOp->Asl.Node, TRUE);
if (strcmp (CallName, ExternalName))
{
ACPI_FREE (ExternalName);
Next = Next->Asl.Next;
continue;
}
Next->Asl.Child->Asl.CompileFlags |= OP_VISITED;
/*
* Since we will reposition Externals to the Root, set Namepath
* to the fully qualified name and recalculate the aml length
*/
Status = UtInternalizeName (ExternalName,
&NameOp->Asl.Value.String);
ACPI_FREE (ExternalName);
if (ACPI_FAILURE (Status))
{
AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL,
NULL, "- Could not Internalize External");
break;
}
NameOp->Asl.AmlLength = strlen (NameOp->Asl.Value.String);
/* Get argument count */
Child = Op->Asl.Child;
while (Child)
{
ArgCount++;
Child = Child->Asl.Next;
}
/* Setup ArgCount operand */
ArgCountOp = Next->Asl.Child->Asl.Child->Asl.Next->Asl.Next;
ArgCountOp->Asl.Value.Integer = ArgCount;
break;
}
ACPI_FREE (CallName);
}
/*******************************************************************************
*
* FUNCTION: ExAmlExternalWalkBegin
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: None
*
* DESCRIPTION: Parse tree walk to create external opcode list for methods.
*
******************************************************************************/
ACPI_STATUS
ExAmlExternalWalkBegin (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
/* External list head saved in the definition block op */
if (Op->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK)
{
AslGbl_ExternalsListHead = Op->Asl.Value.Arg;
}
if (!AslGbl_ExternalsListHead)
{
return (AE_OK);
}
if (Op->Asl.ParseOpcode != PARSEOP_METHODCALL)
{
return (AE_OK);
}
/*
* The NameOp child under an ExternalOp gets turned into PARSE_METHODCALL
* by XfNamespaceLocateBegin(). Ignore these.
*/
if (Op->Asl.Parent &&
Op->Asl.Parent->Asl.ParseOpcode == PARSEOP_EXTERNAL)
{
return (AE_OK);
}
ExInsertArgCount (Op);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: ExAmlExternalWalkEnd
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: None
*
* DESCRIPTION: Parse tree walk to create external opcode list for methods.
* Here, we just want to catch the case where a definition block
* has been completed. Then we move all of the externals into
* a single block in the parse tree and thus the AML code.
*
******************************************************************************/
ACPI_STATUS
ExAmlExternalWalkEnd (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
if (Op->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK)
{
/*
* Process any existing external list. (Support for
* multiple definition blocks in a single file/compile)
*/
ExMoveExternals (Op);
AslGbl_ExternalsListHead = NULL;
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: ExMoveExternals
*
* PARAMETERS: DefinitionBlockOp - Op for current definition block
*
* RETURN: None
*
* DESCRIPTION: Move all externals present in the source file into a single
* block of AML code, surrounded by an "If (0)" to prevent
* AML interpreters from attempting to execute the External
* opcodes.
*
******************************************************************************/
static void
ExMoveExternals (
ACPI_PARSE_OBJECT *DefinitionBlockOp)
{
ACPI_PARSE_OBJECT *ParentOp;
ACPI_PARSE_OBJECT *ExternalOp;
ACPI_PARSE_OBJECT *PredicateOp;
ACPI_PARSE_OBJECT *NextOp;
ACPI_PARSE_OBJECT *Prev;
ACPI_PARSE_OBJECT *Next;
char *ExternalName;
ACPI_OBJECT_TYPE ObjType;
ACPI_STATUS Status;
UINT32 i;
if (!AslGbl_ExternalsListHead)
{
return;
}
/* Remove the External nodes from the tree */
NextOp = AslGbl_ExternalsListHead;
while (NextOp)
{
/*
* The External is stored in child pointer of each node in the
* list
*/
ExternalOp = NextOp->Asl.Child;
/* Get/set the fully qualified name */
ExternalName = AcpiNsGetNormalizedPathname (ExternalOp->Asl.Node, TRUE);
ExternalOp->Asl.ExternalName = ExternalName;
ExternalOp->Asl.Namepath = ExternalName;
/* Set line numbers (for listings, etc.) */
ExternalOp->Asl.LineNumber = 0;
ExternalOp->Asl.LogicalLineNumber = 0;
Next = ExternalOp->Asl.Child;
Next->Asl.LineNumber = 0;
Next->Asl.LogicalLineNumber = 0;
if (Next->Asl.ParseOpcode == PARSEOP_NAMESEG)
{
Next->Asl.ParseOpcode = PARSEOP_NAMESTRING;
}
Next->Asl.ExternalName = ExternalName;
Status = UtInternalizeName (ExternalName, &Next->Asl.Value.String);
if (ACPI_FAILURE (Status))
{
AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL,
Next, "Could not internalize namestring");
return;
}
Next->Asl.AmlLength = strlen (Next->Asl.Value.String);
Next = Next->Asl.Next;
Next->Asl.LineNumber = 0;
Next->Asl.LogicalLineNumber = 0;
Next = Next->Asl.Next;
Next->Asl.LineNumber = 0;
Next->Asl.LogicalLineNumber = 0;
Next = Next->Asl.Next;
Next->Asl.LineNumber = 0;
Next->Asl.LogicalLineNumber = 0;
ParentOp = ExternalOp->Asl.Parent;
Prev = Next = ParentOp->Asl.Child;
/* Now find the External node's position in parse tree */
while (Next != ExternalOp)
{
Prev = Next;
Next = Next->Asl.Next;
}
/* Remove the External from the parse tree */
if (Prev == ExternalOp)
{
/* External was the first child node */
ParentOp->Asl.Child = ExternalOp->Asl.Next;
}
Prev->Asl.Next = ExternalOp->Asl.Next;
ExternalOp->Asl.Next = NULL;
ExternalOp->Asl.Parent = AslGbl_ExternalsListHead;
/* Point the External to the next in the list */
if (NextOp->Asl.Next)
{
ExternalOp->Asl.Next = NextOp->Asl.Next->Asl.Child;
}
NextOp = NextOp->Asl.Next;
}
/*
* Loop again to remove MethodObj Externals for which
* a MethodCall was not found (dead external reference)
*/
Prev = AslGbl_ExternalsListHead->Asl.Child;
Next = Prev;
while (Next)
{
ObjType = (ACPI_OBJECT_TYPE)
Next->Asl.Child->Asl.Next->Asl.Value.Integer;
if (ObjType == ACPI_TYPE_METHOD &&
!(Next->Asl.CompileFlags & OP_VISITED))
{
if (Next == Prev)
{
AslGbl_ExternalsListHead->Asl.Child = Next->Asl.Next;
Next->Asl.Next = NULL;
Prev = AslGbl_ExternalsListHead->Asl.Child;
Next = Prev;
continue;
}
else
{
Prev->Asl.Next = Next->Asl.Next;
Next->Asl.Next = NULL;
Next = Prev->Asl.Next;
continue;
}
}
Prev = Next;
Next = Next->Asl.Next;
}
/* If list is now empty, don't bother to make If (0) block */
if (!AslGbl_ExternalsListHead->Asl.Child)
{
return;
}
/* Convert Gbl_ExternalsListHead parent to If(). */
AslGbl_ExternalsListHead->Asl.ParseOpcode = PARSEOP_IF;
AslGbl_ExternalsListHead->Asl.AmlOpcode = AML_IF_OP;
AslGbl_ExternalsListHead->Asl.CompileFlags = OP_AML_PACKAGE;
UtSetParseOpName (AslGbl_ExternalsListHead);
/* Create a Zero op for the If predicate */
PredicateOp = TrAllocateOp (PARSEOP_ZERO);
PredicateOp->Asl.AmlOpcode = AML_ZERO_OP;
PredicateOp->Asl.Parent = AslGbl_ExternalsListHead;
PredicateOp->Asl.Child = NULL;
PredicateOp->Asl.Next = AslGbl_ExternalsListHead->Asl.Child;
AslGbl_ExternalsListHead->Asl.Child = PredicateOp;
/* Set line numbers (for listings, etc.) */
AslGbl_ExternalsListHead->Asl.LineNumber = 0;
AslGbl_ExternalsListHead->Asl.LogicalLineNumber = 0;
PredicateOp->Asl.LineNumber = 0;
PredicateOp->Asl.LogicalLineNumber = 0;
/* Insert block back in the list */
Prev = DefinitionBlockOp->Asl.Child;
Next = Prev;
/* Find last default arg */
for (i = 0; i < 6; i++)
{
Prev = Next;
Next = Prev->Asl.Next;
}
if (Next)
{
/* Definition Block is not empty */
AslGbl_ExternalsListHead->Asl.Next = Next;
}
else
{
/* Definition Block is empty. */
AslGbl_ExternalsListHead->Asl.Next = NULL;
}
Prev->Asl.Next = AslGbl_ExternalsListHead;
AslGbl_ExternalsListHead->Asl.Parent = Prev->Asl.Parent;
}

View File

@@ -0,0 +1,509 @@
/******************************************************************************
*
* Module Name: aslfileio - File I/O support
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "acapps.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslfileio")
/*******************************************************************************
*
* FUNCTION: FlFileError
*
* PARAMETERS: FileId - Index into file info array
* ErrorId - Index into error message array
*
* RETURN: None
*
* DESCRIPTION: Decode errno to an error message and add the entire error
* to the error log.
*
******************************************************************************/
void
FlFileError (
UINT32 FileId,
UINT8 ErrorId)
{
sprintf (AslGbl_MsgBuffer, "\"%s\" (%s) - %s", AslGbl_Files[FileId].Filename,
AslGbl_FileDescs[FileId].Description, strerror (errno));
AslCommonError (ASL_ERROR, ErrorId, 0, 0, 0, 0, NULL, AslGbl_MsgBuffer);
}
/*******************************************************************************
*
* FUNCTION: FlOpenFile
*
* PARAMETERS: FileId - Index into file info array
* Filename - file pathname to open
* Mode - Open mode for fopen
*
* RETURN: None
*
* DESCRIPTION: Open a file.
* NOTE: Aborts compiler on any error.
*
******************************************************************************/
void
FlOpenFile (
UINT32 FileId,
char *Filename,
char *Mode)
{
FILE *File;
AslGbl_Files[FileId].Filename = Filename;
AslGbl_Files[FileId].Handle = NULL;
File = fopen (Filename, Mode);
if (!File)
{
FlFileError (FileId, ASL_MSG_OPEN);
AslAbort ();
}
AslGbl_Files[FileId].Handle = File;
}
/*******************************************************************************
*
* FUNCTION: FlGetFileSize
*
* PARAMETERS: FileId - Index into file info array
*
* RETURN: File Size
*
* DESCRIPTION: Get current file size. Uses common seek-to-EOF function.
* File must be open. Aborts compiler on error.
*
******************************************************************************/
UINT32
FlGetFileSize (
UINT32 FileId)
{
UINT32 FileSize;
FileSize = CmGetFileSize (AslGbl_Files[FileId].Handle);
if (FileSize == ACPI_UINT32_MAX)
{
AslAbort();
}
return (FileSize);
}
/*******************************************************************************
*
* FUNCTION: FlReadFile
*
* PARAMETERS: FileId - Index into file info array
* Buffer - Where to place the data
* Length - Amount to read
*
* RETURN: Status. AE_ERROR indicates EOF.
*
* DESCRIPTION: Read data from an open file.
* NOTE: Aborts compiler on any error.
*
******************************************************************************/
ACPI_STATUS
FlReadFile (
UINT32 FileId,
void *Buffer,
UINT32 Length)
{
UINT32 Actual;
/* Read and check for error */
Actual = fread (Buffer, 1, Length, AslGbl_Files[FileId].Handle);
if (Actual < Length)
{
if (feof (AslGbl_Files[FileId].Handle))
{
/* End-of-file, just return error */
return (AE_ERROR);
}
FlFileError (FileId, ASL_MSG_READ);
AslAbort ();
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: FlWriteFile
*
* PARAMETERS: FileId - Index into file info array
* Buffer - Data to write
* Length - Amount of data to write
*
* RETURN: None
*
* DESCRIPTION: Write data to an open file.
* NOTE: Aborts compiler on any error.
*
******************************************************************************/
void
FlWriteFile (
UINT32 FileId,
void *Buffer,
UINT32 Length)
{
UINT32 Actual;
/* Write and check for error */
Actual = fwrite ((char *) Buffer, 1, Length, AslGbl_Files[FileId].Handle);
if (Actual != Length)
{
FlFileError (FileId, ASL_MSG_WRITE);
AslAbort ();
}
if ((FileId == ASL_FILE_PREPROCESSOR) && AslGbl_PreprocessorOutputFlag)
{
/* Duplicate the output to the user preprocessor (.i) file */
Actual = fwrite ((char *) Buffer, 1, Length,
AslGbl_Files[ASL_FILE_PREPROCESSOR_USER].Handle);
if (Actual != Length)
{
FlFileError (FileId, ASL_MSG_WRITE);
AslAbort ();
}
}
}
/*******************************************************************************
*
* FUNCTION: FlPrintFile
*
* PARAMETERS: FileId - Index into file info array
* Format - Printf format string
* ... - Printf arguments
*
* RETURN: None
*
* DESCRIPTION: Formatted write to an open file.
* NOTE: Aborts compiler on any error.
*
******************************************************************************/
void
FlPrintFile (
UINT32 FileId,
char *Format,
...)
{
INT32 Actual;
va_list Args;
va_start (Args, Format);
Actual = vfprintf (AslGbl_Files[FileId].Handle, Format, Args);
va_end (Args);
if (Actual == -1)
{
FlFileError (FileId, ASL_MSG_WRITE);
AslAbort ();
}
if ((FileId == ASL_FILE_PREPROCESSOR) &&
AslGbl_PreprocessorOutputFlag)
{
/*
* Duplicate the output to the user preprocessor (.i) file,
* except: no #line directives.
*/
if (!strncmp (Format, "#line", 5))
{
return;
}
va_start (Args, Format);
Actual = vfprintf (AslGbl_Files[ASL_FILE_PREPROCESSOR_USER].Handle,
Format, Args);
va_end (Args);
if (Actual == -1)
{
FlFileError (FileId, ASL_MSG_WRITE);
AslAbort ();
}
}
}
/*******************************************************************************
*
* FUNCTION: FlSeekFile
*
* PARAMETERS: FileId - Index into file info array
* Offset - Absolute byte offset in file
*
* RETURN: None
*
* DESCRIPTION: Seek to absolute offset.
* NOTE: Aborts compiler on any error.
*
******************************************************************************/
void
FlSeekFile (
UINT32 FileId,
long Offset)
{
int Error;
Error = fseek (AslGbl_Files[FileId].Handle, Offset, SEEK_SET);
if (Error)
{
FlFileError (FileId, ASL_MSG_SEEK);
AslAbort ();
}
}
/*******************************************************************************
*
* FUNCTION: FlCloseFile
*
* PARAMETERS: FileId - Index into file info array
*
* RETURN: None
*
* DESCRIPTION: Close an open file. Aborts compiler on error
*
******************************************************************************/
void
FlCloseFile (
UINT32 FileId)
{
int Error;
if (!AslGbl_Files[FileId].Handle)
{
return;
}
Error = fclose (AslGbl_Files[FileId].Handle);
if (Error)
{
FlFileError (FileId, ASL_MSG_CLOSE);
AslAbort ();
}
/* Do not clear/free the filename string */
AslGbl_Files[FileId].Handle = NULL;
return;
}
/*******************************************************************************
*
* FUNCTION: FlDeleteFile
*
* PARAMETERS: FileId - Index into file info array
*
* RETURN: None
*
* DESCRIPTION: Delete a file.
*
******************************************************************************/
void
FlDeleteFile (
UINT32 FileId)
{
ASL_FILE_INFO *Info = &AslGbl_Files[FileId];
if (!Info->Filename)
{
return;
}
if (remove (Info->Filename))
{
printf ("%s (%s file) ",
Info->Filename, AslGbl_FileDescs[FileId].Description);
perror ("Could not delete");
}
Info->Filename = NULL;
return;
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,461 @@
/******************************************************************************
*
* Module Name: aslglobal.h - Global variable definitions
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#ifndef __ASLGLOBAL_H
#define __ASLGLOBAL_H
/*
* Global variables. Defined in aslmain.c only, externed in all other files
*/
#undef ASL_EXTERN
#ifdef _DECLARE_GLOBALS
#define ASL_EXTERN
#define ASL_INIT_GLOBAL(a,b) (a)=(b)
#else
#define ASL_EXTERN extern
#define ASL_INIT_GLOBAL(a,b) (a)
#endif
#ifdef _DECLARE_GLOBALS
UINT32 AslGbl_ExceptionCount[ASL_NUM_REPORT_LEVELS] = {0,0,0,0,0,0};
/* Table below must match ASL_FILE_TYPES in asltypes.h */
ASL_FILE_DESC AslGbl_FileDescs [ASL_NUM_FILES] =
{
{"stdout: ", "Standard Output"},
{"stderr: ", "Standard Error"},
{"Table Input: ", "Source Input"},
{"Binary Output:", "AML Output"},
{"Source Output:", "Source Output"},
{"Preprocessor: ", "Preprocessor Output"},
{"Preprocessor: ", "Preprocessor Temp File"},
{"Listing File: ", "Listing Output"},
{"Hex Dump: ", "Hex Table Output"},
{"Namespace: ", "Namespace Output"},
{"Debug File: ", "Debug Output"},
{"ASM Source: ", "Assembly Code Output"},
{"C Source: ", "C Code Output"},
{"ASM Include: ", "Assembly Header Output"},
{"C Include: ", "C Header Output"},
{"Offset Table: ", "C Offset Table Output"},
{"Device Map: ", "Device Map Output"},
{"Cross Ref: ", "Cross-reference Output"},
{"Converter dbg:", "Converter debug Output"}
};
/* Table below must match the defines with the same names in actypes.h */
const char *AslGbl_OpFlagNames[ACPI_NUM_OP_FLAGS] =
{
"OP_VISITED",
"OP_AML_PACKAGE",
"OP_IS_TARGET",
"OP_IS_RESOURCE_DESC",
"OP_IS_RESOURCE_FIELD",
"OP_HAS_NO_EXIT",
"OP_IF_HAS_NO_EXIT",
"OP_NAME_INTERNALIZED",
"OP_METHOD_NO_RETVAL",
"OP_METHOD_SOME_NO_RETVAL",
"OP_RESULT_NOT_USED",
"OP_METHOD_TYPED",
"OP_COULD_NOT_REDUCE",
"OP_COMPILE_TIME_CONST",
"OP_IS_TERM_ARG",
"OP_WAS_ONES_OP",
"OP_IS_NAME_DECLARATION",
"OP_COMPILER_EMITTED",
"OP_IS_DUPLICATE",
"OP_IS_RESOURCE_DATA",
"OP_IS_NULL_RETURN",
"OP_NOT_FOUND_DURING_LOAD"
};
const char *AslGbl_SpecialNamedObjects [MAX_SPECIAL_NAMES] =
{
NAMESEG__PTS,
NAMESEG__WAK,
NAMESEG__S0,
NAMESEG__S1,
NAMESEG__S2,
NAMESEG__S3,
NAMESEG__S4,
NAMESEG__S5,
NAMESEG__TTS
};
#else
extern ASL_FILE_DESC AslGbl_FileDescs [ASL_NUM_FILES];
extern UINT32 AslGbl_ExceptionCount[ASL_NUM_REPORT_LEVELS];
extern const char *AslGbl_OpFlagNames[ACPI_NUM_OP_FLAGS];
extern const char *AslGbl_SpecialNamedObjects[MAX_SPECIAL_NAMES];
#endif
/*
* Parser and other externals
*/
extern int yydebug;
extern FILE *AslCompilerin;
extern int DtParserdebug;
extern int PrParserdebug;
extern const ASL_MAPPING_ENTRY AslKeywordMapping[];
extern char *AslCompilertext;
extern char *DtCompilerParsertext;
/*
* Older versions of Bison won't emit this external in the generated header.
* Newer versions do emit the external, so we don't need to do it.
*/
#ifndef ASLCOMPILER_ASLCOMPILERPARSE_H
extern int AslCompilerdebug;
#endif
#define ASL_DEFAULT_LINE_BUFFER_SIZE (1024 * 32) /* 32K */
#define ASL_MSG_BUFFER_SIZE (1024 * 128) /* 128k */
#define ASL_STRING_BUFFER_SIZE (1024 * 32) /* 32k */
#define ASL_MAX_DISABLED_MESSAGES 32
#define ASL_MAX_EXPECTED_MESSAGES 32
#define ASL_MAX_ELEVATED_MESSAGES 32
#define HEX_TABLE_LINE_SIZE 8
#define HEX_LISTING_LINE_SIZE 8
/* Source code buffers and pointers for error reporting */
ASL_EXTERN char ASL_INIT_GLOBAL (*AslGbl_CurrentLineBuffer, NULL);
ASL_EXTERN char ASL_INIT_GLOBAL (*AslGbl_LineBufPtr, NULL);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_LineBufferSize, ASL_DEFAULT_LINE_BUFFER_SIZE);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_CurrentColumn, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_CurrentLineNumber, 1);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_LogicalLineNumber, 1);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_CurrentLineOffset, 0);
ASL_EXTERN UINT8 ASL_INIT_GLOBAL (AslGbl_SyntaxError, 0);
/* Exception reporting */
ASL_EXTERN ASL_ERROR_MSG ASL_INIT_GLOBAL (*AslGbl_ErrorLog,NULL);
ASL_EXTERN ASL_ERROR_MSG ASL_INIT_GLOBAL (*AslGbl_NextError,NULL);
/* Option flags */
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_DoCompile, TRUE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_DoSignon, TRUE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_PreprocessOnly, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_PreprocessFlag, TRUE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_DisassembleAll, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_UseDefaultAmlFilename, TRUE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_MapfileFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_NsOutputFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_PreprocessorOutputFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_KeepPreprocessorTempFile, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_DebugFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_CrossReferenceOutput, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_AsmOutputFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_C_OutputFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_C_OffsetTableFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_AsmIncludeOutputFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_C_IncludeOutputFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_ListingFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_IgnoreErrors, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_SourceOutputFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_ParseOnlyFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_ParserErrorDetected, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_CompileTimesFlag, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_FoldConstants, TRUE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_VerboseErrors, TRUE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_NoErrors, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_WarningsAsErrors, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_NoResourceChecking, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_IntegerOptimizationFlag, TRUE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_ReferenceOptimizationFlag, TRUE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_DisplayRemarks, TRUE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_DisplayWarnings, TRUE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_DisplayOptimizations, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_Deterministic, TRUE);
ASL_EXTERN UINT8 ASL_INIT_GLOBAL (AslGbl_WarningLevel, ASL_WARNING);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_UseOriginalCompilerId, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_VerboseTemplates, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_DoTemplates, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_CompileGeneric, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_AllExceptionsDisabled, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_PruneParseTree, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_DoTypechecking, TRUE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_EnableReferenceTypechecking, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_DoExternalsInPlace, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_DoAslConversion, FALSE);
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_OptimizeTrivialParseNodes, TRUE);
#define HEX_OUTPUT_NONE 0
#define HEX_OUTPUT_C 1
#define HEX_OUTPUT_ASM 2
#define HEX_OUTPUT_ASL 3
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_HexOutputFlag, HEX_OUTPUT_NONE);
/* Files */
ASL_EXTERN BOOLEAN ASL_INIT_GLOBAL (AslGbl_HasIncludeFiles, FALSE);
ASL_EXTERN char *AslGbl_DirectoryPath;
ASL_EXTERN char *AslGbl_CurrentInputFilename;
ASL_EXTERN char ASL_INIT_GLOBAL (*AslGbl_IncludeFilename, NULL);
ASL_EXTERN char ASL_INIT_GLOBAL (*AslGbl_OutputFilenamePrefix, NULL);
ASL_EXTERN ASL_INCLUDE_DIR ASL_INIT_GLOBAL (*AslGbl_IncludeDirList, NULL);
ASL_EXTERN char ASL_INIT_GLOBAL (*AslGbl_ExternalRefFilename, NULL);
ASL_EXTERN char ASL_INIT_GLOBAL (*AslGbl_PreviousIncludeFilename, NULL);
/* Statistics */
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_InputByteCount, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_InputFieldCount, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_NsLookupCount, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_TotalKeywords, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_TotalNamedObjects, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_TotalExecutableOpcodes, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_TotalParseNodes, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_TotalMethods, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_TotalAllocations, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_TotalAllocated, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_TotalFolds, 0);
/* Local caches */
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_ParseOpCount, 0);
ASL_EXTERN ASL_CACHE_INFO ASL_INIT_GLOBAL (*AslGbl_ParseOpCacheList, NULL);
ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*AslGbl_ParseOpCacheNext, NULL);
ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*AslGbl_ParseOpCacheLast, NULL);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_StringCount, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_StringSize, 0);
ASL_EXTERN ASL_CACHE_INFO ASL_INIT_GLOBAL (*AslGbl_StringCacheList, NULL);
ASL_EXTERN char ASL_INIT_GLOBAL (*AslGbl_StringCacheNext, NULL);
ASL_EXTERN char ASL_INIT_GLOBAL (*AslGbl_StringCacheLast, NULL);
/* Map file */
ASL_EXTERN ACPI_GPIO_INFO ASL_INIT_GLOBAL (*AslGbl_GpioList, NULL);
ASL_EXTERN ACPI_SERIAL_INFO ASL_INIT_GLOBAL (*AslGbl_SerialList, NULL);
/* Misc */
ASL_EXTERN UINT8 ASL_INIT_GLOBAL (AslGbl_RevisionOverride, 0);
ASL_EXTERN UINT8 ASL_INIT_GLOBAL (AslGbl_TempCount, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_TableLength, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_SourceLine, 0);
ASL_EXTERN UINT8 ASL_INIT_GLOBAL (AslGbl_FileType, 0);
ASL_EXTERN char ASL_INIT_GLOBAL (*AslGbl_Signature, NULL);
ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*AslGbl_ParseTreeRoot, NULL);
ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*AslGbl_CurrentDB, NULL);
ASL_EXTERN ACPI_PARSE_OBJECT ASL_INIT_GLOBAL (*AslGbl_ExternalsListHead, NULL);
ASL_EXTERN ASL_LISTING_NODE ASL_INIT_GLOBAL (*AslGbl_ListingNode, NULL);
ASL_EXTERN ACPI_PARSE_OBJECT *AslGbl_FirstLevelInsertionNode;
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_CurrentHexColumn, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_CurrentAmlOffset, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_CurrentLine, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_DisabledMessagesIndex, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_ExpectedMessagesIndex, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_ElevatedMessagesIndex, 0);
ASL_EXTERN UINT8 ASL_INIT_GLOBAL (AslGbl_HexBytesWereWritten, FALSE);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_NumNamespaceObjects, 0);
ASL_EXTERN UINT32 ASL_INIT_GLOBAL (AslGbl_ReservedMethods, 0);
ASL_EXTERN UINT8 ASL_INIT_GLOBAL (AslGbl_PruneDepth, 0);
ASL_EXTERN UINT16 ASL_INIT_GLOBAL (AslGbl_PruneType, 0);
ASL_EXTERN ASL_FILE_NODE ASL_INIT_GLOBAL (*AslGbl_IncludeFileStack, NULL);
ASL_EXTERN char ASL_INIT_GLOBAL (*AslGbl_TableSignature, "NO_SIG");
ASL_EXTERN char ASL_INIT_GLOBAL (*AslGbl_TableId, "NO_ID");
ASL_EXTERN ASL_FILE_INFO ASL_INIT_GLOBAL (*AslGbl_Files, NULL);
ASL_EXTERN ASL_GLOBAL_FILE_NODE ASL_INIT_GLOBAL (*AslGbl_FilesList, NULL);
ASL_EXTERN ASL_EXPECTED_MSG_NODE ASL_INIT_GLOBAL (*AslGbl_ExpectedErrorCodeList, NULL);
/* Specific to the -q option */
ASL_EXTERN ASL_COMMENT_STATE AslGbl_CommentState;
/*
* Determines if an inline comment should be saved in the InlineComment or NodeEndComment
* field of ACPI_PARSE_OBJECT.
*/
ASL_EXTERN ACPI_COMMENT_NODE ASL_INIT_GLOBAL (*AslGbl_CommentListHead, NULL);
ASL_EXTERN ACPI_COMMENT_NODE ASL_INIT_GLOBAL (*AslGbl_CommentListTail, NULL);
ASL_EXTERN char ASL_INIT_GLOBAL (*AslGbl_InlineCommentBuffer, NULL);
/* Static structures */
ASL_EXTERN ASL_ANALYSIS_WALK_INFO AslGbl_AnalysisWalkInfo;
ASL_EXTERN ACPI_TABLE_HEADER AslGbl_TableHeader;
/* Event timing */
#define ASL_NUM_EVENTS 24
ASL_EXTERN ASL_EVENT_INFO AslGbl_Events[ASL_NUM_EVENTS];
ASL_EXTERN UINT8 AslGbl_NextEvent;
ASL_EXTERN UINT8 AslGbl_NamespaceEvent;
/* Scratch buffers */
ASL_EXTERN UINT8 AslGbl_AmlBuffer[HEX_LISTING_LINE_SIZE];
ASL_EXTERN char AslGbl_MsgBuffer[ASL_MSG_BUFFER_SIZE];
ASL_EXTERN char AslGbl_StringBuffer[ASL_STRING_BUFFER_SIZE];
ASL_EXTERN char AslGbl_StringBuffer2[ASL_STRING_BUFFER_SIZE];
ASL_EXTERN UINT32 AslGbl_DisabledMessages[ASL_MAX_DISABLED_MESSAGES];
ASL_EXTERN ASL_EXPECTED_MESSAGE AslGbl_ExpectedMessages[ASL_MAX_EXPECTED_MESSAGES];
ASL_EXTERN UINT32 AslGbl_ElevatedMessages[ASL_MAX_ELEVATED_MESSAGES];
#endif /* __ASLGLOBAL_H */

View File

@@ -0,0 +1,339 @@
/******************************************************************************
*
* Module Name: aslhelp - iASL help screens
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "acapps.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslhelp")
/*******************************************************************************
*
* FUNCTION: Usage
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Display option help message.
* Optional items in square brackets.
*
******************************************************************************/
void
Usage (
void)
{
printf (ACPI_COMMON_SIGNON (ASL_COMPILER_NAME));
printf ("%s\n\n", ASL_COMPLIANCE);
ACPI_USAGE_HEADER ("iasl [Options] [Files]");
printf ("\nGeneral:\n");
ACPI_OPTION ("-@ <file>", "Specify command file");
ACPI_OPTION ("-I <dir>", "Specify additional include directory");
ACPI_OPTION ("-p <prefix>", "Specify path/filename prefix for all output files");
ACPI_OPTION ("-v", "Display compiler version");
ACPI_OPTION ("-vd", "Display compiler build date and time");
ACPI_OPTION ("-vo", "Enable optimization comments");
ACPI_OPTION ("-vs", "Disable signon");
ACPI_OPTION ("-ld", "Disable deterministic output");
printf ("\nHelp:\n");
ACPI_OPTION ("-h", "This message");
ACPI_OPTION ("-hc", "Display operators allowed in constant expressions");
ACPI_OPTION ("-hd", "Info for obtaining and disassembling binary ACPI tables");
ACPI_OPTION ("-hf", "Display help for output filename generation");
ACPI_OPTION ("-hr", "Display ACPI reserved method names");
ACPI_OPTION ("-ht", "Display currently supported ACPI table names");
printf ("\nPreprocessor:\n");
ACPI_OPTION ("-D <symbol>", "Define symbol for preprocessor use");
ACPI_OPTION ("-li", "Create preprocessed output file (*.i)");
ACPI_OPTION ("-P", "Preprocess only and create preprocessor output file (*.i)");
ACPI_OPTION ("-Pn", "Disable preprocessor");
printf ("\nErrors, Warnings, and Remarks:\n");
ACPI_OPTION ("-va", "Disable all errors/warnings/remarks");
ACPI_OPTION ("-ve", "Report only errors (ignore warnings and remarks)");
ACPI_OPTION ("-vi", "Less verbose errors and warnings for use with IDEs");
ACPI_OPTION ("-vr", "Disable remarks");
ACPI_OPTION ("-vw <messageid>", "Ignore specific error, warning or remark");
ACPI_OPTION ("-vx <messageid>", "Expect a specific warning, remark, or error");
ACPI_OPTION ("-w <1|2|3>", "Set warning reporting level");
ACPI_OPTION ("-we", "Report warnings as errors");
ACPI_OPTION ("-ww <messageid>", "Report specific warning or remark as error");
printf ("\nAML Bytecode Generation (*.aml):\n");
ACPI_OPTION ("-oa", "Disable all optimizations (compatibility mode)");
ACPI_OPTION ("-of", "Disable constant folding");
ACPI_OPTION ("-oi", "Disable integer optimization to Zero/One/Ones");
ACPI_OPTION ("-on", "Disable named reference string optimization");
ACPI_OPTION ("-ot", "Disable typechecking");
ACPI_OPTION ("-cr", "Disable Resource Descriptor error checking");
ACPI_OPTION ("-in", "Ignore NoOp operators");
ACPI_OPTION ("-r <revision>", "Override table header Revision (1-255)");
printf ("\nListings:\n");
ACPI_OPTION ("-l", "Create mixed listing file (ASL source and AML) (*.lst)");
ACPI_OPTION ("-lm", "Create hardware summary map file (*.map)");
ACPI_OPTION ("-ln", "Create namespace file (*.nsp)");
ACPI_OPTION ("-ls", "Create combined source file (expanded includes) (*.src)");
ACPI_OPTION ("-lx", "Create cross-reference file (*.xrf)");
printf ("\nFirmware Support - C Text Output:\n");
ACPI_OPTION ("-tc", "Create hex AML table in C (*.hex)");
ACPI_OPTION ("-sc", "Create named hex AML arrays in C (*.c)");
ACPI_OPTION ("-ic", "Create include file in C for -sc symbols (*.h)");
ACPI_OPTION ("-so", "Create namespace AML offset table in C (*.offset.h)");
printf ("\nFirmware Support - Assembler Text Output:\n");
ACPI_OPTION ("-ta", "Create hex AML table in assembler (*.hex)");
ACPI_OPTION ("-sa", "Create named hex AML arrays in assembler (*.asm)");
ACPI_OPTION ("-ia", "Create include file in assembler for -sa symbols (*.inc)");
printf ("\nFirmware Support - ASL Text Output:\n");
ACPI_OPTION ("-ts", "Create hex AML table in ASL (Buffer object) (*.hex)");
printf ("\nLegacy-ASL to ASL+ Converter:\n");
ACPI_OPTION ("-ca <file>", "Convert legacy-ASL source file to new ASL+ file");
ACPI_OPTION ("", " (Original comments are passed through to ASL+ file)");
printf ("\nData Table Compiler:\n");
ACPI_OPTION ("-tp", "Compile tables with flex/bison prototype");
ACPI_OPTION ("-G", "Compile custom table that contains generic operators");
ACPI_OPTION ("-T <sig list>|ALL", "Create ACPI table template/example files");
ACPI_OPTION ("-T <count>", "Emit DSDT and <count> SSDTs to same file");
ACPI_OPTION ("-vt", "Create verbose template files (full disassembly)");
printf ("\nAML Disassembler:\n");
ACPI_OPTION ("-d <f1 f2 ...>", "Disassemble or decode binary ACPI tables to file (*.dsl)");
ACPI_OPTION ("", " (Optional, file type is automatically detected)");
ACPI_OPTION ("-da <f1 f2 ...>", "Disassemble multiple tables from single namespace");
ACPI_OPTION ("-db", "Do not translate Buffers to Resource Templates");
ACPI_OPTION ("-dc <f1 f2 ...>", "Disassemble AML and immediately compile it");
ACPI_OPTION ("", " (Obtain DSDT from current system if no input file)");
ACPI_OPTION ("-df", "Force disassembler to assume table contains valid AML");
ACPI_OPTION ("-dl", "Emit legacy ASL code only (no C-style operators)");
ACPI_OPTION ("-ds <signature(4)>", "Specify a table signature(4) (CDAT table only)");
ACPI_OPTION ("-e <f1 f2 ...>", "Include ACPI table(s) for external symbol resolution");
ACPI_OPTION ("-fe <file>", "Specify external symbol declaration file");
ACPI_OPTION ("-in", "Ignore NoOp opcodes");
ACPI_OPTION ("-l", "Disassemble to mixed ASL and AML code");
ACPI_OPTION ("-vt", "Dump binary table data in hex format within output file");
printf ("\nDebug Options:\n");
ACPI_OPTION ("-bc", "Create converter debug file (*.cdb)");
ACPI_OPTION ("-bf", "Create debug file (full output) (*.txt)");
ACPI_OPTION ("-bs", "Create debug file (parse tree only) (*.txt)");
ACPI_OPTION ("-bp <depth>", "Prune ASL parse tree");
ACPI_OPTION ("-bt <type>", "Object type to be pruned from the parse tree");
ACPI_OPTION ("-f", "Ignore errors, force creation of AML output file(s)");
ACPI_OPTION ("-m <size>", "Set internal line buffer size (in Kbytes)");
ACPI_OPTION ("-n", "Parse only, no output generation");
ACPI_OPTION ("-oc", "Display compile times and statistics");
ACPI_OPTION ("-x <level>", "Set debug level for trace output");
ACPI_OPTION ("-z", "Do not insert new compiler ID for DataTables");
}
/*******************************************************************************
*
* FUNCTION: FilenameHelp
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Display help message for output filename generation
*
******************************************************************************/
void
AslFilenameHelp (
void)
{
printf ("\nAML output filename generation:\n");
printf (" Output filenames are generated by appending an extension to a common\n");
printf (" filename prefix. The filename prefix is obtained via one of the\n");
printf (" following methods (in priority order):\n");
printf (" 1) The -p option specifies the prefix\n");
printf (" 2) The prefix of the AMLFileName in the ASL Definition Block\n");
printf (" 3) The prefix of the input filename\n");
printf ("\n");
}
/*******************************************************************************
*
* FUNCTION: AslDisassemblyHelp
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Display help message for obtaining and disassembling AML/ASL
* files.
*
******************************************************************************/
void
AslDisassemblyHelp (
void)
{
printf ("\nObtaining binary ACPI tables and disassembling to ASL source code.\n\n");
printf ("Use the following ACPICA toolchain:\n");
printf (" AcpiDump: Dump all ACPI tables to a hex ascii file\n");
printf (" AcpiXtract: Extract one or more binary ACPI tables from AcpiDump output\n");
printf (" iASL -d <file>: Disassemble a binary ACPI table to ASL source code\n");
printf ("\n");
}

View File

@@ -0,0 +1,440 @@
NoEcho('
/******************************************************************************
*
* Module Name: aslhelpers.y - helper and option terms
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
')
/*******************************************************************************
*
* ASL Helper Terms
*
******************************************************************************/
OptionalBusMasterKeyword
: ',' {$$ = TrCreateLeafOp (
PARSEOP_BUSMASTERTYPE_MASTER);}
| ',' PARSEOP_BUSMASTERTYPE_MASTER {$$ = TrCreateLeafOp (
PARSEOP_BUSMASTERTYPE_MASTER);}
| ',' PARSEOP_BUSMASTERTYPE_NOTMASTER {$$ = TrCreateLeafOp (
PARSEOP_BUSMASTERTYPE_NOTMASTER);}
;
OptionalAccessAttribTerm
: {$$ = NULL;}
| ',' {$$ = NULL;}
| ',' ByteConstExpr {$$ = $2;}
| ',' AccessAttribKeyword {$$ = $2;}
;
OptionalAccessSize
: {$$ = TrCreateValuedLeafOp (
PARSEOP_BYTECONST, 0);}
| ',' {$$ = TrCreateValuedLeafOp (
PARSEOP_BYTECONST, 0);}
| ',' ByteConstExpr {$$ = $2;}
;
OptionalAccessTypeKeyword /* Default: AnyAcc */
: {$$ = TrCreateLeafOp (
PARSEOP_ACCESSTYPE_ANY);}
| ',' {$$ = TrCreateLeafOp (
PARSEOP_ACCESSTYPE_ANY);}
| ',' AccessTypeKeyword {$$ = $2;}
;
OptionalAddressingMode
: ',' {$$ = NULL;}
| ',' AddressingModeKeyword {$$ = $2;}
;
OptionalAddressRange
: {$$ = NULL;}
| ',' {$$ = NULL;}
| ',' AddressKeyword {$$ = $2;}
;
OptionalBitsPerByte
: ',' {$$ = NULL;}
| ',' BitsPerByteKeyword {$$ = $2;}
;
OptionalBuffer_Last
: {$$ = NULL;}
| ',' {$$ = NULL;}
| ',' RawDataBufferTerm {$$ = $2;}
;
OptionalByteConstExpr
: {$$ = NULL;}
| ',' {$$ = NULL;}
| ',' ByteConstExpr {$$ = $2;}
;
OptionalDecodeType
: ',' {$$ = NULL;}
| ',' DecodeKeyword {$$ = $2;}
;
OptionalDevicePolarity
: ',' {$$ = NULL;}
| ',' DevicePolarityKeyword {$$ = $2;}
;
OptionalDWordConstExpr
: {$$ = NULL;}
| ',' {$$ = NULL;}
| ',' DWordConstExpr {$$ = $2;}
;
OptionalEndian
: ',' {$$ = NULL;}
| ',' EndianKeyword {$$ = $2;}
;
OptionalFlowControl
: ',' {$$ = NULL;}
| ',' FlowControlKeyword {$$ = $2;}
;
OptionalIoRestriction
: ',' {$$ = NULL;}
| ',' IoRestrictionKeyword {$$ = $2;}
;
OptionalListString
: {$$ = TrCreateValuedLeafOp (
PARSEOP_STRING_LITERAL,
ACPI_TO_INTEGER (""));} /* Placeholder is a NULL string */
| ',' {$$ = TrCreateValuedLeafOp (
PARSEOP_STRING_LITERAL,
ACPI_TO_INTEGER (""));} /* Placeholder is a NULL string */
| ',' TermArg {$$ = $2;}
;
OptionalLockRuleKeyword /* Default: NoLock */
: {$$ = TrCreateLeafOp (
PARSEOP_LOCKRULE_NOLOCK);}
| ',' {$$ = TrCreateLeafOp (
PARSEOP_LOCKRULE_NOLOCK);}
| ',' LockRuleKeyword {$$ = $2;}
;
OptionalMaxType
: ',' {$$ = NULL;}
| ',' MaxKeyword {$$ = $2;}
;
OptionalMemType
: ',' {$$ = NULL;}
| ',' MemTypeKeyword {$$ = $2;}
;
OptionalMinType
: ',' {$$ = NULL;}
| ',' MinKeyword {$$ = $2;}
;
OptionalNameString
: {$$ = NULL;}
| ',' {$$ = NULL;}
| ',' NameString {$$ = $2;}
;
OptionalNameString_Last
: {$$ = NULL;}
| ',' {$$ = NULL;}
| ',' NameString {$$ = $2;}
;
OptionalNameString_First
: {$$ = TrCreateLeafOp (
PARSEOP_ZERO);}
| NameString {$$ = $1;}
;
OptionalObjectTypeKeyword
: {$$ = TrCreateLeafOp (
PARSEOP_OBJECTTYPE_UNK);}
| ',' ObjectTypeKeyword {$$ = $2;}
;
OptionalParityType
: ',' {$$ = NULL;}
| ',' ParityTypeKeyword {$$ = $2;}
;
OptionalQWordConstExpr
: {$$ = NULL;}
| ',' {$$ = NULL;}
| ',' QWordConstExpr {$$ = $2;}
;
OptionalRangeType
: ',' {$$ = NULL;}
| ',' RangeTypeKeyword {$$ = $2;}
;
OptionalReadWriteKeyword
: {$$ = TrCreateLeafOp (
PARSEOP_READWRITETYPE_BOTH);}
| PARSEOP_READWRITETYPE_BOTH {$$ = TrCreateLeafOp (
PARSEOP_READWRITETYPE_BOTH);}
| PARSEOP_READWRITETYPE_READONLY {$$ = TrCreateLeafOp (
PARSEOP_READWRITETYPE_READONLY);}
;
OptionalResourceType_First
: {$$ = TrCreateLeafOp (
PARSEOP_RESOURCETYPE_CONSUMER);}
| ResourceTypeKeyword {$$ = $1;}
;
OptionalResourceType
: {$$ = TrCreateLeafOp (
PARSEOP_RESOURCETYPE_CONSUMER);}
| ',' {$$ = TrCreateLeafOp (
PARSEOP_RESOURCETYPE_CONSUMER);}
| ',' ResourceTypeKeyword {$$ = $2;}
;
/* Same as above except default is producer */
OptionalProducerResourceType
: {$$ = TrCreateLeafOp (
PARSEOP_RESOURCETYPE_PRODUCER);}
| ',' {$$ = TrCreateLeafOp (
PARSEOP_RESOURCETYPE_PRODUCER);}
| ',' ResourceTypeKeyword {$$ = $2;}
;
OptionalSlaveMode
: ',' {$$ = NULL;}
| ',' SlaveModeKeyword {$$ = $2;}
;
OptionalSlaveMode_First
: {$$ = NULL;}
| SlaveModeKeyword {$$ = $1;}
;
OptionalShareType
: {$$ = NULL;}
| ',' {$$ = NULL;}
| ',' ShareTypeKeyword {$$ = $2;}
;
OptionalShareType_First
: {$$ = NULL;}
| ShareTypeKeyword {$$ = $1;}
;
OptionalStopBits
: ',' {$$ = NULL;}
| ',' StopBitsKeyword {$$ = $2;}
;
OptionalStringData
: {$$ = NULL;}
| ',' {$$ = NULL;}
| ',' StringData {$$ = $2;}
;
OptionalSyncLevel /* Default: 0 */
: {$$ = TrCreateValuedLeafOp (
PARSEOP_BYTECONST, 0);}
| ',' {$$ = TrCreateValuedLeafOp (
PARSEOP_BYTECONST, 0);}
| ',' ByteConstExpr {$$ = $2;}
;
OptionalTranslationType_Last
: {$$ = NULL;}
| ',' {$$ = NULL;}
| ',' TranslationKeyword {$$ = $2;}
;
OptionalType
: {$$ = NULL;}
| ',' {$$ = NULL;}
| ',' TypeKeyword {$$ = $2;}
;
OptionalType_Last
: {$$ = NULL;}
| ',' {$$ = NULL;}
| ',' TypeKeyword {$$ = $2;}
;
OptionalUpdateRuleKeyword /* Default: Preserve */
: {$$ = TrCreateLeafOp (
PARSEOP_UPDATERULE_PRESERVE);}
| ',' {$$ = TrCreateLeafOp (
PARSEOP_UPDATERULE_PRESERVE);}
| ',' UpdateRuleKeyword {$$ = $2;}
;
OptionalWireMode
: ',' {$$ = NULL;}
| ',' WireModeKeyword {$$ = $2;}
;
OptionalWordConstExpr
: ',' {$$ = NULL;}
| ',' WordConstExpr {$$ = $2;}
;
OptionalXferSize
: {$$ = TrCreateValuedLeafOp (
PARSEOP_XFERSIZE_32, 2);}
| ',' {$$ = TrCreateValuedLeafOp (
PARSEOP_XFERSIZE_32, 2);}
| ',' XferSizeKeyword {$$ = $2;}
;

View File

@@ -0,0 +1,529 @@
/******************************************************************************
*
* Module Name: aslhex - ASCII hex output file generation (C, ASM, and ASL)
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "acapps.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("ashex")
/*
* This module emits ASCII hex output files in either C, ASM, or ASL format
*/
/* Local prototypes */
static void
HxDoHexOutputC (
void);
static void
HxDoHexOutputAsl (
void);
static void
HxDoHexOutputAsm (
void);
static UINT32
HxReadAmlOutputFile (
UINT8 *Buffer);
/*******************************************************************************
*
* FUNCTION: HxDoHexOutput
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Create the hex output file. Note: data is obtained by reading
* the entire AML output file that was previously generated.
*
******************************************************************************/
void
HxDoHexOutput (
void)
{
switch (AslGbl_HexOutputFlag)
{
case HEX_OUTPUT_C:
HxDoHexOutputC ();
break;
case HEX_OUTPUT_ASM:
HxDoHexOutputAsm ();
break;
case HEX_OUTPUT_ASL:
HxDoHexOutputAsl ();
break;
default:
/* No other output types supported */
break;
}
}
/*******************************************************************************
*
* FUNCTION: HxReadAmlOutputFile
*
* PARAMETERS: Buffer - Where to return data
*
* RETURN: None
*
* DESCRIPTION: Read a line of the AML output prior to formatting the data
*
******************************************************************************/
static UINT32
HxReadAmlOutputFile (
UINT8 *Buffer)
{
UINT32 Actual;
Actual = fread (Buffer, 1, HEX_TABLE_LINE_SIZE,
AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle);
if (ferror (AslGbl_Files[ASL_FILE_AML_OUTPUT].Handle))
{
FlFileError (ASL_FILE_AML_OUTPUT, ASL_MSG_READ);
AslAbort ();
}
return (Actual);
}
/*******************************************************************************
*
* FUNCTION: HxDoHexOutputC
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Create the hex output file. This is the same data as the AML
* output file, but formatted into hex/ascii bytes suitable for
* inclusion into a C source file.
*
* Note: the base name of the hex output file is prepended to
* all symbols as they are output to the file.
*
******************************************************************************/
static void
HxDoHexOutputC (
void)
{
UINT8 FileData[HEX_TABLE_LINE_SIZE];
UINT32 LineLength;
UINT32 Offset = 0;
UINT32 AmlFileSize;
UINT32 i;
char *FileBasename;
/* Obtain the file basename (filename with no extension) */
FileBasename = FlGetFileBasename (AslGbl_Files [ASL_FILE_HEX_OUTPUT].Filename);
/* Get AML size, seek back to start */
AmlFileSize = FlGetFileSize (ASL_FILE_AML_OUTPUT);
FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
/* Finish the file header and emit the non-data symbols */
FlPrintFile (ASL_FILE_HEX_OUTPUT, " * C source code output\n");
FlPrintFile (ASL_FILE_HEX_OUTPUT, " * AML code block contains 0x%X bytes\n *\n */\n",
AmlFileSize);
FlPrintFile (ASL_FILE_HEX_OUTPUT, "#ifndef __%s_HEX__\n", FileBasename);
FlPrintFile (ASL_FILE_HEX_OUTPUT, "#define __%s_HEX__\n\n", FileBasename);
AcpiUtStrlwr (FileBasename);
FlPrintFile (ASL_FILE_HEX_OUTPUT, "unsigned char %s_aml_code[] =\n{\n", FileBasename);
while (Offset < AmlFileSize)
{
/* Read enough bytes needed for one output line */
LineLength = HxReadAmlOutputFile (FileData);
if (!LineLength)
{
break;
}
FlPrintFile (ASL_FILE_HEX_OUTPUT, " ");
for (i = 0; i < LineLength; i++)
{
/*
* Output each hex byte in the form: "0xnn,"
* Add a comma until the very last byte of the AML file
* (Some C compilers complain about a trailing comma)
*/
FlPrintFile (ASL_FILE_HEX_OUTPUT, "0x%2.2X", FileData[i]);
if ((Offset + i + 1) < AmlFileSize)
{
FlPrintFile (ASL_FILE_HEX_OUTPUT, ",");
}
else
{
FlPrintFile (ASL_FILE_HEX_OUTPUT, " ");
}
}
/* Add fill spaces if needed for last line */
if (LineLength < HEX_TABLE_LINE_SIZE)
{
FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s",
5 * (HEX_TABLE_LINE_SIZE - LineLength), " ");
}
/* Emit the offset and ascii dump for the entire line */
FlPrintFile (ASL_FILE_HEX_OUTPUT, " /* %8.8X", Offset);
LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData);
FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s*/\n",
HEX_TABLE_LINE_SIZE - LineLength + 1, " ");
Offset += LineLength;
}
FlPrintFile (ASL_FILE_HEX_OUTPUT, "};\n\n");
FlPrintFile (ASL_FILE_HEX_OUTPUT, "#endif\n");
}
/*******************************************************************************
*
* FUNCTION: HxDoHexOutputAsl
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Create the hex output file. This is the same data as the AML
* output file, but formatted into hex/ascii bytes suitable for
* inclusion into a C source file.
*
******************************************************************************/
static void
HxDoHexOutputAsl (
void)
{
UINT8 FileData[HEX_TABLE_LINE_SIZE];
UINT32 LineLength;
UINT32 Offset = 0;
UINT32 AmlFileSize;
UINT32 i;
/* Get AML size, seek back to start */
AmlFileSize = FlGetFileSize (ASL_FILE_AML_OUTPUT);
FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
FlPrintFile (ASL_FILE_HEX_OUTPUT, " * ASL source code output\n");
FlPrintFile (ASL_FILE_HEX_OUTPUT, " * AML code block contains 0x%X bytes\n *\n */\n",
AmlFileSize);
FlPrintFile (ASL_FILE_HEX_OUTPUT, " Name (BUF1, Buffer()\n {\n");
while (Offset < AmlFileSize)
{
/* Read enough bytes needed for one output line */
LineLength = HxReadAmlOutputFile (FileData);
if (!LineLength)
{
break;
}
FlPrintFile (ASL_FILE_HEX_OUTPUT, " ");
for (i = 0; i < LineLength; i++)
{
/*
* Print each hex byte.
* Add a comma until the very last byte of the AML file
* (Some C compilers complain about a trailing comma)
*/
FlPrintFile (ASL_FILE_HEX_OUTPUT, "0x%2.2X", FileData[i]);
if ((Offset + i + 1) < AmlFileSize)
{
FlPrintFile (ASL_FILE_HEX_OUTPUT, ",");
}
else
{
FlPrintFile (ASL_FILE_HEX_OUTPUT, " ");
}
}
/* Add fill spaces if needed for last line */
if (LineLength < HEX_TABLE_LINE_SIZE)
{
FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s",
5 * (HEX_TABLE_LINE_SIZE - LineLength), " ");
}
/* Emit the offset and ascii dump for the entire line */
FlPrintFile (ASL_FILE_HEX_OUTPUT, " /* %8.8X", Offset);
LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData);
FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s*/\n",
HEX_TABLE_LINE_SIZE - LineLength + 1, " ");
Offset += LineLength;
}
FlPrintFile (ASL_FILE_HEX_OUTPUT, " })\n");
}
/*******************************************************************************
*
* FUNCTION: HxDoHexOutputAsm
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Create the hex output file. This is the same data as the AML
* output file, but formatted into hex/ascii bytes suitable for
* inclusion into a ASM source file.
*
******************************************************************************/
static void
HxDoHexOutputAsm (
void)
{
UINT8 FileData[HEX_TABLE_LINE_SIZE];
UINT32 LineLength;
UINT32 Offset = 0;
UINT32 AmlFileSize;
UINT32 i;
/* Get AML size, seek back to start */
AmlFileSize = FlGetFileSize (ASL_FILE_AML_OUTPUT);
FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
FlPrintFile (ASL_FILE_HEX_OUTPUT, "; Assembly code source output\n");
FlPrintFile (ASL_FILE_HEX_OUTPUT, "; AML code block contains 0x%X bytes\n;\n",
AmlFileSize);
while (Offset < AmlFileSize)
{
/* Read enough bytes needed for one output line */
LineLength = HxReadAmlOutputFile (FileData);
if (!LineLength)
{
break;
}
FlPrintFile (ASL_FILE_HEX_OUTPUT, " db ");
for (i = 0; i < LineLength; i++)
{
/*
* Print each hex byte.
* Add a comma until the last byte of the line
*/
FlPrintFile (ASL_FILE_HEX_OUTPUT, "0%2.2Xh", FileData[i]);
if ((i + 1) < LineLength)
{
FlPrintFile (ASL_FILE_HEX_OUTPUT, ",");
}
}
FlPrintFile (ASL_FILE_HEX_OUTPUT, " ");
/* Add fill spaces if needed for last line */
if (LineLength < HEX_TABLE_LINE_SIZE)
{
FlPrintFile (ASL_FILE_HEX_OUTPUT, "%*s",
5 * (HEX_TABLE_LINE_SIZE - LineLength), " ");
}
/* Emit the offset and ascii dump for the entire line */
FlPrintFile (ASL_FILE_HEX_OUTPUT, " ; %8.8X", Offset);
LsDumpAsciiInComment (ASL_FILE_HEX_OUTPUT, LineLength, FileData);
FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n");
Offset += LineLength;
}
FlPrintFile (ASL_FILE_HEX_OUTPUT, "\n");
}

View File

@@ -0,0 +1,475 @@
NoEcho('
/******************************************************************************
*
* Module Name: aslkeywords.y - Rules for resource descriptor keywords
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
')
/*******************************************************************************
*
* ASL Parameter Keyword Terms
*
******************************************************************************/
AccessAttribKeyword
: PARSEOP_ACCESSATTRIB_BLOCK {$$ = TrCreateLeafOp (PARSEOP_ACCESSATTRIB_BLOCK);}
| PARSEOP_ACCESSATTRIB_BLOCK_CALL {$$ = TrCreateLeafOp (PARSEOP_ACCESSATTRIB_BLOCK_CALL);}
| PARSEOP_ACCESSATTRIB_BYTE {$$ = TrCreateLeafOp (PARSEOP_ACCESSATTRIB_BYTE);}
| PARSEOP_ACCESSATTRIB_QUICK {$$ = TrCreateLeafOp (PARSEOP_ACCESSATTRIB_QUICK );}
| PARSEOP_ACCESSATTRIB_SND_RCV {$$ = TrCreateLeafOp (PARSEOP_ACCESSATTRIB_SND_RCV);}
| PARSEOP_ACCESSATTRIB_WORD {$$ = TrCreateLeafOp (PARSEOP_ACCESSATTRIB_WORD);}
| PARSEOP_ACCESSATTRIB_WORD_CALL {$$ = TrCreateLeafOp (PARSEOP_ACCESSATTRIB_WORD_CALL);}
| PARSEOP_ACCESSATTRIB_BYTES
PARSEOP_OPEN_PAREN {$<n>$ = TrCreateLeafOp (PARSEOP_ACCESSATTRIB_BYTES);}
ByteConst
PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($<n>3,1,$4);}
| PARSEOP_ACCESSATTRIB_RAW_BYTES
PARSEOP_OPEN_PAREN {$<n>$ = TrCreateLeafOp (PARSEOP_ACCESSATTRIB_RAW_BYTES);}
ByteConst
PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($<n>3,1,$4);}
| PARSEOP_ACCESSATTRIB_RAW_PROCESS
PARSEOP_OPEN_PAREN {$<n>$ = TrCreateLeafOp (PARSEOP_ACCESSATTRIB_RAW_PROCESS);}
ByteConst
PARSEOP_CLOSE_PAREN {$$ = TrLinkOpChildren ($<n>3,1,$4);}
;
AccessTypeKeyword
: PARSEOP_ACCESSTYPE_ANY {$$ = TrCreateLeafOp (PARSEOP_ACCESSTYPE_ANY);}
| PARSEOP_ACCESSTYPE_BYTE {$$ = TrCreateLeafOp (PARSEOP_ACCESSTYPE_BYTE);}
| PARSEOP_ACCESSTYPE_WORD {$$ = TrCreateLeafOp (PARSEOP_ACCESSTYPE_WORD);}
| PARSEOP_ACCESSTYPE_DWORD {$$ = TrCreateLeafOp (PARSEOP_ACCESSTYPE_DWORD);}
| PARSEOP_ACCESSTYPE_QWORD {$$ = TrCreateLeafOp (PARSEOP_ACCESSTYPE_QWORD);}
| PARSEOP_ACCESSTYPE_BUF {$$ = TrCreateLeafOp (PARSEOP_ACCESSTYPE_BUF);}
;
AddressingModeKeyword
: PARSEOP_ADDRESSINGMODE_7BIT {$$ = TrCreateLeafOp (PARSEOP_ADDRESSINGMODE_7BIT);}
| PARSEOP_ADDRESSINGMODE_10BIT {$$ = TrCreateLeafOp (PARSEOP_ADDRESSINGMODE_10BIT);}
;
AddressKeyword
: PARSEOP_ADDRESSTYPE_MEMORY {$$ = TrCreateLeafOp (PARSEOP_ADDRESSTYPE_MEMORY);}
| PARSEOP_ADDRESSTYPE_RESERVED {$$ = TrCreateLeafOp (PARSEOP_ADDRESSTYPE_RESERVED);}
| PARSEOP_ADDRESSTYPE_NVS {$$ = TrCreateLeafOp (PARSEOP_ADDRESSTYPE_NVS);}
| PARSEOP_ADDRESSTYPE_ACPI {$$ = TrCreateLeafOp (PARSEOP_ADDRESSTYPE_ACPI);}
;
AddressSpaceKeyword
: ByteConst {$$ = UtCheckIntegerRange ($1, ACPI_NUM_PREDEFINED_REGIONS, 0xFF);}
| RegionSpaceKeyword {}
;
BitsPerByteKeyword
: PARSEOP_BITSPERBYTE_FIVE {$$ = TrCreateLeafOp (PARSEOP_BITSPERBYTE_FIVE);}
| PARSEOP_BITSPERBYTE_SIX {$$ = TrCreateLeafOp (PARSEOP_BITSPERBYTE_SIX);}
| PARSEOP_BITSPERBYTE_SEVEN {$$ = TrCreateLeafOp (PARSEOP_BITSPERBYTE_SEVEN);}
| PARSEOP_BITSPERBYTE_EIGHT {$$ = TrCreateLeafOp (PARSEOP_BITSPERBYTE_EIGHT);}
| PARSEOP_BITSPERBYTE_NINE {$$ = TrCreateLeafOp (PARSEOP_BITSPERBYTE_NINE);}
;
ClockPhaseKeyword
: PARSEOP_CLOCKPHASE_FIRST {$$ = TrCreateLeafOp (PARSEOP_CLOCKPHASE_FIRST);}
| PARSEOP_CLOCKPHASE_SECOND {$$ = TrCreateLeafOp (PARSEOP_CLOCKPHASE_SECOND);}
;
ClockPolarityKeyword
: PARSEOP_CLOCKPOLARITY_LOW {$$ = TrCreateLeafOp (PARSEOP_CLOCKPOLARITY_LOW);}
| PARSEOP_CLOCKPOLARITY_HIGH {$$ = TrCreateLeafOp (PARSEOP_CLOCKPOLARITY_HIGH);}
;
DecodeKeyword
: PARSEOP_DECODETYPE_POS {$$ = TrCreateLeafOp (PARSEOP_DECODETYPE_POS);}
| PARSEOP_DECODETYPE_SUB {$$ = TrCreateLeafOp (PARSEOP_DECODETYPE_SUB);}
;
DevicePolarityKeyword
: PARSEOP_DEVICEPOLARITY_LOW {$$ = TrCreateLeafOp (PARSEOP_DEVICEPOLARITY_LOW);}
| PARSEOP_DEVICEPOLARITY_HIGH {$$ = TrCreateLeafOp (PARSEOP_DEVICEPOLARITY_HIGH);}
;
DMATypeKeyword
: PARSEOP_DMATYPE_A {$$ = TrCreateLeafOp (PARSEOP_DMATYPE_A);}
| PARSEOP_DMATYPE_COMPATIBILITY {$$ = TrCreateLeafOp (PARSEOP_DMATYPE_COMPATIBILITY);}
| PARSEOP_DMATYPE_B {$$ = TrCreateLeafOp (PARSEOP_DMATYPE_B);}
| PARSEOP_DMATYPE_F {$$ = TrCreateLeafOp (PARSEOP_DMATYPE_F);}
;
EndianKeyword
: PARSEOP_ENDIAN_LITTLE {$$ = TrCreateLeafOp (PARSEOP_ENDIAN_LITTLE);}
| PARSEOP_ENDIAN_BIG {$$ = TrCreateLeafOp (PARSEOP_ENDIAN_BIG);}
;
FlowControlKeyword
: PARSEOP_FLOWCONTROL_HW {$$ = TrCreateLeafOp (PARSEOP_FLOWCONTROL_HW);}
| PARSEOP_FLOWCONTROL_NONE {$$ = TrCreateLeafOp (PARSEOP_FLOWCONTROL_NONE);}
| PARSEOP_FLOWCONTROL_SW {$$ = TrCreateLeafOp (PARSEOP_FLOWCONTROL_SW);}
;
InterruptLevel
: PARSEOP_INTLEVEL_ACTIVEBOTH {$$ = TrCreateLeafOp (PARSEOP_INTLEVEL_ACTIVEBOTH);}
| PARSEOP_INTLEVEL_ACTIVEHIGH {$$ = TrCreateLeafOp (PARSEOP_INTLEVEL_ACTIVEHIGH);}
| PARSEOP_INTLEVEL_ACTIVELOW {$$ = TrCreateLeafOp (PARSEOP_INTLEVEL_ACTIVELOW);}
;
InterruptTypeKeyword
: PARSEOP_INTTYPE_EDGE {$$ = TrCreateLeafOp (PARSEOP_INTTYPE_EDGE);}
| PARSEOP_INTTYPE_LEVEL {$$ = TrCreateLeafOp (PARSEOP_INTTYPE_LEVEL);}
;
IODecodeKeyword
: PARSEOP_IODECODETYPE_16 {$$ = TrCreateLeafOp (PARSEOP_IODECODETYPE_16);}
| PARSEOP_IODECODETYPE_10 {$$ = TrCreateLeafOp (PARSEOP_IODECODETYPE_10);}
;
IoRestrictionKeyword
: PARSEOP_IORESTRICT_IN {$$ = TrCreateLeafOp (PARSEOP_IORESTRICT_IN);}
| PARSEOP_IORESTRICT_OUT {$$ = TrCreateLeafOp (PARSEOP_IORESTRICT_OUT);}
| PARSEOP_IORESTRICT_NONE {$$ = TrCreateLeafOp (PARSEOP_IORESTRICT_NONE);}
| PARSEOP_IORESTRICT_PRESERVE {$$ = TrCreateLeafOp (PARSEOP_IORESTRICT_PRESERVE);}
;
LockRuleKeyword
: PARSEOP_LOCKRULE_LOCK {$$ = TrCreateLeafOp (PARSEOP_LOCKRULE_LOCK);}
| PARSEOP_LOCKRULE_NOLOCK {$$ = TrCreateLeafOp (PARSEOP_LOCKRULE_NOLOCK);}
;
MatchOpKeyword
: PARSEOP_MATCHTYPE_MTR {$$ = TrCreateLeafOp (PARSEOP_MATCHTYPE_MTR);}
| PARSEOP_MATCHTYPE_MEQ {$$ = TrCreateLeafOp (PARSEOP_MATCHTYPE_MEQ);}
| PARSEOP_MATCHTYPE_MLE {$$ = TrCreateLeafOp (PARSEOP_MATCHTYPE_MLE);}
| PARSEOP_MATCHTYPE_MLT {$$ = TrCreateLeafOp (PARSEOP_MATCHTYPE_MLT);}
| PARSEOP_MATCHTYPE_MGE {$$ = TrCreateLeafOp (PARSEOP_MATCHTYPE_MGE);}
| PARSEOP_MATCHTYPE_MGT {$$ = TrCreateLeafOp (PARSEOP_MATCHTYPE_MGT);}
;
MaxKeyword
: PARSEOP_MAXTYPE_FIXED {$$ = TrCreateLeafOp (PARSEOP_MAXTYPE_FIXED);}
| PARSEOP_MAXTYPE_NOTFIXED {$$ = TrCreateLeafOp (PARSEOP_MAXTYPE_NOTFIXED);}
;
MemTypeKeyword
: PARSEOP_MEMTYPE_CACHEABLE {$$ = TrCreateLeafOp (PARSEOP_MEMTYPE_CACHEABLE);}
| PARSEOP_MEMTYPE_WRITECOMBINING {$$ = TrCreateLeafOp (PARSEOP_MEMTYPE_WRITECOMBINING);}
| PARSEOP_MEMTYPE_PREFETCHABLE {$$ = TrCreateLeafOp (PARSEOP_MEMTYPE_PREFETCHABLE);}
| PARSEOP_MEMTYPE_NONCACHEABLE {$$ = TrCreateLeafOp (PARSEOP_MEMTYPE_NONCACHEABLE);}
;
MinKeyword
: PARSEOP_MINTYPE_FIXED {$$ = TrCreateLeafOp (PARSEOP_MINTYPE_FIXED);}
| PARSEOP_MINTYPE_NOTFIXED {$$ = TrCreateLeafOp (PARSEOP_MINTYPE_NOTFIXED);}
;
ObjectTypeKeyword
: PARSEOP_OBJECTTYPE_UNK {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_UNK);}
| PARSEOP_OBJECTTYPE_INT {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_INT);}
| PARSEOP_OBJECTTYPE_STR {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_STR);}
| PARSEOP_OBJECTTYPE_BUF {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_BUF);}
| PARSEOP_OBJECTTYPE_PKG {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_PKG);}
| PARSEOP_OBJECTTYPE_FLD {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_FLD);}
| PARSEOP_OBJECTTYPE_DEV {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_DEV);}
| PARSEOP_OBJECTTYPE_EVT {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_EVT);}
| PARSEOP_OBJECTTYPE_MTH {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_MTH);}
| PARSEOP_OBJECTTYPE_MTX {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_MTX);}
| PARSEOP_OBJECTTYPE_OPR {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_OPR);}
| PARSEOP_OBJECTTYPE_POW {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_POW);}
| PARSEOP_OBJECTTYPE_PRO {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_PRO);}
| PARSEOP_OBJECTTYPE_THZ {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_THZ);}
| PARSEOP_OBJECTTYPE_BFF {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_BFF);}
| PARSEOP_OBJECTTYPE_DDB {$$ = TrCreateLeafOp (PARSEOP_OBJECTTYPE_DDB);}
;
ParityTypeKeyword
: PARSEOP_PARITYTYPE_SPACE {$$ = TrCreateLeafOp (PARSEOP_PARITYTYPE_SPACE);}
| PARSEOP_PARITYTYPE_MARK {$$ = TrCreateLeafOp (PARSEOP_PARITYTYPE_MARK);}
| PARSEOP_PARITYTYPE_ODD {$$ = TrCreateLeafOp (PARSEOP_PARITYTYPE_ODD);}
| PARSEOP_PARITYTYPE_EVEN {$$ = TrCreateLeafOp (PARSEOP_PARITYTYPE_EVEN);}
| PARSEOP_PARITYTYPE_NONE {$$ = TrCreateLeafOp (PARSEOP_PARITYTYPE_NONE);}
;
PinConfigByte
: PinConfigKeyword {$$ = $1;}
| ByteConstExpr {$$ = UtCheckIntegerRange ($1, 0x80, 0xFF);}
;
PinConfigKeyword
: PARSEOP_PIN_NOPULL {$$ = TrCreateLeafOp (PARSEOP_PIN_NOPULL);}
| PARSEOP_PIN_PULLDOWN {$$ = TrCreateLeafOp (PARSEOP_PIN_PULLDOWN);}
| PARSEOP_PIN_PULLUP {$$ = TrCreateLeafOp (PARSEOP_PIN_PULLUP);}
| PARSEOP_PIN_PULLDEFAULT {$$ = TrCreateLeafOp (PARSEOP_PIN_PULLDEFAULT);}
;
PldKeyword
: PARSEOP_PLD_REVISION {$$ = TrCreateLeafOp (PARSEOP_PLD_REVISION);}
| PARSEOP_PLD_IGNORECOLOR {$$ = TrCreateLeafOp (PARSEOP_PLD_IGNORECOLOR);}
| PARSEOP_PLD_RED {$$ = TrCreateLeafOp (PARSEOP_PLD_RED);}
| PARSEOP_PLD_GREEN {$$ = TrCreateLeafOp (PARSEOP_PLD_GREEN);}
| PARSEOP_PLD_BLUE {$$ = TrCreateLeafOp (PARSEOP_PLD_BLUE);}
| PARSEOP_PLD_WIDTH {$$ = TrCreateLeafOp (PARSEOP_PLD_WIDTH);}
| PARSEOP_PLD_HEIGHT {$$ = TrCreateLeafOp (PARSEOP_PLD_HEIGHT);}
| PARSEOP_PLD_USERVISIBLE {$$ = TrCreateLeafOp (PARSEOP_PLD_USERVISIBLE);}
| PARSEOP_PLD_DOCK {$$ = TrCreateLeafOp (PARSEOP_PLD_DOCK);}
| PARSEOP_PLD_LID {$$ = TrCreateLeafOp (PARSEOP_PLD_LID);}
| PARSEOP_PLD_PANEL {$$ = TrCreateLeafOp (PARSEOP_PLD_PANEL);}
| PARSEOP_PLD_VERTICALPOSITION {$$ = TrCreateLeafOp (PARSEOP_PLD_VERTICALPOSITION);}
| PARSEOP_PLD_HORIZONTALPOSITION {$$ = TrCreateLeafOp (PARSEOP_PLD_HORIZONTALPOSITION);}
| PARSEOP_PLD_SHAPE {$$ = TrCreateLeafOp (PARSEOP_PLD_SHAPE);}
| PARSEOP_PLD_GROUPORIENTATION {$$ = TrCreateLeafOp (PARSEOP_PLD_GROUPORIENTATION);}
| PARSEOP_PLD_GROUPTOKEN {$$ = TrCreateLeafOp (PARSEOP_PLD_GROUPTOKEN);}
| PARSEOP_PLD_GROUPPOSITION {$$ = TrCreateLeafOp (PARSEOP_PLD_GROUPPOSITION);}
| PARSEOP_PLD_BAY {$$ = TrCreateLeafOp (PARSEOP_PLD_BAY);}
| PARSEOP_PLD_EJECTABLE {$$ = TrCreateLeafOp (PARSEOP_PLD_EJECTABLE);}
| PARSEOP_PLD_EJECTREQUIRED {$$ = TrCreateLeafOp (PARSEOP_PLD_EJECTREQUIRED);}
| PARSEOP_PLD_CABINETNUMBER {$$ = TrCreateLeafOp (PARSEOP_PLD_CABINETNUMBER);}
| PARSEOP_PLD_CARDCAGENUMBER {$$ = TrCreateLeafOp (PARSEOP_PLD_CARDCAGENUMBER);}
| PARSEOP_PLD_REFERENCE {$$ = TrCreateLeafOp (PARSEOP_PLD_REFERENCE);}
| PARSEOP_PLD_ROTATION {$$ = TrCreateLeafOp (PARSEOP_PLD_ROTATION);}
| PARSEOP_PLD_ORDER {$$ = TrCreateLeafOp (PARSEOP_PLD_ORDER);}
| PARSEOP_PLD_RESERVED {$$ = TrCreateLeafOp (PARSEOP_PLD_RESERVED);}
| PARSEOP_PLD_VERTICALOFFSET {$$ = TrCreateLeafOp (PARSEOP_PLD_VERTICALOFFSET);}
| PARSEOP_PLD_HORIZONTALOFFSET {$$ = TrCreateLeafOp (PARSEOP_PLD_HORIZONTALOFFSET);}
;
RangeTypeKeyword
: PARSEOP_RANGETYPE_ISAONLY {$$ = TrCreateLeafOp (PARSEOP_RANGETYPE_ISAONLY);}
| PARSEOP_RANGETYPE_NONISAONLY {$$ = TrCreateLeafOp (PARSEOP_RANGETYPE_NONISAONLY);}
| PARSEOP_RANGETYPE_ENTIRE {$$ = TrCreateLeafOp (PARSEOP_RANGETYPE_ENTIRE);}
;
RegionSpaceKeyword
: PARSEOP_REGIONSPACE_IO {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_IO);}
| PARSEOP_REGIONSPACE_MEM {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_MEM);}
| PARSEOP_REGIONSPACE_PCI {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_PCI);}
| PARSEOP_REGIONSPACE_EC {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_EC);}
| PARSEOP_REGIONSPACE_SMBUS {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_SMBUS);}
| PARSEOP_REGIONSPACE_CMOS {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_CMOS);}
| PARSEOP_REGIONSPACE_PCIBAR {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_PCIBAR);}
| PARSEOP_REGIONSPACE_IPMI {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_IPMI);}
| PARSEOP_REGIONSPACE_GPIO {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_GPIO);}
| PARSEOP_REGIONSPACE_GSBUS {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_GSBUS);}
| PARSEOP_REGIONSPACE_PCC {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_PCC);}
| PARSEOP_REGIONSPACE_PRM {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_PRM);}
| PARSEOP_REGIONSPACE_FFIXEDHW {$$ = TrCreateLeafOp (PARSEOP_REGIONSPACE_FFIXEDHW);}
;
ResourceTypeKeyword
: PARSEOP_RESOURCETYPE_CONSUMER {$$ = TrCreateLeafOp (PARSEOP_RESOURCETYPE_CONSUMER);}
| PARSEOP_RESOURCETYPE_PRODUCER {$$ = TrCreateLeafOp (PARSEOP_RESOURCETYPE_PRODUCER);}
;
SerializeRuleKeyword
: PARSEOP_SERIALIZERULE_SERIAL {$$ = TrCreateLeafOp (PARSEOP_SERIALIZERULE_SERIAL);}
| PARSEOP_SERIALIZERULE_NOTSERIAL {$$ = TrCreateLeafOp (PARSEOP_SERIALIZERULE_NOTSERIAL);}
;
ShareTypeKeyword
: PARSEOP_SHARETYPE_SHARED {$$ = TrCreateLeafOp (PARSEOP_SHARETYPE_SHARED);}
| PARSEOP_SHARETYPE_EXCLUSIVE {$$ = TrCreateLeafOp (PARSEOP_SHARETYPE_EXCLUSIVE);}
| PARSEOP_SHARETYPE_SHAREDWAKE {$$ = TrCreateLeafOp (PARSEOP_SHARETYPE_SHAREDWAKE);}
| PARSEOP_SHARETYPE_EXCLUSIVEWAKE {$$ = TrCreateLeafOp (PARSEOP_SHARETYPE_EXCLUSIVEWAKE);}
;
SlaveModeKeyword
: PARSEOP_SLAVEMODE_CONTROLLERINIT {$$ = TrCreateLeafOp (PARSEOP_SLAVEMODE_CONTROLLERINIT);}
| PARSEOP_SLAVEMODE_DEVICEINIT {$$ = TrCreateLeafOp (PARSEOP_SLAVEMODE_DEVICEINIT);}
;
StopBitsKeyword
: PARSEOP_STOPBITS_TWO {$$ = TrCreateLeafOp (PARSEOP_STOPBITS_TWO);}
| PARSEOP_STOPBITS_ONEPLUSHALF {$$ = TrCreateLeafOp (PARSEOP_STOPBITS_ONEPLUSHALF);}
| PARSEOP_STOPBITS_ONE {$$ = TrCreateLeafOp (PARSEOP_STOPBITS_ONE);}
| PARSEOP_STOPBITS_ZERO {$$ = TrCreateLeafOp (PARSEOP_STOPBITS_ZERO);}
;
TranslationKeyword
: PARSEOP_TRANSLATIONTYPE_SPARSE {$$ = TrCreateLeafOp (PARSEOP_TRANSLATIONTYPE_SPARSE);}
| PARSEOP_TRANSLATIONTYPE_DENSE {$$ = TrCreateLeafOp (PARSEOP_TRANSLATIONTYPE_DENSE);}
;
TypeKeyword
: PARSEOP_TYPE_TRANSLATION {$$ = TrCreateLeafOp (PARSEOP_TYPE_TRANSLATION);}
| PARSEOP_TYPE_STATIC {$$ = TrCreateLeafOp (PARSEOP_TYPE_STATIC);}
;
UpdateRuleKeyword
: PARSEOP_UPDATERULE_PRESERVE {$$ = TrCreateLeafOp (PARSEOP_UPDATERULE_PRESERVE);}
| PARSEOP_UPDATERULE_ONES {$$ = TrCreateLeafOp (PARSEOP_UPDATERULE_ONES);}
| PARSEOP_UPDATERULE_ZEROS {$$ = TrCreateLeafOp (PARSEOP_UPDATERULE_ZEROS);}
;
WireModeKeyword
: PARSEOP_WIREMODE_FOUR {$$ = TrCreateLeafOp (PARSEOP_WIREMODE_FOUR);}
| PARSEOP_WIREMODE_THREE {$$ = TrCreateLeafOp (PARSEOP_WIREMODE_THREE);}
;
XferSizeKeyword
: PARSEOP_XFERSIZE_8 {$$ = TrCreateValuedLeafOp (PARSEOP_XFERSIZE_8, 0);}
| PARSEOP_XFERSIZE_16 {$$ = TrCreateValuedLeafOp (PARSEOP_XFERSIZE_16, 1);}
| PARSEOP_XFERSIZE_32 {$$ = TrCreateValuedLeafOp (PARSEOP_XFERSIZE_32, 2);}
| PARSEOP_XFERSIZE_64 {$$ = TrCreateValuedLeafOp (PARSEOP_XFERSIZE_64, 3);}
| PARSEOP_XFERSIZE_128 {$$ = TrCreateValuedLeafOp (PARSEOP_XFERSIZE_128, 4);}
| PARSEOP_XFERSIZE_256 {$$ = TrCreateValuedLeafOp (PARSEOP_XFERSIZE_256, 5);}
;
XferTypeKeyword
: PARSEOP_XFERTYPE_8 {$$ = TrCreateLeafOp (PARSEOP_XFERTYPE_8);}
| PARSEOP_XFERTYPE_8_16 {$$ = TrCreateLeafOp (PARSEOP_XFERTYPE_8_16);}
| PARSEOP_XFERTYPE_16 {$$ = TrCreateLeafOp (PARSEOP_XFERTYPE_16);}
;
ClockScaleKeyword
: PARSEOP_CLOCK_HZ {$$ = TrCreateLeafOp (PARSEOP_CLOCK_HZ);}
| PARSEOP_CLOCK_KHZ {$$ = TrCreateLeafOp (PARSEOP_CLOCK_KHZ);}
| PARSEOP_CLOCK_MHZ {$$ = TrCreateLeafOp (PARSEOP_CLOCK_MHZ);}
;
ClockModeKeyword
: PARSEOP_CLOCK_FIXED {$$ = TrCreateLeafOp (PARSEOP_CLOCK_FIXED);}
| PARSEOP_CLOCK_VARIABLE {$$ = TrCreateLeafOp (PARSEOP_CLOCK_VARIABLE);}
;

View File

@@ -0,0 +1,571 @@
/******************************************************************************
*
* Module Name: asllength - Tree walk to determine package and opcode lengths
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "amlcode.h"
#include "acconvert.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("asllength")
/* Local prototypes */
static UINT8
CgGetPackageLenByteCount (
ACPI_PARSE_OBJECT *Op,
UINT32 PackageLength);
static void
CgGenerateAmlOpcodeLength (
ACPI_PARSE_OBJECT *Op);
#ifdef ACPI_OBSOLETE_FUNCTIONS
void
LnAdjustLengthToRoot (
ACPI_PARSE_OBJECT *Op,
UINT32 LengthDelta);
#endif
/*******************************************************************************
*
* FUNCTION: LnInitLengthsWalk
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Walk callback to initialize (and re-initialize) the node
* subtree length(s) to zero. The Subtree lengths are bubbled
* up to the root node in order to get a total AML length.
*
******************************************************************************/
ACPI_STATUS
LnInitLengthsWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
Op->Asl.AmlSubtreeLength = 0;
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: LnPackageLengthWalk
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Walk callback to calculate the total AML length.
* 1) Calculate the AML lengths (opcode, package length, etc.) for
* THIS node.
* 2) Bubbble up all of these lengths to the parent node by summing
* them all into the parent subtree length.
*
* Note: The SubtreeLength represents the total AML length of all child nodes
* in all subtrees under a given node. Therefore, once this walk is
* complete, the Root Node subtree length is the AML length of the entire
* tree (and thus, the entire ACPI table)
*
******************************************************************************/
ACPI_STATUS
LnPackageLengthWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
/* Generate the AML lengths for this node */
CgGenerateAmlLengths (Op);
/* Bubble up all lengths (this node and all below it) to the parent */
if ((Op->Asl.Parent) &&
(Op->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG))
{
Op->Asl.Parent->Asl.AmlSubtreeLength += (
Op->Asl.AmlLength +
Op->Asl.AmlOpcodeLength +
Op->Asl.AmlPkgLenBytes +
Op->Asl.AmlSubtreeLength +
CvCalculateCommentLengths (Op)
);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: CgGetPackageLenByteCount
*
* PARAMETERS: Op - Parse node
* PackageLength - Length to be encoded
*
* RETURN: Required length of the package length encoding
*
* DESCRIPTION: Calculate the number of bytes required to encode the given
* package length.
*
******************************************************************************/
static UINT8
CgGetPackageLenByteCount (
ACPI_PARSE_OBJECT *Op,
UINT32 PackageLength)
{
/*
* Determine the number of bytes required to encode the package length
* Note: the package length includes the number of bytes used to encode
* the package length, so we must account for this also.
*/
if (PackageLength <= (0x0000003F - 1))
{
return (1);
}
else if (PackageLength <= (0x00000FFF - 2))
{
return (2);
}
else if (PackageLength <= (0x000FFFFF - 3))
{
return (3);
}
else if (PackageLength <= (0x0FFFFFFF - 4))
{
return (4);
}
else
{
/* Fatal error - the package length is too large to encode */
AslError (ASL_ERROR, ASL_MSG_ENCODING_LENGTH, Op, NULL);
}
return (0);
}
/*******************************************************************************
*
* FUNCTION: CgGenerateAmlOpcodeLength
*
* PARAMETERS: Op - Parse node whose AML opcode lengths will be
* calculated
*
* RETURN: None.
*
* DESCRIPTION: Calculate the AmlOpcodeLength, AmlPkgLenBytes, and AmlLength
* fields for this node.
*
******************************************************************************/
static void
CgGenerateAmlOpcodeLength (
ACPI_PARSE_OBJECT *Op)
{
/* Check for two-byte opcode */
if (Op->Asl.AmlOpcode > 0x00FF)
{
Op->Asl.AmlOpcodeLength = 2;
}
else
{
Op->Asl.AmlOpcodeLength = 1;
}
/* Does this opcode have an associated "PackageLength" field? */
Op->Asl.AmlPkgLenBytes = 0;
if (Op->Asl.CompileFlags & OP_AML_PACKAGE)
{
Op->Asl.AmlPkgLenBytes = CgGetPackageLenByteCount (
Op, Op->Asl.AmlSubtreeLength);
}
/* Data opcode lengths are easy */
switch (Op->Asl.AmlOpcode)
{
case AML_BYTE_OP:
Op->Asl.AmlLength = 1;
break;
case AML_WORD_OP:
Op->Asl.AmlLength = 2;
break;
case AML_DWORD_OP:
Op->Asl.AmlLength = 4;
break;
case AML_QWORD_OP:
Op->Asl.AmlLength = 8;
break;
default:
/* All data opcodes must be above */
break;
}
}
/*******************************************************************************
*
* FUNCTION: CgGenerateAmlLengths
*
* PARAMETERS: Op - Parse node
*
* RETURN: None.
*
* DESCRIPTION: Generate internal length fields based on the AML opcode or
* parse opcode.
*
******************************************************************************/
void
CgGenerateAmlLengths (
ACPI_PARSE_OBJECT *Op)
{
char *Buffer;
ACPI_STATUS Status;
switch (Op->Asl.AmlOpcode)
{
case AML_RAW_DATA_BYTE:
Op->Asl.AmlOpcodeLength = 0;
Op->Asl.AmlLength = 1;
return;
case AML_RAW_DATA_WORD:
Op->Asl.AmlOpcodeLength = 0;
Op->Asl.AmlLength = 2;
return;
case AML_RAW_DATA_DWORD:
Op->Asl.AmlOpcodeLength = 0;
Op->Asl.AmlLength = 4;
return;
case AML_RAW_DATA_QWORD:
Op->Asl.AmlOpcodeLength = 0;
Op->Asl.AmlLength = 8;
return;
case AML_RAW_DATA_BUFFER:
/* Aml length is/was set by creator */
Op->Asl.AmlOpcodeLength = 0;
return;
case AML_RAW_DATA_CHAIN:
/* Aml length is/was set by creator */
Op->Asl.AmlOpcodeLength = 0;
return;
default:
break;
}
switch (Op->Asl.ParseOpcode)
{
case PARSEOP_DEFINITION_BLOCK:
AslGbl_TableLength = sizeof (ACPI_TABLE_HEADER) + Op->Asl.AmlSubtreeLength;
break;
case PARSEOP_NAMESEG:
Op->Asl.AmlOpcodeLength = 0;
Op->Asl.AmlLength = 4;
Op->Asl.ExternalName = Op->Asl.Value.String;
break;
case PARSEOP_NAMESTRING:
case PARSEOP_METHODCALL:
if (Op->Asl.CompileFlags & OP_NAME_INTERNALIZED)
{
break;
}
Op->Asl.AmlOpcodeLength = 0;
Status = UtInternalizeName (Op->Asl.Value.String, &Buffer);
if (ACPI_FAILURE (Status))
{
DbgPrint (ASL_DEBUG_OUTPUT,
"Failure from internalize name %X\n", Status);
break;
}
Op->Asl.ExternalName = Op->Asl.Value.String;
Op->Asl.Value.String = Buffer;
Op->Asl.CompileFlags |= OP_NAME_INTERNALIZED;
Op->Asl.AmlLength = strlen (Buffer);
/*
* Check for single backslash reference to root or reference to a name
* consisting of only prefix (^) characters. Make it a null terminated
* string in the AML.
*/
if (Op->Asl.AmlLength == 1 || UtNameContainsAllPrefix(Op))
{
Op->Asl.AmlLength++;
}
break;
case PARSEOP_STRING_LITERAL:
Op->Asl.AmlOpcodeLength = 1;
/* Get null terminator */
Op->Asl.AmlLength = strlen (Op->Asl.Value.String) + 1;
break;
case PARSEOP_PACKAGE_LENGTH:
Op->Asl.AmlOpcodeLength = 0;
Op->Asl.AmlPkgLenBytes = CgGetPackageLenByteCount (Op,
(UINT32) Op->Asl.Value.Integer);
break;
case PARSEOP_RAW_DATA:
Op->Asl.AmlOpcodeLength = 0;
break;
case PARSEOP_DEFAULT_ARG:
case PARSEOP_INCLUDE:
case PARSEOP_INCLUDE_END:
/* Ignore the "default arg" nodes, they are extraneous at this point */
break;
case PARSEOP_EXTERNAL:
CgGenerateAmlOpcodeLength (Op);
break;
default:
CgGenerateAmlOpcodeLength (Op);
break;
}
}
#ifdef ACPI_OBSOLETE_FUNCTIONS
/*******************************************************************************
*
* FUNCTION: LnAdjustLengthToRoot
*
* PARAMETERS: Op - Node whose Length was changed
*
* RETURN: None.
*
* DESCRIPTION: Change the Subtree length of the given node, and bubble the
* change all the way up to the root node. This allows for
* last second changes to a package length (for example, if the
* package length encoding gets shorter or longer.)
*
******************************************************************************/
void
LnAdjustLengthToRoot (
ACPI_PARSE_OBJECT *SubtreeOp,
UINT32 LengthDelta)
{
ACPI_PARSE_OBJECT *Op;
/* Adjust all subtree lengths up to the root */
Op = SubtreeOp->Asl.Parent;
while (Op)
{
Op->Asl.AmlSubtreeLength -= LengthDelta;
Op = Op->Asl.Parent;
}
/* Adjust the global table length */
AslGbl_TableLength -= LengthDelta;
}
#endif

View File

@@ -0,0 +1,854 @@
/******************************************************************************
*
* Module Name: asllisting - Listing file generation
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "amlcode.h"
#include "acparser.h"
#include "acnamesp.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("asllisting")
/* Local prototypes */
static void
LsGenerateListing (
UINT32 FileId);
static ACPI_STATUS
LsAmlListingWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context);
static ACPI_STATUS
LsTreeWriteWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context);
static void
LsWriteNodeToListing (
ACPI_PARSE_OBJECT *Op,
UINT32 FileId);
static void
LsFinishSourceListing (
UINT32 FileId);
/*******************************************************************************
*
* FUNCTION: LsDoListings
*
* PARAMETERS: None. Examines the various output file global flags.
*
* RETURN: None
*
* DESCRIPTION: Generate all requested listing files.
*
******************************************************************************/
void
LsDoListings (
void)
{
if (AslGbl_C_OutputFlag)
{
LsGenerateListing (ASL_FILE_C_SOURCE_OUTPUT);
}
if (AslGbl_ListingFlag)
{
LsGenerateListing (ASL_FILE_LISTING_OUTPUT);
}
if (AslGbl_AsmOutputFlag)
{
LsGenerateListing (ASL_FILE_ASM_SOURCE_OUTPUT);
}
if (AslGbl_C_IncludeOutputFlag)
{
LsGenerateListing (ASL_FILE_C_INCLUDE_OUTPUT);
}
if (AslGbl_AsmIncludeOutputFlag)
{
LsGenerateListing (ASL_FILE_ASM_INCLUDE_OUTPUT);
}
if (AslGbl_C_OffsetTableFlag)
{
LsGenerateListing (ASL_FILE_C_OFFSET_OUTPUT);
}
}
/*******************************************************************************
*
* FUNCTION: LsGenerateListing
*
* PARAMETERS: FileId - ID of listing file
*
* RETURN: None
*
* DESCRIPTION: Generate a listing file. This can be one of the several types
* of "listings" supported.
*
******************************************************************************/
static void
LsGenerateListing (
UINT32 FileId)
{
UINT32 WalkMode = ASL_WALK_VISIT_DOWNWARD | ASL_WALK_VISIT_DB_SEPARATELY;
/* Start at the beginning of both the source and AML files */
FlSeekFile (ASL_FILE_SOURCE_OUTPUT, 0);
FlSeekFile (ASL_FILE_AML_OUTPUT, 0);
AslGbl_SourceLine = 0;
AslGbl_CurrentHexColumn = 0;
LsPushNode (AslGbl_Files[ASL_FILE_INPUT].Filename);
if (FileId == ASL_FILE_C_OFFSET_OUTPUT)
{
AslGbl_CurrentAmlOffset = 0;
/* Offset table file has a special header and footer */
LsDoOffsetTableHeader (FileId);
TrWalkParseTree (AslGbl_CurrentDB, WalkMode,
LsAmlOffsetWalk, NULL, (void *) ACPI_TO_POINTER (FileId));
LsDoOffsetTableFooter (FileId);
return;
}
/* Process all parse nodes */
TrWalkParseTree (AslGbl_CurrentDB, WalkMode,
LsAmlListingWalk, NULL, (void *) ACPI_TO_POINTER (FileId));
/* Final processing */
LsFinishSourceListing (FileId);
}
/*******************************************************************************
*
* FUNCTION: LsAmlListingWalk
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Process one node during a listing file generation.
*
******************************************************************************/
static ACPI_STATUS
LsAmlListingWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
UINT8 FileByte;
UINT32 i;
UINT32 FileId = (UINT32) ACPI_TO_INTEGER (Context);
LsWriteNodeToListing (Op, FileId);
if (Op->Asl.CompileFlags & OP_IS_RESOURCE_DATA)
{
/* Buffer is a resource template, don't dump the data all at once */
return (AE_OK);
}
if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) ||
(FileId == ASL_FILE_C_INCLUDE_OUTPUT))
{
return (AE_OK);
}
/* Write the hex bytes to the listing file(s) (if requested) */
for (i = 0; i < Op->Asl.FinalAmlLength; i++)
{
if (ACPI_FAILURE (FlReadFile (ASL_FILE_AML_OUTPUT, &FileByte, 1)))
{
FlFileError (ASL_FILE_AML_OUTPUT, ASL_MSG_READ);
AslAbort ();
}
LsWriteListingHexBytes (&FileByte, 1, FileId);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: LsDumpParseTree, LsTreeWriteWalk
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Dump entire parse tree, for compiler debug only
*
******************************************************************************/
void
LsDumpParseTree (
void)
{
if (!AslGbl_DebugFlag)
{
return;
}
DbgPrint (ASL_TREE_OUTPUT, "\nOriginal parse tree from parser:\n\n");
DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_HEADER1);
TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD,
LsTreeWriteWalk, NULL, NULL);
DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_HEADER1);
}
static ACPI_STATUS
LsTreeWriteWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
/* Dump ParseOp name and possible value */
switch (Op->Asl.ParseOpcode)
{
case PARSEOP_NAMESEG:
case PARSEOP_NAMESTRING:
case PARSEOP_METHODCALL:
case PARSEOP_STRING_LITERAL:
UtDumpStringOp (Op, Level);
break;
case PARSEOP_BYTECONST:
UtDumpIntegerOp (Op, Level, 2);
break;
case PARSEOP_WORDCONST:
case PARSEOP_PACKAGE_LENGTH:
UtDumpIntegerOp (Op, Level, 4);
break;
case PARSEOP_DWORDCONST:
case PARSEOP_EISAID:
UtDumpIntegerOp (Op, Level, 8);
break;
case PARSEOP_QWORDCONST:
case PARSEOP_INTEGER:
case PARSEOP_ONE:
case PARSEOP_ZERO:
case PARSEOP_ONES:
UtDumpIntegerOp (Op, Level, 16);
break;
case PARSEOP_INCLUDE:
DbgPrint (ASL_TREE_OUTPUT,
"Open: %s\n", Op->Asl.Value.String);
return (AE_OK);
case PARSEOP_INCLUDE_END:
DbgPrint (ASL_TREE_OUTPUT,
"Close: %s\n", Op->Asl.Filename);
return (AE_OK);
default:
UtDumpBasicOp (Op, Level);
break;
}
/* Dump the remaining data */
DbgPrint (ASL_TREE_OUTPUT, ASL_PARSE_TREE_DEBUG1,
Op->Asl.ParseOpcode, Op->Asl.CompileFlags,
Op->Asl.LineNumber, Op->Asl.EndLine,
Op->Asl.LogicalLineNumber, Op->Asl.EndLogicalLine);
TrPrintOpFlags (Op->Asl.CompileFlags, ASL_TREE_OUTPUT);
DbgPrint (ASL_TREE_OUTPUT, "\n");
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: LsWriteNodeToListing
*
* PARAMETERS: Op - Parse node to write to the listing file.
* FileId - ID of current listing file
*
* RETURN: None.
*
* DESCRIPTION: Write "a node" to the listing file. This means to
* 1) Write out all of the source text associated with the node
* 2) Write out all of the AML bytes associated with the node
* 3) Write any compiler exceptions associated with the node
*
******************************************************************************/
static void
LsWriteNodeToListing (
ACPI_PARSE_OBJECT *Op,
UINT32 FileId)
{
const ACPI_OPCODE_INFO *OpInfo;
UINT32 OpClass;
char *Pathname;
UINT32 Length;
UINT32 i;
OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
OpClass = OpInfo->Class;
/* TBD: clean this up with a single flag that says:
* I start a named output block
*/
if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
{
switch (Op->Asl.ParseOpcode)
{
case PARSEOP_DEFINITION_BLOCK:
case PARSEOP_METHODCALL:
case PARSEOP_INCLUDE:
case PARSEOP_INCLUDE_END:
case PARSEOP_DEFAULT_ARG:
break;
default:
switch (OpClass)
{
case AML_CLASS_NAMED_OBJECT:
switch (Op->Asl.AmlOpcode)
{
case AML_SCOPE_OP:
case AML_ALIAS_OP:
break;
default:
if (Op->Asl.ExternalName)
{
LsFlushListingBuffer (FileId);
FlPrintFile (FileId, " };\n");
}
break;
}
break;
default:
/* Don't care about other objects */
break;
}
break;
}
}
/* These cases do not have a corresponding AML opcode */
switch (Op->Asl.ParseOpcode)
{
case PARSEOP_DEFINITION_BLOCK:
/* Always start a definition block at AML offset zero */
AslGbl_CurrentAmlOffset = 0;
LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine, FileId);
/* Use the table Signature and TableId to build a unique name */
switch (FileId)
{
case ASL_FILE_ASM_SOURCE_OUTPUT:
FlPrintFile (FileId,
"%s_%s_Header \\\n",
AslGbl_TableSignature, AslGbl_TableId);
break;
case ASL_FILE_C_SOURCE_OUTPUT:
FlPrintFile (FileId,
" unsigned char %s_%s_Header [] =\n {\n",
AslGbl_TableSignature, AslGbl_TableId);
break;
case ASL_FILE_ASM_INCLUDE_OUTPUT:
FlPrintFile (FileId,
"extrn %s_%s_Header : byte\n",
AslGbl_TableSignature, AslGbl_TableId);
break;
case ASL_FILE_C_INCLUDE_OUTPUT:
FlPrintFile (FileId,
"extern unsigned char %s_%s_Header [];\n",
AslGbl_TableSignature, AslGbl_TableId);
break;
default:
break;
}
return;
case PARSEOP_METHODCALL:
LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
FileId);
return;
case PARSEOP_INCLUDE:
/* Flush everything up to and including the include source line */
LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
FileId);
/* Create a new listing node and push it */
LsPushNode (Op->Asl.Value.String);
return;
case PARSEOP_INCLUDE_END:
/* Flush out the rest of the include file */
LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
FileId);
/* Pop off this listing node and go back to the parent file */
(void) LsPopNode ();
return;
case PARSEOP_DEFAULT_ARG:
if (Op->Asl.CompileFlags & OP_IS_RESOURCE_DESC)
{
LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.EndLogicalLine,
FileId);
}
return;
default:
/* All other opcodes have an AML opcode */
break;
}
/*
* Otherwise, we look at the AML opcode because we can
* switch on the opcode type, getting an entire class
* at once
*/
switch (OpClass)
{
case AML_CLASS_ARGUMENT: /* argument type only */
case AML_CLASS_INTERNAL:
break;
case AML_CLASS_NAMED_OBJECT:
switch (Op->Asl.AmlOpcode)
{
case AML_FIELD_OP:
case AML_INDEX_FIELD_OP:
case AML_BANK_FIELD_OP:
/*
* For fields, we want to dump all the AML after the
* entire definition
*/
LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine,
FileId);
break;
case AML_NAME_OP:
if (Op->Asl.CompileFlags & OP_IS_RESOURCE_DESC)
{
LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
FileId);
}
else
{
/*
* For fields, we want to dump all the AML after the
* entire definition
*/
LsWriteSourceLines (Op->Asl.EndLine, Op->Asl.EndLogicalLine,
FileId);
}
break;
default:
LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
FileId);
break;
}
switch (Op->Asl.AmlOpcode)
{
case AML_SCOPE_OP:
case AML_ALIAS_OP:
/* These opcodes do not declare a new object, ignore them */
break;
default:
/* All other named object opcodes come here */
switch (FileId)
{
case ASL_FILE_ASM_SOURCE_OUTPUT:
case ASL_FILE_C_SOURCE_OUTPUT:
case ASL_FILE_ASM_INCLUDE_OUTPUT:
case ASL_FILE_C_INCLUDE_OUTPUT:
/*
* For named objects, we will create a valid symbol so that the
* AML code can be referenced from C or ASM
*/
if (Op->Asl.ExternalName)
{
/* Get the full pathname associated with this node */
Pathname = AcpiNsGetExternalPathname (Op->Asl.Node);
Length = strlen (Pathname);
if (Length >= 4)
{
/* Convert all dots in the path to underscores */
for (i = 0; i < Length; i++)
{
if (Pathname[i] == '.')
{
Pathname[i] = '_';
}
}
/* Create the appropriate symbol in the output file */
switch (FileId)
{
case ASL_FILE_ASM_SOURCE_OUTPUT:
FlPrintFile (FileId,
"%s_%s_%s \\\n",
AslGbl_TableSignature, AslGbl_TableId, &Pathname[1]);
break;
case ASL_FILE_C_SOURCE_OUTPUT:
FlPrintFile (FileId,
" unsigned char %s_%s_%s [] =\n {\n",
AslGbl_TableSignature, AslGbl_TableId, &Pathname[1]);
break;
case ASL_FILE_ASM_INCLUDE_OUTPUT:
FlPrintFile (FileId,
"extrn %s_%s_%s : byte\n",
AslGbl_TableSignature, AslGbl_TableId, &Pathname[1]);
break;
case ASL_FILE_C_INCLUDE_OUTPUT:
FlPrintFile (FileId,
"extern unsigned char %s_%s_%s [];\n",
AslGbl_TableSignature, AslGbl_TableId, &Pathname[1]);
break;
default:
break;
}
}
ACPI_FREE (Pathname);
}
break;
default:
/* Nothing to do for listing file */
break;
}
}
break;
case AML_CLASS_EXECUTE:
case AML_CLASS_CREATE:
default:
if ((Op->Asl.ParseOpcode == PARSEOP_BUFFER) &&
(Op->Asl.CompileFlags & OP_IS_RESOURCE_DESC))
{
return;
}
LsWriteSourceLines (Op->Asl.LineNumber, Op->Asl.LogicalLineNumber,
FileId);
break;
case AML_CLASS_UNKNOWN:
break;
}
}
/*******************************************************************************
*
* FUNCTION: LsFinishSourceListing
*
* PARAMETERS: FileId - ID of current listing file.
*
* RETURN: None
*
* DESCRIPTION: Cleanup routine for the listing file. Flush the hex AML
* listing buffer, and flush out any remaining lines in the
* source input file.
*
******************************************************************************/
static void
LsFinishSourceListing (
UINT32 FileId)
{
if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) ||
(FileId == ASL_FILE_C_INCLUDE_OUTPUT))
{
return;
}
LsFlushListingBuffer (FileId);
AslGbl_CurrentAmlOffset = 0;
/* Flush any remaining text in the source file */
if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
{
FlPrintFile (FileId, " /*\n");
}
while (LsWriteOneSourceLine (FileId))
{ ; }
if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
{
FlPrintFile (FileId, "\n */\n };\n");
}
FlPrintFile (FileId, "\n");
if (FileId == ASL_FILE_LISTING_OUTPUT)
{
/* Print a summary of the compile exceptions */
FlPrintFile (FileId, "\n\nSummary of errors and warnings\n\n");
AePrintErrorLog (FileId);
FlPrintFile (FileId, "\n");
UtDisplayOneSummary (FileId, TRUE);
FlPrintFile (FileId, "\n");
}
}

View File

@@ -0,0 +1,819 @@
/******************************************************************************
*
* Module Name: asllistsup - Listing file support utilities
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslistsup")
/*******************************************************************************
*
* FUNCTION: LsDumpAscii
*
* PARAMETERS: FileId - ID of current listing file
* Count - Number of bytes to convert
* Buffer - Buffer of bytes to convert
*
* RETURN: None
*
* DESCRIPTION: Convert hex bytes to ascii
*
******************************************************************************/
void
LsDumpAscii (
UINT32 FileId,
UINT32 Count,
UINT8 *Buffer)
{
UINT8 BufChar;
UINT32 i;
FlPrintFile (FileId, " \"");
for (i = 0; i < Count; i++)
{
BufChar = Buffer[i];
if (isprint (BufChar))
{
FlPrintFile (FileId, "%c", BufChar);
}
else
{
/* Not a printable character, just put out a dot */
FlPrintFile (FileId, ".");
}
}
FlPrintFile (FileId, "\"");
}
/*******************************************************************************
*
* FUNCTION: LsDumpAsciiInComment
*
* PARAMETERS: FileId - ID of current listing file
* Count - Number of bytes to convert
* Buffer - Buffer of bytes to convert
*
* RETURN: None
*
* DESCRIPTION: Convert hex bytes to ascii
*
******************************************************************************/
void
LsDumpAsciiInComment (
UINT32 FileId,
UINT32 Count,
UINT8 *Buffer)
{
UINT8 BufChar = 0;
UINT8 LastChar;
UINT32 i;
FlPrintFile (FileId, " \"");
for (i = 0; i < Count; i++)
{
LastChar = BufChar;
BufChar = Buffer[i];
if (isprint (BufChar))
{
/* Handle embedded C comment sequences */
if (((LastChar == '*') && (BufChar == '/')) ||
((LastChar == '/') && (BufChar == '*')))
{
/* Insert a space to break the sequence */
FlPrintFile (FileId, " ");
}
FlPrintFile (FileId, "%c", BufChar);
}
else
{
/* Not a printable character, just put out a dot */
FlPrintFile (FileId, ".");
}
}
FlPrintFile (FileId, "\"");
}
/*******************************************************************************
*
* FUNCTION: LsCheckException
*
* PARAMETERS: LineNumber - Current logical (cumulative) line #
* FileId - ID of output listing file
*
* RETURN: None
*
* DESCRIPTION: Check if there is an exception for this line, and if there is,
* put it in the listing immediately. Handles multiple errors
* per line. AslGbl_NextError points to the next error in the
* sorted (by line #) list of compile errors/warnings.
*
******************************************************************************/
void
LsCheckException (
UINT32 LineNumber,
UINT32 FileId)
{
if ((!AslGbl_NextError) ||
(LineNumber < AslGbl_NextError->LogicalLineNumber ))
{
return;
}
/* Handle multiple errors per line */
if (FileId == ASL_FILE_LISTING_OUTPUT)
{
while (AslGbl_NextError &&
(LineNumber >= AslGbl_NextError->LogicalLineNumber))
{
AePrintException (FileId, AslGbl_NextError, "\n[****iasl****]\n");
AslGbl_NextError = AslGbl_NextError->Next;
}
FlPrintFile (FileId, "\n");
}
}
/*******************************************************************************
*
* FUNCTION: LsWriteListingHexBytes
*
* PARAMETERS: Buffer - AML code buffer
* Length - Number of AML bytes to write
* FileId - ID of current listing file.
*
* RETURN: None
*
* DESCRIPTION: Write the contents of the AML buffer to the listing file via
* the listing buffer. The listing buffer is flushed every 16
* AML bytes.
*
******************************************************************************/
void
LsWriteListingHexBytes (
UINT8 *Buffer,
UINT32 Length,
UINT32 FileId)
{
UINT32 i;
/* Transfer all requested bytes */
for (i = 0; i < Length; i++)
{
/* Print line header when buffer is empty */
if (AslGbl_CurrentHexColumn == 0)
{
if (AslGbl_HasIncludeFiles)
{
FlPrintFile (FileId, "%*s", 10, " ");
}
switch (FileId)
{
case ASL_FILE_LISTING_OUTPUT:
FlPrintFile (FileId, "%8.8X%s", AslGbl_CurrentAmlOffset,
ASL_LISTING_LINE_PREFIX);
break;
case ASL_FILE_ASM_SOURCE_OUTPUT:
FlPrintFile (FileId, " db ");
break;
case ASL_FILE_C_SOURCE_OUTPUT:
FlPrintFile (FileId, " ");
break;
default:
/* No other types supported */
return;
}
}
/* Transfer AML byte and update counts */
AslGbl_AmlBuffer[AslGbl_CurrentHexColumn] = Buffer[i];
AslGbl_CurrentHexColumn++;
AslGbl_CurrentAmlOffset++;
/* Flush buffer when it is full */
if (AslGbl_CurrentHexColumn >= HEX_LISTING_LINE_SIZE)
{
LsFlushListingBuffer (FileId);
}
}
}
/*******************************************************************************
*
* FUNCTION: LsWriteSourceLines
*
* PARAMETERS: ToLineNumber -
* ToLogicalLineNumber - Write up to this source line number
* FileId - ID of current listing file
*
* RETURN: None
*
* DESCRIPTION: Read then write source lines to the listing file until we have
* reached the specified logical (cumulative) line number. This
* automatically echos out comment blocks and other non-AML
* generating text until we get to the actual AML-generating line
* of ASL code specified by the logical line number.
*
******************************************************************************/
void
LsWriteSourceLines (
UINT32 ToLineNumber,
UINT32 ToLogicalLineNumber,
UINT32 FileId)
{
/* Nothing to do for these file types */
if ((FileId == ASL_FILE_ASM_INCLUDE_OUTPUT) ||
(FileId == ASL_FILE_C_INCLUDE_OUTPUT))
{
return;
}
AslGbl_CurrentLine = ToLogicalLineNumber;
/* Flush any hex bytes remaining from the last opcode */
LsFlushListingBuffer (FileId);
/* Read lines and write them as long as we are not caught up */
if (AslGbl_SourceLine < AslGbl_CurrentLine)
{
/*
* If we just completed writing some AML hex bytes, output a linefeed
* to add some whitespace for readability.
*/
if (AslGbl_HexBytesWereWritten)
{
FlPrintFile (FileId, "\n");
AslGbl_HexBytesWereWritten = FALSE;
}
if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
{
FlPrintFile (FileId, " /*\n");
}
/* Write one line at a time until we have reached the target line # */
while ((AslGbl_SourceLine < AslGbl_CurrentLine) &&
LsWriteOneSourceLine (FileId))
{ ; }
if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
{
FlPrintFile (FileId, " */");
}
FlPrintFile (FileId, "\n");
}
}
/*******************************************************************************
*
* FUNCTION: LsWriteOneSourceLine
*
* PARAMETERS: FileId - ID of current listing file
*
* RETURN: FALSE on EOF (input source file), TRUE otherwise
*
* DESCRIPTION: Read one line from the input source file and echo it to the
* listing file, prefixed with the line number, and if the source
* file contains include files, prefixed with the current filename
*
******************************************************************************/
UINT32
LsWriteOneSourceLine (
UINT32 FileId)
{
UINT8 FileByte;
UINT32 Column = 0;
UINT32 Index = 16;
BOOLEAN StartOfLine = FALSE;
BOOLEAN ProcessLongLine = FALSE;
AslGbl_SourceLine++;
AslGbl_ListingNode->LineNumber++;
/* Ignore lines that are completely blank (but count the line above) */
if (FlReadFile (ASL_FILE_SOURCE_OUTPUT, &FileByte, 1) != AE_OK)
{
return (0);
}
if (FileByte == '\n')
{
return (1);
}
/*
* This is a non-empty line, we will print the entire line with
* the line number and possibly other prefixes and transforms.
*/
/* Line prefixes for special files, C and ASM output */
if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
{
FlPrintFile (FileId, " *");
}
if (FileId == ASL_FILE_ASM_SOURCE_OUTPUT)
{
FlPrintFile (FileId, "; ");
}
if (AslGbl_HasIncludeFiles)
{
/*
* This file contains "include" statements, print the current
* filename and line number within the current file
*/
FlPrintFile (FileId, "%12s %5d%s",
AslGbl_ListingNode->Filename, AslGbl_ListingNode->LineNumber,
ASL_LISTING_LINE_PREFIX);
}
else
{
/* No include files, just print the line number */
FlPrintFile (FileId, "%8u%s", AslGbl_SourceLine,
ASL_LISTING_LINE_PREFIX);
}
/* Read the rest of this line (up to a newline or EOF) */
do
{
if (FileId == ASL_FILE_C_SOURCE_OUTPUT)
{
if (FileByte == '/')
{
FileByte = '*';
}
}
/* Split long input lines for readability in the listing */
Column++;
if (Column >= 128)
{
if (!ProcessLongLine)
{
if ((FileByte != '}') &&
(FileByte != '{'))
{
goto WriteByte;
}
ProcessLongLine = TRUE;
}
if (FileByte == '{')
{
FlPrintFile (FileId, "\n%*s{\n", Index, " ");
StartOfLine = TRUE;
Index += 4;
continue;
}
else if (FileByte == '}')
{
if (!StartOfLine)
{
FlPrintFile (FileId, "\n");
}
StartOfLine = TRUE;
Index -= 4;
FlPrintFile (FileId, "%*s}\n", Index, " ");
continue;
}
/* Ignore spaces/tabs at the start of line */
else if ((FileByte == ' ') && StartOfLine)
{
continue;
}
else if (StartOfLine)
{
StartOfLine = FALSE;
FlPrintFile (FileId, "%*s", Index, " ");
}
WriteByte:
FlWriteFile (FileId, &FileByte, 1);
if (FileByte == '\n')
{
/*
* This line has been completed.
* Check if an error occurred on this source line during the compile.
* If so, we print the error message after the source line.
*/
LsCheckException (AslGbl_SourceLine, FileId);
return (1);
}
}
else
{
FlWriteFile (FileId, &FileByte, 1);
if (FileByte == '\n')
{
/*
* This line has been completed.
* Check if an error occurred on this source line during the compile.
* If so, we print the error message after the source line.
*/
LsCheckException (AslGbl_SourceLine, FileId);
return (1);
}
}
} while (FlReadFile (ASL_FILE_SOURCE_OUTPUT, &FileByte, 1) == AE_OK);
/* EOF on the input file was reached */
return (0);
}
/*******************************************************************************
*
* FUNCTION: LsFlushListingBuffer
*
* PARAMETERS: FileId - ID of the listing file
*
* RETURN: None
*
* DESCRIPTION: Flush out the current contents of the 16-byte hex AML code
* buffer. Usually called at the termination of a single line
* of source code or when the buffer is full.
*
******************************************************************************/
void
LsFlushListingBuffer (
UINT32 FileId)
{
UINT32 i;
if (AslGbl_CurrentHexColumn == 0)
{
return;
}
/* Write the hex bytes */
switch (FileId)
{
case ASL_FILE_LISTING_OUTPUT:
for (i = 0; i < AslGbl_CurrentHexColumn; i++)
{
FlPrintFile (FileId, "%2.2X ", AslGbl_AmlBuffer[i]);
}
for (i = 0; i < ((HEX_LISTING_LINE_SIZE - AslGbl_CurrentHexColumn) * 3); i++)
{
FlWriteFile (FileId, ".", 1);
}
/* Write the ASCII character associated with each of the bytes */
LsDumpAscii (FileId, AslGbl_CurrentHexColumn, AslGbl_AmlBuffer);
break;
case ASL_FILE_ASM_SOURCE_OUTPUT:
for (i = 0; i < AslGbl_CurrentHexColumn; i++)
{
if (i > 0)
{
FlPrintFile (FileId, ",");
}
FlPrintFile (FileId, "0%2.2Xh", AslGbl_AmlBuffer[i]);
}
for (i = 0; i < ((HEX_LISTING_LINE_SIZE - AslGbl_CurrentHexColumn) * 5); i++)
{
FlWriteFile (FileId, " ", 1);
}
FlPrintFile (FileId, " ;%8.8X",
AslGbl_CurrentAmlOffset - HEX_LISTING_LINE_SIZE);
/* Write the ASCII character associated with each of the bytes */
LsDumpAscii (FileId, AslGbl_CurrentHexColumn, AslGbl_AmlBuffer);
break;
case ASL_FILE_C_SOURCE_OUTPUT:
for (i = 0; i < AslGbl_CurrentHexColumn; i++)
{
FlPrintFile (FileId, "0x%2.2X,", AslGbl_AmlBuffer[i]);
}
/* Pad hex output with spaces if line is shorter than max line size */
for (i = 0; i < ((HEX_LISTING_LINE_SIZE - AslGbl_CurrentHexColumn) * 5); i++)
{
FlWriteFile (FileId, " ", 1);
}
/* AML offset for the start of the line */
FlPrintFile (FileId, " /* %8.8X",
AslGbl_CurrentAmlOffset - AslGbl_CurrentHexColumn);
/* Write the ASCII character associated with each of the bytes */
LsDumpAsciiInComment (FileId, AslGbl_CurrentHexColumn, AslGbl_AmlBuffer);
FlPrintFile (FileId, " */");
break;
default:
/* No other types supported */
return;
}
FlPrintFile (FileId, "\n");
AslGbl_CurrentHexColumn = 0;
AslGbl_HexBytesWereWritten = TRUE;
}
/*******************************************************************************
*
* FUNCTION: LsPushNode
*
* PARAMETERS: Filename - Pointer to the include filename
*
* RETURN: None
*
* DESCRIPTION: Push a listing node on the listing/include file stack. This
* stack enables tracking of include files (infinitely nested)
* and resumption of the listing of the parent file when the
* include file is finished.
*
******************************************************************************/
void
LsPushNode (
char *Filename)
{
ASL_LISTING_NODE *Lnode;
/* Create a new node */
Lnode = UtLocalCalloc (sizeof (ASL_LISTING_NODE));
/* Initialize */
Lnode->Filename = Filename;
Lnode->LineNumber = 0;
/* Link (push) */
Lnode->Next = AslGbl_ListingNode;
AslGbl_ListingNode = Lnode;
}
/*******************************************************************************
*
* FUNCTION: LsPopNode
*
* PARAMETERS: None
*
* RETURN: List head after current head is popped off
*
* DESCRIPTION: Pop the current head of the list, free it, and return the
* next node on the stack (the new current node).
*
******************************************************************************/
ASL_LISTING_NODE *
LsPopNode (
void)
{
ASL_LISTING_NODE *Lnode;
/* Just grab the node at the head of the list */
Lnode = AslGbl_ListingNode;
if ((!Lnode) ||
(!Lnode->Next))
{
AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, NULL,
"Could not pop empty listing stack");
return (AslGbl_ListingNode);
}
AslGbl_ListingNode = Lnode->Next;
ACPI_FREE (Lnode);
/* New "Current" node is the new head */
return (AslGbl_ListingNode);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,423 @@
/******************************************************************************
*
* Module Name: asllookup- Namespace lookup functions
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "acparser.h"
#include "amlcode.h"
#include "acnamesp.h"
#include "acdispat.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("asllookup")
/* Local prototypes */
static ACPI_STATUS
LkIsObjectUsed (
ACPI_HANDLE ObjHandle,
UINT32 Level,
void *Context,
void **ReturnValue);
static ACPI_PARSE_OBJECT *
LkGetNameOp (
ACPI_PARSE_OBJECT *Op);
/*******************************************************************************
*
* FUNCTION: LkFindUnreferencedObjects
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Namespace walk to find objects that are not referenced in any
* way. Must be called after the namespace has been cross
* referenced.
*
******************************************************************************/
void
LkFindUnreferencedObjects (
void)
{
/* Walk entire namespace from the supplied root */
(void) AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX, FALSE, LkIsObjectUsed, NULL,
NULL, NULL);
}
/*******************************************************************************
*
* FUNCTION: LkIsObjectUsed
*
* PARAMETERS: ACPI_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Check for an unreferenced namespace object and emit a warning.
* We have to be careful, because some types and names are
* typically or always unreferenced, we don't want to issue
* excessive warnings. Note: Names that are declared within a
* control method are temporary, so we always issue a remark
* if they are not referenced.
*
******************************************************************************/
static ACPI_STATUS
LkIsObjectUsed (
ACPI_HANDLE ObjHandle,
UINT32 Level,
void *Context,
void **ReturnValue)
{
ACPI_NAMESPACE_NODE *Node = ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle);
ACPI_NAMESPACE_NODE *Next;
ASL_METHOD_LOCAL *MethodLocals;
ASL_METHOD_LOCAL *MethodArgs;
UINT32 i;
if (Node->Type == ACPI_TYPE_METHOD)
{
if (!Node->Op || !Node->MethodLocals)
{
return (AE_OK);
}
MethodLocals = (ASL_METHOD_LOCAL *) Node->MethodLocals;
MethodArgs = (ASL_METHOD_LOCAL *) Node->MethodArgs;
/*
* Analysis of LocalX variables
*/
for (i = 0; i < ACPI_METHOD_NUM_LOCALS; i++)
{
/* Warn for Locals that are set but never referenced */
if ((MethodLocals[i].Flags & ASL_LOCAL_INITIALIZED) &&
(!(MethodLocals[i].Flags & ASL_LOCAL_REFERENCED)))
{
sprintf (AslGbl_MsgBuffer, "Local%u", i);
AslError (ASL_WARNING, ASL_MSG_LOCAL_NOT_USED,
MethodLocals[i].Op, AslGbl_MsgBuffer);
}
}
/*
* Analysis of ArgX variables (standard method arguments,
* and remaining unused ArgX can also be used as locals)
*/
for (i = 0; i < ACPI_METHOD_NUM_ARGS; i++)
{
if (MethodArgs[i].Flags & ASL_ARG_IS_LOCAL)
{
/* Warn if ArgX is being used as a local, but not referenced */
if ((MethodArgs[i].Flags & ASL_ARG_INITIALIZED) &&
(!(MethodArgs[i].Flags & ASL_ARG_REFERENCED)))
{
sprintf (AslGbl_MsgBuffer, "Arg%u", i);
AslError (ASL_WARNING, ASL_MSG_ARG_AS_LOCAL_NOT_USED,
MethodArgs[i].Op, AslGbl_MsgBuffer);
}
}
else
{
/*
* Remark if a normal method ArgX is not referenced.
* We ignore the predefined methods since often, not
* all arguments are needed or used.
*/
if ((Node->Name.Ascii[0] != '_') &&
(!(MethodArgs[i].Flags & ASL_ARG_REFERENCED)))
{
sprintf (AslGbl_MsgBuffer, "Arg%u", i);
AslError (ASL_REMARK, ASL_MSG_ARG_NOT_USED,
MethodArgs[i].Op, AslGbl_MsgBuffer);
}
}
}
}
/* Referenced flag is set during the namespace xref */
if (Node->Flags & ANOBJ_IS_REFERENCED)
{
return (AE_OK);
}
if (!Node->Op)
{
return (AE_OK);
}
/* These types are typically never directly referenced, ignore them */
switch (Node->Type)
{
case ACPI_TYPE_DEVICE:
case ACPI_TYPE_PROCESSOR:
case ACPI_TYPE_POWER:
case ACPI_TYPE_THERMAL:
case ACPI_TYPE_LOCAL_RESOURCE:
case ACPI_TYPE_LOCAL_RESOURCE_FIELD: /* Names assigned to descriptor elements */
return (AE_OK);
default:
break;
}
/* Determine if the name is within a control method */
Next = Node->Parent;
while (Next)
{
if (Next->Type == ACPI_TYPE_METHOD)
{
/*
* Name is within a method, therefore it is temporary.
* Issue a remark even if it is a reserved name (starts
* with an underscore).
*/
sprintf (AslGbl_MsgBuffer, "Name [%4.4s] is within a method [%4.4s]",
Node->Name.Ascii, Next->Name.Ascii);
AslError (ASL_REMARK, ASL_MSG_NOT_REFERENCED,
LkGetNameOp (Node->Op), AslGbl_MsgBuffer);
return (AE_OK);
}
Next = Next->Parent;
}
/* The name is not within a control method */
/*
* Ignore names that start with an underscore. These are the reserved
* ACPI names and are typically not referenced since they are meant
* to be called by the host OS.
*/
if (Node->Name.Ascii[0] == '_')
{
return (AE_OK);
}
/*
* What remains is an unresolved user name that is not within a method.
* However, the object could be referenced via another table, so issue
* the warning at level 2.
*/
AslError (ASL_WARNING2, ASL_MSG_NOT_REFERENCED,
LkGetNameOp (Node->Op), NULL);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: LkGetNameOp
*
* PARAMETERS: Op - Current Op
*
* RETURN: NameOp associated with the input op
*
* DESCRIPTION: Find the name declaration op associated with the operator
*
******************************************************************************/
static ACPI_PARSE_OBJECT *
LkGetNameOp (
ACPI_PARSE_OBJECT *Op)
{
const ACPI_OPCODE_INFO *OpInfo;
ACPI_PARSE_OBJECT *NameOp = Op;
OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
/* Get the NamePath from the appropriate place */
if (OpInfo->Flags & AML_NAMED)
{
/* For nearly all NAMED operators, the name reference is the first child */
NameOp = Op->Asl.Child;
if (Op->Asl.AmlOpcode == AML_ALIAS_OP)
{
/*
* ALIAS is the only oddball opcode, the name declaration
* (alias name) is the second operand
*/
NameOp = Op->Asl.Child->Asl.Next;
}
}
else if (OpInfo->Flags & AML_CREATE)
{
/* Name must appear as the last parameter */
NameOp = Op->Asl.Child;
while (!(NameOp->Asl.CompileFlags & OP_IS_NAME_DECLARATION))
{
NameOp = NameOp->Asl.Next;
}
}
return (NameOp);
}

View File

@@ -0,0 +1,447 @@
/******************************************************************************
*
* Module Name: aslmain - compiler main and utilities
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#define _DECLARE_GLOBALS
#include "aslcompiler.h"
#include "acapps.h"
#include "acdisasm.h"
#include <signal.h>
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslmain")
/*
* Main routine for the iASL compiler.
*
* Portability note: The compiler depends upon the host for command-line
* wildcard support - it is not implemented locally. For example:
*
* Linux/Unix systems: Shell expands wildcards automatically.
*
* Windows: The setargv.obj module must be linked in to automatically
* expand wildcards.
*/
/* Local prototypes */
static void ACPI_SYSTEM_XFACE
AslSignalHandler (
int Sig);
static void
AslInitialize (
void);
/*******************************************************************************
*
* FUNCTION: main
*
* PARAMETERS: Standard argc/argv
*
* RETURN: Program termination code
*
* DESCRIPTION: C main routine for the iASL Compiler/Disassembler. Process
* command line options and begin the compile/disassembly for each file on
* the command line (wildcards supported).
*
******************************************************************************/
int ACPI_SYSTEM_XFACE
main (
int argc,
char **argv)
{
ACPI_STATUS Status;
int Index1;
int Index2;
int ReturnStatus = 0;
signal (SIGINT, AslSignalHandler);
/*
* Big-endian machines are not currently supported. ACPI tables must
* be little-endian, and support for big-endian machines needs to
* be implemented.
*/
if (UtIsBigEndianMachine ())
{
fprintf (stderr,
"iASL is not currently supported on big-endian machines.\n");
return (-1);
}
AcpiOsInitialize ();
ACPI_DEBUG_INITIALIZE (); /* For debug version only */
/* Initialize preprocessor and compiler before command line processing */
AcpiGbl_ExternalFileList = NULL;
AcpiDbgLevel = 0;
PrInitializePreprocessor ();
AslInitialize ();
Index1 = Index2 =
AslCommandLine (argc, argv);
/* Allocate the line buffer(s), must be after command line */
AslGbl_LineBufferSize /= 2;
UtExpandLineBuffers ();
/* Perform global actions first/only */
if (AslGbl_DisassembleAll)
{
while (argv[Index1])
{
Status = AcpiDmAddToExternalFileList (argv[Index1]);
if (ACPI_FAILURE (Status))
{
return (-1);
}
Index1++;
}
}
/* ACPICA subsystem initialization */
Status = AdInitialize ();
if (ACPI_FAILURE (Status))
{
return (Status);
}
/* Process each pathname/filename in the list, with possible wildcards */
while (argv[Index2])
{
/*
* If -p not specified, we will use the input filename as the
* output filename prefix
*/
if (AslGbl_UseDefaultAmlFilename)
{
AslGbl_OutputFilenamePrefix = argv[Index2];
UtConvertBackslashes (AslGbl_OutputFilenamePrefix);
}
Status = AslDoOneFile (argv[Index2]);
if (ACPI_FAILURE (Status))
{
ReturnStatus = -1;
}
Index2++;
}
/*
* At this point, compilation of a data table or disassembly is complete.
* However, if there is a parse tree, perform compiler analysis and
* generate AML.
*/
if (AslGbl_PreprocessOnly || AcpiGbl_DisasmFlag || !AslGbl_ParseTreeRoot)
{
goto CleanupAndExit;
}
CmDoAslMiddleAndBackEnd ();
/*
* At this point, all semantic analysis has been completed. Check
* expected error messages before cleanup or conversion.
*/
AslCheckExpectedExceptions ();
/* ASL-to-ASL+ conversion - Perform immediate disassembly */
if (AslGbl_DoAslConversion)
{
/* re-initialize ACPICA subsystem for disassembler */
Status = AdInitialize ();
if (ACPI_FAILURE (Status))
{
return (Status);
}
/*
* New input file is the output AML file from above.
* New output is from the input ASL file from above.
*/
AslGbl_OutputFilenamePrefix = AslGbl_Files[ASL_FILE_INPUT].Filename;
AslGbl_Files[ASL_FILE_INPUT].Filename =
AslGbl_Files[ASL_FILE_AML_OUTPUT].Filename;
CvDbgPrint ("Output filename: %s\n", AslGbl_OutputFilenamePrefix);
fprintf (stderr, "\n");
AcpiGbl_DisasmFlag = TRUE;
AslDoDisassembly ();
AcpiGbl_DisasmFlag = FALSE;
/* delete the AML file. This AML file should never be utilized by AML interpreters. */
FlDeleteFile (ASL_FILE_AML_OUTPUT);
}
CleanupAndExit:
UtFreeLineBuffers ();
AslParserCleanup ();
AcpiDmClearExternalFileList();
(void) AcpiTerminate ();
/* CmCleanupAndExit is intended for the compiler only */
if (!AcpiGbl_DisasmFlag)
{
ReturnStatus = CmCleanupAndExit ();
}
return (ReturnStatus);
}
/******************************************************************************
*
* FUNCTION: AslSignalHandler
*
* PARAMETERS: Sig - Signal that invoked this handler
*
* RETURN: None
*
* DESCRIPTION: Signal interrupt handler. Delete any intermediate files and
* any output files that may be left in an indeterminate state.
* Currently handles SIGINT (control-c).
*
*****************************************************************************/
static void ACPI_SYSTEM_XFACE
AslSignalHandler (
int Sig)
{
UINT32 i;
signal (Sig, SIG_IGN);
fflush (stdout);
fflush (stderr);
switch (Sig)
{
case SIGINT:
printf ("\n" ASL_PREFIX "<Control-C>\n");
break;
default:
printf (ASL_PREFIX "Unknown interrupt signal (%d)\n", Sig);
break;
}
/*
* Close all open files
* Note: the .pre file is the same as the input source file
*/
if (AslGbl_Files)
{
AslGbl_Files[ASL_FILE_PREPROCESSOR].Handle = NULL;
for (i = ASL_FILE_INPUT; i < ASL_MAX_FILE_TYPE; i++)
{
FlCloseFile (i);
}
/* Delete any output files */
for (i = ASL_FILE_AML_OUTPUT; i < ASL_MAX_FILE_TYPE; i++)
{
FlDeleteFile (i);
}
}
printf (ASL_PREFIX "Terminating\n");
_exit (0);
}
/*******************************************************************************
*
* FUNCTION: AslInitialize
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Initialize compiler globals
*
******************************************************************************/
static void
AslInitialize (
void)
{
AcpiGbl_DmOpt_Verbose = FALSE;
/* Default integer width is 32 bits */
AcpiGbl_IntegerBitWidth = 32;
AcpiGbl_IntegerNybbleWidth = 8;
AcpiGbl_IntegerByteWidth = 4;
}

View File

@@ -0,0 +1,613 @@
/******************************************************************************
*
* Module Name: aslmap - parser to AML opcode mapping table
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "amlcode.h"
#include "acparser.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslmap")
/*******************************************************************************
*
* FUNCTION: AslMapNamedOpcodeToDataType
*
* PARAMETERS: Opcode - The Named AML opcode to map
*
* RETURN: The ACPI type associated with the named opcode
*
* DESCRIPTION: Convert a raw Named AML opcode to the associated data type.
* Named opcodes are a subset of the AML opcodes.
*
******************************************************************************/
ACPI_OBJECT_TYPE
AslMapNamedOpcodeToDataType (
UINT16 Opcode)
{
const ACPI_OPCODE_INFO *OpInfo;
/*
* There are some differences from the opcode table types, we
* catch them here.
*/
OpInfo = AcpiPsGetOpcodeInfo (Opcode);
if (Opcode == AML_INT_NAMEPATH_OP)
{
return (ACPI_TYPE_ANY);
}
if (Opcode == AML_INT_METHODCALL_OP)
{
return (ACPI_TYPE_ANY);
}
if (OpInfo->Flags & AML_NSOBJECT)
{
return (OpInfo->ObjectType);
}
return (ACPI_TYPE_ANY);
}
/*******************************************************************************
*
* DATA STRUCTURE: AslKeywordMapping
*
* DESCRIPTION: Maps the ParseOpcode to the actual AML opcode. The parse
* opcodes are generated from Bison, and this table must
* track any additions to them.
*
* Each entry in the table contains the following items:
*
* AML opcode - Opcode that is written to the AML file
* Value - Value of the object to be written (if applicable)
* Flags - 1) Whether this opcode opens an AML "package".
*
******************************************************************************/
/*
* TBD:
* AccessAttrib
* AccessType
* AMlop for DMA?
* ObjectType keywords
* Register
*/
const ASL_MAPPING_ENTRY AslKeywordMapping [] =
{
/*! [Begin] no source code translation (keep the table structure) */
/* AML Opcode Value Flags Btype */
/* ACCESSAS */ OP_TABLE_ENTRY (AML_INT_ACCESSFIELD_OP, 0, 0, 0),
/* ACCESSATTRIB_BLOCK */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_BLOCK, 0, 0),
/* ACCESSATTRIB_BLOCK_PROCESS_CALL */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_BLOCK_PROCESS_CALL, 0, 0),
/* ACCESSATTRIB_BYTE */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_BYTE, 0, 0),
/* ACCESSATTRIB_BYTES */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_BYTES, 0, 0),
/* ACCESSATTRIB_QUICK */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_QUICK, 0, 0),
/* ACCESSATTRIB_RAW_BYTES */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_RAW_BYTES, 0, 0),
/* ACCESSATTRIB_RAW_PROCESS_BYTES */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_RAW_PROCESS_BYTES, 0, 0),
/* ACCESSATTRIB_SEND_RECEIVE */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_SEND_RECEIVE, 0, 0),
/* ACCESSATTRIB_WORD */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_WORD, 0, 0),
/* ACCESSATTRIB_PROCESS_CALL */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ATTRIB_PROCESS_CALL, 0, 0),
/* ACCESSTYPE_ANY */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ACCESS_ANY, 0, 0),
/* ACCESSTYPE_BUF */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ACCESS_BUFFER, 0, 0),
/* ACCESSTYPE_BYTE */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ACCESS_BYTE, 0, 0),
/* ACCESSTYPE_DWORD */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ACCESS_DWORD, 0, 0),
/* ACCESSTYPE_QWORD */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ACCESS_QWORD, 0, 0),
/* ACCESSTYPE_WORD */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_ACCESS_WORD, 0, 0),
/* ACQUIRE */ OP_TABLE_ENTRY (AML_ACQUIRE_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* ADD */ OP_TABLE_ENTRY (AML_ADD_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* ADDRESSINGMODE_7BIT */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* ADDRESSINGMODE_10BIT */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* ADDRESSTYPE_ACPI */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* ADDRESSTYPE_MEMORY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* ADDRESSTYPE_NVS */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0),
/* ADDRESSTYPE_RESERVED */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* ALIAS */ OP_TABLE_ENTRY (AML_ALIAS_OP, 0, 0, 0),
/* AND */ OP_TABLE_ENTRY (AML_BIT_AND_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* ARG0 */ OP_TABLE_ENTRY (AML_ARG0, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* ARG1 */ OP_TABLE_ENTRY (AML_ARG1, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* ARG2 */ OP_TABLE_ENTRY (AML_ARG2, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* ARG3 */ OP_TABLE_ENTRY (AML_ARG3, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* ARG4 */ OP_TABLE_ENTRY (AML_ARG4, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* ARG5 */ OP_TABLE_ENTRY (AML_ARG5, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* ARG6 */ OP_TABLE_ENTRY (AML_ARG6, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* BANKFIELD */ OP_TABLE_ENTRY (AML_BANK_FIELD_OP, 0, OP_AML_PACKAGE, 0),
/* BITSPERBYTE_EIGHT */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0),
/* BITSPERBYTE_FIVE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* BITSPERBYTE_NINE */ OP_TABLE_ENTRY (AML_BYTE_OP, 4, 0, 0),
/* BITSPERBYTE_SEVEN */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* BITSPERBYTE_SIX */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* BREAK */ OP_TABLE_ENTRY (AML_BREAK_OP, 0, 0, 0),
/* BREAKPOINT */ OP_TABLE_ENTRY (AML_BREAKPOINT_OP, 0, 0, 0),
/* BUFFER */ OP_TABLE_ENTRY (AML_BUFFER_OP, 0, OP_AML_PACKAGE, ACPI_BTYPE_BUFFER),
/* BUSMASTERTYPE_MASTER */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* BUSMASTERTYPE_NOTMASTER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* BYTECONST */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, 0, 0, ACPI_BTYPE_INTEGER),
/* CASE */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* CLOCKPHASE_FIRST */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* CLOCKPHASE_SECOND */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* CLOCKPOLARITY_HIGH */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* CLOCKPOLARITY_LOW */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* CONCATENATE */ OP_TABLE_ENTRY (AML_CONCATENATE_OP, 0, 0, ACPI_BTYPE_COMPUTE_DATA),
/* CONCATENATERESTEMPLATE */ OP_TABLE_ENTRY (AML_CONCATENATE_TEMPLATE_OP,0, 0, ACPI_BTYPE_BUFFER),
/* CONDREFOF */ OP_TABLE_ENTRY (AML_CONDITIONAL_REF_OF_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* CONNECTION */ OP_TABLE_ENTRY (AML_INT_CONNECTION_OP, 0, 0, 0),
/* CONTINUE */ OP_TABLE_ENTRY (AML_CONTINUE_OP, 0, 0, 0),
/* COPYOBJECT */ OP_TABLE_ENTRY (AML_COPY_OBJECT_OP, 0, 0, ACPI_BTYPE_DATA_REFERENCE),
/* CREATEBITFIELD */ OP_TABLE_ENTRY (AML_CREATE_BIT_FIELD_OP, 0, 0, 0),
/* CREATEBYTEFIELD */ OP_TABLE_ENTRY (AML_CREATE_BYTE_FIELD_OP, 0, 0, 0),
/* CREATEDWORDFIELD */ OP_TABLE_ENTRY (AML_CREATE_DWORD_FIELD_OP, 0, 0, 0),
/* CREATEFIELD */ OP_TABLE_ENTRY (AML_CREATE_FIELD_OP, 0, 0, 0),
/* CREATEQWORDFIELD */ OP_TABLE_ENTRY (AML_CREATE_QWORD_FIELD_OP, 0, 0, 0),
/* CREATEWORDFIELD */ OP_TABLE_ENTRY (AML_CREATE_WORD_FIELD_OP, 0, 0, 0),
/* DATABUFFER */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* DATATABLEREGION */ OP_TABLE_ENTRY (AML_DATA_REGION_OP, 0, 0, 0),
/* DEBUG */ OP_TABLE_ENTRY (AML_DEBUG_OP, 0, 0, ACPI_BTYPE_DEBUG_OBJECT),
/* DECODETYPE_POS */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* DECODETYPE_SUB */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* DECREMENT */ OP_TABLE_ENTRY (AML_DECREMENT_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* DEFAULT */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* DEFAULT_ARG */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* DEFINITIONBLOCK */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* DEREFOF */ OP_TABLE_ENTRY (AML_DEREF_OF_OP, 0, 0, ACPI_BTYPE_DATA_REFERENCE | ACPI_BTYPE_STRING),
/* DEVICE */ OP_TABLE_ENTRY (AML_DEVICE_OP, 0, OP_AML_PACKAGE, 0),
/* DEVICEPOLARITY_HIGH */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* DEVICEPOLARITY_LOW */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* DIVIDE */ OP_TABLE_ENTRY (AML_DIVIDE_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* DMA */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* DMATYPE_A */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* DMATYPE_COMPATIBILITY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* DMATYPE_B */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* DMATYPE_F */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0),
/* DWORDCONST */ OP_TABLE_ENTRY (AML_RAW_DATA_DWORD, 0, 0, ACPI_BTYPE_INTEGER),
/* DWORDIO */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* DWORDMEMORY */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* DWORDPCC */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* DWORDSPACE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* EISAID */ OP_TABLE_ENTRY (AML_DWORD_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* ELSE */ OP_TABLE_ENTRY (AML_ELSE_OP, 0, OP_AML_PACKAGE, 0),
/* ELSEIF */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, OP_AML_PACKAGE, 0),
/* ENDDEPENDENTFN */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* ENDIAN_BIG */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* ENDIAN_LITTLE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* ENDTAG */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* ERRORNODE */ OP_TABLE_ENTRY (AML_NOOP_OP, 0, 0, 0),
/* EVENT */ OP_TABLE_ENTRY (AML_EVENT_OP, 0, 0, 0),
/* EXTENDEDIO */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* EXTENDEDMEMORY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* EXTENDEDSPACE */ OP_TABLE_ENTRY (AML_RAW_DATA_QWORD, 0, 0, ACPI_BTYPE_INTEGER),
/* EXTERNAL */ OP_TABLE_ENTRY (AML_EXTERNAL_OP, 0, 0, 0),
/* FATAL */ OP_TABLE_ENTRY (AML_FATAL_OP, 0, 0, 0),
/* FIELD */ OP_TABLE_ENTRY (AML_FIELD_OP, 0, OP_AML_PACKAGE, 0),
/* FINDSETLEFTBIT */ OP_TABLE_ENTRY (AML_FIND_SET_LEFT_BIT_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* FINDSETRIGHTBIT */ OP_TABLE_ENTRY (AML_FIND_SET_RIGHT_BIT_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* FIXEDDMA */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* FIXEDIO */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* FLOWCONTROL_HW */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* FLOWCONTROL_NONE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* FLOWCONTROL_SW */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* FROMBCD */ OP_TABLE_ENTRY (AML_FROM_BCD_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* FUNCTION */ OP_TABLE_ENTRY (AML_METHOD_OP, 0, OP_AML_PACKAGE, 0),
/* GPIOINT */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* GPIOIO */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* CSI2SERIALBUS */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* I2CSERIALBUS */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* I2CSERIALBUSV2 */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* IF */ OP_TABLE_ENTRY (AML_IF_OP, 0, OP_AML_PACKAGE, 0),
/* INCLUDE */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* INCLUDE_END */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* INCREMENT */ OP_TABLE_ENTRY (AML_INCREMENT_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* INDEX */ OP_TABLE_ENTRY (AML_INDEX_OP, 0, 0, ACPI_BTYPE_REFERENCE_OBJECT),
/* INDEXFIELD */ OP_TABLE_ENTRY (AML_INDEX_FIELD_OP, 0, OP_AML_PACKAGE, 0),
/* INTEGER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* INTERRUPT */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* INTLEVEL_ACTIVEBOTH */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* INTLEVEL_ACTIVEHIGH */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* INTLEVEL_ACTIVELOW */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* INTTYPE_EDGE */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* INTTYPE_LEVEL */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* IO */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* IODECODETYPE_10 */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* IODECODETYPE_16 */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* IORESTRICT_IN */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* IORESTRICT_NONE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* IORESTRICT_OUT */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* IORESTRICT_PRESERVE */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0),
/* IRQ */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* IRQNOFLAGS */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* LAND */ OP_TABLE_ENTRY (AML_LOGICAL_AND_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* LEQUAL */ OP_TABLE_ENTRY (AML_LOGICAL_EQUAL_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* LGREATER */ OP_TABLE_ENTRY (AML_LOGICAL_GREATER_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* LGREATEREQUAL */ OP_TABLE_ENTRY (AML_LOGICAL_GREATER_EQUAL_OP,0, 0, ACPI_BTYPE_INTEGER),
/* LLESS */ OP_TABLE_ENTRY (AML_LOGICAL_LESS_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* LLESSEQUAL */ OP_TABLE_ENTRY (AML_LOGICAL_LESS_EQUAL_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* LNOT */ OP_TABLE_ENTRY (AML_LOGICAL_NOT_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* LNOTEQUAL */ OP_TABLE_ENTRY (AML_LOGICAL_NOT_EQUAL_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* LOAD */ OP_TABLE_ENTRY (AML_LOAD_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* LOADTABLE */ OP_TABLE_ENTRY (AML_LOAD_TABLE_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* LOCAL0 */ OP_TABLE_ENTRY (AML_LOCAL0, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* LOCAL1 */ OP_TABLE_ENTRY (AML_LOCAL1, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* LOCAL2 */ OP_TABLE_ENTRY (AML_LOCAL2, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* LOCAL3 */ OP_TABLE_ENTRY (AML_LOCAL3, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* LOCAL4 */ OP_TABLE_ENTRY (AML_LOCAL4, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* LOCAL5 */ OP_TABLE_ENTRY (AML_LOCAL5, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* LOCAL6 */ OP_TABLE_ENTRY (AML_LOCAL6, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* LOCAL7 */ OP_TABLE_ENTRY (AML_LOCAL7, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* LOCKRULE_LOCK */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_LOCK_ALWAYS, 0, 0),
/* LOCKRULE_NOLOCK */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_LOCK_NEVER, 0, 0),
/* LOR */ OP_TABLE_ENTRY (AML_LOGICAL_OR_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* MATCH */ OP_TABLE_ENTRY (AML_MATCH_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* MATCHTYPE_MEQ */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, MATCH_MEQ, 0, ACPI_BTYPE_INTEGER),
/* MATCHTYPE_MGE */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, MATCH_MGE, 0, ACPI_BTYPE_INTEGER),
/* MATCHTYPE_MGT */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, MATCH_MGT, 0, ACPI_BTYPE_INTEGER),
/* MATCHTYPE_MLE */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, MATCH_MLE, 0, ACPI_BTYPE_INTEGER),
/* MATCHTYPE_MLT */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, MATCH_MLT, 0, ACPI_BTYPE_INTEGER),
/* MATCHTYPE_MTR */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, MATCH_MTR, 0, ACPI_BTYPE_INTEGER),
/* MAXTYPE_FIXED */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* MAXTYPE_NOTFIXED */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* MEMORY24 */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* MEMORY32 */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* MEMORY32FIXED */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* MEMTYPE_CACHEABLE */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* MEMTYPE_NONCACHEABLE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* MEMTYPE_PREFETCHABLE */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0),
/* MEMTYPE_WRITECOMBINING */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* METHOD */ OP_TABLE_ENTRY (AML_METHOD_OP, 0, OP_AML_PACKAGE, 0),
/* METHODCALL */ OP_TABLE_ENTRY (AML_INT_METHODCALL_OP, 0, 0, ACPI_BTYPE_OBJECTS_AND_REFS),
/* MID */ OP_TABLE_ENTRY (AML_MID_OP, 0, 0, ACPI_BTYPE_STRING | ACPI_BTYPE_BUFFER),
/* MINTYPE_FIXED */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* MINTYPE_NOTFIXED */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* MOD */ OP_TABLE_ENTRY (AML_MOD_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* MULTIPLY */ OP_TABLE_ENTRY (AML_MULTIPLY_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* MUTEX */ OP_TABLE_ENTRY (AML_MUTEX_OP, 0, 0, 0),
/* NAME */ OP_TABLE_ENTRY (AML_NAME_OP, 0, 0, 0),
/* NAMESEG */ OP_TABLE_ENTRY (AML_INT_NAMEPATH_OP, 0, 0, 0),
/* NAMESTRING */ OP_TABLE_ENTRY (AML_INT_NAMEPATH_OP, 0, 0, 0),
/* NAND */ OP_TABLE_ENTRY (AML_BIT_NAND_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* NOOP */ OP_TABLE_ENTRY (AML_NOOP_OP, 0, 0, 0),
/* NOR */ OP_TABLE_ENTRY (AML_BIT_NOR_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* NOT */ OP_TABLE_ENTRY (AML_BIT_NOT_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* NOTIFY */ OP_TABLE_ENTRY (AML_NOTIFY_OP, 0, 0, 0),
/* OBJECTTYPE */ OP_TABLE_ENTRY (AML_OBJECT_TYPE_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* OBJECTTYPE_BFF */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_BUFFER_FIELD, 0, 0),
/* OBJECTTYPE_BUF */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_BUFFER, 0, 0),
/* OBJECTTYPE_DDB */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_DDB_HANDLE, 0, 0),
/* OBJECTTYPE_DEV */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_DEVICE, 0, 0),
/* OBJECTTYPE_EVT */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_EVENT, 0, 0),
/* OBJECTTYPE_FLD */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_FIELD_UNIT, 0, 0),
/* OBJECTTYPE_INT */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_INTEGER, 0, 0),
/* OBJECTTYPE_MTH */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_METHOD, 0, 0),
/* OBJECTTYPE_MTX */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_MUTEX, 0, 0),
/* OBJECTTYPE_OPR */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_REGION, 0, 0),
/* OBJECTTYPE_PKG */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_PACKAGE, 0, 0),
/* OBJECTTYPE_POW */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_POWER, 0, 0),
/* OBJECTTYPE_PRO */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_PROCESSOR, 0, 0),
/* OBJECTTYPE_STR */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_STRING, 0, 0),
/* OBJECTTYPE_THZ */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_THERMAL, 0, 0),
/* OBJECTTYPE_UNK */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_TYPE_ANY, 0, 0),
/* OFFSET */ OP_TABLE_ENTRY (AML_INT_RESERVEDFIELD_OP, 0, 0, 0),
/* ONE */ OP_TABLE_ENTRY (AML_ONE_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* ONES */ OP_TABLE_ENTRY (AML_ONES_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* OPERATIONREGION */ OP_TABLE_ENTRY (AML_REGION_OP, 0, 0, 0),
/* OR */ OP_TABLE_ENTRY (AML_BIT_OR_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* PACKAGE */ OP_TABLE_ENTRY (AML_PACKAGE_OP, 0, OP_AML_PACKAGE, ACPI_BTYPE_PACKAGE),
/* PACKAGEP_LENGTH */ OP_TABLE_ENTRY (AML_PACKAGE_LENGTH, 0, OP_AML_PACKAGE, 0),
/* PARITYTYPE_EVEN */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* PARITYTYPE_MARK */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0),
/* PARITYTYPE_NONE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* PARITYTYPE_ODD */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* PARITYTYPE_SPACE */ OP_TABLE_ENTRY (AML_BYTE_OP, 4, 0, 0),
/* PINCONFIG */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* PINFUNCTION */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* PINGROUP */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* PINGROUPCONFIG */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* PINGROUPFUNCTION */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* PIN_NOPULL */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0),
/* PIN_PULLDEFAULT */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* PIN_PULLDOWN */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* PIN_PULLUP */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* CLOCKINPUT */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* CLOCK_HZ */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* CLOCK_KHZ */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* CLOCK_MHZ */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* CLOCK_FIXED */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* CLOCK_VARIABLE */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* POWERRESOURCE */ OP_TABLE_ENTRY (AML_POWER_RESOURCE_OP, 0, OP_AML_PACKAGE, 0),
/* PROCESSOR */ OP_TABLE_ENTRY (AML_PROCESSOR_OP, 0, OP_AML_PACKAGE, 0),
/* QWORDCONST */ OP_TABLE_ENTRY (AML_RAW_DATA_QWORD, 0, 0, ACPI_BTYPE_INTEGER),
/* QWORDIO */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* QWORDMEMORY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* QWORDPCC */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* QWORDSPACE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* RANGE_TYPE_ENTIRE */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0),
/* RANGE_TYPE_ISAONLY */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* RANGE_TYPE_NONISAONLY */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* RAW_DATA */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* READWRITETYPE_BOTH */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* READWRITETYPE_READONLY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* REFOF */ OP_TABLE_ENTRY (AML_REF_OF_OP, 0, 0, ACPI_BTYPE_REFERENCE_OBJECT),
/* REGIONSPACE_CMOS */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_CMOS, 0, 0),
/* REGIONSPACE_EC */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_EC, 0, 0),
/* REGIONSPACE_FFIXEDHW */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_FIXED_HARDWARE, 0, 0),
/* REGIONSPACE_GPIO */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_GPIO, 0, 0),
/* REGIONSPACE_GSBUS */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_GSBUS, 0, 0),
/* REGIONSPACE_IO */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_SYSTEM_IO, 0, 0),
/* REGIONSPACE_IPMI */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_IPMI, 0, 0),
/* REGIONSPACE_MEM */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_SYSTEM_MEMORY, 0, 0),
/* REGIONSPACE_PCC */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_PLATFORM_COMM, 0, 0),
/* REGIONSPACE_PCI */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_PCI_CONFIG, 0, 0),
/* REGIONSPACE_PCIBAR */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_PCI_BAR_TARGET, 0, 0),
/* REGIONSPACE_PRM */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_PLATFORM_RT, 0, 0),
/* REGIONSPACE_SMBUS */ OP_TABLE_ENTRY (AML_RAW_DATA_BYTE, ACPI_ADR_SPACE_SMBUS, 0, 0),
/* REGISTER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* RELEASE */ OP_TABLE_ENTRY (AML_RELEASE_OP, 0, 0, 0),
/* RESERVED_BYTES */ OP_TABLE_ENTRY (AML_INT_RESERVEDFIELD_OP, 0, 0, 0),
/* RESET */ OP_TABLE_ENTRY (AML_RESET_OP, 0, 0, 0),
/* RESOURCETEMPLATE */ OP_TABLE_ENTRY (AML_BUFFER_OP, 0, 0, ACPI_BTYPE_BUFFER),
/* RESOURCETYPE_CONSUMER */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* RESOURCETYPE_PRODUCER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* RETURN */ OP_TABLE_ENTRY (AML_RETURN_OP, 0, 0, 0),
/* REVISION */ OP_TABLE_ENTRY (AML_REVISION_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* SCOPE */ OP_TABLE_ENTRY (AML_SCOPE_OP, 0, OP_AML_PACKAGE, 0),
/* SERIALIZERULE_NOTSERIAL */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* SERIALIZERULE_SERIAL */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* SHARETYPE_EXCLUSIVE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* SHARETYPE_EXCLUSIVEWAKE */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* SHARETYPE_SHARED */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* SHARETYPE_SHAREDWAKE */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0),
/* SHIFTLEFT */ OP_TABLE_ENTRY (AML_SHIFT_LEFT_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* SHIFTRIGHT */ OP_TABLE_ENTRY (AML_SHIFT_RIGHT_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* SIGNAL */ OP_TABLE_ENTRY (AML_SIGNAL_OP, 0, 0, 0),
/* SIZEOF */ OP_TABLE_ENTRY (AML_SIZE_OF_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* SLAVEMODE_CONTROLLERINIT */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* SLAVEMODE_DEVICEINIT */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* SLEEP */ OP_TABLE_ENTRY (AML_SLEEP_OP, 0, 0, 0),
/* SPISERIALBUS */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* SPISERIALBUSV2 */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* STALL */ OP_TABLE_ENTRY (AML_STALL_OP, 0, 0, 0),
/* STARTDEPENDENTFN */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* STARTDEPENDENTFN_NOPRI */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* STOPBITS_ONE */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* STOPBITS_ONEPLUSHALF */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* STOPBITS_TWO */ OP_TABLE_ENTRY (AML_BYTE_OP, 3, 0, 0),
/* STOPBITS_ZERO */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* STORE */ OP_TABLE_ENTRY (AML_STORE_OP, 0, 0, ACPI_BTYPE_DATA_REFERENCE),
/* STRING_LITERAL */ OP_TABLE_ENTRY (AML_STRING_OP, 0, 0, ACPI_BTYPE_STRING),
/* SUBTRACT */ OP_TABLE_ENTRY (AML_SUBTRACT_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* SWITCH */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* THERMALZONE */ OP_TABLE_ENTRY (AML_THERMAL_ZONE_OP, 0, OP_AML_PACKAGE, 0),
/* TIMER */ OP_TABLE_ENTRY (AML_TIMER_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* TOBCD */ OP_TABLE_ENTRY (AML_TO_BCD_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* TOBUFFER */ OP_TABLE_ENTRY (AML_TO_BUFFER_OP, 0, 0, ACPI_BTYPE_BUFFER),
/* TODECIMALSTRING */ OP_TABLE_ENTRY (AML_TO_DECIMAL_STRING_OP, 0, 0, ACPI_BTYPE_STRING),
/* TOHEXSTRING */ OP_TABLE_ENTRY (AML_TO_HEX_STRING_OP, 0, 0, ACPI_BTYPE_STRING),
/* TOINTEGER */ OP_TABLE_ENTRY (AML_TO_INTEGER_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* TOSTRING */ OP_TABLE_ENTRY (AML_TO_STRING_OP, 0, 0, ACPI_BTYPE_STRING),
/* TOUUID */ OP_TABLE_ENTRY (AML_DWORD_OP, 0, OP_AML_PACKAGE, ACPI_BTYPE_INTEGER),
/* TRANSLATIONTYPE_DENSE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* TRANSLATIONTYPE_SPARSE */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* TYPE_STATIC */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* TYPE_TRANSLATION */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* UART_SERIALBUS */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* UART_SERIALBUSV2 */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* UNICODE */ OP_TABLE_ENTRY (AML_BUFFER_OP, 0, OP_AML_PACKAGE, ACPI_BTYPE_BUFFER),
/* UNLOAD */ OP_TABLE_ENTRY (AML_UNLOAD_OP, 0, 0, 0),
/* UPDATERULE_ONES */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_UPDATE_WRITE_AS_ONES, 0, 0),
/* UPDATERULE_PRESERVE */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_UPDATE_PRESERVE, 0, 0),
/* UPDATERULE_ZEROS */ OP_TABLE_ENTRY (AML_BYTE_OP, AML_FIELD_UPDATE_WRITE_AS_ZEROS,0, 0),
/* VARIABLE_PACKAGE */ OP_TABLE_ENTRY (AML_VARIABLE_PACKAGE_OP, 0, OP_AML_PACKAGE, ACPI_BTYPE_PACKAGE),
/* VENDORLONG */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* VENDORSHORT */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* WAIT */ OP_TABLE_ENTRY (AML_WAIT_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* WHILE */ OP_TABLE_ENTRY (AML_WHILE_OP, 0, OP_AML_PACKAGE, 0),
/* WIREMODE_FOUR */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* WIREMODE_THREE */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* WORDBUSNUMBER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* WORDCONST */ OP_TABLE_ENTRY (AML_RAW_DATA_WORD, 0, 0, ACPI_BTYPE_INTEGER),
/* WORDIO */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* WORDPCC */ OP_TABLE_ENTRY (AML_DEFAULT_ARG_OP, 0, 0, 0),
/* WORDSPACE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* XFERSIZE_8 */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* XFERSIZE_16 */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* XFERSIZE_32 */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* XFERSIZE_64 */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* XFERSIZE_128 */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* XFERSIZE_256 */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* XFERTYPE_8 */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* XFERTYPE_8_16 */ OP_TABLE_ENTRY (AML_BYTE_OP, 1, 0, 0),
/* XFERTYPE_16 */ OP_TABLE_ENTRY (AML_BYTE_OP, 2, 0, 0),
/* XOR */ OP_TABLE_ENTRY (AML_BIT_XOR_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* ZERO */ OP_TABLE_ENTRY (AML_ZERO_OP, 0, 0, ACPI_BTYPE_INTEGER),
/* TOPLD */ OP_TABLE_ENTRY (AML_DWORD_OP, 0, OP_AML_PACKAGE, ACPI_BTYPE_INTEGER),
/* XFERSIZE_128 */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* REVISION */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* IGNORECOLOR */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* RED */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* GREEN */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* BLUE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* WIDTH */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* HEIGHT */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* USERVISIBLE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* DOCK */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* LID */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* PANEL */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* VERTICALPOSITION */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* HORIZONTALPOSITION */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* SHAPE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* GROUPORIENTATION */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* GROUPTOKEN */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* GROUPPOSITION */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* BAY */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* EJECTABLE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* EJECTREQUIRED */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* CABINETNUMBER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* CARDCAGENUMBER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* REFERENCE */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* ROTATION */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* ORDER */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* RESERVED */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* VERTICALOFFSET */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* HORIZONTALOFFSET */ OP_TABLE_ENTRY (AML_BYTE_OP, 0, 0, 0),
/* PRINTF */ OP_TABLE_ENTRY (AML_STORE_OP, 0, 0, ACPI_BTYPE_DATA_REFERENCE),
/* FPRINTF */ OP_TABLE_ENTRY (AML_STORE_OP, 0, 0, ACPI_BTYPE_DATA_REFERENCE),
/* ASLCODE */ OP_TABLE_ENTRY (0, 0, 0, 0)
/*! [End] no source code translation !*/
};

View File

@@ -0,0 +1,456 @@
/******************************************************************************
*
* Module Name: aslmapenter - Build resource descriptor/device maps
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "acpi.h"
#include "accommon.h"
#include "acapps.h"
#include "aslcompiler.h"
/* This module used for application-level code only */
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslmapenter")
/* Local prototypes */
static ACPI_GPIO_INFO *
MpCreateGpioInfo (
UINT16 PinNumber,
char *DeviceName);
static ACPI_SERIAL_INFO *
MpCreateSerialInfo (
char *DeviceName,
UINT16 Address);
/*******************************************************************************
*
* FUNCTION: MpSaveGpioInfo
*
* PARAMETERS: Resource - GPIO resource descriptor
* PinCount - From GPIO descriptor
* PinList - From GPIO descriptor
* DeviceName - The "ResourceSource" name
*
* RETURN: None
*
* DESCRIPTION: External Interface.
* Save GPIO resource descriptor information.
* Creates new GPIO info blocks, one for each pin defined by the
* GPIO descriptor.
*
******************************************************************************/
void
MpSaveGpioInfo (
ACPI_PARSE_OBJECT *Op,
AML_RESOURCE *Resource,
UINT32 PinCount,
UINT16 *PinList,
char *DeviceName)
{
ACPI_GPIO_INFO *Info;
UINT32 i;
/* Mapfile option enabled? */
if (!AslGbl_MapfileFlag)
{
return;
}
/* Create an info block for each pin defined in the descriptor */
for (i = 0; i < PinCount; i++)
{
Info = MpCreateGpioInfo (PinList[i], DeviceName);
Info->Op = Op;
Info->DeviceName = DeviceName;
Info->PinCount = PinCount;
Info->PinIndex = i;
Info->PinNumber = PinList[i];
Info->Type = Resource->Gpio.ConnectionType;
Info->Direction = (UINT8) (Resource->Gpio.IntFlags & 0x0003); /* _IOR, for IO descriptor */
Info->Polarity = (UINT8) ((Resource->Gpio.IntFlags >> 1) & 0x0003); /* _POL, for INT descriptor */
}
}
/*******************************************************************************
*
* FUNCTION: MpSaveSerialInfo
*
* PARAMETERS: Resource - A Serial resource descriptor
* DeviceName - The "ResourceSource" name.
*
* RETURN: None
*
* DESCRIPTION: External Interface.
* Save serial resource descriptor information.
* Creates a new serial info block.
*
******************************************************************************/
void
MpSaveSerialInfo (
ACPI_PARSE_OBJECT *Op,
AML_RESOURCE *Resource,
char *DeviceName)
{
ACPI_SERIAL_INFO *Info;
UINT16 Address;
UINT32 Speed;
/* Mapfile option enabled? */
if (!AslGbl_MapfileFlag)
{
return;
}
if (Resource->DescriptorType != ACPI_RESOURCE_NAME_SERIAL_BUS)
{
return;
}
/* Extract address and speed from the resource descriptor */
switch (Resource->CommonSerialBus.Type)
{
case AML_RESOURCE_I2C_SERIALBUSTYPE:
Address = Resource->I2cSerialBus.SlaveAddress;
Speed = Resource->I2cSerialBus.ConnectionSpeed;
break;
case AML_RESOURCE_SPI_SERIALBUSTYPE:
Address = Resource->SpiSerialBus.DeviceSelection;
Speed = Resource->SpiSerialBus.ConnectionSpeed;
break;
case AML_RESOURCE_UART_SERIALBUSTYPE:
Address = 0;
Speed = Resource->UartSerialBus.DefaultBaudRate;
break;
default: /* Invalid bus subtype */
return;
}
Info = MpCreateSerialInfo (DeviceName, Address);
Info->Op = Op;
Info->DeviceName = DeviceName;
Info->Resource = Resource;
Info->Address = Address;
Info->Speed = Speed;
}
/*******************************************************************************
*
* FUNCTION: MpCreateGpioInfo
*
* PARAMETERS: PinNumber - GPIO pin number
* DeviceName - The "ResourceSource" name
*
* RETURN: New GPIO info block.
*
* DESCRIPTION: Create a new GPIO info block and place it on the global list.
* The list is sorted by GPIO device names first, and pin numbers
* secondarily.
*
******************************************************************************/
static ACPI_GPIO_INFO *
MpCreateGpioInfo (
UINT16 PinNumber,
char *DeviceName)
{
ACPI_GPIO_INFO *Info;
ACPI_GPIO_INFO *NextGpio;
ACPI_GPIO_INFO *PrevGpio;
char *Buffer;
/*
* Allocate a new info block and insert it into the global GPIO list
* sorted by both source device name and then the pin number. There is
* one block per pin.
*/
Buffer = UtLocalCacheCalloc (sizeof (ACPI_GPIO_INFO));
Info = ACPI_CAST_PTR (ACPI_GPIO_INFO, Buffer);
NextGpio = AslGbl_GpioList;
PrevGpio = NULL;
if (!AslGbl_GpioList)
{
AslGbl_GpioList = Info;
Info->Next = NULL;
return (Info);
}
/* Sort on source DeviceName first */
while (NextGpio &&
(strcmp (DeviceName, NextGpio->DeviceName) > 0))
{
PrevGpio = NextGpio;
NextGpio = NextGpio->Next;
}
/* Now sort on the PinNumber */
while (NextGpio &&
(NextGpio->PinNumber < PinNumber) &&
!strcmp (DeviceName, NextGpio->DeviceName))
{
PrevGpio = NextGpio;
NextGpio = NextGpio->Next;
}
/* Finish the list insertion */
if (PrevGpio)
{
PrevGpio->Next = Info;
}
else
{
AslGbl_GpioList = Info;
}
Info->Next = NextGpio;
return (Info);
}
/*******************************************************************************
*
* FUNCTION: MpCreateSerialInfo
*
* PARAMETERS: DeviceName - The "ResourceSource" name.
* Address - Physical address for the device
*
* RETURN: New Serial info block.
*
* DESCRIPTION: Create a new Serial info block and place it on the global list.
* The list is sorted by Serial device names first, and addresses
* secondarily.
*
******************************************************************************/
static ACPI_SERIAL_INFO *
MpCreateSerialInfo (
char *DeviceName,
UINT16 Address)
{
ACPI_SERIAL_INFO *Info;
ACPI_SERIAL_INFO *NextSerial;
ACPI_SERIAL_INFO *PrevSerial;
char *Buffer;
/*
* Allocate a new info block and insert it into the global Serial list
* sorted by both source device name and then the address.
*/
Buffer = UtLocalCacheCalloc (sizeof (ACPI_SERIAL_INFO));
Info = ACPI_CAST_PTR (ACPI_SERIAL_INFO, Buffer);
NextSerial = AslGbl_SerialList;
PrevSerial = NULL;
if (!AslGbl_SerialList)
{
AslGbl_SerialList = Info;
Info->Next = NULL;
return (Info);
}
/* Sort on source DeviceName */
while (NextSerial &&
(strcmp (DeviceName, NextSerial->DeviceName) > 0))
{
PrevSerial = NextSerial;
NextSerial = NextSerial->Next;
}
/* Now sort on the Address */
while (NextSerial &&
(NextSerial->Address < Address) &&
!strcmp (DeviceName, NextSerial->DeviceName))
{
PrevSerial = NextSerial;
NextSerial = NextSerial->Next;
}
/* Finish the list insertion */
if (PrevSerial)
{
PrevSerial->Next = Info;
}
else
{
AslGbl_SerialList = Info;
}
Info->Next = NextSerial;
return (Info);
}

View File

@@ -0,0 +1,750 @@
/******************************************************************************
*
* Module Name: aslmapoutput - Output/emit the resource descriptor/device maps
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "acpi.h"
#include "accommon.h"
#include "acapps.h"
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "acinterp.h"
#include "acparser.h"
#include "acnamesp.h"
#include "amlcode.h"
/* This module used for application-level code only */
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslmapoutput")
/* Local prototypes */
static void
MpEmitGpioInfo (
void);
static void
MpEmitSerialInfo (
void);
static void
MpEmitDeviceTree (
void);
static ACPI_STATUS
MpEmitOneDevice (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue);
static void
MpXrefDevices (
ACPI_GPIO_INFO *Info);
static ACPI_STATUS
MpNamespaceXrefBegin (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context);
/* Strings used to decode flag bits */
const char *DirectionDecode[] =
{
"Both I/O ",
"InputOnly ",
"OutputOnly ",
"Preserve "
};
const char *PolarityDecode[] =
{
"ActiveHigh",
"ActiveLow ",
"ActiveBoth",
"Reserved "
};
/*******************************************************************************
*
* FUNCTION: MpEmitMappingInfo
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: External interface.
* Map file has already been opened. Emit all of the collected
* hardware mapping information. Includes: GPIO information,
* Serial information, and a dump of the entire ACPI device tree.
*
******************************************************************************/
void
MpEmitMappingInfo (
void)
{
/* Mapfile option enabled? */
if (!AslGbl_MapfileFlag)
{
return;
}
if (!AslGbl_GpioList)
{
FlPrintFile (ASL_FILE_MAP_OUTPUT,
"\nNo GPIO devices found\n");
}
if (!AslGbl_SerialList)
{
FlPrintFile (ASL_FILE_MAP_OUTPUT,
"\nNo Serial devices found (I2C/SPI/UART)\n");
}
if (!AslGbl_GpioList && !AslGbl_SerialList)
{
return;
}
/* Headers */
FlPrintFile (ASL_FILE_MAP_OUTPUT, "\nResource Descriptor Connectivity Map\n");
FlPrintFile (ASL_FILE_MAP_OUTPUT, "------------------------------------\n");
/* Emit GPIO and Serial descriptors, then entire ACPI device tree */
MpEmitGpioInfo ();
MpEmitSerialInfo ();
MpEmitDeviceTree ();
/* Clear the lists - no need to free memory here */
AslGbl_SerialList = NULL;
AslGbl_GpioList = NULL;
}
/*******************************************************************************
*
* FUNCTION: MpEmitGpioInfo
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Emit the info about all GPIO devices found during the
* compile or disassembly.
*
******************************************************************************/
static void
MpEmitGpioInfo (
void)
{
ACPI_GPIO_INFO *Info;
char *Type;
char *PrevDeviceName = NULL;
const char *Direction;
const char *Polarity;
char *ParentPathname;
const char *Description;
char *HidString;
const AH_DEVICE_ID *HidInfo;
/* Walk the GPIO descriptor list */
Info = AslGbl_GpioList;
while (Info)
{
HidString = MpGetHidViaNamestring (Info->DeviceName);
/* Print header info for the controller itself */
if (!PrevDeviceName ||
strcmp (PrevDeviceName, Info->DeviceName))
{
FlPrintFile (ASL_FILE_MAP_OUTPUT,
"\n\nGPIO Controller: %-8s %-28s",
HidString, Info->DeviceName);
HidInfo = AcpiAhMatchHardwareId (HidString);
if (HidInfo)
{
FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s",
HidInfo->Description);
}
FlPrintFile (ASL_FILE_MAP_OUTPUT,
"\n\nPin Type Direction Polarity"
" Dest _HID Destination\n");
}
PrevDeviceName = Info->DeviceName;
/* Setup various strings based upon the type (GpioInt or GpioIo) */
switch (Info->Type)
{
case AML_RESOURCE_GPIO_TYPE_INT:
Type = "GpioInt";
Direction = "-Interrupt-";
Polarity = PolarityDecode[Info->Polarity];
break;
case AML_RESOURCE_GPIO_TYPE_IO:
Type = "GpioIo ";
Direction = DirectionDecode[Info->Direction];
Polarity = " ";
break;
default:
continue;
}
/* Emit the GPIO info */
FlPrintFile (ASL_FILE_MAP_OUTPUT, "%4.4X %s %s %s ",
Info->PinNumber, Type, Direction, Polarity);
ParentPathname = NULL;
HidString = MpGetConnectionInfo (Info->Op, Info->PinIndex,
&Info->TargetNode, &ParentPathname);
if (HidString)
{
/*
* This is a Connection() field
* Attempt to find all references to the field.
*/
FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s %-28s",
HidString, ParentPathname);
MpXrefDevices (Info);
}
else
{
/*
* For Devices, attempt to get the _HID description string.
* Failing that (many _HIDs are not recognized), attempt to
* get the _DDN description string.
*/
HidString = MpGetParentDeviceHid (Info->Op, &Info->TargetNode,
&ParentPathname);
FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s %-28s",
HidString, ParentPathname);
/* Get the _HID description or _DDN string */
HidInfo = AcpiAhMatchHardwareId (HidString);
if (HidInfo)
{
FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s",
HidInfo->Description);
}
else if ((Description = MpGetDdnValue (ParentPathname)))
{
FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s (_DDN)",
Description);
}
}
FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n");
ACPI_FREE (ParentPathname);
Info = Info->Next;
}
}
/*******************************************************************************
*
* FUNCTION: MpEmitSerialInfo
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Emit the info about all Serial devices found during the
* compile or disassembly.
*
******************************************************************************/
static void
MpEmitSerialInfo (
void)
{
ACPI_SERIAL_INFO *Info;
char *Type;
char *ParentPathname;
char *PrevDeviceName = NULL;
char *HidString;
const AH_DEVICE_ID *HidInfo;
const char *Description;
AML_RESOURCE *Resource;
/* Walk the constructed serial descriptor list */
Info = AslGbl_SerialList;
while (Info)
{
Resource = Info->Resource;
switch (Resource->CommonSerialBus.Type)
{
case AML_RESOURCE_I2C_SERIALBUSTYPE:
Type = "I2C ";
break;
case AML_RESOURCE_SPI_SERIALBUSTYPE:
Type = "SPI ";
break;
case AML_RESOURCE_UART_SERIALBUSTYPE:
Type = "UART";
break;
default:
Type = "UNKN";
break;
}
HidString = MpGetHidViaNamestring (Info->DeviceName);
/* Print header info for the controller itself */
if (!PrevDeviceName ||
strcmp (PrevDeviceName, Info->DeviceName))
{
FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\n%s Controller: ",
Type);
FlPrintFile (ASL_FILE_MAP_OUTPUT, "%-8s %-28s",
HidString, Info->DeviceName);
HidInfo = AcpiAhMatchHardwareId (HidString);
if (HidInfo)
{
FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s",
HidInfo->Description);
}
FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\n");
FlPrintFile (ASL_FILE_MAP_OUTPUT,
"Type Address Speed Dest _HID Destination\n");
}
PrevDeviceName = Info->DeviceName;
FlPrintFile (ASL_FILE_MAP_OUTPUT, "%s %4.4X %8.8X ",
Type, Info->Address, Info->Speed);
ParentPathname = NULL;
HidString = MpGetConnectionInfo (Info->Op, 0, &Info->TargetNode,
&ParentPathname);
if (HidString)
{
/*
* This is a Connection() field
* Attempt to find all references to the field.
*/
FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s %-28s",
HidString, ParentPathname);
}
else
{
/* Normal resource template */
HidString = MpGetParentDeviceHid (Info->Op, &Info->TargetNode,
&ParentPathname);
FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s %-28s",
HidString, ParentPathname);
/* Get the _HID description or _DDN string */
HidInfo = AcpiAhMatchHardwareId (HidString);
if (HidInfo)
{
FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s",
HidInfo->Description);
}
else if ((Description = MpGetDdnValue (ParentPathname)))
{
FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s (_DDN)",
Description);
}
}
FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n");
ACPI_FREE (ParentPathname);
Info = Info->Next;
}
}
/*******************************************************************************
*
* FUNCTION: MpEmitDeviceTree
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Emit information about all devices within the ACPI namespace.
*
******************************************************************************/
static void
MpEmitDeviceTree (
void)
{
FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n\nACPI Device Tree\n");
FlPrintFile (ASL_FILE_MAP_OUTPUT, "----------------\n\n");
FlPrintFile (ASL_FILE_MAP_OUTPUT, "Device Pathname "
"_HID Description\n\n");
/* Walk the namespace from the root */
(void) AcpiNsWalkNamespace (ACPI_TYPE_DEVICE, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX, FALSE, MpEmitOneDevice, NULL, NULL, NULL);
}
/*******************************************************************************
*
* FUNCTION: MpEmitOneDevice
*
* PARAMETERS: ACPI_NAMESPACE_WALK callback
*
* RETURN: Status
*
* DESCRIPTION: Emit information about one ACPI device in the namespace. Used
* during dump of all device objects within the namespace.
*
******************************************************************************/
static ACPI_STATUS
MpEmitOneDevice (
ACPI_HANDLE ObjHandle,
UINT32 NestingLevel,
void *Context,
void **ReturnValue)
{
char *DevicePathname;
char *DdnString;
char *HidString;
const AH_DEVICE_ID *HidInfo;
/* Device pathname */
DevicePathname = AcpiNsGetExternalPathname (
ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle));
FlPrintFile (ASL_FILE_MAP_OUTPUT, "%-32s", DevicePathname);
/* _HID or _DDN */
HidString = MpGetHidValue (
ACPI_CAST_PTR (ACPI_NAMESPACE_NODE, ObjHandle));
FlPrintFile (ASL_FILE_MAP_OUTPUT, "%8s", HidString);
HidInfo = AcpiAhMatchHardwareId (HidString);
if (HidInfo)
{
FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s",
HidInfo->Description);
}
else if ((DdnString = MpGetDdnValue (DevicePathname)))
{
FlPrintFile (ASL_FILE_MAP_OUTPUT, " // %s (_DDN)", DdnString);
}
FlPrintFile (ASL_FILE_MAP_OUTPUT, "\n");
ACPI_FREE (DevicePathname);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: MpXrefDevices
*
* PARAMETERS: Info - A GPIO Info block
*
* RETURN: None
*
* DESCRIPTION: Cross-reference the parse tree and find all references to the
* specified GPIO device.
*
******************************************************************************/
static void
MpXrefDevices (
ACPI_GPIO_INFO *Info)
{
/* Walk the entire parse tree */
TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD,
MpNamespaceXrefBegin, NULL, Info);
if (!Info->References)
{
FlPrintFile (ASL_FILE_MAP_OUTPUT, " // **** No references in table");
}
}
/*******************************************************************************
*
* FUNCTION: MpNamespaceXrefBegin
*
* PARAMETERS: WALK_PARSE_TREE callback
*
* RETURN: Status
*
* DESCRIPTION: Walk parse tree callback used to cross-reference GPIO pins.
*
******************************************************************************/
static ACPI_STATUS
MpNamespaceXrefBegin (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
ACPI_GPIO_INFO *Info = ACPI_CAST_PTR (ACPI_GPIO_INFO, Context);
const ACPI_OPCODE_INFO *OpInfo;
char *DevicePathname;
ACPI_PARSE_OBJECT *ParentOp;
char *HidString;
ACPI_FUNCTION_TRACE_PTR (MpNamespaceXrefBegin, Op);
/*
* If this node is the actual declaration of a name
* [such as the XXXX name in "Method (XXXX)"],
* we are not interested in it here. We only care about names that
* are references to other objects within the namespace and the
* parent objects of name declarations
*/
if (Op->Asl.CompileFlags & OP_IS_NAME_DECLARATION)
{
return (AE_OK);
}
/* We are only interested in opcodes that have an associated name */
OpInfo = AcpiPsGetOpcodeInfo (Op->Asl.AmlOpcode);
if ((OpInfo->Flags & AML_NAMED) ||
(OpInfo->Flags & AML_CREATE))
{
return (AE_OK);
}
if ((Op->Asl.ParseOpcode != PARSEOP_NAMESTRING) &&
(Op->Asl.ParseOpcode != PARSEOP_NAMESEG) &&
(Op->Asl.ParseOpcode != PARSEOP_METHODCALL))
{
return (AE_OK);
}
if (!Op->Asl.Node)
{
return (AE_OK);
}
ParentOp = Op->Asl.Parent;
if (ParentOp->Asl.ParseOpcode == PARSEOP_FIELD)
{
return (AE_OK);
}
if (Op->Asl.Node == Info->TargetNode)
{
while (ParentOp && (!ParentOp->Asl.Node))
{
ParentOp = ParentOp->Asl.Parent;
}
if (ParentOp)
{
DevicePathname = AcpiNsGetExternalPathname (
ParentOp->Asl.Node);
if (!Info->References)
{
FlPrintFile (ASL_FILE_MAP_OUTPUT, " // References:");
}
HidString = MpGetHidViaNamestring (DevicePathname);
FlPrintFile (ASL_FILE_MAP_OUTPUT, " %s [%s]",
DevicePathname, HidString);
Info->References++;
ACPI_FREE (DevicePathname);
}
}
return (AE_OK);
}

View File

@@ -0,0 +1,516 @@
/******************************************************************************
*
* Module Name: aslmaputils - Utilities for the resource descriptor/device maps
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "acpi.h"
#include "accommon.h"
#include "acapps.h"
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "acinterp.h"
#include "acnamesp.h"
#include "amlcode.h"
/* This module used for application-level code only */
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslmaputils")
/*******************************************************************************
*
* FUNCTION: MpGetHidFromParseTree
*
* PARAMETERS: HidNode - Node for a _HID object
*
* RETURN: An _HID string value. Automatically converts _HID integers
* to strings. Never NULL.
*
* DESCRIPTION: Extract a _HID value from the parse tree, not the namespace.
* Used when a fully initialized namespace is not available.
*
******************************************************************************/
char *
MpGetHidFromParseTree (
ACPI_NAMESPACE_NODE *HidNode)
{
ACPI_PARSE_OBJECT *Op;
ACPI_PARSE_OBJECT *Arg;
char *HidString;
Op = HidNode->Op;
if (!Op)
{
/* Object is not resolved, probably an External */
return ("Unresolved Symbol - referenced but not defined in this table");
}
switch (Op->Asl.ParseOpcode)
{
case PARSEOP_NAME:
Arg = Op->Asl.Child; /* Get the NameSeg/NameString node */
Arg = Arg->Asl.Next; /* First peer is the object to be associated with the name */
switch (Arg->Asl.ParseOpcode)
{
case PARSEOP_STRING_LITERAL:
return (Arg->Asl.Value.String);
case PARSEOP_INTEGER:
/* Convert EISAID to a string */
HidString = UtLocalCacheCalloc (ACPI_EISAID_STRING_SIZE);
AcpiExEisaIdToString (HidString, Arg->Asl.Value.Integer);
return (HidString);
default:
return ("UNKNOWN");
}
default:
return ("-No HID-");
}
}
/*******************************************************************************
*
* FUNCTION: MpGetHidValue
*
* PARAMETERS: DeviceNode - Node for parent device
*
* RETURN: An _HID string value. Automatically converts _HID integers
* to strings. Never NULL.
*
* DESCRIPTION: Extract _HID value from within a device scope. Does not
* actually execute a method, just gets the string or integer
* value for the _HID.
*
******************************************************************************/
char *
MpGetHidValue (
ACPI_NAMESPACE_NODE *DeviceNode)
{
ACPI_NAMESPACE_NODE *HidNode;
char *HidString;
ACPI_STATUS Status;
Status = AcpiNsGetNode (DeviceNode, METHOD_NAME__HID,
ACPI_NS_NO_UPSEARCH, &HidNode);
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
/* If only partial namespace, get the _HID from the parse tree */
if (!HidNode->Object)
{
return (MpGetHidFromParseTree (HidNode));
}
/* Handle the different _HID flavors */
switch (HidNode->Type)
{
case ACPI_TYPE_STRING:
return (HidNode->Object->String.Pointer);
case ACPI_TYPE_INTEGER:
/* Convert EISAID to a string */
HidString = UtLocalCacheCalloc (ACPI_EISAID_STRING_SIZE);
AcpiExEisaIdToString (HidString, HidNode->Object->Integer.Value);
return (HidString);
case ACPI_TYPE_METHOD:
return ("-Method-");
default:
FlPrintFile (ASL_FILE_MAP_OUTPUT, "BAD HID TYPE: %u", HidNode->Type);
break;
}
ErrorExit:
return ("-No HID-");
}
/*******************************************************************************
*
* FUNCTION: MpGetHidViaNamestring
*
* PARAMETERS: DeviceName - Namepath for parent device
*
* RETURN: _HID string. Never NULL.
*
* DESCRIPTION: Get a _HID value via a device pathname (instead of just simply
* a device node.)
*
******************************************************************************/
char *
MpGetHidViaNamestring (
char *DeviceName)
{
ACPI_NAMESPACE_NODE *DeviceNode;
ACPI_STATUS Status;
Status = AcpiNsGetNode (NULL, DeviceName, ACPI_NS_NO_UPSEARCH,
&DeviceNode);
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
return (MpGetHidValue (DeviceNode));
ErrorExit:
return ("-No HID-");
}
/*******************************************************************************
*
* FUNCTION: MpGetParentDeviceHid
*
* PARAMETERS: Op - Parse Op to be examined
* TargetNode - Where the field node is returned
* ParentDeviceName - Where the node path is returned
*
* RETURN: _HID string. Never NULL.
*
* DESCRIPTION: Find the parent Device or Scope Op, get the full pathname to
* the parent, and get the _HID associated with the parent.
*
******************************************************************************/
char *
MpGetParentDeviceHid (
ACPI_PARSE_OBJECT *Op,
ACPI_NAMESPACE_NODE **TargetNode,
char **ParentDeviceName)
{
ACPI_NAMESPACE_NODE *DeviceNode;
/* Find parent Device() or Scope() Op */
while (Op &&
(Op->Asl.AmlOpcode != AML_DEVICE_OP) &&
(Op->Asl.AmlOpcode != AML_SCOPE_OP))
{
Op = Op->Asl.Parent;
}
if (!Op)
{
FlPrintFile (ASL_FILE_MAP_OUTPUT, " No_Parent_Device ");
goto ErrorExit;
}
/* Get the full pathname to the device and the _HID */
DeviceNode = Op->Asl.Node;
if (!DeviceNode)
{
FlPrintFile (ASL_FILE_MAP_OUTPUT, " No_Device_Node ");
goto ErrorExit;
}
*ParentDeviceName = AcpiNsGetExternalPathname (DeviceNode);
return (MpGetHidValue (DeviceNode));
ErrorExit:
return ("-No HID-");
}
/*******************************************************************************
*
* FUNCTION: MpGetDdnValue
*
* PARAMETERS: DeviceName - Namepath for parent device
*
* RETURN: _DDN description string. NULL on failure.
*
* DESCRIPTION: Execute the _DDN method for the device.
*
******************************************************************************/
char *
MpGetDdnValue (
char *DeviceName)
{
ACPI_NAMESPACE_NODE *DeviceNode;
ACPI_NAMESPACE_NODE *DdnNode;
ACPI_STATUS Status;
Status = AcpiNsGetNode (NULL, DeviceName, ACPI_NS_NO_UPSEARCH,
&DeviceNode);
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
Status = AcpiNsGetNode (DeviceNode, METHOD_NAME__DDN, ACPI_NS_NO_UPSEARCH,
&DdnNode);
if (ACPI_FAILURE (Status))
{
goto ErrorExit;
}
if ((DdnNode->Type != ACPI_TYPE_STRING) ||
!DdnNode->Object)
{
goto ErrorExit;
}
return (DdnNode->Object->String.Pointer);
ErrorExit:
return (NULL);
}
/*******************************************************************************
*
* FUNCTION: MpGetConnectionInfo
*
* PARAMETERS: Op - Parse Op to be examined
* PinIndex - Index into GPIO PinList
* TargetNode - Where the field node is returned
* TargetName - Where the node path is returned
*
* RETURN: A substitute _HID string, indicating that the name is actually
* a field. NULL if the Op does not refer to a Connection.
*
* DESCRIPTION: Get the Field Unit that corresponds to the PinIndex after
* a Connection() invocation.
*
******************************************************************************/
char *
MpGetConnectionInfo (
ACPI_PARSE_OBJECT *Op,
UINT32 PinIndex,
ACPI_NAMESPACE_NODE **TargetNode,
char **TargetName)
{
ACPI_PARSE_OBJECT *NextOp;
UINT32 i;
/*
* Handle Connection() here. Find the next named FieldUnit.
* Note: we look at the ParseOpcode for the compiler, look
* at the AmlOpcode for the disassembler.
*/
if ((Op->Asl.AmlOpcode == AML_INT_CONNECTION_OP) ||
(Op->Asl.ParseOpcode == PARSEOP_CONNECTION))
{
/* Find the correct field unit definition */
NextOp = Op;
for (i = 0; i <= PinIndex;)
{
NextOp = NextOp->Asl.Next;
while (NextOp &&
(NextOp->Asl.ParseOpcode != PARSEOP_NAMESEG) &&
(NextOp->Asl.AmlOpcode != AML_INT_NAMEDFIELD_OP))
{
NextOp = NextOp->Asl.Next;
}
if (!NextOp)
{
return ("UNKNOWN");
}
/* Add length of this field to the current pin index */
if (NextOp->Asl.ParseOpcode == PARSEOP_NAMESEG)
{
i += (UINT32) NextOp->Asl.Child->Asl.Value.Integer;
}
else /* AML_INT_NAMEDFIELD_OP */
{
i += (UINT32) NextOp->Asl.Value.Integer;
}
}
/* Return the node and pathname for the field unit */
*TargetNode = NextOp->Asl.Node;
*TargetName = AcpiNsGetExternalPathname (*TargetNode);
return ("-Field-");
}
return (NULL);
}

View File

@@ -0,0 +1,644 @@
/******************************************************************************
*
* Module Name: aslmessages.c - Compiler error/warning message strings
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslmessages")
/*
* Strings for message reporting levels, must match error
* type string tables in aslmessages.c
*/
const char *AslErrorLevel [ASL_NUM_REPORT_LEVELS] = {
"Optimize",
"Remark ",
"Warning ",
"Warning ",
"Warning ",
"Error "
};
/* All lowercase versions for IDEs */
const char *AslErrorLevelIde [ASL_NUM_REPORT_LEVELS] = {
"optimize",
"remark ",
"warning ",
"warning ",
"warning ",
"error "
};
/*
* Actual message strings for each compiler message ID. There are currently
* three distinct blocks of error messages (so that they can be expanded
* individually):
* Main ASL compiler
* Data Table compiler
* Preprocessor
*
* NOTE1: These tables must match the enum list of message IDs in the file
* aslmessages.h exactly.
*
* NOTE2: With the introduction of the -vw option to disable specific messages,
* new messages should only be added to the end of this list, so that values
* for existing messages are not disturbed. As important, obsolete messages
* cannot be removed from this list, as it will affect the -vw option.
*/
/* ASL compiler */
const char *AslCompilerMsgs [] =
{
/* The zeroth message is reserved */ "",
/* ASL_MSG_ALIGNMENT */ "Must be a multiple of alignment/granularity value",
/* ASL_MSG_ALPHANUMERIC_STRING */ "String must be entirely alphanumeric",
/* ASL_MSG_AML_NOT_IMPLEMENTED */ "Opcode is not implemented in compiler AML code generator",
/* ASL_MSG_ARG_COUNT_HI */ "Too many arguments",
/* ASL_MSG_ARG_COUNT_LO */ "Too few arguments",
/* ASL_MSG_ARG_INIT */ "Method argument is not initialized",
/* ASL_MSG_BACKWARDS_OFFSET */ "Invalid backwards offset",
/* ASL_MSG_BUFFER_LENGTH */ "Effective AML buffer length is zero",
/* ASL_MSG_CLOSE */ "Could not close file",
/* ASL_MSG_COMPILER_INTERNAL */ "Internal compiler error",
/* ASL_MSG_COMPILER_RESERVED */ "Use of compiler reserved name",
/* ASL_MSG_CONNECTION_MISSING */ "A Connection operator is required for this field SpaceId",
/* ASL_MSG_CONNECTION_INVALID */ "Invalid OpRegion SpaceId for use of Connection operator",
/* ASL_MSG_CONSTANT_EVALUATION */ "Could not evaluate constant expression",
/* ASL_MSG_CONSTANT_FOLDED */ "Constant expression evaluated and reduced",
/* ASL_MSG_CORE_EXCEPTION */ "From ACPICA Subsystem",
/* ASL_MSG_DEBUG_FILE_OPEN */ "Could not open debug file",
/* ASL_MSG_DEBUG_FILENAME */ "Could not create debug filename",
/* ASL_MSG_DEPENDENT_NESTING */ "Dependent function macros cannot be nested",
/* ASL_MSG_DMA_CHANNEL */ "Invalid DMA channel (must be 0-7)",
/* ASL_MSG_DMA_LIST */ "Too many DMA channels (8 max)",
/* ASL_MSG_DUPLICATE_CASE */ "Case value already specified",
/* ASL_MSG_DUPLICATE_ITEM */ "Duplicate value in list",
/* ASL_MSG_EARLY_EOF */ "Premature end-of-file reached",
/* ASL_MSG_ENCODING_LENGTH */ "Package length too long to encode",
/* ASL_MSG_EX_INTERRUPT_LIST */ "Too many interrupts (255 max)",
/* ASL_MSG_EX_INTERRUPT_LIST_MIN */ "Too few interrupts (1 minimum required)",
/* ASL_MSG_EX_INTERRUPT_NUMBER */ "Invalid interrupt number (must be 32 bits)",
/* ASL_MSG_FIELD_ACCESS_WIDTH */ "Access width is greater than region size",
/* ASL_MSG_FIELD_UNIT_ACCESS_WIDTH */ "Access width of Field Unit extends beyond region limit",
/* ASL_MSG_FIELD_UNIT_OFFSET */ "Field Unit extends beyond region limit",
/* ASL_MSG_GPE_NAME_CONFLICT */ "Name conflicts with a previous GPE method",
/* ASL_MSG_HID_LENGTH */ "_HID string must be exactly 7 or 8 characters",
/* ASL_MSG_HID_PREFIX */ "_HID prefix must be all uppercase or decimal digits",
/* ASL_MSG_HID_SUFFIX */ "_HID suffix must be all hex digits",
/* ASL_MSG_INCLUDE_FILE_OPEN */ "Could not open include file",
/* ASL_MSG_INPUT_FILE_OPEN */ "Could not open input file",
/* ASL_MSG_INTEGER_LENGTH */ "Truncating 64-bit constant found in 32-bit table",
/* ASL_MSG_INTEGER_OPTIMIZATION */ "Integer optimized to single-byte AML opcode",
/* ASL_MSG_INTERRUPT_LIST */ "Too many interrupts (16 max)",
/* ASL_MSG_INTERRUPT_NUMBER */ "Invalid interrupt number (must be 0-15)",
/* ASL_MSG_INVALID_ACCESS_SIZE */ "Invalid AccessSize (Maximum is 4 - QWord access)",
/* ASL_MSG_INVALID_ADDR_FLAGS */ "Invalid combination of Length and Min/Max fixed flags",
/* ASL_MSG_INVALID_CONSTANT_OP */ "Invalid operator in constant expression (not type 3/4/5)",
/* ASL_MSG_INVALID_EISAID */ "EISAID string must be of the form \"UUUXXXX\" (3 uppercase, 4 hex digits)",
/* ASL_MSG_INVALID_ESCAPE */ "Invalid or unknown escape sequence",
/* ASL_MSG_INVALID_GRAN_FIXED */ "Granularity must be zero for fixed Min/Max",
/* ASL_MSG_INVALID_GRANULARITY */ "Granularity must be zero or a power of two minus one",
/* ASL_MSG_INVALID_LENGTH */ "Length is larger than Min/Max window",
/* ASL_MSG_INVALID_LENGTH_FIXED */ "Length is not equal to fixed Min/Max window",
/* ASL_MSG_INVALID_MIN_MAX */ "Address Min is greater than Address Max",
/* ASL_MSG_INVALID_OPERAND */ "Invalid operand",
/* ASL_MSG_INVALID_PERFORMANCE */ "Invalid performance/robustness value",
/* ASL_MSG_INVALID_PRIORITY */ "Invalid priority value",
/* ASL_MSG_INVALID_STRING */ "Invalid Hex/Octal Escape - Non-ASCII or NULL",
/* ASL_MSG_INVALID_TARGET */ "Target operand not allowed in constant expression",
/* ASL_MSG_INVALID_TIME */ "Time parameter too long (255 max)",
/* ASL_MSG_INVALID_TYPE */ "Invalid type",
/* ASL_MSG_INVALID_UUID */ "UUID string must be of the form \"aabbccdd-eeff-gghh-iijj-kkllmmnnoopp\"",
/* ASL_MSG_ISA_ADDRESS */ "Maximum 10-bit ISA address (0x3FF)",
/* ASL_MSG_LEADING_ASTERISK */ "Invalid leading asterisk",
/* ASL_MSG_LIST_LENGTH_LONG */ "Initializer list longer than declared package length",
/* ASL_MSG_LIST_LENGTH_SHORT */ "Initializer list shorter than declared package length",
/* ASL_MSG_LISTING_FILE_OPEN */ "Could not open listing file",
/* ASL_MSG_LISTING_FILENAME */ "Could not create listing filename",
/* ASL_MSG_LOCAL_INIT */ "Method local variable is not initialized",
/* ASL_MSG_LOCAL_OUTSIDE_METHOD */ "Local or Arg used outside a control method",
/* ASL_MSG_LONG_LINE */ "Splitting long input line",
/* ASL_MSG_MEMORY_ALLOCATION */ "Memory allocation failure",
/* ASL_MSG_MISSING_ENDDEPENDENT */ "Missing EndDependentFn() macro in dependent resource list",
/* ASL_MSG_MISSING_STARTDEPENDENT */ "Missing StartDependentFn() macro in dependent resource list",
/* ASL_MSG_MULTIPLE_DEFAULT */ "More than one Default statement within Switch construct",
/* ASL_MSG_MULTIPLE_TYPES */ "Multiple types",
/* ASL_MSG_NAME_EXISTS */ "Name already exists in scope",
/* ASL_MSG_NAME_OPTIMIZATION */ "NamePath optimized",
/* ASL_MSG_NAMED_OBJECT_IN_WHILE */ "Creating a named object in a While loop",
/* ASL_MSG_NESTED_COMMENT */ "Nested comment found",
/* ASL_MSG_NO_CASES */ "No Case statements under Switch",
/* ASL_MSG_NO_REGION */ "_REG has no corresponding Operation Region",
/* ASL_MSG_NO_RETVAL */ "Called method returns no value",
/* ASL_MSG_NO_WHILE */ "No enclosing While statement",
/* ASL_MSG_NON_ASCII */ "Invalid characters found in file",
/* ASL_MSG_BUFFER_FIELD_LENGTH */ "Field length must be non-zero",
/* ASL_MSG_NOT_EXIST */ "Object does not exist",
/* ASL_MSG_NOT_FOUND */ "Object not found or not accessible from current scope",
/* ASL_MSG_NOT_METHOD */ "Not a control method, cannot invoke",
/* ASL_MSG_NOT_PARAMETER */ "Not a parameter, used as local only",
/* ASL_MSG_NOT_REACHABLE */ "Object is not accessible from this scope",
/* ASL_MSG_NOT_REFERENCED */ "Object is not referenced",
/* ASL_MSG_NULL_DESCRIPTOR */ "Min/Max/Length/Gran are all zero, but no resource tag",
/* ASL_MSG_NULL_STRING */ "Invalid zero-length (null) string",
/* ASL_MSG_OPEN */ "Could not open file",
/* ASL_MSG_OUTPUT_FILE_OPEN */ "Could not open output AML file",
/* ASL_MSG_OUTPUT_FILENAME */ "Could not create output filename",
/* ASL_MSG_PACKAGE_LENGTH */ "Effective AML package length is zero",
/* ASL_MSG_PREPROCESSOR_FILENAME */ "Could not create preprocessor filename",
/* ASL_MSG_READ */ "Could not read file",
/* ASL_MSG_RECURSION */ "Recursive method call",
/* ASL_MSG_REGION_BUFFER_ACCESS */ "Host Operation Region requires BufferAcc access",
/* ASL_MSG_REGION_BYTE_ACCESS */ "Host Operation Region requires ByteAcc access",
/* ASL_MSG_RESERVED_ARG_COUNT_HI */ "Reserved method has too many arguments",
/* ASL_MSG_RESERVED_ARG_COUNT_LO */ "Reserved method has too few arguments",
/* ASL_MSG_RESERVED_METHOD */ "Reserved name must be a control method",
/* ASL_MSG_RESERVED_NO_RETURN_VAL */ "Reserved method should not return a value",
/* ASL_MSG_RESERVED_OPERAND_TYPE */ "Invalid object type for reserved name",
/* ASL_MSG_RESERVED_PACKAGE_LENGTH */ "Invalid package length for reserved name",
/* ASL_MSG_RESERVED_RETURN_VALUE */ "Reserved method must return a value",
/* ASL_MSG_RESERVED_USE */ "Invalid use of reserved name",
/* ASL_MSG_RESERVED_WORD */ "Use of reserved name",
/* ASL_MSG_RESOURCE_FIELD */ "Resource field name cannot be used as a target",
/* ASL_MSG_RESOURCE_INDEX */ "Missing ResourceSourceIndex (required)",
/* ASL_MSG_RESOURCE_LIST */ "Too many resource items (internal error)",
/* ASL_MSG_RESOURCE_SOURCE */ "Missing ResourceSource string (required)",
/* ASL_MSG_RESULT_NOT_USED */ "Result is not used, operator has no effect",
/* ASL_MSG_RETURN_TYPES */ "Not all control paths return a value",
/* ASL_MSG_SCOPE_FWD_REF */ "Forward references from Scope operator not allowed",
/* ASL_MSG_SCOPE_TYPE */ "Existing object has invalid type for Scope operator",
/* ASL_MSG_SEEK */ "Could not seek file",
/* ASL_MSG_SERIALIZED */ "Control Method marked Serialized",
/* ASL_MSG_SERIALIZED_REQUIRED */ "Control Method should be made Serialized due to creation of named objects within",
/* ASL_MSG_SINGLE_NAME_OPTIMIZATION */ "NamePath optimized to NameSeg (uses run-time search path)",
/* ASL_MSG_SOME_NO_RETVAL */ "Called method may not always return a value",
/* ASL_MSG_STRING_LENGTH */ "String literal too long",
/* ASL_MSG_SWITCH_TYPE */ "Switch expression is not a static Integer/Buffer/String data type, defaulting to Integer",
/* ASL_MSG_SYNC_LEVEL */ "SyncLevel must be in the range 0-15",
/* ASL_MSG_SYNTAX */ "",
/* ASL_MSG_TABLE_SIGNATURE */ "Invalid Table Signature",
/* ASL_MSG_TAG_LARGER */ "ResourceTag larger than Field",
/* ASL_MSG_TAG_SMALLER */ "ResourceTag smaller than Field",
/* ASL_MSG_TIMEOUT */ "Result is not used, possible operator timeout will be missed",
/* ASL_MSG_TOO_MANY_TEMPS */ "Method requires too many temporary variables (_T_x)",
/* ASL_MSG_TRUNCATION */ "64-bit return value will be truncated to 32 bits (DSDT or SSDT version < 2)",
/* ASL_MSG_UNKNOWN_RESERVED_NAME */ "Unknown reserved name",
/* ASL_MSG_UNREACHABLE_CODE */ "Statement is unreachable",
/* ASL_MSG_UNSUPPORTED */ "Unsupported feature",
/* ASL_MSG_UPPER_CASE */ "Non-hex letters must be upper case",
/* ASL_MSG_VENDOR_LIST */ "Too many vendor data bytes (7 max)",
/* ASL_MSG_WRITE */ "Could not write file",
/* ASL_MSG_RANGE */ "Constant out of range",
/* ASL_MSG_BUFFER_ALLOCATION */ "Could not allocate line buffer",
/* ASL_MSG_MISSING_DEPENDENCY */ "Missing dependency",
/* ASL_MSG_ILLEGAL_FORWARD_REF */ "Illegal forward reference",
/* ASL_MSG_ILLEGAL_METHOD_REF */ "Object is declared in a different method",
/* ASL_MSG_LOCAL_NOT_USED */ "Method Local is set but never used",
/* ASL_MSG_ARG_AS_LOCAL_NOT_USED */ "Method Argument (as a local) is set but never used",
/* ASL_MSG_ARG_NOT_USED */ "Method Argument is never used",
/* ASL_MSG_CONSTANT_REQUIRED */ "Non-reducible expression",
/* ASL_MSG_CROSS_TABLE_SCOPE */ "Illegal open scope on external object from within DSDT",
/* ASL_MSG_EXCEPTION_NOT_RECEIVED */ "Expected remark, warning, or error did not occur. Message ID:",
/* ASL_MSG_NULL_RESOURCE_TEMPLATE */ "Empty Resource Template (END_TAG only)",
/* ASL_MSG_FOUND_HERE */ "Original name creation/declaration below: ",
/* ASL_MSG_ILLEGAL_RECURSION */ "Illegal recursive call to method that creates named objects",
/* ASL_MSG_DUPLICATE_INPUT_FILE */ "Duplicate input files detected:",
/* ASL_MSG_WARNING_AS_ERROR */ "Warnings detected during compilation",
/* ASL_MSG_OEM_TABLE_ID */ "Invalid OEM Table ID",
/* ASL_MSG_OEM_ID */ "Invalid OEM ID",
/* ASL_MSG_UNLOAD */ "Unload is not supported by all operating systems",
/* ASL_MSG_OFFSET */ "Unnecessary/redundant use of Offset operator",
/* ASL_MSG_LONG_SLEEP */ "Very long Sleep, greater than 1 second",
/* ASL_MSG_PREFIX_NOT_EXIST */ "One or more prefix Scopes do not exist",
/* ASL_MSG_NAMEPATH_NOT_EXIST */ "One or more objects within the Pathname do not exist",
/* ASL_MSG_REGION_LENGTH */ "Operation Region declared with zero length",
/* ASL_MSG_TEMPORARY_OBJECT */ "Object is created temporarily in another method and cannot be accessed",
/* ASL_MSG_UNDEFINED_EXTERNAL */ "Named object was declared external but the actual definition does not exist",
/* ASL_MSG_BUFFER_FIELD_OVERFLOW */ "Buffer field extends beyond end of target buffer",
/* ASL_MSG_INVALID_SPECIAL_NAME */ "declaration of this named object outside root scope is illegal",
/* ASL_MSG_INVALID_PROCESSOR_UID */ "_UID inside processor declaration must be an integer",
/* ASL_MSG_LEGACY_PROCESSOR_OP */ "Legacy Processor() keyword detected. Use Device() keyword instead.",
/* ASL_MSG_NAMESTRING_LENGTH */ "NameString contains too many NameSegs (>255)",
/* ASL_MSG_CASE_FOUND_HERE */ "Original Case value below:",
/* ASL_MSG_EXTERN_INVALID_RET_TYPE */ "Return type is only allowed for Externals declared as MethodObj",
/* ASL_MSG_EXTERN_INVALID_PARAM_TYPE */ "Parameter type is only allowed for Externals declared as MethodObj",
/* ASL_MSG_NAMED_OBJECT_CREATION */ "Creation of named objects within a method is highly inefficient, use globals or method local variables instead",
/* ASL_MSG_ARG_COUNT_MISMATCH */ "Method NumArgs count does not match length of ParameterTypes list",
/* ASL_MSG_STATIC_OPREGION_IN_METHOD */ "Static OperationRegion should be declared outside control method",
/* ASL_MSG_DECLARATION_TYPE_MISMATCH */ "Type mismatch between external declaration and actual object declaration detected",
/* ASL_MSG_TYPE_MISMATCH_FOUND_HERE */ "Actual object declaration:",
/* ASL_MSG_DUPLICATE_EXTERN_MISMATCH */ "Type mismatch between multiple external declarations detected",
/* ASL_MSG_DUPLICATE_EXTERN_FOUND_HERE */"Duplicate external declaration:",
/* ASL_MSG_CONDREF_NEEDS_EXTERNAL_DECL */"CondRefOf parameter requires External() declaration",
/* ASL_MSG_EXTERNAL_FOUND_HERE */ "External declaration below ",
/* ASL_MSG_LOWER_CASE_NAMESEG */ "At least one lower case letter found in NameSeg, ASL is case insensitive - converting to upper case",
/* ASL_MSG_LOWER_CASE_NAMEPATH */ "At least one lower case letter found in NamePath, ASL is case insensitive - converting to upper case",
/* ASL_MSG_UUID_NOT_FOUND */ "Unknown UUID string",
/* ASL_MSG_LEGACY_DDB_TYPE */ "DDBHandleObj has been deprecated along with the Unload operator. DDBHandlObj objects are only used in Unload"
};
/* Table compiler */
const char *AslTableCompilerMsgs [] =
{
/* ASL_MSG_BUFFER_ELEMENT */ "Invalid element in buffer initializer list",
/* ASL_MSG_DIVIDE_BY_ZERO */ "Expression contains divide-by-zero",
/* ASL_MSG_FLAG_VALUE */ "Flag value is too large",
/* ASL_MSG_INTEGER_SIZE */ "Integer too large for target",
/* ASL_MSG_INVALID_EXPRESSION */ "Invalid expression",
/* ASL_MSG_INVALID_FIELD_NAME */ "Invalid Field Name",
/* ASL_MSG_INVALID_HEX_INTEGER */ "Invalid hex integer constant",
/* ASL_MSG_OEM_TABLE */ "OEM table - unknown contents",
/* ASL_MSG_RESERVED_FIELD */ "Reserved field",
/* ASL_MSG_UNKNOWN_LABEL */ "Label is undefined",
/* ASL_MSG_UNKNOWN_SUBTABLE */ "Unknown subtable type",
/* ASL_MSG_UNKNOWN_TABLE */ "Unknown ACPI table signature",
/* ASL_MSG_ZERO_VALUE */ "Value must be non-zero",
/* ASL_MSG_INVALID_LABEL */ "Invalid field label detected",
/* ASL_MSG_BUFFER_LIST */ "Invalid buffer initializer list",
/* ASL_MSG_ENTRY_LIST */ "Invalid entry initializer list",
/* ASL_MSG_UNKNOWN_FORMAT */ "Unknown format value",
/* ASL_MSG_RESERVED_VALUE */ "Value for field is reserved or unknown",
/* ASL_MSG_TWO_ZERO_VALUES */ "32-bit DSDT Address and 64-bit X_DSDT Address cannot both be zero",
/* ASL_MSG_BAD_PARSE_TREE */ "Parse tree appears to be ill-defined"
};
/* Preprocessor */
const char *AslPreprocessorMsgs [] =
{
/* ASL_MSG_DIRECTIVE_SYNTAX */ "Invalid directive syntax",
/* ASL_MSG_ENDIF_MISMATCH */ "Mismatched #endif",
/* ASL_MSG_ERROR_DIRECTIVE */ "#error",
/* ASL_MSG_EXISTING_NAME */ "Name is already defined",
/* ASL_MSG_INVALID_INVOCATION */ "Invalid macro invocation",
/* ASL_MSG_MACRO_SYNTAX */ "Invalid macro syntax",
/* ASL_MSG_TOO_MANY_ARGUMENTS */ "Too many macro arguments",
/* ASL_MSG_UNKNOWN_DIRECTIVE */ "Unknown directive",
/* ASL_MSG_UNKNOWN_PRAGMA */ "Unknown pragma",
/* ASL_MSG_WARNING_DIRECTIVE */ "#warning",
/* ASL_MSG_INCLUDE_FILE */ "Found a # preprocessor directive in ASL Include() file"
};
/*******************************************************************************
*
* FUNCTION: AeDecodeMessageId
*
* PARAMETERS: MessageId - ASL message ID (exception code) to be
* formatted. Possibly fully encoded.
*
* RETURN: A string containing the exception message text.
*
* DESCRIPTION: This function validates and translates an ASL message ID into
* an ASCII string.
*
******************************************************************************/
const char *
AeDecodeMessageId (
UINT16 MessageId)
{
UINT32 Index;
const char **MessageTable;
/* Main ASL Compiler messages */
if (MessageId <= ASL_MSG_MAIN_COMPILER_END)
{
MessageTable = AslCompilerMsgs;
Index = MessageId;
if (Index >= ACPI_ARRAY_LENGTH (AslCompilerMsgs))
{
return ("[Unknown iASL Compiler exception ID]");
}
}
/* Data Table Compiler messages */
else if (MessageId <= ASL_MSG_TABLE_COMPILER_END)
{
MessageTable = AslTableCompilerMsgs;
Index = MessageId - ASL_MSG_TABLE_COMPILER;
if (Index >= ACPI_ARRAY_LENGTH (AslTableCompilerMsgs))
{
return ("[Unknown iASL Table Compiler exception ID]");
}
}
/* Preprocessor messages */
else if (MessageId <= ASL_MSG_PREPROCESSOR_END)
{
MessageTable = AslPreprocessorMsgs;
Index = MessageId - ASL_MSG_PREPROCESSOR;
if (Index >= ACPI_ARRAY_LENGTH (AslPreprocessorMsgs))
{
return ("[Unknown iASL Preprocessor exception ID]");
}
}
/* Everything else is unknown */
else
{
return ("[Unknown iASL exception ID]");
}
return (MessageTable[Index]);
}
/*******************************************************************************
*
* FUNCTION: AeDecodeExceptionLevel
*
* PARAMETERS: Level - The ASL error level to be decoded
*
* RETURN: A string containing the error level text
*
* DESCRIPTION: This function validates and translates an ASL error level into
* an ASCII string.
*
******************************************************************************/
const char *
AeDecodeExceptionLevel (
UINT8 Level)
{
/* Range check on Level */
if (Level >= ACPI_ARRAY_LENGTH (AslErrorLevel))
{
return ("Unknown exception level");
}
/* Differentiate the string type to be used (IDE is all lower case) */
if (AslGbl_VerboseErrors)
{
return (AslErrorLevel[Level]);
}
return (AslErrorLevelIde[Level]);
}
/*******************************************************************************
*
* FUNCTION: AeBuildFullExceptionCode
*
* PARAMETERS: Level - ASL error level
* MessageId - ASL exception code to be formatted
*
* RETURN: Fully encoded exception code
*
* DESCRIPTION: Build the full exception code from the error level and the
* actual message ID.
*
******************************************************************************/
UINT16
AeBuildFullExceptionCode (
UINT8 Level,
UINT16 MessageId)
{
/*
* Error level is in the thousands slot (error/warning/remark, etc.)
* Error codes are 0 - 999
*/
return (((Level + 1) * 1000) + MessageId);
}
#ifdef ACPI_HELP_APP
/*******************************************************************************
*
* FUNCTION: AhDecodeAslException
*
* PARAMETERS: HexString - iASL status string from command line, in
* hex. If null, display all exceptions.
*
* RETURN: None
*
* DESCRIPTION: Decode and display an iASL exception code. Note1: a
* NULL string for HexString displays all known iASL exceptions. Note2:
* implements the -x option for AcpiHelp.
*
******************************************************************************/
#define AH_DISPLAY_ASL_EXCEPTION_TEXT(Status, Exception) \
printf ("%.4X: %s\n", Status, Exception)
#define AH_DISPLAY_EXCEPTION(Status, Name) \
printf ("%.4X: %s\n", Status, Name)
void
AhDecodeAslException (
char *HexString)
{
UINT32 i;
UINT32 MessageId;
const char *OneException;
UINT32 Index = 1;
/*
* A null input string means to decode and display all known
* exception codes.
*/
if (!HexString)
{
printf ("All defined iASL exception codes:\n\n");
printf ("Main iASL exceptions:\n\n");
AH_DISPLAY_EXCEPTION (0,
"AE_OK (No error occurred)");
/* Display codes in each block of exception types */
for (i = 1; Index < ACPI_ARRAY_LENGTH (AslCompilerMsgs); i++, Index++)
{
AH_DISPLAY_ASL_EXCEPTION_TEXT (Index, AslCompilerMsgs[i]);
}
printf ("\niASL Table Compiler exceptions:\n\n");
Index = ASL_MSG_TABLE_COMPILER;
for (i = 0; i < ACPI_ARRAY_LENGTH (AslTableCompilerMsgs); i++, Index++)
{
AH_DISPLAY_ASL_EXCEPTION_TEXT (Index, AslTableCompilerMsgs[i]);
}
printf ("\niASL Preprocessor exceptions:\n\n");
Index = ASL_MSG_PREPROCESSOR;
for (i = 0; i < ACPI_ARRAY_LENGTH (AslPreprocessorMsgs); i++, Index++)
{
AH_DISPLAY_ASL_EXCEPTION_TEXT (Index, AslPreprocessorMsgs[i]);
}
return;
}
/* HexString is valid - convert it to a MessageId and decode it */
MessageId = strtol (HexString, NULL, 16);
OneException = AeDecodeMessageId ((UINT16) MessageId);
AH_DISPLAY_ASL_EXCEPTION_TEXT (MessageId, OneException);
}
#endif

View File

@@ -0,0 +1,435 @@
/******************************************************************************
*
* Module Name: aslmessages.h - Compiler error/warning messages
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#ifndef __ASLMESSAGES_H
#define __ASLMESSAGES_H
/* These values must match error type string tables in aslmessages.c */
typedef enum
{
ASL_OPTIMIZATION = 0,
ASL_REMARK,
ASL_WARNING,
ASL_WARNING2,
ASL_WARNING3,
ASL_ERROR,
ASL_NUM_REPORT_LEVELS
} ASL_MESSAGE_TYPES;
#define ASL_ERROR_LEVEL_LENGTH 8 /* Length of strings for types above */
void
AhDecodeAslException (
char *HexString);
/*
* Exception code blocks, 0 - 999
* Available for new exception blocks: 600 - 999
*/
#define ASL_MSG_MAIN_COMPILER 0 /* 0 - 299 */
#define ASL_MSG_MAIN_COMPILER_END 299
#define ASL_MSG_TABLE_COMPILER 300 /* 300 - 499 */
#define ASL_MSG_TABLE_COMPILER_END 499
#define ASL_MSG_PREPROCESSOR 500 /* 500 - 599 */
#define ASL_MSG_PREPROCESSOR_END 599
/*
* Values (message IDs) for all compiler messages. There are currently
* three distinct blocks of error messages (so that they can be expanded
* individually):
* Main ASL compiler
* Data Table compiler
* Preprocessor
*
* NOTE1: This list must match the tables of message strings in the file
* aslmessages.c exactly.
*
* NOTE2: With the introduction of the -vw option to disable specific
* messages, new messages should only be added to the end of these
* lists, so that values for existing messages are not disturbed.
*/
typedef enum
{
ASL_MSG_RESERVED = ASL_MSG_MAIN_COMPILER,
ASL_MSG_ALIGNMENT,
ASL_MSG_ALPHANUMERIC_STRING,
ASL_MSG_AML_NOT_IMPLEMENTED,
ASL_MSG_ARG_COUNT_HI,
ASL_MSG_ARG_COUNT_LO,
ASL_MSG_ARG_INIT,
ASL_MSG_BACKWARDS_OFFSET,
ASL_MSG_BUFFER_LENGTH,
ASL_MSG_CLOSE,
ASL_MSG_COMPILER_INTERNAL,
ASL_MSG_COMPILER_RESERVED,
ASL_MSG_CONNECTION_MISSING,
ASL_MSG_CONNECTION_INVALID,
ASL_MSG_CONSTANT_EVALUATION,
ASL_MSG_CONSTANT_FOLDED,
ASL_MSG_CORE_EXCEPTION,
ASL_MSG_DEBUG_FILE_OPEN,
ASL_MSG_DEBUG_FILENAME,
ASL_MSG_DEPENDENT_NESTING,
ASL_MSG_DMA_CHANNEL,
ASL_MSG_DMA_LIST,
ASL_MSG_DUPLICATE_CASE,
ASL_MSG_DUPLICATE_ITEM,
ASL_MSG_EARLY_EOF,
ASL_MSG_ENCODING_LENGTH,
ASL_MSG_EX_INTERRUPT_LIST,
ASL_MSG_EX_INTERRUPT_LIST_MIN,
ASL_MSG_EX_INTERRUPT_NUMBER,
ASL_MSG_FIELD_ACCESS_WIDTH,
ASL_MSG_FIELD_UNIT_ACCESS_WIDTH,
ASL_MSG_FIELD_UNIT_OFFSET,
ASL_MSG_GPE_NAME_CONFLICT,
ASL_MSG_HID_LENGTH,
ASL_MSG_HID_PREFIX,
ASL_MSG_HID_SUFFIX,
ASL_MSG_INCLUDE_FILE_OPEN,
ASL_MSG_INPUT_FILE_OPEN,
ASL_MSG_INTEGER_LENGTH,
ASL_MSG_INTEGER_OPTIMIZATION,
ASL_MSG_INTERRUPT_LIST,
ASL_MSG_INTERRUPT_NUMBER,
ASL_MSG_INVALID_ACCESS_SIZE,
ASL_MSG_INVALID_ADDR_FLAGS,
ASL_MSG_INVALID_CONSTANT_OP,
ASL_MSG_INVALID_EISAID,
ASL_MSG_INVALID_ESCAPE,
ASL_MSG_INVALID_GRAN_FIXED,
ASL_MSG_INVALID_GRANULARITY,
ASL_MSG_INVALID_LENGTH,
ASL_MSG_INVALID_LENGTH_FIXED,
ASL_MSG_INVALID_MIN_MAX,
ASL_MSG_INVALID_OPERAND,
ASL_MSG_INVALID_PERFORMANCE,
ASL_MSG_INVALID_PRIORITY,
ASL_MSG_INVALID_STRING,
ASL_MSG_INVALID_TARGET,
ASL_MSG_INVALID_TIME,
ASL_MSG_INVALID_TYPE,
ASL_MSG_INVALID_UUID,
ASL_MSG_ISA_ADDRESS,
ASL_MSG_LEADING_ASTERISK,
ASL_MSG_LIST_LENGTH_LONG,
ASL_MSG_LIST_LENGTH_SHORT,
ASL_MSG_LISTING_FILE_OPEN,
ASL_MSG_LISTING_FILENAME,
ASL_MSG_LOCAL_INIT,
ASL_MSG_LOCAL_OUTSIDE_METHOD,
ASL_MSG_LONG_LINE,
ASL_MSG_MEMORY_ALLOCATION,
ASL_MSG_MISSING_ENDDEPENDENT,
ASL_MSG_MISSING_STARTDEPENDENT,
ASL_MSG_MULTIPLE_DEFAULT,
ASL_MSG_MULTIPLE_TYPES,
ASL_MSG_NAME_EXISTS,
ASL_MSG_NAME_OPTIMIZATION,
ASL_MSG_NAMED_OBJECT_IN_WHILE,
ASL_MSG_NESTED_COMMENT,
ASL_MSG_NO_CASES,
ASL_MSG_NO_REGION,
ASL_MSG_NO_RETVAL,
ASL_MSG_NO_WHILE,
ASL_MSG_NON_ASCII,
ASL_MSG_BUFFER_FIELD_LENGTH,
ASL_MSG_NOT_EXIST,
ASL_MSG_NOT_FOUND,
ASL_MSG_NOT_METHOD,
ASL_MSG_NOT_PARAMETER,
ASL_MSG_NOT_REACHABLE,
ASL_MSG_NOT_REFERENCED,
ASL_MSG_NULL_DESCRIPTOR,
ASL_MSG_NULL_STRING,
ASL_MSG_OPEN,
ASL_MSG_OUTPUT_FILE_OPEN,
ASL_MSG_OUTPUT_FILENAME,
ASL_MSG_PACKAGE_LENGTH,
ASL_MSG_PREPROCESSOR_FILENAME,
ASL_MSG_READ,
ASL_MSG_RECURSION,
ASL_MSG_REGION_BUFFER_ACCESS,
ASL_MSG_REGION_BYTE_ACCESS,
ASL_MSG_RESERVED_ARG_COUNT_HI,
ASL_MSG_RESERVED_ARG_COUNT_LO,
ASL_MSG_RESERVED_METHOD,
ASL_MSG_RESERVED_NO_RETURN_VAL,
ASL_MSG_RESERVED_OPERAND_TYPE,
ASL_MSG_RESERVED_PACKAGE_LENGTH,
ASL_MSG_RESERVED_RETURN_VALUE,
ASL_MSG_RESERVED_USE,
ASL_MSG_RESERVED_WORD,
ASL_MSG_RESOURCE_FIELD,
ASL_MSG_RESOURCE_INDEX,
ASL_MSG_RESOURCE_LIST,
ASL_MSG_RESOURCE_SOURCE,
ASL_MSG_RESULT_NOT_USED,
ASL_MSG_RETURN_TYPES,
ASL_MSG_SCOPE_FWD_REF,
ASL_MSG_SCOPE_TYPE,
ASL_MSG_SEEK,
ASL_MSG_SERIALIZED,
ASL_MSG_SERIALIZED_REQUIRED,
ASL_MSG_SINGLE_NAME_OPTIMIZATION,
ASL_MSG_SOME_NO_RETVAL,
ASL_MSG_STRING_LENGTH,
ASL_MSG_SWITCH_TYPE,
ASL_MSG_SYNC_LEVEL,
ASL_MSG_SYNTAX,
ASL_MSG_TABLE_SIGNATURE,
ASL_MSG_TAG_LARGER,
ASL_MSG_TAG_SMALLER,
ASL_MSG_TIMEOUT,
ASL_MSG_TOO_MANY_TEMPS,
ASL_MSG_TRUNCATION,
ASL_MSG_UNKNOWN_RESERVED_NAME,
ASL_MSG_UNREACHABLE_CODE,
ASL_MSG_UNSUPPORTED,
ASL_MSG_UPPER_CASE,
ASL_MSG_VENDOR_LIST,
ASL_MSG_WRITE,
ASL_MSG_RANGE,
ASL_MSG_BUFFER_ALLOCATION,
ASL_MSG_MISSING_DEPENDENCY,
ASL_MSG_ILLEGAL_FORWARD_REF,
ASL_MSG_ILLEGAL_METHOD_REF,
ASL_MSG_LOCAL_NOT_USED,
ASL_MSG_ARG_AS_LOCAL_NOT_USED,
ASL_MSG_ARG_NOT_USED,
ASL_MSG_CONSTANT_REQUIRED,
ASL_MSG_CROSS_TABLE_SCOPE,
ASL_MSG_EXCEPTION_NOT_RECEIVED,
ASL_MSG_NULL_RESOURCE_TEMPLATE,
ASL_MSG_FOUND_HERE,
ASL_MSG_ILLEGAL_RECURSION,
ASL_MSG_DUPLICATE_INPUT_FILE,
ASL_MSG_WARNING_AS_ERROR,
ASL_MSG_OEM_TABLE_ID,
ASL_MSG_OEM_ID,
ASL_MSG_UNLOAD,
ASL_MSG_OFFSET,
ASL_MSG_LONG_SLEEP,
ASL_MSG_PREFIX_NOT_EXIST,
ASL_MSG_NAMEPATH_NOT_EXIST,
ASL_MSG_REGION_LENGTH,
ASL_MSG_TEMPORARY_OBJECT,
ASL_MSG_UNDEFINED_EXTERNAL,
ASL_MSG_BUFFER_FIELD_OVERFLOW,
ASL_MSG_INVALID_SPECIAL_NAME,
ASL_MSG_INVALID_PROCESSOR_UID,
ASL_MSG_LEGACY_PROCESSOR_OP,
ASL_MSG_NAMESTRING_LENGTH,
ASL_MSG_CASE_FOUND_HERE,
ASL_MSG_EXTERN_INVALID_RET_TYPE,
ASL_MSG_EXTERN_INVALID_PARAM_TYPE,
ASL_MSG_NAMED_OBJECT_CREATION,
ASL_MSG_ARG_COUNT_MISMATCH,
ASL_MSG_STATIC_OPREGION_IN_METHOD,
ASL_MSG_DECLARATION_TYPE_MISMATCH,
ASL_MSG_TYPE_MISMATCH_FOUND_HERE,
ASL_MSG_DUPLICATE_EXTERN_MISMATCH,
ASL_MSG_DUPLICATE_EXTERN_FOUND_HERE,
ASL_MSG_CONDREF_NEEDS_EXTERNAL_DECL,
ASL_MSG_EXTERNAL_FOUND_HERE,
ASL_MSG_LOWER_CASE_NAMESEG,
ASL_MSG_LOWER_CASE_NAMEPATH,
ASL_MSG_UUID_NOT_FOUND,
ASL_MSG_LEGACY_DDB_TYPE,
/* These messages are used by the Data Table compiler only */
ASL_MSG_BUFFER_ELEMENT = ASL_MSG_TABLE_COMPILER,
ASL_MSG_DIVIDE_BY_ZERO,
ASL_MSG_FLAG_VALUE,
ASL_MSG_INTEGER_SIZE,
ASL_MSG_INVALID_EXPRESSION,
ASL_MSG_INVALID_FIELD_NAME,
ASL_MSG_INVALID_HEX_INTEGER,
ASL_MSG_OEM_TABLE,
ASL_MSG_RESERVED_FIELD,
ASL_MSG_UNKNOWN_LABEL,
ASL_MSG_UNKNOWN_SUBTABLE,
ASL_MSG_UNKNOWN_TABLE,
ASL_MSG_ZERO_VALUE,
ASL_MSG_INVALID_LABEL,
ASL_MSG_BUFFER_LIST,
ASL_MSG_ENTRY_LIST,
ASL_MSG_UNKNOWN_FORMAT,
ASL_MSG_RESERVED_VALUE,
ASL_MSG_TWO_ZERO_VALUES,
ASL_MSG_BAD_PARSE_TREE,
/* These messages are used by the Preprocessor only */
ASL_MSG_DIRECTIVE_SYNTAX = ASL_MSG_PREPROCESSOR,
ASL_MSG_ENDIF_MISMATCH,
ASL_MSG_ERROR_DIRECTIVE,
ASL_MSG_EXISTING_NAME,
ASL_MSG_INVALID_INVOCATION,
ASL_MSG_MACRO_SYNTAX,
ASL_MSG_TOO_MANY_ARGUMENTS,
ASL_MSG_UNKNOWN_DIRECTIVE,
ASL_MSG_UNKNOWN_PRAGMA,
ASL_MSG_WARNING_DIRECTIVE,
ASL_MSG_INCLUDE_FILE
} ASL_MESSAGE_IDS;
#endif /* __ASLMESSAGES_H */

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,564 @@
/******************************************************************************
*
* Module Name: aslnamesp - Namespace output file generation
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "acnamesp.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslnamesp")
/* Local prototypes */
static ACPI_STATUS
NsDoOneNamespaceObject (
ACPI_HANDLE ObjHandle,
UINT32 Level,
void *Context,
void **ReturnValue);
static ACPI_STATUS
NsDoOnePathname (
ACPI_HANDLE ObjHandle,
UINT32 Level,
void *Context,
void **ReturnValue);
/*******************************************************************************
*
* FUNCTION: NsSetupNamespaceListing
*
* PARAMETERS: Handle - local file handle
*
* RETURN: None
*
* DESCRIPTION: Set the namespace output file to the input handle
*
******************************************************************************/
void
NsSetupNamespaceListing (
void *Handle)
{
AslGbl_NsOutputFlag = TRUE;
AslGbl_Files[ASL_FILE_NAMESPACE_OUTPUT].Handle = Handle;
}
/*******************************************************************************
*
* FUNCTION: NsDisplayNamespace
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Walk the namespace an display information about each node
* in the tree. Information is written to the optional
* namespace output file.
*
******************************************************************************/
ACPI_STATUS
NsDisplayNamespace (
void)
{
ACPI_STATUS Status;
if (!AslGbl_NsOutputFlag)
{
return (AE_OK);
}
AslGbl_NumNamespaceObjects = 0;
/* File header */
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "Contents of ACPI Namespace\n\n"
"Count Depth Name - Type\n\n");
/* Walk entire namespace from the root */
Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX, FALSE, NsDoOneNamespaceObject, NULL,
NULL, NULL);
if (ACPI_FAILURE (Status))
{
return (Status);
}
/* Print the full pathname for each namespace node in the common namespace */
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
"\nNamespace pathnames and where declared:\n"
"<NamePath, Object type, Containing file, Line number within file>\n\n");
Status = AcpiNsWalkNamespace (ACPI_TYPE_ANY, ACPI_ROOT_OBJECT,
ACPI_UINT32_MAX, FALSE, NsDoOnePathname, NULL,
NULL, NULL);
/*
* We just dumped the entire common namespace, we don't want to do it
* again for other input files.
*/
AslGbl_NsOutputFlag = FALSE;
return (Status);
}
/*******************************************************************************
*
* FUNCTION: NsDoOneNamespaceObject
*
* PARAMETERS: ACPI_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Dump a namespace object to the namespace output file.
* Called during the walk of the namespace to dump all objects.
*
******************************************************************************/
static ACPI_STATUS
NsDoOneNamespaceObject (
ACPI_HANDLE ObjHandle,
UINT32 Level,
void *Context,
void **ReturnValue)
{
ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_PARSE_OBJECT *Op;
AslGbl_NumNamespaceObjects++;
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "%5u [%u] %*s %4.4s - %s",
AslGbl_NumNamespaceObjects, Level, (Level * 3), " ",
&Node->Name.Ascii[0], AcpiUtGetTypeName (Node->Type));
Op = Node->Op;
ObjDesc = ACPI_CAST_PTR (ACPI_OPERAND_OBJECT, Node->Object);
if (!Op)
{
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\n");
return (AE_OK);
}
if ((ObjDesc) &&
(ACPI_GET_DESCRIPTOR_TYPE (ObjDesc) == ACPI_DESC_TYPE_OPERAND))
{
switch (Node->Type)
{
case ACPI_TYPE_INTEGER:
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
" [Initial Value 0x%8.8X%8.8X]",
ACPI_FORMAT_UINT64 (ObjDesc->Integer.Value));
break;
case ACPI_TYPE_STRING:
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
" [Initial Value \"%s\"]",
ObjDesc->String.Pointer);
break;
default:
/* Nothing to do for other types */
break;
}
}
else
{
switch (Node->Type)
{
case ACPI_TYPE_INTEGER:
if (Op->Asl.ParseOpcode == PARSEOP_NAME)
{
Op = Op->Asl.Child;
}
if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
(Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
{
Op = Op->Asl.Next;
}
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
" [Initial Value 0x%8.8X%8.8X]",
ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer));
break;
case ACPI_TYPE_STRING:
if (Op->Asl.ParseOpcode == PARSEOP_NAME)
{
Op = Op->Asl.Child;
}
if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
(Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
{
Op = Op->Asl.Next;
}
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
" [Initial Value \"%s\"]",
Op->Asl.Value.String);
break;
case ACPI_TYPE_LOCAL_REGION_FIELD:
if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
(Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
{
Op = Op->Asl.Child;
}
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
" [Offset 0x%04X Length 0x%04X bits]",
Op->Asl.Parent->Asl.ExtraValue, (UINT32) Op->Asl.Value.Integer);
break;
case ACPI_TYPE_BUFFER_FIELD:
switch (Op->Asl.ParseOpcode)
{
case PARSEOP_CREATEBYTEFIELD:
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [BYTE ( 8 bit)]");
break;
case PARSEOP_CREATEDWORDFIELD:
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [DWORD (32 bit)]");
break;
case PARSEOP_CREATEQWORDFIELD:
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [QWORD (64 bit)]");
break;
case PARSEOP_CREATEWORDFIELD:
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [WORD (16 bit)]");
break;
case PARSEOP_CREATEBITFIELD:
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [BIT ( 1 bit)]");
break;
case PARSEOP_CREATEFIELD:
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, " [Arbitrary Bit Field]");
break;
default:
break;
}
break;
case ACPI_TYPE_PACKAGE:
if (Op->Asl.ParseOpcode == PARSEOP_NAME)
{
Op = Op->Asl.Child;
}
if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
(Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
{
Op = Op->Asl.Next;
}
Op = Op->Asl.Child;
if ((Op->Asl.ParseOpcode == PARSEOP_BYTECONST) ||
(Op->Asl.ParseOpcode == PARSEOP_RAW_DATA))
{
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
" [Initial Length 0x%.2X elements]",
(UINT32) Op->Asl.Value.Integer);
}
break;
case ACPI_TYPE_BUFFER:
if (Op->Asl.ParseOpcode == PARSEOP_NAME)
{
Op = Op->Asl.Child;
}
if ((Op->Asl.ParseOpcode == PARSEOP_NAMESEG) ||
(Op->Asl.ParseOpcode == PARSEOP_NAMESTRING))
{
Op = Op->Asl.Next;
}
Op = Op->Asl.Child;
if (Op && (Op->Asl.ParseOpcode == PARSEOP_INTEGER))
{
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
" [Initial Length 0x%.2X bytes]",
(UINT32) Op->Asl.Value.Integer);
}
break;
case ACPI_TYPE_METHOD:
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
" [Code Length 0x%.4X bytes]",
Op->Asl.AmlSubtreeLength);
break;
case ACPI_TYPE_LOCAL_RESOURCE:
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
" [Desc Offset 0x%.4X Bytes]", Node->Value);
break;
case ACPI_TYPE_LOCAL_RESOURCE_FIELD:
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
" [Field Offset 0x%.4X Bits 0x%.4X Bytes] ",
Node->Value, Node->Value / 8);
if (Node->Flags & ANOBJ_IS_REFERENCED)
{
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
"Referenced");
}
else
{
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT,
"Name not referenced");
}
break;
default:
/* Nothing to do for other types */
break;
}
}
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "\n");
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: NsDoOnePathname
*
* PARAMETERS: ACPI_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Print the full pathname and additional info for a namespace
* node.
*
******************************************************************************/
static ACPI_STATUS
NsDoOnePathname (
ACPI_HANDLE ObjHandle,
UINT32 Level,
void *Context,
void **ReturnValue)
{
ACPI_NAMESPACE_NODE *Node = (ACPI_NAMESPACE_NODE *) ObjHandle;
ACPI_STATUS Status;
ACPI_BUFFER TargetPath;
/* Ignore predefined namespace nodes and External declarations */
if (!Node->Op || (Node->Flags & ANOBJ_IS_EXTERNAL))
{
return (AE_OK);
}
TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
Status = AcpiNsHandleToPathname (Node, &TargetPath, FALSE);
if (ACPI_FAILURE (Status))
{
return (Status);
}
/*
* Print the full pathname (and other information)
* for each namespace node in the common namespace
*/
FlPrintFile (ASL_FILE_NAMESPACE_OUTPUT, "%-41s %-12s %s, %u\n",
ACPI_CAST_PTR (char, TargetPath.Pointer),
AcpiUtGetTypeName (Node->Type),
Node->Op->Asl.Filename, Node->Op->Asl.LogicalLineNumber);
ACPI_FREE (TargetPath.Pointer);
return (AE_OK);
}

View File

@@ -0,0 +1,579 @@
/******************************************************************************
*
* Module Name: asloffset - Generate a C "offset table" for BIOS use.
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "amlcode.h"
#include "acnamesp.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("asloffset")
/* Local prototypes */
static void
LsEmitOffsetTableEntry (
UINT32 FileId,
ACPI_NAMESPACE_NODE *Node,
UINT32 NamepathOffset,
UINT32 Offset,
char *OpName,
UINT64 Value,
UINT8 AmlOpcode,
UINT16 ParentOpcode);
/*******************************************************************************
*
* FUNCTION: LsAmlOffsetWalk
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Process one node during a offset table file generation.
*
* Three types of objects are currently emitted to the offset table:
* 1) Tagged (named) resource descriptors
* 2) Named integer objects with constant integer values
* 3) Named package objects
* 4) Operation Regions that have constant Offset (address) parameters
* 5) Control methods
*
* The offset table allows the BIOS to dynamically update the values of these
* objects at boot time.
*
******************************************************************************/
ACPI_STATUS
LsAmlOffsetWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
UINT32 FileId = (UINT32) ACPI_TO_INTEGER (Context);
ACPI_NAMESPACE_NODE *Node;
UINT32 Length;
UINT32 NamepathOffset;
UINT32 DataOffset;
ACPI_PARSE_OBJECT *NextOp;
/* Ignore actual data blocks for resource descriptors */
if (Op->Asl.CompileFlags & OP_IS_RESOURCE_DATA)
{
return (AE_OK); /* Do NOT update the global AML offset */
}
/* We are only interested in named objects (have a namespace node) */
Node = Op->Asl.Node;
if (!Node)
{
AslGbl_CurrentAmlOffset += Op->Asl.FinalAmlLength;
return (AE_OK);
}
/* Named resource descriptor (has a descriptor tag) */
if ((Node->Type == ACPI_TYPE_LOCAL_RESOURCE) &&
(Op->Asl.CompileFlags & OP_IS_RESOURCE_DESC))
{
LsEmitOffsetTableEntry (FileId, Node, 0, AslGbl_CurrentAmlOffset,
Op->Asl.ParseOpName, 0, Op->Asl.Extra, AML_BUFFER_OP);
AslGbl_CurrentAmlOffset += Op->Asl.FinalAmlLength;
return (AE_OK);
}
switch (Op->Asl.AmlOpcode)
{
case AML_NAME_OP:
/* Named object -- Name (NameString, DataRefObject) */
if (!Op->Asl.Child)
{
FlPrintFile (FileId, "%s NO CHILD!\n", AslGbl_MsgBuffer);
return (AE_OK);
}
Length = Op->Asl.FinalAmlLength;
/* Get to the NameSeg/NamePath Op (and length of the name) */
Op = Op->Asl.Child;
/* Get offset of last nameseg and the actual data */
NamepathOffset = AslGbl_CurrentAmlOffset + Length +
(Op->Asl.FinalAmlLength - ACPI_NAMESEG_SIZE);
DataOffset = AslGbl_CurrentAmlOffset + Length +
Op->Asl.FinalAmlLength;
/* Get actual value associated with the name */
Op = Op->Asl.Next;
switch (Op->Asl.AmlOpcode)
{
case AML_BYTE_OP:
case AML_WORD_OP:
case AML_DWORD_OP:
case AML_QWORD_OP:
/* The +1 is to handle the integer size prefix (opcode) */
LsEmitOffsetTableEntry (FileId, Node, NamepathOffset, (DataOffset + 1),
Op->Asl.ParseOpName, Op->Asl.Value.Integer,
(UINT8) Op->Asl.AmlOpcode, AML_NAME_OP);
break;
case AML_ONE_OP:
case AML_ONES_OP:
case AML_ZERO_OP:
/* For these, offset will point to the opcode */
LsEmitOffsetTableEntry (FileId, Node, NamepathOffset, DataOffset,
Op->Asl.ParseOpName, Op->Asl.Value.Integer,
(UINT8) Op->Asl.AmlOpcode, AML_NAME_OP);
break;
case AML_PACKAGE_OP:
case AML_VARIABLE_PACKAGE_OP:
/* Get the package element count */
NextOp = Op->Asl.Child;
LsEmitOffsetTableEntry (FileId, Node, NamepathOffset, DataOffset,
Op->Asl.ParseOpName, NextOp->Asl.Value.Integer,
(UINT8) Op->Asl.AmlOpcode, AML_NAME_OP);
break;
default:
break;
}
AslGbl_CurrentAmlOffset += Length;
return (AE_OK);
case AML_REGION_OP:
/* OperationRegion (NameString, RegionSpace, RegionOffset, RegionLength) */
Length = Op->Asl.FinalAmlLength;
/* Get the name/namepath node */
NextOp = Op->Asl.Child;
/* Get offset of last nameseg and the actual data */
NamepathOffset = AslGbl_CurrentAmlOffset + Length +
(NextOp->Asl.FinalAmlLength - ACPI_NAMESEG_SIZE);
DataOffset = AslGbl_CurrentAmlOffset + Length +
(NextOp->Asl.FinalAmlLength + 1);
/* Get the SpaceId node, then the Offset (address) node */
NextOp = NextOp->Asl.Next;
NextOp = NextOp->Asl.Next;
switch (NextOp->Asl.AmlOpcode)
{
/*
* We are only interested in integer constants that can be changed
* at boot time. Note, the One/Ones/Zero opcodes are considered
* non-changeable, so we ignore them here.
*/
case AML_BYTE_OP:
case AML_WORD_OP:
case AML_DWORD_OP:
case AML_QWORD_OP:
LsEmitOffsetTableEntry (FileId, Node, NamepathOffset, (DataOffset + 1),
Op->Asl.ParseOpName, NextOp->Asl.Value.Integer,
(UINT8) NextOp->Asl.AmlOpcode, AML_REGION_OP);
AslGbl_CurrentAmlOffset += Length;
return (AE_OK);
default:
break;
}
break;
case AML_METHOD_OP:
/* Method (Namepath, ...) */
Length = Op->Asl.FinalAmlLength;
/* Get the NameSeg/NamePath Op */
NextOp = Op->Asl.Child;
/* Get offset of last nameseg and the actual data (flags byte) */
NamepathOffset = AslGbl_CurrentAmlOffset + Length +
(NextOp->Asl.FinalAmlLength - ACPI_NAMESEG_SIZE);
DataOffset = AslGbl_CurrentAmlOffset + Length +
NextOp->Asl.FinalAmlLength;
/* Get the flags byte Op */
NextOp = NextOp->Asl.Next;
LsEmitOffsetTableEntry (FileId, Node, NamepathOffset, DataOffset,
Op->Asl.ParseOpName, NextOp->Asl.Value.Integer,
(UINT8) Op->Asl.AmlOpcode, AML_METHOD_OP);
break;
case AML_PROCESSOR_OP:
/* Processor (Namepath, ProcessorId, Address, Length) */
Length = Op->Asl.FinalAmlLength;
NextOp = Op->Asl.Child; /* Get Namepath */
/* Get offset of last nameseg and the actual data (PBlock address) */
NamepathOffset = AslGbl_CurrentAmlOffset + Length +
(NextOp->Asl.FinalAmlLength - ACPI_NAMESEG_SIZE);
DataOffset = AslGbl_CurrentAmlOffset + Length +
(NextOp->Asl.FinalAmlLength + 1);
NextOp = NextOp->Asl.Next; /* Get ProcessorID (BYTE) */
NextOp = NextOp->Asl.Next; /* Get Address (DWORD) */
LsEmitOffsetTableEntry (FileId, Node, NamepathOffset, DataOffset,
Op->Asl.ParseOpName, NextOp->Asl.Value.Integer,
(UINT8) AML_DWORD_OP, AML_PROCESSOR_OP);
break;
case AML_DEVICE_OP:
case AML_SCOPE_OP:
case AML_THERMAL_ZONE_OP:
/* Device/Scope/ThermalZone (Namepath) */
Length = Op->Asl.FinalAmlLength;
NextOp = Op->Asl.Child; /* Get Namepath */
/* Get offset of last nameseg */
NamepathOffset = AslGbl_CurrentAmlOffset + Length +
(NextOp->Asl.FinalAmlLength - ACPI_NAMESEG_SIZE);
LsEmitOffsetTableEntry (FileId, Node, NamepathOffset, 0,
Op->Asl.ParseOpName, 0, (UINT8) 0, Op->Asl.AmlOpcode);
break;
default:
break;
}
AslGbl_CurrentAmlOffset += Op->Asl.FinalAmlLength;
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: LsEmitOffsetTableEntry
*
* PARAMETERS: FileId - ID of current listing file
* Node - Namespace node associated with the name
* Offset - Offset of the value within the AML table
* OpName - Name of the AML opcode
* Value - Current value of the AML field
* AmlOpcode - Opcode associated with the field
* ObjectType - ACPI object type
*
* RETURN: None
*
* DESCRIPTION: Emit a line of the offset table (-so option)
*
******************************************************************************/
static void
LsEmitOffsetTableEntry (
UINT32 FileId,
ACPI_NAMESPACE_NODE *Node,
UINT32 NamepathOffset,
UINT32 Offset,
char *OpName,
UINT64 Value,
UINT8 AmlOpcode,
UINT16 ParentOpcode)
{
ACPI_BUFFER TargetPath;
ACPI_STATUS Status;
/* Get the full pathname to the namespace node */
TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
Status = AcpiNsHandleToPathname (Node, &TargetPath, FALSE);
if (ACPI_FAILURE (Status))
{
return;
}
/* [1] - Skip the opening backslash for the path */
strcpy (AslGbl_MsgBuffer, "\"");
strcat (AslGbl_MsgBuffer, &((char *) TargetPath.Pointer)[1]);
strcat (AslGbl_MsgBuffer, "\",");
ACPI_FREE (TargetPath.Pointer);
/*
* Max offset is 4G, constrained by 32-bit ACPI table length.
* Max Length for Integers is 8 bytes.
*/
FlPrintFile (FileId,
" {%-29s 0x%4.4X, 0x%8.8X, 0x%2.2X, 0x%8.8X, 0x%8.8X%8.8X}, /* %s */\n",
AslGbl_MsgBuffer, ParentOpcode, NamepathOffset, AmlOpcode,
Offset, ACPI_FORMAT_UINT64 (Value), OpName);
}
/*******************************************************************************
*
* FUNCTION: LsDoOffsetTableHeader, LsDoOffsetTableFooter
*
* PARAMETERS: FileId - ID of current listing file
*
* RETURN: None
*
* DESCRIPTION: Header and footer for the offset table file.
*
******************************************************************************/
void
LsDoOffsetTableHeader (
UINT32 FileId)
{
FlPrintFile (FileId,
"#ifndef __AML_OFFSET_TABLE_H\n"
"#define __AML_OFFSET_TABLE_H\n\n");
FlPrintFile (FileId, "typedef struct {\n"
" char *Pathname; /* Full pathname (from root) to the object */\n"
" unsigned short ParentOpcode; /* AML opcode for the parent object */\n"
" unsigned long NamesegOffset; /* Offset of last nameseg in the parent namepath */\n"
" unsigned char Opcode; /* AML opcode for the data */\n"
" unsigned long Offset; /* Offset for the data */\n"
" unsigned long long Value; /* Original value of the data (as applicable) */\n"
"} AML_OFFSET_TABLE_ENTRY;\n\n");
FlPrintFile (FileId,
"#endif /* __AML_OFFSET_TABLE_H */\n\n");
FlPrintFile (FileId,
"/*\n"
" * Information specific to the supported object types:\n"
" *\n"
" * Integers:\n"
" * Opcode is the integer prefix, indicates length of the data\n"
" * (One of: BYTE, WORD, DWORD, QWORD, ZERO, ONE, ONES)\n"
" * Offset points to the actual integer data\n"
" * Value is the existing value in the AML\n"
" *\n"
" * Packages:\n"
" * Opcode is the package or var_package opcode\n"
" * Offset points to the package opcode\n"
" * Value is the package element count\n"
" *\n"
" * Operation Regions:\n"
" * Opcode is the address integer prefix, indicates length of the data\n"
" * Offset points to the region address\n"
" * Value is the existing address value in the AML\n"
" *\n"
" * Control Methods:\n"
" * Offset points to the method flags byte\n"
" * Value is the existing flags value in the AML\n"
" *\n"
" * Processors:\n"
" * Offset points to the first byte of the PBlock Address\n"
" *\n"
" * Resource Descriptors:\n"
" * Opcode is the descriptor type\n"
" * Offset points to the start of the descriptor\n"
" *\n"
" * Scopes/Devices/ThermalZones:\n"
" * Nameseg offset only\n"
" */\n");
FlPrintFile (FileId,
"AML_OFFSET_TABLE_ENTRY %s_%s_OffsetTable[] =\n{\n",
AslGbl_TableSignature, AslGbl_TableId);
}
void
LsDoOffsetTableFooter (
UINT32 FileId)
{
FlPrintFile (FileId,
" {NULL,0,0,0,0,0} /* Table terminator */\n};\n\n");
AslGbl_CurrentAmlOffset = 0;
}

View File

@@ -0,0 +1,952 @@
/******************************************************************************
*
* Module Name: aslopcode - AML opcode generation
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "amlcode.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslopcodes")
/* Local prototypes */
static void
OpcDoAccessAs (
ACPI_PARSE_OBJECT *Op);
static void
OpcDoConnection (
ACPI_PARSE_OBJECT *Op);
static void
OpcDoUnicode (
ACPI_PARSE_OBJECT *Op);
static void
OpcDoEisaId (
ACPI_PARSE_OBJECT *Op);
static void
OpcDoUuId (
ACPI_PARSE_OBJECT *Op);
/*******************************************************************************
*
* FUNCTION: OpcAmlOpcodeUpdateWalk
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Opcode update walk, ascending callback
*
******************************************************************************/
ACPI_STATUS
OpcAmlOpcodeUpdateWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
/*
* Handle the Package() case where the actual opcode cannot be determined
* until the PackageLength operand has been folded and minimized.
* (PackageOp versus VarPackageOp)
*
* This is (as of ACPI 3.0) the only case where the AML opcode can change
* based upon the value of a parameter.
*
* The parser always inserts a VarPackage opcode, which can possibly be
* optimized to a Package opcode.
*/
if (Op->Asl.ParseOpcode == PARSEOP_VAR_PACKAGE)
{
OpnDoPackage (Op);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: OpcAmlOpcodeWalk
*
* PARAMETERS: ASL_WALK_CALLBACK
*
* RETURN: Status
*
* DESCRIPTION: Parse tree walk to generate both the AML opcodes and the AML
* operands.
*
******************************************************************************/
ACPI_STATUS
OpcAmlOpcodeWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
AslGbl_TotalParseNodes++;
OpcGenerateAmlOpcode (Op);
OpnGenerateAmlOperands (Op);
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: OpcGetIntegerWidth
*
* PARAMETERS: Op - DEFINITION BLOCK op
*
* RETURN: none
*
* DESCRIPTION: Extract integer width from the table revision
*
******************************************************************************/
void
OpcGetIntegerWidth (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *Child;
if (!Op)
{
return;
}
if (AslGbl_RevisionOverride)
{
AcpiUtSetIntegerWidth (AslGbl_RevisionOverride);
}
else
{
Child = Op->Asl.Child;
Child = Child->Asl.Next;
Child = Child->Asl.Next;
/* Use the revision to set the integer width */
AcpiUtSetIntegerWidth ((UINT8) Child->Asl.Value.Integer);
}
}
/*******************************************************************************
*
* FUNCTION: OpcSetOptimalIntegerSize
*
* PARAMETERS: Op - A parse tree node
*
* RETURN: Integer width, in bytes. Also sets the node AML opcode to the
* optimal integer AML prefix opcode.
*
* DESCRIPTION: Determine the optimal AML encoding of an integer. All leading
* zeros can be truncated to squeeze the integer into the
* minimal number of AML bytes.
*
******************************************************************************/
UINT32
OpcSetOptimalIntegerSize (
ACPI_PARSE_OBJECT *Op)
{
#if 0
/*
* TBD: - we don't want to optimize integers in the block header, but the
* code below does not work correctly.
*/
if (Op->Asl.Parent &&
Op->Asl.Parent->Asl.Parent &&
(Op->Asl.Parent->Asl.Parent->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK))
{
return (0);
}
#endif
/*
* Check for the special AML integers first - Zero, One, Ones.
* These are single-byte opcodes that are the smallest possible
* representation of an integer.
*
* This optimization is optional.
*/
if (AslGbl_IntegerOptimizationFlag)
{
switch (Op->Asl.Value.Integer)
{
case 0:
Op->Asl.AmlOpcode = AML_ZERO_OP;
AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION,
Op, "Zero");
return (1);
case 1:
Op->Asl.AmlOpcode = AML_ONE_OP;
AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION,
Op, "One");
return (1);
case ACPI_UINT32_MAX:
/* Check for table integer width (32 or 64) */
if (AcpiGbl_IntegerByteWidth == 4)
{
Op->Asl.AmlOpcode = AML_ONES_OP;
AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION,
Op, "Ones");
return (1);
}
break;
case ACPI_UINT64_MAX:
/* Check for table integer width (32 or 64) */
if (AcpiGbl_IntegerByteWidth == 8)
{
Op->Asl.AmlOpcode = AML_ONES_OP;
AslError (ASL_OPTIMIZATION, ASL_MSG_INTEGER_OPTIMIZATION,
Op, "Ones");
return (1);
}
break;
default:
break;
}
}
/* Find the best fit using the various AML integer prefixes */
if (Op->Asl.Value.Integer <= ACPI_UINT8_MAX)
{
Op->Asl.AmlOpcode = AML_BYTE_OP;
return (1);
}
if (Op->Asl.Value.Integer <= ACPI_UINT16_MAX)
{
Op->Asl.AmlOpcode = AML_WORD_OP;
return (2);
}
if (Op->Asl.Value.Integer <= ACPI_UINT32_MAX)
{
Op->Asl.AmlOpcode = AML_DWORD_OP;
return (4);
}
else /* 64-bit integer */
{
if (AcpiGbl_IntegerByteWidth == 4)
{
AslError (ASL_WARNING, ASL_MSG_INTEGER_LENGTH,
Op, NULL);
if (!AslGbl_IgnoreErrors)
{
/* Truncate the integer to 32-bit */
Op->Asl.Value.Integer &= ACPI_UINT32_MAX;
/* Now set the optimal integer size */
return (OpcSetOptimalIntegerSize (Op));
}
}
Op->Asl.AmlOpcode = AML_QWORD_OP;
return (8);
}
}
/*******************************************************************************
*
* FUNCTION: OpcDoAccessAs
*
* PARAMETERS: Op - Parse node
*
* RETURN: None
*
* DESCRIPTION: Implement the ACCESS_AS ASL keyword.
*
******************************************************************************/
static void
OpcDoAccessAs (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *TypeOp;
ACPI_PARSE_OBJECT *AttribOp;
ACPI_PARSE_OBJECT *LengthOp;
UINT8 Attribute;
Op->Asl.AmlOpcodeLength = 1;
TypeOp = Op->Asl.Child;
/* First child is the access type */
TypeOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
TypeOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
/* Second child is the optional access attribute */
AttribOp = TypeOp->Asl.Next;
if (AttribOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
{
AttribOp->Asl.Value.Integer = 0;
}
AttribOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
AttribOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
/* Only a few AccessAttributes support AccessLength */
Attribute = (UINT8) AttribOp->Asl.Value.Integer;
if ((Attribute != AML_FIELD_ATTRIB_BYTES) &&
(Attribute != AML_FIELD_ATTRIB_RAW_BYTES) &&
(Attribute != AML_FIELD_ATTRIB_RAW_PROCESS_BYTES))
{
return;
}
Op->Asl.AmlOpcode = AML_FIELD_EXT_ACCESS_OP;
/*
* Child of Attributes is the AccessLength (required for Multibyte,
* RawBytes, RawProcess.)
*/
LengthOp = AttribOp->Asl.Child;
if (!LengthOp)
{
return;
}
/* TBD: probably can remove */
if (LengthOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
{
LengthOp->Asl.Value.Integer = 16;
}
LengthOp->Asl.AmlOpcode = AML_RAW_DATA_BYTE;
LengthOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
}
/*******************************************************************************
*
* FUNCTION: OpcDoConnection
*
* PARAMETERS: Op - Parse node
*
* RETURN: None
*
* DESCRIPTION: Implement the Connection ASL keyword.
*
******************************************************************************/
static void
OpcDoConnection (
ACPI_PARSE_OBJECT *Op)
{
ASL_RESOURCE_NODE *Rnode;
ACPI_PARSE_OBJECT *BufferOp;
ACPI_PARSE_OBJECT *BufferLengthOp;
ACPI_PARSE_OBJECT *BufferDataOp;
ASL_RESOURCE_INFO Info;
UINT8 State;
Op->Asl.AmlOpcodeLength = 1;
if (Op->Asl.Child->Asl.AmlOpcode == AML_INT_NAMEPATH_OP)
{
return;
}
BufferOp = Op->Asl.Child;
BufferLengthOp = BufferOp->Asl.Child;
BufferDataOp = BufferLengthOp->Asl.Next;
Info.DescriptorTypeOp = BufferDataOp->Asl.Next;
Info.CurrentByteOffset = 0;
State = ACPI_RSTATE_NORMAL;
Rnode = RsDoOneResourceDescriptor (&Info, &State);
if (!Rnode)
{
return; /* error */
}
/*
* Transform the nodes into the following
*
* Op -> AML_BUFFER_OP
* First Child -> BufferLength
* Second Child -> Descriptor Buffer (raw byte data)
*/
BufferOp->Asl.ParseOpcode = PARSEOP_BUFFER;
BufferOp->Asl.AmlOpcode = AML_BUFFER_OP;
BufferOp->Asl.CompileFlags = OP_AML_PACKAGE | OP_IS_RESOURCE_DESC;
UtSetParseOpName (BufferOp);
BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER;
BufferLengthOp->Asl.Value.Integer = Rnode->BufferLength;
(void) OpcSetOptimalIntegerSize (BufferLengthOp);
UtSetParseOpName (BufferLengthOp);
BufferDataOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
BufferDataOp->Asl.AmlOpcode = AML_RAW_DATA_CHAIN;
BufferDataOp->Asl.AmlOpcodeLength = 0;
BufferDataOp->Asl.AmlLength = Rnode->BufferLength;
BufferDataOp->Asl.Value.Buffer = (UINT8 *) Rnode;
UtSetParseOpName (BufferDataOp);
}
/*******************************************************************************
*
* FUNCTION: OpcDoUnicode
*
* PARAMETERS: Op - Parse node
*
* RETURN: None
*
* DESCRIPTION: Implement the UNICODE ASL "macro". Convert the input string
* to a unicode buffer. There is no Unicode AML opcode.
*
* Note: The Unicode string is 16 bits per character, no leading signature,
* with a 16-bit terminating NULL.
*
******************************************************************************/
static void
OpcDoUnicode (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *InitializerOp;
UINT32 Length;
UINT32 Count;
UINT32 i;
UINT8 *AsciiString;
UINT16 *UnicodeString;
ACPI_PARSE_OBJECT *BufferLengthOp;
/* Change op into a buffer object */
Op->Asl.CompileFlags &= ~OP_COMPILE_TIME_CONST;
Op->Asl.ParseOpcode = PARSEOP_BUFFER;
UtSetParseOpName (Op);
/* Buffer Length is first, followed by the string */
BufferLengthOp = Op->Asl.Child;
InitializerOp = BufferLengthOp->Asl.Next;
AsciiString = (UINT8 *) InitializerOp->Asl.Value.String;
/* Create a new buffer for the Unicode string */
Count = strlen (InitializerOp->Asl.Value.String) + 1;
Length = Count * sizeof (UINT16);
UnicodeString = UtLocalCalloc (Length);
/* Convert to Unicode string (including null terminator) */
for (i = 0; i < Count; i++)
{
UnicodeString[i] = (UINT16) AsciiString[i];
}
/*
* Just set the buffer size node to be the buffer length, regardless
* of whether it was previously an integer or a default_arg placeholder
*/
BufferLengthOp->Asl.ParseOpcode = PARSEOP_INTEGER;
BufferLengthOp->Asl.AmlOpcode = AML_DWORD_OP;
BufferLengthOp->Asl.Value.Integer = Length;
UtSetParseOpName (BufferLengthOp);
(void) OpcSetOptimalIntegerSize (BufferLengthOp);
/* The Unicode string is a raw data buffer */
InitializerOp->Asl.Value.Buffer = (UINT8 *) UnicodeString;
InitializerOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
InitializerOp->Asl.AmlLength = Length;
InitializerOp->Asl.ParseOpcode = PARSEOP_RAW_DATA;
InitializerOp->Asl.Child = NULL;
UtSetParseOpName (InitializerOp);
}
/*******************************************************************************
*
* FUNCTION: OpcDoEisaId
*
* PARAMETERS: Op - Parse node
*
* RETURN: None
*
* DESCRIPTION: Convert a string EISA ID to numeric representation. See the
* Pnp BIOS Specification for details. Here is an excerpt:
*
* A seven character ASCII representation of the product
* identifier compressed into a 32-bit identifier. The seven
* character ID consists of a three character manufacturer code,
* a three character hexadecimal product identifier, and a one
* character hexadecimal revision number. The manufacturer code
* is a 3 uppercase character code that is compressed into 3 5-bit
* values as follows:
* 1) Find hex ASCII value for each letter
* 2) Subtract 40h from each ASCII value
* 3) Retain 5 least significant bits for each letter by
* discarding upper 3 bits because they are always 0.
* 4) Compressed code = concatenate 0 and the 3 5-bit values
*
* The format of the compressed product identifier is as follows:
* Byte 0: Bit 7 - Reserved (0)
* Bits 6-2: - 1st character of compressed mfg code
* Bits 1-0 - Upper 2 bits of 2nd character of mfg code
* Byte 1: Bits 7-5 - Lower 3 bits of 2nd character of mfg code
* Bits 4-0 - 3rd character of mfg code
* Byte 2: Bits 7-4 - 1st hex digit of product number
* Bits 3-0 - 2nd hex digit of product number
* Byte 3: Bits 7-4 - 3rd hex digit of product number
* Bits 3-0 - Hex digit of the revision number
*
******************************************************************************/
static void
OpcDoEisaId (
ACPI_PARSE_OBJECT *Op)
{
UINT32 EisaId = 0;
UINT32 BigEndianId;
char *InString;
ACPI_STATUS Status = AE_OK;
UINT32 i;
InString = (char *) Op->Asl.Value.String;
/*
* The EISAID string must be exactly 7 characters and of the form
* "UUUXXXX" -- 3 uppercase letters and 4 hex digits (e.g., "PNP0001")
*/
if (strlen (InString) != 7)
{
Status = AE_BAD_PARAMETER;
}
else
{
/* Check all 7 characters for correct format */
for (i = 0; i < 7; i++)
{
/* First 3 characters must be uppercase letters */
if (i < 3)
{
if (!isupper ((int) InString[i]))
{
Status = AE_BAD_PARAMETER;
}
}
/* Last 4 characters must be hex digits */
else if (!isxdigit ((int) InString[i]))
{
Status = AE_BAD_PARAMETER;
}
}
}
if (ACPI_FAILURE (Status))
{
AslError (ASL_ERROR, ASL_MSG_INVALID_EISAID, Op, Op->Asl.Value.String);
}
else
{
/* Create ID big-endian first (bits are contiguous) */
BigEndianId =
(UINT32) ((UINT8) (InString[0] - 0x40)) << 26 |
(UINT32) ((UINT8) (InString[1] - 0x40)) << 21 |
(UINT32) ((UINT8) (InString[2] - 0x40)) << 16 |
(AcpiUtAsciiCharToHex (InString[3])) << 12 |
(AcpiUtAsciiCharToHex (InString[4])) << 8 |
(AcpiUtAsciiCharToHex (InString[5])) << 4 |
AcpiUtAsciiCharToHex (InString[6]);
/* Swap to little-endian to get final ID (see function header) */
EisaId = AcpiUtDwordByteSwap (BigEndianId);
}
/*
* Morph the Op into an integer, regardless of whether there
* was an error in the EISAID string
*/
Op->Asl.Value.Integer = EisaId;
Op->Asl.CompileFlags &= ~OP_COMPILE_TIME_CONST;
Op->Asl.ParseOpcode = PARSEOP_INTEGER;
(void) OpcSetOptimalIntegerSize (Op);
/* Op is now an integer */
UtSetParseOpName (Op);
}
/*******************************************************************************
*
* FUNCTION: OpcDoUuId
*
* PARAMETERS: Op - Parse node
*
* RETURN: None
*
* DESCRIPTION: Convert UUID string to 16-byte buffer
*
******************************************************************************/
static void
OpcDoUuId (
ACPI_PARSE_OBJECT *Op)
{
char *InString;
UINT8 *Buffer;
ACPI_STATUS Status = AE_OK;
ACPI_PARSE_OBJECT *NewOp;
InString = ACPI_CAST_PTR (char, Op->Asl.Value.String);
Buffer = UtLocalCalloc (16);
Status = AuValidateUuid (InString);
if (ACPI_FAILURE (Status))
{
AslError (ASL_ERROR, ASL_MSG_INVALID_UUID, Op, Op->Asl.Value.String);
}
else
{
/* Convert UUID string to a buffer, check for a known UUID */
AcpiUtConvertStringToUuid (InString, Buffer);
if (!AcpiAhMatchUuid (Buffer))
{
AslError (ASL_REMARK, ASL_MSG_UUID_NOT_FOUND, Op, NULL);
}
}
/* Change Op to a Buffer */
Op->Asl.ParseOpcode = PARSEOP_BUFFER;
Op->Common.AmlOpcode = AML_BUFFER_OP;
/* Disable further optimization */
Op->Asl.CompileFlags &= ~OP_COMPILE_TIME_CONST;
UtSetParseOpName (Op);
/* Child node is the buffer length */
NewOp = TrAllocateOp (PARSEOP_INTEGER);
NewOp->Asl.AmlOpcode = AML_BYTE_OP;
NewOp->Asl.Value.Integer = 16;
NewOp->Asl.Parent = Op;
Op->Asl.Child = NewOp;
Op = NewOp;
/* Peer to the child is the raw buffer data */
NewOp = TrAllocateOp (PARSEOP_RAW_DATA);
NewOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
NewOp->Asl.AmlLength = 16;
NewOp->Asl.Value.String = ACPI_CAST_PTR (char, Buffer);
NewOp->Asl.Parent = Op->Asl.Parent;
Op->Asl.Next = NewOp;
}
/*******************************************************************************
*
* FUNCTION: OpcGenerateAmlOpcode
*
* PARAMETERS: Op - Parse node
*
* RETURN: None
*
* DESCRIPTION: Generate the AML opcode associated with the node and its
* parse (lex/flex) keyword opcode. Essentially implements
* a mapping between the parse opcodes and the actual AML opcodes.
*
******************************************************************************/
void
OpcGenerateAmlOpcode (
ACPI_PARSE_OBJECT *Op)
{
UINT16 Index;
Index = (UINT16) (Op->Asl.ParseOpcode - ASL_PARSE_OPCODE_BASE);
Op->Asl.AmlOpcode = AslKeywordMapping[Index].AmlOpcode;
Op->Asl.AcpiBtype = AslKeywordMapping[Index].AcpiBtype;
Op->Asl.CompileFlags |= AslKeywordMapping[Index].Flags;
if (!Op->Asl.Value.Integer)
{
Op->Asl.Value.Integer = AslKeywordMapping[Index].Value;
}
/* Special handling for some opcodes */
switch (Op->Asl.ParseOpcode)
{
case PARSEOP_INTEGER:
/*
* Set the opcode based on the size of the integer
*/
(void) OpcSetOptimalIntegerSize (Op);
break;
case PARSEOP_OFFSET:
Op->Asl.AmlOpcodeLength = 1;
break;
case PARSEOP_ACCESSAS:
OpcDoAccessAs (Op);
break;
case PARSEOP_CONNECTION:
OpcDoConnection (Op);
break;
case PARSEOP_EISAID:
OpcDoEisaId (Op);
break;
case PARSEOP_PRINTF:
OpcDoPrintf (Op);
break;
case PARSEOP_FPRINTF:
OpcDoFprintf (Op);
break;
case PARSEOP_TOPLD:
OpcDoPld (Op);
break;
case PARSEOP_TOUUID:
OpcDoUuId (Op);
break;
case PARSEOP_UNICODE:
OpcDoUnicode (Op);
break;
case PARSEOP_INCLUDE:
AslGbl_HasIncludeFiles = TRUE;
break;
case PARSEOP_TIMER:
if (AcpiGbl_IntegerBitWidth == 32)
{
AslError (ASL_REMARK, ASL_MSG_TRUNCATION, Op, NULL);
}
break;
default:
/* Nothing to do for other opcodes */
break;
}
return;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,924 @@
/******************************************************************************
*
* Module Name: aslopt- Compiler optimizations
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "acparser.h"
#include "amlcode.h"
#include "acnamesp.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslopt")
static UINT32 OptTotal = 0;
/* Local prototypes */
static ACPI_STATUS
OptSearchToRoot (
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState,
ACPI_NAMESPACE_NODE *CurrentNode,
ACPI_NAMESPACE_NODE *TargetNode,
ACPI_BUFFER *TargetPath,
char **NewPath);
static ACPI_STATUS
OptBuildShortestPath (
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState,
ACPI_NAMESPACE_NODE *CurrentNode,
ACPI_NAMESPACE_NODE *TargetNode,
ACPI_BUFFER *CurrentPath,
ACPI_BUFFER *TargetPath,
ACPI_SIZE AmlNameStringLength,
UINT8 IsDeclaration,
char **ReturnNewPath);
static ACPI_STATUS
OptOptimizeNameDeclaration (
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState,
ACPI_NAMESPACE_NODE *CurrentNode,
ACPI_NAMESPACE_NODE *TargetNode,
char *AmlNameString,
char **NewPath);
/*******************************************************************************
*
* FUNCTION: OptSearchToRoot
*
* PARAMETERS: Op - Current parser op
* WalkState - Current state
* CurrentNode - Where we are in the namespace
* TargetNode - Node to which we are referring
* TargetPath - External full path to the target node
* NewPath - Where the optimized path is returned
*
* RETURN: Status
*
* DESCRIPTION: Attempt to optimize a reference to a single 4-character ACPI
* name utilizing the search-to-root name resolution algorithm
* that is used by AML interpreters.
*
******************************************************************************/
static ACPI_STATUS
OptSearchToRoot (
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState,
ACPI_NAMESPACE_NODE *CurrentNode,
ACPI_NAMESPACE_NODE *TargetNode,
ACPI_BUFFER *TargetPath,
char **NewPath)
{
ACPI_NAMESPACE_NODE *Node;
ACPI_GENERIC_STATE ScopeInfo;
ACPI_STATUS Status;
char *Path;
ACPI_FUNCTION_NAME (OptSearchToRoot);
/*
* Check if search-to-root can be utilized. Use the last NameSeg of
* the NamePath and 1) See if can be found and 2) If found, make
* sure that it is the same node that we want. If there is another
* name in the search path before the one we want, the nodes will
* not match, and we cannot use this optimization.
*/
Path = &(((char *) TargetPath->Pointer)[
TargetPath->Length - ACPI_NAMESEG_SIZE]);
ScopeInfo.Scope.Node = CurrentNode;
/* Lookup the NameSeg using SEARCH_PARENT (search-to-root) */
Status = AcpiNsLookup (&ScopeInfo, Path, ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
ACPI_NS_SEARCH_PARENT | ACPI_NS_DONT_OPEN_SCOPE,
WalkState, &(Node));
if (ACPI_FAILURE (Status))
{
return (Status);
}
/*
* We found the name, but we must check to make sure that the node
* matches. Otherwise, there is another identical name in the search
* path that precludes the use of this optimization.
*/
if (Node != TargetNode)
{
/*
* This means that another object with the same name was found first,
* and we cannot use this optimization.
*/
return (AE_NOT_FOUND);
}
/* Found the node, we can use this optimization */
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
"NAMESEG: %-24s", Path));
/* We must allocate a new string for the name (TargetPath gets deleted) */
*NewPath = UtLocalCacheCalloc (ACPI_NAMESEG_SIZE + 1);
strcpy (*NewPath, Path);
if (strncmp (*NewPath, "_T_", 3))
{
AslError (ASL_OPTIMIZATION, ASL_MSG_SINGLE_NAME_OPTIMIZATION,
Op, *NewPath);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: OptBuildShortestPath
*
* PARAMETERS: Op - Current parser op
* WalkState - Current state
* CurrentNode - Where we are in the namespace
* TargetNode - Node to which we are referring
* CurrentPath - External full path to the current node
* TargetPath - External full path to the target node
* AmlNameStringLength - Length of the original namepath
* IsDeclaration - TRUE for declaration, FALSE for reference
* ReturnNewPath - Where the optimized path is returned
*
* RETURN: Status
*
* DESCRIPTION: Build an optimal NamePath using carats
*
******************************************************************************/
static ACPI_STATUS
OptBuildShortestPath (
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState,
ACPI_NAMESPACE_NODE *CurrentNode,
ACPI_NAMESPACE_NODE *TargetNode,
ACPI_BUFFER *CurrentPath,
ACPI_BUFFER *TargetPath,
ACPI_SIZE AmlNameStringLength,
UINT8 IsDeclaration,
char **ReturnNewPath)
{
UINT32 NumCommonSegments;
UINT32 MaxCommonSegments;
UINT32 Index;
UINT32 NumCarats;
UINT32 i;
char *NewPathInternal;
char *NewPathExternal;
ACPI_NAMESPACE_NODE *Node;
ACPI_GENERIC_STATE ScopeInfo;
ACPI_STATUS Status;
BOOLEAN SubPath = FALSE;
ACPI_FUNCTION_NAME (OptBuildShortestPath);
ScopeInfo.Scope.Node = CurrentNode;
/*
* Determine the maximum number of NameSegs that the Target and Current paths
* can possibly have in common. (To optimize, we have to have at least 1)
*
* Note: The external NamePath string lengths are always a multiple of 5
* (ACPI_NAMESEG_SIZE + separator)
*/
MaxCommonSegments = TargetPath->Length / ACPI_PATH_SEGMENT_LENGTH;
if (CurrentPath->Length < TargetPath->Length)
{
MaxCommonSegments = CurrentPath->Length / ACPI_PATH_SEGMENT_LENGTH;
}
/*
* Determine how many NameSegs the two paths have in common.
* (Starting from the root)
*/
for (NumCommonSegments = 0;
NumCommonSegments < MaxCommonSegments;
NumCommonSegments++)
{
/* Compare two single NameSegs */
Index = (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1;
if (!ACPI_COMPARE_NAMESEG (
&(ACPI_CAST_PTR (char, TargetPath->Pointer)) [Index],
&(ACPI_CAST_PTR (char, CurrentPath->Pointer)) [Index]))
{
/* Mismatch */
break;
}
}
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " COMMON: %u",
NumCommonSegments));
/* There must be at least 1 common NameSeg in order to optimize */
if (NumCommonSegments == 0)
{
return (AE_NOT_FOUND);
}
if (NumCommonSegments == MaxCommonSegments)
{
if (CurrentPath->Length == TargetPath->Length)
{
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " SAME PATH"));
return (AE_NOT_FOUND);
}
else
{
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " SUBPATH"));
SubPath = TRUE;
}
}
/* Determine how many prefix Carats are required */
NumCarats = (CurrentPath->Length / ACPI_PATH_SEGMENT_LENGTH) -
NumCommonSegments;
/*
* Construct a new target string
*/
NewPathExternal =
UtLocalCacheCalloc (TargetPath->Length + NumCarats + 1);
/* Insert the Carats into the Target string */
for (i = 0; i < NumCarats; i++)
{
NewPathExternal[i] = AML_PARENT_PREFIX;
}
/*
* Copy only the necessary (optimal) segments from the original
* target string
*/
Index = (NumCommonSegments * ACPI_PATH_SEGMENT_LENGTH) + 1;
/* Special handling for exact subpath in a name declaration */
if (IsDeclaration && SubPath &&
(CurrentPath->Length > TargetPath->Length))
{
/*
* The current path is longer than the target, and the target is a
* subpath of the current path. We must include one more NameSeg of
* the target path
*/
Index -= ACPI_PATH_SEGMENT_LENGTH;
/* Special handling for Scope() operator */
if (Op->Asl.AmlOpcode == AML_SCOPE_OP)
{
NewPathExternal[i] = AML_PARENT_PREFIX;
i++;
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "(EXTRA ^)"));
}
}
/* Make sure we haven't gone off the end of the target path */
if (Index > TargetPath->Length)
{
Index = TargetPath->Length;
}
strcpy (&NewPathExternal[i],
&(ACPI_CAST_PTR (char, TargetPath->Pointer))[Index]);
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " %-24s", NewPathExternal));
/*
* Internalize the new target string and check it against the original
* string to make sure that this is in fact an optimization. If the
* original string is already optimal, there is no point in continuing.
*/
Status = AcpiNsInternalizeName (NewPathExternal, &NewPathInternal);
if (ACPI_FAILURE (Status))
{
AslCoreSubsystemError (Op, Status, "Internalizing new NamePath",
ASL_NO_ABORT);
goto Cleanup;
}
if (strlen (NewPathInternal) >= AmlNameStringLength)
{
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
" NOT SHORTER (New %u old %u)",
(UINT32) strlen (NewPathInternal),
(UINT32) AmlNameStringLength));
ACPI_FREE (NewPathInternal);
Status = AE_NOT_FOUND;
goto Cleanup;
}
/*
* Check to make sure that the optimization finds the node we are
* looking for. This is simply a sanity check on the new
* path that has been created.
*/
Status = AcpiNsLookup (&ScopeInfo, NewPathInternal,
ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node));
if (ACPI_SUCCESS (Status))
{
/* Found the namepath, but make sure the node is correct */
if (Node == TargetNode)
{
/* The lookup matched the node, accept this optimization */
AslError (ASL_OPTIMIZATION, ASL_MSG_NAME_OPTIMIZATION,
Op, NewPathExternal);
*ReturnNewPath = NewPathInternal;
}
else
{
/* Node is not correct, do not use this optimization */
Status = AE_NOT_FOUND;
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** WRONG NODE"));
AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
"Not using optimized name - found wrong node");
}
}
else
{
/* The lookup failed, we obviously cannot use this optimization */
ACPI_FREE (NewPathInternal);
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ***** NOT FOUND"));
AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
"Not using optimized name - did not find node");
}
Cleanup:
return (Status);
}
/*******************************************************************************
*
* FUNCTION: OptOptimizeNameDeclaration
*
* PARAMETERS: Op - Current parser op
* WalkState - Current state
* CurrentNode - Where we are in the namespace
* AmlNameString - Unoptimized namepath
* NewPath - Where the optimized path is returned
*
* RETURN: Status. AE_OK If path is optimized
*
* DESCRIPTION: Perform a simple optimization of removing an extraneous
* backslash prefix if we are already at the root scope.
*
******************************************************************************/
static ACPI_STATUS
OptOptimizeNameDeclaration (
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState,
ACPI_NAMESPACE_NODE *CurrentNode,
ACPI_NAMESPACE_NODE *TargetNode,
char *AmlNameString,
char **NewPath)
{
ACPI_STATUS Status;
char *NewPathExternal;
ACPI_NAMESPACE_NODE *Node;
ACPI_FUNCTION_TRACE (OptOptimizeNameDeclaration);
if (((CurrentNode == AcpiGbl_RootNode) ||
(Op->Common.Parent->Asl.ParseOpcode == PARSEOP_DEFINITION_BLOCK)) &&
(ACPI_IS_ROOT_PREFIX (AmlNameString[0])))
{
/*
* The current scope is the root, and the namepath has a root prefix
* that is therefore extraneous. Remove it.
*/
*NewPath = &AmlNameString[1];
/* Debug output */
Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, *NewPath,
NULL, &NewPathExternal);
if (ACPI_FAILURE (Status))
{
AslCoreSubsystemError (Op, Status, "Externalizing NamePath",
ASL_NO_ABORT);
return (Status);
}
/*
* Check to make sure that the optimization finds the node we are
* looking for. This is simply a sanity check on the new
* path that has been created.
*
* We know that we are at the root, so NULL is used for the scope.
*/
Status = AcpiNsLookup (NULL, *NewPath,
ACPI_TYPE_ANY, ACPI_IMODE_EXECUTE,
ACPI_NS_DONT_OPEN_SCOPE, WalkState, &(Node));
if (ACPI_SUCCESS (Status))
{
/* Found the namepath, but make sure the node is correct */
if (Node == TargetNode)
{
/* The lookup matched the node, accept this optimization */
AslError (ASL_OPTIMIZATION, ASL_MSG_NAME_OPTIMIZATION,
Op, NewPathExternal);
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
"AT ROOT: %-24s", NewPathExternal));
}
else
{
/* Node is not correct, do not use this optimization */
Status = AE_NOT_FOUND;
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
" ***** WRONG NODE"));
AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
"Not using optimized name - found wrong node");
}
}
else
{
/* The lookup failed, we obviously cannot use this optimization */
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
" ***** NOT FOUND"));
AslError (ASL_WARNING, ASL_MSG_COMPILER_INTERNAL, Op,
"Not using optimized name - did not find node");
}
ACPI_FREE (NewPathExternal);
return (Status);
}
/* Could not optimize */
return (AE_NOT_FOUND);
}
/*******************************************************************************
*
* FUNCTION: OptOptimizeNamePath
*
* PARAMETERS: Op - Current parser op
* Flags - Opcode info flags
* WalkState - Current state
* AmlNameString - Unoptimized namepath
* TargetNode - Node to which AmlNameString refers
*
* RETURN: None. If path is optimized, the Op is updated with new path
*
* DESCRIPTION: Optimize a Named Declaration or Reference to the minimal length.
* Must take into account both the current location in the
* namespace and the actual reference path.
*
******************************************************************************/
void
OptOptimizeNamePath (
ACPI_PARSE_OBJECT *Op,
UINT32 Flags,
ACPI_WALK_STATE *WalkState,
char *AmlNameString,
ACPI_NAMESPACE_NODE *TargetNode)
{
ACPI_STATUS Status;
ACPI_BUFFER TargetPath;
ACPI_BUFFER CurrentPath;
ACPI_SIZE AmlNameStringLength;
ACPI_NAMESPACE_NODE *CurrentNode;
char *ExternalNameString;
char *NewPath = NULL;
ACPI_SIZE HowMuchShorter;
ACPI_PARSE_OBJECT *NextOp;
ACPI_FUNCTION_TRACE (OptOptimizeNamePath);
/* This is an optional optimization */
if (!AslGbl_ReferenceOptimizationFlag)
{
return_VOID;
}
/* Various required items */
if (!TargetNode || !WalkState || !AmlNameString || !Op->Common.Parent)
{
return_VOID;
}
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
"PATH OPTIMIZE: Line %5d ParentOp [%12.12s] ThisOp [%12.12s] ",
Op->Asl.LogicalLineNumber,
AcpiPsGetOpcodeName (Op->Common.Parent->Common.AmlOpcode),
AcpiPsGetOpcodeName (Op->Common.AmlOpcode)));
if (!(Flags & (AML_NAMED | AML_CREATE)))
{
if (Op->Asl.CompileFlags & OP_IS_NAME_DECLARATION)
{
/* We don't want to fuss with actual name declaration nodes here */
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
"******* NAME DECLARATION\n"));
return_VOID;
}
}
/*
* The original path must be longer than one NameSeg (4 chars) for there
* to be any possibility that it can be optimized to a shorter string
*/
AmlNameStringLength = strlen (AmlNameString);
if (AmlNameStringLength <= ACPI_NAMESEG_SIZE)
{
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
"NAMESEG %4.4s\n", AmlNameString));
return_VOID;
}
/*
* We need to obtain the node that represents the current scope -- where
* we are right now in the namespace. We will compare this path
* against the Namepath, looking for commonality.
*/
CurrentNode = AcpiGbl_RootNode;
if (WalkState->ScopeInfo)
{
CurrentNode = WalkState->ScopeInfo->Scope.Node;
}
if (Flags & (AML_NAMED | AML_CREATE))
{
/* This is the declaration of a new name */
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "NAME\n"));
/*
* The node of interest is the parent of this node (the containing
* scope). The actual namespace node may be up more than one level
* of parse op or it may not exist at all (if we traverse back
* up to the root.)
*/
NextOp = Op->Asl.Parent;
while (NextOp && (!NextOp->Asl.Node))
{
NextOp = NextOp->Asl.Parent;
}
if (NextOp && NextOp->Asl.Node)
{
CurrentNode = NextOp->Asl.Node;
}
else
{
CurrentNode = AcpiGbl_RootNode;
}
}
else
{
/* This is a reference to an existing named object */
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "REFERENCE\n"));
}
/*
* Obtain the full paths to the two nodes that we are interested in
* (Target and current namespace location) in external
* format -- something we can easily manipulate
*/
TargetPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
Status = AcpiNsHandleToPathname (TargetNode, &TargetPath, FALSE);
if (ACPI_FAILURE (Status))
{
AslCoreSubsystemError (Op, Status, "Getting Target NamePath",
ASL_NO_ABORT);
return_VOID;
}
TargetPath.Length--; /* Subtract one for null terminator */
/* CurrentPath is the path to this scope (where we are in the namespace) */
CurrentPath.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
Status = AcpiNsHandleToPathname (CurrentNode, &CurrentPath, FALSE);
if (ACPI_FAILURE (Status))
{
AslCoreSubsystemError (Op, Status, "Getting Current NamePath",
ASL_NO_ABORT);
return_VOID;
}
CurrentPath.Length--; /* Subtract one for null terminator */
/* Debug output only */
Status = AcpiNsExternalizeName (ACPI_UINT32_MAX, AmlNameString,
NULL, &ExternalNameString);
if (ACPI_FAILURE (Status))
{
AslCoreSubsystemError (Op, Status, "Externalizing NamePath",
ASL_NO_ABORT);
return_VOID;
}
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
"CURRENT SCOPE: (%2u) %-37s FULL PATH TO NAME: (%2u) %-32s ACTUAL AML:%-32s\n",
(UINT32) CurrentPath.Length, (char *) CurrentPath.Pointer,
(UINT32) TargetPath.Length, (char *) TargetPath.Pointer,
ExternalNameString));
ACPI_FREE (ExternalNameString);
/*
* Attempt an optimization depending on the type of namepath
*/
if (Flags & (AML_NAMED | AML_CREATE))
{
/*
* This is a named opcode and the namepath is a name declaration, not
* a reference.
*/
Status = OptOptimizeNameDeclaration (Op, WalkState, CurrentNode,
TargetNode, AmlNameString, &NewPath);
if (ACPI_FAILURE (Status))
{
/*
* 2) now attempt to
* optimize the namestring with carats (up-arrow)
*/
Status = OptBuildShortestPath (Op, WalkState, CurrentNode,
TargetNode, &CurrentPath, &TargetPath,
AmlNameStringLength, 1, &NewPath);
}
}
else
{
/*
* This is a reference to an existing named object
*
* 1) Check if search-to-root can be utilized using the last
* NameSeg of the NamePath
*/
Status = OptSearchToRoot (Op, WalkState, CurrentNode,
TargetNode, &TargetPath, &NewPath);
if (ACPI_FAILURE (Status))
{
/*
* 2) Search-to-root could not be used, now attempt to
* optimize the namestring with carats (up-arrow)
*/
Status = OptBuildShortestPath (Op, WalkState, CurrentNode,
TargetNode, &CurrentPath, &TargetPath,
AmlNameStringLength, 0, &NewPath);
}
}
/*
* Success from above indicates that the NamePath was successfully
* optimized. We need to update the parse op with the new name
*/
if (ACPI_SUCCESS (Status))
{
HowMuchShorter = (AmlNameStringLength - strlen (NewPath));
OptTotal += HowMuchShorter;
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS,
" REDUCED BY %2u (TOTAL SAVED %2u)",
(UINT32) HowMuchShorter, OptTotal));
if (Flags & AML_NAMED)
{
if (Op->Asl.AmlOpcode == AML_ALIAS_OP)
{
/*
* ALIAS is the only oddball opcode, the name declaration
* (alias name) is the second operand
*/
Op->Asl.Child->Asl.Next->Asl.Value.String = NewPath;
Op->Asl.Child->Asl.Next->Asl.AmlLength = strlen (NewPath);
}
else
{
Op->Asl.Child->Asl.Value.String = NewPath;
Op->Asl.Child->Asl.AmlLength = strlen (NewPath);
}
}
else if (Flags & AML_CREATE)
{
/* Name must appear as the last parameter */
NextOp = Op->Asl.Child;
while (!(NextOp->Asl.CompileFlags & OP_IS_NAME_DECLARATION))
{
NextOp = NextOp->Asl.Next;
}
/* Update the parse node with the new NamePath */
NextOp->Asl.Value.String = NewPath;
NextOp->Asl.AmlLength = strlen (NewPath);
}
else
{
/* Update the parse node with the new NamePath */
Op->Asl.Value.String = NewPath;
Op->Asl.AmlLength = strlen (NewPath);
}
}
else
{
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, " ALREADY OPTIMAL"));
}
/* Cleanup path buffers */
ACPI_FREE (TargetPath.Pointer);
ACPI_FREE (CurrentPath.Pointer);
ACPI_DEBUG_PRINT_RAW ((ACPI_DB_OPTIMIZATIONS, "\n"));
return_VOID;
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,941 @@
/******************************************************************************
*
* Module Name: aslparseop - Parse op create/allocate/cache interfaces
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "acapps.h"
#include "acconvert.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslparseop")
/*******************************************************************************
*
* FUNCTION: TrCreateOp
*
* PARAMETERS: ParseOpcode - Opcode to be assigned to the op
* NumChildren - Number of children to follow
* ... - A list of child ops to link to the new
* op. NumChildren long.
*
* RETURN: Pointer to the new op. Aborts on allocation failure
*
* DESCRIPTION: Create a new parse op and link together a list of child
* ops underneath the new op.
*
******************************************************************************/
ACPI_PARSE_OBJECT *
TrCreateOp (
UINT32 ParseOpcode,
UINT32 NumChildren,
...)
{
ACPI_PARSE_OBJECT *Op;
ACPI_PARSE_OBJECT *Child;
ACPI_PARSE_OBJECT *PrevChild;
va_list ap;
UINT32 i;
BOOLEAN FirstChild;
va_start (ap, NumChildren);
/* Allocate one new op */
Op = TrAllocateOp (ParseOpcode);
DbgPrint (ASL_PARSE_OUTPUT,
"\nCreateOp Ln/Col %u/%u NewParent %p Child %u Op %s ",
Op->Asl.LineNumber, Op->Asl.Column, Op,
NumChildren, UtGetOpName(ParseOpcode));
/* Some extra debug output based on the parse opcode */
switch (ParseOpcode)
{
case PARSEOP_ASL_CODE:
AslGbl_ParseTreeRoot = Op;
Op->Asl.ParseOpcode = PARSEOP_DEFAULT_ARG;
DbgPrint (ASL_PARSE_OUTPUT, "ASLCODE (Tree Completed)->");
break;
case PARSEOP_DEFINITION_BLOCK:
DbgPrint (ASL_PARSE_OUTPUT, "DEFINITION_BLOCK (Tree Completed)->");
break;
case PARSEOP_OPERATIONREGION:
DbgPrint (ASL_PARSE_OUTPUT, "OPREGION->");
break;
case PARSEOP_OR:
DbgPrint (ASL_PARSE_OUTPUT, "OR->");
break;
default:
/* Nothing to do for other opcodes */
break;
}
/* Link the new op to its children */
PrevChild = NULL;
FirstChild = TRUE;
for (i = 0; i < NumChildren; i++)
{
/* Get the next child */
Child = va_arg (ap, ACPI_PARSE_OBJECT *);
DbgPrint (ASL_PARSE_OUTPUT, "%p, ", Child);
/*
* If child is NULL, this means that an optional argument
* was omitted. We must create a placeholder with a special
* opcode (DEFAULT_ARG) so that the code generator will know
* that it must emit the correct default for this argument
*/
if (!Child)
{
Child = TrAllocateOp (PARSEOP_DEFAULT_ARG);
}
/* Link first child to parent */
if (FirstChild)
{
FirstChild = FALSE;
Op->Asl.Child = Child;
/*
* For the ASL-/ASL+ converter: if the ParseOp is a Connection,
* External, Offset or AccessAs, it means that the comments in the
* FirstChild belongs to their parent due to the parsing order in
* the .y files. To correct this, take the comments in the
* FirstChild place it in the parent. This also means that
* legitimate comments for the child gets put to the parent.
*/
if (AcpiGbl_CaptureComments &&
((ParseOpcode == PARSEOP_CONNECTION) ||
(ParseOpcode == PARSEOP_EXTERNAL) ||
(ParseOpcode == PARSEOP_OFFSET) ||
(ParseOpcode == PARSEOP_ACCESSAS)))
{
Op->Asl.CommentList = Child->Asl.CommentList;
Op->Asl.EndBlkComment = Child->Asl.EndBlkComment;
Op->Asl.InlineComment = Child->Asl.InlineComment;
Op->Asl.FileChanged = Child->Asl.FileChanged;
Child->Asl.CommentList = NULL;
Child->Asl.EndBlkComment = NULL;
Child->Asl.InlineComment = NULL;
Child->Asl.FileChanged = FALSE;
/*
* These do not need to be "passed off". They can be copied
* because the code for these opcodes should be printed in the
* same file.
*/
Op->Asl.Filename = Child->Asl.Filename;
Op->Asl.ParentFilename = Child->Asl.ParentFilename;
}
}
/* Point all children to parent */
Child->Asl.Parent = Op;
/* Link children in a peer list */
if (PrevChild)
{
PrevChild->Asl.Next = Child;
};
/* Get the comment from last child in the resource template call */
if (AcpiGbl_CaptureComments &&
(Op->Asl.ParseOpcode == PARSEOP_RESOURCETEMPLATE))
{
CvDbgPrint ("Transferred current comment list to this op.\n");
Op->Asl.CommentList = Child->Asl.CommentList;
Child->Asl.CommentList = NULL;
Op->Asl.InlineComment = Child->Asl.InlineComment;
Child->Asl.InlineComment = NULL;
}
/*
* This child might be a list, point all ops in the list
* to the same parent
*/
while (Child->Asl.Next)
{
Child = Child->Asl.Next;
Child->Asl.Parent = Op;
}
PrevChild = Child;
}
va_end(ap);
DbgPrint (ASL_PARSE_OUTPUT, "\n");
return (Op);
}
/*******************************************************************************
*
* FUNCTION: TrCreateLeafOp
*
* PARAMETERS: ParseOpcode - New opcode to be assigned to the op
*
* RETURN: Pointer to the new op. Aborts on allocation failure
*
* DESCRIPTION: Create a simple leaf op (no children or peers, and no value
* assigned to the op)
*
******************************************************************************/
ACPI_PARSE_OBJECT *
TrCreateLeafOp (
UINT32 ParseOpcode)
{
ACPI_PARSE_OBJECT *Op;
Op = TrAllocateOp (ParseOpcode);
DbgPrint (ASL_PARSE_OUTPUT,
"\nCreateLeafOp Ln/Col %u/%u NewOp %p Op %s\n\n",
Op->Asl.LineNumber, Op->Asl.Column, Op, UtGetOpName (ParseOpcode));
return (Op);
}
/*******************************************************************************
*
* FUNCTION: TrCreateValuedLeafOp
*
* PARAMETERS: ParseOpcode - New opcode to be assigned to the op
* Value - Value to be assigned to the op
*
* RETURN: Pointer to the new op. Aborts on allocation failure
*
* DESCRIPTION: Create a leaf op (no children or peers) with a value
* assigned to it
*
******************************************************************************/
ACPI_PARSE_OBJECT *
TrCreateValuedLeafOp (
UINT32 ParseOpcode,
UINT64 Value)
{
ACPI_PARSE_OBJECT *Op;
UINT32 i;
char *StringPtr = NULL;
Op = TrAllocateOp (ParseOpcode);
Op->Asl.Value.Integer = Value;
DbgPrint (ASL_PARSE_OUTPUT,
"\nCreateValuedLeafOp Ln/Col %u/%u NewOp %p "
"Op %s Value %8.8X%8.8X ",
Op->Asl.LineNumber, Op->Asl.Column, Op, UtGetOpName(ParseOpcode),
ACPI_FORMAT_UINT64 (Value));
switch (ParseOpcode)
{
case PARSEOP_STRING_LITERAL:
DbgPrint (ASL_PARSE_OUTPUT, "STRING->%s", Op->Asl.Value.String);
break;
case PARSEOP_NAMESEG:
/* Check for mixed case (or all lower case). Issue a remark in this case */
for (i = 0; i < ACPI_NAMESEG_SIZE; i++)
{
if (islower ((int) Op->Asl.Value.Name[i]))
{
AcpiUtStrupr (&Op->Asl.Value.Name[i]);
AslError (ASL_REMARK, ASL_MSG_LOWER_CASE_NAMESEG, Op, Op->Asl.Value.Name);
break;
}
}
DbgPrint (ASL_PARSE_OUTPUT, "NAMESEG->%s", Op->Asl.Value.String);
break;
case PARSEOP_NAMESTRING:
/* Check for mixed case (or all lower case). Issue a remark in this case */
StringPtr = Op->Asl.Value.Name;
for (i = 0; *StringPtr; i++)
{
if (islower ((int) *StringPtr))
{
AcpiUtStrupr (&Op->Asl.Value.Name[i]);
AslError (ASL_REMARK, ASL_MSG_LOWER_CASE_NAMEPATH, Op, Op->Asl.Value.Name);
break;
}
StringPtr++;
}
DbgPrint (ASL_PARSE_OUTPUT, "NAMESTRING->%s", Op->Asl.Value.String);
break;
case PARSEOP_EISAID:
DbgPrint (ASL_PARSE_OUTPUT, "EISAID->%s", Op->Asl.Value.String);
break;
case PARSEOP_METHOD:
DbgPrint (ASL_PARSE_OUTPUT, "METHOD");
break;
case PARSEOP_INTEGER:
DbgPrint (ASL_PARSE_OUTPUT, "INTEGER->%8.8X%8.8X",
ACPI_FORMAT_UINT64 (Value));
break;
default:
break;
}
DbgPrint (ASL_PARSE_OUTPUT, "\n\n");
return (Op);
}
/*******************************************************************************
*
* FUNCTION: TrCreateTargetOp
*
* PARAMETERS: OriginalOp - Op to be copied
*
* RETURN: Pointer to the new op. Aborts on allocation failure
*
* DESCRIPTION: Copy an existing op (and subtree). Used in ASL+ (C-style)
* expressions where the target is the same as one of the
* operands. A new op and subtree must be created from the
* original so that the parse tree can be linked properly.
*
* NOTE: This code is specific to target operands that are the last
* operand in an ASL/AML operator. Meaning that the top-level
* parse Op in a possible subtree has a NULL Next pointer.
* This simplifies the recursion.
*
* Subtree example:
* DeRefOf (Local1) += 32
*
* This gets converted to:
* Add (DeRefOf (Local1), 32, DeRefOf (Local1))
*
* Each DeRefOf has a single child, Local1. Even more complex
* subtrees can be created via the Index and DeRefOf operators.
*
******************************************************************************/
ACPI_PARSE_OBJECT *
TrCreateTargetOp (
ACPI_PARSE_OBJECT *OriginalOp,
ACPI_PARSE_OBJECT *ParentOp)
{
ACPI_PARSE_OBJECT *Op;
if (!OriginalOp)
{
return (NULL);
}
Op = UtParseOpCacheCalloc ();
/* Copy the pertinent values (omit link pointer fields) */
Op->Asl.Value = OriginalOp->Asl.Value;
Op->Asl.Filename = OriginalOp->Asl.Filename;
Op->Asl.LineNumber = OriginalOp->Asl.LineNumber;
Op->Asl.LogicalLineNumber = OriginalOp->Asl.LogicalLineNumber;
Op->Asl.LogicalByteOffset = OriginalOp->Asl.LogicalByteOffset;
Op->Asl.Column = OriginalOp->Asl.Column;
Op->Asl.Flags = OriginalOp->Asl.Flags;
Op->Asl.CompileFlags = OriginalOp->Asl.CompileFlags;
Op->Asl.AmlOpcode = OriginalOp->Asl.AmlOpcode;
Op->Asl.ParseOpcode = OriginalOp->Asl.ParseOpcode;
Op->Asl.Parent = ParentOp;
UtSetParseOpName (Op);
/* Copy a possible subtree below this op */
if (OriginalOp->Asl.Child)
{
Op->Asl.Child = TrCreateTargetOp (OriginalOp->Asl.Child, Op);
}
if (OriginalOp->Asl.Next) /* Null for top-level op */
{
Op->Asl.Next = TrCreateTargetOp (OriginalOp->Asl.Next, ParentOp);
}
return (Op);
}
/*******************************************************************************
*
* FUNCTION: TrCreateAssignmentOp
*
* PARAMETERS: Target - Assignment target
* Source - Assignment source
*
* RETURN: Pointer to the new op. Aborts on allocation failure
*
* DESCRIPTION: Implements the C-style '=' operator. It changes the parse
* tree if possible to utilize the last argument of the math
* operators which is a target operand -- thus saving invocation
* of and additional Store() operator. An optimization.
*
******************************************************************************/
ACPI_PARSE_OBJECT *
TrCreateAssignmentOp (
ACPI_PARSE_OBJECT *Target,
ACPI_PARSE_OBJECT *Source)
{
ACPI_PARSE_OBJECT *TargetOp;
ACPI_PARSE_OBJECT *SourceOp1;
ACPI_PARSE_OBJECT *SourceOp2;
ACPI_PARSE_OBJECT *Operator;
DbgPrint (ASL_PARSE_OUTPUT,
"\nTrCreateAssignmentOp Line [%u to %u] Source %s Target %s\n",
Source->Asl.LineNumber, Source->Asl.EndLine,
UtGetOpName (Source->Asl.ParseOpcode),
UtGetOpName (Target->Asl.ParseOpcode));
TrSetOpFlags (Target, OP_IS_TARGET);
switch (Source->Asl.ParseOpcode)
{
/*
* Only these operators can be optimized because they have
* a target operand
*/
case PARSEOP_ADD:
case PARSEOP_AND:
case PARSEOP_DIVIDE:
case PARSEOP_INDEX:
case PARSEOP_MOD:
case PARSEOP_MULTIPLY:
case PARSEOP_NOT:
case PARSEOP_OR:
case PARSEOP_SHIFTLEFT:
case PARSEOP_SHIFTRIGHT:
case PARSEOP_SUBTRACT:
case PARSEOP_XOR:
break;
/* Otherwise, just create a normal Store operator */
default:
goto CannotOptimize;
}
/*
* Transform the parse tree such that the target is moved to the
* last operand of the operator
*/
SourceOp1 = Source->Asl.Child;
SourceOp2 = SourceOp1->Asl.Next;
/* NOT only has one operand, but has a target */
if (Source->Asl.ParseOpcode == PARSEOP_NOT)
{
SourceOp2 = SourceOp1;
}
/* DIVIDE has an extra target operand (remainder) */
if (Source->Asl.ParseOpcode == PARSEOP_DIVIDE)
{
SourceOp2 = SourceOp2->Asl.Next;
}
TargetOp = SourceOp2->Asl.Next;
/*
* Can't perform this optimization if there already is a target
* for the operator (ZERO is a "no target" placeholder).
*/
if (TargetOp->Asl.ParseOpcode != PARSEOP_ZERO)
{
goto CannotOptimize;
}
/* Link in the target as the final operand */
SourceOp2->Asl.Next = Target;
Target->Asl.Parent = Source;
return (Source);
CannotOptimize:
Operator = TrAllocateOp (PARSEOP_STORE);
TrLinkOpChildren (Operator, 2, Source, Target);
/* Set the appropriate line numbers for the new op */
Operator->Asl.LineNumber = Target->Asl.LineNumber;
Operator->Asl.LogicalLineNumber = Target->Asl.LogicalLineNumber;
Operator->Asl.LogicalByteOffset = Target->Asl.LogicalByteOffset;
Operator->Asl.Column = Target->Asl.Column;
return (Operator);
}
/*******************************************************************************
*
* FUNCTION: TrCreateNullTargetOp
*
* PARAMETERS: None
*
* RETURN: Pointer to the new op. Aborts on allocation failure
*
* DESCRIPTION: Create a "null" target op. This is defined by the ACPI
* specification to be a zero AML opcode, and indicates that
* no target has been specified for the parent operation
*
******************************************************************************/
ACPI_PARSE_OBJECT *
TrCreateNullTargetOp (
void)
{
ACPI_PARSE_OBJECT *Op;
Op = TrAllocateOp (PARSEOP_ZERO);
Op->Asl.CompileFlags |= (OP_IS_TARGET | OP_COMPILE_TIME_CONST);
DbgPrint (ASL_PARSE_OUTPUT,
"\nCreateNullTargetOp Ln/Col %u/%u NewOp %p Op %s\n",
Op->Asl.LineNumber, Op->Asl.Column, Op,
UtGetOpName (Op->Asl.ParseOpcode));
return (Op);
}
/*******************************************************************************
*
* FUNCTION: TrCreateConstantLeafOp
*
* PARAMETERS: ParseOpcode - The constant opcode
*
* RETURN: Pointer to the new op. Aborts on allocation failure
*
* DESCRIPTION: Create a leaf op (no children or peers) for one of the
* special constants - __LINE__, __FILE__, and __DATE__.
*
* Note: The fullimplemenation of __METHOD__ cannot happen here because we
* don't have a full parse tree at this time and cannot find the parent
* control method. __METHOD__ must be implemented later, after the parse
* tree has been fully constructed.
*
******************************************************************************/
ACPI_PARSE_OBJECT *
TrCreateConstantLeafOp (
UINT32 ParseOpcode)
{
ACPI_PARSE_OBJECT *Op = NULL;
time_t CurrentTime;
char *StaticTimeString;
char *TimeString;
char *Filename = NULL;
ACPI_STATUS Status;
switch (ParseOpcode)
{
case PARSEOP___LINE__:
Op = TrAllocateOp (PARSEOP_INTEGER);
Op->Asl.Value.Integer = Op->Asl.LineNumber;
break;
case PARSEOP___METHOD__:
/* Will become a string literal later */
Op = TrAllocateOp (PARSEOP___METHOD__);
Op->Asl.Value.String = NULL;
break;
case PARSEOP___PATH__:
Op = TrAllocateOp (PARSEOP_STRING_LITERAL);
/* Op.Asl.Filename contains the full pathname to the file */
Op->Asl.Value.String = Op->Asl.Filename;
break;
case PARSEOP___FILE__:
Op = TrAllocateOp (PARSEOP_STRING_LITERAL);
/* Get the simple filename from the full path */
Status = FlSplitInputPathname (Op->Asl.Filename, NULL, &Filename);
if (ACPI_FAILURE (Status))
{
return (NULL);
}
Op->Asl.Value.String = Filename;
break;
case PARSEOP___DATE__:
Op = TrAllocateOp (PARSEOP_STRING_LITERAL);
/* Get a copy of the current time */
Op->Asl.Value.String = "";
CurrentTime = time (NULL);
StaticTimeString = ctime (&CurrentTime);
if (StaticTimeString)
{
TimeString = UtLocalCalloc (strlen (StaticTimeString) + 1);
strcpy (TimeString, StaticTimeString);
TimeString[strlen(TimeString) -1] = 0; /* Remove trailing newline */
Op->Asl.Value.String = TimeString;
}
break;
default: /* This would be an internal error */
return (NULL);
}
DbgPrint (ASL_PARSE_OUTPUT,
"\nCreateConstantLeafOp Ln/Col %u/%u NewOp %p "
"Op %s Value %8.8X%8.8X\n",
Op->Asl.LineNumber, Op->Asl.Column, Op, UtGetOpName (ParseOpcode),
ACPI_FORMAT_UINT64 (Op->Asl.Value.Integer));
return (Op);
}
/*******************************************************************************
*
* FUNCTION: TrAllocateOp
*
* PARAMETERS: ParseOpcode - Opcode to be assigned to the op
*
* RETURN: New parse op. Aborts on allocation failure
*
* DESCRIPTION: Allocate and initialize a new parse op for the parse tree
*
******************************************************************************/
ACPI_PARSE_OBJECT *
TrAllocateOp (
UINT32 ParseOpcode)
{
ACPI_PARSE_OBJECT *Op;
ACPI_PARSE_OBJECT *LatestOp;
ACPI_FUNCTION_NAME (TrAllocateOp);
Op = UtParseOpCacheCalloc ();
Op->Asl.ParseOpcode = (UINT16) ParseOpcode;
Op->Asl.Filename = AslGbl_Files[ASL_FILE_INPUT].Filename;
Op->Asl.LineNumber = AslGbl_CurrentLineNumber;
Op->Asl.LogicalLineNumber = AslGbl_LogicalLineNumber;
Op->Asl.LogicalByteOffset = AslGbl_CurrentLineOffset;
Op->Asl.Column = AslGbl_CurrentColumn;
UtSetParseOpName (Op);
/* The following is for capturing comments */
if (AcpiGbl_CaptureComments)
{
LatestOp = AslGbl_CommentState.LatestParseOp;
Op->Asl.InlineComment = NULL;
Op->Asl.EndNodeComment = NULL;
Op->Asl.CommentList = NULL;
Op->Asl.FileChanged = FALSE;
/*
* Check to see if the file name has changed before resetting the
* latest parse op.
*/
if (LatestOp &&
(ParseOpcode != PARSEOP_INCLUDE) &&
(ParseOpcode != PARSEOP_INCLUDE_END) &&
strcmp (LatestOp->Asl.Filename, Op->Asl.Filename))
{
CvDbgPrint ("latest op: %s\n", LatestOp->Asl.ParseOpName);
Op->Asl.FileChanged = TRUE;
if (AslGbl_IncludeFileStack)
{
Op->Asl.ParentFilename = AslGbl_IncludeFileStack->Filename;
}
else
{
Op->Asl.ParentFilename = NULL;
}
}
AslGbl_CommentState.LatestParseOp = Op;
CvDbgPrint ("%s=Set latest parse op to this op.\n", ACPI_GET_FUNCTION_NAME);
CvDbgPrint (" Op->Asl.ParseOpName = %s\n",
AslGbl_CommentState.LatestParseOp->Asl.ParseOpName);
CvDbgPrint (" Op->Asl.ParseOpcode = 0x%x\n", ParseOpcode);
if (Op->Asl.FileChanged)
{
CvDbgPrint(" file has been changed!\n");
}
/*
* if this parse op's syntax uses () and {} (i.e. Package(1){0x00}) then
* set a flag in the comment state. This facilitates paring comments for
* these types of opcodes.
*/
if ((CvParseOpBlockType(Op) == (BLOCK_PAREN | BLOCK_BRACE)) &&
(ParseOpcode != PARSEOP_DEFINITION_BLOCK))
{
CvDbgPrint ("Parsing paren/Brace op now!\n");
AslGbl_CommentState.ParsingParenBraceNode = Op;
}
if (AslGbl_CommentListHead)
{
CvDbgPrint ("Transferring...\n");
Op->Asl.CommentList = AslGbl_CommentListHead;
AslGbl_CommentListHead = NULL;
AslGbl_CommentListTail = NULL;
CvDbgPrint (" Transferred current comment list to this op.\n");
CvDbgPrint (" %s\n", Op->Asl.CommentList->Comment);
}
if (AslGbl_InlineCommentBuffer)
{
Op->Asl.InlineComment = AslGbl_InlineCommentBuffer;
AslGbl_InlineCommentBuffer = NULL;
CvDbgPrint ("Transferred current inline comment list to this op.\n");
}
}
return (Op);
}
/*******************************************************************************
*
* FUNCTION: TrPrintOpFlags
*
* PARAMETERS: Flags - Flags word to be decoded
* OutputLevel - Debug output level: ASL_TREE_OUTPUT etc.
*
* RETURN: None
*
* DESCRIPTION: Decode a flags word to text. Displays all flags that are set.
*
******************************************************************************/
void
TrPrintOpFlags (
UINT32 Flags,
UINT32 OutputLevel)
{
UINT32 FlagBit = 1;
UINT32 i;
for (i = 0; i < ACPI_NUM_OP_FLAGS; i++)
{
if (Flags & FlagBit)
{
DbgPrint (OutputLevel, " %s", AslGbl_OpFlagNames[i]);
}
FlagBit <<= 1;
}
}

View File

@@ -0,0 +1,245 @@
%{
/******************************************************************************
*
* Module Name: aslparser.y - Master Bison/Yacc input file for iASL
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "acpi.h"
#include "accommon.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslparse")
/*
* Global Notes:
*
* October 2005: The following list terms have been optimized (from the
* original ASL grammar in the ACPI specification) to force the immediate
* reduction of each list item so that the parse stack use doesn't increase on
* each list element and possibly overflow on very large lists (>4000 items).
* This dramatically reduces use of the parse stack overall.
*
* ArgList, TermList, ByteList, DWordList, PackageList,
* ResourceMacroList, and FieldUnitList
*/
void *
AslLocalAllocate (
unsigned int Size);
/* Bison/yacc configuration */
#define static
#undef malloc
#define malloc AslLocalAllocate
#undef alloca
#define alloca AslLocalAllocate
#define yytname AslCompilername
#define YYINITDEPTH 600 /* State stack depth */
#define YYDEBUG 1 /* Enable debug output */
#define YYERROR_VERBOSE 1 /* Verbose error messages */
#define YYFLAG -32768
/* Define YYMALLOC/YYFREE to prevent redefinition errors */
#define YYMALLOC AslLocalAllocate
#define YYFREE ACPI_FREE
%}
/*
* Declare the type of values in the grammar
*/
%union {
UINT64 i;
char *s;
ACPI_PARSE_OBJECT *n;
}
/*
* These shift/reduce conflicts are expected. There should be zero
* reduce/reduce conflicts.
*/
%expect 134
/*! [Begin] no source code translation */
/*
* The M4 macro processor is used to bring in the parser items,
* in order to keep this master file smaller, and to break up
* the various parser items.
*/
m4_define(NoEcho)
/* Token types */
m4_include(asltokens.y)
/* Production types/names */
m4_include(asltypes.y)
%%
/* Production rules */
m4_include(aslrules.y)
m4_include(aslprimaries.y)
m4_include(aslcstyle.y)
m4_include(aslkeywords.y)
m4_include(aslresources.y)
m4_include(aslhelpers.y)
%%
/*! [End] no source code translation !*/
/* Local support functions in C */
m4_include(aslsupport.y)

View File

@@ -0,0 +1,833 @@
/******************************************************************************
*
* Module Name: aslpld - Implementation of ASL ToPLD macro
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "amlcode.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslpld")
/* Local prototypes */
static UINT8 *
OpcEncodePldBuffer (
ACPI_PLD_INFO *PldInfo);
static BOOLEAN
OpcFindName (
const char **List,
char *Name,
UINT32 *Index);
/*******************************************************************************
*
* FUNCTION: OpcDoPld
*
* PARAMETERS: Op - Current parse node
*
* RETURN: None
*
* DESCRIPTION: Convert ToPLD macro to 20-byte buffer
*
* The ToPLD parse tree looks like this:
*
* TOPLD
* PLD_REVISION
* INTEGER
* PLD_IGNORECOLOR
* INTEGER
* ...
* etc.
*
******************************************************************************/
void
OpcDoPld (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PLD_INFO PldInfo;
UINT8 *Buffer;
ACPI_PARSE_OBJECT *ThisOp;
ACPI_PARSE_OBJECT *NewOp;
UINT16 ParseOpcode;
UINT32 Value;
if (!Op)
{
AslError (ASL_ERROR, ASL_MSG_NOT_EXIST, Op, NULL);
return;
}
if (Op->Asl.ParseOpcode != PARSEOP_TOPLD)
{
AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, Op, NULL);
return;
}
memset (&PldInfo, 0, sizeof (ACPI_PLD_INFO));
/* Traverse the list of PLD Ops (one per PLD field) */
ThisOp = Op->Asl.Child;
while (ThisOp)
{
/* Get child values */
ParseOpcode = ThisOp->Asl.Child->Asl.ParseOpcode;
Value = (UINT32) ThisOp->Asl.Child->Asl.Value.Integer;
switch (ThisOp->Asl.ParseOpcode)
{
case PARSEOP_PLD_REVISION:
if (ParseOpcode != PARSEOP_INTEGER)
{
AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
break;
}
if (Value > 127)
{
AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
break;
}
PldInfo.Revision = (UINT8) Value;
break;
case PARSEOP_PLD_IGNORECOLOR:
if (ParseOpcode != PARSEOP_INTEGER)
{
AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
break;
}
if (Value > 1)
{
AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
break;
}
PldInfo.IgnoreColor = (UINT8) Value;
break;
case PARSEOP_PLD_RED:
case PARSEOP_PLD_GREEN:
case PARSEOP_PLD_BLUE:
if (ParseOpcode != PARSEOP_INTEGER)
{
AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
break;
}
if (Value > 255)
{
AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
break;
}
if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_RED)
{
PldInfo.Red = (UINT8) Value;
}
else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_GREEN)
{
PldInfo.Green = (UINT8) Value;
}
else /* PARSEOP_PLD_BLUE */
{
PldInfo.Blue = (UINT8) Value;
}
break;
case PARSEOP_PLD_WIDTH:
case PARSEOP_PLD_HEIGHT:
if (ParseOpcode != PARSEOP_INTEGER)
{
AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
break;
}
if (Value > 65535)
{
AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
break;
}
if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_WIDTH)
{
PldInfo.Width = (UINT16) Value;
}
else /* PARSEOP_PLD_HEIGHT */
{
PldInfo.Height = (UINT16) Value;
}
break;
case PARSEOP_PLD_USERVISIBLE:
case PARSEOP_PLD_DOCK:
case PARSEOP_PLD_LID:
if (ParseOpcode != PARSEOP_INTEGER)
{
AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
break;
}
if (Value > 1)
{
AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
break;
}
if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_USERVISIBLE)
{
PldInfo.UserVisible = (UINT8) Value;
}
else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_DOCK)
{
PldInfo.Dock = (UINT8) Value;
}
else
{
PldInfo.Lid = (UINT8) Value;
}
break;
case PARSEOP_PLD_PANEL:
if (ParseOpcode == PARSEOP_INTEGER)
{
if (Value > 6)
{
AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
break;
}
}
else /* PARSEOP_STRING */
{
if (!OpcFindName (AcpiGbl_PldPanelList,
ThisOp->Asl.Child->Asl.Value.String,
&Value))
{
AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL);
break;
}
}
PldInfo.Panel = (UINT8) Value;
break;
case PARSEOP_PLD_VERTICALPOSITION:
if (ParseOpcode == PARSEOP_INTEGER)
{
if (Value > 2)
{
AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
break;
}
}
else /* PARSEOP_STRING */
{
if (!OpcFindName (AcpiGbl_PldVerticalPositionList,
ThisOp->Asl.Child->Asl.Value.String,
&Value))
{
AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL);
break;
}
}
PldInfo.VerticalPosition = (UINT8) Value;
break;
case PARSEOP_PLD_HORIZONTALPOSITION:
if (ParseOpcode == PARSEOP_INTEGER)
{
if (Value > 2)
{
AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
break;
}
}
else /* PARSEOP_STRING */
{
if (!OpcFindName (AcpiGbl_PldHorizontalPositionList,
ThisOp->Asl.Child->Asl.Value.String,
&Value))
{
AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL);
break;
}
}
PldInfo.HorizontalPosition = (UINT8) Value;
break;
case PARSEOP_PLD_SHAPE:
if (ParseOpcode == PARSEOP_INTEGER)
{
if (Value > 8)
{
AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
break;
}
}
else /* PARSEOP_STRING */
{
if (!OpcFindName (AcpiGbl_PldShapeList,
ThisOp->Asl.Child->Asl.Value.String,
&Value))
{
AslError (ASL_ERROR, ASL_MSG_INVALID_OPERAND, ThisOp, NULL);
break;
}
}
PldInfo.Shape = (UINT8) Value;
break;
case PARSEOP_PLD_GROUPORIENTATION:
if (ParseOpcode != PARSEOP_INTEGER)
{
AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
break;
}
if (Value > 1)
{
AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
break;
}
PldInfo.GroupOrientation = (UINT8) Value;
break;
case PARSEOP_PLD_GROUPTOKEN:
case PARSEOP_PLD_GROUPPOSITION:
if (ParseOpcode != PARSEOP_INTEGER)
{
AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
break;
}
if (Value > 255)
{
AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
break;
}
if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_GROUPTOKEN)
{
PldInfo.GroupToken = (UINT8) Value;
}
else /* PARSEOP_PLD_GROUPPOSITION */
{
PldInfo.GroupPosition = (UINT8) Value;
}
break;
case PARSEOP_PLD_BAY:
case PARSEOP_PLD_EJECTABLE:
case PARSEOP_PLD_EJECTREQUIRED:
if (ParseOpcode != PARSEOP_INTEGER)
{
AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
break;
}
if (Value > 1)
{
AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
break;
}
if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_BAY)
{
PldInfo.Bay = (UINT8) Value;
}
else if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_EJECTABLE)
{
PldInfo.Ejectable = (UINT8) Value;
}
else /* PARSEOP_PLD_EJECTREQUIRED */
{
PldInfo.OspmEjectRequired = (UINT8) Value;
}
break;
case PARSEOP_PLD_CABINETNUMBER:
case PARSEOP_PLD_CARDCAGENUMBER:
if (ParseOpcode != PARSEOP_INTEGER)
{
AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
break;
}
if (Value > 255)
{
AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
break;
}
if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_CABINETNUMBER)
{
PldInfo.CabinetNumber = (UINT8) Value;
}
else /* PARSEOP_PLD_CARDCAGENUMBER */
{
PldInfo.CardCageNumber = (UINT8) Value;
}
break;
case PARSEOP_PLD_REFERENCE:
if (ParseOpcode != PARSEOP_INTEGER)
{
AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
break;
}
if (Value > 1)
{
AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
break;
}
PldInfo.Reference = (UINT8) Value;
break;
case PARSEOP_PLD_ROTATION:
if (ParseOpcode != PARSEOP_INTEGER)
{
AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
break;
}
if (Value > 7)
{
switch (Value)
{
case 45:
Value = 1;
break;
case 90:
Value = 2;
break;
case 135:
Value = 3;
break;
case 180:
Value = 4;
break;
case 225:
Value = 5;
break;
case 270:
Value = 6;
break;
case 315:
Value = 7;
break;
default:
AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
break;
}
}
PldInfo.Rotation = (UINT8) Value;
break;
case PARSEOP_PLD_ORDER:
if (ParseOpcode != PARSEOP_INTEGER)
{
AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
break;
}
if (Value > 31)
{
AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
break;
}
PldInfo.Order = (UINT8) Value;
break;
case PARSEOP_PLD_VERTICALOFFSET:
case PARSEOP_PLD_HORIZONTALOFFSET:
if (ParseOpcode != PARSEOP_INTEGER)
{
AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
break;
}
if (Value > 65535)
{
AslError (ASL_ERROR, ASL_MSG_RANGE, ThisOp, NULL);
break;
}
if (ThisOp->Asl.ParseOpcode == PARSEOP_PLD_VERTICALOFFSET)
{
PldInfo.VerticalOffset = (UINT16) Value;
}
else /* PARSEOP_PLD_HORIZONTALOFFSET */
{
PldInfo.HorizontalOffset = (UINT16) Value;
}
break;
default:
AslError (ASL_ERROR, ASL_MSG_INVALID_TYPE, ThisOp, NULL);
break;
}
ThisOp = ThisOp->Asl.Next;
}
Buffer = OpcEncodePldBuffer (&PldInfo);
/* Change Op to a Buffer */
Op->Asl.ParseOpcode = PARSEOP_BUFFER;
Op->Common.AmlOpcode = AML_BUFFER_OP;
/* Disable further optimization */
Op->Asl.CompileFlags &= ~OP_COMPILE_TIME_CONST;
UtSetParseOpName (Op);
/* Child node is the buffer length */
NewOp = TrAllocateOp (PARSEOP_INTEGER);
NewOp->Asl.AmlOpcode = AML_BYTE_OP;
NewOp->Asl.Value.Integer = 20;
NewOp->Asl.Parent = Op;
Op->Asl.Child = NewOp;
Op = NewOp;
/* Peer to the child is the raw buffer data */
NewOp = TrAllocateOp (PARSEOP_RAW_DATA);
NewOp->Asl.AmlOpcode = AML_RAW_DATA_BUFFER;
NewOp->Asl.AmlLength = 20;
NewOp->Asl.Value.String = ACPI_CAST_PTR (char, Buffer);
NewOp->Asl.Parent = Op->Asl.Parent;
Op->Asl.Next = NewOp;
}
/*******************************************************************************
*
* FUNCTION: OpcEncodePldBuffer
*
* PARAMETERS: PldInfo - _PLD buffer struct (Using local struct)
*
* RETURN: Encode _PLD buffer suitable for return value from _PLD
*
* DESCRIPTION: Bit-packs a _PLD buffer struct.
*
******************************************************************************/
static UINT8 *
OpcEncodePldBuffer (
ACPI_PLD_INFO *PldInfo)
{
UINT32 *Buffer;
UINT32 Dword;
Buffer = ACPI_CAST_PTR (UINT32, UtLocalCacheCalloc (ACPI_PLD_BUFFER_SIZE));
/* First 32 bits */
Dword = 0;
ACPI_PLD_SET_REVISION (&Dword, PldInfo->Revision);
ACPI_PLD_SET_IGNORE_COLOR (&Dword, PldInfo->IgnoreColor);
ACPI_PLD_SET_RED (&Dword, PldInfo->Red);
ACPI_PLD_SET_GREEN (&Dword, PldInfo->Green);
ACPI_PLD_SET_BLUE (&Dword, PldInfo->Blue);
ACPI_MOVE_32_TO_32 (&Buffer[0], &Dword);
/* Second 32 bits */
Dword = 0;
ACPI_PLD_SET_WIDTH (&Dword, PldInfo->Width);
ACPI_PLD_SET_HEIGHT (&Dword, PldInfo->Height);
ACPI_MOVE_32_TO_32 (&Buffer[1], &Dword);
/* Third 32 bits */
Dword = 0;
ACPI_PLD_SET_USER_VISIBLE (&Dword, PldInfo->UserVisible);
ACPI_PLD_SET_DOCK (&Dword, PldInfo->Dock);
ACPI_PLD_SET_LID (&Dword, PldInfo->Lid);
ACPI_PLD_SET_PANEL (&Dword, PldInfo->Panel);
ACPI_PLD_SET_VERTICAL (&Dword, PldInfo->VerticalPosition);
ACPI_PLD_SET_HORIZONTAL (&Dword, PldInfo->HorizontalPosition);
ACPI_PLD_SET_SHAPE (&Dword, PldInfo->Shape);
ACPI_PLD_SET_ORIENTATION (&Dword, PldInfo->GroupOrientation);
ACPI_PLD_SET_TOKEN (&Dword, PldInfo->GroupToken);
ACPI_PLD_SET_POSITION (&Dword, PldInfo->GroupPosition);
ACPI_PLD_SET_BAY (&Dword, PldInfo->Bay);
ACPI_MOVE_32_TO_32 (&Buffer[2], &Dword);
/* Fourth 32 bits */
Dword = 0;
ACPI_PLD_SET_EJECTABLE (&Dword, PldInfo->Ejectable);
ACPI_PLD_SET_OSPM_EJECT (&Dword, PldInfo->OspmEjectRequired);
ACPI_PLD_SET_CABINET (&Dword, PldInfo->CabinetNumber);
ACPI_PLD_SET_CARD_CAGE (&Dword, PldInfo->CardCageNumber);
ACPI_PLD_SET_REFERENCE (&Dword, PldInfo->Reference);
ACPI_PLD_SET_ROTATION (&Dword, PldInfo->Rotation);
ACPI_PLD_SET_ORDER (&Dword, PldInfo->Order);
ACPI_MOVE_32_TO_32 (&Buffer[3], &Dword);
/* Revision 2 adds an additional DWORD */
if (PldInfo->Revision >= 2)
{
/* Fifth 32 bits */
Dword = 0;
ACPI_PLD_SET_VERT_OFFSET (&Dword, PldInfo->VerticalOffset);
ACPI_PLD_SET_HORIZ_OFFSET (&Dword, PldInfo->HorizontalOffset);
ACPI_MOVE_32_TO_32 (&Buffer[4], &Dword);
}
return (ACPI_CAST_PTR (UINT8, Buffer));
}
/*******************************************************************************
*
* FUNCTION: OpcFindName
*
* PARAMETERS: List - Array of char strings to be searched
* Name - Char string to string for
* Index - Index value to set if found
*
* RETURN: TRUE if any names matched, FALSE otherwise
*
* DESCRIPTION: Match PLD name to value in lookup table. Sets Value to
* equivalent parameter value.
*
******************************************************************************/
static BOOLEAN
OpcFindName (
const char **List,
char *Name,
UINT32 *Index)
{
const char *NameString;
UINT32 i;
AcpiUtStrupr (Name);
for (i = 0, NameString = List[0];
NameString;
i++, NameString = List[i])
{
if (!(strncmp (NameString, Name, strlen (Name))))
{
*Index = i;
return (TRUE);
}
}
return (FALSE);
}

View File

@@ -0,0 +1,896 @@
/******************************************************************************
*
* Module Name: aslpredef - support for ACPI predefined names
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#define ACPI_CREATE_PREDEFINED_TABLE
#define ACPI_CREATE_RESOURCE_TABLE
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "acpredef.h"
#include "acnamesp.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslpredef")
/* Local prototypes */
static void
ApCheckForUnexpectedReturnValue (
ACPI_PARSE_OBJECT *Op,
ASL_METHOD_INFO *MethodInfo);
static UINT32
ApCheckForSpecialName (
ACPI_PARSE_OBJECT *Op,
char *Name);
/*******************************************************************************
*
* FUNCTION: ApCheckForPredefinedMethod
*
* PARAMETERS: Op - A parse node of type "METHOD".
* MethodInfo - Saved info about this method
*
* RETURN: None
*
* DESCRIPTION: If method is a predefined name, check that the number of
* arguments and the return type (returns a value or not)
* is correct.
*
******************************************************************************/
BOOLEAN
ApCheckForPredefinedMethod (
ACPI_PARSE_OBJECT *Op,
ASL_METHOD_INFO *MethodInfo)
{
UINT32 Index;
UINT32 RequiredArgCount;
const ACPI_PREDEFINED_INFO *ThisName;
/* Check for a match against the predefined name list */
Index = ApCheckForPredefinedName (Op, Op->Asl.NameSeg);
switch (Index)
{
case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */
case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */
case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */
/* Just return, nothing to do */
return (FALSE);
case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */
AslGbl_ReservedMethods++;
/* NumArguments must be zero for all _Lxx/_Exx/_Wxx/_Qxx methods */
if (MethodInfo->NumArguments != 0)
{
sprintf (AslGbl_MsgBuffer, "%s requires %d", Op->Asl.ExternalName, 0);
AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op,
AslGbl_MsgBuffer);
}
break;
default:
/*
* Matched a predefined method name - validate the ASL-defined
* argument count against the ACPI specification.
*
* Some methods are allowed to have a "minimum" number of args
* (_SCP) because their definition in ACPI has changed over time.
*/
AslGbl_ReservedMethods++;
ThisName = &AcpiGbl_PredefinedMethods[Index];
RequiredArgCount = METHOD_GET_ARG_COUNT (ThisName->Info.ArgumentList);
if (MethodInfo->NumArguments != RequiredArgCount)
{
sprintf (AslGbl_MsgBuffer, "%4.4s requires %u",
ThisName->Info.Name, RequiredArgCount);
if (MethodInfo->NumArguments < RequiredArgCount)
{
AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_LO, Op,
AslGbl_MsgBuffer);
}
else if ((MethodInfo->NumArguments > RequiredArgCount) &&
!(ThisName->Info.ArgumentList & ARG_COUNT_IS_MINIMUM))
{
AslError (ASL_WARNING, ASL_MSG_RESERVED_ARG_COUNT_HI, Op,
AslGbl_MsgBuffer);
}
}
/*
* Check if method returns no value, but the predefined name is
* required to return a value
*/
if (MethodInfo->NumReturnNoValue &&
ThisName->Info.ExpectedBtypes)
{
AcpiUtGetExpectedReturnTypes (AslGbl_StringBuffer,
ThisName->Info.ExpectedBtypes);
sprintf (AslGbl_MsgBuffer, "%s required for %4.4s",
AslGbl_StringBuffer, ThisName->Info.Name);
AslError (ASL_WARNING, ASL_MSG_RESERVED_RETURN_VALUE, Op,
AslGbl_MsgBuffer);
}
break;
}
return (TRUE);
}
/*******************************************************************************
*
* FUNCTION: ApCheckForUnexpectedReturnValue
*
* PARAMETERS: Op - A parse node of type "RETURN".
* MethodInfo - Saved info about this method
*
* RETURN: None
*
* DESCRIPTION: Check for an unexpected return value from a predefined method.
* Invoked for predefined methods that are defined to not return
* any value. If there is a return value, issue a remark, since
* the ASL writer may be confused as to the method definition
* and/or functionality.
*
* Note: We ignore all return values of "Zero", since this is what a standalone
* Return() statement will always generate -- so we ignore it here --
* i.e., there is no difference between Return() and Return(Zero).
* Also, a null Return() will be disassembled to return(Zero) -- so, we
* don't want to generate extraneous remarks/warnings for a disassembled
* ASL file.
*
******************************************************************************/
static void
ApCheckForUnexpectedReturnValue (
ACPI_PARSE_OBJECT *Op,
ASL_METHOD_INFO *MethodInfo)
{
ACPI_PARSE_OBJECT *ReturnValueOp;
/* Ignore Return() and Return(Zero) (they are the same) */
ReturnValueOp = Op->Asl.Child;
if (ReturnValueOp->Asl.ParseOpcode == PARSEOP_ZERO)
{
return;
}
/* We have a valid return value, but the reserved name did not expect it */
AslError (ASL_WARNING, ASL_MSG_RESERVED_NO_RETURN_VAL,
Op, MethodInfo->Op->Asl.ExternalName);
}
/*******************************************************************************
*
* FUNCTION: ApCheckPredefinedReturnValue
*
* PARAMETERS: Op - A parse node of type "RETURN".
* MethodInfo - Saved info about this method
*
* RETURN: None
*
* DESCRIPTION: If method is a predefined name, attempt to validate the return
* value. Only "static" types can be validated - a simple return
* of an integer/string/buffer/package or a named reference to
* a static object. Values such as a Localx or Argx or a control
* method invocation are not checked. Issue a warning if there is
* a valid return value, but the reserved method defines no
* return value.
*
******************************************************************************/
void
ApCheckPredefinedReturnValue (
ACPI_PARSE_OBJECT *Op,
ASL_METHOD_INFO *MethodInfo)
{
UINT32 Index;
ACPI_PARSE_OBJECT *ReturnValueOp;
const ACPI_PREDEFINED_INFO *ThisName;
/*
* Check parent method for a match against the predefined name list.
*
* Note: Disable compiler errors/warnings because any errors will be
* caught when analyzing the parent method. Eliminates duplicate errors.
*/
AslGbl_AllExceptionsDisabled = TRUE;
Index = ApCheckForPredefinedName (MethodInfo->Op,
MethodInfo->Op->Asl.NameSeg);
AslGbl_AllExceptionsDisabled = FALSE;
switch (Index)
{
case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */
/* No return value expected, warn if there is one */
ApCheckForUnexpectedReturnValue (Op, MethodInfo);
return;
case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */
case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */
case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */
/* Just return, nothing to do */
return;
default: /* A standard predefined ACPI name */
ThisName = &AcpiGbl_PredefinedMethods[Index];
if (!ThisName->Info.ExpectedBtypes)
{
/* No return value expected, warn if there is one */
ApCheckForUnexpectedReturnValue (Op, MethodInfo);
return;
}
/* Get the object returned, it is the next argument */
ReturnValueOp = Op->Asl.Child;
switch (ReturnValueOp->Asl.ParseOpcode)
{
case PARSEOP_ZERO:
case PARSEOP_ONE:
case PARSEOP_ONES:
case PARSEOP_INTEGER:
case PARSEOP_STRING_LITERAL:
case PARSEOP_BUFFER:
case PARSEOP_PACKAGE:
/* Static data return object - check against expected type */
ApCheckObjectType (ThisName->Info.Name, ReturnValueOp,
ThisName->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT);
/* For packages, check the individual package elements */
if (ReturnValueOp->Asl.ParseOpcode == PARSEOP_PACKAGE)
{
ApCheckPackage (ReturnValueOp, ThisName);
}
break;
default:
/*
* All other ops are very difficult or impossible to typecheck at
* compile time. These include all Localx, Argx, and method
* invocations. Also, NAMESEG and NAMESTRING because the type of
* any named object can be changed at runtime (for example,
* CopyObject will change the type of the target object.)
*/
break;
}
}
}
/*******************************************************************************
*
* FUNCTION: ApCheckForPredefinedObject
*
* PARAMETERS: Op - A parse node
* Name - The ACPI name to be checked
*
* RETURN: None
*
* DESCRIPTION: Check for a predefined name for a static object (created via
* the ASL Name operator). If it is a predefined ACPI name, ensure
* that the name does not require any arguments (which would
* require a control method implementation of the name), and that
* the type of the object is one of the expected types for the
* predefined name.
*
******************************************************************************/
void
ApCheckForPredefinedObject (
ACPI_PARSE_OBJECT *Op,
char *Name)
{
UINT32 Index;
ACPI_PARSE_OBJECT *ObjectOp;
const ACPI_PREDEFINED_INFO *ThisName;
/*
* Check for a real predefined name -- not a resource descriptor name
* or a predefined scope name
*/
Index = ApCheckForPredefinedName (Op, Name);
switch (Index)
{
case ACPI_NOT_RESERVED_NAME: /* No underscore or _Txx or _xxx name not matched */
case ACPI_PREDEFINED_NAME: /* Resource Name or reserved scope name */
case ACPI_COMPILER_RESERVED_NAME: /* A _Txx that was not emitted by compiler */
/* Nothing to do */
return;
case ACPI_EVENT_RESERVED_NAME: /* _Lxx/_Exx/_Wxx/_Qxx methods */
/*
* These names must be control methods, by definition in ACPI spec.
* Also because they are defined to return no value. None of them
* require any arguments.
*/
AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op,
"with zero arguments");
return;
default:
break;
}
/* A standard predefined ACPI name */
/*
* If this predefined name requires input arguments, then
* it must be implemented as a control method
*/
ThisName = &AcpiGbl_PredefinedMethods[Index];
if (METHOD_GET_ARG_COUNT (ThisName->Info.ArgumentList) > 0)
{
AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op,
"with arguments");
return;
}
/*
* If no return value is expected from this predefined name, then
* it follows that it must be implemented as a control method
* (with zero args, because the args > 0 case was handled above)
* Examples are: _DIS, _INI, _IRC, _OFF, _ON, _PSx
*/
if (!ThisName->Info.ExpectedBtypes)
{
AslError (ASL_ERROR, ASL_MSG_RESERVED_METHOD, Op,
"with zero arguments");
return;
}
/* Typecheck the actual object, it is the next argument */
ObjectOp = Op->Asl.Child->Asl.Next;
ApCheckObjectType (ThisName->Info.Name, Op->Asl.Child->Asl.Next,
ThisName->Info.ExpectedBtypes, ACPI_NOT_PACKAGE_ELEMENT);
/* For packages, check the individual package elements */
if (ObjectOp->Asl.ParseOpcode == PARSEOP_PACKAGE)
{
ApCheckPackage (ObjectOp, ThisName);
}
}
/*******************************************************************************
*
* FUNCTION: ApCheckForPredefinedName
*
* PARAMETERS: Op - A parse node
* Name - NameSeg to check
*
* RETURN: None
*
* DESCRIPTION: Check a NameSeg against the reserved list.
*
******************************************************************************/
UINT32
ApCheckForPredefinedName (
ACPI_PARSE_OBJECT *Op,
char *Name)
{
UINT32 i;
const ACPI_PREDEFINED_INFO *ThisName;
if (Name[0] == 0)
{
AslError (ASL_ERROR, ASL_MSG_COMPILER_INTERNAL, Op,
"Zero length name found");
}
/* All reserved names are prefixed with a single underscore */
if (Name[0] != '_')
{
return (ACPI_NOT_RESERVED_NAME);
}
/* Check for a standard predefined method name */
ThisName = AcpiGbl_PredefinedMethods;
for (i = 0; ThisName->Info.Name[0]; i++)
{
if (ACPI_COMPARE_NAMESEG (Name, ThisName->Info.Name))
{
/* Return index into predefined array */
return (i);
}
ThisName++; /* Does not account for extra package data, but is OK */
}
/* Check for resource names and predefined scope names */
ThisName = AcpiGbl_ResourceNames;
while (ThisName->Info.Name[0])
{
if (ACPI_COMPARE_NAMESEG (Name, ThisName->Info.Name))
{
return (ACPI_PREDEFINED_NAME);
}
ThisName++;
}
ThisName = AcpiGbl_ScopeNames;
while (ThisName->Info.Name[0])
{
if (ACPI_COMPARE_NAMESEG (Name, ThisName->Info.Name))
{
return (ACPI_PREDEFINED_NAME);
}
ThisName++;
}
/* Check for _Lxx/_Exx/_Wxx/_Qxx/_T_x. Warning if unknown predefined name */
return (ApCheckForSpecialName (Op, Name));
}
/*******************************************************************************
*
* FUNCTION: ApCheckForSpecialName
*
* PARAMETERS: Op - A parse node
* Name - NameSeg to check
*
* RETURN: None
*
* DESCRIPTION: Check for the "special" predefined names -
* _Lxx, _Exx, _Qxx, _Wxx, and _T_x
*
******************************************************************************/
static UINT32
ApCheckForSpecialName (
ACPI_PARSE_OBJECT *Op,
char *Name)
{
/*
* Check for the "special" predefined names. We already know that the
* first character is an underscore.
* GPE: _Lxx
* GPE: _Exx
* GPE: _Wxx
* EC: _Qxx
*/
if ((Name[1] == 'L') ||
(Name[1] == 'E') ||
(Name[1] == 'W') ||
(Name[1] == 'Q'))
{
/* The next two characters must be hex digits */
if ((isxdigit ((int) Name[2])) &&
(isxdigit ((int) Name[3])))
{
return (ACPI_EVENT_RESERVED_NAME);
}
}
/* Check for the names reserved for the compiler itself: _T_x */
else if ((Op->Asl.ExternalName[1] == 'T') &&
(Op->Asl.ExternalName[2] == '_'))
{
/* Ignore if actually emitted by the compiler */
if (Op->Asl.CompileFlags & OP_COMPILER_EMITTED)
{
return (ACPI_NOT_RESERVED_NAME);
}
/*
* Was not actually emitted by the compiler. This is a special case,
* however. If the ASL code being compiled was the result of a
* disassembly, it may possibly contain valid compiler-emitted names
* of the form "_T_x". We don't want to issue an error or even a
* warning and force the user to manually change the names. So, we
* will issue a remark instead.
*/
AslError (ASL_REMARK, ASL_MSG_COMPILER_RESERVED,
Op, Op->Asl.ExternalName);
return (ACPI_COMPILER_RESERVED_NAME);
}
/*
* The name didn't match any of the known predefined names. Flag it as a
* warning, since the entire namespace starting with an underscore is
* reserved by the ACPI spec.
*/
AslError (ASL_WARNING, ASL_MSG_UNKNOWN_RESERVED_NAME,
Op, Op->Asl.ExternalName);
return (ACPI_NOT_RESERVED_NAME);
}
/*******************************************************************************
*
* FUNCTION: ApCheckObjectType
*
* PARAMETERS: PredefinedName - Name of the predefined object we are checking
* Op - Current parse node
* ExpectedBtypes - Bitmap of expected return type(s)
* PackageIndex - Index of object within parent package (if
* applicable - ACPI_NOT_PACKAGE_ELEMENT
* otherwise)
*
* RETURN: None
*
* DESCRIPTION: Check if the object type is one of the types that is expected
* by the predefined name. Only a limited number of object types
* can be returned by the predefined names.
*
******************************************************************************/
ACPI_STATUS
ApCheckObjectType (
const char *PredefinedName,
ACPI_PARSE_OBJECT *Op,
UINT32 ExpectedBtypes,
UINT32 PackageIndex)
{
UINT32 ReturnBtype;
char *TypeName;
if (!Op)
{
return (AE_TYPE);
}
/* Map the parse opcode to a bitmapped return type (RTYPE) */
switch (Op->Asl.ParseOpcode)
{
case PARSEOP_ZERO:
case PARSEOP_ONE:
case PARSEOP_ONES:
case PARSEOP_INTEGER:
ReturnBtype = ACPI_RTYPE_INTEGER;
TypeName = "Integer";
break;
case PARSEOP_STRING_LITERAL:
ReturnBtype = ACPI_RTYPE_STRING;
TypeName = "String";
break;
case PARSEOP_BUFFER:
ReturnBtype = ACPI_RTYPE_BUFFER;
TypeName = "Buffer";
break;
case PARSEOP_PACKAGE:
case PARSEOP_VAR_PACKAGE:
ReturnBtype = ACPI_RTYPE_PACKAGE;
TypeName = "Package";
break;
case PARSEOP_NAMESEG:
case PARSEOP_NAMESTRING:
/*
* Ignore any named references within a package object.
*
* For Package objects, references are allowed instead of any of the
* standard data types (Integer/String/Buffer/Package). These
* references are resolved at runtime. NAMESEG and NAMESTRING are
* impossible to typecheck at compile time because the type of
* any named object can be changed at runtime (for example,
* CopyObject will change the type of the target object).
*/
if (PackageIndex != ACPI_NOT_PACKAGE_ELEMENT)
{
return (AE_OK);
}
ReturnBtype = ACPI_RTYPE_REFERENCE;
TypeName = "Reference";
break;
default:
/* Not one of the supported object types */
TypeName = UtGetOpName (Op->Asl.ParseOpcode);
goto TypeErrorExit;
}
/* Exit if the object is one of the expected types */
if (ReturnBtype & ExpectedBtypes)
{
return (AE_OK);
}
TypeErrorExit:
/* Format the expected types and emit an error message */
AcpiUtGetExpectedReturnTypes (AslGbl_StringBuffer, ExpectedBtypes);
if (PackageIndex == ACPI_NOT_PACKAGE_ELEMENT)
{
sprintf (AslGbl_MsgBuffer, "%4.4s: found %s, %s required",
PredefinedName, TypeName, AslGbl_StringBuffer);
}
else
{
sprintf (AslGbl_MsgBuffer, "%4.4s: found %s at index %u, %s required",
PredefinedName, TypeName, PackageIndex, AslGbl_StringBuffer);
}
AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, AslGbl_MsgBuffer);
return (AE_TYPE);
}
/*******************************************************************************
*
* FUNCTION: ApDisplayReservedNames
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Dump information about the ACPI predefined names and predefined
* resource descriptor names.
*
******************************************************************************/
void
ApDisplayReservedNames (
void)
{
const ACPI_PREDEFINED_INFO *ThisName;
UINT32 Count;
UINT32 NumTypes;
/*
* Predefined names/methods
*/
printf ("\nPredefined Name Information\n\n");
Count = 0;
ThisName = AcpiGbl_PredefinedMethods;
while (ThisName->Info.Name[0])
{
AcpiUtDisplayPredefinedMethod (AslGbl_MsgBuffer, ThisName, FALSE);
Count++;
ThisName = AcpiUtGetNextPredefinedMethod (ThisName);
}
printf ("%u Predefined Names are recognized\n", Count);
/*
* Resource Descriptor names
*/
printf ("\nPredefined Names for Resource Descriptor Fields\n\n");
Count = 0;
ThisName = AcpiGbl_ResourceNames;
while (ThisName->Info.Name[0])
{
NumTypes = AcpiUtGetResourceBitWidth (AslGbl_MsgBuffer,
ThisName->Info.ArgumentList);
printf ("%4.4s Field is %s bits wide%s\n",
ThisName->Info.Name, AslGbl_MsgBuffer,
(NumTypes > 1) ? " (depending on descriptor type)" : "");
Count++;
ThisName++;
}
printf ("%u Resource Descriptor Field Names are recognized\n", Count);
/*
* Predefined scope names
*/
printf ("\nPredefined Scope/Device Names (automatically created at root)\n\n");
ThisName = AcpiGbl_ScopeNames;
while (ThisName->Info.Name[0])
{
printf ("%4.4s Scope/Device\n", ThisName->Info.Name);
ThisName++;
}
}

View File

@@ -0,0 +1,993 @@
/******************************************************************************
*
* Module Name: aslprepkg - support for ACPI predefined name package objects
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "acpredef.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslprepkg")
/* Local prototypes */
static ACPI_PARSE_OBJECT *
ApCheckPackageElements (
const char *PredefinedName,
ACPI_PARSE_OBJECT *Op,
UINT8 Type1,
UINT32 Count1,
UINT8 Type2,
UINT32 Count2);
static void
ApCheckPackageList (
const char *PredefinedName,
ACPI_PARSE_OBJECT *ParentOp,
const ACPI_PREDEFINED_INFO *Package,
UINT32 StartIndex,
UINT32 Count);
static void
ApPackageTooSmall (
const char *PredefinedName,
ACPI_PARSE_OBJECT *Op,
UINT32 Count,
UINT32 ExpectedCount);
static void
ApZeroLengthPackage (
const char *PredefinedName,
ACPI_PARSE_OBJECT *Op);
static void
ApPackageTooLarge (
const char *PredefinedName,
ACPI_PARSE_OBJECT *Op,
UINT32 Count,
UINT32 ExpectedCount);
static void
ApCustomPackage (
ACPI_PARSE_OBJECT *ParentOp,
const ACPI_PREDEFINED_INFO *Predefined);
/*******************************************************************************
*
* FUNCTION: ApCheckPackage
*
* PARAMETERS: ParentOp - Parser op for the package
* Predefined - Pointer to package-specific info for
* the method
*
* RETURN: None
*
* DESCRIPTION: Top-level validation for predefined name return package
* objects.
*
******************************************************************************/
void
ApCheckPackage (
ACPI_PARSE_OBJECT *ParentOp,
const ACPI_PREDEFINED_INFO *Predefined)
{
ACPI_PARSE_OBJECT *Op;
const ACPI_PREDEFINED_INFO *Package;
ACPI_STATUS Status;
UINT32 ExpectedCount;
UINT32 Count;
UINT32 i;
/* The package info for this name is in the next table entry */
Package = Predefined + 1;
/* First child is the package length */
Op = ParentOp->Asl.Child;
Count = (UINT32) Op->Asl.Value.Integer;
/*
* Many of the variable-length top-level packages are allowed to simply
* have zero elements. This allows the BIOS to tell the host that even
* though the predefined name/method exists, the feature is not supported.
* Other package types require one or more elements. In any case, there
* is no need to continue validation.
*/
if (!Count)
{
switch (Package->RetInfo.Type)
{
case ACPI_PTYPE1_FIXED:
case ACPI_PTYPE1_OPTION:
case ACPI_PTYPE2_PKG_COUNT:
case ACPI_PTYPE2_REV_FIXED:
ApZeroLengthPackage (Predefined->Info.Name, ParentOp);
break;
case ACPI_PTYPE1_VAR:
case ACPI_PTYPE2:
case ACPI_PTYPE2_COUNT:
case ACPI_PTYPE2_FIXED:
case ACPI_PTYPE2_MIN:
case ACPI_PTYPE2_FIX_VAR:
case ACPI_PTYPE2_VAR_VAR:
default:
break;
}
return;
}
/* Get the first element of the package */
Op = Op->Asl.Next;
/* Decode the package type */
switch (Package->RetInfo.Type)
{
case ACPI_PTYPE_CUSTOM:
ApCustomPackage (ParentOp, Predefined);
break;
case ACPI_PTYPE1_FIXED:
/*
* The package count is fixed and there are no subpackages
*
* If package is too small, exit.
* If package is larger than expected, issue warning but continue
*/
ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;
if (Count < ExpectedCount)
{
goto PackageTooSmall;
}
else if (Count > ExpectedCount)
{
ApPackageTooLarge (Predefined->Info.Name, ParentOp,
Count, ExpectedCount);
}
/* Validate all elements of the package */
ApCheckPackageElements (Predefined->Info.Name, Op,
Package->RetInfo.ObjectType1, Package->RetInfo.Count1,
Package->RetInfo.ObjectType2, Package->RetInfo.Count2);
break;
case ACPI_PTYPE1_VAR:
/*
* The package count is variable, there are no subpackages,
* and all elements must be of the same type
*/
for (i = 0; i < Count; i++)
{
if (!Op)
{
/*
* If we get to this point, it means that the package length
* is larger than the initializer list. Stop processing the
* package and return because we have run out of package
* elements to analyze.
*/
return;
}
ApCheckObjectType (Predefined->Info.Name, Op,
Package->RetInfo.ObjectType1, i);
Op = Op->Asl.Next;
}
break;
case ACPI_PTYPE1_OPTION:
/*
* The package count is variable, there are no subpackages.
* There are a fixed number of required elements, and a variable
* number of optional elements.
*
* Check if package is at least as large as the minimum required
*/
ExpectedCount = Package->RetInfo3.Count;
if (Count < ExpectedCount)
{
goto PackageTooSmall;
}
/* Variable number of sub-objects */
for (i = 0; i < Count; i++)
{
if (i < Package->RetInfo3.Count)
{
/* These are the required package elements (0, 1, or 2) */
ApCheckObjectType (Predefined->Info.Name, Op,
Package->RetInfo3.ObjectType[i], i);
}
else
{
/* These are the optional package elements */
ApCheckObjectType (Predefined->Info.Name, Op,
Package->RetInfo3.TailObjectType, i);
}
Op = Op->Asl.Next;
}
break;
case ACPI_PTYPE2_REV_FIXED:
/* First element is the (Integer) revision */
ApCheckObjectType (Predefined->Info.Name, Op,
ACPI_RTYPE_INTEGER, 0);
Op = Op->Asl.Next;
Count--;
/* Examine the subpackages */
ApCheckPackageList (Predefined->Info.Name, Op,
Package, 1, Count);
break;
case ACPI_PTYPE2_PKG_COUNT:
/* First element is the (Integer) count of subpackages to follow */
Status = ApCheckObjectType (Predefined->Info.Name, Op,
ACPI_RTYPE_INTEGER, 0);
/* We must have an integer count from above (otherwise, use Count) */
if (ACPI_SUCCESS (Status))
{
/*
* Count cannot be larger than the parent package length, but
* allow it to be smaller. The >= accounts for the Integer above.
*/
ExpectedCount = (UINT32) Op->Asl.Value.Integer;
if (ExpectedCount >= Count)
{
goto PackageTooSmall;
}
Count = ExpectedCount;
}
Op = Op->Asl.Next;
/* Examine the subpackages */
ApCheckPackageList (Predefined->Info.Name, Op,
Package, 1, Count);
break;
case ACPI_PTYPE2_UUID_PAIR:
/* The package contains a variable list of UUID Buffer/Package pairs */
/* The length of the package must be even */
if (Count & 1)
{
sprintf (AslGbl_MsgBuffer, "%4.4s: Package length, %d, must be even.",
Predefined->Info.Name, Count);
AslError (ASL_ERROR, ASL_MSG_RESERVED_PACKAGE_LENGTH,
ParentOp->Asl.Child, AslGbl_MsgBuffer);
}
/* Validate the alternating types */
for (i = 0; i < Count; ++i)
{
if (i & 1)
{
ApCheckObjectType (Predefined->Info.Name, Op,
Package->RetInfo.ObjectType2, i);
}
else
{
ApCheckObjectType (Predefined->Info.Name, Op,
Package->RetInfo.ObjectType1, i);
}
Op = Op->Asl.Next;
}
break;
case ACPI_PTYPE2_VAR_VAR:
/* Check for minimum size (ints at beginning + 1 subpackage) */
ExpectedCount = Package->RetInfo4.Count1 + 1;
if (Count < ExpectedCount)
{
goto PackageTooSmall;
}
/* Check the non-package elements at beginning of main package */
for (i = 0; i < Package->RetInfo4.Count1; ++i)
{
ApCheckObjectType (Predefined->Info.Name, Op,
Package->RetInfo4.ObjectType1, i);
Op = Op->Asl.Next;
}
/* Examine the variable-length list of subpackages */
ApCheckPackageList (Predefined->Info.Name, Op,
Package, Package->RetInfo4.Count1, Count);
break;
case ACPI_PTYPE2:
case ACPI_PTYPE2_FIXED:
case ACPI_PTYPE2_MIN:
case ACPI_PTYPE2_COUNT:
case ACPI_PTYPE2_FIX_VAR:
/*
* These types all return a single Package that consists of a
* variable number of subpackages.
*/
/* Examine the subpackages */
ApCheckPackageList (Predefined->Info.Name, Op,
Package, 0, Count);
break;
default:
return;
}
return;
PackageTooSmall:
ApPackageTooSmall (Predefined->Info.Name, ParentOp,
Count, ExpectedCount);
}
/*******************************************************************************
*
* FUNCTION: ApCustomPackage
*
* PARAMETERS: ParentOp - Parse op for the package
* Predefined - Pointer to package-specific info for
* the method
*
* RETURN: None
*
* DESCRIPTION: Validate packages that don't fit into the standard model and
* require custom code.
*
* NOTE: Currently used for the _BIX method only. When needed for two or more
* methods, probably a detect/dispatch mechanism will be required.
*
******************************************************************************/
static void
ApCustomPackage (
ACPI_PARSE_OBJECT *ParentOp,
const ACPI_PREDEFINED_INFO *Predefined)
{
ACPI_PARSE_OBJECT *Op;
UINT32 Count;
UINT32 ExpectedCount;
UINT32 Version;
/* First child is the package length */
Op = ParentOp->Asl.Child;
Count = (UINT32) Op->Asl.Value.Integer;
/* Get the version number, must be Integer */
Op = Op->Asl.Next;
Version = (UINT32) Op->Asl.Value.Integer;
if (Op->Asl.ParseOpcode != PARSEOP_INTEGER)
{
AslError (ASL_ERROR, ASL_MSG_RESERVED_OPERAND_TYPE, Op, AslGbl_MsgBuffer);
return;
}
/* Validate count (# of elements) */
ExpectedCount = 21; /* Version 1 */
if (Version == 0)
{
ExpectedCount = 20; /* Version 0 */
}
if (Count < ExpectedCount)
{
ApPackageTooSmall (Predefined->Info.Name, ParentOp,
Count, ExpectedCount);
return;
}
else if (Count > ExpectedCount)
{
ApPackageTooLarge (Predefined->Info.Name, ParentOp,
Count, ExpectedCount);
}
/* Validate all elements of the package */
Op = ApCheckPackageElements (Predefined->Info.Name, Op,
ACPI_RTYPE_INTEGER, 16,
ACPI_RTYPE_STRING, 4);
/* Version 1 has a single trailing integer */
if (Version > 0)
{
ApCheckPackageElements (Predefined->Info.Name, Op,
ACPI_RTYPE_INTEGER, 1, 0, 0);
}
}
/*******************************************************************************
*
* FUNCTION: ApCheckPackageElements
*
* PARAMETERS: PredefinedName - Name of the predefined object
* Op - Parser op for the package
* Type1 - Object type for first group
* Count1 - Count for first group
* Type2 - Object type for second group
* Count2 - Count for second group
*
* RETURN: Next Op peer in the parse tree, after all specified elements
* have been validated. Used for multiple validations (calls
* to this function).
*
* DESCRIPTION: Validate all elements of a package. Works with packages that
* are defined to contain up to two groups of different object
* types.
*
******************************************************************************/
static ACPI_PARSE_OBJECT *
ApCheckPackageElements (
const char *PredefinedName,
ACPI_PARSE_OBJECT *Op,
UINT8 Type1,
UINT32 Count1,
UINT8 Type2,
UINT32 Count2)
{
UINT32 i;
/*
* Up to two groups of package elements are supported by the data
* structure. All elements in each group must be of the same type.
* The second group can have a count of zero.
*
* Aborts check upon a NULL package element, as this means (at compile
* time) that the remainder of the package elements are also NULL
* (This is the only way to create NULL package elements.)
*/
for (i = 0; (i < Count1) && Op; i++)
{
ApCheckObjectType (PredefinedName, Op, Type1, i);
Op = Op->Asl.Next;
}
for (i = 0; (i < Count2) && Op; i++)
{
ApCheckObjectType (PredefinedName, Op, Type2, (i + Count1));
Op = Op->Asl.Next;
}
return (Op);
}
/*******************************************************************************
*
* FUNCTION: ApCheckPackageList
*
* PARAMETERS: PredefinedName - Name of the predefined object
* ParentOp - Parser op of the parent package
* Package - Package info for this predefined name
* StartIndex - Index in parent package where list begins
* ParentCount - Element count of parent package
*
* RETURN: None
*
* DESCRIPTION: Validate the individual package elements for a predefined name.
* Handles the cases where the predefined name is defined as a
* Package of Packages (subpackages). These are the types:
*
* ACPI_PTYPE2
* ACPI_PTYPE2_FIXED
* ACPI_PTYPE2_MIN
* ACPI_PTYPE2_COUNT
* ACPI_PTYPE2_FIX_VAR
* ACPI_PTYPE2_VAR_VAR
*
******************************************************************************/
static void
ApCheckPackageList (
const char *PredefinedName,
ACPI_PARSE_OBJECT *ParentOp,
const ACPI_PREDEFINED_INFO *Package,
UINT32 StartIndex,
UINT32 ParentCount)
{
ACPI_PARSE_OBJECT *SubPackageOp = ParentOp;
ACPI_PARSE_OBJECT *Op;
ACPI_STATUS Status;
UINT32 Count;
UINT32 ExpectedCount;
UINT32 i;
UINT32 j;
/*
* Validate each subpackage in the parent Package
*
* Note: We ignore NULL package elements on the assumption that
* they will be initialized by the BIOS or other ASL code.
*/
for (i = 0; (i < ParentCount) && SubPackageOp; i++)
{
/* Each object in the list must be of type Package */
Status = ApCheckObjectType (PredefinedName, SubPackageOp,
ACPI_RTYPE_PACKAGE, i + StartIndex);
if (ACPI_FAILURE (Status))
{
goto NextSubpackage;
}
/* Examine the different types of expected subpackages */
Op = SubPackageOp->Asl.Child;
/* First child is the package length */
Count = (UINT32) Op->Asl.Value.Integer;
Op = Op->Asl.Next;
/*
* Most subpackage must have at least one element, with
* only rare exceptions. (_RDI)
*/
if (!Count &&
(Package->RetInfo.Type != ACPI_PTYPE2_VAR_VAR))
{
ApZeroLengthPackage (PredefinedName, SubPackageOp);
goto NextSubpackage;
}
/*
* Decode the package type.
* PTYPE2 indicates that a "package of packages" is expected for
* this name. The various flavors of PTYPE2 indicate the number
* and format of the subpackages.
*/
switch (Package->RetInfo.Type)
{
case ACPI_PTYPE2:
case ACPI_PTYPE2_PKG_COUNT:
case ACPI_PTYPE2_REV_FIXED:
/* Each subpackage has a fixed number of elements */
ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;
if (Count < ExpectedCount)
{
ApPackageTooSmall (PredefinedName, SubPackageOp,
Count, ExpectedCount);
break;
}
if (Count > ExpectedCount)
{
ApPackageTooLarge (PredefinedName, SubPackageOp,
Count, ExpectedCount);
break;
}
ApCheckPackageElements (PredefinedName, Op,
Package->RetInfo.ObjectType1, Package->RetInfo.Count1,
Package->RetInfo.ObjectType2, Package->RetInfo.Count2);
break;
case ACPI_PTYPE2_FIX_VAR:
/*
* Each subpackage has a fixed number of elements and an
* optional element
*/
ExpectedCount = Package->RetInfo.Count1 + Package->RetInfo.Count2;
if (Count < ExpectedCount)
{
ApPackageTooSmall (PredefinedName, SubPackageOp,
Count, ExpectedCount);
break;
}
ApCheckPackageElements (PredefinedName, Op,
Package->RetInfo.ObjectType1, Package->RetInfo.Count1,
Package->RetInfo.ObjectType2,
Count - Package->RetInfo.Count1);
break;
case ACPI_PTYPE2_VAR_VAR:
/*
* Must have at least the minimum number elements.
* A zero PkgCount means the number of elements is variable.
*/
ExpectedCount = Package->RetInfo4.PkgCount;
if (ExpectedCount && (Count < ExpectedCount))
{
ApPackageTooSmall (PredefinedName, SubPackageOp,
Count, 1);
break;
}
ApCheckPackageElements (PredefinedName, Op,
Package->RetInfo4.SubObjectTypes,
Package->RetInfo4.PkgCount,
0, 0);
break;
case ACPI_PTYPE2_FIXED:
/* Each subpackage has a fixed length */
ExpectedCount = Package->RetInfo2.Count;
if (Count < ExpectedCount)
{
ApPackageTooSmall (PredefinedName, SubPackageOp,
Count, ExpectedCount);
break;
}
if (Count > ExpectedCount)
{
ApPackageTooLarge (PredefinedName, SubPackageOp,
Count, ExpectedCount);
break;
}
/* Check each object/type combination */
for (j = 0; j < ExpectedCount; j++)
{
ApCheckObjectType (PredefinedName, Op,
Package->RetInfo2.ObjectType[j], j);
Op = Op->Asl.Next;
}
break;
case ACPI_PTYPE2_MIN:
/* Each subpackage has a variable but minimum length */
ExpectedCount = Package->RetInfo.Count1;
if (Count < ExpectedCount)
{
ApPackageTooSmall (PredefinedName, SubPackageOp,
Count, ExpectedCount);
break;
}
/* Check the type of each subpackage element */
ApCheckPackageElements (PredefinedName, Op,
Package->RetInfo.ObjectType1, Count, 0, 0);
break;
case ACPI_PTYPE2_COUNT:
/*
* First element is the (Integer) count of elements, including
* the count field (the ACPI name is NumElements)
*/
Status = ApCheckObjectType (PredefinedName, Op,
ACPI_RTYPE_INTEGER, 0);
/* We must have an integer count from above (otherwise, use Count) */
if (ACPI_SUCCESS (Status))
{
/*
* Make sure package is large enough for the Count and is
* is as large as the minimum size
*/
ExpectedCount = (UINT32) Op->Asl.Value.Integer;
if (Count < ExpectedCount)
{
ApPackageTooSmall (PredefinedName, SubPackageOp,
Count, ExpectedCount);
break;
}
else if (Count > ExpectedCount)
{
ApPackageTooLarge (PredefinedName, SubPackageOp,
Count, ExpectedCount);
}
/* Some names of this type have a minimum length */
if (Count < Package->RetInfo.Count1)
{
ExpectedCount = Package->RetInfo.Count1;
ApPackageTooSmall (PredefinedName, SubPackageOp,
Count, ExpectedCount);
break;
}
Count = ExpectedCount;
}
/* Check the type of each subpackage element */
Op = Op->Asl.Next;
ApCheckPackageElements (PredefinedName, Op,
Package->RetInfo.ObjectType1, (Count - 1), 0, 0);
break;
default:
break;
}
NextSubpackage:
SubPackageOp = SubPackageOp->Asl.Next;
}
}
/*******************************************************************************
*
* FUNCTION: ApPackageTooSmall
*
* PARAMETERS: PredefinedName - Name of the predefined object
* Op - Current parser op
* Count - Actual package element count
* ExpectedCount - Expected package element count
*
* RETURN: None
*
* DESCRIPTION: Issue error message for a package that is smaller than
* required.
*
******************************************************************************/
static void
ApPackageTooSmall (
const char *PredefinedName,
ACPI_PARSE_OBJECT *Op,
UINT32 Count,
UINT32 ExpectedCount)
{
sprintf (AslGbl_MsgBuffer, "%4.4s: length %u, required minimum is %u",
PredefinedName, Count, ExpectedCount);
AslError (ASL_ERROR, ASL_MSG_RESERVED_PACKAGE_LENGTH, Op, AslGbl_MsgBuffer);
}
/*******************************************************************************
*
* FUNCTION: ApZeroLengthPackage
*
* PARAMETERS: PredefinedName - Name of the predefined object
* Op - Current parser op
*
* RETURN: None
*
* DESCRIPTION: Issue error message for a zero-length package (a package that
* is required to have a non-zero length). Variable length
* packages seem to be allowed to have zero length, however.
* Even if not allowed, BIOS code does it.
*
******************************************************************************/
static void
ApZeroLengthPackage (
const char *PredefinedName,
ACPI_PARSE_OBJECT *Op)
{
sprintf (AslGbl_MsgBuffer, "%4.4s: length is zero", PredefinedName);
AslError (ASL_ERROR, ASL_MSG_RESERVED_PACKAGE_LENGTH, Op, AslGbl_MsgBuffer);
}
/*******************************************************************************
*
* FUNCTION: ApPackageTooLarge
*
* PARAMETERS: PredefinedName - Name of the predefined object
* Op - Current parser op
* Count - Actual package element count
* ExpectedCount - Expected package element count
*
* RETURN: None
*
* DESCRIPTION: Issue a remark for a package that is larger than expected.
*
******************************************************************************/
static void
ApPackageTooLarge (
const char *PredefinedName,
ACPI_PARSE_OBJECT *Op,
UINT32 Count,
UINT32 ExpectedCount)
{
sprintf (AslGbl_MsgBuffer, "%4.4s: length is %u, only %u required",
PredefinedName, Count, ExpectedCount);
AslError (ASL_REMARK, ASL_MSG_RESERVED_PACKAGE_LENGTH, Op, AslGbl_MsgBuffer);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,488 @@
/******************************************************************************
*
* Module Name: aslprintf - ASL Printf/Fprintf macro support
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "amlcode.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslprintf")
/* Local prototypes */
static void
OpcCreateConcatenateNode (
ACPI_PARSE_OBJECT *Op,
ACPI_PARSE_OBJECT *Node);
static void
OpcParsePrintf (
ACPI_PARSE_OBJECT *Op,
ACPI_PARSE_OBJECT *DestOp);
/*******************************************************************************
*
* FUNCTION: OpcDoPrintf
*
* PARAMETERS: Op - printf parse node
*
* RETURN: None
*
* DESCRIPTION: Convert printf macro to a Store(..., Debug) AML operation.
*
******************************************************************************/
void
OpcDoPrintf (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *DestOp;
/* Store destination is the Debug op */
DestOp = TrAllocateOp (PARSEOP_DEBUG);
DestOp->Asl.AmlOpcode = AML_DEBUG_OP;
DestOp->Asl.Parent = Op;
DestOp->Asl.LogicalLineNumber = Op->Asl.LogicalLineNumber;
OpcParsePrintf (Op, DestOp);
}
/*******************************************************************************
*
* FUNCTION: OpcDoFprintf
*
* PARAMETERS: Op - fprintf parse node
*
* RETURN: None
*
* DESCRIPTION: Convert fprintf macro to a Store AML operation.
*
******************************************************************************/
void
OpcDoFprintf (
ACPI_PARSE_OBJECT *Op)
{
ACPI_PARSE_OBJECT *DestOp;
/* Store destination is the first argument of fprintf */
DestOp = Op->Asl.Child;
Op->Asl.Child = DestOp->Asl.Next;
DestOp->Asl.Next = NULL;
OpcParsePrintf (Op, DestOp);
}
/*******************************************************************************
*
* FUNCTION: OpcParsePrintf
*
* PARAMETERS: Op - Printf parse node
* DestOp - Destination of Store operation
*
* RETURN: None
*
* DESCRIPTION: Convert printf macro to a Store AML operation. The printf
* macro parse tree is laid out as follows:
*
* Op - printf parse op
* Op->Child - Format string
* Op->Next - Format string arguments
*
******************************************************************************/
static void
OpcParsePrintf (
ACPI_PARSE_OBJECT *Op,
ACPI_PARSE_OBJECT *DestOp)
{
char *Format;
char *StartPosition = NULL;
ACPI_PARSE_OBJECT *ArgNode;
ACPI_PARSE_OBJECT *NextNode;
UINT32 StringLength = 0;
char *NewString;
BOOLEAN StringToProcess = FALSE;
ACPI_PARSE_OBJECT *NewOp;
/* Get format string */
Format = ACPI_CAST_PTR (char, Op->Asl.Child->Asl.Value.String);
ArgNode = Op->Asl.Child->Asl.Next;
/*
* Detach argument list so that we can use a NULL check to distinguish
* the first concatenation operation we need to make
*/
Op->Asl.Child = NULL;
for (; *Format; ++Format)
{
if (*Format != '%')
{
if (!StringToProcess)
{
/* Mark the beginning of a string */
StartPosition = Format;
StringToProcess = TRUE;
}
++StringLength;
continue;
}
/* Save string, if any, to new string object and concat it */
if (StringToProcess)
{
NewString = UtLocalCacheCalloc (StringLength + 1);
memcpy (NewString, StartPosition, StringLength);
NewOp = TrAllocateOp (PARSEOP_STRING_LITERAL);
NewOp->Asl.Value.String = NewString;
NewOp->Asl.AmlOpcode = AML_STRING_OP;
NewOp->Asl.AcpiBtype = ACPI_BTYPE_STRING;
NewOp->Asl.LogicalLineNumber = Op->Asl.LogicalLineNumber;
OpcCreateConcatenateNode(Op, NewOp);
StringLength = 0;
StringToProcess = FALSE;
}
++Format;
/*
* We have a format parameter and will need an argument to go
* with it
*/
if (!ArgNode ||
ArgNode->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
{
AslError(ASL_ERROR, ASL_MSG_ARG_COUNT_LO, Op, NULL);
return;
}
/*
* We do not support sub-specifiers of printf (flags, width,
* precision, length). For specifiers we only support %x/%X for
* hex or %s for strings. Also, %o for generic "acpi object".
*/
switch (*Format)
{
case 's':
if (ArgNode->Asl.ParseOpcode != PARSEOP_STRING_LITERAL)
{
AslError(ASL_ERROR, ASL_MSG_INVALID_TYPE, ArgNode,
"String required");
return;
}
NextNode = ArgNode->Asl.Next;
ArgNode->Asl.Next = NULL;
OpcCreateConcatenateNode(Op, ArgNode);
ArgNode = NextNode;
continue;
case 'X':
case 'x':
case 'o':
NextNode = ArgNode->Asl.Next;
ArgNode->Asl.Next = NULL;
/*
* Append an empty string if the first argument is
* not a string. This will implicitly convert the 2nd
* concat source to a string per the ACPI specification.
*/
if (!Op->Asl.Child)
{
NewOp = TrAllocateOp (PARSEOP_STRING_LITERAL);
NewOp->Asl.Value.String = "";
NewOp->Asl.AmlOpcode = AML_STRING_OP;
NewOp->Asl.AcpiBtype = ACPI_BTYPE_STRING;
NewOp->Asl.LogicalLineNumber = Op->Asl.LogicalLineNumber;
OpcCreateConcatenateNode(Op, NewOp);
}
OpcCreateConcatenateNode(Op, ArgNode);
ArgNode = NextNode;
break;
default:
AslError(ASL_ERROR, ASL_MSG_INVALID_OPERAND, Op,
"Unrecognized format specifier");
continue;
}
}
/* Process any remaining string */
if (StringToProcess)
{
NewString = UtLocalCacheCalloc (StringLength + 1);
memcpy (NewString, StartPosition, StringLength);
NewOp = TrAllocateOp (PARSEOP_STRING_LITERAL);
NewOp->Asl.Value.String = NewString;
NewOp->Asl.AcpiBtype = ACPI_BTYPE_STRING;
NewOp->Asl.AmlOpcode = AML_STRING_OP;
NewOp->Asl.LogicalLineNumber = Op->Asl.LogicalLineNumber;
OpcCreateConcatenateNode(Op, NewOp);
}
/*
* If we get here and there's no child node then Format
* was an empty string. Just make a no op.
*/
if (!Op->Asl.Child)
{
Op->Asl.ParseOpcode = PARSEOP_NOOP;
AslError(ASL_WARNING, ASL_MSG_NULL_STRING, Op,
"Converted to NOOP");
return;
}
/* Check for erroneous extra arguments */
if (ArgNode &&
ArgNode->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
{
AslError(ASL_WARNING, ASL_MSG_ARG_COUNT_HI, ArgNode,
"Extra arguments ignored");
}
/* Change Op to a Store */
Op->Asl.ParseOpcode = PARSEOP_STORE;
Op->Common.AmlOpcode = AML_STORE_OP;
Op->Asl.CompileFlags = 0;
/* Disable further optimization */
Op->Asl.CompileFlags &= ~OP_COMPILE_TIME_CONST;
UtSetParseOpName (Op);
/* Set Store destination */
Op->Asl.Child->Asl.Next = DestOp;
}
/*******************************************************************************
*
* FUNCTION: OpcCreateConcatenateNode
*
* PARAMETERS: Op - Parse node
* Node - Parse node to be concatenated
*
* RETURN: None
*
* DESCRIPTION: Make Node the child of Op. If child node already exists, then
* concat child with Node and makes concat node the child of Op.
*
******************************************************************************/
static void
OpcCreateConcatenateNode (
ACPI_PARSE_OBJECT *Op,
ACPI_PARSE_OBJECT *Node)
{
ACPI_PARSE_OBJECT *NewConcatOp;
if (!Op->Asl.Child)
{
Op->Asl.Child = Node;
Node->Asl.Parent = Op;
return;
}
NewConcatOp = TrAllocateOp (PARSEOP_CONCATENATE);
NewConcatOp->Asl.AmlOpcode = AML_CONCATENATE_OP;
NewConcatOp->Asl.AcpiBtype = 0x7;
NewConcatOp->Asl.LogicalLineNumber = Op->Asl.LogicalLineNumber;
/* First arg is child of Op*/
NewConcatOp->Asl.Child = Op->Asl.Child;
Op->Asl.Child->Asl.Parent = NewConcatOp;
/* Second arg is Node */
NewConcatOp->Asl.Child->Asl.Next = Node;
Node->Asl.Parent = NewConcatOp;
/* Third arg is Zero (not used) */
NewConcatOp->Asl.Child->Asl.Next->Asl.Next =
TrAllocateOp (PARSEOP_ZERO);
NewConcatOp->Asl.Child->Asl.Next->Asl.Next->Asl.Parent =
NewConcatOp;
Op->Asl.Child = NewConcatOp;
NewConcatOp->Asl.Parent = Op;
}

View File

@@ -0,0 +1,349 @@
/******************************************************************************
*
* Module Name: aslprune - Parse tree prune utility
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "acapps.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslprune")
/* Local prototypes */
static ACPI_STATUS
PrTreePruneWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context);
static void
PrPrintObjectAtLevel (
UINT32 Level,
const char *ObjectName);
/* Structure used for the pruning parse tree walk */
typedef struct acpi_prune_info
{
UINT32 PruneLevel;
UINT16 ParseOpcode;
UINT16 Count;
} ACPI_PRUNE_INFO;
/*******************************************************************************
*
* FUNCTION: AslPruneParseTree
*
* PARAMETERS: PruneDepth - Number of levels to prune
* Type - Prune type (Device, Method, etc.)
*
* RETURN: None
*
* DESCRIPTION: Prune off one or more levels of the ASL parse tree
*
******************************************************************************/
void
AslPruneParseTree (
UINT32 PruneDepth,
UINT32 Type)
{
ACPI_PRUNE_INFO PruneObj;
PruneObj.PruneLevel = PruneDepth;
PruneObj.Count = 0;
switch (Type)
{
case 0:
PruneObj.ParseOpcode = (UINT16) PARSEOP_DEVICE;
break;
case 1:
PruneObj.ParseOpcode = (UINT16) PARSEOP_METHOD;
break;
case 2:
PruneObj.ParseOpcode = (UINT16) PARSEOP_IF;
break;
default:
AcpiOsPrintf ("Unsupported type: %u\n", Type);
return;
}
AcpiOsPrintf ("Pruning parse tree, from depth %u\n",
PruneDepth);
AcpiOsPrintf ("\nRemoving Objects:\n");
TrWalkParseTree (AslGbl_ParseTreeRoot, ASL_WALK_VISIT_DOWNWARD,
PrTreePruneWalk, NULL, ACPI_CAST_PTR (void, &PruneObj));
AcpiOsPrintf ("\n%u Total Objects Removed\n", PruneObj.Count);
}
/*******************************************************************************
*
* FUNCTION: PrPrintObjectAtLevel
*
* PARAMETERS: Level - Current nesting level
* ObjectName - ACPI name for the object
*
* RETURN: None
*
* DESCRIPTION: Print object name with indent
*
******************************************************************************/
static void
PrPrintObjectAtLevel (
UINT32 Level,
const char *ObjectName)
{
UINT32 i;
for (i = 0; i < Level; i++)
{
AcpiOsPrintf (" ");
}
AcpiOsPrintf ("[%s] at Level [%u]\n", ObjectName, Level);
}
/*******************************************************************************
*
* FUNCTION: PrTreePruneWalk
*
* PARAMETERS: Parse tree walk callback
*
* RETURN: Status
*
* DESCRIPTION: Prune off one or more levels of the ASL parse tree
*
* Current objects that can be pruned are: Devices, Methods, and If/Else
* blocks.
*
******************************************************************************/
static ACPI_STATUS
PrTreePruneWalk (
ACPI_PARSE_OBJECT *Op,
UINT32 Level,
void *Context)
{
ACPI_PRUNE_INFO *PruneObj = (ACPI_PRUNE_INFO *) Context;
/* We only care about objects below the Prune Level threshold */
if (Level <= PruneObj->PruneLevel)
{
return (AE_OK);
}
if ((Op->Asl.ParseOpcode != PruneObj->ParseOpcode) &&
!(Op->Asl.ParseOpcode == PARSEOP_ELSE &&
PruneObj->ParseOpcode == PARSEOP_IF))
{
return (AE_OK);
}
switch (Op->Asl.ParseOpcode)
{
case PARSEOP_METHOD:
AcpiOsPrintf ("Method");
PrPrintObjectAtLevel (Level, Op->Asl.Child->Asl.Value.Name);
Op->Asl.Child->Asl.Next->Asl.Next->Asl.Next->Asl.Next->Asl.Next->Asl.Next = NULL;
PruneObj->Count++;
break;
case PARSEOP_DEVICE:
AcpiOsPrintf ("Device");
PrPrintObjectAtLevel (Level, Op->Asl.Child->Asl.Value.Name);
Op->Asl.Child->Asl.Next = NULL;
PruneObj->Count++;
break;
case PARSEOP_IF:
case PARSEOP_ELSE:
if (Op->Asl.ParseOpcode == PARSEOP_ELSE)
{
PrPrintObjectAtLevel(Level, "Else");
Op->Asl.Child = NULL;
}
else
{
PrPrintObjectAtLevel(Level, "If");
Op->Asl.Child->Asl.Next = NULL;
}
PruneObj->Count++;
break;
default:
break;
}
return (AE_OK);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,749 @@
/******************************************************************************
*
* Module Name: aslrestype1 - Miscellaneous small resource descriptors
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslrestype1")
/*
* This module contains miscellaneous small resource descriptors:
*
* EndTag
* EndDependentFn
* Memory24
* Memory32
* Memory32Fixed
* StartDependentFn
* StartDependentFnNoPri
* VendorShort
*/
/*******************************************************************************
*
* FUNCTION: RsDoEndTagDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a short "EndDependentFn" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoEndTagDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ASL_RESOURCE_NODE *Rnode;
Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_TAG));
Descriptor = Rnode->Buffer;
Descriptor->EndTag.DescriptorType = ACPI_RESOURCE_NAME_END_TAG |
ASL_RDESC_END_TAG_SIZE;
Descriptor->EndTag.Checksum = 0;
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoEndDependentDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a short "EndDependentFn" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoEndDependentDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ASL_RESOURCE_NODE *Rnode;
Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_END_DEPENDENT));
Descriptor = Rnode->Buffer;
Descriptor->EndDpf.DescriptorType =
ACPI_RESOURCE_NAME_END_DEPENDENT | ASL_RDESC_END_DEPEND_SIZE;
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoMemory24Descriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a short "Memory24" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoMemory24Descriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ACPI_PARSE_OBJECT *MinOp = NULL;
ACPI_PARSE_OBJECT *MaxOp = NULL;
ACPI_PARSE_OBJECT *LengthOp = NULL;
ASL_RESOURCE_NODE *Rnode;
UINT32 CurrentByteOffset;
UINT32 i;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY24));
Descriptor = Rnode->Buffer;
Descriptor->Memory24.DescriptorType = ACPI_RESOURCE_NAME_MEMORY24;
Descriptor->Memory24.ResourceLength = 9;
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Read/Write type */
RsSetFlagBits (&Descriptor->Memory24.Flags, InitializerOp, 0, 1);
RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Flags), 0);
break;
case 1: /* Min Address */
Descriptor->Memory24.Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Minimum));
MinOp = InitializerOp;
break;
case 2: /* Max Address */
Descriptor->Memory24.Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Maximum));
MaxOp = InitializerOp;
break;
case 3: /* Alignment */
Descriptor->Memory24.Alignment = (UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.Alignment));
break;
case 4: /* Length */
Descriptor->Memory24.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
CurrentByteOffset + ASL_RESDESC_OFFSET (Memory24.AddressLength));
LengthOp = InitializerOp;
break;
case 5: /* Name */
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
/* Validate the Min/Max/Len/Align values (Alignment==0 means 64K) */
RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY24,
Descriptor->Memory24.Minimum,
Descriptor->Memory24.Maximum,
Descriptor->Memory24.AddressLength,
Descriptor->Memory24.Alignment,
MinOp, MaxOp, LengthOp, NULL, Info->DescriptorTypeOp);
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoMemory32Descriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a short "Memory32" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoMemory32Descriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ACPI_PARSE_OBJECT *MinOp = NULL;
ACPI_PARSE_OBJECT *MaxOp = NULL;
ACPI_PARSE_OBJECT *LengthOp = NULL;
ACPI_PARSE_OBJECT *AlignOp = NULL;
ASL_RESOURCE_NODE *Rnode;
UINT32 CurrentByteOffset;
UINT32 i;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_MEMORY32));
Descriptor = Rnode->Buffer;
Descriptor->Memory32.DescriptorType = ACPI_RESOURCE_NAME_MEMORY32;
Descriptor->Memory32.ResourceLength = 17;
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Read/Write type */
RsSetFlagBits (&Descriptor->Memory32.Flags, InitializerOp, 0, 1);
RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Flags), 0);
break;
case 1: /* Min Address */
Descriptor->Memory32.Minimum = (UINT32) InitializerOp->Asl.Value.Integer;
RsCreateDwordField (InitializerOp, ACPI_RESTAG_MINADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Minimum));
MinOp = InitializerOp;
break;
case 2: /* Max Address */
Descriptor->Memory32.Maximum = (UINT32) InitializerOp->Asl.Value.Integer;
RsCreateDwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Maximum));
MaxOp = InitializerOp;
break;
case 3: /* Alignment */
Descriptor->Memory32.Alignment = (UINT32) InitializerOp->Asl.Value.Integer;
RsCreateDwordField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.Alignment));
AlignOp = InitializerOp;
break;
case 4: /* Length */
Descriptor->Memory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
CurrentByteOffset + ASL_RESDESC_OFFSET (Memory32.AddressLength));
LengthOp = InitializerOp;
break;
case 5: /* Name */
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
/* Validate the Min/Max/Len/Align values */
RsSmallAddressCheck (ACPI_RESOURCE_NAME_MEMORY32,
Descriptor->Memory32.Minimum,
Descriptor->Memory32.Maximum,
Descriptor->Memory32.AddressLength,
Descriptor->Memory32.Alignment,
MinOp, MaxOp, LengthOp, AlignOp, Info->DescriptorTypeOp);
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoMemory32FixedDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a short "Memory32Fixed" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoMemory32FixedDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ASL_RESOURCE_NODE *Rnode;
UINT32 CurrentByteOffset;
UINT32 i;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_MEMORY32));
Descriptor = Rnode->Buffer;
Descriptor->FixedMemory32.DescriptorType = ACPI_RESOURCE_NAME_FIXED_MEMORY32;
Descriptor->FixedMemory32.ResourceLength = 9;
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Read/Write type */
RsSetFlagBits (&Descriptor->FixedMemory32.Flags, InitializerOp, 0, 1);
RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Flags), 0);
break;
case 1: /* Address */
Descriptor->FixedMemory32.Address = (UINT32) InitializerOp->Asl.Value.Integer;
RsCreateDwordField (InitializerOp, ACPI_RESTAG_BASEADDRESS,
CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.Address));
break;
case 2: /* Length */
Descriptor->FixedMemory32.AddressLength = (UINT32) InitializerOp->Asl.Value.Integer;
RsCreateDwordField (InitializerOp, ACPI_RESTAG_LENGTH,
CurrentByteOffset + ASL_RESDESC_OFFSET (FixedMemory32.AddressLength));
break;
case 3: /* Name */
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoStartDependentDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a short "StartDependentFn" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoStartDependentDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ASL_RESOURCE_NODE *Rnode;
ASL_RESOURCE_NODE *PreviousRnode;
ASL_RESOURCE_NODE *NextRnode;
ASL_RESOURCE_INFO NextInfo;
UINT32 CurrentByteOffset;
UINT32 i;
UINT8 State;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT));
PreviousRnode = Rnode;
Descriptor = Rnode->Buffer;
/* Increment offset past StartDependent descriptor */
CurrentByteOffset += sizeof (AML_RESOURCE_START_DEPENDENT);
/* Descriptor has priority byte */
Descriptor->StartDpf.DescriptorType =
ACPI_RESOURCE_NAME_START_DEPENDENT | (ASL_RDESC_ST_DEPEND_SIZE + 0x01);
/* Process all child initialization nodes */
State = ACPI_RSTATE_START_DEPENDENT;
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Compatibility Priority */
if ((UINT8) InitializerOp->Asl.Value.Integer > 2)
{
AslError (ASL_ERROR, ASL_MSG_INVALID_PRIORITY,
InitializerOp, NULL);
}
RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 0, 0);
break;
case 1: /* Performance/Robustness Priority */
if ((UINT8) InitializerOp->Asl.Value.Integer > 2)
{
AslError (ASL_ERROR, ASL_MSG_INVALID_PERFORMANCE,
InitializerOp, NULL);
}
RsSetFlagBits (&Descriptor->StartDpf.Flags, InitializerOp, 2, 0);
break;
default:
NextInfo.CurrentByteOffset = CurrentByteOffset;
NextInfo.DescriptorTypeOp = InitializerOp;
NextRnode = RsDoOneResourceDescriptor (&NextInfo, &State);
/*
* Update current byte offset to indicate the number of bytes from the
* start of the buffer. Buffer can include multiple descriptors, we
* must keep track of the offset of not only each descriptor, but each
* element (field) within each descriptor as well.
*/
CurrentByteOffset += RsLinkDescriptorChain (
&PreviousRnode, NextRnode);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoStartDependentNoPriDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a short "StartDependentNoPri" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoStartDependentNoPriDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ASL_RESOURCE_NODE *Rnode;
ASL_RESOURCE_NODE *PreviousRnode;
ASL_RESOURCE_NODE *NextRnode;
ASL_RESOURCE_INFO NextInfo;
UINT32 CurrentByteOffset;
UINT8 State;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO));
Descriptor = Rnode->Buffer;
Descriptor->StartDpf.DescriptorType =
ACPI_RESOURCE_NAME_START_DEPENDENT | ASL_RDESC_ST_DEPEND_SIZE;
PreviousRnode = Rnode;
/* Increment offset past StartDependentNoPri descriptor */
CurrentByteOffset += sizeof (AML_RESOURCE_START_DEPENDENT_NOPRIO);
/* Process all child initialization nodes */
State = ACPI_RSTATE_START_DEPENDENT;
while (InitializerOp)
{
NextInfo.CurrentByteOffset = CurrentByteOffset;
NextInfo.DescriptorTypeOp = InitializerOp;
NextRnode = RsDoOneResourceDescriptor (&NextInfo, &State);
/*
* Update current byte offset to indicate the number of bytes from the
* start of the buffer. Buffer can include multiple descriptors, we
* must keep track of the offset of not only each descriptor, but each
* element (field) within each descriptor as well.
*/
CurrentByteOffset += RsLinkDescriptorChain (&PreviousRnode, NextRnode);
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoVendorSmallDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a short "VendorShort" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoVendorSmallDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ASL_RESOURCE_NODE *Rnode;
UINT8 *VendorData;
UINT32 i;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
/* Allocate worst case - 7 vendor bytes */
Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_SMALL) + 7);
Descriptor = Rnode->Buffer;
Descriptor->VendorSmall.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_SMALL;
VendorData = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_SMALL_HEADER);
/* Process all child initialization nodes */
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
for (i = 0; InitializerOp; i++)
{
if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
{
break;
}
/* Maximum 7 vendor data bytes allowed (0-6) */
if (i >= 7)
{
AslError (ASL_ERROR, ASL_MSG_VENDOR_LIST, InitializerOp, NULL);
/* Eat the excess initializers */
while (InitializerOp)
{
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
break;
}
VendorData[i] = (UINT8) InitializerOp->Asl.Value.Integer;
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
/* Adjust the Rnode buffer size, so correct number of bytes are emitted */
Rnode->BufferLength -= (7 - i);
/* Set the length in the Type Tag */
Descriptor->VendorSmall.DescriptorType |= (UINT8) i;
return (Rnode);
}

View File

@@ -0,0 +1,773 @@
/******************************************************************************
*
* Module Name: aslrestype1i - Small I/O-related resource descriptors
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslrestype1i")
/*
* This module contains the I/O-related small resource descriptors:
*
* DMA
* FixedDMA
* FixedIO
* IO
* IRQ
* IRQNoFlags
*/
/*******************************************************************************
*
* FUNCTION: RsDoDmaDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a short "DMA" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoDmaDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ASL_RESOURCE_NODE *Rnode;
UINT32 CurrentByteOffset;
UINT32 i;
UINT8 DmaChannelMask = 0;
UINT8 DmaChannels = 0;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_DMA));
Descriptor = Rnode->Buffer;
Descriptor->Dma.DescriptorType =
ACPI_RESOURCE_NAME_DMA | ASL_RDESC_DMA_SIZE;
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* DMA type */
RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 5, 0);
RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_DMATYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 5, 2);
break;
case 1: /* Bus Master */
RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 2, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_BUSMASTER,
CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 2);
break;
case 2: /* Xfer Type (transfer width) */
RsSetFlagBits (&Descriptor->Dma.Flags, InitializerOp, 0, 0);
RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_XFERTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Dma.Flags), 0, 2);
break;
case 3: /* Name */
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
default:
/* All DMA channel bytes are handled here, after flags and name */
if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
{
/* Up to 8 channels can be specified in the list */
DmaChannels++;
if (DmaChannels > 8)
{
AslError (ASL_ERROR, ASL_MSG_DMA_LIST,
InitializerOp, NULL);
return (Rnode);
}
/* Only DMA channels 0-7 are allowed (mask is 8 bits) */
if (InitializerOp->Asl.Value.Integer > 7)
{
AslError (ASL_ERROR, ASL_MSG_DMA_CHANNEL,
InitializerOp, NULL);
}
/* Build the mask */
DmaChannelMask |=
(1 << ((UINT8) InitializerOp->Asl.Value.Integer));
}
if (i == 4) /* case 4: First DMA byte */
{
/* Check now for duplicates in list */
RsCheckListForDuplicates (InitializerOp);
/* Create a named field at the start of the list */
RsCreateByteField (InitializerOp, ACPI_RESTAG_DMA,
CurrentByteOffset +
ASL_RESDESC_OFFSET (Dma.DmaChannelMask));
}
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
/* Now we can set the channel mask */
Descriptor->Dma.DmaChannelMask = DmaChannelMask;
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoFixedDmaDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a short "FixedDMA" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoFixedDmaDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ASL_RESOURCE_NODE *Rnode;
UINT32 CurrentByteOffset;
UINT32 i;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_DMA));
Descriptor = Rnode->Buffer;
Descriptor->FixedDma.DescriptorType =
ACPI_RESOURCE_NAME_FIXED_DMA | ASL_RDESC_FIXED_DMA_SIZE;
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* DMA Request Lines [WORD] (_DMA) */
Descriptor->FixedDma.RequestLines = (UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_DMA,
CurrentByteOffset + ASL_RESDESC_OFFSET (FixedDma.RequestLines));
break;
case 1: /* DMA Channel [WORD] (_TYP) */
Descriptor->FixedDma.Channels = (UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_DMATYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (FixedDma.Channels));
break;
case 2: /* Transfer Width [BYTE] (_SIZ) */
Descriptor->FixedDma.Width = (UINT8) InitializerOp->Asl.Value.Integer;
RsCreateByteField (InitializerOp, ACPI_RESTAG_XFERTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (FixedDma.Width));
break;
case 3: /* Descriptor Name (optional) */
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
default: /* Ignore any extra nodes */
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoFixedIoDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a short "FixedIO" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoFixedIoDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ACPI_PARSE_OBJECT *AddressOp = NULL;
ASL_RESOURCE_NODE *Rnode;
UINT32 CurrentByteOffset;
UINT32 i;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_FIXED_IO));
Descriptor = Rnode->Buffer;
Descriptor->Io.DescriptorType =
ACPI_RESOURCE_NAME_FIXED_IO | ASL_RDESC_FIXED_IO_SIZE;
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Base Address */
Descriptor->FixedIo.Address =
(UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_BASEADDRESS,
CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.Address));
AddressOp = InitializerOp;
break;
case 1: /* Length */
Descriptor->FixedIo.AddressLength =
(UINT8) InitializerOp->Asl.Value.Integer;
RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
CurrentByteOffset + ASL_RESDESC_OFFSET (FixedIo.AddressLength));
break;
case 2: /* Name */
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
/* Error checks */
if (Descriptor->FixedIo.Address > 0x03FF)
{
AslError (ASL_WARNING, ASL_MSG_ISA_ADDRESS, AddressOp, NULL);
}
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoIoDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a short "IO" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoIoDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ACPI_PARSE_OBJECT *MinOp = NULL;
ACPI_PARSE_OBJECT *MaxOp = NULL;
ACPI_PARSE_OBJECT *LengthOp = NULL;
ACPI_PARSE_OBJECT *AlignOp = NULL;
ASL_RESOURCE_NODE *Rnode;
UINT32 CurrentByteOffset;
UINT32 i;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IO));
Descriptor = Rnode->Buffer;
Descriptor->Io.DescriptorType =
ACPI_RESOURCE_NAME_IO | ASL_RDESC_IO_SIZE;
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Decode size */
RsSetFlagBits (&Descriptor->Io.Flags, InitializerOp, 0, 1);
RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Flags), 0);
break;
case 1: /* Min Address */
Descriptor->Io.Minimum =
(UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Minimum));
MinOp = InitializerOp;
break;
case 2: /* Max Address */
Descriptor->Io.Maximum =
(UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Maximum));
MaxOp = InitializerOp;
break;
case 3: /* Alignment */
Descriptor->Io.Alignment =
(UINT8) InitializerOp->Asl.Value.Integer;
RsCreateByteField (InitializerOp, ACPI_RESTAG_ALIGNMENT,
CurrentByteOffset + ASL_RESDESC_OFFSET (Io.Alignment));
AlignOp = InitializerOp;
break;
case 4: /* Length */
Descriptor->Io.AddressLength =
(UINT8) InitializerOp->Asl.Value.Integer;
RsCreateByteField (InitializerOp, ACPI_RESTAG_LENGTH,
CurrentByteOffset + ASL_RESDESC_OFFSET (Io.AddressLength));
LengthOp = InitializerOp;
break;
case 5: /* Name */
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
/* Validate the Min/Max/Len/Align values */
RsSmallAddressCheck (ACPI_RESOURCE_NAME_IO,
Descriptor->Io.Minimum,
Descriptor->Io.Maximum,
Descriptor->Io.AddressLength,
Descriptor->Io.Alignment,
MinOp, MaxOp, LengthOp, AlignOp, Info->DescriptorTypeOp);
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoIrqDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a short "IRQ" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoIrqDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ASL_RESOURCE_NODE *Rnode;
UINT32 Interrupts = 0;
UINT16 IrqMask = 0;
UINT32 CurrentByteOffset;
UINT32 i;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ));
/* Length = 3 (with flag byte) */
Descriptor = Rnode->Buffer;
Descriptor->Irq.DescriptorType =
ACPI_RESOURCE_NAME_IRQ | (ASL_RDESC_IRQ_SIZE + 0x01);
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Interrupt Type (or Mode - edge/level) */
RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 0, 1);
RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 0);
break;
case 1: /* Interrupt Level (or Polarity - Active high/low) */
RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 3, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTLEVEL,
CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 3);
break;
case 2: /* Share Type - Default: exclusive (0) */
RsSetFlagBits (&Descriptor->Irq.Flags, InitializerOp, 4, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.Flags), 4);
break;
case 3: /* Name */
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
default:
/* All IRQ bytes are handled here, after the flags and name */
if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
{
/* Up to 16 interrupts can be specified in the list */
Interrupts++;
if (Interrupts > 16)
{
AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST,
InitializerOp, NULL);
return (Rnode);
}
/* Only interrupts 0-15 are allowed (mask is 16 bits) */
if (InitializerOp->Asl.Value.Integer > 15)
{
AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER,
InitializerOp, NULL);
}
else
{
IrqMask |= (1 << (UINT8) InitializerOp->Asl.Value.Integer);
}
}
/* Case 4: First IRQ value in list */
if (i == 4)
{
/* Check now for duplicates in list */
RsCheckListForDuplicates (InitializerOp);
/* Create a named field at the start of the list */
RsCreateWordField (InitializerOp, ACPI_RESTAG_INTERRUPT,
CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask));
}
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
/* Now we can set the channel mask */
Descriptor->Irq.IrqMask = IrqMask;
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoIrqNoFlagsDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a short "IRQNoFlags" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoIrqNoFlagsDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ASL_RESOURCE_NODE *Rnode;
UINT16 IrqMask = 0;
UINT32 Interrupts = 0;
UINT32 CurrentByteOffset;
UINT32 i;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_IRQ_NOFLAGS));
Descriptor = Rnode->Buffer;
Descriptor->Irq.DescriptorType =
ACPI_RESOURCE_NAME_IRQ | ASL_RDESC_IRQ_SIZE;
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Name */
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
default:
/* IRQ bytes are handled here, after the flags and name */
if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
{
/* Up to 16 interrupts can be specified in the list */
Interrupts++;
if (Interrupts > 16)
{
AslError (ASL_ERROR, ASL_MSG_INTERRUPT_LIST,
InitializerOp, NULL);
return (Rnode);
}
/* Only interrupts 0-15 are allowed (mask is 16 bits) */
if (InitializerOp->Asl.Value.Integer > 15)
{
AslError (ASL_ERROR, ASL_MSG_INTERRUPT_NUMBER,
InitializerOp, NULL);
}
else
{
IrqMask |= (1 << ((UINT8) InitializerOp->Asl.Value.Integer));
}
}
/* Case 1: First IRQ value in list */
if (i == 1)
{
/* Check now for duplicates in list */
RsCheckListForDuplicates (InitializerOp);
/* Create a named field at the start of the list */
RsCreateWordField (InitializerOp, ACPI_RESTAG_INTERRUPT,
CurrentByteOffset + ASL_RESDESC_OFFSET (Irq.IrqMask));
}
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
/* Now we can set the interrupt mask */
Descriptor->Irq.IrqMask = IrqMask;
return (Rnode);
}

View File

@@ -0,0 +1,567 @@
/******************************************************************************
*
* Module Name: aslrestype2 - Miscellaneous Large resource descriptors
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#include "amlcode.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslrestype2")
/*
* This module contains miscellaneous large resource descriptors:
*
* Register
* Interrupt
* VendorLong
*/
/*******************************************************************************
*
* FUNCTION: RsDoGeneralRegisterDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a long "Register" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoGeneralRegisterDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ASL_RESOURCE_NODE *Rnode;
UINT32 CurrentByteOffset;
UINT32 i;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_GENERIC_REGISTER));
Descriptor = Rnode->Buffer;
Descriptor->GenericReg.DescriptorType = ACPI_RESOURCE_NAME_GENERIC_REGISTER;
Descriptor->GenericReg.ResourceLength = 12;
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Address space */
Descriptor->GenericReg.AddressSpaceId = (UINT8) InitializerOp->Asl.Value.Integer;
RsCreateByteField (InitializerOp, ACPI_RESTAG_ADDRESSSPACE,
CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.AddressSpaceId));
break;
case 1: /* Register Bit Width */
Descriptor->GenericReg.BitWidth = (UINT8) InitializerOp->Asl.Value.Integer;
RsCreateByteField (InitializerOp, ACPI_RESTAG_REGISTERBITWIDTH,
CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.BitWidth));
break;
case 2: /* Register Bit Offset */
Descriptor->GenericReg.BitOffset = (UINT8) InitializerOp->Asl.Value.Integer;
RsCreateByteField (InitializerOp, ACPI_RESTAG_REGISTERBITOFFSET,
CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.BitOffset));
break;
case 3: /* Register Address */
Descriptor->GenericReg.Address = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_ADDRESS,
CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.Address));
break;
case 4: /* Access Size (ACPI 3.0) */
Descriptor->GenericReg.AccessSize = (UINT8) InitializerOp->Asl.Value.Integer;
RsCreateByteField (InitializerOp, ACPI_RESTAG_ACCESSSIZE,
CurrentByteOffset + ASL_RESDESC_OFFSET (GenericReg.AccessSize));
if (Descriptor->GenericReg.AddressSpaceId == ACPI_ADR_SPACE_PLATFORM_COMM)
{
break;
}
if (Descriptor->GenericReg.AccessSize > AML_FIELD_ACCESS_QWORD)
{
AslError (ASL_ERROR, ASL_MSG_INVALID_ACCESS_SIZE,
InitializerOp, NULL);
}
break;
case 5: /* ResourceTag (ACPI 3.0b) */
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoInterruptDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a long "Interrupt" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoInterruptDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
AML_RESOURCE *Rover = NULL;
ACPI_PARSE_OBJECT *InitializerOp;
ASL_RESOURCE_NODE *Rnode;
UINT16 StringLength = 0;
UINT32 OptionIndex = 0;
UINT32 CurrentByteOffset;
UINT32 i;
BOOLEAN HasResSourceIndex = FALSE;
UINT8 ResSourceIndex = 0;
UINT8 *ResSourceString = NULL;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
CurrentByteOffset = Info->CurrentByteOffset;
StringLength = RsGetStringDataLength (InitializerOp);
/* Count the interrupt numbers */
for (i = 0; InitializerOp; i++)
{
InitializerOp = ASL_GET_PEER_NODE (InitializerOp);
if (i <= 6)
{
if (i == 3 &&
InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
{
/*
* ResourceSourceIndex was specified, always make room for
* it, even if the ResourceSource was omitted.
*/
OptionIndex++;
}
continue;
}
OptionIndex += 4;
}
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_EXTENDED_IRQ) +
1 + OptionIndex + StringLength);
Descriptor = Rnode->Buffer;
Descriptor->ExtendedIrq.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_IRQ;
/*
* Initial descriptor length -- may be enlarged if there are
* optional fields present
*/
Descriptor->ExtendedIrq.ResourceLength = 2; /* Flags and table length byte */
Descriptor->ExtendedIrq.InterruptCount = 0;
Rover = ACPI_CAST_PTR (AML_RESOURCE,
(&(Descriptor->ExtendedIrq.Interrupts[0])));
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Resource Usage (Default: consumer (1) */
RsSetFlagBits (&Descriptor->ExtendedIrq.Flags, InitializerOp, 0, 1);
break;
case 1: /* Interrupt Type (or Mode - edge/level) */
RsSetFlagBits (&Descriptor->ExtendedIrq.Flags, InitializerOp, 1, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtendedIrq.Flags), 1);
break;
case 2: /* Interrupt Level (or Polarity - Active high/low) */
RsSetFlagBits (&Descriptor->ExtendedIrq.Flags, InitializerOp, 2, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTLEVEL,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtendedIrq.Flags), 2);
break;
case 3: /* Share Type - Default: exclusive (0) */
RsSetFlagBits (&Descriptor->ExtendedIrq.Flags, InitializerOp, 3, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_INTERRUPTSHARE,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtendedIrq.Flags), 3);
break;
case 4: /* ResSourceIndex [Optional Field - BYTE] */
if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
{
HasResSourceIndex = TRUE;
ResSourceIndex = (UINT8) InitializerOp->Asl.Value.Integer;
}
break;
case 5: /* ResSource [Optional Field - STRING] */
if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
(InitializerOp->Asl.Value.String))
{
if (StringLength)
{
ResSourceString = (UINT8 *) InitializerOp->Asl.Value.String;
}
/* ResourceSourceIndex must also be valid */
if (!HasResSourceIndex)
{
AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
InitializerOp, NULL);
}
}
#if 0
/*
* Not a valid ResourceSource, ResourceSourceIndex must also
* be invalid
*/
else if (HasResSourceIndex)
{
AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
InitializerOp, NULL);
}
#endif
break;
case 6: /* ResourceTag */
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
default:
/*
* Interrupt Numbers come through here, repeatedly
*/
/* Maximum 255 interrupts allowed for this descriptor */
if (Descriptor->ExtendedIrq.InterruptCount == 255)
{
AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_LIST,
InitializerOp, NULL);
return (Rnode);
}
/* Each interrupt number must be a 32-bit value */
if (InitializerOp->Asl.Value.Integer > ACPI_UINT32_MAX)
{
AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_NUMBER,
InitializerOp, NULL);
}
/* Save the integer and move pointer to the next one */
Rover->DwordItem = (UINT32) InitializerOp->Asl.Value.Integer;
Rover = ACPI_ADD_PTR (AML_RESOURCE, &(Rover->DwordItem), 4);
Descriptor->ExtendedIrq.InterruptCount++;
Descriptor->ExtendedIrq.ResourceLength += 4;
/* Case 7: First interrupt number in list */
if (i == 7)
{
if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
{
/* Must be at least one interrupt */
AslError (ASL_ERROR, ASL_MSG_EX_INTERRUPT_LIST_MIN,
InitializerOp, NULL);
}
/* Check now for duplicates in list */
RsCheckListForDuplicates (InitializerOp);
/* Create a named field at the start of the list */
RsCreateDwordField (InitializerOp, ACPI_RESTAG_INTERRUPT,
CurrentByteOffset +
ASL_RESDESC_OFFSET (ExtendedIrq.Interrupts[0]));
}
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
/* Add optional ResSourceIndex if present */
if (HasResSourceIndex)
{
Rover->ByteItem = ResSourceIndex;
Rover = ACPI_ADD_PTR (AML_RESOURCE, &(Rover->ByteItem), 1);
Descriptor->ExtendedIrq.ResourceLength += 1;
}
/* Add optional ResSource string if present */
if (StringLength && ResSourceString)
{
strcpy ((char *) Rover, (char *) ResSourceString);
Descriptor->ExtendedIrq.ResourceLength = (UINT16)
(Descriptor->ExtendedIrq.ResourceLength + StringLength);
}
Rnode->BufferLength =
(ASL_RESDESC_OFFSET (ExtendedIrq.Interrupts[0]) -
ASL_RESDESC_OFFSET (ExtendedIrq.DescriptorType))
+ OptionIndex + StringLength;
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoVendorLargeDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a long "VendorLong" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoVendorLargeDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ASL_RESOURCE_NODE *Rnode;
UINT8 *VendorData;
UINT32 i;
/* Count the number of data bytes */
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
for (i = 0; InitializerOp; i++)
{
if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
{
break;
}
InitializerOp = InitializerOp->Asl.Next;
}
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
Rnode = RsAllocateResourceNode (sizeof (AML_RESOURCE_VENDOR_LARGE) + i);
Descriptor = Rnode->Buffer;
Descriptor->VendorLarge.DescriptorType = ACPI_RESOURCE_NAME_VENDOR_LARGE;
Descriptor->VendorLarge.ResourceLength = (UINT16) i;
/* Point to end-of-descriptor for vendor data */
VendorData = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_LARGE_HEADER);
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
if (InitializerOp->Asl.ParseOpcode == PARSEOP_DEFAULT_ARG)
{
break;
}
VendorData[i] = (UINT8) InitializerOp->Asl.Value.Integer;
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
return (Rnode);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,679 @@
/******************************************************************************
*
* Module Name: aslrestype2e - Large Extended address resource descriptors
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslrestype2e")
/*
* This module contains the Extended (64-bit) address space descriptors:
*
* ExtendedIO
* ExtendedMemory
* ExtendedSpace
*/
/*******************************************************************************
*
* FUNCTION: RsDoExtendedIoDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a long "ExtendedIO" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoExtendedIoDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ACPI_PARSE_OBJECT *MinOp = NULL;
ACPI_PARSE_OBJECT *MaxOp = NULL;
ACPI_PARSE_OBJECT *LengthOp = NULL;
ACPI_PARSE_OBJECT *GranOp = NULL;
ASL_RESOURCE_NODE *Rnode;
UINT16 StringLength = 0;
UINT32 CurrentByteOffset;
UINT32 i;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
StringLength = RsGetStringDataLength (InitializerOp);
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (
sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength);
Descriptor = Rnode->Buffer;
Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64;
Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE;
Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION;
Descriptor->ExtAddress64.ResourceLength = (UINT16)
(sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) -
sizeof (AML_RESOURCE_LARGE_HEADER));
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Resource Usage */
RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 0, 1);
break;
case 1: /* MinType */
RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 2, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 2);
break;
case 2: /* MaxType */
RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 3, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 3);
break;
case 3: /* DecodeType */
RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 1, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 1);
break;
case 4: /* Range Type */
RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 0, 3);
RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_RANGETYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 0, 2);
break;
case 5: /* Address Granularity */
Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity));
GranOp = InitializerOp;
break;
case 6: /* Address Min */
Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum));
MinOp = InitializerOp;
break;
case 7: /* Address Max */
Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum));
MaxOp = InitializerOp;
break;
case 8: /* Translation Offset */
Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset));
break;
case 9: /* Address Length */
Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength));
LengthOp = InitializerOp;
break;
case 10: /* Type-Specific Attributes */
Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific));
break;
case 11: /* ResourceTag */
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
case 12: /* Type */
RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 4, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 4);
break;
case 13: /* Translation Type */
RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 5, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 5);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
/* Validate the Min/Max/Len/Gran values */
RsLargeAddressCheck (
Descriptor->ExtAddress64.Minimum,
Descriptor->ExtAddress64.Maximum,
Descriptor->ExtAddress64.AddressLength,
Descriptor->ExtAddress64.Granularity,
Descriptor->ExtAddress64.Flags,
MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) +
StringLength;
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoExtendedMemoryDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a long "ExtendedMemory" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoExtendedMemoryDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ACPI_PARSE_OBJECT *MinOp = NULL;
ACPI_PARSE_OBJECT *MaxOp = NULL;
ACPI_PARSE_OBJECT *LengthOp = NULL;
ACPI_PARSE_OBJECT *GranOp = NULL;
ASL_RESOURCE_NODE *Rnode;
UINT16 StringLength = 0;
UINT32 CurrentByteOffset;
UINT32 i;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
StringLength = RsGetStringDataLength (InitializerOp);
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (
sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength);
Descriptor = Rnode->Buffer;
Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64;
Descriptor->ExtAddress64.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE;
Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION;
Descriptor->ExtAddress64.ResourceLength = (UINT16)
(sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) -
sizeof (AML_RESOURCE_LARGE_HEADER));
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Resource Usage */
RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 0, 1);
break;
case 1: /* DecodeType */
RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 1, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 1);
break;
case 2: /* MinType */
RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 2, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 2);
break;
case 3: /* MaxType */
RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 3, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 3);
break;
case 4: /* Memory Type */
RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 1, 0);
RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_MEMTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 1, 2);
break;
case 5: /* Read/Write Type */
RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 0, 1);
RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 0);
break;
case 6: /* Address Granularity */
Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity));
GranOp = InitializerOp;
break;
case 7: /* Min Address */
Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum));
MinOp = InitializerOp;
break;
case 8: /* Max Address */
Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum));
MaxOp = InitializerOp;
break;
case 9: /* Translation Offset */
Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset));
break;
case 10: /* Address Length */
Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength));
LengthOp = InitializerOp;
break;
case 11: /* Type-Specific Attributes */
Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific));
break;
case 12: /* ResourceTag */
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
case 13: /* Address Range */
RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 3, 0);
RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_MEMATTRIBUTES,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 3, 2);
break;
case 14: /* Type */
RsSetFlagBits (&Descriptor->ExtAddress64.SpecificFlags, InitializerOp, 5, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.SpecificFlags), 5);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
/* Validate the Min/Max/Len/Gran values */
RsLargeAddressCheck (
Descriptor->ExtAddress64.Minimum,
Descriptor->ExtAddress64.Maximum,
Descriptor->ExtAddress64.AddressLength,
Descriptor->ExtAddress64.Granularity,
Descriptor->ExtAddress64.Flags,
MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) +
StringLength;
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoExtendedSpaceDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a long "ExtendedSpace" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoExtendedSpaceDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ACPI_PARSE_OBJECT *MinOp = NULL;
ACPI_PARSE_OBJECT *MaxOp = NULL;
ACPI_PARSE_OBJECT *LengthOp = NULL;
ACPI_PARSE_OBJECT *GranOp = NULL;
ASL_RESOURCE_NODE *Rnode;
UINT16 StringLength = 0;
UINT32 CurrentByteOffset;
UINT32 i;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
StringLength = RsGetStringDataLength (InitializerOp);
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (
sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) + 1 + StringLength);
Descriptor = Rnode->Buffer;
Descriptor->ExtAddress64.DescriptorType = ACPI_RESOURCE_NAME_EXTENDED_ADDRESS64;
Descriptor->ExtAddress64.RevisionID = AML_RESOURCE_EXTENDED_ADDRESS_REVISION;
Descriptor->ExtAddress64.ResourceLength = (UINT16)
(sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) -
sizeof (AML_RESOURCE_LARGE_HEADER));
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Resource Type */
Descriptor->ExtAddress64.ResourceType =
(UINT8) InitializerOp->Asl.Value.Integer;
break;
case 1: /* Resource Usage */
RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 0, 1);
break;
case 2: /* DecodeType */
RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 1, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 1);
break;
case 3: /* MinType */
RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 2, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 2);
break;
case 4: /* MaxType */
RsSetFlagBits (&Descriptor->ExtAddress64.Flags, InitializerOp, 3, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Flags), 3);
break;
case 5: /* Type-Specific flags */
Descriptor->ExtAddress64.SpecificFlags =
(UINT8) InitializerOp->Asl.Value.Integer;
break;
case 6: /* Address Granularity */
Descriptor->ExtAddress64.Granularity = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Granularity));
GranOp = InitializerOp;
break;
case 7: /* Min Address */
Descriptor->ExtAddress64.Minimum = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Minimum));
MinOp = InitializerOp;
break;
case 8: /* Max Address */
Descriptor->ExtAddress64.Maximum = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.Maximum));
MaxOp = InitializerOp;
break;
case 9: /* Translation Offset */
Descriptor->ExtAddress64.TranslationOffset = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TranslationOffset));
break;
case 10: /* Address Length */
Descriptor->ExtAddress64.AddressLength = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.AddressLength));
LengthOp = InitializerOp;
break;
case 11: /* Type-Specific Attributes */
Descriptor->ExtAddress64.TypeSpecific = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_TYPESPECIFICATTRIBUTES,
CurrentByteOffset + ASL_RESDESC_OFFSET (ExtAddress64.TypeSpecific));
break;
case 12: /* ResourceTag */
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
/* Validate the Min/Max/Len/Gran values */
RsLargeAddressCheck (
Descriptor->ExtAddress64.Minimum,
Descriptor->ExtAddress64.Maximum,
Descriptor->ExtAddress64.AddressLength,
Descriptor->ExtAddress64.Granularity,
Descriptor->ExtAddress64.Flags,
MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
Rnode->BufferLength = sizeof (AML_RESOURCE_EXTENDED_ADDRESS64) +
StringLength;
return (Rnode);
}

View File

@@ -0,0 +1,980 @@
/******************************************************************************
*
* Module Name: aslrestype2q - Large QWord address resource descriptors
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslrestype2q")
/*
* This module contains the QWord (64-bit) address space descriptors:
*
* QWordIO
* QWordMemory
* QwordPcc
* QWordSpace
*/
/*******************************************************************************
*
* FUNCTION: RsDoQwordIoDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a long "QwordIO" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoQwordIoDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ACPI_PARSE_OBJECT *MinOp = NULL;
ACPI_PARSE_OBJECT *MaxOp = NULL;
ACPI_PARSE_OBJECT *LengthOp = NULL;
ACPI_PARSE_OBJECT *GranOp = NULL;
ASL_RESOURCE_NODE *Rnode;
UINT8 *OptionalFields;
UINT16 StringLength = 0;
UINT32 OptionIndex = 0;
UINT32 CurrentByteOffset;
UINT32 i;
BOOLEAN ResSourceIndex = FALSE;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
StringLength = RsGetStringDataLength (InitializerOp);
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (
sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength);
Descriptor = Rnode->Buffer;
Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64;
Descriptor->Address64.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE;
/*
* Initial descriptor length -- may be enlarged if there are
* optional fields present
*/
OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64);
Descriptor->Address64.ResourceLength = (UINT16)
(sizeof (AML_RESOURCE_ADDRESS64) -
sizeof (AML_RESOURCE_LARGE_HEADER));
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Resource Usage */
RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 0, 1);
break;
case 1: /* MinType */
RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2);
break;
case 2: /* MaxType */
RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3);
break;
case 3: /* DecodeType */
RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1);
break;
case 4: /* Range Type */
RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 0, 3);
RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_RANGETYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 0, 2);
break;
case 5: /* Address Granularity */
Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity));
GranOp = InitializerOp;
break;
case 6: /* Address Min */
Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum));
MinOp = InitializerOp;
break;
case 7: /* Address Max */
Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum));
MaxOp = InitializerOp;
break;
case 8: /* Translation Offset */
Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer;
RsCreateByteField (InitializerOp, ACPI_RESTAG_TRANSLATION,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset));
break;
case 9: /* Address Length */
Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength));
LengthOp = InitializerOp;
break;
case 10: /* ResSourceIndex [Optional Field - BYTE] */
if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
{
OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
OptionIndex++;
Descriptor->Address64.ResourceLength++;
ResSourceIndex = TRUE;
}
break;
case 11: /* ResSource [Optional Field - STRING] */
if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
(InitializerOp->Asl.Value.String))
{
if (StringLength)
{
Descriptor->Address64.ResourceLength = (UINT16)
(Descriptor->Address64.ResourceLength + StringLength);
strcpy ((char *)
&OptionalFields[OptionIndex],
InitializerOp->Asl.Value.String);
/* ResourceSourceIndex must also be valid */
if (!ResSourceIndex)
{
AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
InitializerOp, NULL);
}
}
}
#if 0
/*
* Not a valid ResourceSource, ResourceSourceIndex must also
* be invalid
*/
else if (ResSourceIndex)
{
AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
InitializerOp, NULL);
}
#endif
break;
case 12: /* ResourceTag */
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
case 13: /* Type */
RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 4, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 4);
break;
case 14: /* Translation Type */
RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 5, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 5);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
/* Validate the Min/Max/Len/Gran values */
RsLargeAddressCheck (
Descriptor->Address64.Minimum,
Descriptor->Address64.Maximum,
Descriptor->Address64.AddressLength,
Descriptor->Address64.Granularity,
Descriptor->Address64.Flags,
MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) +
OptionIndex + StringLength;
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoQwordMemoryDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a long "QwordMemory" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoQwordMemoryDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ACPI_PARSE_OBJECT *MinOp = NULL;
ACPI_PARSE_OBJECT *MaxOp = NULL;
ACPI_PARSE_OBJECT *LengthOp = NULL;
ACPI_PARSE_OBJECT *GranOp = NULL;
ASL_RESOURCE_NODE *Rnode;
UINT8 *OptionalFields;
UINT16 StringLength = 0;
UINT32 OptionIndex = 0;
UINT32 CurrentByteOffset;
UINT32 i;
BOOLEAN ResSourceIndex = FALSE;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
StringLength = RsGetStringDataLength (InitializerOp);
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (
sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength);
Descriptor = Rnode->Buffer;
Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64;
Descriptor->Address64.ResourceType = ACPI_ADDRESS_TYPE_MEMORY_RANGE;
/*
* Initial descriptor length -- may be enlarged if there are
* optional fields present
*/
OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64);
Descriptor->Address64.ResourceLength = (UINT16)
(sizeof (AML_RESOURCE_ADDRESS64) -
sizeof (AML_RESOURCE_LARGE_HEADER));
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Resource Usage */
RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 0, 1);
break;
case 1: /* DecodeType */
RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1);
break;
case 2: /* MinType */
RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2);
break;
case 3: /* MaxType */
RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3);
break;
case 4: /* Memory Type */
RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 1, 0);
RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_MEMTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 1, 2);
break;
case 5: /* Read/Write Type */
RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 0, 1);
RsCreateBitField (InitializerOp, ACPI_RESTAG_READWRITETYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 0);
break;
case 6: /* Address Granularity */
Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity));
GranOp = InitializerOp;
break;
case 7: /* Min Address */
Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum));
MinOp = InitializerOp;
break;
case 8: /* Max Address */
Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum));
MaxOp = InitializerOp;
break;
case 9: /* Translation Offset */
Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset));
break;
case 10: /* Address Length */
Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength));
LengthOp = InitializerOp;
break;
case 11: /* ResSourceIndex [Optional Field - BYTE] */
if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
{
OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
OptionIndex++;
Descriptor->Address64.ResourceLength++;
ResSourceIndex = TRUE;
}
break;
case 12: /* ResSource [Optional Field - STRING] */
if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
(InitializerOp->Asl.Value.String))
{
if (StringLength)
{
Descriptor->Address64.ResourceLength = (UINT16)
(Descriptor->Address64.ResourceLength + StringLength);
strcpy ((char *)
&OptionalFields[OptionIndex],
InitializerOp->Asl.Value.String);
/* ResourceSourceIndex must also be valid */
if (!ResSourceIndex)
{
AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
InitializerOp, NULL);
}
}
}
#if 0
/*
* Not a valid ResourceSource, ResourceSourceIndex must also
* be invalid
*/
else if (ResSourceIndex)
{
AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
InitializerOp, NULL);
}
#endif
break;
case 13: /* ResourceTag */
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
case 14: /* Address Range */
RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 3, 0);
RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_MEMATTRIBUTES,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 3, 2);
break;
case 15: /* Type */
RsSetFlagBits (&Descriptor->Address64.SpecificFlags, InitializerOp, 5, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.SpecificFlags), 5);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
/* Validate the Min/Max/Len/Gran values */
RsLargeAddressCheck (
Descriptor->Address64.Minimum,
Descriptor->Address64.Maximum,
Descriptor->Address64.AddressLength,
Descriptor->Address64.Granularity,
Descriptor->Address64.Flags,
MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) +
OptionIndex + StringLength;
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoQwordPccDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a long "QWordPcc" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoQwordPccDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ACPI_PARSE_OBJECT *MinOp = NULL;
ACPI_PARSE_OBJECT *MaxOp = NULL;
ACPI_PARSE_OBJECT *LengthOp = NULL;
ACPI_PARSE_OBJECT *GranOp = NULL;
ASL_RESOURCE_NODE *Rnode;
UINT16 StringLength = 0;
UINT32 OptionIndex = 0;
UINT8 *OptionalFields;
UINT32 i;
BOOLEAN ResSourceIndex = FALSE;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
StringLength = RsGetStringDataLength (InitializerOp);
Rnode = RsAllocateResourceNode (
sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength);
Descriptor = Rnode->Buffer;
Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32;
Descriptor->Address32.ResourceType = ACPI_ADDRESS_TYPE_PCC_NUMBER;
/*
* Initial descriptor length -- may be enlarged if there are
* optional fields present
*/
OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32);
Descriptor->Address32.ResourceLength = (UINT16)
(sizeof (AML_RESOURCE_ADDRESS32) -
sizeof (AML_RESOURCE_LARGE_HEADER));
/*
* Bit [3] Max Address Fixed, _MAF: 1 (max address is fixed)
* Bit [2] Min Address Fixed,_MIF: 1 (min address is fixed)
* Bit [1] Decode Type, _DEC: 0 (do not care)
* BIT [0] Ignored (must be zero)
*/
Descriptor->Address32.Flags = 0b1100;
// No type specific flags. Set to 0.
Descriptor->Address32.SpecificFlags = 0;
// must be set to zero if _MAX == _MIN.
Descriptor->Address32.Granularity = 0x0;
/* Process all child initialization nodes */
// No translation offset.
Descriptor->Address32.TranslationOffset = 0;
// Pcc is unique address.
Descriptor->Address32.AddressLength = 1;
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Address Min = Max */
Descriptor->Address32.Minimum =
(UINT32) InitializerOp->Asl.Value.Integer;
Descriptor->Address32.Maximum =
(UINT32) InitializerOp->Asl.Value.Integer;
break;
case 1: /* ResSourceIndex [Optional Field - BYTE] */
if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
{
/* Found a valid ResourceSourceIndex */
OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
OptionIndex++;
Descriptor->Address32.ResourceLength++;
ResSourceIndex = TRUE;
}
break;
case 2: /* ResSource [Optional Field - STRING] */
if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
(InitializerOp->Asl.Value.String))
{
if (StringLength)
{
/* Found a valid ResourceSource */
Descriptor->Address32.ResourceLength = (UINT16)
(Descriptor->Address32.ResourceLength + StringLength);
strcpy ((char *)
&OptionalFields[OptionIndex],
InitializerOp->Asl.Value.String);
/* ResourceSourceIndex must also be valid */
if (!ResSourceIndex)
{
AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
InitializerOp, NULL);
}
}
}
break;
case 3: // DescriptorName
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
/* Validate the Min/Max/Len/Gran values */
RsLargeAddressCheck (
(UINT64) Descriptor->Address32.Minimum,
(UINT64) Descriptor->Address32.Maximum,
(UINT64) Descriptor->Address32.AddressLength,
(UINT64) Descriptor->Address32.Granularity,
Descriptor->Address32.Flags,
MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) +
OptionIndex + StringLength;
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoQwordSpaceDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a long "QwordSpace" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoQwordSpaceDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ACPI_PARSE_OBJECT *MinOp = NULL;
ACPI_PARSE_OBJECT *MaxOp = NULL;
ACPI_PARSE_OBJECT *LengthOp = NULL;
ACPI_PARSE_OBJECT *GranOp = NULL;
ASL_RESOURCE_NODE *Rnode;
UINT8 *OptionalFields;
UINT16 StringLength = 0;
UINT32 OptionIndex = 0;
UINT32 CurrentByteOffset;
UINT32 i;
BOOLEAN ResSourceIndex = FALSE;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
StringLength = RsGetStringDataLength (InitializerOp);
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (
sizeof (AML_RESOURCE_ADDRESS64) + 1 + StringLength);
Descriptor = Rnode->Buffer;
Descriptor->Address64.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS64;
/*
* Initial descriptor length -- may be enlarged if there are
* optional fields present
*/
OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS64);
Descriptor->Address64.ResourceLength = (UINT16)
(sizeof (AML_RESOURCE_ADDRESS64) -
sizeof (AML_RESOURCE_LARGE_HEADER));
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Resource Type */
Descriptor->Address64.ResourceType =
(UINT8) InitializerOp->Asl.Value.Integer;
break;
case 1: /* Resource Usage */
RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 0, 1);
break;
case 2: /* DecodeType */
RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 1, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 1);
break;
case 3: /* MinType */
RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 2, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 2);
break;
case 4: /* MaxType */
RsSetFlagBits (&Descriptor->Address64.Flags, InitializerOp, 3, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Flags), 3);
break;
case 5: /* Type-Specific flags */
Descriptor->Address64.SpecificFlags =
(UINT8) InitializerOp->Asl.Value.Integer;
break;
case 6: /* Address Granularity */
Descriptor->Address64.Granularity = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Granularity));
GranOp = InitializerOp;
break;
case 7: /* Min Address */
Descriptor->Address64.Minimum = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_MINADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Minimum));
MinOp = InitializerOp;
break;
case 8: /* Max Address */
Descriptor->Address64.Maximum = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_MAXADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.Maximum));
MaxOp = InitializerOp;
break;
case 9: /* Translation Offset */
Descriptor->Address64.TranslationOffset = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.TranslationOffset));
break;
case 10: /* Address Length */
Descriptor->Address64.AddressLength = InitializerOp->Asl.Value.Integer;
RsCreateQwordField (InitializerOp, ACPI_RESTAG_LENGTH,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address64.AddressLength));
LengthOp = InitializerOp;
break;
case 11: /* ResSourceIndex [Optional Field - BYTE] */
if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
{
OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
OptionIndex++;
Descriptor->Address64.ResourceLength++;
ResSourceIndex = TRUE;
}
break;
case 12: /* ResSource [Optional Field - STRING] */
if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
(InitializerOp->Asl.Value.String))
{
if (StringLength)
{
Descriptor->Address64.ResourceLength = (UINT16)
(Descriptor->Address64.ResourceLength + StringLength);
strcpy ((char *)
&OptionalFields[OptionIndex],
InitializerOp->Asl.Value.String);
/* ResourceSourceIndex must also be valid */
if (!ResSourceIndex)
{
AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
InitializerOp, NULL);
}
}
}
#if 0
/*
* Not a valid ResourceSource, ResourceSourceIndex must also
* be invalid
*/
else if (ResSourceIndex)
{
AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
InitializerOp, NULL);
}
#endif
break;
case 13: /* ResourceTag */
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
/* Validate the Min/Max/Len/Gran values */
RsLargeAddressCheck (
Descriptor->Address64.Minimum,
Descriptor->Address64.Maximum,
Descriptor->Address64.AddressLength,
Descriptor->Address64.Granularity,
Descriptor->Address64.Flags,
MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS64) +
OptionIndex + StringLength;
return (Rnode);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,961 @@
/******************************************************************************
*
* Module Name: aslrestype2w - Large Word address resource descriptors
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "aslcompiler.y.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslrestype2w")
/*
* This module contains the Word (16-bit) address space descriptors:
*
* WordIO
* WordMemory
* WordPcc
* WordSpace
*/
/*******************************************************************************
*
* FUNCTION: RsDoWordIoDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a long "WordIO" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoWordIoDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ACPI_PARSE_OBJECT *MinOp = NULL;
ACPI_PARSE_OBJECT *MaxOp = NULL;
ACPI_PARSE_OBJECT *LengthOp = NULL;
ACPI_PARSE_OBJECT *GranOp = NULL;
ASL_RESOURCE_NODE *Rnode;
UINT8 *OptionalFields;
UINT16 StringLength = 0;
UINT32 OptionIndex = 0;
UINT32 CurrentByteOffset;
UINT32 i;
BOOLEAN ResSourceIndex = FALSE;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
StringLength = RsGetStringDataLength (InitializerOp);
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (
sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength);
Descriptor = Rnode->Buffer;
Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16;
Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_IO_RANGE;
/*
* Initial descriptor length -- may be enlarged if there are
* optional fields present
*/
OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16);
Descriptor->Address16.ResourceLength = (UINT16)
(sizeof (AML_RESOURCE_ADDRESS16) -
sizeof (AML_RESOURCE_LARGE_HEADER));
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Resource Usage */
RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1);
break;
case 1: /* MinType */
RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2);
break;
case 2: /* MaxType */
RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3);
break;
case 3: /* DecodeType */
RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1);
break;
case 4: /* Range Type */
RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 0, 3);
RsCreateMultiBitField (InitializerOp, ACPI_RESTAG_RANGETYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 0, 2);
break;
case 5: /* Address Granularity */
Descriptor->Address16.Granularity = (UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
GranOp = InitializerOp;
break;
case 6: /* Address Min */
Descriptor->Address16.Minimum = (UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
MinOp = InitializerOp;
break;
case 7: /* Address Max */
Descriptor->Address16.Maximum = (UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
MaxOp = InitializerOp;
break;
case 8: /* Translation Offset */
Descriptor->Address16.TranslationOffset = (UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
break;
case 9: /* Address Length */
Descriptor->Address16.AddressLength = (UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
LengthOp = InitializerOp;
break;
case 10: /* ResSourceIndex [Optional Field - BYTE] */
if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
{
OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
OptionIndex++;
Descriptor->Address16.ResourceLength++;
ResSourceIndex = TRUE;
}
break;
case 11: /* ResSource [Optional Field - STRING] */
if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
(InitializerOp->Asl.Value.String))
{
if (StringLength)
{
Descriptor->Address16.ResourceLength = (UINT16)
(Descriptor->Address16.ResourceLength + StringLength);
strcpy ((char *)
&OptionalFields[OptionIndex],
InitializerOp->Asl.Value.String);
/* ResourceSourceIndex must also be valid */
if (!ResSourceIndex)
{
AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
InitializerOp, NULL);
}
}
}
#if 0
/*
* Not a valid ResourceSource, ResourceSourceIndex must also
* be invalid
*/
else if (ResSourceIndex)
{
AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
InitializerOp, NULL);
}
#endif
break;
case 12: /* ResourceTag */
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
case 13: /* Type */
RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 4, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_TYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 4);
break;
case 14: /* Translation Type */
RsSetFlagBits (&Descriptor->Address16.SpecificFlags, InitializerOp, 5, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_TRANSTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.SpecificFlags), 5);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
/* Validate the Min/Max/Len/Gran values */
RsLargeAddressCheck (
(UINT64) Descriptor->Address16.Minimum,
(UINT64) Descriptor->Address16.Maximum,
(UINT64) Descriptor->Address16.AddressLength,
(UINT64) Descriptor->Address16.Granularity,
Descriptor->Address16.Flags,
MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
OptionIndex + StringLength;
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoWordBusNumberDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a long "WordBusNumber" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoWordBusNumberDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ACPI_PARSE_OBJECT *MinOp = NULL;
ACPI_PARSE_OBJECT *MaxOp = NULL;
ACPI_PARSE_OBJECT *LengthOp = NULL;
ACPI_PARSE_OBJECT *GranOp = NULL;
ASL_RESOURCE_NODE *Rnode;
UINT8 *OptionalFields;
UINT16 StringLength = 0;
UINT32 OptionIndex = 0;
UINT32 CurrentByteOffset;
UINT32 i;
BOOLEAN ResSourceIndex = FALSE;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
StringLength = RsGetStringDataLength (InitializerOp);
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (
sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength);
Descriptor = Rnode->Buffer;
Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16;
Descriptor->Address16.ResourceType = ACPI_ADDRESS_TYPE_BUS_NUMBER_RANGE;
/*
* Initial descriptor length -- may be enlarged if there are
* optional fields present
*/
OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16);
Descriptor->Address16.ResourceLength = (UINT16)
(sizeof (AML_RESOURCE_ADDRESS16) -
sizeof (AML_RESOURCE_LARGE_HEADER));
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Resource Usage */
RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1);
break;
case 1: /* MinType */
RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2);
break;
case 2: /* MaxType */
RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3);
break;
case 3: /* DecodeType */
RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1);
break;
case 4: /* Address Granularity */
Descriptor->Address16.Granularity =
(UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
GranOp = InitializerOp;
break;
case 5: /* Min Address */
Descriptor->Address16.Minimum =
(UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
MinOp = InitializerOp;
break;
case 6: /* Max Address */
Descriptor->Address16.Maximum =
(UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
MaxOp = InitializerOp;
break;
case 7: /* Translation Offset */
Descriptor->Address16.TranslationOffset =
(UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
break;
case 8: /* Address Length */
Descriptor->Address16.AddressLength =
(UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
LengthOp = InitializerOp;
break;
case 9: /* ResSourceIndex [Optional Field - BYTE] */
if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
{
OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
OptionIndex++;
Descriptor->Address16.ResourceLength++;
ResSourceIndex = TRUE;
}
break;
case 10: /* ResSource [Optional Field - STRING] */
if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
(InitializerOp->Asl.Value.String))
{
if (StringLength)
{
Descriptor->Address16.ResourceLength = (UINT16)
(Descriptor->Address16.ResourceLength + StringLength);
strcpy ((char *)
&OptionalFields[OptionIndex],
InitializerOp->Asl.Value.String);
/* ResourceSourceIndex must also be valid */
if (!ResSourceIndex)
{
AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
InitializerOp, NULL);
}
}
}
#if 0
/*
* Not a valid ResourceSource, ResourceSourceIndex must also
* be invalid
*/
else if (ResSourceIndex)
{
AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
InitializerOp, NULL);
}
#endif
break;
case 11: /* ResourceTag */
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
/* Validate the Min/Max/Len/Gran values */
RsLargeAddressCheck (
(UINT64) Descriptor->Address16.Minimum,
(UINT64) Descriptor->Address16.Maximum,
(UINT64) Descriptor->Address16.AddressLength,
(UINT64) Descriptor->Address16.Granularity,
Descriptor->Address16.Flags,
MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
OptionIndex + StringLength;
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoWordPccDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a long "WordPcc" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoWordPccDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ACPI_PARSE_OBJECT *MinOp = NULL;
ACPI_PARSE_OBJECT *MaxOp = NULL;
ACPI_PARSE_OBJECT *LengthOp = NULL;
ACPI_PARSE_OBJECT *GranOp = NULL;
ASL_RESOURCE_NODE *Rnode;
UINT16 StringLength = 0;
UINT32 OptionIndex = 0;
UINT8 *OptionalFields;
UINT32 i;
BOOLEAN ResSourceIndex = FALSE;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
StringLength = RsGetStringDataLength (InitializerOp);
Rnode = RsAllocateResourceNode (
sizeof (AML_RESOURCE_ADDRESS32) + 1 + StringLength);
Descriptor = Rnode->Buffer;
Descriptor->Address32.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS32;
Descriptor->Address32.ResourceType = ACPI_ADDRESS_TYPE_PCC_NUMBER;
/*
* Initial descriptor length -- may be enlarged if there are
* optional fields present
*/
OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS32);
Descriptor->Address32.ResourceLength = (UINT16)
(sizeof (AML_RESOURCE_ADDRESS32) -
sizeof (AML_RESOURCE_LARGE_HEADER));
/*
* Bit [3] Max Address Fixed, _MAF: 1 (max address is fixed)
* Bit [2] Min Address Fixed,_MIF: 1 (min address is fixed)
* Bit [1] Decode Type, _DEC: 0 (do not care)
* BIT [0] Ignored (must be zero)
*/
Descriptor->Address32.Flags = 0b1100;
// No type specific flags. Set to 0.
Descriptor->Address32.SpecificFlags = 0;
// must be set to zero if _MAX == _MIN.
Descriptor->Address32.Granularity = 0x0;
/* Process all child initialization nodes */
// No translation offset.
Descriptor->Address32.TranslationOffset = 0;
// Pcc is unique address.
Descriptor->Address32.AddressLength = 1;
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Address Min = Max */
Descriptor->Address32.Minimum =
(UINT32) InitializerOp->Asl.Value.Integer;
Descriptor->Address32.Maximum =
(UINT32) InitializerOp->Asl.Value.Integer;
break;
case 1: /* ResSourceIndex [Optional Field - BYTE] */
if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
{
/* Found a valid ResourceSourceIndex */
OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
OptionIndex++;
Descriptor->Address32.ResourceLength++;
ResSourceIndex = TRUE;
}
break;
case 2: /* ResSource [Optional Field - STRING] */
if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
(InitializerOp->Asl.Value.String))
{
if (StringLength)
{
/* Found a valid ResourceSource */
Descriptor->Address32.ResourceLength = (UINT16)
(Descriptor->Address32.ResourceLength + StringLength);
strcpy ((char *)
&OptionalFields[OptionIndex],
InitializerOp->Asl.Value.String);
/* ResourceSourceIndex must also be valid */
if (!ResSourceIndex)
{
AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
InitializerOp, NULL);
}
}
}
break;
case 3: // DescriptorName
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
/* Validate the Min/Max/Len/Gran values */
RsLargeAddressCheck (
(UINT64) Descriptor->Address32.Minimum,
(UINT64) Descriptor->Address32.Maximum,
(UINT64) Descriptor->Address32.AddressLength,
(UINT64) Descriptor->Address32.Granularity,
Descriptor->Address32.Flags,
MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS32) +
OptionIndex + StringLength;
return (Rnode);
}
/*******************************************************************************
*
* FUNCTION: RsDoWordSpaceDescriptor
*
* PARAMETERS: Info - Parse Op and resource template offset
*
* RETURN: Completed resource node
*
* DESCRIPTION: Construct a long "WordSpace" descriptor
*
******************************************************************************/
ASL_RESOURCE_NODE *
RsDoWordSpaceDescriptor (
ASL_RESOURCE_INFO *Info)
{
AML_RESOURCE *Descriptor;
ACPI_PARSE_OBJECT *InitializerOp;
ACPI_PARSE_OBJECT *MinOp = NULL;
ACPI_PARSE_OBJECT *MaxOp = NULL;
ACPI_PARSE_OBJECT *LengthOp = NULL;
ACPI_PARSE_OBJECT *GranOp = NULL;
ASL_RESOURCE_NODE *Rnode;
UINT8 *OptionalFields;
UINT16 StringLength = 0;
UINT32 OptionIndex = 0;
UINT32 CurrentByteOffset;
UINT32 i;
BOOLEAN ResSourceIndex = FALSE;
InitializerOp = Info->DescriptorTypeOp->Asl.Child;
StringLength = RsGetStringDataLength (InitializerOp);
CurrentByteOffset = Info->CurrentByteOffset;
Rnode = RsAllocateResourceNode (
sizeof (AML_RESOURCE_ADDRESS16) + 1 + StringLength);
Descriptor = Rnode->Buffer;
Descriptor->Address16.DescriptorType = ACPI_RESOURCE_NAME_ADDRESS16;
/*
* Initial descriptor length -- may be enlarged if there are
* optional fields present
*/
OptionalFields = ((UINT8 *) Descriptor) + sizeof (AML_RESOURCE_ADDRESS16);
Descriptor->Address16.ResourceLength = (UINT16)
(sizeof (AML_RESOURCE_ADDRESS16) -
sizeof (AML_RESOURCE_LARGE_HEADER));
/* Process all child initialization nodes */
for (i = 0; InitializerOp; i++)
{
switch (i)
{
case 0: /* Resource Type */
Descriptor->Address16.ResourceType =
(UINT8) InitializerOp->Asl.Value.Integer;
break;
case 1: /* Resource Usage */
RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 0, 1);
break;
case 2: /* DecodeType */
RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 1, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_DECODE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 1);
break;
case 3: /* MinType */
RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 2, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_MINTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 2);
break;
case 4: /* MaxType */
RsSetFlagBits (&Descriptor->Address16.Flags, InitializerOp, 3, 0);
RsCreateBitField (InitializerOp, ACPI_RESTAG_MAXTYPE,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Flags), 3);
break;
case 5: /* Type-Specific flags */
Descriptor->Address16.SpecificFlags =
(UINT8) InitializerOp->Asl.Value.Integer;
break;
case 6: /* Address Granularity */
Descriptor->Address16.Granularity =
(UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_GRANULARITY,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Granularity));
GranOp = InitializerOp;
break;
case 7: /* Min Address */
Descriptor->Address16.Minimum =
(UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_MINADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Minimum));
MinOp = InitializerOp;
break;
case 8: /* Max Address */
Descriptor->Address16.Maximum =
(UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_MAXADDR,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.Maximum));
MaxOp = InitializerOp;
break;
case 9: /* Translation Offset */
Descriptor->Address16.TranslationOffset =
(UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_TRANSLATION,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.TranslationOffset));
break;
case 10: /* Address Length */
Descriptor->Address16.AddressLength =
(UINT16) InitializerOp->Asl.Value.Integer;
RsCreateWordField (InitializerOp, ACPI_RESTAG_LENGTH,
CurrentByteOffset + ASL_RESDESC_OFFSET (Address16.AddressLength));
LengthOp = InitializerOp;
break;
case 11: /* ResSourceIndex [Optional Field - BYTE] */
if (InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG)
{
OptionalFields[0] = (UINT8) InitializerOp->Asl.Value.Integer;
OptionIndex++;
Descriptor->Address16.ResourceLength++;
ResSourceIndex = TRUE;
}
break;
case 12: /* ResSource [Optional Field - STRING] */
if ((InitializerOp->Asl.ParseOpcode != PARSEOP_DEFAULT_ARG) &&
(InitializerOp->Asl.Value.String))
{
if (StringLength)
{
Descriptor->Address16.ResourceLength = (UINT16)
(Descriptor->Address16.ResourceLength + StringLength);
strcpy ((char *)
&OptionalFields[OptionIndex],
InitializerOp->Asl.Value.String);
/* ResourceSourceIndex must also be valid */
if (!ResSourceIndex)
{
AslError (ASL_ERROR, ASL_MSG_RESOURCE_INDEX,
InitializerOp, NULL);
}
}
}
#if 0
/*
* Not a valid ResourceSource, ResourceSourceIndex must also
* be invalid
*/
else if (ResSourceIndex)
{
AslError (ASL_ERROR, ASL_MSG_RESOURCE_SOURCE,
InitializerOp, NULL);
}
#endif
break;
case 13: /* ResourceTag */
UtAttachNamepathToOwner (Info->DescriptorTypeOp, InitializerOp);
break;
default:
AslError (ASL_ERROR, ASL_MSG_RESOURCE_LIST, InitializerOp, NULL);
break;
}
InitializerOp = RsCompleteNodeAndGetNext (InitializerOp);
}
/* Validate the Min/Max/Len/Gran values */
RsLargeAddressCheck (
(UINT64) Descriptor->Address16.Minimum,
(UINT64) Descriptor->Address16.Maximum,
(UINT64) Descriptor->Address16.AddressLength,
(UINT64) Descriptor->Address16.Granularity,
Descriptor->Address16.Flags,
MinOp, MaxOp, LengthOp, GranOp, Info->DescriptorTypeOp);
Rnode->BufferLength = sizeof (AML_RESOURCE_ADDRESS16) +
OptionIndex + StringLength;
return (Rnode);
}

View File

@@ -0,0 +1,890 @@
NoEcho('
/******************************************************************************
*
* Module Name: aslrules.y - Main Bison/Yacc production rules
* - Keep this file synched with the
* CvParseOpBlockType function in cvcompiler.c
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
')
/*******************************************************************************
*
* ASL Root and Secondary Terms
*
******************************************************************************/
/*
* Root term. Allow multiple #line directives before the definition block
* to handle output from preprocessors
*/
AslCode
: DefinitionBlockList {$<n>$ = TrLinkOpChildren (
TrCreateLeafOp (PARSEOP_ASL_CODE),1, $1);}
| error {YYABORT; $$ = NULL;}
;
/*
* Note concerning support for "module-level code".
*
* ACPI 1.0 allowed Type1 and Type2 executable opcodes outside of control
* methods (the so-called module-level code.) This support was explicitly
* removed in ACPI 2.0, but this type of code continues to be created by
* BIOS vendors. In order to support the disassembly and recompilation of
* such code (and the porting of ASL code to iASL), iASL supports this
* code in violation of the current ACPI specification.
*
* The grammar change to support module-level code is to revert the
* {ObjectList} portion of the DefinitionBlockTerm in ACPI 2.0 to the
* original use of {TermList} instead (see below.) This allows the use
* of Type1 and Type2 opcodes at module level.
*
* 04/2016: The module-level code is now allowed in the following terms:
* DeviceTerm, PowerResTerm, ProcessorTerm, ScopeTerm, ThermalZoneTerm.
* The ObjectList term is obsolete and has been removed.
*/
DefinitionBlockTerm
: PARSEOP_DEFINITION_BLOCK
PARSEOP_OPEN_PAREN {$<n>$ = TrCreateLeafOp (PARSEOP_DEFINITION_BLOCK); COMMENT_CAPTURE_OFF;}
String ','
String ','
ByteConst ','
String ','
String ','
DWordConst
PARSEOP_CLOSE_PAREN {TrSetOpIntegerWidth ($6,$8);
TrSetOpEndLineNumber ($<n>3); COMMENT_CAPTURE_ON;}
'{' TermList '}' {$$ = TrLinkOpChildren ($<n>3,7,
$4,$6,$8,$10,$12,$14,$18);}
;
DefinitionBlockList
: DefinitionBlockTerm
| DefinitionBlockTerm
DefinitionBlockList {$$ = TrLinkPeerOps (2, $1,$2);}
;
/******* Basic ASCII identifiers **************************************************/
/* Allow IO, DMA, IRQ Resource macro and FOR macro names to also be used as identifiers */
NameString
: NameSeg {}
| PARSEOP_NAMESTRING {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) $1);}
| PARSEOP_IO {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IO");}
| PARSEOP_DMA {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "DMA");}
| PARSEOP_IRQ {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "IRQ");}
| PARSEOP_FOR {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESTRING, (ACPI_NATIVE_INT) "FOR");}
;
/*
NameSeg
: PARSEOP_NAMESEG {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESEG, (ACPI_NATIVE_INT)
TrNormalizeNameSeg ($1));}
;
*/
NameSeg
: PARSEOP_NAMESEG {$$ = TrCreateValuedLeafOp (PARSEOP_NAMESEG,
(ACPI_NATIVE_INT) AslCompilerlval.s);}
;
/******* Fundamental argument/statement types ***********************************/
Term
: Object {}
| Type1Opcode {}
| Type2Opcode {}
| Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);}
| Type2StringOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);}
| Type2BufferOpcode {}
| Type2BufferOrStringOpcode {}
| error {$$ = AslDoError(); yyclearin;}
;
SuperName
: SimpleName {}
| DebugTerm {}
| Type6Opcode {}
;
Target
: {$$ = TrCreateNullTargetOp ();} /* Placeholder is a ZeroOp object */
| ',' {$$ = TrCreateNullTargetOp ();} /* Placeholder is a ZeroOp object */
| ',' SuperName {$$ = TrSetOpFlags ($2, OP_IS_TARGET);}
;
/*
RequiredTarget
: ',' SuperName {$$ = TrSetOpFlags ($2, OP_IS_TARGET);}
;
*/
TermArg
: SimpleName {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);}
| Type2Opcode {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);}
| DataObject {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);}
| PARSEOP_OPEN_PAREN
TermArg
PARSEOP_CLOSE_PAREN {$$ = TrSetOpFlags ($2, OP_IS_TERM_ARG);}
;
/*
NOTE: Removed from TermArg due to reduce/reduce conflicts:
| Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);}
| Type2StringOpcode {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);}
| Type2BufferOpcode {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);}
| Type2BufferOrStringOpcode {$$ = TrSetOpFlags ($1, OP_IS_TERM_ARG);}
*/
MethodInvocationTerm
: NameString
PARSEOP_OPEN_PAREN {TrSetOpIntegerValue (PARSEOP_METHODCALL, $1); COMMENT_CAPTURE_OFF;}
ArgList
PARSEOP_CLOSE_PAREN {$$ = TrLinkChildOp ($1,$4); COMMENT_CAPTURE_ON;}
;
/* OptionalCount must appear before ByteList or an incorrect reduction will result */
OptionalCount
: {$$ = TrCreateLeafOp (PARSEOP_ONES);} /* Placeholder is a OnesOp object */
| ',' {$$ = TrCreateLeafOp (PARSEOP_ONES);} /* Placeholder is a OnesOp object */
| ',' TermArg {$$ = $2;}
;
/*
* Data count for buffers and packages (byte count for buffers,
* element count for packages).
*/
OptionalDataCount
/* Legacy ASL */
: {$$ = NULL;}
| PARSEOP_OPEN_PAREN
TermArg
PARSEOP_CLOSE_PAREN {$$ = $2;}
| PARSEOP_OPEN_PAREN
PARSEOP_CLOSE_PAREN {$$ = NULL;}
/* C-style (ASL+) -- adds equals term */
| PARSEOP_EXP_EQUALS {$$ = NULL;}
| PARSEOP_OPEN_PAREN
TermArg
PARSEOP_CLOSE_PAREN
PARSEOP_EXP_EQUALS {$$ = $2;}
| PARSEOP_OPEN_PAREN
PARSEOP_CLOSE_PAREN
String
PARSEOP_EXP_EQUALS {$$ = NULL;}
;
/******* List Terms **************************************************/
/* ACPI 3.0 -- allow semicolons between terms */
TermList
: {$$ = NULL;}
| TermList Term {$$ = TrLinkPeerOp (
TrSetOpFlags ($1, OP_RESULT_NOT_USED),$2);}
| TermList Term ';' {$$ = TrLinkPeerOp (
TrSetOpFlags ($1, OP_RESULT_NOT_USED),$2);}
| TermList ';' Term {$$ = TrLinkPeerOp (
TrSetOpFlags ($1, OP_RESULT_NOT_USED),$3);}
| TermList ';' Term ';' {$$ = TrLinkPeerOp (
TrSetOpFlags ($1, OP_RESULT_NOT_USED),$3);}
;
ArgList
: {$$ = NULL;}
| TermArg
| ArgList ',' /* Allows a trailing comma at list end */
| ArgList ','
TermArg {$$ = TrLinkPeerOp ($1,$3);}
;
ByteList
: {$$ = NULL;}
| ByteConstExpr
| ByteList ',' /* Allows a trailing comma at list end */
| ByteList ','
ByteConstExpr {$$ = TrLinkPeerOp ($1,$3);}
;
DWordList
: {$$ = NULL;}
| DWordConstExpr
| DWordList ',' /* Allows a trailing comma at list end */
| DWordList ','
DWordConstExpr {$$ = TrLinkPeerOp ($1,$3);}
;
FieldUnitList
: {$$ = NULL;}
| FieldUnit
| FieldUnitList ',' /* Allows a trailing comma at list end */
| FieldUnitList ','
FieldUnit {$$ = TrLinkPeerOp ($1,$3);}
;
FieldUnit
: FieldUnitEntry {}
| OffsetTerm {}
| AccessAsTerm {}
| ConnectionTerm {}
;
FieldUnitEntry
: ',' AmlPackageLengthTerm {$$ = TrCreateOp (PARSEOP_RESERVED_BYTES,1,$2);}
| NameSeg ','
AmlPackageLengthTerm {$$ = TrLinkChildOp ($1,$3);}
;
Object
: CompilerDirective {}
| NamedObject {}
| NameSpaceModifier {}
/* | StructureTerm {} */
;
PackageList
: {$$ = NULL;}
| PackageElement
| PackageList ',' /* Allows a trailing comma at list end */
| PackageList ','
PackageElement {$$ = TrLinkPeerOp ($1,$3);}
;
PackageElement
: DataObject {}
| NameString {}
;
/* Rules for specifying the type of one method argument or return value */
ParameterTypePackage
: {$$ = NULL;}
| ObjectTypeKeyword {$$ = $1;}
| ParameterTypePackage ','
ObjectTypeKeyword {$$ = TrLinkPeerOps (2,$1,$3);}
;
ParameterTypePackageList
: {$$ = NULL;}
| ObjectTypeKeyword {$$ = TrLinkOpChildren (
TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$1);}
| '{' ParameterTypePackage '}' {$$ = TrLinkOpChildren (
TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$2);}
;
OptionalParameterTypePackage
: {$$ = NULL;}
| ',' ParameterTypePackageList {$$ = $2;}
;
/* Rules for specifying the types for method arguments */
ParameterTypesPackage
: ParameterTypePackageList {$$ = $1;}
| ParameterTypesPackage ','
ParameterTypePackageList {$$ = TrLinkPeerOps (2,$1,$3);}
;
ParameterTypesPackageList
: {$$ = NULL;}
| ObjectTypeKeyword {$$ = TrLinkOpChildren (
TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$1);}
| '{' ParameterTypesPackage '}' {$$ = TrLinkOpChildren (
TrCreateLeafOp (PARSEOP_DEFAULT_ARG),1,$2);}
;
OptionalParameterTypesPackage
: {$$ = NULL;}
| ',' ParameterTypesPackageList {$$ = $2;}
;
/*
* Case-Default list; allow only one Default term and unlimited Case terms
*/
CaseDefaultTermList
: {$$ = NULL;}
| CaseTerm {}
| DefaultTerm {}
| CaseDefaultTermList
CaseTerm {$$ = TrLinkPeerOp ($1,$2);}
| CaseDefaultTermList
DefaultTerm {$$ = TrLinkPeerOp ($1,$2);}
/* Original - attempts to force zero or one default term within the switch */
/*
CaseDefaultTermList
: {$$ = NULL;}
| CaseTermList
DefaultTerm
CaseTermList {$$ = TrLinkPeerOp ($1,TrLinkPeerOp ($2, $3));}
| CaseTermList
CaseTerm {$$ = TrLinkPeerOp ($1,$2);}
;
CaseTermList
: {$$ = NULL;}
| CaseTerm {}
| CaseTermList
CaseTerm {$$ = TrLinkPeerOp ($1,$2);}
;
*/
/*******************************************************************************
*
* ASL Data and Constant Terms
*
******************************************************************************/
DataObject
: BufferData {}
| PackageData {}
| IntegerData {}
| StringData {}
;
BufferData
: Type5Opcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);}
| Type2BufferOrStringOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);}
| Type2BufferOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);}
| BufferTerm {}
;
PackageData
: PackageTerm {}
;
IntegerData
: Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);}
| Type3Opcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);}
| Integer {}
| ConstTerm {}
;
StringData
: Type2StringOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);}
| String {}
;
StringLiteral
: String {}
;
ByteConst
: Integer {$$ = TrSetOpIntegerValue (PARSEOP_BYTECONST, $1);}
;
WordConst
: Integer {$$ = TrSetOpIntegerValue (PARSEOP_WORDCONST, $1);}
;
DWordConst
: Integer {$$ = TrSetOpIntegerValue (PARSEOP_DWORDCONST, $1);}
;
QWordConst
: Integer {$$ = TrSetOpIntegerValue (PARSEOP_QWORDCONST, $1);}
;
/*
* The OP_COMPILE_TIME_CONST flag in the following constant expressions
* enables compile-time constant folding to reduce the Type3Opcodes/Type2IntegerOpcodes
* to simple integers. It is an error if these types of expressions cannot be
* reduced, since the AML grammar for ****ConstExpr requires a simple constant.
* Note: The required byte length of the constant is passed through to the
* constant folding code in the node AmlLength field.
*/
ByteConstExpr
: Type3Opcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);
TrSetOpAmlLength ($1, 1);}
| Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);
TrSetOpAmlLength ($1, 1);}
| ConstExprTerm {$$ = TrSetOpIntegerValue (PARSEOP_BYTECONST, $1);}
| ByteConst {}
;
WordConstExpr
: Type3Opcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);
TrSetOpAmlLength ($1, 2);}
| Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);
TrSetOpAmlLength ($1, 2);}
| ConstExprTerm {$$ = TrSetOpIntegerValue (PARSEOP_WORDCONST, $1);}
| WordConst {}
;
DWordConstExpr
: Type3Opcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);
TrSetOpAmlLength ($1, 4);}
| Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);
TrSetOpAmlLength ($1, 4);}
| ConstExprTerm {$$ = TrSetOpIntegerValue (PARSEOP_DWORDCONST, $1);}
| DWordConst {}
;
QWordConstExpr
: Type3Opcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);
TrSetOpAmlLength ($1, 8);}
| Type2IntegerOpcode {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);
TrSetOpAmlLength ($1, 8);}
| ConstExprTerm {$$ = TrSetOpIntegerValue (PARSEOP_QWORDCONST, $1);}
| QWordConst {}
;
ConstTerm
: ConstExprTerm {}
| PARSEOP_REVISION {$$ = TrCreateLeafOp (PARSEOP_REVISION);}
;
ConstExprTerm
: PARSEOP_ZERO {$$ = TrCreateValuedLeafOp (PARSEOP_ZERO, 0);}
| PARSEOP_ONE {$$ = TrCreateValuedLeafOp (PARSEOP_ONE, 1);}
| PARSEOP_ONES {$$ = TrCreateValuedLeafOp (PARSEOP_ONES, ACPI_UINT64_MAX);}
| PARSEOP___DATE__ {$$ = TrCreateConstantLeafOp (PARSEOP___DATE__);}
| PARSEOP___FILE__ {$$ = TrCreateConstantLeafOp (PARSEOP___FILE__);}
| PARSEOP___LINE__ {$$ = TrCreateConstantLeafOp (PARSEOP___LINE__);}
| PARSEOP___PATH__ {$$ = TrCreateConstantLeafOp (PARSEOP___PATH__);}
| PARSEOP___METHOD__ {$$ = TrCreateConstantLeafOp (PARSEOP___METHOD__);}
;
Integer
: PARSEOP_INTEGER {$$ = TrCreateValuedLeafOp (PARSEOP_INTEGER,
AslCompilerlval.i);}
;
String
: PARSEOP_STRING_LITERAL {$$ = TrCreateValuedLeafOp (PARSEOP_STRING_LITERAL,
(ACPI_NATIVE_INT) AslCompilerlval.s);}
;
/*******************************************************************************
*
* ASL Opcode Terms
*
******************************************************************************/
CompilerDirective
: IncludeTerm {}
| IncludeEndTerm {}
| ExternalTerm {}
;
NamedObject
: BankFieldTerm {}
| CreateBitFieldTerm {}
| CreateByteFieldTerm {}
| CreateDWordFieldTerm {}
| CreateFieldTerm {}
| CreateQWordFieldTerm {}
| CreateWordFieldTerm {}
| DataRegionTerm {}
| DeviceTerm {}
| EventTerm {}
| FieldTerm {}
| FunctionTerm {}
| IndexFieldTerm {}
| MethodTerm {}
| MutexTerm {}
| OpRegionTerm {}
| PowerResTerm {}
| ProcessorTerm {}
| ThermalZoneTerm {}
;
NameSpaceModifier
: AliasTerm {}
| NameTerm {}
/* | NameTermAslPlus {} */
| ScopeTerm {}
;
SimpleName
: NameString {}
| LocalTerm {}
| ArgTerm {}
;
/* For ObjectType(), SuperName except for MethodInvocationTerm */
ObjectTypeSource
: SimpleName {}
| DebugTerm {}
| RefOfTerm {}
| DerefOfTerm {}
| IndexTerm {}
| IndexExpTerm {}
;
/* For DeRefOf(), SuperName except for DerefOf and Debug */
DerefOfSource
: SimpleName {}
| RefOfTerm {}
| DerefOfTerm {}
| IndexTerm {}
| IndexExpTerm {}
| StoreTerm {}
| EqualsTerm {}
| MethodInvocationTerm {}
;
/* For RefOf(), SuperName except for RefOf and MethodInvocationTerm */
RefOfSource
: SimpleName {}
| DebugTerm {}
| DerefOfTerm {}
| IndexTerm {}
| IndexExpTerm {}
;
/* For CondRefOf(), SuperName except for RefOf and MethodInvocationTerm */
CondRefOfSource
: SimpleName {}
| DebugTerm {}
| DerefOfTerm {}
| IndexTerm {}
| IndexExpTerm {}
;
/*
* Opcode types, as defined in the ACPI specification
*/
Type1Opcode
: BreakTerm {}
| BreakPointTerm {}
| ContinueTerm {}
| FatalTerm {}
| ForTerm {}
| ElseIfTerm {}
| NoOpTerm {}
| NotifyTerm {}
| ReleaseTerm {}
| ResetTerm {}
| ReturnTerm {}
| SignalTerm {}
| SleepTerm {}
| StallTerm {}
| SwitchTerm {}
| UnloadTerm {}
| WhileTerm {}
;
Type2Opcode
: AcquireTerm {}
| CondRefOfTerm {}
| CopyObjectTerm {}
| DerefOfTerm {}
| LoadTerm {} /* Moved from Type1 -- now returns an integer (ACPI 6.4) */
| ObjectTypeTerm {}
| RefOfTerm {}
| SizeOfTerm {}
| StoreTerm {}
| EqualsTerm {}
| TimerTerm {}
| WaitTerm {}
| MethodInvocationTerm {}
;
/*
* Type 3/4/5 opcodes
*/
Type2IntegerOpcode /* "Type3" opcodes */
: Expression {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);}
| AddTerm {}
| AndTerm {}
| DecTerm {}
| DivideTerm {}
| FindSetLeftBitTerm {}
| FindSetRightBitTerm {}
| FromBCDTerm {}
| IncTerm {}
| IndexTerm {}
/* | StructureIndexTerm {} */
/* | StructurePointerTerm {} */
| LAndTerm {}
| LEqualTerm {}
| LGreaterTerm {}
| LGreaterEqualTerm {}
| LLessTerm {}
| LLessEqualTerm {}
| LNotTerm {}
| LNotEqualTerm {}
| LoadTableTerm {}
| LOrTerm {}
| MatchTerm {}
| ModTerm {}
| MultiplyTerm {}
| NAndTerm {}
| NOrTerm {}
| NotTerm {}
| OrTerm {}
| ShiftLeftTerm {}
| ShiftRightTerm {}
| SubtractTerm {}
| ToBCDTerm {}
| ToIntegerTerm {}
| XOrTerm {}
;
Type2StringOpcode /* "Type4" Opcodes */
: ToDecimalStringTerm {}
| ToHexStringTerm {}
| ToStringTerm {}
;
Type2BufferOpcode /* "Type5" Opcodes */
: ToBufferTerm {}
| ConcatResTerm {}
;
Type2BufferOrStringOpcode
: ConcatTerm {$$ = TrSetOpFlags ($1, OP_COMPILE_TIME_CONST);}
| PrintfTerm {}
| FprintfTerm {}
| MidTerm {}
;
/*
* A type 3 opcode evaluates to an Integer and cannot have a destination operand
*/
Type3Opcode
: EISAIDTerm {}
;
/* Obsolete
Type4Opcode
: ConcatTerm {}
| ToDecimalStringTerm {}
| ToHexStringTerm {}
| MidTerm {}
| ToStringTerm {}
;
*/
/* Type 5 opcodes are a subset of Type2 opcodes, and return a constant */
Type5Opcode
: ResourceTemplateTerm {}
| UnicodeTerm {}
| ToPLDTerm {}
| ToUUIDTerm {}
;
Type6Opcode
: RefOfTerm {}
| DerefOfTerm {}
| IndexTerm {}
| IndexExpTerm {}
/* | StructureIndexTerm {} */
/* | StructurePointerTerm {} */
| MethodInvocationTerm {}
;
/*******************************************************************************
*
* ASL Helper Terms
*
******************************************************************************/
AmlPackageLengthTerm
: Integer {$$ = TrSetOpIntegerValue (PARSEOP_PACKAGE_LENGTH,
(ACPI_PARSE_OBJECT *) $1);}
;
NameStringItem
: ',' NameString {$$ = $2;}
| ',' error {$$ = AslDoError (); yyclearin;}
;
TermArgItem
: ',' TermArg {$$ = $2;}
| ',' error {$$ = AslDoError (); yyclearin;}
;
OptionalReference
: {$$ = TrCreateLeafOp (PARSEOP_ZERO);} /* Placeholder is a ZeroOp object */
| ',' {$$ = TrCreateLeafOp (PARSEOP_ZERO);} /* Placeholder is a ZeroOp object */
| ',' TermArg {$$ = $2;}
;
OptionalReturnArg
: {$$ = TrSetOpFlags (TrCreateLeafOp (PARSEOP_ZERO),
OP_IS_NULL_RETURN);} /* Placeholder is a ZeroOp object */
| TermArg {$$ = $1;}
;
OptionalSerializeRuleKeyword
: {$$ = NULL;}
| ',' {$$ = NULL;}
| ',' SerializeRuleKeyword {$$ = $2;}
;
OptionalTermArg
: {$$ = TrCreateLeafOp (PARSEOP_DEFAULT_ARG);}
| TermArg {$$ = $1;}
;
OptionalWordConst
: {$$ = NULL;}
| WordConst {$$ = $1;}
;

View File

@@ -0,0 +1,642 @@
/******************************************************************************
*
* Module Name: aslstartup - Compiler startup routines, called from main
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "actables.h"
#include "acdisasm.h"
#include "acapps.h"
#include "acconvert.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslstartup")
/* Local prototypes */
static UINT8
AslDetectSourceFileType (
ASL_FILE_INFO *Info);
/* Globals */
static BOOLEAN AslToFile = TRUE;
/*******************************************************************************
*
* FUNCTION: AslInitializeGlobals
*
* PARAMETERS: None
*
* RETURN: None
*
* DESCRIPTION: Re-initialize globals needed to restart the compiler. This
* allows multiple files to be disassembled and/or compiled.
*
******************************************************************************/
void
AslInitializeGlobals (
void)
{
UINT32 i;
/* Init compiler globals */
AslGbl_SyntaxError = 0;
AslGbl_CurrentColumn = 0;
AslGbl_CurrentLineNumber = 1;
AslGbl_LogicalLineNumber = 1;
AslGbl_CurrentLineOffset = 0;
AslGbl_InputFieldCount = 0;
AslGbl_InputByteCount = 0;
AslGbl_NsLookupCount = 0;
AslGbl_LineBufPtr = AslGbl_CurrentLineBuffer;
AslGbl_ErrorLog = NULL;
AslGbl_NextError = NULL;
AslGbl_Signature = NULL;
AslGbl_FileType = 0;
AslGbl_TotalExecutableOpcodes = 0;
AslGbl_TotalNamedObjects = 0;
AslGbl_TotalKeywords = 0;
AslGbl_TotalParseNodes = 0;
AslGbl_TotalMethods = 0;
AslGbl_TotalAllocations = 0;
AslGbl_TotalAllocated = 0;
AslGbl_TotalFolds = 0;
AslGbl_NextEvent = 0;
for (i = 0; i < ASL_NUM_REPORT_LEVELS; i++)
{
AslGbl_ExceptionCount[i] = 0;
}
if (AcpiGbl_CaptureComments)
{
AslGbl_CommentState.SpacesBefore = 0;
AslGbl_CommentState.CommentType = 1;
AslGbl_CommentState.LatestParseOp = NULL;
AslGbl_CommentState.ParsingParenBraceNode = NULL;
AslGbl_CommentState.CaptureComments = TRUE;
}
}
/*******************************************************************************
*
* FUNCTION: AslDetectSourceFileType
*
* PARAMETERS: Info - Name/Handle for the file (must be open)
*
* RETURN: File Type
*
* DESCRIPTION: Determine the type of the input file. Either binary (contains
* non-ASCII characters), ASL file, or an ACPI Data Table file.
*
******************************************************************************/
static UINT8
AslDetectSourceFileType (
ASL_FILE_INFO *Info)
{
char *FileChar;
UINT8 Type = ASL_INPUT_TYPE_ASCII_DATA; /* default */
ACPI_STATUS Status;
/* Check for 100% ASCII source file (comments are ignored) */
Status = FlIsFileAsciiSource (Info->Filename, FALSE);
if (ACPI_SUCCESS (Status))
{
/*
* File contains ASCII source code. Determine if this is an ASL
* file or an ACPI data table file.
*/
while (fgets (AslGbl_CurrentLineBuffer, AslGbl_LineBufferSize, Info->Handle))
{
/* Uppercase the buffer for caseless compare */
FileChar = AslGbl_CurrentLineBuffer;
while (*FileChar)
{
*FileChar = (char) toupper ((int) *FileChar);
FileChar++;
}
/* Presence of "DefinitionBlock" indicates actual ASL code */
if (strstr (AslGbl_CurrentLineBuffer, "DEFINITIONBLOCK"))
{
/* Appears to be an ASL file */
Type = ASL_INPUT_TYPE_ASCII_ASL;
goto Cleanup;
}
}
/* Appears to be an ASCII data table source file */
Type = ASL_INPUT_TYPE_ASCII_DATA;
goto Cleanup;
}
/*
* We have some sort of binary table; reopen in binary mode, then
* check for valid ACPI table
*/
fclose (Info->Handle);
Info->Handle = fopen (Info->Filename, "rb");
if (!Info->Handle)
{
fprintf (stderr, "Could not open input file %s\n",
Info->Filename);
}
Status = AcValidateTableHeader (Info->Handle, 0);
if (ACPI_SUCCESS (Status))
{
fprintf (stderr,
"Binary file appears to be a valid ACPI table, disassembling\n");
Type = ASL_INPUT_TYPE_BINARY_ACPI_TABLE;
goto Cleanup;
}
else
{
fprintf (stderr,
"Binary file does not contain a valid standard ACPI table\n");
}
Type = ASL_INPUT_TYPE_BINARY;
Cleanup:
/* Must seek back to the start of the file */
fseek (Info->Handle, 0, SEEK_SET);
return (Type);
}
/*******************************************************************************
*
* FUNCTION: AslDoDisassembly
*
* PARAMETERS: None
*
* RETURN: Status
*
* DESCRIPTION: Initiate AML file disassembly. Uses ACPICA subsystem to build
* namespace. This function assumes that the ACPI subsystem has
* been initialized. The caller of the initialization will also
* terminate the ACPI subsystem.
*
******************************************************************************/
ACPI_STATUS
AslDoDisassembly (
void)
{
ACPI_STATUS Status;
Status = AcpiAllocateRootTable (4);
if (ACPI_FAILURE (Status))
{
AcpiOsPrintf ("Could not initialize ACPI Table Manager, %s\n",
AcpiFormatException (Status));
return (Status);
}
/* This is where the disassembly happens */
AcpiGbl_DmOpt_Disasm = TRUE;
Status = AdAmlDisassemble (AslToFile,
AslGbl_Files[ASL_FILE_INPUT].Filename, AslGbl_OutputFilenamePrefix,
&AslGbl_Files[ASL_FILE_INPUT].Filename);
if (ACPI_FAILURE (Status))
{
return (Status);
}
/* Check if any control methods were unresolved */
AcpiDmUnresolvedWarning (0);
/* Clear Error log */
AeClearErrorLog ();
/*
* AslGbl_Files[ASL_FILE_INPUT].Filename was replaced with the
* .DSL disassembly file, which can now be compiled if requested
*/
if (AslGbl_DoCompile)
{
AcpiOsPrintf ("\nCompiling \"%s\"\n",
AslGbl_Files[ASL_FILE_INPUT].Filename);
return (AE_CTRL_CONTINUE);
}
return (AE_OK);
}
/*******************************************************************************
*
* FUNCTION: AslDoOneFile
*
* PARAMETERS: Filename - Name of the file
*
* RETURN: Status
*
* DESCRIPTION: Process a single file - either disassemble, compile, or both
*
******************************************************************************/
ACPI_STATUS
AslDoOneFile (
char *Filename)
{
ACPI_STATUS Status;
UINT8 Event;
ASL_GLOBAL_FILE_NODE *FileNode;
/* Re-initialize "some" compiler/preprocessor globals */
AslInitializeGlobals ();
PrInitializeGlobals ();
/*
* Extract the directory path. This path is used for possible include
* files and the optional AML filename embedded in the input file
* DefinitionBlock declaration.
*/
Status = FlSplitInputPathname (Filename, &AslGbl_DirectoryPath, NULL);
if (ACPI_FAILURE (Status))
{
return (Status);
}
/*
* There was an input file detected at this point. Each input ASL file is
* associated with one global file node consisting of the input file and
* all output files associated with it. This is useful when compiling
* multiple files in one command.
*/
Status = FlInitOneFile(Filename);
if (ACPI_FAILURE (Status))
{
return (AE_ERROR);
}
/* Take a copy of the input filename, convert any backslashes */
AslGbl_Files[ASL_FILE_INPUT].Filename =
UtLocalCacheCalloc (strlen (Filename) + 1);
strcpy (AslGbl_Files[ASL_FILE_INPUT].Filename, Filename);
UtConvertBackslashes (AslGbl_Files[ASL_FILE_INPUT].Filename);
/*
* Open the input file. Here, this could be an ASCII source file,
* either an ASL file or a Data Table file, or a binary AML file
* or binary data table file (For disassembly).
*/
Status = FlOpenInputFile (AslGbl_Files[ASL_FILE_INPUT].Filename);
if (ACPI_FAILURE (Status))
{
AePrintErrorLog (ASL_FILE_STDERR);
return (AE_ERROR);
}
FileNode = FlGetCurrentFileNode();
/* Determine input file type */
AslGbl_FileType = AslDetectSourceFileType (&AslGbl_Files[ASL_FILE_INPUT]);
FileNode->FileType = AslGbl_FileType;
if (AslGbl_FileType == ASL_INPUT_TYPE_BINARY)
{
return (AE_ERROR);
}
FileNode->OriginalInputFileSize = FlGetFileSize (ASL_FILE_INPUT);
/*
* If -p not specified, we will use the input filename as the
* output filename prefix
*/
if (AslGbl_UseDefaultAmlFilename)
{
AslGbl_OutputFilenamePrefix = AslGbl_Files[ASL_FILE_INPUT].Filename;
}
/*
* Open the output file. Note: by default, the name of this file comes from
* the table descriptor within the input file.
*/
if (AslGbl_FileType == ASL_INPUT_TYPE_ASCII_ASL)
{
Event = UtBeginEvent ("Open AML output file");
Status = FlOpenAmlOutputFile (AslGbl_OutputFilenamePrefix);
UtEndEvent (Event);
if (ACPI_FAILURE (Status))
{
AePrintErrorLog (ASL_FILE_STDERR);
return (AE_ERROR);
}
}
/* Open the optional output files (listings, etc.) */
Status = FlOpenMiscOutputFiles (AslGbl_OutputFilenamePrefix);
if (ACPI_FAILURE (Status))
{
AePrintErrorLog (ASL_FILE_STDERR);
return (AE_ERROR);
}
/*
* Compilation of ASL source versus DataTable source uses different
* compiler subsystems
*/
switch (AslGbl_FileType)
{
/*
* Data Table Compilation
*/
case ASL_INPUT_TYPE_ASCII_DATA:
Status = DtDoCompile ();
if (ACPI_FAILURE (Status))
{
return (Status);
}
if (AslGbl_Signature)
{
AslGbl_Signature = NULL;
}
/* Check if any errors occurred during compile */
Status = AslCheckForErrorExit ();
if (ACPI_FAILURE (Status))
{
return (Status);
}
/* Cleanup (for next source file) and exit */
AeClearErrorLog ();
PrTerminatePreprocessor ();
return (Status);
/*
* ASL Compilation
*/
case ASL_INPUT_TYPE_ASCII_ASL:
Status = CmDoCompile ();
if (ACPI_FAILURE (Status))
{
PrTerminatePreprocessor ();
return (Status);
}
/*
* At this point, we know how many lines are in the input file. Save it
* to display for post-compilation summary.
*/
FileNode->TotalLineCount = AslGbl_CurrentLineNumber;
return (AE_OK);
/*
* Binary ACPI table was auto-detected, disassemble it
*/
case ASL_INPUT_TYPE_BINARY_ACPI_TABLE:
/* We have what appears to be an ACPI table, disassemble it */
FlCloseFile (ASL_FILE_INPUT);
AslGbl_DoCompile = FALSE;
AcpiGbl_DisasmFlag = TRUE;
Status = AslDoDisassembly ();
return (Status);
/* Unknown binary table */
case ASL_INPUT_TYPE_BINARY:
AePrintErrorLog (ASL_FILE_STDERR);
return (AE_ERROR);
default:
printf ("Unknown file type %X\n", AslGbl_FileType);
return (AE_ERROR);
}
}
/*******************************************************************************
*
* FUNCTION: AslCheckForErrorExit
*
* PARAMETERS: None. Examines global exception count array
*
* RETURN: Status
*
* DESCRIPTION: Determine if compiler should abort with error status
*
******************************************************************************/
ACPI_STATUS
AslCheckForErrorExit (
void)
{
/*
* Return non-zero exit code if there have been errors, unless the
* global ignore error flag has been set
*/
if (!AslGbl_IgnoreErrors)
{
if (AslGbl_ExceptionCount[ASL_ERROR] > 0)
{
return (AE_ERROR);
}
/* Optionally treat warnings as errors */
if (AslGbl_WarningsAsErrors)
{
if ((AslGbl_ExceptionCount[ASL_WARNING] > 0) ||
(AslGbl_ExceptionCount[ASL_WARNING2] > 0) ||
(AslGbl_ExceptionCount[ASL_WARNING3] > 0))
{
AslError (ASL_ERROR, ASL_MSG_WARNING_AS_ERROR, NULL,
"(reporting warnings as errors)");
return (AE_ERROR);
}
}
}
return (AE_OK);
}

View File

@@ -0,0 +1,444 @@
/******************************************************************************
*
* Module Name: aslstubs - Stubs used to link to Aml interpreter
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
#include "aslcompiler.h"
#include "acdispat.h"
#include "actables.h"
#include "acevents.h"
#include "acinterp.h"
#include "acnamesp.h"
#include "acparser.h"
#define _COMPONENT ACPI_COMPILER
ACPI_MODULE_NAME ("aslstubs")
/*
* Stubs to simplify linkage to the ACPICA core subsystem.
* Things like Events, Global Lock, etc. are not used
* by the compiler, so they are stubbed out here.
*/
ACPI_STATUS
AcpiNsInitializeObjects (
void)
{
return (AE_OK);
}
ACPI_STATUS
AcpiPsExecuteTable (
ACPI_EVALUATE_INFO *Info)
{
return (AE_OK);
}
ACPI_STATUS
AcpiHwReadPort (
ACPI_IO_ADDRESS Address,
UINT32 *Value,
UINT32 Width)
{
return (AE_OK);
}
ACPI_STATUS
AcpiHwWritePort (
ACPI_IO_ADDRESS Address,
UINT32 Value,
UINT32 Width)
{
return (AE_OK);
}
ACPI_STATUS
AcpiDsMethodError (
ACPI_STATUS Status,
ACPI_WALK_STATE *WalkState)
{
return (Status);
}
ACPI_STATUS
AcpiDsMethodDataGetValue (
UINT8 Type,
UINT32 Index,
ACPI_WALK_STATE *WalkState,
ACPI_OPERAND_OBJECT **DestDesc)
{
return (AE_OK);
}
ACPI_STATUS
AcpiDsMethodDataGetNode (
UINT8 Type,
UINT32 Index,
ACPI_WALK_STATE *WalkState,
ACPI_NAMESPACE_NODE **Node)
{
return (AE_OK);
}
ACPI_STATUS
AcpiDsStoreObjectToLocal (
UINT8 Type,
UINT32 Index,
ACPI_OPERAND_OBJECT *SrcDesc,
ACPI_WALK_STATE *WalkState)
{
return (AE_OK);
}
ACPI_STATUS
AcpiEvInstallRegionHandlers (
void)
{
return (AE_OK);
}
ACPI_STATUS
AcpiEvQueueNotifyRequest (
ACPI_NAMESPACE_NODE *Node,
UINT32 NotifyValue)
{
return (AE_OK);
}
BOOLEAN
AcpiEvIsNotifyObject (
ACPI_NAMESPACE_NODE *Node)
{
return (FALSE);
}
#if (!ACPI_REDUCED_HARDWARE)
ACPI_STATUS
AcpiEvDeleteGpeBlock (
ACPI_GPE_BLOCK_INFO *GpeBlock)
{
return (AE_OK);
}
void
AcpiEvUpdateGpes (
ACPI_OWNER_ID TableOwnerId)
{
return;
}
ACPI_STATUS
AcpiEvAcquireGlobalLock (
UINT16 Timeout)
{
return (AE_OK);
}
ACPI_STATUS
AcpiEvReleaseGlobalLock (
void)
{
return (AE_OK);
}
#endif /* !ACPI_REDUCED_HARDWARE */
ACPI_STATUS
AcpiEvInitializeRegion (
ACPI_OPERAND_OBJECT *RegionObj)
{
return (AE_OK);
}
ACPI_STATUS
AcpiExReadDataFromField (
ACPI_WALK_STATE *WalkState,
ACPI_OPERAND_OBJECT *ObjDesc,
ACPI_OPERAND_OBJECT **RetBufferDesc)
{
return (AE_SUPPORT);
}
ACPI_STATUS
AcpiExWriteDataToField (
ACPI_OPERAND_OBJECT *SourceDesc,
ACPI_OPERAND_OBJECT *ObjDesc,
ACPI_OPERAND_OBJECT **ResultDesc)
{
return (AE_SUPPORT);
}
ACPI_STATUS
AcpiExLoadTableOp (
ACPI_WALK_STATE *WalkState,
ACPI_OPERAND_OBJECT **ReturnDesc)
{
return (AE_SUPPORT);
}
ACPI_STATUS
AcpiExUnloadTable (
ACPI_OPERAND_OBJECT *DdbHandle)
{
return (AE_SUPPORT);
}
ACPI_STATUS
AcpiExLoadOp (
ACPI_OPERAND_OBJECT *ObjDesc,
ACPI_OPERAND_OBJECT *Target,
ACPI_WALK_STATE *WalkState)
{
return (AE_SUPPORT);
}
void
AcpiExDoDebugObject (
ACPI_OPERAND_OBJECT *SourceDesc,
UINT32 Level,
UINT32 Index)
{
return;
}
void
AcpiExStartTraceMethod (
ACPI_NAMESPACE_NODE *MethodNode,
ACPI_OPERAND_OBJECT *ObjDesc,
ACPI_WALK_STATE *WalkState)
{
return;
}
void
AcpiExStopTraceMethod (
ACPI_NAMESPACE_NODE *MethodNode,
ACPI_OPERAND_OBJECT *ObjDesc,
ACPI_WALK_STATE *WalkState)
{
return;
}
void
AcpiExStartTraceOpcode (
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState)
{
return;
}
void
AcpiExStopTraceOpcode (
ACPI_PARSE_OBJECT *Op,
ACPI_WALK_STATE *WalkState)
{
return;
}
void
AcpiExTracePoint (
ACPI_TRACE_EVENT_TYPE Type,
BOOLEAN Begin,
UINT8 *Aml,
char *Pathname)
{
return;
}
ACPI_STATUS
AcpiTbFindTable (
char *Signature,
char *OemId,
char *OemTableId,
UINT32 *TableIndex)
{
return (AE_SUPPORT);
}
ACPI_STATUS
AcpiNsLoadTable (
UINT32 TableIndex,
ACPI_NAMESPACE_NODE *Node)
{
return (AE_NOT_IMPLEMENTED);
}
ACPI_STATUS
AcpiDsRestartControlMethod (
ACPI_WALK_STATE *WalkState,
ACPI_OPERAND_OBJECT *ReturnDesc)
{
return (AE_OK);
}
void
AcpiDsTerminateControlMethod (
ACPI_OPERAND_OBJECT *MethodDesc,
ACPI_WALK_STATE *WalkState)
{
return;
}
ACPI_STATUS
AcpiDsCallControlMethod (
ACPI_THREAD_STATE *Thread,
ACPI_WALK_STATE *WalkState,
ACPI_PARSE_OBJECT *Op)
{
return (AE_OK);
}
ACPI_STATUS
AcpiDsMethodDataInitArgs (
ACPI_OPERAND_OBJECT **Params,
UINT32 MaxParamCount,
ACPI_WALK_STATE *WalkState)
{
return (AE_OK);
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,228 @@
NoEcho('
/******************************************************************************
*
* Module Name: aslsupport.y - Bison/Yacc C support functions
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
')
/******************************************************************************
*
* Local support functions
*
*****************************************************************************/
/*! [Begin] no source code translation */
int
AslCompilerwrap(void)
{
return (1);
}
/*! [End] no source code translation !*/
void *
AslLocalAllocate (
unsigned int Size)
{
void *Mem;
DbgPrint (ASL_PARSE_OUTPUT,
"\nAslLocalAllocate: Expanding Stack to %u\n\n", Size);
Mem = ACPI_ALLOCATE_ZEROED (Size);
if (!Mem)
{
AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION,
AslGbl_CurrentLineNumber, AslGbl_LogicalLineNumber,
AslGbl_InputByteCount, AslGbl_CurrentColumn,
AslGbl_Files[ASL_FILE_INPUT].Filename, NULL);
exit (1);
}
return (Mem);
}
ACPI_PARSE_OBJECT *
AslDoError (
void)
{
return (TrCreateLeafOp (PARSEOP_ERRORNODE));
}
/*******************************************************************************
*
* FUNCTION: UtGetOpName
*
* PARAMETERS: ParseOpcode - Parser keyword ID
*
* RETURN: Pointer to the opcode name
*
* DESCRIPTION: Get the ascii name of the parse opcode
*
******************************************************************************/
char *
UtGetOpName (
UINT32 ParseOpcode)
{
#ifdef ASL_YYTNAME_START
/*
* First entries (ASL_YYTNAME_START) in yytname are special reserved names.
* Ignore first 8 characters of the name
*/
return ((char *) yytname
[(ParseOpcode - ASL_FIRST_PARSE_OPCODE) + ASL_YYTNAME_START] + 8);
#else
return ("[Unknown parser generator]");
#endif
}

View File

@@ -0,0 +1,651 @@
NoEcho('
/******************************************************************************
*
* Module Name: asltokens.y - Bison/Yacc token types
*
*****************************************************************************/
/******************************************************************************
*
* 1. Copyright Notice
*
* Some or all of this work - Copyright (c) 1999 - 2025, Intel Corp.
* All rights reserved.
*
* 2. License
*
* 2.1. This is your license from Intel Corp. under its intellectual property
* rights. You may have additional license terms from the party that provided
* you this software, covering your right to use that party's intellectual
* property rights.
*
* 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a
* copy of the source code appearing in this file ("Covered Code") an
* irrevocable, perpetual, worldwide license under Intel's copyrights in the
* base code distributed originally by Intel ("Original Intel Code") to copy,
* make derivatives, distribute, use and display any portion of the Covered
* 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 (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
* license, and in no event shall the patent license extend to any additions
* to or modifications of the Original Intel Code. No other license or right
* is granted directly or by implication, estoppel or otherwise;
*
* The above copyright and patent license is granted only if the following
* conditions are met:
*
* 3. Conditions
*
* 3.1. Redistribution of Source with Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification with rights to further distribute source must include
* the above Copyright Notice, the above License, this list of Conditions,
* and the following Disclaimer and Export Compliance provision. In addition,
* Licensee must cause all Covered Code to which Licensee contributes to
* contain a file documenting the changes Licensee made to create that Covered
* Code and the date of any change. Licensee must include in that file the
* documentation of any changes made by any predecessor Licensee. Licensee
* must include a prominent statement that the modification is derived,
* directly or indirectly, from Original Intel Code.
*
* 3.2. Redistribution of Source with no Rights to Further Distribute Source.
* Redistribution of source code of any substantial portion of the Covered
* Code or modification without rights to further distribute source must
* include the following Disclaimer and Export Compliance provision in the
* documentation and/or other materials provided with distribution. In
* addition, Licensee may not authorize further sublicense of source of any
* portion of the Covered Code, and must include terms to the effect that the
* license from Licensee to its licensee is limited to the intellectual
* property embodied in the software Licensee provides to its licensee, and
* not to intellectual property embodied in modifications its licensee may
* make.
*
* 3.3. Redistribution of Executable. Redistribution in executable form of any
* substantial portion of the Covered Code or modification must reproduce the
* above Copyright Notice, and the following Disclaimer and Export Compliance
* provision in the documentation and/or other materials provided with the
* distribution.
*
* 3.4. Intel retains all right, title, and interest in and to the Original
* Intel Code.
*
* 3.5. Neither the name Intel nor any other trademark owned or controlled by
* Intel shall be used in advertising or otherwise to promote the sale, use or
* other dealings in products derived from or relating to the Covered Code
* without prior written authorization from Intel.
*
* 4. Disclaimer and Export Compliance
*
* 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED
* HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE
* IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE,
* INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY
* UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY
* IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A
* PARTICULAR PURPOSE.
*
* 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES
* OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR
* COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT,
* SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY
* CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL
* HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS
* SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY
* LIMITED REMEDY.
*
* 4.3. Licensee shall not export, either directly or indirectly, any of this
* software or system incorporating such software without first obtaining any
* required license or other approval from the U. S. Department of Commerce or
* any other agency or department of the United States Government. In the
* event Licensee exports any such software from the United States or
* re-exports any such software from a foreign destination, Licensee shall
* ensure that the distribution and export/re-export of the software is in
* compliance with all laws, regulations, orders, or other restrictions of the
* U.S. Export Administration Regulations. Licensee agrees that neither it nor
* any of its subsidiaries will export/re-export any technical data, process,
* software, or service, directly or indirectly, to any country for which the
* United States government or any agency thereof requires an export license,
* other governmental approval, or letter of assurance, without first obtaining
* such license, approval or letter.
*
*****************************************************************************
*
* Alternatively, you may choose to be licensed under the terms of the
* following license:
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions, and the following disclaimer,
* without modification.
* 2. Redistributions in binary form must reproduce at minimum a disclaimer
* substantially similar to the "NO WARRANTY" disclaimer below
* ("Disclaimer") and any redistribution must be conditioned upon
* including a substantially similar Disclaimer requirement for further
* binary redistribution.
* 3. Neither the names of the above-listed copyright holders nor the names
* of any contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* Alternatively, you may choose to be licensed under the terms of the
* GNU General Public License ("GPL") version 2 as published by the Free
* Software Foundation.
*
*****************************************************************************/
')
/******************************************************************************
*
* Token types: These are returned by the lexer
*
* NOTE: This list MUST match the AslKeywordMapping table found
* in aslmap.c EXACTLY! Double check any changes!
*
*****************************************************************************/
/*
* Most tokens are defined to return <i>, which is a UINT64.
*
* These tokens return <s>, a pointer to the associated lexed string:
*
* PARSEOP_NAMESEG
* PARSEOP_NAMESTRING
* PARSEOP_STRING_LITERAL
* PARSEOP_STRUCTURE_NAMESTRING
*/
%token <i> PARSEOP_ACCESSAS
%token <i> PARSEOP_ACCESSATTRIB_BLOCK
%token <i> PARSEOP_ACCESSATTRIB_BLOCK_CALL
%token <i> PARSEOP_ACCESSATTRIB_BYTE
%token <i> PARSEOP_ACCESSATTRIB_BYTES
%token <i> PARSEOP_ACCESSATTRIB_QUICK
%token <i> PARSEOP_ACCESSATTRIB_RAW_BYTES
%token <i> PARSEOP_ACCESSATTRIB_RAW_PROCESS
%token <i> PARSEOP_ACCESSATTRIB_SND_RCV
%token <i> PARSEOP_ACCESSATTRIB_WORD
%token <i> PARSEOP_ACCESSATTRIB_WORD_CALL
%token <i> PARSEOP_ACCESSTYPE_ANY
%token <i> PARSEOP_ACCESSTYPE_BUF
%token <i> PARSEOP_ACCESSTYPE_BYTE
%token <i> PARSEOP_ACCESSTYPE_DWORD
%token <i> PARSEOP_ACCESSTYPE_QWORD
%token <i> PARSEOP_ACCESSTYPE_WORD
%token <i> PARSEOP_ACQUIRE
%token <i> PARSEOP_ADD
%token <i> PARSEOP_ADDRESSINGMODE_7BIT
%token <i> PARSEOP_ADDRESSINGMODE_10BIT
%token <i> PARSEOP_ADDRESSTYPE_ACPI
%token <i> PARSEOP_ADDRESSTYPE_MEMORY
%token <i> PARSEOP_ADDRESSTYPE_NVS
%token <i> PARSEOP_ADDRESSTYPE_RESERVED
%token <i> PARSEOP_ALIAS
%token <i> PARSEOP_AND
%token <i> PARSEOP_ARG0
%token <i> PARSEOP_ARG1
%token <i> PARSEOP_ARG2
%token <i> PARSEOP_ARG3
%token <i> PARSEOP_ARG4
%token <i> PARSEOP_ARG5
%token <i> PARSEOP_ARG6
%token <i> PARSEOP_BANKFIELD
%token <i> PARSEOP_BITSPERBYTE_EIGHT
%token <i> PARSEOP_BITSPERBYTE_FIVE
%token <i> PARSEOP_BITSPERBYTE_NINE
%token <i> PARSEOP_BITSPERBYTE_SEVEN
%token <i> PARSEOP_BITSPERBYTE_SIX
%token <i> PARSEOP_BREAK
%token <i> PARSEOP_BREAKPOINT
%token <i> PARSEOP_BUFFER
%token <i> PARSEOP_BUSMASTERTYPE_MASTER
%token <i> PARSEOP_BUSMASTERTYPE_NOTMASTER
%token <i> PARSEOP_BYTECONST
%token <i> PARSEOP_CASE
%token <i> PARSEOP_CLOCKPHASE_FIRST
%token <i> PARSEOP_CLOCKPHASE_SECOND
%token <i> PARSEOP_CLOCKPOLARITY_HIGH
%token <i> PARSEOP_CLOCKPOLARITY_LOW
%token <i> PARSEOP_CONCATENATE
%token <i> PARSEOP_CONCATENATERESTEMPLATE
%token <i> PARSEOP_CONDREFOF
%token <i> PARSEOP_CONNECTION
%token <i> PARSEOP_CONTINUE
%token <i> PARSEOP_COPYOBJECT
%token <i> PARSEOP_CREATEBITFIELD
%token <i> PARSEOP_CREATEBYTEFIELD
%token <i> PARSEOP_CREATEDWORDFIELD
%token <i> PARSEOP_CREATEFIELD
%token <i> PARSEOP_CREATEQWORDFIELD
%token <i> PARSEOP_CREATEWORDFIELD
%token <i> PARSEOP_DATABUFFER
%token <i> PARSEOP_DATATABLEREGION
%token <i> PARSEOP_DEBUG
%token <i> PARSEOP_DECODETYPE_POS
%token <i> PARSEOP_DECODETYPE_SUB
%token <i> PARSEOP_DECREMENT
%token <i> PARSEOP_DEFAULT
%token <i> PARSEOP_DEFAULT_ARG
%token <i> PARSEOP_DEFINITION_BLOCK
%token <i> PARSEOP_DEREFOF
%token <i> PARSEOP_DEVICE
%token <i> PARSEOP_DEVICEPOLARITY_HIGH
%token <i> PARSEOP_DEVICEPOLARITY_LOW
%token <i> PARSEOP_DIVIDE
%token <i> PARSEOP_DMA
%token <i> PARSEOP_DMATYPE_A
%token <i> PARSEOP_DMATYPE_COMPATIBILITY
%token <i> PARSEOP_DMATYPE_B
%token <i> PARSEOP_DMATYPE_F
%token <i> PARSEOP_DWORDCONST
%token <i> PARSEOP_DWORDIO
%token <i> PARSEOP_DWORDMEMORY
%token <i> PARSEOP_DWORDPCC
%token <i> PARSEOP_DWORDSPACE
%token <i> PARSEOP_EISAID
%token <i> PARSEOP_ELSE
%token <i> PARSEOP_ELSEIF
%token <i> PARSEOP_ENDDEPENDENTFN
%token <i> PARSEOP_ENDIAN_BIG
%token <i> PARSEOP_ENDIAN_LITTLE
%token <i> PARSEOP_ENDTAG
%token <i> PARSEOP_ERRORNODE
%token <i> PARSEOP_EVENT
%token <i> PARSEOP_EXTENDEDIO
%token <i> PARSEOP_EXTENDEDMEMORY
%token <i> PARSEOP_EXTENDEDSPACE
%token <i> PARSEOP_EXTERNAL
%token <i> PARSEOP_FATAL
%token <i> PARSEOP_FIELD
%token <i> PARSEOP_FINDSETLEFTBIT
%token <i> PARSEOP_FINDSETRIGHTBIT
%token <i> PARSEOP_FIXEDDMA
%token <i> PARSEOP_FIXEDIO
%token <i> PARSEOP_FLOWCONTROL_HW
%token <i> PARSEOP_FLOWCONTROL_NONE
%token <i> PARSEOP_FLOWCONTROL_SW
%token <i> PARSEOP_FROMBCD
%token <i> PARSEOP_FUNCTION
%token <i> PARSEOP_GPIO_INT
%token <i> PARSEOP_GPIO_IO
%token <i> PARSEOP_CSI2_SERIALBUS
%token <i> PARSEOP_I2C_SERIALBUS
%token <i> PARSEOP_I2C_SERIALBUS_V2
%token <i> PARSEOP_IF
%token <i> PARSEOP_INCLUDE
%token <i> PARSEOP_INCLUDE_END
%token <i> PARSEOP_INCREMENT
%token <i> PARSEOP_INDEX
%token <i> PARSEOP_INDEXFIELD
%token <i> PARSEOP_INTEGER
%token <i> PARSEOP_INTERRUPT
%token <i> PARSEOP_INTLEVEL_ACTIVEBOTH
%token <i> PARSEOP_INTLEVEL_ACTIVEHIGH
%token <i> PARSEOP_INTLEVEL_ACTIVELOW
%token <i> PARSEOP_INTTYPE_EDGE
%token <i> PARSEOP_INTTYPE_LEVEL
%token <i> PARSEOP_IO
%token <i> PARSEOP_IODECODETYPE_10
%token <i> PARSEOP_IODECODETYPE_16
%token <i> PARSEOP_IORESTRICT_IN
%token <i> PARSEOP_IORESTRICT_NONE
%token <i> PARSEOP_IORESTRICT_OUT
%token <i> PARSEOP_IORESTRICT_PRESERVE
%token <i> PARSEOP_IRQ
%token <i> PARSEOP_IRQNOFLAGS
%token <i> PARSEOP_LAND
%token <i> PARSEOP_LEQUAL
%token <i> PARSEOP_LGREATER
%token <i> PARSEOP_LGREATEREQUAL
%token <i> PARSEOP_LLESS
%token <i> PARSEOP_LLESSEQUAL
%token <i> PARSEOP_LNOT
%token <i> PARSEOP_LNOTEQUAL
%token <i> PARSEOP_LOAD
%token <i> PARSEOP_LOADTABLE
%token <i> PARSEOP_LOCAL0
%token <i> PARSEOP_LOCAL1
%token <i> PARSEOP_LOCAL2
%token <i> PARSEOP_LOCAL3
%token <i> PARSEOP_LOCAL4
%token <i> PARSEOP_LOCAL5
%token <i> PARSEOP_LOCAL6
%token <i> PARSEOP_LOCAL7
%token <i> PARSEOP_LOCKRULE_LOCK
%token <i> PARSEOP_LOCKRULE_NOLOCK
%token <i> PARSEOP_LOR
%token <i> PARSEOP_MATCH
%token <i> PARSEOP_MATCHTYPE_MEQ
%token <i> PARSEOP_MATCHTYPE_MGE
%token <i> PARSEOP_MATCHTYPE_MGT
%token <i> PARSEOP_MATCHTYPE_MLE
%token <i> PARSEOP_MATCHTYPE_MLT
%token <i> PARSEOP_MATCHTYPE_MTR
%token <i> PARSEOP_MAXTYPE_FIXED
%token <i> PARSEOP_MAXTYPE_NOTFIXED
%token <i> PARSEOP_MEMORY24
%token <i> PARSEOP_MEMORY32
%token <i> PARSEOP_MEMORY32FIXED
%token <i> PARSEOP_MEMTYPE_CACHEABLE
%token <i> PARSEOP_MEMTYPE_NONCACHEABLE
%token <i> PARSEOP_MEMTYPE_PREFETCHABLE
%token <i> PARSEOP_MEMTYPE_WRITECOMBINING
%token <i> PARSEOP_METHOD
%token <i> PARSEOP_METHODCALL
%token <i> PARSEOP_MID
%token <i> PARSEOP_MINTYPE_FIXED
%token <i> PARSEOP_MINTYPE_NOTFIXED
%token <i> PARSEOP_MOD
%token <i> PARSEOP_MULTIPLY
%token <i> PARSEOP_MUTEX
%token <i> PARSEOP_NAME
%token <s> PARSEOP_NAMESEG
%token <s> PARSEOP_NAMESTRING
%token <i> PARSEOP_NAND
%token <i> PARSEOP_NOOP
%token <i> PARSEOP_NOR
%token <i> PARSEOP_NOT
%token <i> PARSEOP_NOTIFY
%token <i> PARSEOP_OBJECTTYPE
%token <i> PARSEOP_OBJECTTYPE_BFF
%token <i> PARSEOP_OBJECTTYPE_BUF
%token <i> PARSEOP_OBJECTTYPE_DDB
%token <i> PARSEOP_OBJECTTYPE_DEV
%token <i> PARSEOP_OBJECTTYPE_EVT
%token <i> PARSEOP_OBJECTTYPE_FLD
%token <i> PARSEOP_OBJECTTYPE_INT
%token <i> PARSEOP_OBJECTTYPE_MTH
%token <i> PARSEOP_OBJECTTYPE_MTX
%token <i> PARSEOP_OBJECTTYPE_OPR
%token <i> PARSEOP_OBJECTTYPE_PKG
%token <i> PARSEOP_OBJECTTYPE_POW
%token <i> PARSEOP_OBJECTTYPE_PRO
%token <i> PARSEOP_OBJECTTYPE_STR
%token <i> PARSEOP_OBJECTTYPE_THZ
%token <i> PARSEOP_OBJECTTYPE_UNK
%token <i> PARSEOP_OFFSET
%token <i> PARSEOP_ONE
%token <i> PARSEOP_ONES
%token <i> PARSEOP_OPERATIONREGION
%token <i> PARSEOP_OR
%token <i> PARSEOP_PACKAGE
%token <i> PARSEOP_PACKAGE_LENGTH
%token <i> PARSEOP_PARITYTYPE_EVEN
%token <i> PARSEOP_PARITYTYPE_MARK
%token <i> PARSEOP_PARITYTYPE_NONE
%token <i> PARSEOP_PARITYTYPE_ODD
%token <i> PARSEOP_PARITYTYPE_SPACE
%token <i> PARSEOP_PINCONFIG
%token <i> PARSEOP_PINFUNCTION
%token <i> PARSEOP_PINGROUP
%token <i> PARSEOP_PINGROUPCONFIG
%token <i> PARSEOP_PINGROUPFUNCTION
%token <i> PARSEOP_PIN_NOPULL
%token <i> PARSEOP_PIN_PULLDEFAULT
%token <i> PARSEOP_PIN_PULLDOWN
%token <i> PARSEOP_PIN_PULLUP
%token <i> PARSEOP_CLOCKINPUT
%token <i> PARSEOP_CLOCK_HZ
%token <i> PARSEOP_CLOCK_KHZ
%token <i> PARSEOP_CLOCK_MHZ
%token <i> PARSEOP_CLOCK_FIXED
%token <i> PARSEOP_CLOCK_VARIABLE
%token <i> PARSEOP_POWERRESOURCE
%token <i> PARSEOP_PROCESSOR
%token <i> PARSEOP_QWORDCONST
%token <i> PARSEOP_QWORDIO
%token <i> PARSEOP_QWORDMEMORY
%token <i> PARSEOP_QWORDPCC
%token <i> PARSEOP_QWORDSPACE
%token <i> PARSEOP_RANGETYPE_ENTIRE
%token <i> PARSEOP_RANGETYPE_ISAONLY
%token <i> PARSEOP_RANGETYPE_NONISAONLY
%token <i> PARSEOP_RAW_DATA
%token <i> PARSEOP_READWRITETYPE_BOTH
%token <i> PARSEOP_READWRITETYPE_READONLY
%token <i> PARSEOP_REFOF
%token <i> PARSEOP_REGIONSPACE_CMOS
%token <i> PARSEOP_REGIONSPACE_EC
%token <i> PARSEOP_REGIONSPACE_FFIXEDHW
%token <i> PARSEOP_REGIONSPACE_GPIO
%token <i> PARSEOP_REGIONSPACE_GSBUS
%token <i> PARSEOP_REGIONSPACE_IO
%token <i> PARSEOP_REGIONSPACE_IPMI
%token <i> PARSEOP_REGIONSPACE_MEM
%token <i> PARSEOP_REGIONSPACE_PCC
%token <i> PARSEOP_REGIONSPACE_PCI
%token <i> PARSEOP_REGIONSPACE_PCIBAR
%token <i> PARSEOP_REGIONSPACE_PRM
%token <i> PARSEOP_REGIONSPACE_SMBUS
%token <i> PARSEOP_REGISTER
%token <i> PARSEOP_RELEASE
%token <i> PARSEOP_RESERVED_BYTES
%token <i> PARSEOP_RESET
%token <i> PARSEOP_RESOURCETEMPLATE
%token <i> PARSEOP_RESOURCETYPE_CONSUMER
%token <i> PARSEOP_RESOURCETYPE_PRODUCER
%token <i> PARSEOP_RETURN
%token <i> PARSEOP_REVISION
%token <i> PARSEOP_SCOPE
%token <i> PARSEOP_SERIALIZERULE_NOTSERIAL
%token <i> PARSEOP_SERIALIZERULE_SERIAL
%token <i> PARSEOP_SHARETYPE_EXCLUSIVE
%token <i> PARSEOP_SHARETYPE_EXCLUSIVEWAKE
%token <i> PARSEOP_SHARETYPE_SHARED
%token <i> PARSEOP_SHARETYPE_SHAREDWAKE
%token <i> PARSEOP_SHIFTLEFT
%token <i> PARSEOP_SHIFTRIGHT
%token <i> PARSEOP_SIGNAL
%token <i> PARSEOP_SIZEOF
%token <i> PARSEOP_SLAVEMODE_CONTROLLERINIT
%token <i> PARSEOP_SLAVEMODE_DEVICEINIT
%token <i> PARSEOP_SLEEP
%token <i> PARSEOP_SPI_SERIALBUS
%token <i> PARSEOP_SPI_SERIALBUS_V2
%token <i> PARSEOP_STALL
%token <i> PARSEOP_STARTDEPENDENTFN
%token <i> PARSEOP_STARTDEPENDENTFN_NOPRI
%token <i> PARSEOP_STOPBITS_ONE
%token <i> PARSEOP_STOPBITS_ONEPLUSHALF
%token <i> PARSEOP_STOPBITS_TWO
%token <i> PARSEOP_STOPBITS_ZERO
%token <i> PARSEOP_STORE
%token <s> PARSEOP_STRING_LITERAL
%token <i> PARSEOP_SUBTRACT
%token <i> PARSEOP_SWITCH
%token <i> PARSEOP_THERMALZONE
%token <i> PARSEOP_TIMER
%token <i> PARSEOP_TOBCD
%token <i> PARSEOP_TOBUFFER
%token <i> PARSEOP_TODECIMALSTRING
%token <i> PARSEOP_TOHEXSTRING
%token <i> PARSEOP_TOINTEGER
%token <i> PARSEOP_TOSTRING
%token <i> PARSEOP_TOUUID
%token <i> PARSEOP_TRANSLATIONTYPE_DENSE
%token <i> PARSEOP_TRANSLATIONTYPE_SPARSE
%token <i> PARSEOP_TYPE_STATIC
%token <i> PARSEOP_TYPE_TRANSLATION
%token <i> PARSEOP_UART_SERIALBUS
%token <i> PARSEOP_UART_SERIALBUS_V2
%token <i> PARSEOP_UNICODE
%token <i> PARSEOP_UNLOAD
%token <i> PARSEOP_UPDATERULE_ONES
%token <i> PARSEOP_UPDATERULE_PRESERVE
%token <i> PARSEOP_UPDATERULE_ZEROS
%token <i> PARSEOP_VAR_PACKAGE
%token <i> PARSEOP_VENDORLONG
%token <i> PARSEOP_VENDORSHORT
%token <i> PARSEOP_WAIT
%token <i> PARSEOP_WHILE
%token <i> PARSEOP_WIREMODE_FOUR
%token <i> PARSEOP_WIREMODE_THREE
%token <i> PARSEOP_WORDBUSNUMBER
%token <i> PARSEOP_WORDCONST
%token <i> PARSEOP_WORDIO
%token <i> PARSEOP_WORDPCC
%token <i> PARSEOP_WORDSPACE
%token <i> PARSEOP_XFERSIZE_8
%token <i> PARSEOP_XFERSIZE_16
%token <i> PARSEOP_XFERSIZE_32
%token <i> PARSEOP_XFERSIZE_64
%token <i> PARSEOP_XFERSIZE_128
%token <i> PARSEOP_XFERSIZE_256
%token <i> PARSEOP_XFERTYPE_8
%token <i> PARSEOP_XFERTYPE_8_16
%token <i> PARSEOP_XFERTYPE_16
%token <i> PARSEOP_XOR
%token <i> PARSEOP_ZERO
/* ToPld macro */
%token <i> PARSEOP_TOPLD
%token <i> PARSEOP_PLD_REVISION
%token <i> PARSEOP_PLD_IGNORECOLOR
%token <i> PARSEOP_PLD_RED
%token <i> PARSEOP_PLD_GREEN
%token <i> PARSEOP_PLD_BLUE
%token <i> PARSEOP_PLD_WIDTH
%token <i> PARSEOP_PLD_HEIGHT
%token <i> PARSEOP_PLD_USERVISIBLE
%token <i> PARSEOP_PLD_DOCK
%token <i> PARSEOP_PLD_LID
%token <i> PARSEOP_PLD_PANEL
%token <i> PARSEOP_PLD_VERTICALPOSITION
%token <i> PARSEOP_PLD_HORIZONTALPOSITION
%token <i> PARSEOP_PLD_SHAPE
%token <i> PARSEOP_PLD_GROUPORIENTATION
%token <i> PARSEOP_PLD_GROUPTOKEN
%token <i> PARSEOP_PLD_GROUPPOSITION
%token <i> PARSEOP_PLD_BAY
%token <i> PARSEOP_PLD_EJECTABLE
%token <i> PARSEOP_PLD_EJECTREQUIRED
%token <i> PARSEOP_PLD_CABINETNUMBER
%token <i> PARSEOP_PLD_CARDCAGENUMBER
%token <i> PARSEOP_PLD_REFERENCE
%token <i> PARSEOP_PLD_ROTATION
%token <i> PARSEOP_PLD_ORDER
%token <i> PARSEOP_PLD_RESERVED
%token <i> PARSEOP_PLD_VERTICALOFFSET
%token <i> PARSEOP_PLD_HORIZONTALOFFSET
/*
* C-style expression parser. These must appear after all of the
* standard ASL operators and keywords.
*
* Note: The order of these tokens implements the precedence rules
* (low precedence to high). See aslrules.y for an exhaustive list.
*/
%right <i> PARSEOP_EXP_EQUALS
PARSEOP_EXP_ADD_EQ
PARSEOP_EXP_SUB_EQ
PARSEOP_EXP_MUL_EQ
PARSEOP_EXP_DIV_EQ
PARSEOP_EXP_MOD_EQ
PARSEOP_EXP_SHL_EQ
PARSEOP_EXP_SHR_EQ
PARSEOP_EXP_AND_EQ
PARSEOP_EXP_XOR_EQ
PARSEOP_EXP_OR_EQ
%left <i> PARSEOP_EXP_LOGICAL_OR
%left <i> PARSEOP_EXP_LOGICAL_AND
%left <i> PARSEOP_EXP_OR
%left <i> PARSEOP_EXP_XOR
%left <i> PARSEOP_EXP_AND
%left <i> PARSEOP_EXP_EQUAL
PARSEOP_EXP_NOT_EQUAL
%left <i> PARSEOP_EXP_GREATER
PARSEOP_EXP_LESS
PARSEOP_EXP_GREATER_EQUAL
PARSEOP_EXP_LESS_EQUAL
%left <i> PARSEOP_EXP_SHIFT_RIGHT
PARSEOP_EXP_SHIFT_LEFT
%left <i> PARSEOP_EXP_ADD
PARSEOP_EXP_SUBTRACT
%left <i> PARSEOP_EXP_MULTIPLY
PARSEOP_EXP_DIVIDE
PARSEOP_EXP_MODULO
%right <i> PARSEOP_EXP_NOT
PARSEOP_EXP_LOGICAL_NOT
%left <i> PARSEOP_EXP_INCREMENT
PARSEOP_EXP_DECREMENT
%left <i> PARSEOP_OPEN_PAREN
PARSEOP_CLOSE_PAREN
/* Brackets for Index() support */
%left <i> PARSEOP_EXP_INDEX_LEFT
%right <i> PARSEOP_EXP_INDEX_RIGHT
/* Macros */
%token <i> PARSEOP_PRINTF
%token <i> PARSEOP_FPRINTF
%token <i> PARSEOP_FOR
/* Structures */
%token <i> PARSEOP_STRUCTURE
%token <s> PARSEOP_STRUCTURE_NAMESTRING
%token <i> PARSEOP_STRUCTURE_TAG
%token <i> PARSEOP_STRUCTURE_ELEMENT
%token <i> PARSEOP_STRUCTURE_INSTANCE
%token <i> PARSEOP_STRUCTURE_REFERENCE
%token <i> PARSEOP_STRUCTURE_POINTER
/* Top level */
%token <i> PARSEOP_ASL_CODE
/*******************************************************************************
*
* Tokens below are not in the aslmap.c file
*
******************************************************************************/
/* Tokens below this are not in the aslmap.c file */
/* Specific parentheses tokens are not used at this time */
/* PARSEOP_EXP_PAREN_OPEN */
/* PARSEOP_EXP_PAREN_CLOSE */
/* ASL+ variable creation */
%token <i> PARSEOP_INTEGER_TYPE
%token <i> PARSEOP_STRING_TYPE
%token <i> PARSEOP_BUFFER_TYPE
%token <i> PARSEOP_PACKAGE_TYPE
%token <i> PARSEOP_REFERENCE_TYPE
/*
* Special functions. These should probably stay at the end of this
* table.
*/
%token <i> PARSEOP___DATE__
%token <i> PARSEOP___FILE__
%token <i> PARSEOP___LINE__
%token <i> PARSEOP___PATH__
%token <i> PARSEOP___METHOD__

Some files were not shown because too many files have changed in this diff Show More