File: AgdiParser.c

package info (click to toggle)
edk2 2025.11-4
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 338,436 kB
  • sloc: ansic: 2,166,377; asm: 270,725; perl: 235,301; python: 149,900; sh: 34,744; cpp: 23,311; makefile: 3,334; pascal: 1,602; xml: 806; lisp: 35; ruby: 16; sed: 6; tcl: 4
file content (154 lines) | stat: -rw-r--r-- 4,091 bytes parent folder | download
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
/** @file
  AGDI table parser

  Copyright (c) 2025, Arm Limited. All rights reserved.
  SPDX-License-Identifier: BSD-2-Clause-Patent

  @par Reference(s):
    - ACPI for the Arm Components 1.2 EAC1 Platform Design Document,
      dated July 2025.
      (https://developer.arm.com/documentation/den0093/1-2eac1/)
**/

#include <IndustryStandard/ArmAgdiTable.h>
#include <Library/PrintLib.h>
#include <Library/UefiLib.h>
#include "AcpiParser.h"
#include "AcpiView.h"
#include "AcpiViewConfig.h"

STATIC ACPI_DESCRIPTION_HEADER_INFO  mAcpiHdrInfo;

/**
  Validate Signaling Mode Value.

  @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
ValidateSignalingFlags (
  IN UINT8   *Ptr,
  IN UINT32  Length,
  IN VOID    *Context
  )
{
  if (*Ptr >= ArmAgdiSignalingModeInval) {
    IncrementErrorCount ();
    Print (L"\nERROR: Signaling Flags must be either 0, 1 or 2");
  }
}

/**
  Validate that the Reserved field has expected value.

  @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
ValidateResField (
  IN UINT8   *Ptr,
  IN UINT32  Length,
  IN VOID    *Context
  )
{
  if (*Ptr != 0) {
    IncrementErrorCount ();
    Print (L"\nERROR: Reserved bits in Flags must be 0");
  }
}

/**
  An ACPI_PARSER array describing the AGDI Signaling Mode Flags field.
**/
STATIC CONST ACPI_PARSER  AgdiSignalingModeFlags[] = {
  { L"Signaling Mode", 2, 0, L"%u", NULL, NULL, ValidateSignalingFlags, NULL },
  { L"Reserved",       6, 2, L"%u", NULL, NULL, ValidateResField,       NULL },
};

/**
  This function dumps the signaling mode flags field.
  If no format string is specified the Format must be NULL.

  @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
DumpSignalingFlags (
  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 (AgdiSignalingModeFlags)
    );
}

/**
  An ACPI_PARSER array describing the ACPI AGDI Table.
**/
STATIC CONST ACPI_PARSER  AgdiParser[] = {
  PARSE_ACPI_HEADER (&mAcpiHdrInfo),
  { L"Signaling mode Flags",        1,  36, NULL,              DumpSignalingFlags, NULL, NULL, NULL },
  { L"Reserved",                    3,  37, L"0x%x 0x%x 0x%x", Dump3Chars,         NULL, NULL, NULL },
  { L"Sdei Event Number",           4,  40, L"0x%x",           NULL,               NULL, NULL, NULL },
  { L"GSIV",                        4,  44, L"0x%x",           NULL,               NULL, NULL, NULL },
};

/**
  This function parses the ACPI AGDI table.
  When trace is enabled this function parses the AGDI 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
ParseAcpiAgdi (
  IN BOOLEAN  Trace,
  IN UINT8    *Ptr,
  IN UINT32   AcpiTableLength,
  IN UINT8    AcpiTableRevision
  )
{
  if (!Trace) {
    return;
  }

  // Parse ACPI Header + RASF "fixed" fields
  ParseAcpi (
    Trace,
    0,
    "AGDI",
    Ptr,
    AcpiTableLength,
    PARSER_PARAMS (AgdiParser)
    );
}