1/*++
2
3  Copyright (c) 2004  - 2015, Intel Corporation. All rights reserved.<BR>
4
5  This program and the accompanying materials are licensed and made available under
6  the terms and conditions of the BSD License that accompanies this distribution.
7  The full text of the license may be found at
8  http://opensource.org/licenses/bsd-license.php.
9
10  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13
14
15Module Name:
16
17  Madt3.0.c
18
19Abstract:
20
21  This file contains a structure definition for the ACPI 2.0 Multiple APIC
22  Description Table (MADT).  Any changes to the MADT table require updating the
23  respective structure count in Madt.h and then adding the structure to the
24  MADT defined in this file.  The table layout is defined in Madt.h and the
25  table contents are defined in Acpi3_0.h and Madt.h.
26
27--*/
28
29//
30// Statements that include other files
31//
32#include "Madt.h"
33#include <IndustryStandard/Acpi50.h>
34
35//
36// Multiple APIC Description Table
37//
38EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE  Madt = {
39  EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE, // **Signatures are the same 1.0-3.0 because it says "APIC".
40  sizeof (EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE),  // **Length
41  EFI_ACPI_5_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION,
42  //
43  // EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION,  // **Table Revision must be 2.0 for ACPI 3.0
44  // Checksum will be updated at runtime
45  //
46  0x00, // **Check sum
47  //
48  // It is expected that these values will be programmed at runtime
49  //
50  ' ',                        // OEMID
51  ' ',                        // Creative way to
52  ' ',                        // make six bytes
53  ' ',                        // of space in
54  ' ',                        // a table for
55  ' ',                        // **OEMID
56  0,                          // **OEM Table ID
57  EFI_ACPI_OEM_MADT_REVISION, // **OEM Revision
58  0,                          // **Creator ID
59  0,                          // **Creator Revision
60  //
61  // MADT specific fields
62  //
63  LOCAL_APIC_ADDRESS,               // **Local APIC Address
64  EFI_ACPI_4_0_MULTIPLE_APIC_FLAGS, // **Flags
65  //
66  // Processor Local APIC Structure
67  // Correct processor order, Primary threads first then Hyper threads
68  // And correct APIC-ids
69  // This text below is included as a reference until Thurley is 100%:
70  // According to EDS the Local APIC ID is determined based of a bit structure
71  // Bit 24: Core ID Bit 25: Core Pair ID Bit 26-27: Reserved Bit 28-30: Socket ID Bit 31: Reserved
72  // 4 Sockets and 4 Cores per Socket.
73  // So possible LAPIC IDs 00, 01, 02, 03, 10, 11, 12, 13, 20, 21, 22, 23, 30, 31, 32, 33
74  // Static Entries 00, 10, 20, 30, 01, 11, 21, 31, 02, 12, 22, 32, 03, 13, 23, 33
75  // BSP needs to be first entry in table. Check before boot. If BSP non zero need to rotate the entries.
76  // Suppore BSP is LAPIC ID xy. Rotate the table by using formula [x + (y * 4)]
77  // So if BSP LAPIC ID is 21 then table rotated 6 times.
78  // End of Reference Text.
79  // Thurley is supposed to be 2 sockets, 4 cores, and hyperthreading available per each core.
80  // 2 (sockets) x 4 (cores) = 8 (processors non-HT), 8 (processors non-HT) x 2 (HT/proc) = 16 (HT procs)
81  // Rhyme & reason of the ordering below.  This is a best guess ordering for now,
82  // Thurley EPS may give better info on LAPIC numbers.
83  // Ordering was established to help dissipate heat across two sockets evenly.
84  // Since logical processor number only has to be unique, I followed
85  // a similar approach to high end servers and have the first digit of the LAPIC
86  // id the socket number.
87  //
88  EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC,                    // Type 0x00
89  sizeof (EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC_STRUCTURE), // Length
90  0x01,                                                 // Processor ID
91  0x00,                                                 // Local APIC ID
92  0x00000001,                                           // Flags - Disabled (until initialized by platform driver)
93  EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC,                    // Type
94  sizeof (EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC_STRUCTURE), // Length
95  0x02,                                                 // Processor ID
96  0x04,                                                 // Local APIC ID
97  0x00000001,                                           // Flags - Disabled (until initialized by platform driver)
98  EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC,                    // Type
99  sizeof (EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC_STRUCTURE), // Length
100  0x03,                                                 // Processor ID
101  0x02,                                                 // Local APIC ID
102  0x00000001,                                           // Flags - Disabled (until initialized by platform driver)
103  EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC,                    // Type
104  sizeof (EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC_STRUCTURE), // Length
105  0x04,                                                 // Processor ID
106  0x06,                                                 // Local APIC ID
107  0x00000001,                                           // Flags - Disabled (until initialized by platform driver)
108  //
109  // ***************   IO APIC Structure ******************
110  //
111  //
112  //
113  // **************************  I/O APIC  **************
114  //
115  EFI_ACPI_3_0_IO_APIC,                     // Type 0x01
116  sizeof (EFI_ACPI_3_0_IO_APIC_STRUCTURE),  // Length
117  ICH_IOAPIC_ID,                            // IO APIC ID
118  EFI_ACPI_RESERVED_BYTE,                   // Reserved    EFI_ACPI_RESERVED_BYTE
119  IO_APIC_ADDRESS,                          // IO APIC Address (physical)   0xFEC00000
120  0x18 * 0,                                 // Global System Interrupt Base
121
122  //
123  // Interrupt Source Override Structure: Sample
124  //
125  // EFI_ACPI_2_0_INTERRUPT_SOURCE_OVERRIDE,                   // Type  0x02
126  // sizeof (EFI_ACPI_2_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE),// Length
127  // 0x00,                                                     // Bus
128  // 0x00,                                                     // Source
129  // 0x00000000,                                               // Global System Interrupt
130  // 0x0000,                                                   // Flags
131  //
132  // IRQ0=>IRQ2 Interrupt Source Override Structure
133  //
134  EFI_ACPI_3_0_INTERRUPT_SOURCE_OVERRIDE, // Type  0x02
135  sizeof (EFI_ACPI_3_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE),  // Length
136  0x00,       // Bus - ISA
137  0x00,       // Source - IRQ0
138  0x00000002, // Global System Interrupt - IRQ2
139  0x0000,     // Flags - Conforms to specifications of the bus
140  //
141  // ISO (SCI Active High) Interrupt Source Override Structure
142  //
143  EFI_ACPI_3_0_INTERRUPT_SOURCE_OVERRIDE, // Type  0x02
144  sizeof (EFI_ACPI_3_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE),  // Length
145  0x00,       // Bus - ISA
146  0x09,       // Source - IRQ0
147  0x00000009, // Global System Interrupt - IRQ2
148  0x000D,     // Flags - Level-tiggered, Active High
149
150
151
152  EFI_ACPI_3_0_LOCAL_APIC_NMI,                    // Type
153  sizeof (EFI_ACPI_3_0_LOCAL_APIC_NMI_STRUCTURE), // Length
154  0x01,                                           // ACPI Processor ID
155  0x000D,                                         // Flags - Level-tiggered, Active High
156  0x01,                                           // Local APIC LINT#
157  EFI_ACPI_3_0_LOCAL_APIC_NMI,                    // Type
158  sizeof (EFI_ACPI_3_0_LOCAL_APIC_NMI_STRUCTURE), // Length
159  0x02,                                           // ACPI Processor ID
160  0x000D,                                         // Flags - Level-tiggered, Active High
161  0x01,                                           // Local APIC LINT#
162  EFI_ACPI_3_0_LOCAL_APIC_NMI,                    // Type
163  sizeof (EFI_ACPI_3_0_LOCAL_APIC_NMI_STRUCTURE), // Length
164  0x03,                                           // ACPI Processor ID
165  0x000D,                                         // Flags - Level-tiggered, Active High
166  0x01,                                           // Local APIC LINT#
167  EFI_ACPI_3_0_LOCAL_APIC_NMI,                    // Type
168  sizeof (EFI_ACPI_3_0_LOCAL_APIC_NMI_STRUCTURE), // Length
169  0x04,                                           // ACPI Processor ID
170  0x000D,                                         // Flags - Level-tiggered, Active High
171  0x01,                                           // Local APIC LINT#
172};
173
174VOID*
175ReferenceAcpiTable (
176  VOID
177  )
178{
179  //
180  // Reference the table being generated to prevent the optimizer from
181  // removing the data structure from the executable
182  //
183  return (VOID*)&Madt;
184}
185