1/****************************************************************************** 2 * 3 * Module Name: asltypes.h - compiler data types and struct definitions 4 * 5 *****************************************************************************/ 6 7/* 8 * Copyright (C) 2000 - 2023, Intel Corp. 9 * All rights reserved. 10 * 11 * Redistribution and use in source and binary forms, with or without 12 * modification, are permitted provided that the following conditions 13 * are met: 14 * 1. Redistributions of source code must retain the above copyright 15 * notice, this list of conditions, and the following disclaimer, 16 * without modification. 17 * 2. Redistributions in binary form must reproduce at minimum a disclaimer 18 * substantially similar to the "NO WARRANTY" disclaimer below 19 * ("Disclaimer") and any redistribution must be conditioned upon 20 * including a substantially similar Disclaimer requirement for further 21 * binary redistribution. 22 * 3. Neither the names of the above-listed copyright holders nor the names 23 * of any contributors may be used to endorse or promote products derived 24 * from this software without specific prior written permission. 25 * 26 * Alternatively, this software may be distributed under the terms of the 27 * GNU General Public License ("GPL") version 2 as published by the Free 28 * Software Foundation. 29 * 30 * NO WARRANTY 31 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 32 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 33 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 34 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 35 * HOLDERS OR CONTRIBUTORS BE LIABLE FOR SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 39 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 40 * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 41 * POSSIBILITY OF SUCH DAMAGES. 42 */ 43 44#ifndef __ASLTYPES_H 45#define __ASLTYPES_H 46 47 48/******************************************************************************* 49 * 50 * Structure definitions 51 * 52 ******************************************************************************/ 53 54 55/* Op flags for the ACPI_PARSE_OBJECT */ 56 57#define OP_VISITED 0x00000001 58#define OP_AML_PACKAGE 0x00000002 59#define OP_IS_TARGET 0x00000004 60#define OP_IS_RESOURCE_DESC 0x00000008 61#define OP_IS_RESOURCE_FIELD 0x00000010 62#define OP_HAS_NO_EXIT 0x00000020 63#define OP_IF_HAS_NO_EXIT 0x00000040 64#define OP_NAME_INTERNALIZED 0x00000080 65#define OP_METHOD_NO_RETVAL 0x00000100 66#define OP_METHOD_SOME_NO_RETVAL 0x00000200 67#define OP_RESULT_NOT_USED 0x00000400 68#define OP_METHOD_TYPED 0x00000800 69#define OP_COULD_NOT_REDUCE 0x00001000 70#define OP_COMPILE_TIME_CONST 0x00002000 71#define OP_IS_TERM_ARG 0x00004000 72#define OP_WAS_ONES_OP 0x00008000 73#define OP_IS_NAME_DECLARATION 0x00010000 74#define OP_COMPILER_EMITTED 0x00020000 75#define OP_IS_DUPLICATE 0x00040000 76#define OP_IS_RESOURCE_DATA 0x00080000 77#define OP_IS_NULL_RETURN 0x00100000 78#define OP_NOT_FOUND_DURING_LOAD 0x00200000 79 80#define ACPI_NUM_OP_FLAGS 0x22 81 82/* Keeps information about individual control methods */ 83 84typedef struct asl_method_info 85{ 86 ACPI_PARSE_OBJECT *Op; 87 ACPI_PARSE_OBJECT *CurrentOp; 88 struct asl_method_info *Next; 89 UINT32 ValidArgTypes[ACPI_METHOD_NUM_ARGS]; 90 UINT32 ValidReturnTypes; 91 UINT32 NumReturnNoValue; 92 UINT32 NumReturnWithValue; 93 UINT8 NumArguments; 94 UINT8 LocalInitialized[ACPI_METHOD_NUM_LOCALS]; 95 UINT8 ArgInitialized[ACPI_METHOD_NUM_ARGS]; 96 UINT8 HasBeenTyped; 97 UINT8 ShouldBeSerialized; 98 UINT8 CreatesNamedObjects; 99 100} ASL_METHOD_INFO; 101 102 103/* Parse tree walk info for control method analysis */ 104 105typedef struct asl_analysis_walk_info 106{ 107 ASL_METHOD_INFO *MethodStack; 108 109} ASL_ANALYSIS_WALK_INFO; 110 111 112/* An entry in the ParseOpcode to AmlOpcode mapping table */ 113 114typedef struct asl_mapping_entry 115{ 116 UINT32 Value; 117 UINT32 AcpiBtype; /* Object type or return type */ 118 UINT16 AmlOpcode; 119 UINT8 Flags; 120 121} ASL_MAPPING_ENTRY; 122 123 124/* Parse tree walk info structure */ 125 126typedef struct asl_walk_info 127{ 128 ACPI_PARSE_OBJECT **NodePtr; 129 UINT32 *LevelPtr; 130 131} ASL_WALK_INFO; 132 133 134/* File info */ 135 136typedef struct asl_file_info 137{ 138 FILE *Handle; 139 char *Filename; 140 141} ASL_FILE_INFO; 142 143typedef struct asl_file_status 144{ 145 UINT32 Line; 146 UINT32 Offset; 147 148} ASL_FILE_STATUS; 149 150 151typedef UINT32 ASL_FILE_SWITCH_STATUS; /* File switch status */ 152#define SWITCH_TO_DIFFERENT_FILE 0 153#define SWITCH_TO_SAME_FILE 1 154#define FILE_NOT_FOUND 2 155 156/* 157 * File types. Note: Any changes to this table must also be reflected 158 * in the Gbl_Files array. 159 * 160 * Corresponding filename suffixes are in comments 161 * 162 * NOTE: Don't move the first 4 file types 163 * 164 * .xxx file extension: this is used as a temporary .aml file for 165 * the ASL/ASL+ converter and is deleted after conversion. This file 166 * should never be used in the interpreter. 167 */ 168typedef enum 169{ 170 ASL_FILE_STDOUT = 0, 171 ASL_FILE_STDERR, 172 ASL_FILE_INPUT, /* .asl */ 173 ASL_FILE_AML_OUTPUT, /* .aml */ 174 ASL_FILE_SOURCE_OUTPUT, /* .src */ 175 ASL_FILE_PREPROCESSOR, /* .pre */ 176 ASL_FILE_PREPROCESSOR_USER, /* .i */ 177 ASL_FILE_LISTING_OUTPUT, /* .lst */ 178 ASL_FILE_HEX_OUTPUT, /* .hex */ 179 ASL_FILE_NAMESPACE_OUTPUT, /* .nsp */ 180 ASL_FILE_DEBUG_OUTPUT, /* .txt */ 181 ASL_FILE_ASM_SOURCE_OUTPUT, /* .asm */ 182 ASL_FILE_C_SOURCE_OUTPUT, /* .c */ 183 ASL_FILE_ASM_INCLUDE_OUTPUT,/* .inc */ 184 ASL_FILE_C_INCLUDE_OUTPUT, /* .h */ 185 ASL_FILE_C_OFFSET_OUTPUT, /* .offset.h */ 186 ASL_FILE_MAP_OUTPUT, /* .map */ 187 ASL_FILE_XREF_OUTPUT, /* .xrf */ 188 ASL_FILE_CONV_DEBUG_OUTPUT, /* .cdb */ 189 ASL_FILE_CONV_OUTPUT /* .xxx */ 190 191} ASL_FILE_TYPES; 192 193#define ASL_MAX_FILE_TYPE 18 194#define ASL_NUM_FILES (ASL_MAX_FILE_TYPE + 1) 195 196typedef struct asl_file_desc 197{ 198 const char *ShortDescription; 199 const char *Description; 200 201} ASL_FILE_DESC; 202 203 204/* Name suffixes used to create filenames for output files */ 205 206#define FILE_SUFFIX_ASL_CODE "asl" 207#define FILE_SUFFIX_AML_CODE "aml" 208#define FILE_SUFFIX_SOURCE "src" 209#define FILE_SUFFIX_PREPROCESSOR "pre" 210#define FILE_SUFFIX_PREPROC_USER "i" 211#define FILE_SUFFIX_LISTING "lst" 212#define FILE_SUFFIX_HEX_DUMP "hex" 213#define FILE_SUFFIX_NAMESPACE "nsp" 214#define FILE_SUFFIX_DEBUG "txt" 215#define FILE_SUFFIX_ASM_SOURCE "asm" 216#define FILE_SUFFIX_C_SOURCE "c" 217#define FILE_SUFFIX_ASM_INCLUDE "inc" 218#define FILE_SUFFIX_C_INCLUDE "h" 219#define FILE_SUFFIX_C_OFFSET "offset.h" 220#define FILE_SUFFIX_MAP "map" 221#define FILE_SUFFIX_XREF "xrf" 222#define FILE_SUFFIX_CONVERT_AML "xxx" 223#define FILE_SUFFIX_CONVERT_DEBUG "cdb" 224 225 226/* Cache block structure for ParseOps and Strings */ 227 228typedef struct asl_cache_info 229{ 230 void *Next; 231 char Buffer[]; 232 233} ASL_CACHE_INFO; 234 235 236typedef struct asl_include_dir 237{ 238 char *Dir; 239 struct asl_include_dir *Next; 240 241} ASL_INCLUDE_DIR; 242 243 244/* 245 * An entry in the exception list, one for each error/warning 246 * Note: SubError nodes would be treated with the same messageId and Level 247 * as the parent error node. 248 * 249 * The source filename represents the name of the .src of where the error 250 * occurred. This is useful for errors that occur inside of include files. 251 * Since include files aren't recorded as a part of the global files list, 252 * this provides a way to get the included file. 253 */ 254typedef struct asl_error_msg 255{ 256 UINT32 LineNumber; 257 UINT32 LogicalLineNumber; 258 UINT32 LogicalByteOffset; 259 UINT32 Column; 260 char *Message; 261 struct asl_error_msg *Next; 262 struct asl_error_msg *SubError; 263 char *Filename; 264 char *SourceLine; 265 char *SourceFilename; 266 UINT32 FilenameLength; 267 UINT16 MessageId; 268 UINT8 Level; 269 270} ASL_ERROR_MSG; 271 272/* An entry in the expected messages array */ 273 274typedef struct asl_expected_message 275{ 276 UINT32 MessageId; 277 char *MessageIdStr; 278 BOOLEAN MessageReceived; 279 280} ASL_EXPECTED_MESSAGE; 281 282/* 283 * An entry in the line-based expected messages list 284 * 285 * TBD: might be possible to merge this with ASL_EXPECTED_MESSAGE 286 */ 287typedef struct asl_expected_msg_node 288{ 289 struct asl_expected_msg_node *Next; 290 UINT32 MessageId; 291 char *MessageIdStr; 292 struct asl_location_node *LocationList; 293 294} ASL_EXPECTED_MSG_NODE; 295 296typedef struct asl_location_node 297{ 298 struct asl_location_node *Next; 299 char *Filename; 300 UINT32 LineNumber; 301 UINT32 Column; 302 UINT32 LogicalByteOffset; 303 BOOLEAN MessageReceived; 304 305} ASL_LOCATION_NODE; 306 307 308/* An entry in the listing file stack (for include files) */ 309 310typedef struct asl_listing_node 311{ 312 char *Filename; 313 UINT32 LineNumber; 314 struct asl_listing_node *Next; 315 316} ASL_LISTING_NODE; 317 318 319/* Callback interface for a parse tree walk */ 320 321/* 322 * TBD - another copy of this is in adisasm.h, fix 323 */ 324#ifndef ASL_WALK_CALLBACK_DEFINED 325typedef 326ACPI_STATUS (*ASL_WALK_CALLBACK) ( 327 ACPI_PARSE_OBJECT *Op, 328 UINT32 Level, 329 void *Context); 330#define ASL_WALK_CALLBACK_DEFINED 331#endif 332 333 334typedef struct asl_event_info 335{ 336 UINT64 StartTime; 337 UINT64 EndTime; 338 char *EventName; 339 BOOLEAN Valid; 340 341} ASL_EVENT_INFO; 342 343 344/* Hardware mapping file structures */ 345 346typedef struct acpi_gpio_info 347{ 348 struct acpi_gpio_info *Next; 349 ACPI_PARSE_OBJECT *Op; 350 char *DeviceName; 351 ACPI_NAMESPACE_NODE *TargetNode; 352 UINT32 References; 353 UINT32 PinCount; 354 UINT32 PinIndex; 355 UINT16 PinNumber; 356 UINT8 Type; 357 UINT8 Direction; 358 UINT8 Polarity; 359 360} ACPI_GPIO_INFO; 361 362typedef struct acpi_serial_info 363{ 364 struct acpi_serial_info *Next; 365 ACPI_PARSE_OBJECT *Op; 366 char *DeviceName; 367 ACPI_NAMESPACE_NODE *TargetNode; 368 AML_RESOURCE *Resource; 369 UINT32 Speed; 370 UINT16 Address; 371 372} ACPI_SERIAL_INFO; 373 374typedef struct asl_method_local 375{ 376 ACPI_PARSE_OBJECT *Op; 377 UINT8 Flags; 378 379} ASL_METHOD_LOCAL; 380 381/* Values for Flags field above */ 382 383#define ASL_LOCAL_INITIALIZED (1) 384#define ASL_LOCAL_REFERENCED (1<<1) 385#define ASL_ARG_IS_LOCAL (1<<2) 386#define ASL_ARG_INITIALIZED (1<<3) 387#define ASL_ARG_REFERENCED (1<<4) 388 389/* Info used to track method counts for cross reference output file */ 390 391typedef struct asl_xref_info 392{ 393 UINT32 ThisMethodInvocations; 394 UINT32 TotalPredefinedMethods; 395 UINT32 TotalUserMethods; 396 UINT32 TotalUnreferenceUserMethods; 397 UINT32 ThisObjectReferences; 398 UINT32 TotalObjects; 399 UINT32 TotalUnreferencedObjects; 400 ACPI_PARSE_OBJECT *MethodOp; 401 ACPI_PARSE_OBJECT *CurrentMethodOp; 402 403} ASL_XREF_INFO; 404 405 406typedef struct asl_file_node 407{ 408 FILE *File; 409 UINT32 CurrentLineNumber; 410 void *State; 411 char *Filename; 412 struct asl_file_node *Next; 413 414} ASL_FILE_NODE; 415 416typedef struct asl_files_node 417{ 418 struct asl_file_info Files[ASL_NUM_FILES]; 419 struct asl_files_node *Next; 420 char *TableSignature; 421 char *TableId; 422 UINT32 TotalLineCount; 423 UINT32 OriginalInputFileSize; 424 UINT32 TotalKeywords; 425 UINT32 TotalFields; 426 UINT32 OutputByteLength; 427 UINT32 TotalNamedObjects; 428 UINT32 TotalExecutableOpcodes; 429 BOOLEAN ParserErrorDetected; 430 UINT8 FileType; 431 432} ASL_GLOBAL_FILE_NODE; 433 434#endif /* __ASLTYPES_H */ 435