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

//**********************************************************************
// $Header: /Alaska/BIN/Modules/ACPI/Template/Core/ACPICORE.H 25    10/28/13 12:06p Oleksiyy $
//
// $Revision: 25 $
//
// $Date: 10/28/13 12:06p $
//**********************************************************************
// Revision History
// ----------------
// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/ACPICORE.H $
// 
// 25    10/28/13 12:06p Oleksiyy
// [TAG]  		EIP121819
// [Category]  	Improvement
// [Description]  	Add $FID ACPI table.
// [Files]  		AcpiCore.c, AcpiCore.h
// 
// 24    12/03/12 11:50a 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
// 
// 23    5/27/11 5:34p Felixp
// AcpiSdt.h is renamed to AcpiSystemDescriptionTable.h.
// 
// 22    5/14/11 2:48p Yakovlevs
// [TAG]  		EIP 56526
// [Category]  	New Feature
// [Description]  	ACPI Manipulation Protocol. PI 1.2 Spec Vol 5 Section
// 9.
// [Files]  		AcpiCore.c; AcpiCore.h; AcpiSdtPrivate.h; Aml.c; AmlChild.c;
// AmlNamespace.c; AmlOption.c; AmlString.c AcpiSdt.c; 
// Protocol\AcpiSdt.h. 
// 
// 21    8/11/09 12:46p Markw
// EIP# 24914 -- Add Local x2APIC support.
// 
// 20    5/26/09 1:43p Yakovlevs
// 
// 19    5/14/09 5:38p Yakovlevs
// Commented out Duplicated EFI_ACPI_TABLE_VERSION definition
// 
// 18    3/26/09 4:51p Oleksiyy
// New ACPI Core implementation - improves logic, execution time and
// memory usage of ACPI module.
// 
// 1     2/18/09 3:51p Oleksiyy
// 
//**********************************************************************
//<AMI_FHDR_START>
//
// Name:	AcpiCore.h
//
// Description:	ACPI Core Header File. Main ACPI Driver Specific Definitions.
//
//<AMI_FHDR_END>
//**********************************************************************
#ifndef __AcpiCore__H__
#define __AcpiCore__H__
#ifdef __cplusplus
extern "C" {
#endif

#include <Protocol\FirmwareVolume.h >
#include <Protocol\AmiSio.h>
#include <Protocol\DevicePath.h>
#include <Protocol\AcpiSupport.h>
#include <AmiDxeLib.h>
#include <AMIHobs.h>
#include <token.h>
#include <Dxe.h>
#include <AcpiRes.h>
#include "OEM_ACPI.h"
#if defined(PI_SPECIFICATION_VERSION)&&(PI_SPECIFICATION_VERSION>=0x00010014)
#include <Protocol\AcpiSystemDescriptionTable.h>
#include "AcpiSdtPrivate.h"
#endif
#include <Setup.h>
#include <acpi11.h>
#include <acpi20.h>
#include <Efi.h>
#include <Acpi.h>
#include <GenericSio.h>
#pragma	pack(push, 1)

//**********************************************************************
// Protocol Data Definitions
//**********************************************************************
// ACPI Version bitmap definition:
//
// EFI_ACPI_TABLE_VERSION_1_0B - ACPI Version 1.0b (not supported curently)
// EFI_ACPI_TABLE_VERSION_2_0 - ACPI Version 2.0 
// EFI_ACPI_TABLE_VERSION_NONE - No ACPI Versions.  This might be used
//  to create memory-based operation regions or other information
//  that is not part of the ACPI "tree" but must still be found
//  in ACPI memory space and/or managed by the core ACPI driver.
//
//**********************************************************************
/*
#define EFI_ACPI_TABLE_VERSION 			UINT32

#define EFI_ACPI_TABLE_VERSION_NONE		0x00000001
#define EFI_ACPI_TABLE_VERSION_1_0B   	0x00000002
#define EFI_ACPI_TABLE_VERSION_2_0    	0x00000004
#define EFI_ACPI_TABLE_VERSION_3_0    	0x00000008
#define EFI_ACPI_TABLE_VERSION_X    	(EFI_ACPI_TABLE_VERSION_2_0 | EFI_ACPI_TABLE_VERSION_3_0)
#define EFI_ACPI_TABLE_VERSION_ALL  	(EFI_ACPI_TABLE_VERSION_1_0B|EFI_ACPI_TABLE_VERSION_X)
*/
//==================================================================//
//GUID for DSDT storage type	FFS_FILEGUID                = 11D8AC35-FB8A-44d1-8D09-0B5606D321B9
#define EFI_ACPI_DSDT_V_1_1_GUID {0x9410046e,0x1d26,0x45bc,0xb6,0x58,0xde,0xca,0xb1,0x4d,0x75,0x65}

#define EFI_ACPI_DSDT_V_2_0_GUID {0x11D8AC35,0xFB8A,0x44d1,0x8D,0x09,0x0B,0x56,0x06,0xD3,0x21,0xB9}
//ACPI tables GUIDs must be published in System Configuration table
#define EFI_ACPI_11_TABLE_GUID   {0xeb9d2d30,0x2d88,0x11d3,0x9a,0x16,0x00,0x90,0x27,0x3f,0xc1,0x4d}
#define EFI_ACPI_20_TABLE_GUID   {0x8868e871,0xe4f1,0x11d3,0xbc,0x22,0x00,0x80,0xc7,0x3c,0x88,0x81}

#define	ACPI_REV1       0x01
#define	ACPI_REV2       0x02
#define	ACPI_REV3       0x03
#define	ACPI_REV4       0x04

#define ACPI_TABLE_NOT_FOUND        (~0)
#define ACPI_TABLE_NOT_REMOVABLE    (~1)
//======================================================
//  Here Follows Definitions that are not Chipset specific
//======================================================

#define CREATOR_ID_MS 0x5446534D  //"TFSM""MSFT"(Microsoft)

#define	CREATOR_REV_MS 0x00010013

#define CREATOR_ID_AMI 0x20494D41  //" IMA""AMI "(AMI)

#define	CREATOR_REV	0x00000000


#define APIC_SIG 0x43495041  //"APIC"Multiple APIC Description Table

#define SPIC_SIG 0x43495053  //"SPIC"Multiple SAPIC Description Table

#define BOOT_SIG 0x544F4F42  //"BOOT"MS Simple Boot Spec

#define DBGP_SIG 0x50474244  //"DBGP" MS Bebug Port Spec

#define DSDT_SIG 0x54445344  //"DSDT" Differentiated System Description Table

#define ECDT_SIG 0x54444345	//"ECDT" Embedded Controller Boot Resources Table

#define ETDT_SIG 0x54445445	//"ETDT" Event Timer Description Table

#define FACP_SIG 0x50434146  //"FACP" Fixed ACPI Description Table (FADT)

#define FACS_SIG 0x53434146  //"FACS" //Firmware ACPI Control Structure

#define PSDT_SIG 0x54445350  //"PSDT"Persistent System Description Table

#define RSDT_SIG 0x54445352  //"RSDT"Root System Description Table

#define SBST_SIG 0x54534253  //"SBST"Smart Battery Specification Table

#define SLIT_SIG 0x54494C53  //"SLIT"System Locality Information Table

#define SPCR_SIG 0x52435053  //"SPCR"Serial Port Concole Redirection Table

#define SRAT_SIG 0x54415253  //"SBST"Static Resource Affinity Table

#define SSDT_SIG 0x54445353  //"SSDT"Secondary System Description Table

#define SPMI_SIG 0x494D5053  //"SPMI"Server Platform Management Interface Table

#define XSDT_SIG 0x54445358  //"XSDT" eXtended System Description Table

#define RSDP_SIG 0x2052545020445352 //"RSD PTR "

//======================================================
//  ACPI Description Headers Signatures
//======================================================
#define MCFG_SIG 0x4746434D  //PCI Express Congiguration Table

#define	HPET_SIG 0x54455048

//for testing purposes only
#define IPPT_SIG 0x54505049 // "IPPT" --  IA64 Platform Properties Table

#define FIDT_SIG 0x54444946  //"FIDT" $FID Table

#define THREE_CHAR_ARRAY(x) {(x)/10+'0',(x)%10+'0',0}

//======================================================
//  Bits Description in APICXX.Type field. ACPI 2.0
//======================================================
#ifndef AT_LAPIC_H
#define			AT_LAPIC_H		0
#endif

#ifndef	AT_IOAPIC
#define			AT_IOAPIC		1
#endif

#ifndef	AT_ISO
#define			AT_ISO			2
#endif

#ifndef	AT_NMI
#define			AT_NMI			3
#endif

#ifndef AT_LAPIC_H_NMI
#define			AT_LAPIC_H_NMI	4
#endif

#ifndef AT_LAPIC_H_ADR
#define			AT_LAPIC_H_ADR	5
#endif

#ifndef	AT_IOSAPIC
#define			AT_IOSAPIC		6
#endif
//Updated according ACPI Spec 2.0 errata 1.3
#ifndef AT_LSAPIC
#define			AT_LSAPIC		7
#endif

#ifndef AT_PIS
#define			AT_PIS			8
#endif

#ifndef AT_LX2APIC
#define			AT_LX2APIC      9
#endif

#ifndef AT_LX2APIC_NMI
#define			AT_LX2APIC_NMI  0xa
#endif

#define		IOA_BASE_BOT		APCB

#if defined(IO_APIC_BASE_TOP_ADDRESS)
#define		IOA_BASE_TOP		IO_APIC_BASE_TOP_ADDRESS
#else
#define		IOA_BASE_TOP		0xFED00000
#endif

#define		IOA_IND_REG_OFFS	0x00
#define		IOA_DAT_REG_OFFS	0x10
#define		IOA_ID_IND		    0x00
#define		IOA_VER_IND		    0x01

//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: ACPI_AML_RES
//
// Description: Structure to store System resource Information
//
// Fields: Name             Type                    Description
//----------------------------------------------------------------------------
// Base                 UINT64
// Length               UINT64
// 
//----------------------------------------------------------------------------
//<AMI_THDR_END>

typedef struct _ACPI_AML_RES {
	UINT64			Base;
	UINT64			Length;	
} ACPI_AML_RES;

//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: ACPI_AML_UPD_INFO
//
// Description: Structure to store Aml update information
//
// Fields: Name             Type                    Description
//----------------------------------------------------------------------------
// Dsdt1Addr            UINT64
// Dsdt2Addr            UINT64
// PciGap               ACPI_AML_RES[3]
// SS1                  BOOLEAN
// SS2                  BOOLEAN
// SS3                  BOOLEAN
// SS4                  BOOLEAN
// RomStart             UINT32
// TopOfMemory          UINT32
// SioDevStatusVar      SIO_DEV_STATUS
// 
//----------------------------------------------------------------------------
//<AMI_THDR_END>
typedef struct _ACPI_AML_UPD_INFO {
	UINT64			Dsdt1Addr;
	UINT64			Dsdt2Addr;
	ACPI_AML_RES	PciGap[3];
	BOOLEAN 		SS1;
	BOOLEAN 		SS2;
	BOOLEAN 		SS3;
	BOOLEAN 		SS4;
	UINT32			RomStart;
	UINT32			TopOfMemory;
	SIO_DEV_STATUS	SioDevStatusVar;
} ACPI_AML_UPD_INFO;

EFI_STATUS LocateACPITableProtocol (IN EFI_GUID *Protocol, OUT VOID  **Instance, IN UINT8 Version);

typedef enum {
	pgBelow1M,
	pgBelow4G,
	pgAbove4G,
	pgMaxResType,
} AML_RES_TYPE;

//======================================================
//  Bits Description in LAPIC_XX.Flags field. ACPI 2.0
//======================================================
#define		FL_ENABLE		0x0001

//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: MADT_ENTRY_HEADER
//
// Description: Header of the entrie for MADT table.
//             
//
// Fields: Type             Name                    Description
//----------------------------------------------------------------------------
//	    UINT8	        Type
//	    UINT8	        Length
// 
//----------------------------------------------------------------------------
//<AMI_THDR_END>
typedef struct _MADT_ENTRY_HEADER{
	UINT8	Type;
	UINT8	Length; 
}MADT_ENTRY_HEADER;

//======================================================
//  LAPIC Structure per each CPU  IA32
//======================================================
typedef	struct _LAPIC_H32 {
    MADT_ENTRY_HEADER   Header;
	UINT8		        CpuId;
	UINT8		        LapicId;
	UINT32	            Flags;
} LAPIC_H32,*PLAPIC_H32, LAPIC_H_20,*PLAPIC_H_20;

//======================================================
//  LX2APIC Structure per each CPU  IA32
//======================================================
typedef	struct _LX2APIC {
    MADT_ENTRY_HEADER   Header;
    UINT16              Reserved;
	UINT32              ApicId;
	UINT32	            Flags;
    UINT32              Uid;
} LX2APIC,*PLX2APIC;

//======================================================
//  IOAPIC Structure per each CPU  IA32
//======================================================
typedef	struct _IOAPIC_H32 {
    MADT_ENTRY_HEADER   Header;
	UINT8		        IoapicId;			//2
	UINT8		        Reserved;			//3
	UINT32	            IoapicAddress;		//4
	UINT32	            SysVectBase;		//8
} IOAPIC_H32,*PIOAPIC_H32, IOAPIC_H20,*PIOAPIC_H20;

//======================================================
//  ISO Interrupt Source Override Structure IA32
//======================================================
//  Should be present per each ISA Interrupt which
//  is not identity-mapped into SAPIC Interrupt space
//======================================================
typedef	struct _ISO_H32 {
    MADT_ENTRY_HEADER   Header;
	UINT8		        Bus;				//2
	UINT8		        Source;				//3
	UINT32	            GlobalSysVect;		//4
	UINT16	            Flags;				//8

} ISO_H20,*PISO_H20;

typedef	struct _LSAPIC_H20 {	
    MADT_ENTRY_HEADER   Header;		    
	UINT8			CpuId;				//2
	UINT8			LsapicId;			//3
	UINT8			LsapicEid;			//4
    UINT8           Reserved1;          //5
    UINT8           Reserved2;          //6
    UINT8           Reserved3;          //7
	UINT32			Flags;				//8 Same as MPS 1.4 
} LSAPIC_H20,*PLSAPIC_H20;

typedef	struct _LSAPIC_H30 {	
    MADT_ENTRY_HEADER   Header;
	UINT8			CpuId;				//2
	UINT8			LsapicId;			//3
	UINT8			LsapicEid;			//4
    UINT8           Reserved1;          //5
    UINT8           Reserved2;          //6
    UINT8           Reserved3;          //7
	UINT32			Flags;				//8 Same as MPS 1.4 
    UINT32          AcpiProcUidVal;      //12
    UINT8           AcpiProcUidString;   //16 This value could be bigger than 1 byte
    //------ To Do - Deal with variable length of AcpiProcUidString
} LSAPIC_H30,*PLSAPIC_H30;

typedef	struct _IOSAPIC_H20 {	
    MADT_ENTRY_HEADER   Header;
	UINT8			IoapicId;			//2
	UINT8			Reserved;			//3
	UINT32			SysVectBase;		//8
	UINT64			IosapicAddress;		//4
} IOSAPIC_H20,*PIOSAPIC_H20;

typedef struct _ISO_PARAMETER_TABLE{
	UINT8	PicIrq;
	UINT8	Flags; 
	UINT16	ApicInt;
}ISO_PARAMETER_TABLE;


typedef	struct _NMI_H20 {
    MADT_ENTRY_HEADER   Header;
	UINT16			Flags;				//2 same as MPS INTI flags 1.4
	UINT32			GlobalSysVect;		//4
} NMI_H20,*PNMI_H20;

typedef	struct _LNMI_H20 {
    MADT_ENTRY_HEADER   Header;
	UINT8			CPU_ID;				//2
	UINT16			Flags;				//3 same as MPS INTI flags 1.4
	UINT8			LapicIntin;			//5
} LNMI_H20,*PLNMI_H20;

typedef	struct _LX2APIC_NMI {
    MADT_ENTRY_HEADER   Header;
	UINT16			Flags;				//same as MPS INTI flags 1.4
    UINT32          Uid;
	UINT8			LapicIntin;
    UINT8           Reserved[3];
} LX2APIC_NMI,*PLX2APIC_NMI;


//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: MADT_ENTRIES
//
// Description: Structure for storing collected entries for MADT table before 
//              actualy building it. It is in the form of T_ITEM_LIST.
//
// Fields: Type             Name                    Description
//----------------------------------------------------------------------------
//    UINTN               MadtEntInitCount
//    UINTN               MadtEntCount
//    MADT_ENTRY_HEADER   **MadtEntries
// 
//----------------------------------------------------------------------------
//<AMI_THDR_END>
typedef	struct _MADT_ENTRIES {
    UINTN               MadtEntInitCount;
    UINTN               MadtEntCount;
    MADT_ENTRY_HEADER   **MadtEntries;

} MADT_ENTRIES;

//======================================================
//  Bits Description in FACS.GlobalLock field. ACPI 2.0
//======================================================
#define     GL_PENDING          0x01
#define     GL_OWNED			0x20

//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: ACPI_TBL_ITEM
//
// Description: Structure for storing pointers for ACPI tables and it's Version
//              Member of ACPI_DB
//
// Fields: Type             Name                    Description
//----------------------------------------------------------------------------
//    ACPI_HDR                *BtHeaderPtr
//    EFI_ACPI_TABLE_VERSION  AcpiTblVer
// 
//----------------------------------------------------------------------------
//<AMI_THDR_END>
typedef	struct _ACPI_TBL_ITEM {
    ACPI_HDR                *BtHeaderPtr;
    EFI_ACPI_TABLE_VERSION  AcpiTblVer;

} ACPI_TBL_ITEM;

//<AMI_THDR_START>
//----------------------------------------------------------------------------
// Name: ACPI_DB
//
// Description: Structure for storing ACPI tables and protocols during Boottime.
//              ACPI tables are stored in the form of T_ITEM_LIST.
//
// Fields: Type             Name                   Description
//----------------------------------------------------------------------------
//    UINTN                         AcpiInitCount
//    UINTN                         AcpiEntCount
//    ACPI_TBL_ITEM                 **AcpiEntries
//    UINT32                        AcpiLength
//    EFI_ACPI_TABLE_PROTOCOL       AcpiTableProtocol
//    EFI_ACPI_SUPPORT_PROTOCOL	    AcpiSupportProtocol
//	  EFI_HANDLE					AcpiSupportHandle
// 
//----------------------------------------------------------------------------
//<AMI_THDR_END>
typedef	struct _ACPI_DB {
    UINTN                       AcpiInitCount;
    UINTN                       AcpiEntCount;
    ACPI_TBL_ITEM               **AcpiEntries;
    UINT32                      AcpiLength;
    EFI_ACPI_TABLE_PROTOCOL     AcpiTableProtocol;
    EFI_ACPI_SUPPORT_PROTOCOL	AcpiSupportProtocol;
	EFI_HANDLE					AcpiSupportHandle;
#if defined(PI_SPECIFICATION_VERSION)&&(PI_SPECIFICATION_VERSION>=0x00010014)
    EFI_ACPI_SDT_PROTOCOL       AcpiSdtProtocol;
    UINTN                       NotifyInitCount;
    UINTN                       NotifyFnCount;
    EFI_ACPI_NOTIFICATION_FN    *AcpiNotifyFn;

//    UINTN                       SdtHndInitCount;
//    UINTN                       SdtHandleCount;
//    EFI_ACPI_NOTIFICATION_FN    *AcpiNotifyFn;
    EFI_AML_NODE_LIST           *AmlRootNode;
#endif
} ACPI_DB;

//Function Prototypes
UINTN FindAcpiTblByHandle (UINTN *Handle);



#pragma pack(pop)

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