Rev 1498 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 1498 | Rev 2216 | ||
---|---|---|---|
Line 6... | Line 6... | ||
6 | 6 | ||
7 | /****************************************************************************** |
7 | /****************************************************************************** |
8 | * |
8 | * |
9 | * 1. Copyright Notice |
9 | * 1. Copyright Notice |
10 | * |
10 | * |
11 | * Some or all of this work - Copyright (c) 1999 - 2010, Intel Corp. |
11 | * Some or all of this work - Copyright (c) 1999 - 2011, Intel Corp. |
12 | * All rights reserved. |
12 | * All rights reserved. |
13 | * |
13 | * |
14 | * 2. License |
14 | * 2. License |
15 | * |
15 | * |
Line 125... | Line 125... | ||
125 | static char VersionString[9]; |
125 | static char VersionString[9]; |
Line 126... | Line 126... | ||
126 | 126 | ||
Line 127... | Line 127... | ||
127 | 127 | ||
128 | /* Local prototypes */ |
128 | /* Local prototypes */ |
129 | 129 | ||
Line 130... | Line 130... | ||
130 | static void |
130 | static ACPI_STATUS |
131 | DtInitialize ( |
131 | DtInitialize ( |
Line 164... | Line 164... | ||
164 | DT_FIELD *FieldList; |
164 | DT_FIELD *FieldList; |
Line 165... | Line 165... | ||
165 | 165 | ||
Line 166... | Line 166... | ||
166 | 166 | ||
- | 167 | /* Initialize globals */ |
|
- | 168 | ||
- | 169 | Status = DtInitialize (); |
|
- | 170 | if (ACPI_FAILURE (Status)) |
|
- | 171 | { |
|
Line 167... | Line 172... | ||
167 | /* Initialize globals */ |
172 | printf ("Error during compiler initialization, 0x%X\n", Status); |
168 | 173 | return (Status); |
|
169 | DtInitialize (); |
174 | } |
170 | 175 | ||
Line 181... | Line 186... | ||
181 | if (!FieldList) |
186 | if (!FieldList) |
182 | { |
187 | { |
183 | /* TBD: temporary error message. Msgs should come from function above */ |
188 | /* TBD: temporary error message. Msgs should come from function above */ |
Line 184... | Line 189... | ||
184 | 189 | ||
185 | DtError (ASL_ERROR, ASL_MSG_SYNTAX, NULL, |
190 | DtError (ASL_ERROR, ASL_MSG_SYNTAX, NULL, |
- | 191 | "Input file does not appear to be an ASL or data table source file"); |
|
186 | "Could not parse input file"); |
192 | |
- | 193 | Status = AE_ERROR; |
|
187 | return (AE_ERROR); |
194 | goto CleanupAndExit; |
Line 188... | Line 195... | ||
188 | } |
195 | } |
Line 189... | Line 196... | ||
189 | 196 | ||
Line 201... | Line 208... | ||
201 | { |
208 | { |
202 | /* TBD: temporary error message. Msgs should come from function above */ |
209 | /* TBD: temporary error message. Msgs should come from function above */ |
Line 203... | Line 210... | ||
203 | 210 | ||
204 | DtError (ASL_ERROR, ASL_MSG_SYNTAX, NULL, |
211 | DtError (ASL_ERROR, ASL_MSG_SYNTAX, NULL, |
- | 212 | "Could not compile input file"); |
|
205 | "Could not compile input file"); |
213 | |
206 | goto CleanupAndExit; |
214 | goto CleanupAndExit; |
Line 207... | Line 215... | ||
207 | } |
215 | } |
Line 217... | Line 225... | ||
217 | 225 | ||
Line 218... | Line 226... | ||
218 | /* Write the binary, then the optional hex file */ |
226 | /* Write the binary, then the optional hex file */ |
219 | 227 | ||
- | 228 | DtOutputBinary (Gbl_RootTable); |
|
Line 220... | Line 229... | ||
220 | DtOutputBinary (Gbl_RootTable); |
229 | LsDoHexOutput (); |
Line 221... | Line 230... | ||
221 | LsDoHexOutput (); |
230 | DtWriteTableToListing (); |
222 | 231 | ||
Line 231... | Line 240... | ||
231 | * |
240 | * |
232 | * FUNCTION: DtInitialize |
241 | * FUNCTION: DtInitialize |
233 | * |
242 | * |
234 | * PARAMETERS: None |
243 | * PARAMETERS: None |
235 | * |
244 | * |
236 | * RETURN: None |
245 | * RETURN: Status |
237 | * |
246 | * |
238 | * DESCRIPTION: Initialize data table compiler globals. Enables multiple |
247 | * DESCRIPTION: Initialize data table compiler globals. Enables multiple |
239 | * compiles per invocation. |
248 | * compiles per invocation. |
240 | * |
249 | * |
241 | *****************************************************************************/ |
250 | *****************************************************************************/ |
Line 242... | Line 251... | ||
242 | 251 | ||
243 | static void |
252 | static ACPI_STATUS |
244 | DtInitialize ( |
253 | DtInitialize ( |
245 | void) |
254 | void) |
- | 255 | { |
|
- | 256 | ACPI_STATUS Status; |
|
- | 257 | ||
- | 258 | ||
- | 259 | Status = AcpiOsInitialize (); |
|
- | 260 | if (ACPI_FAILURE (Status)) |
|
- | 261 | { |
|
- | 262 | return (Status); |
|
- | 263 | } |
|
- | 264 | ||
- | 265 | Status = AcpiUtInitGlobals (); |
|
- | 266 | if (ACPI_FAILURE (Status)) |
|
- | 267 | { |
|
- | 268 | return (Status); |
|
Line 246... | Line 269... | ||
246 | { |
269 | } |
247 | 270 | ||
248 | Gbl_FieldList = NULL; |
271 | Gbl_FieldList = NULL; |
Line 249... | Line 272... | ||
249 | Gbl_RootTable = NULL; |
272 | Gbl_RootTable = NULL; |
- | 273 | Gbl_SubtableStack = NULL; |
|
250 | Gbl_SubtableStack = NULL; |
274 | |
Line 251... | Line 275... | ||
251 | 275 | sprintf (VersionString, "%X", (UINT32) ACPI_CA_VERSION); |
|
252 | sprintf (VersionString, "%X", (UINT32) ACPI_CA_VERSION); |
276 | return (AE_OK); |
Line 289... | Line 313... | ||
289 | for (i = 0; i < 7; i++) |
313 | for (i = 0; i < 7; i++) |
290 | { |
314 | { |
291 | Next = Next->Next; |
315 | Next = Next->Next; |
292 | } |
316 | } |
Line 293... | Line 317... | ||
293 | 317 | ||
294 | Next->Value = CompilerCreatorId; |
318 | Next->Value = ASL_CREATOR_ID; |
Line 295... | Line 319... | ||
295 | Next->Flags = DT_FIELD_NOT_ALLOCATED; |
319 | Next->Flags = DT_FIELD_NOT_ALLOCATED; |
296 | 320 | ||
297 | Next = Next->Next; |
321 | Next = Next->Next; |
Line 323... | Line 347... | ||
323 | ACPI_STATUS Status; |
347 | ACPI_STATUS Status; |
Line 324... | Line 348... | ||
324 | 348 | ||
Line 325... | Line 349... | ||
325 | 349 | ||
326 | /* Verify that we at least have a table signature and save it */ |
350 | /* Verify that we at least have a table signature and save it */ |
327 | 351 | ||
- | 352 | Signature = DtGetFieldValue (*FieldList); |
|
328 | Signature = DtGetFieldValue (*FieldList, "Signature"); |
353 | if (!Signature) |
- | 354 | { |
|
329 | if (!Signature) |
355 | sprintf (MsgBuffer, "Expected \"%s\"", "Signature"); |
330 | { |
356 | DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME, |
Line 331... | Line 357... | ||
331 | DtError (ASL_ERROR, ASL_MSG_TABLE_SIGNATURE, *FieldList, NULL); |
357 | *FieldList, MsgBuffer); |
332 | return (AE_ERROR); |
358 | return (AE_ERROR); |
Line 354... | Line 380... | ||
354 | else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_RSDP)) |
380 | else if (ACPI_COMPARE_NAME (Signature, ACPI_SIG_RSDP)) |
355 | { |
381 | { |
356 | Status = DtCompileRsdp (FieldList); |
382 | Status = DtCompileRsdp (FieldList); |
357 | return (Status); |
383 | return (Status); |
358 | } |
384 | } |
359 | else if (!ACPI_STRNCMP (Signature, "OEM", 3)) |
- | |
360 | { |
- | |
361 | DtFatal (ASL_MSG_OEM_TABLE, *FieldList, Signature); |
- | |
362 | return (AE_ERROR); |
- | |
363 | } |
- | |
Line 364... | Line 385... | ||
364 | 385 | ||
365 | /* |
386 | /* |
366 | * All other tables must use the common ACPI table header. Insert the |
387 | * All other tables must use the common ACPI table header. Insert the |
367 | * current iASL IDs (name, version), and compile the header now. |
388 | * current iASL IDs (name, version), and compile the header now. |
Line 375... | Line 396... | ||
375 | return (Status); |
396 | return (Status); |
376 | } |
397 | } |
Line 377... | Line 398... | ||
377 | 398 | ||
Line 378... | Line 399... | ||
378 | DtPushSubtable (Gbl_RootTable); |
399 | DtPushSubtable (Gbl_RootTable); |
Line 379... | Line 400... | ||
379 | 400 | ||
380 | /* Match signature and dispatch appropriately */ |
401 | /* Validate the signature via the ACPI table list */ |
381 | 402 | ||
382 | TableData = AcpiDmGetTableData (Signature); |
403 | TableData = AcpiDmGetTableData (Signature); |
383 | if (!TableData) |
404 | if (!TableData) |
384 | { |
405 | { |
Line -... | Line 406... | ||
- | 406 | DtCompileGeneric ((void **) FieldList); |
|
- | 407 | goto Out; |
|
385 | DtFatal (ASL_MSG_UNKNOWN_TABLE, *FieldList, Signature); |
408 | } |
386 | return (AE_ERROR); |
409 | |
387 | } |
410 | /* Dispatch to per-table compile */ |
Line 388... | Line 411... | ||
388 | 411 | ||
Line 416... | Line 439... | ||
416 | DtFatal (ASL_MSG_COMPILER_INTERNAL, *FieldList, |
439 | DtFatal (ASL_MSG_COMPILER_INTERNAL, *FieldList, |
417 | "Missing table dispatch info"); |
440 | "Missing table dispatch info"); |
418 | return (AE_ERROR); |
441 | return (AE_ERROR); |
419 | } |
442 | } |
Line -... | Line 443... | ||
- | 443 | ||
420 | 444 | Out: |
|
Line 421... | Line 445... | ||
421 | /* Set the final table length and then the checksum */ |
445 | /* Set the final table length and then the checksum */ |
422 | 446 | ||
423 | DtSetTableLength (); |
447 | DtSetTableLength (); |
Line 457... | Line 481... | ||
457 | DT_SUBTABLE *InlineSubtable; |
481 | DT_SUBTABLE *InlineSubtable; |
458 | UINT32 FieldLength = 0; |
482 | UINT32 FieldLength = 0; |
459 | UINT8 FieldType; |
483 | UINT8 FieldType; |
460 | UINT8 *Buffer; |
484 | UINT8 *Buffer; |
461 | UINT8 *FlagBuffer = NULL; |
485 | UINT8 *FlagBuffer = NULL; |
462 | UINT32 FlagBitPosition = 0; |
- | |
463 | ACPI_STATUS Status; |
486 | ACPI_STATUS Status; |
Line 464... | Line 487... | ||
464 | 487 | ||
465 | 488 | ||
466 | if (!Field || !*Field) |
489 | if (!Field || !*Field) |
467 | { |
490 | { |
Line 468... | Line 491... | ||
468 | return (AE_BAD_PARAMETER); |
491 | return (AE_BAD_PARAMETER); |
- | 492 | } |
|
- | 493 | ||
- | 494 | Length = DtGetSubtableLength (*Field, Info); |
|
- | 495 | if (Length == ASL_EOF) |
|
- | 496 | { |
|
469 | } |
497 | return (AE_ERROR); |
Line -... | Line 498... | ||
- | 498 | } |
|
- | 499 | ||
470 | 500 | Subtable = UtLocalCalloc (sizeof (DT_SUBTABLE)); |
|
- | 501 | ||
471 | Length = DtGetSubtableLength (*Field, Info); |
502 | if (Length > 0) |
472 | Subtable = UtLocalCalloc (sizeof (DT_SUBTABLE)); |
503 | { |
473 | 504 | Subtable->Buffer = UtLocalCalloc (Length); |
|
Line 474... | Line 505... | ||
474 | Subtable->Buffer = UtLocalCalloc (Length); |
505 | } |
Line 490... | Line 521... | ||
490 | DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, MsgBuffer); |
521 | DtFatal (ASL_MSG_COMPILER_INTERNAL, NULL, MsgBuffer); |
491 | Status = AE_BAD_DATA; |
522 | Status = AE_BAD_DATA; |
492 | goto Error; |
523 | goto Error; |
493 | } |
524 | } |
Line 494... | Line 525... | ||
494 | 525 | ||
495 | /* Does input field name match what is expected? */ |
- | |
496 | - | ||
497 | if (ACPI_STRCMP (LocalField->Name, Info->Name)) |
- | |
498 | { |
- | |
499 | /* |
- | |
500 | * If Required = TRUE, the subtable must exist. |
- | |
501 | * If Required = FALSE, the subtable is optional |
- | |
502 | * (For example, AcpiDmTableInfoDmarScope in DMAR table is |
- | |
503 | * optional) |
- | |
504 | */ |
- | |
505 | if (Required) |
- | |
506 | { |
- | |
507 | sprintf (MsgBuffer, "Expected \"%s\"", Info->Name); |
- | |
508 | DtNameError (ASL_ERROR, ASL_MSG_INVALID_FIELD_NAME, |
- | |
509 | LocalField, MsgBuffer); |
- | |
510 | } |
- | |
511 | else |
- | |
512 | { |
- | |
513 | Status = AE_NOT_FOUND; |
- | |
514 | goto Error; |
- | |
515 | } |
- | |
Line -... | Line 526... | ||
- | 526 | /* Maintain table offsets */ |
|
516 | } |
527 | |
- | 528 | LocalField->TableOffset = Gbl_CurrentTableOffset; |
|
- | 529 | FieldLength = DtGetFieldLength (LocalField, Info); |
|
517 | 530 | Gbl_CurrentTableOffset += FieldLength; |
|
518 | FieldLength = DtGetFieldLength (LocalField, Info); |
531 | |
Line 519... | Line 532... | ||
519 | FieldType = DtGetFieldType (Info); |
532 | FieldType = DtGetFieldType (Info); |
520 | Gbl_InputFieldCount++; |
533 | Gbl_InputFieldCount++; |
Line 528... | Line 541... | ||
528 | * to compile and insert the flag fields from the individual bits |
541 | * to compile and insert the flag fields from the individual bits |
529 | */ |
542 | */ |
530 | LocalField = LocalField->Next; |
543 | LocalField = LocalField->Next; |
531 | *Field = LocalField; |
544 | *Field = LocalField; |
Line 532... | Line -... | ||
532 | - | ||
533 | FlagBitPosition = 0; |
545 | |
534 | FlagBuffer = Buffer; |
546 | FlagBuffer = Buffer; |
Line 535... | Line 547... | ||
535 | break; |
547 | break; |
Line 536... | Line 548... | ||
536 | 548 | ||
Line 537... | Line 549... | ||
537 | case DT_FIELD_TYPE_FLAG: |
549 | case DT_FIELD_TYPE_FLAG: |
538 | 550 | ||
539 | /* Individual Flag field, can be multiple bits */ |
551 | /* Individual Flag field, can be multiple bits */ |
540 | - | ||
541 | if (FlagBuffer) |
552 | |
542 | { |
553 | if (FlagBuffer) |
543 | FlagBitPosition = DtCompileFlag (FlagBuffer, |
554 | { |
544 | LocalField, Info, FlagBitPosition); |
555 | DtCompileFlag (FlagBuffer, LocalField, Info); |
545 | } |
556 | } |
Line 555... | Line 566... | ||
555 | case DT_FIELD_TYPE_INLINE_SUBTABLE: |
566 | case DT_FIELD_TYPE_INLINE_SUBTABLE: |
556 | /* |
567 | /* |
557 | * Recursion (one level max): compile GAS (Generic Address) |
568 | * Recursion (one level max): compile GAS (Generic Address) |
558 | * or Notify in-line subtable |
569 | * or Notify in-line subtable |
559 | */ |
570 | */ |
560 | LocalField = LocalField->Next; |
- | |
561 | *Field = LocalField; |
571 | *Field = LocalField; |
Line 562... | Line 572... | ||
562 | 572 | ||
563 | if (Info->Opcode == ACPI_DMT_GAS) |
573 | if (Info->Opcode == ACPI_DMT_GAS) |
564 | { |
574 | { |
Line 574... | Line 584... | ||
574 | if (ACPI_FAILURE (Status)) |
584 | if (ACPI_FAILURE (Status)) |
575 | { |
585 | { |
576 | goto Error; |
586 | goto Error; |
577 | } |
587 | } |
Line -... | Line 588... | ||
- | 588 | ||
- | 589 | DtSetSubtableLength (InlineSubtable); |
|
578 | 590 | ||
579 | ACPI_MEMCPY (Buffer, InlineSubtable->Buffer, FieldLength); |
591 | ACPI_MEMCPY (Buffer, InlineSubtable->Buffer, FieldLength); |
580 | ACPI_FREE (InlineSubtable->Buffer); |
592 | ACPI_FREE (InlineSubtable->Buffer); |
581 | ACPI_FREE (InlineSubtable); |
593 | ACPI_FREE (InlineSubtable); |
582 | LocalField = *Field; |
594 | LocalField = *Field; |
Line -... | Line 595... | ||
- | 595 | break; |
|
- | 596 | ||
- | 597 | case DT_FIELD_TYPE_LABEL: |
|
- | 598 | ||
- | 599 | DtWriteFieldToListing (Buffer, LocalField, 0); |
|
- | 600 | LocalField = LocalField->Next; |
|
583 | break; |
601 | break; |
Line 584... | Line 602... | ||
584 | 602 | ||
Line 585... | Line 603... | ||
585 | default: |
603 | default: |
586 | 604 | ||
- | 605 | /* Normal case for most field types (Integer, String, etc.) */ |
|
- | 606 | ||
587 | /* Normal case for most field types (Integer, String, etc.) */ |
607 | DtCompileOneField (Buffer, LocalField, |
Line 588... | Line 608... | ||
588 | 608 | FieldLength, FieldType, Info->Flags); |
|
589 | DtCompileOneField (Buffer, LocalField, |
609 | |
590 | FieldLength, FieldType, Info->Flags); |
610 | DtWriteFieldToListing (Buffer, LocalField, FieldLength); |
Line 591... | Line 611... | ||
591 | LocalField = LocalField->Next; |
611 | LocalField = LocalField->Next; |
592 | 612 | ||
593 | if (Info->Flags & DT_LENGTH) |
613 | if (Info->Flags & DT_LENGTH) |
- | 614 | { |
|
594 | { |
615 | /* Field is an Integer that will contain a subtable length */ |
595 | /* Field is an Integer that will contain a subtable length */ |
616 | |
Line 596... | Line 617... | ||
596 | 617 | Subtable->LengthField = Buffer; |
|
597 | Subtable->LengthField = Buffer; |
618 | Subtable->SizeOfLengthField = FieldLength; |