dtfield.c revision 209734
1208625Sjkim/****************************************************************************** 2208625Sjkim * 3208625Sjkim * Module Name: dtfield.c - Code generation for individual source fields 4208625Sjkim * 5208625Sjkim *****************************************************************************/ 6208625Sjkim 7208625Sjkim/****************************************************************************** 8208625Sjkim * 9208625Sjkim * 1. Copyright Notice 10208625Sjkim * 11208625Sjkim * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. 12208625Sjkim * All rights reserved. 13208625Sjkim * 14208625Sjkim * 2. License 15208625Sjkim * 16208625Sjkim * 2.1. This is your license from Intel Corp. under its intellectual property 17208625Sjkim * rights. You may have additional license terms from the party that provided 18208625Sjkim * you this software, covering your right to use that party's intellectual 19208625Sjkim * property rights. 20208625Sjkim * 21208625Sjkim * 2.2. Intel grants, free of charge, to any person ("Licensee") obtaining a 22208625Sjkim * copy of the source code appearing in this file ("Covered Code") an 23208625Sjkim * irrevocable, perpetual, worldwide license under Intel's copyrights in the 24208625Sjkim * base code distributed originally by Intel ("Original Intel Code") to copy, 25208625Sjkim * make derivatives, distribute, use and display any portion of the Covered 26208625Sjkim * Code in any form, with the right to sublicense such rights; and 27208625Sjkim * 28208625Sjkim * 2.3. Intel grants Licensee a non-exclusive and non-transferable patent 29208625Sjkim * license (with the right to sublicense), under only those claims of Intel 30208625Sjkim * patents that are infringed by the Original Intel Code, to make, use, sell, 31208625Sjkim * offer to sell, and import the Covered Code and derivative works thereof 32208625Sjkim * solely to the minimum extent necessary to exercise the above copyright 33208625Sjkim * license, and in no event shall the patent license extend to any additions 34208625Sjkim * to or modifications of the Original Intel Code. No other license or right 35208625Sjkim * is granted directly or by implication, estoppel or otherwise; 36208625Sjkim * 37208625Sjkim * The above copyright and patent license is granted only if the following 38208625Sjkim * conditions are met: 39208625Sjkim * 40208625Sjkim * 3. Conditions 41208625Sjkim * 42208625Sjkim * 3.1. Redistribution of Source with Rights to Further Distribute Source. 43208625Sjkim * Redistribution of source code of any substantial portion of the Covered 44208625Sjkim * Code or modification with rights to further distribute source must include 45208625Sjkim * the above Copyright Notice, the above License, this list of Conditions, 46208625Sjkim * and the following Disclaimer and Export Compliance provision. In addition, 47208625Sjkim * Licensee must cause all Covered Code to which Licensee contributes to 48208625Sjkim * contain a file documenting the changes Licensee made to create that Covered 49208625Sjkim * Code and the date of any change. Licensee must include in that file the 50208625Sjkim * documentation of any changes made by any predecessor Licensee. Licensee 51208625Sjkim * must include a prominent statement that the modification is derived, 52208625Sjkim * directly or indirectly, from Original Intel Code. 53208625Sjkim * 54208625Sjkim * 3.2. Redistribution of Source with no Rights to Further Distribute Source. 55208625Sjkim * Redistribution of source code of any substantial portion of the Covered 56208625Sjkim * Code or modification without rights to further distribute source must 57208625Sjkim * include the following Disclaimer and Export Compliance provision in the 58208625Sjkim * documentation and/or other materials provided with distribution. In 59208625Sjkim * addition, Licensee may not authorize further sublicense of source of any 60208625Sjkim * portion of the Covered Code, and must include terms to the effect that the 61208625Sjkim * license from Licensee to its licensee is limited to the intellectual 62208625Sjkim * property embodied in the software Licensee provides to its licensee, and 63208625Sjkim * not to intellectual property embodied in modifications its licensee may 64208625Sjkim * make. 65208625Sjkim * 66208625Sjkim * 3.3. Redistribution of Executable. Redistribution in executable form of any 67208625Sjkim * substantial portion of the Covered Code or modification must reproduce the 68208625Sjkim * above Copyright Notice, and the following Disclaimer and Export Compliance 69208625Sjkim * provision in the documentation and/or other materials provided with the 70208625Sjkim * distribution. 71208625Sjkim * 72208625Sjkim * 3.4. Intel retains all right, title, and interest in and to the Original 73208625Sjkim * Intel Code. 74208625Sjkim * 75208625Sjkim * 3.5. Neither the name Intel nor any other trademark owned or controlled by 76208625Sjkim * Intel shall be used in advertising or otherwise to promote the sale, use or 77208625Sjkim * other dealings in products derived from or relating to the Covered Code 78208625Sjkim * without prior written authorization from Intel. 79208625Sjkim * 80208625Sjkim * 4. Disclaimer and Export Compliance 81208625Sjkim * 82208625Sjkim * 4.1. INTEL MAKES NO WARRANTY OF ANY KIND REGARDING ANY SOFTWARE PROVIDED 83208625Sjkim * HERE. ANY SOFTWARE ORIGINATING FROM INTEL OR DERIVED FROM INTEL SOFTWARE 84208625Sjkim * IS PROVIDED "AS IS," AND INTEL WILL NOT PROVIDE ANY SUPPORT, ASSISTANCE, 85208625Sjkim * INSTALLATION, TRAINING OR OTHER SERVICES. INTEL WILL NOT PROVIDE ANY 86208625Sjkim * UPDATES, ENHANCEMENTS OR EXTENSIONS. INTEL SPECIFICALLY DISCLAIMS ANY 87208625Sjkim * IMPLIED WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT AND FITNESS FOR A 88208625Sjkim * PARTICULAR PURPOSE. 89208625Sjkim * 90208625Sjkim * 4.2. IN NO EVENT SHALL INTEL HAVE ANY LIABILITY TO LICENSEE, ITS LICENSEES 91208625Sjkim * OR ANY OTHER THIRD PARTY, FOR ANY LOST PROFITS, LOST DATA, LOSS OF USE OR 92208625Sjkim * COSTS OF PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES, OR FOR ANY INDIRECT, 93208625Sjkim * SPECIAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THIS AGREEMENT, UNDER ANY 94208625Sjkim * CAUSE OF ACTION OR THEORY OF LIABILITY, AND IRRESPECTIVE OF WHETHER INTEL 95208625Sjkim * HAS ADVANCE NOTICE OF THE POSSIBILITY OF SUCH DAMAGES. THESE LIMITATIONS 96208625Sjkim * SHALL APPLY NOTWITHSTANDING THE FAILURE OF THE ESSENTIAL PURPOSE OF ANY 97208625Sjkim * LIMITED REMEDY. 98208625Sjkim * 99208625Sjkim * 4.3. Licensee shall not export, either directly or indirectly, any of this 100208625Sjkim * software or system incorporating such software without first obtaining any 101208625Sjkim * required license or other approval from the U. S. Department of Commerce or 102208625Sjkim * any other agency or department of the United States Government. In the 103208625Sjkim * event Licensee exports any such software from the United States or 104208625Sjkim * re-exports any such software from a foreign destination, Licensee shall 105208625Sjkim * ensure that the distribution and export/re-export of the software is in 106208625Sjkim * compliance with all laws, regulations, orders, or other restrictions of the 107208625Sjkim * U.S. Export Administration Regulations. Licensee agrees that neither it nor 108208625Sjkim * any of its subsidiaries will export/re-export any technical data, process, 109208625Sjkim * software, or service, directly or indirectly, to any country for which the 110208625Sjkim * United States government or any agency thereof requires an export license, 111208625Sjkim * other governmental approval, or letter of assurance, without first obtaining 112208625Sjkim * such license, approval or letter. 113208625Sjkim * 114208625Sjkim *****************************************************************************/ 115208625Sjkim 116208625Sjkim#define __DTFIELD_C__ 117208625Sjkim 118208625Sjkim#include "aslcompiler.h" 119208625Sjkim#include "dtcompiler.h" 120208625Sjkim 121208625Sjkim#define _COMPONENT DT_COMPILER 122208625Sjkim ACPI_MODULE_NAME ("dtfield") 123208625Sjkim 124208625Sjkim 125208625Sjkim/* Local prototypes */ 126208625Sjkim 127208625Sjkimstatic void 128208625SjkimDtCompileString ( 129208625Sjkim UINT8 *Buffer, 130208625Sjkim DT_FIELD *Field, 131208625Sjkim UINT32 ByteLength); 132208625Sjkim 133208625Sjkimstatic char * 134209734SjkimDtNormalizeBuffer ( 135209734Sjkim char *Buffer, 136209734Sjkim UINT32 *Count); 137208625Sjkim 138208625Sjkim 139208625Sjkim/****************************************************************************** 140208625Sjkim * 141208625Sjkim * FUNCTION: DtCompileOneField 142208625Sjkim * 143208625Sjkim * PARAMETERS: Buffer - Output buffer 144208625Sjkim * Field - Field to be compiled 145208625Sjkim * ByteLength - Byte length of the field 146208625Sjkim * Type - Field type 147208625Sjkim * 148208625Sjkim * RETURN: None 149208625Sjkim * 150208625Sjkim * DESCRIPTION: Compile a field value to binary 151208625Sjkim * 152208625Sjkim *****************************************************************************/ 153208625Sjkim 154208625Sjkimvoid 155208625SjkimDtCompileOneField ( 156208625Sjkim UINT8 *Buffer, 157208625Sjkim DT_FIELD *Field, 158208625Sjkim UINT32 ByteLength, 159208625Sjkim UINT8 Type, 160208625Sjkim UINT8 Flags) 161208625Sjkim{ 162208625Sjkim 163208625Sjkim switch (Type) 164208625Sjkim { 165208625Sjkim case DT_FIELD_TYPE_INTEGER: 166208625Sjkim DtCompileInteger (Buffer, Field, ByteLength, Flags); 167208625Sjkim break; 168208625Sjkim 169208625Sjkim case DT_FIELD_TYPE_STRING: 170208625Sjkim DtCompileString (Buffer, Field, ByteLength); 171208625Sjkim break; 172208625Sjkim 173208625Sjkim case DT_FIELD_TYPE_BUFFER: 174208625Sjkim DtCompileBuffer (Buffer, Field->Value, Field, ByteLength); 175208625Sjkim break; 176208625Sjkim 177208625Sjkim default: 178208625Sjkim DtFatal (ASL_MSG_COMPILER_INTERNAL, Field, "Invalid field type"); 179208625Sjkim break; 180208625Sjkim } 181208625Sjkim} 182208625Sjkim 183208625Sjkim 184208625Sjkim/****************************************************************************** 185208625Sjkim * 186208625Sjkim * FUNCTION: DtCompileString 187208625Sjkim * 188208625Sjkim * PARAMETERS: Buffer - Output buffer 189208625Sjkim * Field - String to be copied to buffer 190208625Sjkim * ByteLength - Maximum length of string 191208625Sjkim * 192208625Sjkim * RETURN: None 193208625Sjkim * 194208625Sjkim * DESCRIPTION: Copy string to the buffer 195208625Sjkim * 196208625Sjkim *****************************************************************************/ 197208625Sjkim 198208625Sjkimstatic void 199208625SjkimDtCompileString ( 200208625Sjkim UINT8 *Buffer, 201208625Sjkim DT_FIELD *Field, 202208625Sjkim UINT32 ByteLength) 203208625Sjkim{ 204208625Sjkim UINT32 Length; 205208625Sjkim 206208625Sjkim 207208625Sjkim Length = ACPI_STRLEN (Field->Value); 208208625Sjkim 209208625Sjkim /* Check if the string is too long for the field */ 210208625Sjkim 211208625Sjkim if (Length > ByteLength) 212208625Sjkim { 213208625Sjkim sprintf (MsgBuffer, "Maximum %u characters", ByteLength); 214208625Sjkim DtError (ASL_ERROR, ASL_MSG_STRING_LENGTH, Field, MsgBuffer); 215208625Sjkim Length = ByteLength; 216208625Sjkim } 217208625Sjkim 218208625Sjkim ACPI_MEMCPY (Buffer, Field->Value, Length); 219208625Sjkim} 220208625Sjkim 221208625Sjkim 222208625Sjkim/****************************************************************************** 223208625Sjkim * 224208625Sjkim * FUNCTION: DtCompileInteger 225208625Sjkim * 226208625Sjkim * PARAMETERS: Buffer - Output buffer 227208625Sjkim * Field - Field obj with Integer to be compiled 228208625Sjkim * ByteLength - Byte length of the integer 229208625Sjkim * 230208625Sjkim * RETURN: None 231208625Sjkim * 232208625Sjkim * DESCRIPTION: Compile an integer 233208625Sjkim * 234208625Sjkim *****************************************************************************/ 235208625Sjkim 236208625Sjkimvoid 237208625SjkimDtCompileInteger ( 238208625Sjkim UINT8 *Buffer, 239208625Sjkim DT_FIELD *Field, 240208625Sjkim UINT32 ByteLength, 241208625Sjkim UINT8 Flags) 242208625Sjkim{ 243208625Sjkim UINT64 Value = 0; 244208625Sjkim UINT64 MaxValue; 245208625Sjkim UINT8 *Hex; 246208625Sjkim char *Message = NULL; 247208625Sjkim ACPI_STATUS Status; 248208625Sjkim int i; 249208625Sjkim 250208625Sjkim 251208625Sjkim /* Byte length must be in range 1-8 */ 252208625Sjkim 253208625Sjkim if ((ByteLength > 8) || (ByteLength == 0)) 254208625Sjkim { 255208625Sjkim DtFatal (ASL_MSG_COMPILER_INTERNAL, Field, 256208625Sjkim "Invalid internal Byte length"); 257208625Sjkim return; 258208625Sjkim } 259208625Sjkim 260208625Sjkim /* Convert string to an actual integer */ 261208625Sjkim 262208625Sjkim Status = DtStrtoul64 (Field->Value, &Value); 263208625Sjkim if (ACPI_FAILURE (Status)) 264208625Sjkim { 265208625Sjkim if (Status == AE_LIMIT) 266208625Sjkim { 267208625Sjkim Message = "Constant larger than 64 bits"; 268208625Sjkim } 269208625Sjkim else if (Status == AE_BAD_CHARACTER) 270208625Sjkim { 271208625Sjkim Message = "Invalid character in constant"; 272208625Sjkim } 273208625Sjkim 274208625Sjkim DtError (ASL_ERROR, ASL_MSG_INVALID_HEX_INTEGER, Field, Message); 275208625Sjkim goto Exit; 276208625Sjkim } 277208625Sjkim 278208625Sjkim /* Ensure that reserved fields are set to zero */ 279208625Sjkim /* TBD: should we set to zero, or just make this an ERROR? */ 280208625Sjkim /* TBD: Probably better to use a flag */ 281208625Sjkim 282208625Sjkim if (!ACPI_STRCMP (Field->Name, "Reserved") && 283208625Sjkim (Value != 0)) 284208625Sjkim { 285208625Sjkim DtError (ASL_WARNING, ASL_MSG_RESERVED_VALUE, Field, 286208625Sjkim "Setting to zero"); 287208625Sjkim Value = 0; 288208625Sjkim } 289208625Sjkim 290208625Sjkim /* Check if the value must be non-zero */ 291208625Sjkim 292208625Sjkim if ((Value == 0) && (Flags & DT_NON_ZERO)) 293208625Sjkim { 294208625Sjkim DtError (ASL_ERROR, ASL_MSG_ZERO_VALUE, Field, NULL); 295208625Sjkim } 296208625Sjkim 297208625Sjkim /* 298208625Sjkim * Generate the maximum value for the data type (ByteLength) 299208625Sjkim * Note: construct chosen for maximum portability 300208625Sjkim */ 301208625Sjkim MaxValue = ((UINT64) (-1)) >> (64 - (ByteLength * 8)); 302208625Sjkim 303208625Sjkim /* Validate that the input value is within range of the target */ 304208625Sjkim 305208625Sjkim if (Value > MaxValue) 306208625Sjkim { 307208625Sjkim sprintf (MsgBuffer, "Maximum %u bytes", ByteLength); 308208625Sjkim DtError (ASL_ERROR, ASL_MSG_INTEGER_SIZE, Field, MsgBuffer); 309208625Sjkim } 310208625Sjkim 311208625Sjkim /* 312208625Sjkim * TBD: hard code for ASF! Capabilites field. 313208625Sjkim * 314208625Sjkim * This field is actually a buffer, not a 56-bit integer -- 315208625Sjkim * so, the ordering is reversed. Something should be fixed 316208625Sjkim * so we don't need this code. 317208625Sjkim */ 318208625Sjkim if (ByteLength == 7) 319208625Sjkim { 320208625Sjkim Hex = ACPI_CAST_PTR (UINT8, &Value); 321208625Sjkim for (i = 6; i >= 0; i--) 322208625Sjkim { 323208625Sjkim Buffer[i] = *Hex; 324208625Sjkim Hex++; 325208625Sjkim } 326208625Sjkim return; 327208625Sjkim } 328208625Sjkim 329208625SjkimExit: 330208625Sjkim ACPI_MEMCPY (Buffer, &Value, ByteLength); 331208625Sjkim return; 332208625Sjkim} 333208625Sjkim 334208625Sjkim 335208625Sjkim/****************************************************************************** 336208625Sjkim * 337209734Sjkim * FUNCTION: DtNormalizeBuffer 338208625Sjkim * 339209734Sjkim * PARAMETERS: Buffer - Input buffer 340209734Sjkim * Count - Output the count of hex number in 341209734Sjkim * the Buffer 342208625Sjkim * 343209734Sjkim * RETURN: The normalized buffer, freed by caller 344208625Sjkim * 345209734Sjkim * DESCRIPTION: [1A,2B,3C,4D] or 1A, 2B, 3C, 4D will be normalized 346209734Sjkim * to 1A 2B 3C 4D 347208625Sjkim * 348208625Sjkim *****************************************************************************/ 349208625Sjkim 350208625Sjkimstatic char * 351209734SjkimDtNormalizeBuffer ( 352209734Sjkim char *Buffer, 353209734Sjkim UINT32 *Count) 354208625Sjkim{ 355209734Sjkim char *NewBuffer; 356209734Sjkim char *TmpBuffer; 357209734Sjkim UINT32 BufferCount = 0; 358209734Sjkim BOOLEAN Separator = TRUE; 359209734Sjkim char c; 360208625Sjkim 361208625Sjkim 362209734Sjkim NewBuffer = UtLocalCalloc (ACPI_STRLEN (Buffer) + 1); 363209734Sjkim TmpBuffer = NewBuffer; 364208625Sjkim 365209734Sjkim while ((c = *Buffer++)) 366209734Sjkim { 367209734Sjkim switch (c) 368209734Sjkim { 369209734Sjkim /* Valid separators */ 370208625Sjkim 371209734Sjkim case '[': 372209734Sjkim case ']': 373209734Sjkim case ' ': 374209734Sjkim case ',': 375209734Sjkim Separator = TRUE; 376209734Sjkim break; 377209734Sjkim 378209734Sjkim default: 379209734Sjkim if (Separator) 380209734Sjkim { 381209734Sjkim /* Insert blank as the standard separator */ 382209734Sjkim 383209734Sjkim if (NewBuffer[0]) 384209734Sjkim { 385209734Sjkim *TmpBuffer++ = ' '; 386209734Sjkim BufferCount++; 387209734Sjkim } 388209734Sjkim 389209734Sjkim Separator = FALSE; 390209734Sjkim } 391209734Sjkim 392209734Sjkim *TmpBuffer++ = c; 393209734Sjkim break; 394209734Sjkim } 395209734Sjkim } 396209734Sjkim 397209734Sjkim *Count = BufferCount + 1; 398209734Sjkim return (NewBuffer); 399208625Sjkim} 400208625Sjkim 401208625Sjkim 402208625Sjkim/****************************************************************************** 403208625Sjkim * 404208625Sjkim * FUNCTION: DtCompileBuffer 405208625Sjkim * 406208625Sjkim * PARAMETERS: Buffer - Output buffer 407208625Sjkim * StringValue - Integer list to be compiled 408208625Sjkim * Field - Current field object 409208625Sjkim * ByteLength - Byte length of the integer list 410208625Sjkim * 411208625Sjkim * RETURN: Count of remaining data in the input list 412208625Sjkim * 413208625Sjkim * DESCRIPTION: Compile and pack an integer list, for example 414208625Sjkim * "AA 1F 20 3B" ==> Buffer[] = {0xAA,0x1F,0x20,0x3B} 415208625Sjkim * 416208625Sjkim *****************************************************************************/ 417208625Sjkim 418208625SjkimUINT32 419208625SjkimDtCompileBuffer ( 420208625Sjkim UINT8 *Buffer, 421208625Sjkim char *StringValue, 422208625Sjkim DT_FIELD *Field, 423208625Sjkim UINT32 ByteLength) 424208625Sjkim{ 425208625Sjkim ACPI_STATUS Status; 426208625Sjkim char Hex[3]; 427208625Sjkim UINT64 Value; 428208625Sjkim UINT32 i; 429208625Sjkim UINT32 Count; 430208625Sjkim 431208625Sjkim 432209734Sjkim /* Allow several different types of value separators */ 433208625Sjkim 434209734Sjkim StringValue = DtNormalizeBuffer (StringValue, &Count); 435209734Sjkim 436208625Sjkim Hex[2] = 0; 437208625Sjkim for (i = 0; i < Count; i++) 438208625Sjkim { 439209734Sjkim /* Each element of StringValue is three chars */ 440208625Sjkim 441209734Sjkim Hex[0] = StringValue[(3 * i)]; 442209734Sjkim Hex[1] = StringValue[(3 * i) + 1]; 443209734Sjkim 444208625Sjkim /* Convert one hex byte */ 445208625Sjkim 446208625Sjkim Value = 0; 447208625Sjkim Status = DtStrtoul64 (Hex, &Value); 448208625Sjkim if (ACPI_FAILURE (Status)) 449208625Sjkim { 450208625Sjkim DtError (ASL_ERROR, ASL_MSG_BUFFER_ELEMENT, Field, MsgBuffer); 451208625Sjkim return (ByteLength - Count); 452208625Sjkim } 453208625Sjkim 454208625Sjkim Buffer[i] = (UINT8) Value; 455208625Sjkim } 456208625Sjkim 457209734Sjkim ACPI_FREE (StringValue); 458208625Sjkim return (ByteLength - Count); 459208625Sjkim} 460208625Sjkim 461208625Sjkim 462208625Sjkim/****************************************************************************** 463208625Sjkim * 464208625Sjkim * FUNCTION: DtCompileFlag 465208625Sjkim * 466208625Sjkim * PARAMETERS: Buffer - Output buffer 467208625Sjkim * Field - Field to be compiled 468208625Sjkim * Info - Flag info 469208625Sjkim * 470209734Sjkim * RETURN: 471208625Sjkim * 472208625Sjkim * DESCRIPTION: Compile a flag 473208625Sjkim * 474208625Sjkim *****************************************************************************/ 475208625Sjkim 476209734Sjkimvoid 477208625SjkimDtCompileFlag ( 478208625Sjkim UINT8 *Buffer, 479208625Sjkim DT_FIELD *Field, 480209734Sjkim ACPI_DMTABLE_INFO *Info) 481208625Sjkim{ 482208625Sjkim UINT64 Value = 0; 483208625Sjkim UINT32 BitLength = 1; 484209734Sjkim UINT8 BitPosition = 0; 485208625Sjkim ACPI_STATUS Status; 486208625Sjkim 487208625Sjkim 488208625Sjkim Status = DtStrtoul64 (Field->Value, &Value); 489208625Sjkim if (ACPI_FAILURE (Status)) 490208625Sjkim { 491208625Sjkim DtError (ASL_ERROR, ASL_MSG_INVALID_HEX_INTEGER, Field, NULL); 492208625Sjkim } 493208625Sjkim 494208625Sjkim switch (Info->Opcode) 495208625Sjkim { 496208625Sjkim case ACPI_DMT_FLAG0: 497208625Sjkim case ACPI_DMT_FLAG1: 498208625Sjkim case ACPI_DMT_FLAG2: 499208625Sjkim case ACPI_DMT_FLAG3: 500208625Sjkim case ACPI_DMT_FLAG4: 501208625Sjkim case ACPI_DMT_FLAG5: 502208625Sjkim case ACPI_DMT_FLAG6: 503208625Sjkim case ACPI_DMT_FLAG7: 504208625Sjkim 505209734Sjkim BitPosition = Info->Opcode; 506208625Sjkim BitLength = 1; 507208625Sjkim break; 508208625Sjkim 509208625Sjkim case ACPI_DMT_FLAGS0: 510209734Sjkim 511209734Sjkim BitPosition = 0; 512209734Sjkim BitLength = 2; 513209734Sjkim break; 514209734Sjkim 515209734Sjkim 516208625Sjkim case ACPI_DMT_FLAGS2: 517208625Sjkim 518209734Sjkim BitPosition = 2; 519208625Sjkim BitLength = 2; 520208625Sjkim break; 521208625Sjkim 522208625Sjkim default: 523208625Sjkim 524208625Sjkim DtFatal (ASL_MSG_COMPILER_INTERNAL, Field, "Invalid flag opcode"); 525208625Sjkim break; 526208625Sjkim } 527208625Sjkim 528208625Sjkim /* Check range of the input flag value */ 529208625Sjkim 530208625Sjkim if (Value >= ((UINT64) 1 << BitLength)) 531208625Sjkim { 532208625Sjkim sprintf (MsgBuffer, "Maximum %u bit", BitLength); 533208625Sjkim DtError (ASL_ERROR, ASL_MSG_FLAG_VALUE, Field, MsgBuffer); 534208625Sjkim Value = 0; 535208625Sjkim } 536208625Sjkim 537209734Sjkim *Buffer |= (UINT8) (Value << BitPosition); 538208625Sjkim} 539