Source
// SPDX-License-Identifier: BSD-3-Clause OR GPL-2.0
/******************************************************************************
*
* Module Name: psparse - Parser top level AML parse routines
*
* Copyright (C) 2000 - 2019, Intel Corp.
*
*****************************************************************************/
/*
* Parse the AML and build an operation tree as most interpreters,
* like Perl, do. Parsing is done by hand rather than with a YACC
* generated parser to tightly constrain stack and dynamic memory
* usage. At the same time, parsing is kept flexible and the code
* fairly compact by parsing based on a list of AML opcode
* templates in aml_op_info[]
*/
ACPI_MODULE_NAME("psparse")
/*******************************************************************************
*
* FUNCTION: acpi_ps_get_opcode_size
*
* PARAMETERS: opcode - An AML opcode
*
* RETURN: Size of the opcode, in bytes (1 or 2)
*
* DESCRIPTION: Get the size of the current opcode.
*
******************************************************************************/
u32 acpi_ps_get_opcode_size(u32 opcode)
{
/* Extended (2-byte) opcode if > 255 */
if (opcode > 0x00FF) {
return (2);
}
/* Otherwise, just a single byte opcode */
return (1);
}
/*******************************************************************************
*
* FUNCTION: acpi_ps_peek_opcode
*
* PARAMETERS: parser_state - A parser state object
*
* RETURN: Next AML opcode
*
* DESCRIPTION: Get next AML opcode (without incrementing AML pointer)