xref: /freebsd/sys/contrib/dev/acpica/compiler/aslsupport.y (revision af6a5351a1fdb1130f18be6c782c4d48916eb971)
1 NoEcho('
2 /******************************************************************************
3  *
4  * Module Name: aslsupport.y - Bison/Yacc C support functions
5  *
6  *****************************************************************************/
7 
8 /*
9  * Copyright (C) 2000 - 2017, Intel Corp.
10  * All rights reserved.
11  *
12  * Redistribution and use in source and binary forms, with or without
13  * modification, are permitted provided that the following conditions
14  * are met:
15  * 1. Redistributions of source code must retain the above copyright
16  *    notice, this list of conditions, and the following disclaimer,
17  *    without modification.
18  * 2. Redistributions in binary form must reproduce at minimum a disclaimer
19  *    substantially similar to the "NO WARRANTY" disclaimer below
20  *    ("Disclaimer") and any redistribution must be conditioned upon
21  *    including a substantially similar Disclaimer requirement for further
22  *    binary redistribution.
23  * 3. Neither the names of the above-listed copyright holders nor the names
24  *    of any contributors may be used to endorse or promote products derived
25  *    from this software without specific prior written permission.
26  *
27  * Alternatively, this software may be distributed under the terms of the
28  * GNU General Public License ("GPL") version 2 as published by the Free
29  * Software Foundation.
30  *
31  * NO WARRANTY
32  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
33  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
34  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR
35  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
36  * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
37  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
38  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
39  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
40  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
41  * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
42  * POSSIBILITY OF SUCH DAMAGES.
43  */
44 
45 ')
46 
47 /******************************************************************************
48  *
49  * Local support functions
50  *
51  *****************************************************************************/
52 
53 /*! [Begin] no source code translation */
54 int
55 AslCompilerwrap(void)
56 {
57   return (1);
58 }
59 /*! [End] no source code translation !*/
60 
61 
62 void *
63 AslLocalAllocate (
64     unsigned int        Size)
65 {
66     void                *Mem;
67 
68 
69     DbgPrint (ASL_PARSE_OUTPUT,
70         "\nAslLocalAllocate: Expanding Stack to %u\n\n", Size);
71 
72     Mem = ACPI_ALLOCATE_ZEROED (Size);
73     if (!Mem)
74     {
75         AslCommonError (ASL_ERROR, ASL_MSG_MEMORY_ALLOCATION,
76             Gbl_CurrentLineNumber, Gbl_LogicalLineNumber,
77             Gbl_InputByteCount, Gbl_CurrentColumn,
78             Gbl_Files[ASL_FILE_INPUT].Filename, NULL);
79         exit (1);
80     }
81 
82     return (Mem);
83 }
84 
85 ACPI_PARSE_OBJECT *
86 AslDoError (
87     void)
88 {
89 
90     return (TrCreateLeafNode (PARSEOP_ERRORNODE));
91 }
92 
93 
94 /*******************************************************************************
95  *
96  * FUNCTION:    UtGetOpName
97  *
98  * PARAMETERS:  ParseOpcode         - Parser keyword ID
99  *
100  * RETURN:      Pointer to the opcode name
101  *
102  * DESCRIPTION: Get the ascii name of the parse opcode
103  *
104  ******************************************************************************/
105 
106 char *
107 UtGetOpName (
108     UINT32                  ParseOpcode)
109 {
110 #ifdef ASL_YYTNAME_START
111     /*
112      * First entries (ASL_YYTNAME_START) in yytname are special reserved names.
113      * Ignore first 8 characters of the name
114      */
115     return ((char *) yytname
116         [(ParseOpcode - ASL_FIRST_PARSE_OPCODE) + ASL_YYTNAME_START] + 8);
117 #else
118     return ("[Unknown parser generator]");
119 #endif
120 }
121