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
|
/** @file
MADT table parser
Copyright (c) 2016 - 2024, Arm Limited. All rights reserved.
Copyright (c) 2022, AMD Incorporated. All rights reserved.
Copyright (c) 2024, Loongson Technology Corporation Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
@par Reference(s):
- ACPI 6.3 Specification - January 2019
- Arm Generic Interrupt Controller Architecture Specification,
GIC architecture version 3 and version 4, issue E
- Arm Server Base System Architecture 5.0
**/
#include <IndustryStandard/Acpi.h>
#include <Library/UefiLib.h>
#include "AcpiParser.h"
#include "AcpiTableParser.h"
#include "AcpiViewConfig.h"
#include "MadtParser.h"
// Local Variables
STATIC CONST UINT8 *MadtInterruptControllerType;
STATIC CONST UINT8 *MadtInterruptControllerLength;
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;
/**
This function validates the System Vector Base in the GICD.
@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
ValidateGICDSystemVectorBase (
IN UINT8 *Ptr,
IN UINT32 Length,
IN VOID *Context
)
{
if (*(UINT32 *)Ptr != 0) {
IncrementErrorCount ();
Print (
L"\nERROR: System Vector Base must be zero."
);
}
}
/**
This function validates the SPE Overflow Interrupt in the GICC.
@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
ValidateSpeOverflowInterrupt (
IN UINT8 *Ptr,
IN UINT32 Length,
IN VOID *Context
)
{
UINT16 SpeOverflowInterrupt;
SpeOverflowInterrupt = *(UINT16 *)Ptr;
// SPE not supported by this processor
if (SpeOverflowInterrupt == 0) {
return;
}
if ((SpeOverflowInterrupt < ARM_PPI_ID_MIN) ||
((SpeOverflowInterrupt > ARM_PPI_ID_MAX) &&
(SpeOverflowInterrupt < ARM_PPI_ID_EXTENDED_MIN)) ||
(SpeOverflowInterrupt > ARM_PPI_ID_EXTENDED_MAX))
{
IncrementErrorCount ();
Print (
L"\nERROR: SPE Overflow Interrupt ID of %d is not in the allowed PPI ID "
L"ranges of %d-%d or %d-%d (for GICv3.1 or later).",
SpeOverflowInterrupt,
ARM_PPI_ID_MIN,
ARM_PPI_ID_MAX,
ARM_PPI_ID_EXTENDED_MIN,
ARM_PPI_ID_EXTENDED_MAX
);
} else if (SpeOverflowInterrupt != ARM_PPI_ID_PMBIRQ) {
IncrementWarningCount ();
Print (
L"\nWARNING: SPE Overflow Interrupt ID of %d is not compliant with SBSA "
L"Level 3 PPI ID assignment: %d.",
SpeOverflowInterrupt,
ARM_PPI_ID_PMBIRQ
);
}
}
/**
This function validates the TRBE Interrupt in the GICC.
@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
ValidateTrbeInterrupt (
IN UINT8 *Ptr,
IN UINT32 Length,
IN VOID *Context
)
{
UINT16 TrbeInterrupt;
TrbeInterrupt = *(UINT16 *)Ptr;
// SPE not supported by this processor
if (TrbeInterrupt == 0) {
return;
}
if ((TrbeInterrupt < ARM_PPI_ID_MIN) ||
((TrbeInterrupt > ARM_PPI_ID_MAX) &&
(TrbeInterrupt < ARM_PPI_ID_EXTENDED_MIN)) ||
(TrbeInterrupt > ARM_PPI_ID_EXTENDED_MAX))
{
IncrementErrorCount ();
Print (
L"\nERROR: TRBE Interrupt ID of %d is not in the allowed PPI ID "
L"ranges of %d-%d or %d-%d (for GICv3.1 or later).",
TrbeInterrupt,
ARM_PPI_ID_MIN,
ARM_PPI_ID_MAX,
ARM_PPI_ID_EXTENDED_MIN,
ARM_PPI_ID_EXTENDED_MAX
);
}
}
/**
This function dumps the GICC Flags fields.
Format string is 2 fields separated by a \0 mapping to 0 or > 0 of
the buffer field bit.
@param [in] Format Format string that is the list of strings to
map values to.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] Length Length of the field.
**/
STATIC
VOID
EFIAPI
DumpValue (
IN CONST CHAR16 *Format,
IN UINT8 *Ptr,
IN UINT32 Length OPTIONAL
)
{
UINT32 Value;
UINTN Len;
CONST CHAR16 *Format_Alt;
Len = StrLen (Format);
Format_Alt = Format + Len + 1;
Value = *(UINT32 *)Ptr;
Print (L"%s", Value ? Format : Format_Alt);
}
STATIC CONST ACPI_PARSER GICCFlagParser[] = {
{ L"Enabled", 1, 0, L"%d", NULL, NULL, NULL, NULL },
{ L"Performance Inter. Mode", 1, 1, L"Level Triggered\0Edge Triggered", DumpValue, NULL, NULL, NULL },
{ L"VGIC Maintenance Inter. Mode", 1, 2, L"Level Triggered\0Edge Triggered", DumpValue, NULL, NULL, NULL },
{ L"Online Capable", 1, 3, L"%d", NULL, NULL, NULL, NULL },
{ L"Reserved", 28, 4, L"%d", NULL, NULL, NULL, NULL }
};
/**
This function dumps the GICC Flags fields.
Format string is unused.
@param [in] Format Unused
@param [in] Ptr Pointer to the start of the buffer.
@param [in] Length Length of the field.
**/
STATIC
VOID
EFIAPI
DumpGicCFlags (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr,
IN UINT32 Length OPTIONAL
)
{
Print (L"0x%X\n", *(UINT32 *)Ptr);
ParseAcpiBitFields (
TRUE,
2,
NULL,
Ptr,
4,
PARSER_PARAMS (GICCFlagParser)
);
}
/**
An ACPI_PARSER array describing the GICC Interrupt Controller Structure.
**/
STATIC CONST ACPI_PARSER GicCParser[] = {
{ L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{ L"CPU Interface Number", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{ L"ACPI Processor UID", 4, 8, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Flags", 4, 12, NULL, DumpGicCFlags, NULL, NULL, NULL },
{ L"Parking Protocol Version", 4, 16, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Performance Interrupt GSIV", 4, 20, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Parked Address", 8, 24, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"Physical Base Address", 8, 32, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"GICV", 8, 40, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"GICH", 8, 48, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"VGIC Maintenance interrupt", 4, 56, L"0x%x", NULL, NULL, NULL, NULL },
{ L"GICR Base Address", 8, 60, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"MPIDR", 8, 68, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"Processor Power Efficiency Class", 1, 76, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Reserved", 1, 77, L"0x%x", NULL, NULL, NULL, NULL },
{ L"SPE overflow Interrupt", 2, 78, L"0x%x", NULL, NULL,
ValidateSpeOverflowInterrupt, NULL },
{ L"TRBE Interrupt", 2, 80, L"0x%x", NULL, NULL,
ValidateTrbeInterrupt, NULL }
};
/**
An ACPI_PARSER array describing the GICD Interrupt Controller Structure.
**/
STATIC CONST ACPI_PARSER GicDParser[] = {
{ L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{ L"GIC ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Physical Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"System Vector Base", 4, 16, L"0x%x", NULL, NULL,
ValidateGICDSystemVectorBase, NULL },
{ L"GIC Version", 1, 20, L"%d", NULL, NULL, NULL, NULL },
{ L"Reserved", 3, 21, L"%x %x %x", Dump3Chars, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the MSI Frame Interrupt Controller Structure.
**/
STATIC CONST ACPI_PARSER GicMSIFrameParser[] = {
{ L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{ L"MSI Frame ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Physical Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"Flags", 4, 16, L"0x%x", NULL, NULL, NULL, NULL },
{ L"SPI Count", 2, 20, L"%d", NULL, NULL, NULL, NULL },
{ L"SPI Base", 2, 22, L"0x%x", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the GICR Interrupt Controller Structure.
**/
STATIC CONST ACPI_PARSER GicRParser[] = {
{ L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Discovery Range Base Address", 8, 4, L"0x%lx", NULL, NULL, NULL,
NULL },
{ L"Discovery Range Length", 4, 12, L"0x%x", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the GIC ITS Interrupt Controller Structure.
**/
STATIC CONST ACPI_PARSER GicITSParser[] = {
{ L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{ L"GIC ITS ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Physical Base Address", 8, 8, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"Reserved", 4, 16, L"0x%x", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the IO APIC Structure.
**/
STATIC CONST ACPI_PARSER IoApic[] = {
{ L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"I/O APIC ID", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Reserved", 1, 3, L"0x%x", NULL, NULL, NULL, NULL },
{ L"I/O APIC Address", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Global System Interrupt Base", 4, 8, L"0x%x", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the Interrupt Source Override Structure.
**/
STATIC CONST ACPI_PARSER InterruptSourceOverride[] = {
{ L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"Bus", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Source", 1, 3, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Global System Interrupt", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Flags", 2, 8, L"0x%x", NULL, NULL, NULL, NULL }
};
STATIC CONST ACPI_PARSER LocalApicFlags[] = {
{ L"Enabled", 1, 0, L"%d", NULL, NULL, NULL, NULL },
{ L"Online Capable", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"Reserved", 30, 2, L"%d", NULL, NULL, NULL, NULL }
};
/**
This function traces Bit Flags fields.
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.
**/
VOID
EFIAPI
DumpLocalApicBitFlags (
IN CONST CHAR16 *Format OPTIONAL,
IN UINT8 *Ptr,
IN UINT32 Length
)
{
if (Format != NULL) {
Print (Format, *(UINT32 *)Ptr);
return;
}
Print (L"0x%X\n", *(UINT32 *)Ptr);
ParseAcpiBitFields (
TRUE,
2,
NULL,
Ptr,
4,
PARSER_PARAMS (LocalApicFlags)
);
}
/**
An ACPI_PARSER array describing the Processor Local APIC Structure.
**/
STATIC CONST ACPI_PARSER ProcessorLocalApic[] = {
{ L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"ACPI Processor UID", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },
{ L"APIC ID", 1, 3, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Flags", 4, 4, NULL, DumpLocalApicBitFlags, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the Processor Local x2APIC Structure.
**/
STATIC CONST ACPI_PARSER ProcessorLocalX2Apic[] = {
{ L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{ L"X2APIC ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Flags", 4, 8, NULL, DumpLocalApicBitFlags, NULL, NULL, NULL },
{ L"ACPI Processor UID", 4, 12, L"0x%x", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the Local x2APIC NMI Structure.
**/
STATIC CONST ACPI_PARSER LocalX2ApicNmi[] = {
{ L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"Flags", 2, 2, L"0x%x", NULL, NULL, NULL, NULL },
{ L"ACPI Processor UID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Local x2APIC LINT#", 1, 8, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Reserved", 3, 9, L"0x%x%x%x", Dump3Chars, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the Core Pragrammable Interrupt Controller (CORE PIC) Structure.
**/
STATIC CONST ACPI_PARSER CorePic[] = {
{ L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"Version", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },
{ L"ACPI Processor ID", 4, 3, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Physical Processor ID", 4, 7, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Flags", 4, 11, L"0x%x", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the Leagcy I/O Programmable Interrupt Controller (LIO PIC) Structure.
**/
STATIC CONST ACPI_PARSER LegacyIoPic[] = {
{ L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"Version", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Base Address", 8, 3, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"Size", 2, 11, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Cascade Vector", 2, 13, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Cascade vector mapping", 8, 15, L"0x%lx", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the HyperTransport Programmable Interrupt Controller (HT PIC) Structure.
**/
STATIC CONST ACPI_PARSER HyperTransportPic[] = {
{ L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"Version", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Base Address", 8, 3, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"Size", 2, 11, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Cascade Vector", 8, 13, L"0x%lx", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the Extend I/0 Programmable Interrupt Controller (EIO PIC) Structure.
**/
STATIC CONST ACPI_PARSER ExtendIoPic[] = {
{ L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"Version", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Cascade Vector", 1, 3, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Node", 1, 4, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Node Map", 8, 5, L"0x%lx", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the MSI Programmable Interrupt Controller (MSI PIC) Structure.
**/
STATIC CONST ACPI_PARSER MsiPic[] = {
{ L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"Version", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Message Address", 8, 3, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"Start", 4, 11, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Count", 4, 15, L"0x%x", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the Bridge I/O Programmable Interrupt Controller (BIO PIC) Structure.
**/
STATIC CONST ACPI_PARSER BridgeIoPic[] = {
{ L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"Version", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Base Address", 8, 3, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"Size", 2, 11, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Hardware ID", 2, 13, L"0x%x", NULL, NULL, NULL, NULL },
{ L"GSI base", 2, 15, L"0x%x", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the LPC Programmable Interrupt Controller (LPC PIC) Structure.
**/
STATIC CONST ACPI_PARSER LpcPic[] = {
{ L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL },
{ L"Version", 1, 2, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Base Address", 8, 3, L"0x%lx", NULL, NULL, NULL, NULL },
{ L"Size", 2, 11, L"0x%x", NULL, NULL, NULL, NULL },
{ L"Cascade vector", 2, 13, L"0x%x", NULL, NULL, NULL, NULL }
};
/**
An ACPI_PARSER array describing the ACPI MADT Table.
**/
STATIC CONST ACPI_PARSER MadtParser[] = {
PARSE_ACPI_HEADER (&AcpiHdrInfo),
{ L"Local Interrupt Controller Address",4, 36, L"0x%x", NULL, NULL, NULL,
NULL },
{ L"Flags", 4, 40, L"0x%x", NULL, NULL, NULL,NULL}
};
/**
An ACPI_PARSER array describing the MADT Interrupt Controller Structure Header Structure.
**/
STATIC CONST ACPI_PARSER MadtInterruptControllerHeaderParser[] = {
{ NULL, 1, 0, NULL, NULL, (VOID **)&MadtInterruptControllerType, NULL, NULL },
{ L"Length", 1, 1, NULL, NULL, (VOID **)&MadtInterruptControllerLength, NULL,
NULL },
{ L"Reserved", 2, 2, NULL, NULL, NULL, NULL, NULL }
};
/**
This function parses the ACPI MADT table.
When trace is enabled this function parses the MADT table and
traces the ACPI table fields.
This function currently parses the following Interrupt Controller
Structures:
- GICC
- GICD
- GIC MSI Frame
- GICR
- GIC ITS
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
ParseAcpiMadt (
IN BOOLEAN Trace,
IN UINT8 *Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
UINT32 Offset;
UINT8 *InterruptContollerPtr;
UINT32 GICDCount;
GICDCount = 0;
if (!Trace) {
return;
}
Offset = ParseAcpi (
TRUE,
0,
"MADT",
Ptr,
AcpiTableLength,
PARSER_PARAMS (MadtParser)
);
InterruptContollerPtr = Ptr + Offset;
while (Offset < AcpiTableLength) {
// Parse Interrupt Controller Structure to obtain Length.
ParseAcpi (
FALSE,
0,
NULL,
InterruptContollerPtr,
AcpiTableLength - Offset,
PARSER_PARAMS (MadtInterruptControllerHeaderParser)
);
// Check if the values used to control the parsing logic have been
// successfully read.
if ((MadtInterruptControllerType == NULL) ||
(MadtInterruptControllerLength == NULL))
{
IncrementErrorCount ();
Print (
L"ERROR: Insufficient remaining table buffer length to read the " \
L"Interrupt Controller Structure header. Length = %d.\n",
AcpiTableLength - Offset
);
return;
}
// Validate Interrupt Controller Structure length
if ((*MadtInterruptControllerLength == 0) ||
((Offset + (*MadtInterruptControllerLength)) > AcpiTableLength))
{
IncrementErrorCount ();
Print (
L"ERROR: Invalid Interrupt Controller Structure length. " \
L"Length = %d. Offset = %d. AcpiTableLength = %d.\n",
*MadtInterruptControllerLength,
Offset,
AcpiTableLength
);
return;
}
switch (*MadtInterruptControllerType) {
case EFI_ACPI_6_3_GIC:
{
ParseAcpi (
TRUE,
2,
"GICC",
InterruptContollerPtr,
*MadtInterruptControllerLength,
PARSER_PARAMS (GicCParser)
);
break;
}
case EFI_ACPI_6_3_GICD:
{
if (++GICDCount > 1) {
IncrementErrorCount ();
Print (
L"ERROR: Only one GICD must be present,"
L" GICDCount = %d\n",
GICDCount
);
}
ParseAcpi (
TRUE,
2,
"GICD",
InterruptContollerPtr,
*MadtInterruptControllerLength,
PARSER_PARAMS (GicDParser)
);
break;
}
case EFI_ACPI_6_3_GIC_MSI_FRAME:
{
ParseAcpi (
TRUE,
2,
"GIC MSI Frame",
InterruptContollerPtr,
*MadtInterruptControllerLength,
PARSER_PARAMS (GicMSIFrameParser)
);
break;
}
case EFI_ACPI_6_3_GICR:
{
ParseAcpi (
TRUE,
2,
"GICR",
InterruptContollerPtr,
*MadtInterruptControllerLength,
PARSER_PARAMS (GicRParser)
);
break;
}
case EFI_ACPI_6_3_GIC_ITS:
{
ParseAcpi (
TRUE,
2,
"GIC ITS",
InterruptContollerPtr,
*MadtInterruptControllerLength,
PARSER_PARAMS (GicITSParser)
);
break;
}
case EFI_ACPI_6_3_IO_APIC:
{
ParseAcpi (
TRUE,
2,
"IO APIC",
InterruptContollerPtr,
*MadtInterruptControllerLength,
PARSER_PARAMS (IoApic)
);
break;
}
case EFI_ACPI_6_3_INTERRUPT_SOURCE_OVERRIDE:
{
ParseAcpi (
TRUE,
2,
"INTERRUPT SOURCE OVERRIDE",
InterruptContollerPtr,
*MadtInterruptControllerLength,
PARSER_PARAMS (InterruptSourceOverride)
);
break;
}
case EFI_ACPI_6_3_PROCESSOR_LOCAL_APIC:
{
ParseAcpi (
TRUE,
2,
"PROCESSOR LOCAL APIC",
InterruptContollerPtr,
*MadtInterruptControllerLength,
PARSER_PARAMS (ProcessorLocalApic)
);
break;
}
case EFI_ACPI_6_3_PROCESSOR_LOCAL_X2APIC:
{
ParseAcpi (
TRUE,
2,
"PROCESSOR LOCAL X2APIC",
InterruptContollerPtr,
*MadtInterruptControllerLength,
PARSER_PARAMS (ProcessorLocalX2Apic)
);
break;
}
case EFI_ACPI_6_3_LOCAL_X2APIC_NMI:
{
ParseAcpi (
TRUE,
2,
"LOCAL x2APIC NMI",
InterruptContollerPtr,
*MadtInterruptControllerLength,
PARSER_PARAMS (LocalX2ApicNmi)
);
break;
}
case EFI_ACPI_6_5_CORE_PIC:
{
ParseAcpi (
TRUE,
2,
"CORE PIC",
InterruptContollerPtr,
*MadtInterruptControllerLength,
PARSER_PARAMS (CorePic)
);
break;
}
case EFI_ACPI_6_5_LIO_PIC:
{
ParseAcpi (
TRUE,
2,
"LIO PIC",
InterruptContollerPtr,
*MadtInterruptControllerLength,
PARSER_PARAMS (LegacyIoPic)
);
break;
}
case EFI_ACPI_6_5_HT_PIC:
{
ParseAcpi (
TRUE,
2,
"HT PIC",
InterruptContollerPtr,
*MadtInterruptControllerLength,
PARSER_PARAMS (HyperTransportPic)
);
break;
}
case EFI_ACPI_6_5_EIO_PIC:
{
ParseAcpi (
TRUE,
2,
"EIO PIC",
InterruptContollerPtr,
*MadtInterruptControllerLength,
PARSER_PARAMS (ExtendIoPic)
);
break;
}
case EFI_ACPI_6_5_MSI_PIC:
{
ParseAcpi (
TRUE,
2,
"MSI PIC",
InterruptContollerPtr,
*MadtInterruptControllerLength,
PARSER_PARAMS (MsiPic)
);
break;
}
case EFI_ACPI_6_5_BIO_PIC:
{
ParseAcpi (
TRUE,
2,
"BIO PIC",
InterruptContollerPtr,
*MadtInterruptControllerLength,
PARSER_PARAMS (BridgeIoPic)
);
break;
}
case EFI_ACPI_6_5_LPC_PIC:
{
ParseAcpi (
TRUE,
2,
"LPC PIC",
InterruptContollerPtr,
*MadtInterruptControllerLength,
PARSER_PARAMS (LpcPic)
);
break;
}
default:
{
IncrementErrorCount ();
Print (
L"ERROR: Unknown Interrupt Controller Structure,"
L" Type = %d, Length = %d\n",
*MadtInterruptControllerType,
*MadtInterruptControllerLength
);
}
} // switch
InterruptContollerPtr += *MadtInterruptControllerLength;
Offset += *MadtInterruptControllerLength;
} // while
}
|