summaryrefslogtreecommitdiff
path: root/Core/EM/ACPI/mptable.h
blob: 6389c5045c3e522fba9f4ab52c37aa839f036761 (plain)
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
//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2009, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**             5555 Oakbrook Pkwy, Norcross, GA 30093               **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************

//**********************************************************************
// $Header: /Alaska/BIN/Modules/ACPI/Template/Core/mptable.h 8     12/03/12 11:47a Oleksiyy $
//
// $Revision: 8 $
//
// $Date: 12/03/12 11:47a $
//**********************************************************************
// Revision History
// ----------------
// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/mptable.h $
// 
// 8     12/03/12 11:47a Oleksiyy
// [TAG]  		EIP107890
// [Category]  	Improvement
// [Description]  	Create a token that it define the Bot and Top of Io
// APIC address.
// [Files]  		AcpiCore.h and mptable.h
// 
// 7     5/08/09 1:16p Yakovlevs
// Made ACPI Driver use AMI Board  Info Protocol if available without
// breaking compatibility.
// 
// 6     3/26/09 4:51p Oleksiyy
// New ACPI Core implementation - improves logic, execution time and
// memory usage of ACPI module.
// 
// 5     4/15/08 9:16p Yakovlevs
// 
// 4     4/11/07 5:45p Artems
// Multiprocessor detection added
// 
// 3     3/28/07 10:43a Artems
// Fixed bug - added System memory entry for legacy video
// 
// 2     2/06/07 5:41p Artems
// 
// 1     2/06/07 4:54p Artems
// 
//**********************************************************************

//<AMI_FHDR_START>
//----------------------------------------------------------------------------
//
// Name:	Mptable.h
//
// Description:	Header file for MP table builder
//
//----------------------------------------------------------------------------
//<AMI_FHDR_END>

#ifndef __MPTABLE__H__
#define __MPTABLE__H__
#ifdef __cplusplus
extern "C" {
#endif

//------------------------ Include files ------------------------------
#include <Protocol/PciRootBridgeIo.h>
#include <Protocol/PciIo.h>
#include <token.h>

//------------------------ Type declarations --------------------------
#define MP_TABLE_MAX_BUS_ENTRIES        0xFF //from 0 to 0xFE, FF reserved means no parent bus
#define MP_TABLE_MAX_IO_APIC_ENTRIES    0x10

#define MP_FLOATING_POINTER_SIGNATURE 0x5F504D5F  // _MP_
#define MP_CONFIGURATION_TABLE_SIGNATURE 0x504D4350     // PCMP

#define MP_TABLE_VERSION_1_1    0x1
#define MP_TABLE_VERSION_1_4    0x4

#define MP_TABLE_CPU_ENTRY_TYPE                  0
#define MP_TABLE_BUS_ENTRY_TYPE                  1
#define MP_TABLE_IO_APIC_ENTRY_TYPE              2
#define MP_TABLE_INT_ASSIGN_ENTRY_TYPE           3
#define MP_TABLE_LOCAL_INT_ASSIGN_ENTRY_TYPE     4

#define MP_EX_TABLE_SYS_ADDRESS_MAP_ENTRY_TYPE              128
#define MP_EX_TABLE_BUS_HIERARCHY_ENTRY_TYPE                129
#define MP_EX_TABLE_COMPAT_BUS_ADDRESS_MODIFIER_ENTRY_TYPE  130

#define IO_APIC_BASE_ADDRESS_BOTTOM	APCB        //defined earlier

#if defined(IO_APIC_BASE_TOP_ADDRESS)
#define IO_APIC_BASE_ADDRESS_TOP	IO_APIC_BASE_TOP_ADDRESS        //must be redefined 
#else                                                               //
#define IO_APIC_BASE_ADDRESS_TOP	0xFED00000                      //if different from default
#endif

#define IO_APIC_SEARCH_STEP		    0x1000

#define IO_APIC_INDEX_REG		0x0
#define IO_APIC_DATA_REG		0x4 //(0x10 in bytes = 0x4 in dwords

#define IO_APIC_MAP_ID_REG		    0x0
#define IO_APIC_MAP_VERSION_REG		0x1

#define INT_TYPE_INT        0
#define INT_TYPE_NMI        1
#define INT_TYPE_SMI        2
#define INT_TYPE_EXT_INT    3

#define POLARITY_CONFORM_SPEC   0
#define POLARITY_ACTIVE_HIGH    1
#define POLARITY_ACTIVE_LOW     3

#define TRIGGER_MODE_CONFORM_SPEC    0
#define TRIGGER_MODE_EDGE_TRIGGERED  1
#define TRIGGER_MODE_LEVEL_TRIGGERED 3

#define BUS_TYPE_ISA    5

#pragma pack(1)

//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: MP_FLOATING_POINTER
//
// Description: This structure represents MP table floating pointer format
// as defined in MPS specification v1.4
//
//----------------------------------------------------------------------------
//<AMI_THDR_END>

typedef struct _MP_FOATING_POINTER
{
    UINT32  Signature;
    UINT32  PhysicalAddresPointer;
    UINT8   Length;
    UINT8   VersionNumber;
    UINT8   CheckSum;
    UINT8   DefaultConfiguration;
    UINT8   IMCRflag;
    UINT8   Reserved[3];
} MP_FLOATING_POINTER;

//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: MP_CONFIGURATION_TABLE_HEADER
//
// Description: This structure represents MP configuration table header format
// as defined in MPS specification v1.4
//
//----------------------------------------------------------------------------
//<AMI_THDR_END>

typedef struct _MP_CONFIGURATION_TABLE_HEADER
{
    UINT32  Signature;
    UINT16  BaseTableLength;
    UINT8   VersionNumber;
    UINT8   CheckSum;
    UINT8   OemId[8];
    UINT8   ProductId[12];
    UINT32  OemTablePointer;
    UINT16  OemTableSize;
    UINT16  BaseTableEntryCount;
    UINT32  LocalApicAddress;
    UINT16  ExtendedTableLength;
    UINT8   ExtendedCheckSum;
    UINT8   Reserved;
} MP_CONFIGURATION_TABLE_HEADER;

//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: MP_TABLE_CPU_ENTRY
//
// Description: This structure represents MP configuration table CPU entry format
// as defined in MPS specification v1.4
//
//----------------------------------------------------------------------------
//<AMI_THDR_END>

typedef struct _MP_TABLE_CPU_ENTRY
{
    UINT8   EntryType;
    UINT8   LocalApicId;
    UINT8   LocalApicVersion;
    struct  
    {
        UINT8   CpuEnable    : 1;
        UINT8   CpuBootStrap : 1;
        UINT8   Reserved     : 6;
    } CpuFlags;
    UINT32  CpuSignature;
    UINT32  FeatureFlags;
    UINT32  Reserved[2];
} MP_TABLE_CPU_ENTRY;

//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: MP_TABLE_BUS_ENTRY
//
// Description: This structure represents MP configuration table bus entry format
// as defined in MPS specification v1.4
//
//----------------------------------------------------------------------------
//<AMI_THDR_END>

typedef struct _MP_TABLE_BUS_ENTRY
{
    UINT8   EntryType;
    UINT8   BusId;
    UINT8   BusTypeString[6];
} MP_TABLE_BUS_ENTRY;

//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: MP_TABLE_IO_APIC_ENTRY
//
// Description: This structure represents MP configuration table IO APIC entry format
// as defined in MPS specification v1.4
//
//----------------------------------------------------------------------------
//<AMI_THDR_END>

typedef struct _MP_TABLE_IO_APIC_ENTRY
{
    UINT8   EntryType;
    UINT8   IoApicId;
    UINT8   IoApicVersion;
    UINT8   Flags;

    UINT32  IoApicAddress;
} MP_TABLE_IO_APIC_ENTRY;

typedef union
{
    UINT8   IsaBusIrq;
    struct
    {
        UINT8   PciIntSignal    : 2;
        UINT8   PciDeviceNumber : 5;
        UINT8   Reserved        : 1;
    } PciBusIrq;
} SOURCE_IRQ;

//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: MP_TABLE_INT_ASSIGN_ENTRY
//
// Description: This structure represents MP configuration table interrupt assingment
// entry format as defined in MPS specification v1.4
//
//----------------------------------------------------------------------------
//<AMI_THDR_END>

typedef struct _MP_TABLE_INT_ASSIGN_ENTRY
{
    UINT8   EntryType;
    UINT8   InterruptType;
    UINT16  Flags;    
    UINT8   SourceBusId;
    SOURCE_IRQ   SourceBusIrq;
    UINT8   DestIoApicId;
    UINT8   DestIoApicItin;
} MP_TABLE_INT_ASSIGN_ENTRY;

//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: MP_TABLE_LOCAL_INT_ASSIGN_ENTRY
//
// Description: This structure represents MP table local interrupt assingment
// entry format as defined in MPS specification v1.4
//
//----------------------------------------------------------------------------
//<AMI_THDR_END>

typedef struct _MP_TABLE_LOCAL_INT_ASSIGN_ENTRY
{
    UINT8   EntryType;
    UINT8   InterruptType;
    struct
    {
        UINT16  Polarity    : 2;
        UINT16  TriggerMode : 2;
        UINT16  Reserved    : 12;
    } InterruptSignal;
    UINT8   SourceBusId;
    UINT8   SourceBusIrq;
    UINT8   DestLocalApicId;
    UINT8   DestLocalApicItin;
} MP_TABLE_LOCAL_INT_ASSIGN_ENTRY;

//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: MP_EX_TABLE_SYS_ADDRESS_MAP_ENTRY
//
// Description: This structure represents MP table system address map extended
// entry format as defined in MPS specification v1.4
//
//----------------------------------------------------------------------------
//<AMI_THDR_END>

typedef struct _MP_EX_TABLE_SYS_ADDRESS_MAP_ENTRY
{
    UINT8 EntryType;
    UINT8 EntryLength;
    UINT8 BusId;
    UINT8 AddressType;
    UINT64 AddressBase;
    UINT64 AddressLength;
} MP_EX_TABLE_SYS_ADDRESS_MAP_ENTRY;

//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: MP_EX_TABLE_BUS_HIERARCHY_ENTRY
//
// Description: This structure represents MP table bus hierarchy extended
// entry format as defined in MPS specification v1.4
//
//----------------------------------------------------------------------------
//<AMI_THDR_END>

typedef struct _MP_EX_TABLE_BUS_HIERARCHY_ENTRY
{
    UINT8 EntryType;
    UINT8 EntryLength;
    UINT8 BusId;
    UINT8 BusInfo;
    UINT8 ParentBusId;
    UINT8 Reserved[3];
} MP_EX_TABLE_BUS_HIERARCHY_ENTRY;

//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: MP_EX_TABLE_COMPAT_BUS_ADDRESS_MODIFIER_ENTRY
//
// Description: This structure represents MP table compatibility bus address modifier 
// extended entry format as defined in MPS specification v1.4
//
//----------------------------------------------------------------------------
//<AMI_THDR_END>

typedef struct _MP_EX_TABLE_COMPAT_BUS_ADDRESS_MODIFIER_ENTRY
{
    UINT8 EntryType;
    UINT8 EntryLength;
    UINT8 BusId;
    UINT8 AddressModifier;
    UINT32 RangeList;
} MP_EX_TABLE_COMPAT_BUS_ADDRESS_MODIFIER_ENTRY;

//----------------------- Additional structures -----------------------

//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: BUS_INFO
//
// Description: PCI bus description data structure
//
// Fields: Name             Type                    Description
//----------------------------------------------------------------------------
// BusId                UINT8                      Bus Id number
// ParentBusId          UINT8                      Parent bus Id number
// BusType              UINT8                      Bus type number
// Flags                UINT8                      Bus flags
// 
//----------------------------------------------------------------------------
//<AMI_THDR_END>

typedef struct _BUS_INFO
{
    UINT8   BusId;
    UINT8   ParentBusId;
    UINT8   BusType;
    UINT8   Flags;
} BUS_INFO;

//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: ACPI_ADDRESS_SPACE_DESC
//
// Description: This structure represents ACPI address space descriptor
// format as defined in ACPI specification v3.0
//
//----------------------------------------------------------------------------
//<AMI_THDR_END>

typedef struct _ACPI_ADDRESS_SPACE_DESC
{
	UINT8	Signature;
	UINT16	DescLength;
	UINT8	ResourceType;
	UINT8	GeneralFlags;
	UINT8	TypeSpecificFlags;
	UINT64	AddressSpaceGranularity;
	UINT64	AddressRangeMin;
	UINT64	AddressRangeMax;
	UINT64	AddressTranslationOffset;
	UINT64	AddressLength;
} ACPI_ADDRESS_SPACE_DESC;

//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: IO_APIC_DEST
//
// Description: Device interrupt destination description data structure
//
// Fields: Name             Type                    Description
//----------------------------------------------------------------------------
// IoApicItin           UINT8                      IO APIC pin number
// IoApicId             UINT8                      IO APIC Id
// 
//----------------------------------------------------------------------------
//<AMI_THDR_END>

typedef struct _IO_APIC_DEST
{
    UINT8   IoApicItin;
    UINT8   IoApicId;
} IO_APIC_DEST;

#if AmiBoardInfo_SUPPORT == 0
//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: PCI_IRQ_APIC_ROUTE
//
// Description: PCI interrupt routing description data structure
//
// Fields: Name             Type                    Description
//----------------------------------------------------------------------------
// PciBusNumber         UINT8                      PCI bus number
// DeviceNumber         UINT8                      PCI device number
// Intn                 IO_APIC_DEST               Interrupt destination
// Reserved             UINT8
// 
//----------------------------------------------------------------------------
//<AMI_THDR_END>

typedef struct _PCI_IRQ_APIC_ROUTE
{
    UINT8   PciBusNumber;
    UINT8   DeviceNumber;
    IO_APIC_DEST Intn[4];
    UINT8   Reserved;
} PCI_IRQ_APIC_ROUTE;
#endif


//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: IO_APIC_INFO
//
// Description: IO APIC description data structure
//
// Fields: Name             Type                    Description
//----------------------------------------------------------------------------
// IoApicId               UINT8               IO APIC Id
// IoApicVersion          UINT8               IO APIC version
// IoApicFlags            UINT8               IO APIC flags
// MaxRedirectionEntries  UINT8               Max number of redirection entries supported by IO APIC
// IoApicAddress          UINT32              IO APIC address in memory
// 
//----------------------------------------------------------------------------
//<AMI_THDR_END>

typedef struct _IO_APIC_INFO
{
    UINT8   IoApicId;
    UINT8   IoApicVersion;
    UINT8   IoApicFlags;
    UINT8   MaxRedirectionEntries;
    UINT32  IoApicAddress;
} IO_APIC_INFO;

#pragma pack()

//------------------------ Global variables ---------------------------


//------------------------ Functions prototypes -----------------------

EFI_STATUS MpsTableBuilderInit(
	IN EFI_HANDLE ImageHandle,
	IN EFI_SYSTEM_TABLE *SystemTable
    );

EFI_STATUS MpsTableFloatPointerModify(
    VOID
    );

EFI_STATUS MpsTableCreate(
    VOID
    );

VOID MpsTableReadyToBootNotify(
	IN EFI_EVENT Event, 
    IN VOID *Context
    );

EFI_STATUS MpsTableAddHeader(
    VOID
    );

UINT16 MpsTableAddCpuEntry(
    VOID
    );

UINT16 MpsTableAddBusEntry(
    VOID
    );

UINT16 MpsTableAddIoApicEntry(
    VOID
    );

UINT16 MpsTableAddIntAssignEntry(
    VOID
    );

UINT16 MpsTableAddLocalIntAssignEntry(
    VOID
    );

VOID MpsTableAddExtendedTable(
    VOID
    );

VOID MpsExTableAddSysAddressMapEntry(
    IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *pPciRootBridgeIoProtocol,
    IN UINT8 BusId,
    IN UINT8 BusAttributes
    );

VOID MpsExTableAddBusHierarchyEntry(
    VOID
    );

VOID MpsExTableAddCompatBusAddressModifierEntry(
    VOID
    );


//----------------------- Additional functions -------------------------

VOID QueryBusInfo(
    VOID
    );

VOID CollectIoApicInfo(
    IN EFI_PCI_IO_PROTOCOL *pPciIoProtocol OPTIONAL,
    IN UINT32 BaseAddress OPTIONAL
    );

VOID ArrangeIoApicEntries(
    VOID
    );

VOID GetIoApicId(
    IN UINT16   SysVectorNumber,
    OUT UINT8 *IoApicId,
    OUT UINT8 *IoApicItin
    );

EFI_STATUS GetCpuInfo(
    IN UINTN Cpu,
    OUT UINT8 *Cores,
    OUT UINT8 *Threads
    );

/****** DO NOT WRITE BELOW THIS LINE *******/
#ifdef __cplusplus
}
#endif
#endif
//**********************************************************************
//**********************************************************************
//**                                                                  **
//**        (C)Copyright 1985-2009, American Megatrends, Inc.         **
//**                                                                  **
//**                       All Rights Reserved.                       **
//**                                                                  **
//**             5555 Oakbrook Pkwy, Norcross, GA 30093               **
//**                                                                  **
//**                       Phone: (770)-246-8600                      **
//**                                                                  **
//**********************************************************************
//**********************************************************************