1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982
|
/** @file
HEST table parser
Copyright (c) 2024, Arm Limited.
SPDX-License-Identifier: BSD-2-Clause-Patent
@par Specification Reference:
- ACPI 6.5, Table 18.3.2 ACPI Error Source
**/
#include <IndustryStandard/Acpi.h>
#include <Library/UefiLib.h>
#include "AcpiParser.h"
#include "AcpiTableParser.h"
#include "AcpiView.h"
STATIC ACPI_DESCRIPTION_HEADER_INFO mAcpiHdrInfo;
STATIC UINT32 *mHestErrorSourceCount;
STATIC UINT16 *mHestErrorSourceType;
STATIC UINT8 *mHestIA32HardwareBankCount;
/**
An String array for Error Notification Structure's type.
Cf ACPI 6.5 Table 18.14: Hardware Error Notification Structure
**/
STATIC CONST CHAR16 *HestErrorNotificationStructureTypeStr[] = {
L"Polled",
L"External Interrupt",
L"Local Interrupt",
L"SCI",
L"NMI",
L"CMCI",
L"MCE",
L"GPIO-Signal",
L"ARMv8 SEA",
L"ARMv8 SEI",
L"External Interrupt - GSIV",
L"Software Delegated Exception",
};
/**
An ACPI_PARSER array describing the ACPI HEST Table.
**/
STATIC CONST ACPI_PARSER HestParser[] = {
PARSE_ACPI_HEADER (&mAcpiHdrInfo),
{ L"Error Source Count", 4, 36, L"%d", NULL,
(VOID **)&mHestErrorSourceCount,NULL, NULL },
// Error Source Descriptor 1
// Error Source Descriptor Type
// Error Source Descriptor Data
// ...
// Error Source Descriptor 2
// Error Source Descriptor Type
// Error Source Descriptor Data
// ...
// ....
// Error Source Descriptor n
// Error Source Descriptor Type
// Error Source Descriptor Data
// ...
};
/**
An ACPI_PARSER array describing the HEST error source descriptor type.
**/
STATIC CONST ACPI_PARSER HestErrorSourceTypeParser[] = {
{ L"Type", 2, 0, L"%d", NULL, (VOID **)&mHestErrorSourceType, NULL, NULL },
};
/**
An ACPI_PARSER array describing the HEST error source flags information.
**/
STATIC CONST ACPI_PARSER HestErrorSourceFlags[] = {
{ L"Type", 1, 0, L"%d", NULL, NULL, NULL, NULL },
{ L"Global", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"GHES Assist", 1, 2, L"%d", NULL, NULL, NULL, NULL },
{ L"Reserved", 5, 3, NULL, NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing IA-32 Architecture Machine Check Bank Structure
Cf ACPI 6.5 Table 18.4: IA-32 Architecture Machine Check Error Bank Structure
**/
STATIC CONST ACPI_PARSER HestErrorIA32ArchMachineCheckBankStructureParser[] = {
{ L"Bank Number", 1, 0, L"%d", NULL, NULL, NULL, NULL },
{ L"Clear Status On Initialization", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"Status Data Format", 1, 2, L"%d", NULL, NULL, NULL, NULL },
{ L"Reserved", 1, 3, NULL, NULL, NULL, NULL, NULL },
{ L"Control Register MSR Address", 4, 4, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"Control Init Data", 8, 8, L"0x%llx", NULL, NULL, NULL, NULL },
{ L"Status Register MSR Address", 4, 16, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"Address Register MSR Address", 4, 20, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"Misc Register MSR Address", 4, 24, L"0x%lx", NULL, NULL, NULL, NULL },
};
/**
An ACPI_PARSER array describing the Hardware Error Notification Structure's
Configuration Write Enable Field (CWE)
Cf ACPI 6.5 Table 18.14: Hardware Error Notification Structure
**/
STATIC CONST ACPI_PARSER HestErrorNotificationCweParser[] = {
{ L"Type", 1, 0, L"%d", NULL, NULL, NULL, NULL },
{ L"Poll Interval", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"Switch To Polling Threshold Value", 1, 2, L"%d", NULL, NULL, NULL, NULL },
{ L"Switch To Polling Threshold Window", 1, 3, L"%d", NULL, NULL, NULL, NULL },
{ L"Error Threshold Value", 1, 4, L"%d", NULL, NULL, NULL, NULL },
{ L"Error Threshold Window", 1, 5, L"%d", NULL, NULL, NULL, NULL },
{ L"Reserved", 10, 6, L"0x%x", NULL, NULL, NULL, NULL },
};
/**
This function validates the Type field of Hardware Error Notification Structure
@param [in] Ptr Pointer to the start of the field data.
@param [in] Length Length of the field.
@param [in] Context Pointer to context specific information e.g. this
could be a pointer to the ACPI table header.
**/
STATIC
VOID
EFIAPI
ValidateErrorNotificationType (
IN UINT8 *Ptr,
IN UINT32 Length,
IN VOID *Context
)
{
UINT8 Type;
Type = *(UINT8 *)Ptr;
if (Type >
EFI_ACPI_6_5_HARDWARE_ERROR_NOTIFICATION_SOFTWARE_DELEGATED_EXCEPTION)
{
IncrementErrorCount ();
Print (
L"\nERROR: Notification Structure Type must be <= 0x%x.",
EFI_ACPI_6_5_HARDWARE_ERROR_NOTIFICATION_SOFTWARE_DELEGATED_EXCEPTION
);
}
}
/**
Dumps flags fields of error source descriptor.
@param [in] Format Optional format string for tracing the data.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] Length Length of the field.
**/
STATIC
VOID
EFIAPI
DumpSourceFlags (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr,
IN UINT32 Length
)
{
if (Format != NULL) {
Print (Format, *(UINT32 *)Ptr);
return;
}
Print (L"0x%x\n", *Ptr);
ParseAcpiBitFields (
TRUE,
2,
NULL,
Ptr,
1,
PARSER_PARAMS (HestErrorSourceFlags)
);
}
/**
Dumps type fields of Error Notification Structure
@param [in] Format Optional format string for tracing the data.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] Length Length of the field.
**/
STATIC
VOID
EFIAPI
DumpErrorNotificationType (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr,
IN UINT32 Length
)
{
if (Format != NULL) {
Print (Format, *Ptr);
return;
}
if (*Ptr <= EFI_ACPI_6_5_HARDWARE_ERROR_NOTIFICATION_SOFTWARE_DELEGATED_EXCEPTION) {
Print (L"%s(0x%x)", HestErrorNotificationStructureTypeStr[*Ptr]);
} else {
Print (L"UNKNOWN(0x%x)", HestErrorNotificationStructureTypeStr[*Ptr]);
}
}
/**
Dumps Configuration Write Enable fields of Hardware Error Notification Structure.
@param [in] Format Optional format string for tracing the data.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] Length Length of the field.
**/
STATIC
VOID
EFIAPI
DumpErrorNotificationCwe (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr,
IN UINT32 Length
)
{
if (Format != NULL) {
Print (Format, *(UINT32 *)Ptr);
return;
}
Print (L"0x%x\n", *Ptr);
ParseAcpiBitFields (
TRUE,
2,
NULL,
Ptr,
1,
PARSER_PARAMS (HestErrorNotificationCweParser)
);
}
/**
An ACPI_PARSER array describing the Hardware Error Notification Structure
Cf ACPI 6.5 Table 18.14: Hardware Error Notification Structure
**/
STATIC CONST ACPI_PARSER HestErrorNotificationParser[] = {
{ L"Type", 1, 0, NULL, DumpErrorNotificationType, NULL, ValidateErrorNotificationType, NULL },
{ L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"Configuration Write Enable", 2, 2, NULL, DumpErrorNotificationCwe, NULL, NULL, NULL },
{ L"Pull Interval", 4, 4, L"%d ms", NULL, NULL, NULL, NULL },
{ L"Vector", 4, 8, L"%d", NULL, NULL, NULL, NULL },
{ L"Switch To Polling Threshold Value", 4, 12, L"%d", NULL, NULL, NULL, NULL },
{ L"Switch To Polling Threshold Window", 4, 16, L"%d ms", NULL, NULL, NULL, NULL },
{ L"Error Threshold Value", 4, 20, L"%d", NULL, NULL, NULL, NULL },
{ L"Error Threshold Window", 4, 24, L"%d ms", NULL, NULL, NULL, NULL },
};
/**
This function validates reserved bits of
pci related Error source structure's bus field.
@param [in] Ptr Pointer to the start of the field data.
@param [in] Length Length of the field.
@param [in] Context Pointer to context specific information e.g. this
could be a pointer to the ACPI table header.
**/
STATIC
VOID
EFIAPI
ValidatePciBusReservedBits (
IN UINT8 *Ptr,
IN UINT32 Length,
IN VOID *Context
)
{
if (*Ptr != 0x00) {
IncrementErrorCount ();
Print (L"\nERROR: bits[31:24] should must be zero...");
}
}
/**
An ACPI_PARSER array describing the PCI related Error Source Bus field.
**/
STATIC CONST ACPI_PARSER HestErrorSourcePciCommonBusParser[] = {
{ L"Bus", 8, 0, L"%d", NULL, NULL, NULL, NULL },
{ L"Segment Number", 16, 8, L"%d", NULL, NULL, NULL, NULL },
{ L"Reserved", 8, 24, L"0x%x", NULL, NULL, ValidatePciBusReservedBits, NULL },
};
/**
This function validates the flags field of IA32 related
error source descriptor structure.
@param [in] Ptr Pointer to the start of the field data.
@param [in] Length Length of the field.
@param [in] Context Pointer to context specific information e.g. this
could be a pointer to the ACPI table header.
**/
STATIC
VOID
EFIAPI
ValidateIA32ErrorSourceFlags (
IN UINT8 *Ptr,
IN UINT32 Length,
IN VOID *Context
)
{
UINT8 SourceFlags;
SourceFlags = *(UINT8 *)Ptr;
if ((SourceFlags &
~(EFI_ACPI_6_5_ERROR_SOURCE_FLAG_FIRMWARE_FIRST |
EFI_ACPI_6_5_ERROR_SOURCE_FLAG_GHES_ASSIST)) != 0)
{
IncrementErrorCount ();
Print (L"\nERROR: Invalid IA32 source flags field value...");
}
if (((SourceFlags & EFI_ACPI_6_5_ERROR_SOURCE_FLAG_FIRMWARE_FIRST) != 0) &&
((SourceFlags & EFI_ACPI_6_5_ERROR_SOURCE_FLAG_GHES_ASSIST) != 0))
{
IncrementErrorCount ();
Print (L"\nERROR: GHES_ASSIST should be reserved if FIRMWARE_FIRST is set...");
}
}
/**
This function validates the flags field of PCI related
error source descriptor structure.
@param [in] Ptr Pointer to the start of the field data.
@param [in] Length Length of the field.
@param [in] Context Pointer to context specific information e.g. this
could be a pointer to the ACPI table header.
**/
STATIC
VOID
EFIAPI
ValidatePciErrorSourceFlags (
IN UINT8 *Ptr,
IN UINT32 Length,
IN VOID *Context
)
{
UINT8 SourceFlags;
SourceFlags = *(UINT8 *)Ptr;
if ((SourceFlags &
~(EFI_ACPI_6_5_ERROR_SOURCE_FLAG_FIRMWARE_FIRST |
EFI_ACPI_6_5_ERROR_SOURCE_FLAG_GLOBAL)) != 0)
{
IncrementErrorCount ();
Print (L"\nERROR: Invalid PCI source flags field value...");
}
}
/**
This function validates the flags field of Ghes related
error source descriptor structure.
@param [in] Ptr Pointer to the start of the field data.
@param [in] Length Length of the field.
@param [in] Context Pointer to context specific information e.g. this
could be a pointer to the ACPI table header.
**/
STATIC
VOID
EFIAPI
ValidateGhesSourceFlags (
IN UINT8 *Ptr,
IN UINT32 Length,
IN VOID *Context
)
{
UINT8 SourceFlags;
SourceFlags = *(UINT8 *)Ptr;
if (SourceFlags != 0) {
IncrementErrorCount ();
Print (L"\nERROR: Ghes'source flags should be reserved...");
}
}
/**
This function validates the enabled field of error source descriptor
structure.
@param [in] Ptr Pointer to the start of the field data.
@param [in] Length Length of the field.
@param [in] Context Pointer to context specific information e.g. this
could be a pointer to the ACPI table header.
**/
STATIC
VOID
EFIAPI
ValidateEnabledField (
IN UINT8 *Ptr,
IN UINT32 Length,
IN VOID *Context
)
{
if (*(UINT8 *)Ptr > 1) {
IncrementErrorCount ();
Print (L"\nERROR: Invalid Enabled field value must be either 0 or 1.");
}
}
/**
This function validates the number of records to preallocated and
max sections per record fields of error source descriptor
structure.
@param [in] Ptr Pointer to the start of the field data.
@param [in] Length Length of the field.
@param [in] Context Pointer to context specific information e.g. this
could be a pointer to the ACPI table header.
**/
STATIC
VOID
EFIAPI
ValidateRecordCount (
IN UINT8 *Ptr,
IN UINT32 Length,
IN VOID *Context
)
{
UINT8 RecordCount;
BOOLEAN CheckRecordCount;
RecordCount = *Ptr;
CheckRecordCount = ((BOOLEAN)(UINTN)Context);
if ((CheckRecordCount) && (RecordCount == 0)) {
IncrementErrorCount ();
Print (L"\nERROR: Record count must be >= 1...");
}
}
/**
Dumps the notification structure fields.
@param [in] Format Optional format string for tracing the data.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] Length Length of the field.
**/
STATIC
VOID
EFIAPI
DumpNotificationStructure (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr,
IN UINT32 Length
)
{
UINT32 Offset;
UINT32 Size;
Size = sizeof (EFI_ACPI_6_5_HARDWARE_ERROR_NOTIFICATION_STRUCTURE);
Print (L"\n");
Offset = ParseAcpi (
TRUE,
2,
NULL,
Ptr,
Size,
PARSER_PARAMS (HestErrorNotificationParser)
);
if (Offset != Size) {
IncrementErrorCount ();
Print (L"ERROR: Failed to parse Hardware Error Notification Structure!\n");
}
}
/**
Dumps bus field in the PCI related Error Source Structure.
from HestTable.
@param [in] Format Optional format string for tracing the data.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] Length Length of the field.
**/
STATIC
VOID
EFIAPI
DumpPciBus (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr,
IN UINT32 Length
)
{
if (Format != NULL) {
Print (Format, *(UINT32 *)Ptr);
return;
}
Print (L"0x%x\n", *Ptr);
ParseAcpiBitFields (
TRUE,
2,
NULL,
Ptr,
1,
PARSER_PARAMS (HestErrorSourcePciCommonBusParser)
);
}
/**
Dumps the IA32 Arch Machine Check Error Bank structure fields.
@param [in] HestTable Start pointer to Hest table.
@param [in] AcpiTableLength Length of HestTable.
@param [in,out] Offset Offset to machine check bank structure
from HestTable.
@retval EFI_SUCCESS Success
@retval EFI_INVALID_PARAMETER Invalid Hest Table
**/
STATIC
EFI_STATUS
EFIAPI
DumpIA32ArchMachineCheckErrorBankStructure (
IN UINT8 *HestTable,
UINT32 AcpiTableLength,
UINT32 *Offset
)
{
UINT8 Idx;
UINT8 *IA32BankStructPtr;
UINT32 TotalBankStructSize;
TotalBankStructSize = *mHestIA32HardwareBankCount *
sizeof (EFI_ACPI_6_5_IA32_ARCHITECTURE_MACHINE_CHECK_ERROR_BANK_STRUCTURE);
if ((*Offset + TotalBankStructSize) > AcpiTableLength) {
IncrementErrorCount ();
Print (
L"ERROR: Not enough data for "
"IA-32 Architecture Machine Check Exception Error source.\n"
);
return EFI_INVALID_PARAMETER;
}
for (Idx = 0; Idx < *mHestIA32HardwareBankCount; Idx++) {
IA32BankStructPtr = HestTable + *Offset;
ParseAcpi (
TRUE,
4,
"IA-32 Architecture Machine Check Bank Structure",
IA32BankStructPtr,
sizeof (EFI_ACPI_6_5_IA32_ARCHITECTURE_MACHINE_CHECK_ERROR_BANK_STRUCTURE),
PARSER_PARAMS (HestErrorIA32ArchMachineCheckBankStructureParser)
);
*Offset +=
sizeof (EFI_ACPI_6_5_IA32_ARCHITECTURE_MACHINE_CHECK_ERROR_BANK_STRUCTURE);
}
*mHestIA32HardwareBankCount = 0;
return EFI_SUCCESS;
}
/**
Helper macro to populate the header fields of error source descriptor in the
ACPI_PARSER array.
**/
#define PARSE_HEST_ERROR_SOURCE_COMMON_HEADER(FlagsValidateFunc, CheckRecordCount) \
{ L"Type", 2, 0, L"%d", NULL, NULL, NULL, NULL }, \
{ L"Source Id", 2, 2, L"%d", NULL, NULL, NULL, NULL }, \
{ L"Reserved", 2, 4, NULL, NULL, NULL, NULL, NULL }, \
{ L"Flags", 1, 6, NULL, DumpSourceFlags, NULL, \
FlagsValidateFunc, NULL }, \
{ L"Enabled", 1, 7, L"%d", NULL, NULL, ValidateEnabledField, NULL }, \
{ L"Number of Records to Pre-allocate", 4, 8, L"%d", NULL, NULL, \
ValidateRecordCount, (VOID *) ((UINTN) CheckRecordCount) }, \
{ L"Max Sections Per Record", 4, 12, L"%d", NULL, NULL, \
ValidateRecordCount, (VOID *) ((UINTN) CheckRecordCount) }
/**
Helper macro to populate the header fields of PCI related
error source descriptor in the ACPI_PARSER array.
**/
#define PARSE_HEST_PCI_ERROR_SOURCE_COMMON_HEADER() \
PARSE_HEST_ERROR_SOURCE_COMMON_HEADER(ValidatePciErrorSourceFlags, TRUE), \
{ L"Bus", 4, 16, NULL, DumpPciBus, NULL, NULL, NULL }, \
{ L"Device", 2, 20, L"%d", NULL, NULL, NULL, NULL }, \
{ L"Function", 2, 22, L"%d", NULL, NULL, NULL, NULL }, \
{ L"Device Control", 2, 24, L"%d", NULL, NULL, NULL, NULL }, \
{ L"Reserved", 2, 26, NULL, NULL, NULL, NULL, NULL }, \
{ L"Uncorrectable Error Mask", 4, 28, L"0x%lx", NULL, NULL, NULL, NULL }, \
{ L"Uncorrectable Error Severity", 4, 32, L"%d", NULL, NULL, NULL, NULL }, \
{ L"Correctable Error Mask", 4, 36, L"0x%lx", NULL, NULL, NULL, NULL }, \
{ L"Advanced Error Capabilities and Control", 4, 40, L"%d", NULL, NULL, \
NULL, NULL }
/**
Helper macro to populate the header fields of GHES related
error source descriptor in the ACPI_PARSER array.
**/
#define PARSE_HEST_GHES_ERROR_SOURCE() \
{ L"Type", 2, 0, L"%d", NULL, NULL, NULL, NULL }, \
{ L"Source Id", 2, 2, L"%d", NULL, NULL, NULL, NULL }, \
{ L"Related Source Id", 2, 4, L"0x%x", NULL, NULL, NULL, NULL }, \
{ L"Flags", 1, 6, L"0x%x", NULL, NULL, ValidateGhesSourceFlags, NULL }, \
{ L"Enabled", 1, 7, L"%d", NULL, NULL, ValidateEnabledField, NULL }, \
{ L"Number of Records to Pre-allocate", 4, 8, L"%d", NULL, NULL, \
ValidateRecordCount, (VOID *) ((UINTN) TRUE) }, \
{ L"Max Sections Per Record", 4, 12, L"%d", NULL, NULL, \
ValidateRecordCount, (VOID *) ((UINTN) TRUE) }, \
{ L"Max Raw Data Length", 4, 16, L"%d", NULL, NULL, NULL, NULL }, \
{ L"Error Status Address", 12, 20, NULL, DumpGas, NULL, NULL, NULL }, \
{ L"Notification Structure", 28, 32, NULL, DumpNotificationStructure, \
NULL, NULL, NULL }, \
{ L"Error Status Block Length", 4, 60, L"%d", NULL, NULL, NULL, NULL }
/**
An ACPI_PARSER array describing the IA-32 Architecture Machine Check Exception
error source descriptor.
Cf ACPI 6.5 Table 18.3: IA-32 Architecture Machine Check Exception Structure
**/
STATIC CONST ACPI_PARSER HestErrorSourceIA32ArchMachineCheckExceptionParser[] = {
PARSE_HEST_ERROR_SOURCE_COMMON_HEADER (ValidateIA32ErrorSourceFlags, FALSE),
{ L"Global Capability Init Data",
8, 16, L"0x%llx", NULL, NULL, NULL, NULL },
{ L"Global Control Init Data",
8, 24, L"0x%llx", NULL, NULL, NULL, NULL },
{ L"Number of Hardware Banks",
1, 32, L"%d", NULL, (VOID **)&mHestIA32HardwareBankCount, NULL, NULL },
{ L"Reserved",
7, 33, NULL, NULL, NULL, NULL, NULL },
/// HestErrorIA32ArchMachineCheckBankStructureParser
/// ...
};
/**
An ACPI_PARSER array describing the IA-32 Architecture Machine Check Exception
error source descriptor.
Cf ACPI 6.5 Table 18.5: IA-32 Architecture Machine Check Exception Structure
**/
STATIC CONST ACPI_PARSER HestErrorSourceIA32ArchCorrectedMachineCheckParser[] = {
PARSE_HEST_ERROR_SOURCE_COMMON_HEADER (ValidateIA32ErrorSourceFlags, TRUE),
{ L"Notification Structure",
28, 16, NULL, DumpNotificationStructure, NULL, NULL, NULL },
{ L"Number of Hardware Banks",
1, 44, L"%d", NULL, (VOID **)&mHestIA32HardwareBankCount, NULL, NULL },
{ L"Reserved",
3, 45, NULL, NULL, NULL, NULL, NULL },
/// HestErrorIA32ArchMachineCheckBankStructureParser
/// ...
};
/**
An ACPI_PARSER array describing the IA-32 Non-Maskable Interrupt
error source descriptor.
Cf ACPI 6.5 Table 18.6: IA-32 Architecture NMI Error Structure
**/
STATIC CONST ACPI_PARSER HestErrorSourceIA32ArchNonMaskableInterruptParser[] = {
{ L"Type", 2, 0, L"%d", NULL, NULL, NULL, NULL },
{ L"Source Id", 2, 2, L"%d", NULL, NULL, NULL, NULL },
{ L"Reserved", 4, 4, NULL, NULL, NULL, NULL, NULL },
{ L"Number of Records to Pre-allocate", 4, 8, L"%d", NULL, NULL,
ValidateRecordCount, (VOID *)((UINTN)TRUE) },
{ L"Max Sections Per Record", 4, 12, L"%d", NULL, NULL,
ValidateRecordCount, (VOID *)((UINTN)TRUE) },
{ L"Max Raw Data Length", 4, 16, L"%d", NULL, NULL, NULL, NULL },
};
/**
An ACPI_PARSER array describing the HEST PCIe Root Port AER
error source descriptor.
Cf ACPI 6.5 Table 18.7: PCI Express Root Port AER Structure
**/
STATIC CONST ACPI_PARSER HestErrorSourcePciExpressRootPortAerParser[] = {
PARSE_HEST_PCI_ERROR_SOURCE_COMMON_HEADER (),
{ L"Root Error Command",
4, 44,L"%d", NULL, NULL, NULL, NULL },
};
/**
An ACPI_PARSER array describing the HEST PCIe Device AER
error source descriptor.
Cf ACPI 6.5 Table 18.8: PCI Express Device AER Structure
**/
STATIC CONST ACPI_PARSER HestErrorSourcePciExpressDeviceAerParser[] = {
PARSE_HEST_PCI_ERROR_SOURCE_COMMON_HEADER (),
};
/**
An ACPI_PARSER array describing the HEST PCIe/PCI-X Bridge AER
error source descriptor.
Cf ACPI 6.5 Table 18.9: PCI Express/PCI-X Bridge AER Structure
**/
STATIC CONST ACPI_PARSER HestErrorSourcePciExpressBridgeAerParser[] = {
PARSE_HEST_PCI_ERROR_SOURCE_COMMON_HEADER (),
{ L"Secondary Uncorrectable Error Mask",
4, 44, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"Secondary Uncorrectable Error Severity",
4, 48, L"%d", NULL, NULL, NULL, NULL },
{ L"Secondary Advanced Error Capabilities and Control",
4, 52, L"%d", NULL, NULL, NULL, NULL },
};
/**
An ACPI_PARSER array describing the HEST GHES error source descriptor.
Cf ACPI 6.5 Table 18.10: Generic Hardware Error Source Structure
**/
STATIC CONST ACPI_PARSER HestErrorSourceGhesParser[] = {
PARSE_HEST_GHES_ERROR_SOURCE (),
};
/**
An ACPI_PARSER array describing the HEST GHESv2 error source descriptor.
Cf ACPI 6.5 Table 18.11: Generic Hardware Error Source version 2 Structure
**/
STATIC CONST ACPI_PARSER HestErrorSourceGhesv2Parser[] = {
PARSE_HEST_GHES_ERROR_SOURCE (),
{ L"Read Ack Register", 12, 64, NULL, DumpGas, NULL, NULL, NULL },
{ L"Read Ack Preserve", 8, 76, L"%llx", NULL, NULL, NULL, NULL },
{ L"Read Ack Write", 8, 84, L"%llx", NULL, NULL, NULL, NULL },
};
/**
An ACPI_PARSER array describing the IA-32 Architecture Deferred Machine Check
error source descriptor.
Cf ACPI 6.5 Table 18.15: IA-32 Architecture Deferred Machine Check Structure
**/
STATIC CONST ACPI_PARSER HestErrorSourceIA32ArchDeferredMachineCheckParser[] = {
PARSE_HEST_ERROR_SOURCE_COMMON_HEADER (ValidateIA32ErrorSourceFlags, TRUE),
{ L"Notification Structure", 28, 16, NULL, DumpNotificationStructure,
NULL, NULL, NULL },
{ L"Number of Hardware Banks", 1, 44, L"%d", NULL,
(VOID **)&mHestIA32HardwareBankCount, NULL, NULL },
{ L"Reserved", 3, 45, NULL, NULL, NULL,NULL, NULL },
/// HestErrorIA32ArchMachineCheckBankStructureParser
/// ...
};
/**
This function parses the ACPI HEST table.
When trace is enabled this function parses the HEST table and
traces the ACPI table fields.
This function also performs validation of the ACPI table fields.
@param [in] Trace If TRUE, trace the ACPI fields.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
**/
VOID
EFIAPI
ParseAcpiHest (
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
EFI_STATUS Status;
UINT32 Offset;
UINT8 *ErrorSourcePtr;
UINT32 ParsedErrorSourceCount;
UINT32 CurErrorSourceType;
if (Trace != TRUE) {
return;
}
Offset = ParseAcpi (
TRUE,
0,
"HEST",
Ptr,
AcpiTableLength,
PARSER_PARAMS (HestParser)
);
// Validate Error Source Descriptors Count.
if (mHestErrorSourceCount == NULL) {
IncrementErrorCount ();
Print (L"ERROR: Invalid Hardware Error Source Table Header...\n");
return;
}
ParsedErrorSourceCount = 0;
CurErrorSourceType = EFI_ACPI_6_5_IA32_ARCHITECTURE_MACHINE_CHECK_EXCEPTION;
while ((Offset < AcpiTableLength) && (ParsedErrorSourceCount < *mHestErrorSourceCount)) {
ErrorSourcePtr = Ptr + Offset;
// Get Type of Error Source Descriptor.
ParseAcpi (
FALSE,
0,
NULL,
ErrorSourcePtr,
AcpiTableLength - Offset,
PARSER_PARAMS (HestErrorSourceTypeParser)
);
// Validate Error Source Descriptors Type.
if (mHestErrorSourceType == NULL) {
IncrementErrorCount ();
Print (L"ERROR: Invalid Error Source Structure...\n");
return;
}
if (CurErrorSourceType > *mHestErrorSourceType) {
IncrementErrorCount ();
Print (L"ERROR: Error Source Structure must be sorted in Type with ascending order...\n");
return;
}
switch (*mHestErrorSourceType) {
case EFI_ACPI_6_5_IA32_ARCHITECTURE_MACHINE_CHECK_EXCEPTION:
ParseAcpi (
TRUE,
2,
"IA-32 Architecture Machine Check Exception",
ErrorSourcePtr,
sizeof (EFI_ACPI_6_5_IA32_ARCHITECTURE_MACHINE_CHECK_EXCEPTION_STRUCTURE),
PARSER_PARAMS (HestErrorSourceIA32ArchMachineCheckExceptionParser)
);
Offset +=
sizeof (EFI_ACPI_6_5_IA32_ARCHITECTURE_MACHINE_CHECK_EXCEPTION_STRUCTURE);
Status = DumpIA32ArchMachineCheckErrorBankStructure (
Ptr,
AcpiTableLength,
&Offset
);
if (EFI_ERROR (Status)) {
return;
}
break;
case EFI_ACPI_6_5_IA32_ARCHITECTURE_CORRECTED_MACHINE_CHECK:
ParseAcpi (
TRUE,
2,
"IA-32 Architecture Corrected Machine Check",
ErrorSourcePtr,
sizeof (EFI_ACPI_6_5_IA32_ARCHITECTURE_CORRECTED_MACHINE_CHECK_STRUCTURE),
PARSER_PARAMS (HestErrorSourceIA32ArchCorrectedMachineCheckParser)
);
Offset +=
sizeof (EFI_ACPI_6_5_IA32_ARCHITECTURE_CORRECTED_MACHINE_CHECK_STRUCTURE);
Status = DumpIA32ArchMachineCheckErrorBankStructure (
Ptr,
AcpiTableLength,
&Offset
);
if (EFI_ERROR (Status)) {
return;
}
break;
case EFI_ACPI_6_5_IA32_ARCHITECTURE_NMI_ERROR:
ParseAcpi (
TRUE,
2,
"IA-32 Architecture Non-Maskable Interrupt",
ErrorSourcePtr,
sizeof (EFI_ACPI_6_5_IA32_ARCHITECTURE_NMI_ERROR_STRUCTURE),
PARSER_PARAMS (HestErrorSourceIA32ArchNonMaskableInterruptParser)
);
Offset +=
sizeof (EFI_ACPI_6_5_IA32_ARCHITECTURE_NMI_ERROR_STRUCTURE);
break;
case EFI_ACPI_6_5_PCI_EXPRESS_ROOT_PORT_AER:
ParseAcpi (
TRUE,
2,
"PCI Express RootPort AER Structure",
ErrorSourcePtr,
sizeof (EFI_ACPI_6_5_PCI_EXPRESS_ROOT_PORT_AER_STRUCTURE),
PARSER_PARAMS (HestErrorSourcePciExpressRootPortAerParser)
);
Offset += sizeof (EFI_ACPI_6_5_PCI_EXPRESS_ROOT_PORT_AER_STRUCTURE);
break;
case EFI_ACPI_6_5_PCI_EXPRESS_DEVICE_AER:
ParseAcpi (
TRUE,
2,
"PCI Express Device AER Structure",
ErrorSourcePtr,
sizeof (EFI_ACPI_6_5_PCI_EXPRESS_DEVICE_AER_STRUCTURE),
PARSER_PARAMS (HestErrorSourcePciExpressDeviceAerParser)
);
Offset += sizeof (EFI_ACPI_6_5_PCI_EXPRESS_DEVICE_AER_STRUCTURE);
break;
case EFI_ACPI_6_5_PCI_EXPRESS_BRIDGE_AER:
ParseAcpi (
TRUE,
2,
"PCI Express Bridge AER Structure",
ErrorSourcePtr,
sizeof (EFI_ACPI_6_5_PCI_EXPRESS_BRIDGE_AER_STRUCTURE),
PARSER_PARAMS (HestErrorSourcePciExpressBridgeAerParser)
);
Offset += sizeof (EFI_ACPI_6_5_PCI_EXPRESS_BRIDGE_AER_STRUCTURE);
break;
case EFI_ACPI_6_5_GENERIC_HARDWARE_ERROR:
ParseAcpi (
TRUE,
2,
"Generic Hardware Error Source Structure",
ErrorSourcePtr,
sizeof (EFI_ACPI_6_5_GENERIC_HARDWARE_ERROR_SOURCE_STRUCTURE),
PARSER_PARAMS (HestErrorSourceGhesParser)
);
Offset += sizeof (EFI_ACPI_6_5_GENERIC_HARDWARE_ERROR_SOURCE_STRUCTURE);
break;
case EFI_ACPI_6_5_GENERIC_HARDWARE_ERROR_VERSION_2:
ParseAcpi (
TRUE,
2,
"Generic Hardware Error Source V2 Structure",
ErrorSourcePtr,
sizeof (
EFI_ACPI_6_5_GENERIC_HARDWARE_ERROR_SOURCE_VERSION_2_STRUCTURE
),
PARSER_PARAMS (HestErrorSourceGhesv2Parser)
);
Offset +=
sizeof (
EFI_ACPI_6_5_GENERIC_HARDWARE_ERROR_SOURCE_VERSION_2_STRUCTURE
);
break;
case EFI_ACPI_6_5_IA32_ARCHITECTURE_DEFERRED_MACHINE_CHECK:
ParseAcpi (
TRUE,
2,
"IA-32 Architecture Deferred Machine Check",
ErrorSourcePtr,
sizeof (EFI_ACPI_6_5_IA32_ARCHITECTURE_DEFERRED_MACHINE_CHECK_STRUCTURE),
PARSER_PARAMS (HestErrorSourceIA32ArchDeferredMachineCheckParser)
);
Offset +=
sizeof (EFI_ACPI_6_5_IA32_ARCHITECTURE_DEFERRED_MACHINE_CHECK_STRUCTURE),
Status = DumpIA32ArchMachineCheckErrorBankStructure (
Ptr,
AcpiTableLength,
&Offset
);
if (EFI_ERROR (Status)) {
return;
}
break;
default:
IncrementErrorCount ();
Print (L"ERROR: Invalid Error Source Descriptor Type(%d).\n", *mHestErrorSourceType);
return;
} // switch
ParsedErrorSourceCount++;
} // while
if (ParsedErrorSourceCount < *mHestErrorSourceCount) {
IncrementErrorCount ();
Print (
L"ERROR: Invalid Error Source Count... Real:%d, ErrorSourceCount:%d\n",
ParsedErrorSourceCount,
*mHestErrorSourceCount
);
return;
}
if (Offset < AcpiTableLength) {
IncrementErrorCount ();
Print (L"ERROR: Invalid Error Source Count, There's more data...\n");
return;
}
}
|