summaryrefslogtreecommitdiff
path: root/Core/EM/ACPI
diff options
context:
space:
mode:
authorraywu <raywu0301@gmail.com>2018-06-15 00:00:50 +0800
committerraywu <raywu0301@gmail.com>2018-06-15 00:00:50 +0800
commitb7c51c9cf4864df6aabb99a1ae843becd577237c (patch)
treeeebe9b0d0ca03062955223097e57da84dd618b9a /Core/EM/ACPI
downloadzprj-b7c51c9cf4864df6aabb99a1ae843becd577237c.tar.xz
init. 1AQQW051HEADmaster
Diffstat (limited to 'Core/EM/ACPI')
-rw-r--r--Core/EM/ACPI/ACPICORE.CIF23
-rw-r--r--Core/EM/ACPI/AMLUPD.asl163
-rw-r--r--Core/EM/ACPI/ASLCORE.CIF37
-rw-r--r--Core/EM/ACPI/AcpiCore.c4475
-rw-r--r--Core/EM/ACPI/AcpiCore.h573
-rw-r--r--Core/EM/ACPI/AcpiS3.h170
-rw-r--r--Core/EM/ACPI/AcpiSdt.c821
-rw-r--r--Core/EM/ACPI/AcpiSdtPrivate.h798
-rw-r--r--Core/EM/ACPI/Aml.c350
-rw-r--r--Core/EM/ACPI/AmlChild.c326
-rw-r--r--Core/EM/ACPI/AmlNamespace.c659
-rw-r--r--Core/EM/ACPI/AmlOption.c500
-rw-r--r--Core/EM/ACPI/AmlString.c600
-rw-r--r--Core/EM/ACPI/AtadSmi.c254
-rw-r--r--Core/EM/ACPI/AtadSmi.cif12
-rw-r--r--Core/EM/ACPI/AtadSmi.dxs98
-rw-r--r--Core/EM/ACPI/AtadSmi.h91
-rw-r--r--Core/EM/ACPI/AtadSmi.mak82
-rw-r--r--Core/EM/ACPI/AtadSmi.sdl25
-rw-r--r--Core/EM/ACPI/CIR.ASL168
-rw-r--r--Core/EM/ACPI/Fdc.asl150
-rw-r--r--Core/EM/ACPI/GameMpu.asl185
-rw-r--r--Core/EM/ACPI/LM75.ASL179
-rw-r--r--Core/EM/ACPI/Lpte.asl199
-rw-r--r--Core/EM/ACPI/MAX1617L.ASL219
-rw-r--r--Core/EM/ACPI/MAX1617R.ASL222
-rw-r--r--Core/EM/ACPI/Mathco.asl50
-rw-r--r--Core/EM/ACPI/MpPciIrq.asm99
-rw-r--r--Core/EM/ACPI/OSCM.asl124
-rw-r--r--Core/EM/ACPI/PCIEACCESS.ASL170
-rw-r--r--Core/EM/ACPI/PCIEHP.ASL346
-rw-r--r--Core/EM/ACPI/PS2kb.asl121
-rw-r--r--Core/EM/ACPI/PS2ms.asl128
-rw-r--r--Core/EM/ACPI/RbRes.asl501
-rw-r--r--Core/EM/ACPI/SMB_EC.ASL91
-rw-r--r--Core/EM/ACPI/TimeAndAlarm.asl523
-rw-r--r--Core/EM/ACPI/Uart1.asl159
-rw-r--r--Core/EM/ACPI/Uart1ir.asl143
-rw-r--r--Core/EM/ACPI/Uart2.asl137
-rw-r--r--Core/EM/ACPI/Uart2ir.asl467
-rw-r--r--Core/EM/ACPI/Uart3.asl103
-rw-r--r--Core/EM/ACPI/Uart3ir.asl127
-rw-r--r--Core/EM/ACPI/Uart4.asl109
-rw-r--r--Core/EM/ACPI/Uart4ir.asl128
-rw-r--r--Core/EM/ACPI/asllib.asl325
-rw-r--r--Core/EM/ACPI/game.asl101
-rw-r--r--Core/EM/ACPI/irda.asl115
-rw-r--r--Core/EM/ACPI/midi.asl124
-rw-r--r--Core/EM/ACPI/mptable.c1553
-rw-r--r--Core/EM/ACPI/mptable.h593
-rw-r--r--Core/EM/ACPI/rmisc.asl120
51 files changed, 17836 insertions, 0 deletions
diff --git a/Core/EM/ACPI/ACPICORE.CIF b/Core/EM/ACPI/ACPICORE.CIF
new file mode 100644
index 0000000..7278965
--- /dev/null
+++ b/Core/EM/ACPI/ACPICORE.CIF
@@ -0,0 +1,23 @@
+<component>
+ name = "ACPI - Core"
+ category = ModulePart
+ LocalRoot = "Core\EM\ACPI\"
+ RefName = "ACPI_CORE"
+[files]
+"AcpiCore.c"
+"AcpiCore.h"
+"mptable.c"
+"mptable.h"
+"MpPciIrq.asm"
+"AcpiS3.h"
+"Aml.c"
+"AmlChild.c"
+"AmlNamespace.c"
+"AmlOption.c"
+"AmlString.c"
+"AcpiSdt.c"
+"AcpiSdtPrivate.h"
+[parts]
+"ASL_CORE"
+"AtadSmi"
+<endComponent>
diff --git a/Core/EM/ACPI/AMLUPD.asl b/Core/EM/ACPI/AMLUPD.asl
new file mode 100644
index 0000000..112797c
--- /dev/null
+++ b/Core/EM/ACPI/AMLUPD.asl
@@ -0,0 +1,163 @@
+// OEM ASL file. Defines ASL Name fields to be linked to AML Exchange bufer location
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/AMLUPD.asl 10 10/14/10 4:59p Oleksiyy $
+//
+// $Revision: 10 $
+//
+// $Date: 10/14/10 4:59p $
+//
+//****************************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/AMLUPD.asl $
+//
+// 10 10/14/10 4:59p Oleksiyy
+// [TAG] EIP46166
+// [Category] Improvement
+// [Description] Fix to made Primary VGA selection on different Root
+// Bridges backward compatible with Core 4.6.4.0.
+// [Files] AMLUPD.asl, RbRes.asl
+//
+// 9 9/28/09 6:35p Yakovlevs
+// Changes to support Multy Root resource reporting features.
+// All PCI ROOT resource reporting features moved to RbRes.asl
+//
+// 8 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 7 6/28/05 5:22p Yakovlevs
+//
+// 6 6/03/05 2:42p Yakovlevs
+//
+// 5 5/31/05 12:09p Yakovlevs
+//
+// 4 5/27/05 5:57p Yakovlevs
+//
+// 3 5/18/05 11:49a Yakovlevs
+//
+// 2 5/05/05 7:11p Yakovlevs
+//
+// 3 5/05/05 5:39p Yakovlevs
+//
+// 2 4/28/05 2:51p Yakovlevs
+//
+// 1 4/25/05 10:56a Markw
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:42p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 8 7/17/02 12:13p Alexp
+// Add example of code to report memory above 4GB. Code is commented out.
+//
+// 7 6/10/02 11:53a Alexp
+// Delete IO APIC related ranges from AMLdata buffer. Use ACPI SDL
+// parameters to provide same ranges.
+//
+// 6 5/17/02 11:01a Alexp
+// Removed several names (SPIO, PMBS,..) as they were defined as static
+// equates and can be passed to ASL from SDL outut directly, not using
+// Aml_exchange buffer
+//
+// 5 3/20/02 11:54a Alexp
+//
+// 4 2/26/02 12:16p Alexp
+// Update headers to generate proper .chm help
+//
+// 3 11/05/01 1:23p Alexp
+// Remove Thermal variables from Template AML_Exchange buffer
+//
+// 2 11/01/01 9:50a Alexp
+//
+//----------------------------------------------------------------------
+
+
+//;<AMI_THDR_START>
+//;------------------------------------------------------------------------/
+//;
+//; Name: BIOS
+//;
+//; Type: OperationRegion
+//;
+//; Description: Set of name objects used as an exchange buffer for BIOS to
+//; pass the System information to AML code
+//; List of mandatory Name Objects to be defined:
+//; SS1 - SS4 - BIOS setup enabled sleep states.
+//; MG1B, MG1L - Non-shadowed memory range below 1Mb. Available for PCI0 bus.
+//; MG2B, MG2L - Memory range above available System memory. Available for PCI0 bus.
+//;
+//; Notes: Memory location and all Name values are updated in BIOS POST
+//; Referrals: AMLDATA
+//;-------------------------------------------------------------------------
+//;<AMI_THDR_END>
+
+///////////////////////////////////////////////////////////////////////////////////
+//Values are set like this to have ASL compiler reserve enough space for objects
+///////////////////////////////////////////////////////////////////////////////////
+// Available Sleep states
+Name(SS1,1) // is S1 enabled in setup?
+Name(SS2,0)
+Name(SS3,1)
+Name(SS4,1)
+///////////////////////////////////////////////////////////////////////////////////
+// Bit mask of statuses of IO peripheral devices, enabled in Setup
+// 0x0 - Serial A (Modem)
+// 1 - Serial B (IR)
+// 2 - LPT
+// 3 - FDD
+//----------------------------
+// 4 - SB16 Audio
+// 5 - Midi
+// 6 - Mss Audio
+// 7 - Adlib sound (FM synth)
+//----------------------------
+// 8 - Game 1 port
+// 9 - Game 2 port
+// a - KBC 60 & 64
+// b - EC 62 & 66
+//----------------------------
+// c - reserved
+// d - reserved
+// e - PS2Mouse
+// f - reserved
+///////////////////////////////////////////////////////////////////////////////////
+Name(IOST,0xFFFF) // Bit mask of statuses of IO peripheral devices,
+ // enabled in Setup
+///////////////////////////////////////////////////////////////////////////////////
+Name(TOPM,0xFFFFF) // System memory top address below 4GB, bytes
+
+///////////////////////////////////////////////////////////////////////////////////
+Name(ROMS,0xffe00000) // Boot strap BIOS image address at top 4Gbyte
+
+///////////////////////////////////////////////////////////////////////////////////
+Name(VGAF, 0x1) //Flag to indicate Legacy VGA Resources were clamed already
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//********************************************************************** \ No newline at end of file
diff --git a/Core/EM/ACPI/ASLCORE.CIF b/Core/EM/ACPI/ASLCORE.CIF
new file mode 100644
index 0000000..7a3fe18
--- /dev/null
+++ b/Core/EM/ACPI/ASLCORE.CIF
@@ -0,0 +1,37 @@
+<component>
+ name = "ASL - CORE"
+ category = ModulePart
+ LocalRoot = "CORE\EM\ACPI\"
+ RefName = "ASL_CORE"
+[files]
+"\Uart4ir.asl"
+"\Uart4.asl"
+"\Uart3ir.asl"
+"\Uart3.asl"
+"\Uart2ir.asl"
+"\Uart2.asl"
+"\Uart1ir.asl"
+"\Uart1.asl"
+"\SMB_EC.ASL"
+"\PS2ms.asl"
+"\PS2kb.asl"
+"\midi.asl"
+"\MAX1617R.ASL"
+"\MAX1617L.ASL"
+"\Mathco.asl"
+"\Lpte.asl"
+"\LM75.ASL"
+"\irda.asl"
+"\GameMpu.asl"
+"\game.asl"
+"\Fdc.asl"
+"\CIR.ASL"
+"\rmisc.asl"
+"\AMLUPD.asl"
+"\asllib.asl"
+"\OSCM.asl"
+"\PCIEACCESS.ASL"
+"\PCIEHP.ASL"
+"\RbRes.asl"
+"\TimeAndAlarm.asl"
+<endComponent>
diff --git a/Core/EM/ACPI/AcpiCore.c b/Core/EM/ACPI/AcpiCore.c
new file mode 100644
index 0000000..7cb3366
--- /dev/null
+++ b/Core/EM/ACPI/AcpiCore.c
@@ -0,0 +1,4475 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/Projects/Intel/Haswell/LynxPoint_SharkBay-DT_Crb_1AQQW/Core/EM/ACPI/AcpiCore.c 9 4/16/14 6:17a Chaseliu $
+//
+// $Revision: 9 $
+//
+// $Date: 4/16/14 6:17a $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/Projects/Intel/Haswell/LynxPoint_SharkBay-DT_Crb_1AQQW/Core/EM/ACPI/AcpiCore.c $
+//
+// 9 4/16/14 6:17a Chaseliu
+// sync to ACPI module 48
+//
+// 8 9/18/13 4:06a Thomaschen
+// Update for ACPI module labeled 47.
+//
+// 108 3/14/14 10:42a Oleksiyy
+// [TAG] EIP121819
+// [Category] Improvement
+// [Description] Add FID acpi table. filling of Tbl_IDs up to date.
+// [Files] AcpiCore.c.
+//
+// 107 3/03/14 5:02p Oleksiyy
+// [TAG] EIP154308
+// [Category] Improvement
+// [Description] Aptio 4: Intel Doc #542550 4h) FirmwarePerformance EFI
+// variable contains address of FPDT ACPI table.
+// [Files] AcpiCore.c and S3Resume.c
+//
+// 106 1/23/14 5:38p Oleksiyy
+// [TAG] EIP113941
+// [Category] New Feature
+// [Description] Time and Alarm ACPI device implemented.
+// [Files] AcpiCore.c
+// ACPICORE.CIF
+//
+// 105 10/28/13 12:05p Oleksiyy
+// [TAG] EIP121819
+// [Category] Improvement
+// [Description] Add FID acpi table.
+// [Files] AcpiCore.c, AcpiCore.h
+//
+// 104 10/04/13 11:55a Oleksiyy
+// [TAG] EIP138574
+// [Category] Improvement
+// [Description] Assert in LockLegacyRes removed.
+// [Files] AcpiCore.c
+//
+// 103 8/12/13 4:07p Oleksiyy
+// [TAG] EIP132574
+// [Category] Improvement
+// [Description] When checking address range && replaced with & to save
+// memory.
+// [Files] AcpiCore.c
+//
+// 102 8/01/13 6:00p Oleksiyy
+// [TAG] EIP130457
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] System hang up 78h and BSOD issue after enter OS when
+// enable X64 support
+// [RootCause] hen only RSDT is validayted by OS and DSDT was located
+// above 4Gig and then typecasted to UINT32 addres info was lost.
+// [Solution] Allocate memory for DSDT always under 4 Gig.
+// [Files] AcpiCore.c
+//
+// 101 6/03/13 5:05p Oleksiyy
+// [TAG] EIP125666
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Wrong typecasting in Registernotify function.
+// [RootCause] Wrong typecasting in Registernotify function.
+// [Solution] Typecastnig removed.
+// [Files] AcpiCore.c
+//
+// 100 12/13/12 11:59a Oleksiyy
+// [TAG] EIP109290
+// [Category] Improvement
+// [Description] Issues found by CppCheck in ACPI eModule
+// [Files] AcpiCore.c, mptable.c, AmlString.c, BootScriptSave.c and
+// BootScriptExecuter.c
+//
+// 99 11/19/12 6:01p Oleksiyy
+// [TAG] EIP101547
+// [Category] New Feature
+// [Description] Support Uninstalling MADT with ACPI Table Protocol
+// [Files] AcpiCore.c
+//
+// 98 6/12/12 3:17p Oleksiyy
+// TAG] EIP90322
+// [Category] Improvement
+// [Description] Extern declaradion of gAmiGlobalVariableGuid moved to
+// AmiLib.h.
+// [Files] AmiLib.h, Misc.c, EfiLib.c, AcpiCore.c and S3Resume.c
+//
+// 97 6/12/12 11:16a Oleksiyy
+// [TAG] EIP88889
+// [Category] Improvement
+// [Description] FACP ver 5.0 structure added, FPDT mesurment accuracy
+// improved.
+// [Files] ACPI50.h, ACPI.sdl, AcpiCore.c, S3Resume.c, Image.c,
+// EfiLib.c
+//
+// 96 5/22/12 4:33p Oleksiyy
+// [TAG] EIP90322
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] ChiefRiver SCT Fail, improper variable FPDT_Variable in
+// ACPI module
+// [RootCause] EFI_GLOBAL_VARIABLE guid is used in non EFI defined
+// variable.
+// [Solution] New guig AMI_GLOBAL_VARIABLE_GUID is created and used.
+// [Files] AmiLib.h, Misc.c, EfiLib.c, AcpiCore.c and S3Resume.c
+//
+// 95 5/04/12 10:48a Oleksiyy
+// [TAG] EIP88478
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] ACPI error when booting to Windows with 4G+ memory
+// [RootCause] "x64_BUILD_SUPPORT" not defined
+// [Solution] Change to EFIx64 identifier.
+// [Files] AcpiCore.c
+//
+// 94 4/12/12 11:53a Oleksiyy
+// [TAG] EIP86325
+// [Category] Improvement
+// [Description] Disabling PciExpNative in BIOS setup doesn't cause bit
+// 4 in IAPC_BOOT_ARCH to be set.
+// Bit preservation is added.
+// [Files] AcpiCore.c
+//
+// 93 12/05/11 4:24p Oleksiyy
+// [TAG] EIP64296
+// [Category] New Feature
+// [Description] Increasing of whole table length after adding FPDT was
+// skiped by mistake. Fixed
+// [Files] AcpiCore.c.
+//
+// 92 11/28/11 5:34p Oleksiyy
+// [TAG] EIP76419
+// [Category] Improvement
+// [Description] TPL level chang to TPL_APPLICATION removed in ACPI
+// Table Protocol functions
+// [Files] AcpiCore.c
+//
+// 90 11/11/11 5:10p Oleksiyy
+// [TAG] EIP64296
+// [Category] New Feature
+// [Description] Creation and filling of Firmware Performance Data Table
+// is added. FirmPerfDataTab.h renamed to ACPI50.h
+// [Files] AcpiCore.c, EfiLib.c, S3Resume.c and ACPI50.h added.
+//
+// 89 11/08/11 4:52p Oleksiyy
+// [TAG] EIP64296
+// [Category] New Feature
+// [Description] Creation and filling of Firmware Performance Data Table
+// is added.
+// [Files] AcpiCore.c, AmiDxeLib.h, CSM.c, DxeMain.c, EfiLib.c,
+// Image.c, S3Resume.c and FirmPerfDataTab.h
+//
+// 88 10/25/11 5:54p Oleksiyy
+// [TAG] EIP71540
+// [Category] Improvement
+// [Description] Fix of "any amount of spaces in table IDs replaced with
+// only one".
+// [Files] ACPI.mak and AcpiCore.c
+//
+// 87 9/30/11 4:23p Oleksiyy
+// [TAG] EIP71374
+// [Category] Improvement
+// [Description] ACPI sleep state setup option update.
+// [Files] ACPI.sd, ACPI.uni and AcpiCore.c
+//
+// 86 8/30/11 4:04p Oleksiyy
+// [TAG] EIP67951
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] BGRT Table does not exist in XSDT
+// [RootCause] Due to bug in OEM Activation routine last table in XSDT
+// was deleted.
+// [Solution] Wrong else statment fixed.
+// [Files] AcpiCore.c
+//
+// 85 7/19/11 11:31a Oleksiyy
+// [TAG] EIP64108
+// [Category] Improvement
+// [Description] ACPI, convert or update all eModules to be compliant
+// with PI 1.2, and UEFI 2.3.1 specifications.
+// [Files] AcpiCore.c, mptable.c, AcpiS3Save.c, S3Resume.dxs,
+// S3Resume.c, AcpiPeiS3Func.c, BootScriptExecuter.c and DxeIpl.c
+//
+// 84 6/10/11 5:10p Oleksiyy
+// [TAG] EIP60372
+// [Category] Improvement
+// [Description] Conformance fix in Uninstall Table function.
+// [Files] AcpiCore.c
+//
+// 83 5/27/11 5:32p Felixp
+// Enhancement: AcpiInstallAcpiTable/ AcpiUninstallAcpiTable are updated.
+// CONST qualifier is added to the parameters to match the specification.
+//
+// 82 5/20/11 2:39p Oleksiyy
+// [TAG] EIP60633
+// [Category] New Feature
+// [Description] Acpi part of Microsoft OEM Activation 3.0
+// [Files] AcpiCore.c
+//
+// 81 5/18/11 5:15p Oleksiyy
+// [TAG] EIP60634
+// [Category] Improvement
+// [Description] Small fix in Install table functionality
+// [Files] AcpiCore.c
+//
+// 80 5/14/11 2:47p 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.
+//
+// 79 4/06/11 6:01p Markw
+// [TAG] EIP53334
+// [Category] Spec Update
+// [Severity] Normal
+// [Description] CPU module provide NMI information if protocol
+// available. This is to properly support x2APIC NMI structures.
+// [Files] AcpiCore.c
+//
+// 78 3/16/11 12:07p Oleksiyy
+// [TAG] EIP56178
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Assert on Legacy free systems
+// [RootCause] The function LockLegacyRes() will assert if it cannot
+// find any handles that have the gEfiAmiSioProtocolGuid installed on
+// them.
+// [Solution] Assert removed from LockLegacyRes function.
+// [Files] AcpiCore.c
+//
+// 77 3/03/11 6:09p Oleksiyy
+// [TAG] EIP55071
+// [Category] New Feature
+// [Description] APIC/SAPIC Differentiation Algorithm Not Working for
+// AMD I/O APIC
+// Sdl tokens are added to set set IOAPIC/IOSAPIC and LAPIC/LSAPIC
+// revision BOUNDARY.
+// [Files] ACPI.sdl and AcpiCore.c
+//
+// 76 1/03/11 10:46a Oleksiyy
+// [TAG] EIP49202
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] System hang at CKP 0x9A
+// [RootCause] System hang at CKP 0x9A if memory is up to 4GB or above
+// and token "x64_BUILD" = 0, "DEBUG_MODE" = 1.
+// [Solution] gRsdtPtrStr typecasted to UINTN before typecasting to
+// EFI_PHYSICAL_ADDRESS.
+// [Files] AcpiCore.c
+//
+// 75 12/23/10 12:02p Oleksiyy
+// [TAG] EIP50019
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] Add support for all fields of ACPI_IA_BOOT_ARCH flag in
+// FACP
+// [RootCause] All values of ACPI_IA_BOOT_ARCH flag, added in ACPI 4
+// spec, is cleared during updating of LEGACY_DEVICES and 8042 fields in
+// CollectAmlUpdInfo routine.
+// [Solution] AcpiCore.c file modified to preserve values of
+// ACPI_IA_BOOT_ARCH flag set in sdl file.
+// [Files] AcpiCore.c and ACPI.sdl
+//
+// 74 12/17/10 5:14p Oleksiyy
+// [TAG] EIP50325
+// [Category] Bug Fix
+// [Severity] Minor
+// [Symptom] Incorrect order of MADT entries for Agesa projects
+// [RootCause] Dummy entries placed before active cores in MADT table
+// [Solution] Token SKIP_DUMMY_LAPICS should be added to any .sdl file
+// to force AcpiCore not to create dummy lapics entires for processors
+// that are absent, but could be hot plugged.
+// Also, BuildLapic function changed and now dummy lapics will have higher
+// Id.
+// [Files] AcpiCore.c
+//
+// 73 10/11/10 5:52p Oleksiyy
+// Healp builder error - Function Header Fixed.
+//
+// 72 10/01/10 11:55a Oleksiyy
+// Issue Number: 45160
+//
+// Category: Improvement
+//
+// Description: AcpiSupportSetAcpiTable function was modified to checksum
+// table, after it was changed by OemAcpiSetPlatformId hook, if Checksum
+// parameter of SetAcpiTable function is FALSE, but table was correctly
+// checksumed before call to OemAcpiSetPlatformId hook.
+//
+// Files: AcpiCore.c
+//
+// 71 9/27/10 11:56a Oleksiyy
+// Issue Number: 44740
+//
+// Category: Improvement
+//
+// Description: Functionality to Publish all tables, added on ReadyToBoot
+// through EFI_ACPI_SUPPORT_PROTOCOL, automatically
+// is added.
+//
+// Files: AcpiCore.c
+//
+// 70 5/25/10 11:07a Oleksiyy
+// Assert in publish tables fixed
+//
+// 69 4/28/10 2:46p Oleksiyy
+// EIP 35563 "Force to ACPI ver. 1.1" ACPI setup menu (default is OFF)
+// added. If Enabled - only Tables for ver. 1.1 will be builded (FACP,
+// FACS,
+// RSDT (no XSDT), and MADT) al other tables added by means of
+// ACPI protocols not modified.
+// EIP 37874 - ACPI_APIC_TBL token added if OFF - MADT will not
+// created (PIC mode).
+//
+// 68 4/05/10 4:46p Oleksiyy
+// EIP 37055 - TPL check added. + Some spelling issues fixed.
+//
+// 67 2/19/10 12:24p Oleksiyy
+// EIP 35099: Functionality to lock legacy resources from OS added,
+// based on setup question. Default value controlled by
+// DEFAULT_ACPI_LOCK_LEGACY_DEV SDL token and "OFF".
+//
+// 66 2/02/10 2:45p Oleksiyy
+// EIP 32520 Update AML part function is changed to perform update
+// before publishing table. Freepool assert when trying to delete old
+// DSDT fixed.
+//
+// 65 12/08/09 11:41a Oleksiyy
+// Minor bug fix in typecasting
+//
+// 64 11/24/09 5:20p Oleksiyy
+// EIP 27605: Added ACPI 4.0 support.
+//
+// 63 9/28/09 6:32p Yakovlevs
+// Changes to support Multy Root resource reporting features.
+// All PCI ROOT resource reporting features moved to PciHootBridge.c.
+//
+// 62 9/25/09 11:24a Oleksiyy
+// EIP 26777: RSDP Revision fixed
+//
+// 61 8/20/09 3:02p Oleksiyy
+// EIP 25407: 32 bit mode bug fix
+//
+// 60 8/11/09 3:39p Markw
+// EIP #24914 - Add local x2APIC support.
+//
+// 59 5/27/09 5:39p Yakovlevs
+// Fixed inconsistancy in SetAcpiTable Routine.
+//
+// 58 5/26/09 1:44p Yakovlevs
+// Fixed Issues in Pointers handling in SetAcpiTable fubction
+//
+// 57 5/18/09 10:09a Yakovlevs
+// Fixed issue in sorting IOAPICs entries.
+//
+// 56 5/15/09 12:49p Yakovlevs
+// Fixed logic in IOAPIC discovery ordering.
+//
+// 55 5/14/09 5:36p Yakovlevs
+// Minor bug fixes and Improvements see release notes for Label 31
+//
+// 54 5/08/09 1:15p Yakovlevs
+// Made ACPI Driver use AMI Board Info Protocol if available without
+// breaking compatibility.
+//
+// 53 5/07/09 5:46p Markw
+// Use #ifdef ACPI_INFO2_PROTOCOL_PUBLISHED to exclude code that uses ACPI
+// INFO 2 for CPUs that provide the header files.
+//
+// 52 5/04/09 5:48p Markw
+// EIP #17903 Use AmiCpuInfo2 Protocol if available. Small bug fixes from
+// last update.
+//
+// 51 4/30/09 5:51p Markw
+// EIP #17903 Use AmiCpuInfo2 Protocol if available. This provides correct
+// ordering for Nehalem in APIC table.
+//
+// 50 4/27/09 5:39p Oleksiyy
+// EIP 21205 - Win XP (SP2) instalation problem fix. Added compatibility
+// fields in FACP Ver 1.
+//
+// 49 4/14/09 11:13a Oleksiyy
+// Removed one ASSERT.
+//
+// 48 3/27/09 4:09p Oleksiyy
+// Code clean-up.
+//
+// 47 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
+//
+// 1 3/18/07 5:23p Felixp
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: <AcpiCore.c>
+//
+// Description: Main ACPI Driver File. It has ACPI Driver entry point,
+// ACPISupport Protocol and ACPITable Protocol.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#include <AmiDxeLib.h>
+#if PI_SPECIFICATION_VERSION >= 0x10014
+#include <Protocol\SuperIo.h>
+#else
+#include <Protocol\AmiSio.h>
+#endif
+#include <Protocol\DevicePath.h>
+#include <AMIHobs.h>
+#include <token.h>
+#include <Dxe.h>
+#include <AcpiRes.h>
+#include "AcpiCore.h"
+#include <Setup.h>
+#include "AcpiOemElinks.h"
+#include "ACPI50.h"
+#include <Ppi\FwVersion.h>
+#if ATAD_SUPPORT == 1
+#include "AtadSmi.h"
+#endif
+#ifdef ACPI_INFO2_PROTOCOL_PUBLISHED
+#include <Protocol\AmiCpuInfo2.h>
+#endif
+
+
+#include <Protocol\AmiBoardInfo.h>
+#include <Protocol/Cpu.h>
+ // [EIP106575], [EIP106731]>
+#include <Protocol/MpService.h>
+ // <[EIP106575], [EIP106731]
+EFI_GUID gAmiBoardInfoGuid = AMI_BOARD_INFO_PROTOCOL_GUID;
+AMI_BOARD_INFO_PROTOCOL *gAmiBoardInfoProtocol=NULL;
+
+//--------------------------------------
+//Some Global vars
+EFI_GUID gDsdt11Guid = EFI_ACPI_DSDT_V_1_1_GUID;
+EFI_GUID gDsdt20Guid = EFI_ACPI_DSDT_V_2_0_GUID;
+//EFI_GUID gDPProtocolGuid = EFI_DEVICE_PATH_PROTOCOL_GUID;
+//EFI_GUID gSioProtocolGuid = EFI_AMI_SIO_PROTOCOL_GUID;
+EFI_GUID gSetupGuid = SETUP_GUID;
+
+#ifdef ACPI_INFO2_PROTOCOL_PUBLISHED
+AMI_CPU_INFO_2_PROTOCOL* gAmiCpu2Info;
+EFI_GUID gAmiCpuInfo2ProtocolGuid = AMI_CPU_INFO_2_PROTOCOL_GUID;
+#endif
+
+ACPI_DB gAcpiData = {0, 0, NULL, 0};
+FACS_20 *gFacs, *gxFacs;
+RSDT_PTR_20 *gRsdtPtrStr = NULL;
+UINTN gAcpiTblPages = 0;
+ACPI_AML_UPD_INFO *gAuiGlob = NULL;
+UINT16 gAcpiIaBootArch=0xFFFF;
+EFI_EVENT gEvtReadyToBoot;
+EFI_GUID gAcpi11TAbleGuid = EFI_ACPI_11_TABLE_GUID;
+EFI_GUID gAcpi20TAbleGuid = EFI_ACPI_20_TABLE_GUID;
+BOOLEAN gX2Apic = FALSE;
+UINT8 gForceAcpi1 = 0, gPublishedOnReadyToBoot = 0, gMaxLapic = 0;
+
+//Here goes Interrupt Source Override MADT entry parameter table
+//Generated From Information on IRQ_XX_OVERRIDE_ENABLE SDL tokens
+ISO_PARAMETER_TABLE IsoTbl[]=
+{
+//UINT8 PicIrq; UINT8 Flags; UINT16 ApicInt
+#if IRQ_00_OVERRIDE_ENABLE == 1
+ { 0x00, (IRQ_00_TRIGGER_MODE<<2)|IRQ_00_POLARITY, IRQ_00_APIC_INT },
+#else
+ { 0xFF, 0, 0 },
+#endif
+#if IRQ_01_OVERRIDE_ENABLE == 1
+ { 0x01, (IRQ_01_TRIGGER_MODE<<2)|IRQ_01_POLARITY, IRQ_01_APIC_INT },
+#else
+ { 0xFF, 0, 1 },
+#endif
+//just dummy entry instead of IRQ2 to keep array consistent
+ { 0xFF, 0, 2 },
+#if IRQ_03_OVERRIDE_ENABLE == 1
+ { 0x03, (IRQ_03_TRIGGER_MODE<<2)|IRQ_03_POLARITY, IRQ_03_APIC_INT },
+#else
+ { 0xFF, 0, 3 },
+#endif
+#if IRQ_04_OVERRIDE_ENABLE == 1
+ { 0x04, (IRQ_04_TRIGGER_MODE<<2)|IRQ_04_POLARITY, IRQ_04_APIC_INT },
+#else
+ { 0xFF, 0, 4 },
+#endif
+#if IRQ_05_OVERRIDE_ENABLE == 1
+ { 0x05, (IRQ_05_TRIGGER_MODE<<2)|IRQ_05_POLARITY, IRQ_05_APIC_INT },
+#else
+ { 0xFF, 0, 5 },
+#endif
+#if IRQ_06_OVERRIDE_ENABLE == 1
+ { 0x06, (IRQ_06_TRIGGER_MODE<<2)|IRQ_06_POLARITY, IRQ_06_APIC_INT },
+#else
+ { 0xFF, 0, 6 },
+#endif
+#if IRQ_07_OVERRIDE_ENABLE == 1
+ { 0x07, (IRQ_07_TRIGGER_MODE<<2)|IRQ_07_POLARITY, IRQ_07_APIC_INT },
+#else
+ { 0xFF, 0, 7 },
+#endif
+
+#if IRQ_08_OVERRIDE_ENABLE == 1
+ { 0x08, (IRQ_08_TRIGGER_MODE<<2)|IRQ_08_POLARITY, IRQ_08_APIC_INT },
+#else
+ { 0xFF, 0, 8 },
+#endif
+#if IRQ_09_OVERRIDE_ENABLE == 1
+ { 0x09, (IRQ_09_TRIGGER_MODE<<2)|IRQ_09_POLARITY, IRQ_09_APIC_INT },
+#else
+ { 0xFF, 0, 9 },
+#endif
+#if IRQ_10_OVERRIDE_ENABLE == 1
+ { 0x0A, (IRQ_10_TRIGGER_MODE<<2)|IRQ_10_POLARITY, IRQ_10_APIC_INT },
+#else
+ { 0xFF, 0, 10 },
+#endif
+#if IRQ_11_OVERRIDE_ENABLE == 1
+ { 0x0B, (IRQ_11_TRIGGER_MODE<<2)|IRQ_11_POLARITY, IRQ_11_APIC_INT },
+#else
+ { 0xFF, 0, 11 },
+#endif
+#if IRQ_12_OVERRIDE_ENABLE == 1
+ { 0x0C, (IRQ_12_TRIGGER_MODE<<2)|IRQ_12_POLARITY, IRQ_12_APIC_INT },
+#else
+ { 0xFF, 0, 12 },
+#endif
+#if IRQ_13_OVERRIDE_ENABLE == 1
+ { 0x0D, (IRQ_13_TRIGGER_MODE<<2)|IRQ_13_POLARITY, IRQ_13_APIC_INT },
+#else
+ { 0xFF, 0, 13 },
+#endif
+#if IRQ_14_OVERRIDE_ENABLE == 1
+ { 0x0E, (IRQ_14_TRIGGER_MODE<<2)|IRQ_14_POLARITY, IRQ_14_APIC_INT },
+#else
+ { 0xFF, 0, 14 },
+#endif
+#if IRQ_15_OVERRIDE_ENABLE == 1
+ { 0x0F, (IRQ_15_TRIGGER_MODE<<2)|IRQ_15_POLARITY, IRQ_15_APIC_INT },
+#else
+ { 0xFF, 0, 15 },
+#endif
+};
+
+static UINTN IsoCnt=sizeof(IsoTbl)/sizeof(ISO_PARAMETER_TABLE);
+
+EFI_STATUS MpsTableBuilderInit(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+);
+
+MADT_ENTRY_HEADER * BuildLocalApicNmi(
+ IN BOOLEAN X2Apic,
+ IN UINT32 ProcessorId,
+ IN UINT8 LapicInitIn,
+ IN UINT16 Flags
+ );
+
+UINT8 ACPI_OEM_ID[6] = ACPI_OEM_ID_MAK; //"A M I"; //add 0 at the end.OemId 6 bytes
+UINT8 ACPI_OEM_TBL_ID[8] = ACPI_OEM_TBL_ID_MAK; //"ALASKA"; //add 0 at the end.OemTableId 8 bytes
+
+#if defined(OemActivation_SUPPORT) && (OemActivation_SUPPORT == 1)
+#define EFI_OA3_MSDM_VARIABLE L"OA3MSDMvariable"
+
+typedef struct _EFI_OA3_MSDM_STRUCTURE {
+ EFI_PHYSICAL_ADDRESS XsdtAddress;
+ EFI_PHYSICAL_ADDRESS MsdmAddress;
+ EFI_PHYSICAL_ADDRESS ProductKeyAddress;
+} EFI_OA3_MSDM_STRUCTURE;
+
+BOOLEAN gOA3Variable = FALSE;
+EFI_OA3_MSDM_STRUCTURE gMsdmVariable;
+#endif
+
+#if ATAD_SUPPORT == 1
+ VOID *AtadBuffPtr = NULL;
+#endif
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: MemCopy
+//
+// Description: This routine copies data from source to destination.
+//
+// Input:
+// fpSrc - Pointer to the source.
+// fpDest - Pointer to the destination.
+// wSize - Number of bytes to copy.
+//
+// Output: None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+VOID
+MemCopy (
+ UINT8* fpSrc,
+ UINT8* fpDest,
+ UINT32 dSize)
+{
+ UINT32 dCount;
+
+ //
+ // Check for pointer validity
+ //
+ if ((fpSrc) && (fpDest))
+ {
+ for (dCount = 0; dCount < dSize; dCount++)
+ {
+ fpDest[dCount] = fpSrc[dCount];
+ }
+ }
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PrepareHdr20
+//
+// Description:
+// This function creates ACPI table v 2.0+ header with specified signature
+//
+// Input:
+// IN UINT32 TblSig - ACPI table signature
+// IN OUT ACPI_HDR* HdrPtr - Pointer to memory, where the header should be placed
+//
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+void PrepareHdr20(UINT32 TblSig, ACPI_HDR *HeaderPtr, UINTN Vers)
+{
+ UINTN i;
+ EFI_STATUS Status;
+
+ if (HeaderPtr==NULL) return;
+
+ HeaderPtr->Signature=TblSig;
+
+ //Check what Revision# header needs depends on TABLE we're building
+ switch (TblSig)
+ {
+ case RSDT_SIG:
+ HeaderPtr->Revision=ACPI_REV1;
+ HeaderPtr->CreatorRev=CREATOR_REV_MS+1;
+ break;
+
+ case XSDT_SIG:
+ HeaderPtr->Revision=ACPI_REV1;
+ HeaderPtr->CreatorRev=CREATOR_REV_MS+2;
+ break;
+
+ case FACP_SIG:
+ HeaderPtr->Revision=ACPI_REV3;
+ HeaderPtr->CreatorRev=CREATOR_REV_MS+3;
+
+ if (Vers > 2)
+ {
+
+ HeaderPtr->Revision=ACPI_REV4;
+ HeaderPtr->CreatorRev++;
+ }
+
+ break;
+ case APIC_SIG:
+ HeaderPtr->Revision=ACPI_REV1;
+ HeaderPtr->CreatorRev=CREATOR_REV_MS+4;
+
+ if (Vers > 2)
+ {
+
+ HeaderPtr->Revision=ACPI_REV2;
+ HeaderPtr->CreatorRev++;
+ }
+
+ if (Vers > 3)HeaderPtr->Revision=ACPI_REV3;
+
+ break;
+ case SBST_SIG:
+ HeaderPtr->Revision=ACPI_REV1;
+ break;
+ case SPCR_SIG:
+ HeaderPtr->Revision=ACPI_REV1;
+ break;
+ case ECDT_SIG:
+ HeaderPtr->Revision=ACPI_REV1;
+ break;
+ //case DSDT_SIG:
+ //HeaderPtr->CreatorRev=CREATOR_REV_MS+5;
+ //HeaderPtr->Revision=ACPI_REV2;
+ break;
+ }
+
+ //instead of puting fixed revision number
+ //HeaderPtr->Revision=ACPI_REV2;
+
+ //Dont' touch Creator ID and Creator Revision;
+ if (TblSig != DSDT_SIG)
+ {
+ if (TblSig == RSDT_SIG)
+ HeaderPtr->CreatorId = CREATOR_ID_MS;
+ else
+ HeaderPtr->CreatorId = CREATOR_ID_AMI;
+
+ HeaderPtr->CreatorRev = CREATOR_REV_MS;
+ HeaderPtr->OemRev = ACPI_OEM_REV;
+ }
+
+ //Get the platform specific OEM_IDs
+ Status=OemAcpiSetPlatformId(HeaderPtr);
+
+ //if platform does not support OEM_ID overwrite
+ if (EFI_ERROR(Status))
+ {
+ for (i=0; i<6; i++) HeaderPtr->OemId[i]=ACPI_OEM_ID[i];
+
+ for (i=0; i<8; i++) HeaderPtr->OemTblId[i]=ACPI_OEM_TBL_ID[i];
+ }
+
+} //PrepareHdr20
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PrepareHdr1
+//
+// Description:
+// This function creates ACPI V1 table header with specified signature
+//
+// Input:
+// IN UINT32 TblSig - ACPI table signature
+// IN OUT ACPI_HDR* HdrPtr - Pointer to memory, where the header should be placed
+//
+// Output:
+// VOID
+//
+// Notes:
+// Depends on type of memory provided, ACPI table header can be in 32 or 64 bit
+// format
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+void PrepareHdr1(UINT32 TblSig, ACPI_HDR* HdrPtr)
+{
+ UINTN i;
+ EFI_STATUS Status;
+
+ if (HdrPtr==NULL) return;
+
+ HdrPtr->Signature = TblSig;
+ HdrPtr->Revision = ACPI_REV1;
+
+ //Dont' touch Creator ID and Creator Revision;
+ if (TblSig != DSDT_SIG)
+ {
+ if (TblSig == RSDT_SIG)
+ HdrPtr->CreatorId = CREATOR_ID_MS;
+ else
+ HdrPtr->CreatorId = CREATOR_ID_AMI;
+
+ HdrPtr->CreatorRev = CREATOR_REV_MS;
+ HdrPtr->OemRev = ACPI_OEM_REV;
+ }
+
+ //Get the platform specific OEM_IDs
+ Status=OemAcpiSetPlatformId(HdrPtr);
+
+ //if platform does not support OEM_ID overwrite
+ if (EFI_ERROR(Status))
+ {
+ for (i=0; i<6; i++) HdrPtr->OemId[i]=ACPI_OEM_ID[i];
+
+ for (i=0; i<8; i++) HdrPtr->OemTblId[i]=ACPI_OEM_TBL_ID[i];
+ }
+
+}//PrepareHdr1
+
+
+
+ // [EIP106575], [EIP106731]>
+EFI_STATUS
+GetNanoFreqCallback (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ UINTN VarSize = sizeof (UINT32);
+ EFI_FPDT_STRUCTURE *FpdtVar;
+ EFI_CPU_ARCH_PROTOCOL *Cpu;
+
+ pBS->CloseEvent(Event);
+
+ Status = pRS->GetVariable(
+ EFI_FPDT_VARIABLE, \
+ &gAmiGlobalVariableGuid,
+ NULL, \
+ &VarSize, \
+ &FpdtVar );
+ if (EFI_ERROR (Status)) {
+ TRACE((-1,"Acpi BuildFPDT: No Cpu Protocol was found.\n"));
+ return Status;
+ }
+
+ Status = pBS->LocateProtocol (
+ &gEfiCpuArchProtocolGuid,
+ NULL,
+ &Cpu
+ );
+ if (!EFI_ERROR (Status)) {
+
+ UINT64 CurrentTicker, TimerPeriod;
+
+ Status = Cpu->GetTimerValue (Cpu, 0, &CurrentTicker, &TimerPeriod);
+
+ if (!EFI_ERROR (Status))
+ FpdtVar->NanoFreq = TimerPeriod;
+
+ if (FpdtVar->NanoFreq == 0) {
+ IoWrite8(0x80, 0xEE);
+ while(1);
+ }
+
+ } else {
+
+ TRACE((-1,"Acpi BuildFPDT: No Cpu Protocol was found.\n"));
+ return Status;
+
+ }
+
+ Status = pRS->SetVariable(
+ L"FPDT_Variable", \
+ &gAmiGlobalVariableGuid, \
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | \
+ EFI_VARIABLE_RUNTIME_ACCESS, \
+ sizeof(UINT32), \
+ &FpdtVar );
+
+ ASSERT_EFI_ERROR(Status);
+
+ return Status;
+}
+ // <[EIP106575], [EIP106731]
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BuildFPDT
+//
+// Description: This function allocates memory for and fills FPDT struscure. It also
+// creates Variable with the addres od S3 and Normal Boot performance srtuctures
+// to be filled later.
+// Input:
+// IN UINTN TablVer - Version of FACP table
+// IN OUT **ACPI_HDR TablPtr - Pointer to memory, where the FACP table will resides.
+// Filled by this procedure
+// Output:
+// EFI_STATUS:
+// EFI_OUT_OF_RESOURCES - Memory for the table could not be allocated
+// EFI_SUCCESS - Table was successfully build
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS BuildFPDT (IN UINTN TablVer, OUT ACPI_HDR **TablPtr)
+
+{
+ UINT8 *TempPtr;
+ PERF_TAB_HEADER *S3PerfRecHdr, *BasBootPerfRecHdr;
+ BASIC_S3_RESUME_PERF_REC *S3PerfRec;
+ BASIC_BOOT_PERF_REC *BasBootPerfRec;
+ UINTN RecordsSize;
+ FPDT_50 *FPDT;
+ EFI_STATUS Status;
+ EFI_FPDT_STRUCTURE *FpdtVar, *OldFpdtVarAddress;
+ EFI_CPU_ARCH_PROTOCOL *Cpu;
+ UINTN VarSize = sizeof (UINT32);
+ // [EIP106575], [EIP106731]>
+ VOID *Registration;
+ EFI_EVENT Event;
+ // <[EIP106575], [EIP106731]
+
+//-----------------------------
+
+ if (TablVer<1 || TablVer>4) return EFI_INVALID_PARAMETER;
+ RecordsSize = (sizeof(EFI_FPDT_STRUCTURE) + sizeof(PERF_TAB_HEADER)*2 +
+ sizeof(BASIC_S3_RESUME_PERF_REC)+
+ sizeof(BASIC_BOOT_PERF_REC));
+ Status = pBS->AllocatePool(EfiRuntimeServicesData, RecordsSize, &TempPtr);
+ if (EFI_ERROR(Status)) return EFI_OUT_OF_RESOURCES;
+#ifdef EFIx64
+ if (((UINT64)TempPtr) & 0xffffffff00000000)
+ {
+ EFI_PHYSICAL_ADDRESS Memory = 0x00000000ffffffff;
+ Status = pBS->FreePool(TempPtr);
+ ASSERT_EFI_ERROR(Status);
+ Status = pBS->AllocatePages(AllocateMaxAddress, EfiRuntimeServicesData, 1, &Memory);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return EFI_OUT_OF_RESOURCES;
+
+ TempPtr = (UINT8*)Memory;
+ }
+#endif
+ pBS->SetMem(TempPtr, RecordsSize, 0);
+
+ *TablPtr = MallocZ (sizeof(FPDT_50));
+
+ if ((*TablPtr)==NULL)
+ {
+ ASSERT(*TablPtr);
+ return EFI_OUT_OF_RESOURCES;
+ }
+ FpdtVar = (EFI_FPDT_STRUCTURE*) TempPtr;
+ TempPtr += sizeof(EFI_FPDT_STRUCTURE);
+ S3PerfRecHdr = (PERF_TAB_HEADER*) TempPtr;
+ TempPtr += sizeof(PERF_TAB_HEADER);
+ S3PerfRec = (BASIC_S3_RESUME_PERF_REC*)TempPtr;
+ TempPtr += sizeof(BASIC_S3_RESUME_PERF_REC);
+ BasBootPerfRecHdr = (PERF_TAB_HEADER*) TempPtr;
+ TempPtr += sizeof(PERF_TAB_HEADER);
+ BasBootPerfRec = (BASIC_BOOT_PERF_REC*)TempPtr;
+
+ S3PerfRecHdr->Signature = 0x54503353;// `S3PT'
+ S3PerfRecHdr->Length = sizeof(PERF_TAB_HEADER) + sizeof(BASIC_S3_RESUME_PERF_REC);
+
+ S3PerfRec->Header.PerfRecType = 0;
+ S3PerfRec->Header.RecLength = sizeof(BASIC_S3_RESUME_PERF_REC);
+ S3PerfRec->Header.Revision = 1;
+
+ BasBootPerfRecHdr->Signature = 0x54504246;// `FBPT'
+ BasBootPerfRecHdr->Length = sizeof(PERF_TAB_HEADER) + sizeof(BASIC_BOOT_PERF_REC);
+
+ BasBootPerfRec->Header.PerfRecType = 2;
+ BasBootPerfRec->Header.RecLength = sizeof(BASIC_BOOT_PERF_REC);
+ BasBootPerfRec->Header.Revision = 2;
+
+ FPDT = (FPDT_50*)*TablPtr;
+ PrepareHdr20(FPDT_SIG, (ACPI_HDR*)FPDT, TablVer);
+ FPDT->Header.Length = sizeof(FPDT_50);
+ FPDT->Header.Revision = 1;
+ FPDT->BasS3Rec.PerfRecType = 1;
+ FPDT->BasS3Rec.Length = sizeof(FPDT_PERF_RECORD);
+ FPDT->BasS3Rec.Revision = 1;
+ FPDT->BasS3Rec.Pointer = (EFI_PHYSICAL_ADDRESS)((UINTN)S3PerfRecHdr);
+
+ FPDT->BasBootRec.PerfRecType = 0;
+ FPDT->BasBootRec.Length = sizeof(FPDT_PERF_RECORD);
+ FPDT->BasBootRec.Revision = 1;
+ FPDT->BasBootRec.Pointer = (EFI_PHYSICAL_ADDRESS)((UINTN)BasBootPerfRecHdr);
+
+ FPDT->Header.Checksum = ChsumTbl((UINT8*)FPDT, FPDT->Header.Length);
+
+ Status = pBS->LocateProtocol (
+ &gEfiCpuArchProtocolGuid,
+ NULL,
+ &Cpu
+ );
+ if (!EFI_ERROR (Status))
+ {
+ UINT64 CurrentTicker, TimerPeriod;
+ Status = Cpu->GetTimerValue (Cpu, 0, &CurrentTicker, &TimerPeriod);
+ if (!EFI_ERROR (Status))
+ FpdtVar->NanoFreq = TimerPeriod;
+
+ } else {
+ Status = pBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ GetNanoFreqCallback,
+ NULL,
+ &Event
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = pBS->RegisterProtocolNotify (
+ &gEfiMpServiceProtocolGuid,
+ Event,
+ &Registration
+ );
+ }
+ }
+ // <[EIP106575], [EIP106731]
+
+ // Get Cpu Frequency
+
+ FpdtVar->S3Pointer = FPDT->BasS3Rec.Pointer;
+ FpdtVar->BasBootPointer = FPDT->BasBootRec.Pointer;
+ Status = pRS->SetVariable(
+ EFI_FPDT_VARIABLE,
+ &gAmiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS |
+ EFI_VARIABLE_RUNTIME_ACCESS,
+ sizeof(UINT32),
+ &FpdtVar
+ );
+ Status = pRS->GetVariable(
+ L"FPDT_Variable_NV", &gAmiGlobalVariableGuid,
+ NULL, &VarSize, &OldFpdtVarAddress
+ );
+ if (EFI_ERROR(Status) || (FpdtVar != OldFpdtVarAddress))
+ {
+ Status = pRS->SetVariable(
+ L"FPDT_Variable_NV",
+ &gAmiGlobalVariableGuid,
+ EFI_VARIABLE_NON_VOLATILE |
+ EFI_VARIABLE_BOOTSERVICE_ACCESS,
+ sizeof(UINT32),
+ &FpdtVar
+ );
+ ASSERT_EFI_ERROR(Status);
+ }
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BuildFIDT
+//
+// Description: This function allocates memory for and fills FIDT struscure.
+//
+// Input:
+// IN OUT **ACPI_HDR TablPtr - Pointer to memory, where the FACP table will resides.
+// Filled by this procedure
+// Output:
+// EFI_STATUS:
+// EFI_OUT_OF_RESOURCES - Memory for the table could not be allocated
+// EFI_SUCCESS - Table was successfully build
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS BuildFIDT (IN OUT ACPI_HDR **TablPtr)
+
+{
+
+ FW_VERSION *FidPtr = NULL;
+ UINTN FidLen = 0;
+ ACPI_HDR *FidTblHdr;
+ EFI_GUID FwGuid = FW_VERSION_GUID;
+ UINT8 i;
+ CHAR8 CoreMajVer [3] = THREE_CHAR_ARRAY(CORE_MAJOR_VERSION);
+ CHAR8 CoreMinVer [3] = THREE_CHAR_ARRAY(CORE_MINOR_VERSION);
+ CHAR8 ProjMajVer [3] = THREE_CHAR_ARRAY(PROJECT_MAJOR_VERSION);
+ CHAR8 ProjMinVer [3] = THREE_CHAR_ARRAY(PROJECT_MINOR_VERSION);
+
+ FidLen = sizeof(ACPI_HDR) + sizeof(FW_VERSION);
+ *TablPtr = MallocZ (FidLen);
+ if ((*TablPtr)==NULL)
+ {
+ ASSERT(*TablPtr);
+ return EFI_OUT_OF_RESOURCES;
+ }
+ FidTblHdr = (ACPI_HDR*)*TablPtr;
+ PrepareHdr20(FIDT_SIG, FidTblHdr, 4);
+ FidTblHdr->Length = (UINT32)FidLen;
+ FidTblHdr->Revision = 1;
+
+ FidPtr = (FW_VERSION*) ((UINT8*)FidTblHdr + sizeof(ACPI_HDR));
+
+ Strcpy (FidPtr->FirmwareID, CONVERT_TO_STRING($FID));
+ FidPtr->StructVersion = 4;
+ FidPtr->Size = sizeof(FW_VERSION);
+ Strcpy (FidPtr->BiosTag, CONVERT_TO_STRING(BIOS_TAG));
+ FidPtr->FirmwareGuid = FwGuid;
+ MemCpy(FidPtr->CoreMajorVersion, CoreMajVer, 3);
+ MemCpy(FidPtr->CoreMinorVersion, CoreMinVer, 3);
+ MemCpy(FidPtr->ProjectMajorVersion, ProjMajVer, 3);
+ MemCpy(FidPtr->ProjectMinorVersion, ProjMinVer, 3);
+
+ FidPtr->SignOnStringId = 0xffff;
+
+ for (i=0; i<6; i++) FidPtr->OemId[i]=ACPI_OEM_ID[i];
+
+ for (i=0; i<8; i++) FidPtr->OemTableId[i]=ACPI_OEM_TBL_ID[i];
+
+ FidTblHdr->Checksum = ChsumTbl((UINT8*)FidTblHdr, FidTblHdr->Length);
+
+
+
+ //TRACE((TRACE_ALWAYS, "FIDT Created.\n"));
+
+
+ return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BuildFacpiAll (NUINT TablVer, VOID *TablPtr)
+//
+// Description: This function allocates memory for and fills FACP table v 1.1+ with
+// predefined values from SDL tokens
+// Input:
+// IN UINTN TablVer - Version of FACP table
+// IN OUT **ACPI_HDR TablPtr - Pointer to memory, where the FACP table will resides.
+// Filled by this procedure
+// Output:
+// EFI_STATUS:
+// EFI_OUT_OF_RESOURCES - Memory for the table could not be allocated
+// EFI_SUCCESS - Table was successfully build
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+
+EFI_STATUS BuildFacpiAll (IN UINTN TablVer, OUT ACPI_HDR **TablPtr)
+
+{
+ FACP_50 *facp;
+ ACPI_HDR *FACP_Hdr;
+ UINT32 SizeOfFacp = sizeof(FACP_20);
+//-----------------------------
+
+ if (TablVer<1 || TablVer>4) return EFI_INVALID_PARAMETER;
+
+ if (TablVer == 1) SizeOfFacp = 0x84;// size of compatability 1.1 structure
+ if (ACPI_BUILD_TABLES_5_0 == 1) SizeOfFacp = sizeof(FACP_50);
+ *TablPtr = MallocZ (SizeOfFacp);
+ if ((*TablPtr)==NULL)
+ {
+ ASSERT(*TablPtr);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ FACP_Hdr = *TablPtr;
+
+ if (TablVer == 1)
+ {
+ PrepareHdr20(FACP_SIG, FACP_Hdr, 2);
+ FACP_Hdr->Revision = ACPI_REV2;// compatability 1.1 structure
+ }
+
+ else
+ PrepareHdr20(FACP_SIG, FACP_Hdr, TablVer);
+
+ facp = (PFACP_50) *TablPtr;
+
+ facp->Reserved1 = ACPI_INT_MODEL;
+
+ facp->PM_PPROF = ACPI_PM_PROFILE;
+ facp->SCI_INT = ACPI_SCI_INT;
+ facp->SMI_CMD = SW_SMI_IO_ADDRESS;
+ facp->ACPI_ENABLE_CMD = SW_SMI_ACPI_ENABLE;
+ facp->ACPI_DISABLE_CMD = SW_SMI_ACPI_DISABLE;
+ facp->S4BIOS_REQ = SW_SMI_S4BIOS;
+
+ facp->PSTATE_CNT = SW_SMI_PSTATE_CNT;
+
+ if (PM1A_EVT_BLK_ADDRESS > 0xffffffff)
+ facp->PM1a_EVT_BLK = 0;
+ else
+ facp->PM1a_EVT_BLK = PM1A_EVT_BLK_ADDRESS;
+
+ if (PM1B_EVT_BLK_ADDRESS > 0xffffffff)
+ facp->PM1b_EVT_BLK = 0;
+ else
+ facp->PM1b_EVT_BLK = PM1B_EVT_BLK_ADDRESS;
+
+ if (PM1A_CNT_BLK_ADDRESS > 0xffffffff)
+ facp->PM1a_CNT_BLK = 0;
+ else
+ facp->PM1a_CNT_BLK = PM1A_CNT_BLK_ADDRESS;
+
+ if (PM1B_CNT_BLK_ADDRESS > 0xffffffff)
+ facp->PM1b_CNT_BLK = 0;
+ else
+ facp->PM1b_CNT_BLK = PM1B_CNT_BLK_ADDRESS;
+
+ if (PM2_CNT_BLK_ADDRESS > 0xffffffff)
+ facp->PM2_CNT_BLK = 0;
+ else
+ facp->PM2_CNT_BLK = PM2_CNT_BLK_ADDRESS;
+
+ if (PM_TMR_BLK_ADDRESS > 0xffffffff)
+ facp->PM_TMR_BLK = 0;
+ else
+ facp->PM_TMR_BLK = PM_TMR_BLK_ADDRESS;
+
+ if (GPE0_BLK_ADDRESS > 0xffffffff)
+ facp->GPE0_BLK = 0;
+ else
+ facp->GPE0_BLK = GPE0_BLK_ADDRESS;
+
+ if (GPE1_BLK_ADDRESS > 0xffffffff)
+ facp->GPE1_BLK = 0;
+ else
+ facp->GPE1_BLK = GPE1_BLK_ADDRESS;
+
+ facp->GPE0_BLK_LEN = GPE0_BLK_LENGTH;
+ facp->GPE1_BLK_LEN = GPE1_BLK_LENGTH;
+ facp->GPE1_BASE = GPE1_BASE_OFFSET;
+ facp->PM1_EVT_LEN = PM1_EVT_LENGTH;
+ facp->PM1_CNT_LEN = PM1_CNT_LENGTH;
+ facp->PM2_CNT_LEN = PM2_CNT_LENGTH;
+ facp->PM_TM_LEN = PM_TMR_LENGTH;
+
+ facp->CST_CNT = SW_SMI_CST_CNT;
+ facp->P_LVL2_LAT = P_LVL2_LAT_VAL;
+ facp->P_LVL3_LAT = P_LVL3_LAT_VAL;
+ facp->FLUSH_SIZE = FLUSH_SIZE_VAL;
+ facp->FLUSH_STRIDE = FLUSH_STRIDE_VAL;
+ facp->DUTY_OFFSET = DUTY_OFFSET_VAL;
+ facp->DUTY_WIDTH = DUTY_WIDTH_VAL;
+ facp->DAY_ALRM = ACPI_ALARM_DAY_CMOS;
+ facp->MON_ALRM = ACPI_ALARM_MONTH_CMOS;
+ facp->CENTURY = ACPI_CENTURY_CMOS;
+ facp->IAPC_BOOT_ARCH = ACPI_IA_BOOT_ARCH;
+
+ //--------Filling Flags for V.1----------------------
+
+ facp->FLAGS = 0;
+
+ if (FACP_FLAG_WBINVD) facp->FLAGS = 1;
+
+ if (FACP_FLAG_WBINVD_FLUSH) facp->FLAGS |= 1<<1;
+
+ if (FACP_FLAG_PROC_C1) facp->FLAGS |= 1<<2;
+
+ if (FACP_FLAG_P_LVL2_UP) facp->FLAGS |= 1<<3;
+
+ if (FACP_FLAG_PWR_BUTTON) facp->FLAGS |= 1<<4;
+
+ if (FACP_FLAG_SLP_BUTTON) facp->FLAGS |= 1<<5;
+
+ if (FACP_FLAG_FIX_RTC) facp->FLAGS |= 1<<6;
+
+ if (FACP_FLAG_RTC_S4) facp->FLAGS |= 1<<7;
+
+ if (FACP_FLAG_TMR_VAL_EXT) facp->FLAGS |= 1<<8;
+
+ if (FACP_FLAG_DCK_CAP) facp->FLAGS |= 1<<9;
+
+
+ //--------Filling Flags for V.2 and GAS compat structure for v.1----------------------
+
+ if (FACP_FLAG_RESET_REG_SUP) facp->FLAGS |= 1<<10;
+
+ if (FACP_FLAG_SEALED_CASE) facp->FLAGS |= 1<<11;
+
+ if (FACP_FLAG_HEADLESS) facp->FLAGS |= 1<<12;
+
+ if (FACP_FLAG_CPU_SW_SLP) facp->FLAGS |= 1<<13;
+
+#if ACPI_BUILD_TABLES_3_0
+
+ if (FACP_FLAG_USE_PLATFORM_CLOCK) facp->FLAGS |= 1<<15;
+
+ if (FACP_FLAG_S4_RTC_STS_VALID) facp->FLAGS |= 1<<16;
+
+ if (FACP_FLAG_REMOTE_POWER_ON_CAPABLE) facp->FLAGS |= 1<<17;
+
+ if (TablVer > 2)
+ {
+ if (FACP_FLAG_FORCE_APIC_CLUSTER_MODEL) facp->FLAGS |= 1<<18;
+
+ if (FACP_FLAG_FORCE_APIC_PHYSICAL_DESTINATION_MODE) facp->FLAGS |= 1<<19;
+
+ if (FACP_FLAG_PCI_EXP_WAK) facp->FLAGS |= 1<<14;
+ }
+
+#endif
+
+ // RESET_REG GAS_20 structure and value
+ facp->RESET_REG.AddrSpcID = ACPI_RESET_REG_TYPE;
+ facp->RESET_REG.RegBitWidth = ACPI_RESET_REG_BITWIDTH;
+ facp->RESET_REG.RegBitOffs = ACPI_RESET_REG_BITOFFSET;
+ facp->RESET_REG.Address = ACPI_RESET_REG_ADDRESS;
+ facp->RESET_VAL = ACPI_RESET_REG_VALUE;
+
+ if (ACPI_RESET_REG_ADDRESS)
+ {
+ // Set FACP flag
+ facp->FLAGS |= 1<<10;
+ }
+
+ if (TablVer == 1)
+ {
+ facp->Header.Length = 0x84;
+ facp->Header.Checksum = 0;
+ facp->Header.Checksum = ChsumTbl((UINT8*)facp, facp->Header.Length);
+ return EFI_SUCCESS;
+ }
+
+ //--------This is all for V.1-----------------------
+
+ // PM1a_EVT_BLK GAS_20 structure
+ facp->X_PM1a_EVT_BLK.AddrSpcID = PM1A_EVT_BLK_TYPE;
+ facp->X_PM1a_EVT_BLK.RegBitWidth= PM1A_EVT_BLK_BITWIDTH;
+ facp->X_PM1a_EVT_BLK.RegBitOffs = PM1A_EVT_BLK_BITOFFSET;
+ facp->X_PM1a_EVT_BLK.AccessSize = 2;
+ facp->X_PM1a_EVT_BLK.Address = PM1A_EVT_BLK_ADDRESS;
+
+ // PM1a_CNT_BLK GAS_20 structure
+ facp->X_PM1a_CNT_BLK.AddrSpcID = PM1A_CNT_BLK_TYPE;
+ facp->X_PM1a_CNT_BLK.RegBitWidth= PM1A_CNT_BLK_BITWIDTH;
+ facp->X_PM1a_CNT_BLK.RegBitOffs = PM1A_CNT_BLK_BITOFFSET;
+ facp->X_PM1a_CNT_BLK.AccessSize = 2;
+ facp->X_PM1a_CNT_BLK.Address = PM1A_CNT_BLK_ADDRESS;
+
+ // PM1b_EVT_BLK GAS_20 structure
+ facp->X_PM1b_EVT_BLK.AddrSpcID = PM1B_EVT_BLK_TYPE;
+ facp->X_PM1b_EVT_BLK.RegBitWidth= PM1B_EVT_BLK_BITWIDTH;
+ facp->X_PM1b_EVT_BLK.RegBitOffs = PM1B_EVT_BLK_BITOFFSET;
+ facp->X_PM1b_EVT_BLK.AccessSize = 2;
+ facp->X_PM1b_EVT_BLK.Address = PM1B_EVT_BLK_ADDRESS;
+
+ // PM1b_CNT_BLK GAS_20 structure
+ facp->X_PM1b_CNT_BLK.AddrSpcID = PM1B_CNT_BLK_TYPE;
+ facp->X_PM1b_CNT_BLK.RegBitWidth= PM1B_CNT_BLK_BITWIDTH;
+ facp->X_PM1b_CNT_BLK.RegBitOffs = PM1B_CNT_BLK_BITOFFSET;
+ facp->X_PM1b_CNT_BLK.AccessSize = 2;
+ facp->X_PM1b_CNT_BLK.Address = PM1B_CNT_BLK_ADDRESS;
+
+ // PM1b_CNT_BLK GAS_20 structure
+ facp->X_PM2_CNT_BLK.AddrSpcID = PM2_CNT_BLK_TYPE;
+ facp->X_PM2_CNT_BLK.RegBitWidth = PM2_CNT_BLK_BITWIDTH;
+ facp->X_PM2_CNT_BLK.RegBitOffs = PM2_CNT_BLK_BITOFFSET;
+ facp->X_PM2_CNT_BLK.AccessSize = 1;
+ facp->X_PM2_CNT_BLK.Address = PM2_CNT_BLK_ADDRESS;
+
+ facp->X_PM_TMR_BLK.AddrSpcID = PM_TMR_BLK_TYPE;
+ facp->X_PM_TMR_BLK.RegBitWidth = PM_TMR_BLK_BITWIDTH;
+ facp->X_PM_TMR_BLK.RegBitOffs = PM_TMR_BLK_BITOFFSET;
+ facp->X_PM_TMR_BLK.AccessSize = 3;
+ facp->X_PM_TMR_BLK.Address = PM_TMR_BLK_ADDRESS;
+
+ facp->X_GPE0_BLK.AddrSpcID = GPE0_BLK_TYPE;
+ facp->X_GPE0_BLK.RegBitWidth = GPE0_BLK_BITWIDTH;
+ facp->X_GPE0_BLK.RegBitOffs = GPE0_BLK_BITOFFSET;
+ facp->X_GPE0_BLK.AccessSize = 1;
+ facp->X_GPE0_BLK.Address = GPE0_BLK_ADDRESS;
+
+ facp->X_GPE1_BLK.AddrSpcID = GPE1_BLK_TYPE;
+ facp->X_GPE1_BLK.RegBitWidth = GPE1_BLK_BITWIDTH;
+ facp->X_GPE1_BLK.RegBitOffs = GPE1_BLK_BITOFFSET;
+ facp->X_GPE1_BLK.AccessSize = 1;
+ facp->X_GPE1_BLK.Address = GPE1_BLK_ADDRESS;
+
+ if (ACPI_BUILD_TABLES_5_0 == 1)
+ {
+#if HW_REDUCED_ACPI
+
+ facp->FLAGS |= 1<<20;
+
+ facp->SLEEP_CONTROL_REG.AddrSpcID = SLEEP_CONTROL_REG_TYPE;
+ facp->SLEEP_CONTROL_REG.RegBitWidth = SLEEP_CONTROL_REG_BITWIDTH;
+ facp->SLEEP_CONTROL_REG.RegBitOffs = SLEEP_CONTROL_REG_BITOFFSET;
+ facp->SLEEP_CONTROL_REG.AccessSize = SLEEP_CONTROL_REG_ACCESS_SIZE;
+ facp->SLEEP_CONTROL_REG.Address = SLEEP_CONTROL_REG_ADDRESS;
+
+ facp->SLEEP_STATUS_REG.AddrSpcID = SLEEP_STATUS_REG_TYPE;
+ facp->SLEEP_STATUS_REG.RegBitWidth = SLEEP_STATUS_REG_BITWIDTH;
+ facp->SLEEP_STATUS_REG.RegBitOffs = SLEEP_STATUS_REG_BITOFFSET;
+ facp->SLEEP_STATUS_REG.AccessSize = SLEEP_STATUS_REG_ACCESS_SIZE;
+ facp->SLEEP_STATUS_REG.Address = SLEEP_STATUS_REG_ADDRESS;
+#endif
+
+ if (LOW_POWER_S0_IDLE_CAPABLE) facp->FLAGS |= 1<<21;
+ facp->Header.Revision = 5; // ACPI 5.0 revision
+ }
+ facp->Header.Length = SizeOfFacp;
+ facp->Header.Checksum = 0;
+ facp->Header.Checksum = ChsumTbl((UINT8*)facp, facp->Header.Length);
+
+ return EFI_SUCCESS;
+
+}// end of BuildFacpiAll
+
+//----------------------------------------------------------------------------
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BuildLapic
+//
+// Description: Allocates memory for and builds LAPIC entry for MADT table
+//
+// Input: IN CPUINFO *CpuInfo - Pointer to a block of information about cpu
+// passed through cpu info HOB, if NULL - it is a
+// dummy entry.
+// IN UINTN CpuCount - Number of the cpu
+//
+// Output:
+// MADT_ENTRY_HEADER * - pointer to the LAPIC entry header for the MADT table
+// if NULL - not enough memory
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+MADT_ENTRY_HEADER *BuildLapic(IN CPUINFO *CpuInfo, IN UINT32 CpuId)
+{
+ LAPIC_H32 *LapicPtr;
+ LapicPtr = MallocZ(sizeof(LAPIC_H32));
+ ASSERT (LapicPtr);
+
+ if (!LapicPtr) return NULL;
+
+ LapicPtr->Header.Type = (UINT8) AT_LAPIC; //Type 0 - indicating LAPIC Entry
+ LapicPtr->Header.Length = (UINT8) sizeof(LAPIC_H32);
+ LapicPtr->CpuId = CpuId;
+
+ if (CpuInfo != NULL) // This is not a dummy entry
+ {
+ LapicPtr->LapicId = (UINT8) CpuInfo->ApicId;
+ if (gMaxLapic < LapicPtr->LapicId) gMaxLapic = LapicPtr->LapicId;
+ LapicPtr->Flags = (CpuInfo->Valid) ? FL_ENABLE : 0;
+ }
+
+ else // Tis is a dummy entry for not installed processor
+ {
+ LapicPtr->LapicId = ++gMaxLapic;
+ LapicPtr->Flags = 0;
+ }
+
+ return (MADT_ENTRY_HEADER*) LapicPtr;
+
+}// end of BuildLapic
+
+//----------------------------------------------------------------------------
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BuildLx2Apic
+//
+// Description: Allocates memory for and builds Local x2APIC entry for MADT table
+//
+// Input:
+// IN UINT32 ApicId - Apic Id of processor.
+// IN UINT32 Uid - UID of processor.
+// IN UINT32 Flags - Flags of entry.
+//
+// Output:
+// MADT_ENTRY_HEADER * - pointer to the LX2APIC entry header for the MADT table
+// if NULL - not enough memory
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+MADT_ENTRY_HEADER *BuildLx2Apic(IN UINT32 ApicId, IN UINT32 Uid, IN UINT32 Flags)
+{
+ LX2APIC *Lx2ApicPtr;
+ Lx2ApicPtr = MallocZ(sizeof(LX2APIC));
+ ASSERT (Lx2ApicPtr);
+
+ if (!Lx2ApicPtr) return NULL;
+
+ Lx2ApicPtr->Header.Type = (UINT8) AT_LX2APIC; //Type A - indicating LX2APIC Entry
+ Lx2ApicPtr->Header.Length = (UINT8) sizeof(LX2APIC);
+ Lx2ApicPtr->ApicId = ApicId;
+ Lx2ApicPtr->Flags = Flags;
+ Lx2ApicPtr->Uid = Uid;
+ return (MADT_ENTRY_HEADER*) Lx2ApicPtr;
+}// end of BuildLx2Apic
+
+//----------------------------------------------------------------------------
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BuildLsapic
+//
+// Description: Allocates memory for and builds LSAPIC entry for MADT table
+//
+//
+// Input: IN CPUINFO *CpuInfo - Pointer to a block of information about cpu
+// passed through cpu info HOB
+// IN UINT32 CpuCount - Number of the cpu
+// IN UINTN Ver - Version of MADT table
+//
+// Output:
+// MADT_ENTRY_HEADER * - pointer to the LAPIC entry header for the MADT table
+// if NULL - not enough memory
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+MADT_ENTRY_HEADER *BuildLsapic(IN CPUINFO *CpuInfo, IN UINT32 CpuId, IN UINTN Ver)
+{
+ LSAPIC_H20 *LsapicPtr;
+
+ if (Ver < 3)
+ LsapicPtr = MallocZ(sizeof(LSAPIC_H20));
+ else
+ LsapicPtr = MallocZ(sizeof(LSAPIC_H30));
+
+ ASSERT (LsapicPtr);
+
+ if (!LsapicPtr) return NULL;
+
+ LsapicPtr->Header.Type = (UINT8) AT_LSAPIC; //Type 7 - indicating LSAPIC Entry
+
+ if (Ver < 3)
+ LsapicPtr->Header.Length = (UINT8) sizeof(LSAPIC_H20);
+ else
+ LsapicPtr->Header.Length = (UINT8) sizeof(LSAPIC_H30);
+
+ LsapicPtr->CpuId = CpuId;
+ LsapicPtr->LsapicId = (UINT8) CpuInfo->ApicId;
+ LsapicPtr->LsapicEid = (UINT8) CpuInfo->ApicEId;
+ LsapicPtr->Flags = (CpuInfo->Valid) ? FL_ENABLE : 0;
+ return (MADT_ENTRY_HEADER*) LsapicPtr;
+
+}// end of BuildLsapic LapicPtr
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BuildIoapicIosapic
+//
+// Description:
+// This function will probe IndReg and DataReg of discovered IOxAPIC base address
+// and allocate memory for and builds Ioapic/Iosapic entry for MADT table
+//
+// Input:
+// IN UINT64 BaseAddr - Base Addrerss where IOxApic presence detected
+// IN OUT UINT64 *VecBase - pointer to the System Vector Base variable that
+// needs to be updated with IOAPIC.MAXREDIR# by this function
+//
+//
+// Output:
+// MADT_ENTRY_HEADER * - pointer to the Ioapic/Iosapi entry header for the MADT table
+// if NULL - not enough memory
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+#pragma optimize( "", off )
+MADT_ENTRY_HEADER *BuildIoapicIosapic(IN UINT32 BaseAddr, OUT UINT32 *VecBase)
+{
+ UINT32 Tmp;
+ UINT32 volatile *DatPtr;
+ UINT8 volatile *IdxPtr;
+ UINT32 IoapicId;
+ UINT32 IoapicVer;
+ IOAPIC_H20 *IoapicPtr;
+ IOSAPIC_H20 *IosapicPtr;
+
+//==============================
+ //Read IOAPIC.ID reg and figure out
+ //1.How many INTINs it has
+ //2.What ID did BIOS gave to it
+ IdxPtr=(UINT8*)(BaseAddr + IOA_IND_REG_OFFS);
+ DatPtr=(UINT32*)(BaseAddr + IOA_DAT_REG_OFFS);
+
+ *IdxPtr = IOA_ID_IND; // bits 27..24=IOAPIC_ID
+
+ Tmp = *DatPtr;
+
+ IoapicId = ((Tmp&0x0f000000)>>24);
+
+ *IdxPtr = IOA_VER_IND; // IOAPIC_VER register
+
+ Tmp=*DatPtr;
+
+ IoapicVer=(Tmp&0xff);
+
+ if (IoapicVer < IO_APIC_VERSION_PARAMETER) // This is Ioapic
+ {
+ IoapicPtr = MallocZ(sizeof(IOAPIC_H20));
+ ASSERT (IoapicPtr);
+
+ if (!IoapicPtr) return NULL;
+
+ IoapicPtr->Header.Type = (UINT8) AT_IOAPIC; // 1 - For IOAPIC Structure
+ IoapicPtr->Header.Length = (UINT8) sizeof (IOAPIC_H20);
+ IoapicPtr->IoapicAddress = (UINT32) BaseAddr;
+ IoapicPtr->IoapicId = (UINT8) IoapicId;
+ IoapicPtr->SysVectBase = (UINT32) *VecBase;
+ //Adjust VecBase with current Max Redirection value
+ (*VecBase)+=((UINT32)((Tmp&0x00ff0000)>>16))+1;
+ return (MADT_ENTRY_HEADER*) IoapicPtr;
+ }
+
+ else // This is Iosapic
+ {
+ IosapicPtr = MallocZ(sizeof(IOSAPIC_H20));
+ ASSERT (IosapicPtr);
+
+ if (!IosapicPtr) return NULL;
+
+ IosapicPtr->Header.Type = (UINT8) AT_IOSAPIC; // 6 - For IOSAPIC Structure
+ IosapicPtr->Header.Length = (UINT8) sizeof (IOSAPIC_H20);
+ IosapicPtr->IosapicAddress = (UINT64) BaseAddr;
+ IosapicPtr->IoapicId = (UINT8) IoapicId;
+ IosapicPtr->SysVectBase = (UINT32) *VecBase;
+ //Adjust VecBase with current Max Redirection value
+ (*VecBase)+=((UINT32)((Tmp&0x00ff0000)>>16))+1;
+ return (MADT_ENTRY_HEADER*) IosapicPtr;
+ }
+
+}// End of BuildIoapicIosapic
+#pragma optimize( "", on )
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BuildIoapicManualy
+//
+// Description: Allocates memory for and builds LAPIC entry for MADT table filled with
+// Dummy information
+//
+// Output:
+// MADT_ENTRY_HEADER * - pointer to the LAPIC entry header for the MADT table
+// if NULL - not enough memory
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+MADT_ENTRY_HEADER *BuildIoapicManualy()
+{
+ IOAPIC_H20 *IoapicPtr;
+
+ IoapicPtr = MallocZ(sizeof(IOAPIC_H20));
+ ASSERT (IoapicPtr);
+
+ if (!IoapicPtr) return NULL;
+
+ IoapicPtr->Header.Type = (UINT8) AT_IOAPIC; // 1 - For IOAPIC Structure
+ IoapicPtr->Header.Length = (UINT8) sizeof (IOAPIC_H20);
+ IoapicPtr->IoapicAddress = (UINT32) APCB;
+ IoapicPtr->IoapicId = (UINT8) 0;
+ IoapicPtr->SysVectBase = (UINT32) 0;
+ return (MADT_ENTRY_HEADER*) IoapicPtr;
+
+
+}// end of BuildIoapicManualy
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: AddIsoFromTbl
+//
+// Description: Allocates memory for and builds ISO entry for MADT table, based
+// on INTERRUPT SOURCE OVERRIDE info from predifined table
+//
+// Input: UINTN IsoTblNumb - Number of entry in ISO table for which an entry should
+// be build.
+//
+// Output:
+// MADT_ENTRY_HEADER * - pointer to the ISO entry header for the MADT table
+// if NULL - not enough memory
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+MADT_ENTRY_HEADER *BuildIsoFromTbl (UINTN IsoTblNumb)
+{
+ ISO_H20 *IsoPtr;
+
+ IsoPtr = MallocZ(sizeof(ISO_H20));
+ ASSERT (IsoPtr);
+
+ if (!IsoPtr) return NULL;
+
+ IsoPtr->Header.Type = AT_ISO; // 2 - For ISO structure
+ IsoPtr->Header.Length = sizeof(ISO_H20);
+ IsoPtr->Bus = 0;
+ IsoPtr->Source = (UINT8) IsoTbl[IsoTblNumb].PicIrq;
+ IsoPtr->GlobalSysVect = (UINT32) IsoTbl[IsoTblNumb].ApicInt;
+ IsoPtr->Flags = (UINT16) IsoTbl[IsoTblNumb].Flags;
+ return (MADT_ENTRY_HEADER*) IsoPtr;
+}//end of BuildIsoFromTbl
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BuildLapicsFromHob
+//
+// Description:
+// Build Local Apic Entries from HOB.
+//
+// Input:
+// IN UINTN TableVer - ACPI Spec. Version
+// IN OUT MADT_ENTRIES *MadtTblEntries - MADT Table Entry list.
+//
+// Output: EFI_STATUS
+// EFI_OUT_OF_RESOURCES - not enough memory
+// EFI_UNSUPPORTED - CPU info hob not found
+// EFI_INVALID_PARAMETER - invalid ACPI version
+// EFI_SUCCESS - MADT table were successfully build
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS BuildLapicsFromHob(
+ IN UINTN TablVer,
+ IN OUT MADT_ENTRIES *MadtTblEntries
+)
+{
+ UINT32 NumbOfCPUs, DummyCPUs = 0, i;
+ static EFI_GUID CpuInfoHobGuid = AMI_CPUINFO_HOB_GUID;
+ static EFI_GUID HobListGuid = HOB_LIST_GUID;
+ UINT32 CpuCount, LastItem = 1;
+ CPUINFO_HOB *CpuInfoHob;
+ CPUINFO *CpuInfo = NULL;
+ MADT_ENTRY_HEADER *HdrPtr;
+ EFI_STATUS Status;
+
+ CpuInfoHob = (CPUINFO_HOB*)GetEfiConfigurationTable(pST,&HobListGuid);
+
+ if (CpuInfoHob == NULL) Status = EFI_UNSUPPORTED;
+ else Status = FindNextHobByGuid(&CpuInfoHobGuid,(VOID**)&CpuInfoHob);
+
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return Status;
+
+ NumbOfCPUs = CpuInfoHob->CpuCount;
+
+#if defined SKIP_DUMMY_LAPICS && SKIP_DUMMY_LAPICS==1
+// If SKIP_DUMMY_LAPICS defined and 1 - somebody want to skip creation of dummy lapics
+// So do nothing there
+#else
+#if NCPU != 0
+DummyCPUs = NCPU; // NCPU - maximum poccesoros supported by platform - so we need to create dummy entries for
+#endif // all processors that are not present, but could be hotpluged.
+#endif
+
+//---Creating LAPIC or/and LSAPIC Entries----------------
+ if (DummyCPUs <= NumbOfCPUs) DummyCPUs = NumbOfCPUs;
+
+ for (CpuCount=0; CpuCount < DummyCPUs; CpuCount++)
+ {
+ if (CpuCount < NumbOfCPUs)
+ {
+ CpuInfo = &(CpuInfoHob->Cpuinfo[CpuCount]);
+
+ if (CpuInfo->ApicVer < LOCAL_APIC_VERSION_PARAMETER)
+ HdrPtr = BuildLapic(CpuInfo, CpuCount + 1); //Id must match processor object, so add 1 to Cpu Count.
+ else
+ HdrPtr = BuildLsapic(CpuInfo, CpuCount + 1, TablVer); //Id must match processor object, so add 1 to Cpu Count.
+ }
+
+ else HdrPtr = BuildLapic(NULL, CpuCount + 1); // Just add dummy entry
+
+ if (!HdrPtr) return EFI_OUT_OF_RESOURCES;
+
+ if (MadtTblEntries->MadtEntCount == 0) // Adding entries in groving LapicId/LsapicId value order
+ Status = AppendItemLst ((T_ITEM_LIST*)MadtTblEntries, (VOID*) HdrPtr);// First entry
+ else
+ {
+ for (i = (LastItem - 1); i < MadtTblEntries->MadtEntCount; i++) // No need to handle LSAPIC entry in different way
+ {
+ if (((LAPIC_H32*)HdrPtr)->LapicId < ((LAPIC_H32*)MadtTblEntries->MadtEntries[i])->LapicId) break; // LapicId and LsapicId filds are on the same place in bouth structures
+ } // found entry with bigger LapicId/LsapicId
+
+ if (i == MadtTblEntries->MadtEntCount)
+ Status = AppendItemLst ((T_ITEM_LIST*)MadtTblEntries, (VOID*) HdrPtr);
+ else
+ Status = InsertItemLst ((T_ITEM_LIST*)MadtTblEntries, (VOID*) HdrPtr, i);
+ }
+
+ ASSERT_EFI_ERROR(Status);
+ }
+
+ return EFI_SUCCESS;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BuildLapicsFromProtocol
+//
+// Description:
+// Build Local Apic Entries from Protocol.
+//
+// Input:
+// IN UINTN TableVer - ACPI Spec. Version
+// IN OUT MADT_ENTRIES *MadtTblEntries - MADT Table Entry list.
+//
+// Output: EFI_STATUS
+// EFI_OUT_OF_RESOURCES - not enough memory
+// EFI_UNSUPPORTED - CPU info hob not found
+// EFI_INVALID_PARAMETER - invalid ACPI version
+// EFI_SUCCESS - MADT table were successfully build
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+#ifdef ACPI_INFO2_PROTOCOL_PUBLISHED
+
+EFI_STATUS BuildLapicsFromProtocol(
+ IN UINTN TablVer,
+ IN OUT MADT_ENTRIES *MadtTblEntries
+)
+{
+ EFI_STATUS Status;
+ MADT_ENTRY_HEADER *HdrPtr;
+ ACPI_PROCESSOR_INFO *AcpiProcInfo;
+ UINT32 NumEntries;
+ UINT32 Index;
+ CPUINFO CpuInfo;
+
+ if (gAmiCpu2Info->ProtocolVer < 1) return EFI_UNSUPPORTED;
+
+ Status = gAmiCpu2Info->GetAcpiInfo(
+ gAmiCpu2Info, (VOID**) &AcpiProcInfo, &NumEntries
+ );
+
+ if (EFI_ERROR(Status)) return Status;
+
+ for (Index = 0; Index < NumEntries; ++Index)
+ {
+ //Note: Only some ACPI_PROCESSOR_INFO fields may only valid for some minimum ACPI_PROCESSOR_INFO.Length.
+ //The ACPI_PROCESSOR_INFO may have additional fields added in later version. Please see comments in
+ //AmiCpuInfo2.h file.
+ if (AcpiProcInfo->Type == ACPI_PROCESSOR_INFO_TYPE)
+ {
+ if (AcpiProcInfo->Length >= 60 && AcpiProcInfo->LocalApicType == ACPI_PROC_INFO_x2APIC)
+ {
+ HdrPtr = BuildLx2Apic(AcpiProcInfo->ApicId, AcpiProcInfo->ProcId, 1);
+ gX2Apic = TRUE;
+ }
+
+ else
+ {
+ //This current implementation only supports 8 bit APIC Id and 8-bit extended Id.
+ CpuInfo.Valid = (BOOLEAN)AcpiProcInfo->Enable;
+ CpuInfo.ApicId = (UINT8)AcpiProcInfo->ApicId;
+ CpuInfo.ApicEId = (UINT8)(AcpiProcInfo->ApicId >> 8);
+ CpuInfo.ApicVer = (UINT8)AcpiProcInfo->ApicVer;
+
+ //Produce entry.
+ if (AcpiProcInfo->ApicVer < LOCAL_APIC_VERSION_PARAMETER)
+ HdrPtr = BuildLapic(&CpuInfo, AcpiProcInfo->ProcId);
+ else
+ HdrPtr = BuildLsapic(&CpuInfo, AcpiProcInfo->ProcId, TablVer);
+ }
+
+ Status = AppendItemLst ((T_ITEM_LIST*)MadtTblEntries, (VOID*) HdrPtr);
+ ASSERT_EFI_ERROR(Status);
+
+ }
+
+ //An earlier version ACPI_PROCESSOR_INFO with a smaller structure may be have been published,
+ //so use length field.
+ AcpiProcInfo = (ACPI_PROCESSOR_INFO*)((UINT8*)AcpiProcInfo + AcpiProcInfo->Length);
+ }
+
+ return EFI_SUCCESS;
+}
+
+#endif
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BuildLapicNmiFromProtocol
+//
+// Description:
+// Build Local Apic NMI Entries from Protocol.
+//
+// Input:
+// IN OUT MADT_ENTRIES *MadtTblEntries - MADT Table Entry list.
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+#if AMI_CPU_INFO_2_PROTOCOL_VERSION >= 3
+EFI_STATUS BuildLapicNmiFromProtocol(
+ IN OUT MADT_ENTRIES *MadtTblEntries
+)
+{
+ EFI_STATUS Status;
+ MADT_ENTRY_HEADER *HdrPtr;
+ ACPI_PROCESSOR_INFO *AcpiProcInfo;
+ UINT32 NumEntries;
+ UINT32 Index;
+
+ if (gAmiCpu2Info->ProtocolVer < 1) return EFI_UNSUPPORTED;
+
+ Status = gAmiCpu2Info->GetAcpiInfo(
+ gAmiCpu2Info, (VOID**) &AcpiProcInfo, &NumEntries
+ );
+ if (EFI_ERROR(Status)) return Status;
+
+ Status = EFI_NOT_FOUND;
+
+ for (Index = 0; Index < NumEntries; ++Index)
+ {
+ //Note: Only some ACPI_PROCESSOR_INFO fields may only valid for some minimum ACPI_PROCESSOR_INFO.Length.
+ //The ACPI_PROCESSOR_INFO may have additional fields added in later version. Please see comments in
+ //AmiCpuInfo2.h file.
+ if (AcpiProcInfo->Type == ACPI_PROCESSOR_INFO_TYPE)
+ {
+ if (AcpiProcInfo->Length >= 72 && AcpiProcInfo->ProduceNmi == TRUE)
+ {
+ HdrPtr = BuildLocalApicNmi(
+ AcpiProcInfo->LocalApicType == ACPI_PROC_INFO_x2APIC,
+ AcpiProcInfo->ProcId,
+ AcpiProcInfo->LintnPin,
+ AcpiProcInfo->NmiFlags
+ );
+
+ Status = AppendItemLst ((T_ITEM_LIST*)MadtTblEntries, (VOID*) HdrPtr);
+ ASSERT_EFI_ERROR(Status);
+ }
+ }
+ //An earlier version ACPI_PROCESSOR_INFO with a smaller structure may be have been published,
+ //so use length field.
+ AcpiProcInfo = (ACPI_PROCESSOR_INFO*)((UINT8*)AcpiProcInfo + AcpiProcInfo->Length);
+ }
+ return Status;
+}
+
+
+#endif
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BuildLocalApicNmi
+//
+// Description: Allocates memory for and builds local APIC or local x2APIC NMI entry
+//
+// Input:
+// IN UINT32 ProcessorId - MADT NMI entry processor id or UID
+// IN UINT8 LapicInitIn - MADT Local (x2)apic NMI Pin
+// IN UINT16 Flags - MADT Local (x2) apic flags
+//
+// Output:
+// MADT_ENTRY_HEADER * - pointer to the LAPIC NMI entry header for the MADT table
+// if NULL - not enough memory
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+MADT_ENTRY_HEADER * BuildLocalApicNmi(IN BOOLEAN X2Apic, IN UINT32 ProcessorId, IN UINT8 LapicInitIn, IN UINT16 Flags)
+{
+ MADT_ENTRY_HEADER *HdrPtr;
+
+ if (X2Apic)
+ {
+ HdrPtr = MallocZ(sizeof(LX2APIC_NMI));
+ ASSERT (HdrPtr);
+
+ if (!HdrPtr) return NULL;
+
+ ((LX2APIC_NMI*) HdrPtr)->Header.Type = AT_LX2APIC_NMI; //Type 10 - indicating Local x2APIC NMI Entry.
+ ((LX2APIC_NMI*) HdrPtr)->Header.Length = sizeof(LX2APIC_NMI);
+ ((LX2APIC_NMI*) HdrPtr)->Flags = Flags;
+ ((LX2APIC_NMI*) HdrPtr)->Uid = ProcessorId;
+ ((LX2APIC_NMI*) HdrPtr)->LapicIntin = LapicInitIn;
+ }
+ else
+ {
+ HdrPtr = MallocZ(sizeof(LNMI_H20));
+ ASSERT (HdrPtr);
+
+ if (!HdrPtr) return NULL;
+
+ ((LNMI_H20*) HdrPtr)->Header.Type = AT_LAPIC_NMI; //Type 4 - indicating LAPIC NMIs Entry
+ ((LNMI_H20*) HdrPtr)->Header.Length = sizeof(LNMI_H20);
+ ((LNMI_H20*) HdrPtr)->Flags = Flags;
+ ((LNMI_H20*) HdrPtr)->CPU_ID = (UINT8)ProcessorId;
+ ((LNMI_H20*) HdrPtr)->LapicIntin = LapicInitIn;
+ }
+
+ return HdrPtr;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BuildMadtAll
+//
+// Description: Creates MADT entries, stores them as T_ITEM_LIST, calculates
+// space needed, allocates memory and builds MADT table from entries
+//
+// Input:
+// IN UINTN TablVer - ACPI Spec. Version
+// OUT ACPI_HDR **TablPtr - Pointer, to the MADT table, filled by this function
+//
+// Output: EFI_STATUS
+// EFI_OUT_OF_RESOURCES - not enough memory
+// EFI_UNSUPPORTED - CPU info hob not found
+// EFI_INVALID_PARAMETER - invalid ACPI version
+// EFI_SUCCESS - MADT table were successfully build
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS BuildMadtAll(IN UINTN TablVer, OUT ACPI_HDR **TablPtr)
+{
+ UINTN LastItem;
+ EFI_STATUS Status;
+ MADT_ENTRIES MadtTblEntries = {0, 0, NULL};
+ MADT_ENTRY_HEADER *HdrPtr;
+ UINT32 IoapicVbase = 0, AllStrLength = 0, IoapicAddr = 0;
+ UINT8 *DestinPtr;
+ UINTN i, j;
+ UINTN IoApicCnt=0;
+
+//--------------------------------
+ if (TablVer<1 || TablVer>4) return EFI_INVALID_PARAMETER;
+
+//-------Build LAPIC or/and LSAPIC Entries.
+#ifdef ACPI_INFO2_PROTOCOL_PUBLISHED
+ // Update for Haswell CPU Refcode. >>>
+ Status = pBS->LocateProtocol(&gAmiCpuInfo2ProtocolGuid, NULL, &gAmiCpu2Info);
+ // <<< Update for Haswell CPU Refcode.
+ Status = EFI_UNSUPPORTED;
+
+ //First try to build Local APIC information from the protocol.
+ if (gAmiCpu2Info != NULL)
+ {
+ Status = BuildLapicsFromProtocol(TablVer, &MadtTblEntries);
+ }
+
+ //If protocol fails, try CPU INFO HOB.
+ if (EFI_ERROR(Status))
+ {
+
+#endif
+ Status = BuildLapicsFromHob(TablVer, &MadtTblEntries);
+ ASSERT_EFI_ERROR(Status);
+#ifdef ACPI_INFO2_PROTOCOL_PUBLISHED
+ }
+
+#endif
+ //Set Marker at last item before IOAPIC/IOsAPIC entries
+ LastItem = MadtTblEntries.MadtEntCount;
+
+//The folloving code may enable IOAPIC Devices found on PCI BUS
+//This IOAPICs might use their ABARs to clame MMIO in FEC0_0000 space.
+//So we need to run this code prior if we don't want to miss any IOAPICs.
+//--------------------------------------------------------------------
+#if PCI_BUS_APIC_AUTODETECT == 1
+ {
+ EFI_HANDLE *pHandleBuffer;
+ UINTN NumberOfHandles;
+ UINT8 PciData[4];
+ EFI_GUID PciIoProtocolGuid = EFI_PCI_IO_PROTOCOL_GUID;
+ EFI_PCI_IO_PROTOCOL *pPciIoProtocol;
+
+ Status = pBS->LocateHandleBuffer(ByProtocol, &PciIoProtocolGuid,
+ NULL, &NumberOfHandles, &pHandleBuffer);
+
+ //The protocol might not be available when function runs first time.
+ //we will rerun it on READY_TO_BOOT event again.
+ if (!EFI_ERROR(Status))
+ {
+
+ for (i = 0; i < NumberOfHandles; i++)
+ {
+ Status = pBS->HandleProtocol(pHandleBuffer[i], &PciIoProtocolGuid,
+ (VOID**)&pPciIoProtocol);
+
+ if (EFI_ERROR(Status))
+ continue;
+
+ //read class code information at 0x8 offset in PCI header
+ Status = pPciIoProtocol->Pci.Read(pPciIoProtocol, EfiPciIoWidthUint32,
+ 0x8, 1, &PciData[0]);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) //problem
+ continue;
+
+ //if IO APIC device
+ if ((PciData[3] == 0x8) && (PciData[2] == 0) && (PciData[1] >= 0x10))
+ {
+ UINT64 Attr=0, OldAttr=0;
+ //----------------------
+ //1. make sure it is Enabled and Decoding it's resources
+ Status=pPciIoProtocol->Attributes(pPciIoProtocol,EfiPciIoAttributeOperationGet, Attr, &OldAttr);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) continue;
+
+ Status=pPciIoProtocol->Attributes(pPciIoProtocol,EfiPciIoAttributeOperationSupported, 0, &Attr);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) continue;
+
+ Status=pPciIoProtocol->Attributes(pPciIoProtocol,EfiPciIoAttributeOperationSet, Attr&(EFI_PCI_DEVICE_ENABLE), NULL);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) continue;
+
+
+ //2. collect info
+ Status = pPciIoProtocol->Pci.Read(pPciIoProtocol, EfiPciIoWidthUint32,
+ 0x10, 1, (VOID*)&IoapicAddr);
+ //problem or mapped to default address range
+ ASSERT_EFI_ERROR(Status);
+
+ if ( ! (EFI_ERROR(Status) || (IoapicAddr == 0)) )
+ {
+ HdrPtr = BuildIoapicIosapic(IoapicAddr, &IoapicVbase);
+
+ if (!HdrPtr) return EFI_OUT_OF_RESOURCES;
+
+ if (MadtTblEntries.MadtEntCount == LastItem) // Adding entries in groving IOapicId/IOsapicId value order
+ {
+ Status = AppendItemLst ((T_ITEM_LIST*)&MadtTblEntries, (VOID*) HdrPtr);// First entry
+ }
+
+ else
+ {
+ for (j = (LastItem); j < MadtTblEntries.MadtEntCount; j++) // No need to handle LSAPIC entry in different way
+ {
+ // IOapicId and IOsapicId filds are on the same place in bouth structures
+ if (((IOAPIC_H32*)HdrPtr)->IoapicId < ((IOAPIC_H32*)MadtTblEntries.MadtEntries[j])->IoapicId) break;
+ } // found entry with bigger IOapicId/IOsapicId
+
+ if (j == MadtTblEntries.MadtEntCount)
+ {
+ Status = AppendItemLst ((T_ITEM_LIST*)&MadtTblEntries, (VOID*) HdrPtr);
+ }
+
+ else
+ {
+ Status = InsertItemLst ((T_ITEM_LIST*)&MadtTblEntries, (VOID*) HdrPtr, j);
+ }
+
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return EFI_OUT_OF_RESOURCES;
+
+ IoApicCnt++;
+ }
+ }//if( ! (EFI_ERROR(Status) || (IoapicAddr == 0)) )
+
+#if PCI_BUS_APIC_LEAVE_ENABLE != 0
+ //Restore attributes of the device
+ Status=pPciIoProtocol->Attributes(pPciIoProtocol,EfiPciIoAttributeOperationSet, OldAttr, NULL);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) continue;
+
+#endif
+ }//if((PciData[3] == 0x8) && (PciData[2] == 0) && (PciData[1] >= 0x10))
+ }//for(i = 0; i < NumberOfHandles; i++)
+
+ pBS->FreePool(pHandleBuffer);
+ }//if(!EFI_ERROR(Status))
+ }
+#endif //PCI_BUS_APIC_AUTODETECT == 1
+
+//--------------------------------------------------------------------
+//---Creating IOAPIC or/and IOSAPIC Entries
+#if (APCB != 0)
+ IoapicAddr = APCB;
+#else
+ IoapicAddr = IOA_BASE_BOT;
+#endif
+
+#if FEC00000_APIC_AUTODETECT == 1
+
+ //trying to check if something alive present at 0xFEC00000..0xFED00000
+ for ( ; IoapicAddr < IOA_BASE_TOP; IoapicAddr += 0x1000)
+ { //If so read IOAPIC.ID reg and figure out
+ //1.How many INTINs it has
+ //2.What ID BIOS give to it
+ if (*((UINT8 *)(IoapicAddr + IOA_IND_REG_OFFS)) != 0xFF)
+ {
+ HdrPtr = BuildIoapicIosapic(IoapicAddr, &IoapicVbase);
+
+ if (!HdrPtr) return EFI_OUT_OF_RESOURCES;
+
+ if (MadtTblEntries.MadtEntCount == LastItem) // Adding entries in groving IOapicId/IOsapicId value order
+ Status = AppendItemLst ((T_ITEM_LIST*)&MadtTblEntries, (VOID*) HdrPtr);// First entry
+ else
+ {
+ for (j = (LastItem); j < MadtTblEntries.MadtEntCount; j++)
+ { // No need to handle LSAPIC entry in different way
+ if (((IOAPIC_H32*)HdrPtr)->IoapicId < ((IOAPIC_H32*)MadtTblEntries.MadtEntries[j])->IoapicId) break; // IOapicId and IOsapicId filds are on the same place in bouth structures
+ } // found entry with bigger IOapicId/IOsapicId
+
+ if (j == MadtTblEntries.MadtEntCount)
+ {
+ Status = AppendItemLst ((T_ITEM_LIST*)&MadtTblEntries, (VOID*) HdrPtr);
+ }
+
+ else
+ {
+ Status = InsertItemLst ((T_ITEM_LIST*)&MadtTblEntries, (VOID*) HdrPtr, j);
+ }
+ }
+
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return EFI_OUT_OF_RESOURCES;
+
+ IoApicCnt++;
+ }
+ }
+
+#endif //FEC00000_APIC_AUTODETECT == 1
+
+//---------------------------------------------------------------------
+
+#if USE_BOARD_INFO_APIC_DATA == 1
+ {
+ AMI_APIC_INFO *BrdApicInfo;
+ BOOLEAN Present;
+
+ //-----------------
+ for (i=0; i<(gAmiBoardInfoProtocol->ApicInfoLength/sizeof(AMI_APIC_INFO)); i++)
+ {
+
+ BrdApicInfo=&gAmiBoardInfoProtocol->ApicInfoTable[i];
+
+ //This is a special case it could be a duplicate entries in MadtTblEntries[]
+ //if other options of IOAPIC/IOsAPIC detection was on.
+ //So check if IOAPIC/IOsAPIC entries with the same properties already present in DB.
+ for (j=(LastItem),Present=FALSE; j < MadtTblEntries.MadtEntCount; j++)
+ {
+ HdrPtr=MadtTblEntries.MadtEntries[j];
+
+ if (HdrPtr->Type==AT_IOAPIC)
+ {
+ IOAPIC_H20 *apic=(IOAPIC_H20*)HdrPtr;
+
+ //----------------------
+ if (BrdApicInfo->ApicAddress.ADDRESS == apic->IoapicAddress)
+ {
+ Present = TRUE;
+ break;
+ }
+ }
+
+ else //Nothing else should not be here except IOAPIC or IOSAPIC entries
+ {
+ IOSAPIC_H20 *sapic=(IOSAPIC_H20*)HdrPtr;
+
+ //----------------------
+ if ((UINT64)BrdApicInfo->ApicAddress.ADDRESS == sapic->IosapicAddress)
+ {
+ Present = TRUE;
+ break;
+ }
+ }
+ }
+
+ //Entry with this address already present in MadtTblEntries array
+ if (Present) continue;
+
+ //Looks like it is a new IOAPIC/IOSAPIC entry!
+ //Check if something alive at this address
+ if (*((UINT8 *)BrdApicInfo->ApicAddress.ADDRESS) != 0xFF)
+ {
+ IoapicAddr=BrdApicInfo->ApicAddress.ADDRESS;
+ HdrPtr = BuildIoapicIosapic(IoapicAddr, &IoapicVbase);
+
+ if (!HdrPtr) return EFI_OUT_OF_RESOURCES;
+
+ if (MadtTblEntries.MadtEntCount == LastItem) // Adding entries in groving IOapicId/IOsapicId value order
+ Status = AppendItemLst ((T_ITEM_LIST*)&MadtTblEntries, (VOID*) HdrPtr);// First entry
+ else
+ {
+ for (j = (LastItem); j < MadtTblEntries.MadtEntCount; j++)
+ { // No need to handle LSAPIC entry in different way
+ if (((IOAPIC_H32*)HdrPtr)->IoapicId < ((IOAPIC_H32*)MadtTblEntries.MadtEntries[j])->IoapicId) break; // IOapicId and IOsapicId filds are on the same place in bouth structures
+ } // found entry with bigger IOapicId/IOsapicId
+
+ if (j == MadtTblEntries.MadtEntCount)
+ {
+ Status = AppendItemLst ((T_ITEM_LIST*)&MadtTblEntries, (VOID*) HdrPtr);
+ }
+
+ else
+ {
+ Status = InsertItemLst ((T_ITEM_LIST*)&MadtTblEntries, (VOID*) HdrPtr, j);
+ }
+ }
+
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return EFI_OUT_OF_RESOURCES;
+
+ IoApicCnt++;
+ }
+ } // if(...i<(gAmiBoardInfoProtocol->ApicInfoLength/sizeof(AMI_APIC_INFO))
+ }
+#endif //USE_BOARD_INFO_APIC_DATA ==1
+
+//-------------------------------------------------------------------------------------------
+ if (!IoApicCnt)
+ {
+ HdrPtr = BuildIoapicManualy();
+
+ if (!HdrPtr) return EFI_OUT_OF_RESOURCES;
+
+ IoapicVbase = (UINT32) 1;
+ Status = AppendItemLst ((T_ITEM_LIST*)&MadtTblEntries, (VOID*) HdrPtr);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return EFI_OUT_OF_RESOURCES;
+ }
+
+
+//-------Build ISO Structure----------------------------
+ for (i=0; i<IsoCnt; i++)
+ {
+ if (IsoTbl[i].PicIrq == 0xFF) continue; //no override for this entry
+
+ HdrPtr = BuildIsoFromTbl(i);
+
+ if (!HdrPtr) return EFI_OUT_OF_RESOURCES;
+
+ Status = AppendItemLst ((T_ITEM_LIST*)&MadtTblEntries, (VOID*) HdrPtr);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return Status;
+ }
+
+//-------Build NMIs Structure---------------------------
+ Status = EFI_UNSUPPORTED;
+#if AMI_CPU_INFO_2_PROTOCOL_VERSION >= 3
+ //First try to build Local APIC information from the protocol.
+ if (gAmiCpu2Info != NULL)
+ {
+ Status = BuildLapicNmiFromProtocol(&MadtTblEntries);
+ }
+#endif
+
+ if (EFI_ERROR(Status))
+ {
+#if (NMIs_QUANTITY > 0)
+
+ HdrPtr = MallocZ(sizeof(NMI_H20));
+ ASSERT (HdrPtr);
+
+ if (!HdrPtr) return EFI_OUT_OF_RESOURCES;
+
+ ((NMI_H20*) HdrPtr)->Header.Type = (UINT8) AT_NMI; //Type 3 - indicating NMIs Entry
+ ((NMI_H20*) HdrPtr)->Header.Length = (UINT8) sizeof(NMI_H20);
+ ((NMI_H20*) HdrPtr)->Flags = (UINT16)((NMI_0_TRIGGER_MODE<<2) | NMI_0_POLARITY);
+ ((NMI_H20*) HdrPtr)->GlobalSysVect = (UINT32) NMI_GLOBAL_SYS_INT_0;
+ Status = AppendItemLst ((T_ITEM_LIST*)&MadtTblEntries, (VOID*) HdrPtr);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return Status;
+
+#if (NMIs_QUANTITY > 1)
+ HdrPtr = MallocZ(sizeof(NMIH_20));
+ ASSERT (HdrPtr);
+
+ if (!HdrPtr) return EFI_OUT_OF_RESOURCES;
+
+ ((NMI_H20*) HdrPtr)->Header.Type = (UINT8) AT_NMI; //Type 3 - indicating NMIs Entry
+ ((NMI_H20*) HdrPtr)->Header.Length = (UINT8) sizeof(NMI_H20);
+ ((NMI_H20*) HdrPtr)->Flags = (UINT16)((NMI_1_TRIGGER_MODE<<2) | NMI_1_POLARITY);
+ ((NMI_H20*) HdrPtr)->GlobalSysVect = (UINT32) NMI_GLOBAL_SYS_INT_1;
+ Status = AppendItemLst ((T_ITEM_LIST*)&MadtTblEntries, (VOID*) HdrPtr);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return Status;
+
+#endif
+
+//---Porting Hook 1 ------ If NMIs_QUANTITY > 2 - Add more structures
+#endif
+//--------Build LAPIC NMI-------------------------
+
+#if (LAPIC_QUANTITY > 0)
+
+ if (LAPIC_0_INT_TYPE == 1) // This is NMI - so build a table for it
+ {
+ HdrPtr = BuildLocalApicNmi(gX2Apic ? TRUE : FALSE, 0xffffffff, LAPIC_0_DEST_LINTIN, (LAPIC_0_TRIGGER_MODE<<2) | LAPIC_0_POLARITY);
+ ASSERT (HdrPtr);
+
+ if (!HdrPtr) return EFI_OUT_OF_RESOURCES;
+
+ Status = AppendItemLst ((T_ITEM_LIST*)&MadtTblEntries, (VOID*) HdrPtr);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return Status;
+ }
+
+#if (LAPIC_QUANTITY > 1)
+
+ if (LAPIC_1_INT_TYPE == 1) // This is NMI - so build a table for it
+ {
+ HdrPtr = BuildLocalApicNmi(gX2Apic ? TRUE : FALSE, 0xffffffff, LAPIC_1_DEST_LINTIN, (LAPIC_1_TRIGGER_MODE<<2) | LAPIC_1_POLARITY);
+ ASSERT (HdrPtr);
+
+ if (!HdrPtr) return EFI_OUT_OF_RESOURCES;
+
+ Status = AppendItemLst ((T_ITEM_LIST*)&MadtTblEntries, (VOID*) HdrPtr);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return Status;
+ }
+
+#endif
+#if (LAPIC_QUANTITY > 2)
+
+ if (LAPIC_2_INT_TYPE == 1) // This is NMI - so build a table for it
+ {
+ HdrPtr = BuildLocalApicNmi(gX2Apic ? TRUE : FALSE, 0xffffffff, LAPIC_2_DEST_LINTIN, (LAPIC_2_TRIGGER_MODE<<2) | LAPIC_2_POLARITY);
+ ASSERT (HdrPtr);
+
+ if (!HdrPtr) return EFI_OUT_OF_RESOURCES;
+
+ Status = AppendItemLst ((T_ITEM_LIST*)&MadtTblEntries, (VOID*) HdrPtr);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return Status;
+ }
+
+#endif
+//------Porting Hook 2----If LAPIC_QUANTITY > 3 - Add more structures
+#endif
+ }
+
+//---Tis ia all for Ver 1 - building a table----------------------
+//----Here starts entries for V 2 and 3 which are empty for now----------------------------------
+//
+// Here entries for LAPIC Address overrride structure and Platforme interrupt source structure
+//
+
+ for (i = 0; i < MadtTblEntries.MadtEntCount; i++)
+ {
+
+ AllStrLength += MadtTblEntries.MadtEntries[i]->Length;
+ }
+
+ *TablPtr = MallocZ(sizeof(APIC_20H) + (UINTN) AllStrLength);
+ ASSERT (*TablPtr);
+
+ if (!(*TablPtr)) return EFI_OUT_OF_RESOURCES;
+
+ if (TablVer == 1) PrepareHdr1 (APIC_SIG, (PACPI_HDR) *TablPtr);
+ else PrepareHdr20 (APIC_SIG, (PACPI_HDR) *TablPtr, TablVer);
+
+ (*TablPtr)->Length = (sizeof(APIC_20H) + AllStrLength);
+ ((APIC_20H*)*TablPtr)->LAPIC_Address = LOCAL_APIC_BASE;
+ ((APIC_20H*)*TablPtr)->Flags = ACPI_APIC_FLAGS;
+ DestinPtr = ((UINT8*) *TablPtr + sizeof(APIC_20H));
+
+ for (i = 0; i < MadtTblEntries.MadtEntCount; i++)
+ {
+
+ MemCopy ((UINT8*)MadtTblEntries.MadtEntries[i], DestinPtr, (UINT32) MadtTblEntries.MadtEntries[i]->Length);
+ DestinPtr += MadtTblEntries.MadtEntries[i]->Length;
+ pBS->FreePool((VOID*)MadtTblEntries.MadtEntries[i]);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return Status;
+ }
+
+ (*TablPtr)->Checksum = 0;
+ (*TablPtr)->Checksum = ChsumTbl((UINT8*)*TablPtr, (*TablPtr)->Length);
+
+ return EFI_SUCCESS;
+}// end of BuildMadtAll-----------------------------------------
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: BuildFacs
+//
+// Description: Allocates ACPI NVS memory and builds FACS table from values,
+// defined by SDL tokens
+//
+// Input: none
+//
+//
+// Output: EFI_STATUS
+// EFI_OUT_OF_RESOURCES - not enough memory
+// EFI_SUCCESS - FACS table were successfully build
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS BuildFacs ()
+{
+ EFI_STATUS Status;
+ UINTN Size;
+
+
+ if (gForceAcpi1) Size = sizeof(FACS_20);
+ else Size = sizeof(FACS_20)*2;
+ Status = pBS->AllocatePool(EfiACPIMemoryNVS, Size+64, &gFacs);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return EFI_OUT_OF_RESOURCES;
+
+#ifdef EFIx64
+
+ if (((UINT64)gFacs) & 0xffffffff00000000)
+ {
+ EFI_PHYSICAL_ADDRESS Memory = 0x00000000ffffffff;
+ Status = pBS->FreePool(gFacs);
+ ASSERT_EFI_ERROR(Status);
+ Status = pBS->AllocatePages(AllocateMaxAddress, EfiACPIMemoryNVS, 1, &Memory);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return EFI_OUT_OF_RESOURCES;
+
+ (UINTN) gFacs = Memory;
+ }
+
+#endif
+ (UINTN) gFacs += 64;
+ (UINTN) gFacs &= (~0x3F);
+ pBS->SetMem(gFacs, Size, 0);
+ gFacs->Signature=(UINT32)FACS_SIG;
+ gFacs->Length=sizeof(FACS_20);
+ gFacs->Flags=FACS_FLAG_S4BIOS;
+
+ if (gForceAcpi1) return EFI_SUCCESS;
+
+ (UINTN) gxFacs = (UINTN) gFacs + sizeof(FACS_20);
+ gxFacs->Signature=(UINT32)FACS_SIG;
+ gxFacs->Length=sizeof(FACS_20);
+
+ if (ACPI_BUILD_TABLES_4_0 != 1)
+ {
+ gxFacs->Flags=FACS_FLAG_S4BIOS;
+ gxFacs->Version=ACPI_REV1;
+ }
+
+ else
+ {
+ gxFacs->Flags = FACS_FLAG_S4BIOS | (FACS_FLAG_64BIT_WAKE_SUPPORTED << 1);
+ gxFacs->Version=ACPI_REV2;
+ }
+
+
+
+
+ return EFI_SUCCESS;
+}// end of BuildFacs ---------------------------------------------
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetDsdtFv
+//
+// Description:
+// This function finds DSDT table in firmvare volume
+//
+// Input:
+// OUT ACPI_HDR **Dsdt1 - pointer to memory where DSDT v1.1 table will be stored
+// OUT ACPI_HDR **Dsdt2 - pointer to memory where DSDT v2.0+ table will be stored
+//
+// Output:
+// EFI_SUCCESS - Function executed successfully
+// EFI_ABORTED - ACPI storage file not found
+// EFI_NOT_FOUND - DSDT table not found in firmware volume
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS GetDsdtFv(OUT ACPI_HDR **Dsdt1, OUT ACPI_HDR **Dsdt2)
+{
+
+ //In current AmiBoardInfo implementation separate instance of
+ //DSDT for ACPI version 1.1b DOES OT SUPPORTED!
+ *Dsdt1=NULL;
+ *Dsdt2 = Malloc(((ACPI_HDR*)gAmiBoardInfoProtocol->BoardAcpiInfo)->Length);
+ ASSERT(*Dsdt2);
+ if (((UINT64)*Dsdt2) & 0xffffffff00000000)
+ {
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS Memory = 0x00000000ffffffff;
+
+ Status = pBS->FreePool(*Dsdt2);
+ ASSERT_EFI_ERROR(Status);
+
+ Status = pBS->AllocatePages(AllocateMaxAddress, EfiBootServicesData,
+ EFI_SIZE_TO_PAGES(((ACPI_HDR*)gAmiBoardInfoProtocol->BoardAcpiInfo)->Length),
+ &Memory);
+ ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR(Status)) return EFI_OUT_OF_RESOURCES;
+
+ *Dsdt2 = (ACPI_HDR *)((UINTN)Memory);
+ }
+
+ if (*Dsdt2==NULL) return EFI_OUT_OF_RESOURCES;
+
+ pBS->CopyMem(*Dsdt2, gAmiBoardInfoProtocol->BoardAcpiInfo,
+ ((ACPI_HDR*)gAmiBoardInfoProtocol->BoardAcpiInfo)->Length);
+
+
+ if ((*Dsdt1 == NULL) && (*Dsdt2 == NULL))
+ {
+ TRACE((-1,"Acpi: No DSDT was FOUND: Status=EFI_NOT_FOUND\n"));
+ return EFI_NOT_FOUND;
+ }
+
+ //PrepareHdr1(DSDT_SIG, (ACPI_HDR*)(*Dsdt1));
+ PrepareHdr20(DSDT_SIG, (ACPI_HDR*)(*Dsdt2),2);
+
+ return EFI_SUCCESS;
+
+}// end of GetDsdtFv -----------------------------------------------
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UpdateFacp
+//
+// Description: This function Updates FACP with the new values for DSDT and Facs
+// pointers
+//
+// Input: FACS_20* gFacs1 - Pointer to gFacs Table for V 1
+// FACS_20* gFacs2 - Pointer to gFacs Table for V 2 or 3
+//
+// Output: EFI_SUCCESS - Function executed successfully
+// EFI_ABORTED - Error
+//
+//
+// Modifies gAcpiData
+//
+//-----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS UpdateFacp () //(FACS_20 *gFacs1, FACS_20 *gFacs2)
+{
+ ACPI_HDR *Facp1 = NULL, *Facp2 = NULL, *Dsdt1 = NULL, *Dsdt2 = NULL;
+ UINTN i;
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ for (i = 0; i < gAcpiData.AcpiEntCount; i++)
+ {
+ if (gAcpiData.AcpiEntries[i]->BtHeaderPtr->Signature == FACP_SIG)
+ {
+ if (gAcpiData.AcpiEntries[i]->AcpiTblVer == EFI_ACPI_TABLE_VERSION_1_0B)
+ Facp1 = gAcpiData.AcpiEntries[i]->BtHeaderPtr; // Find FACP for V 1.1
+ else
+ Facp2 = gAcpiData.AcpiEntries[i]->BtHeaderPtr; // Find FACP for V 2+
+ }
+
+ if (gAcpiData.AcpiEntries[i]->BtHeaderPtr->Signature == DSDT_SIG)
+ {
+ if (gAcpiData.AcpiEntries[i]->AcpiTblVer == EFI_ACPI_TABLE_VERSION_1_0B)
+ Dsdt1 = gAcpiData.AcpiEntries[i]->BtHeaderPtr; // Find DSDT for V 1.1
+ else
+ Dsdt2 = gAcpiData.AcpiEntries[i]->BtHeaderPtr; // Find DSDT for V 2+
+ }
+ }
+
+ if (Dsdt1 == NULL) Dsdt1 = Dsdt2; // The same DSDT for V1.1
+
+ if (Dsdt2 == NULL) Dsdt2 = Dsdt1; // The same DSDT for V2
+
+ if ((Facp1 == NULL) || (Dsdt1 == NULL)) Status = EFI_ABORTED;
+ if ((Facp2 == NULL) && (!gForceAcpi1)) Status = EFI_ABORTED;
+
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR (Status)) return Status;
+
+//--- Updating FACP for V1.1 and 2+---------------------------
+ ((FACP32*) Facp1)->FIRMWARE_CTRL = (UINT32) gFacs;
+ ((FACP32*) Facp1)->DSDT = (UINT32) Dsdt1;
+
+
+ Facp1->Checksum = 0;
+ Facp1->Checksum = ChsumTbl((UINT8*)Facp1, Facp1->Length);
+ if (gForceAcpi1) return Status;
+ if (ACPI_BUILD_TABLES_4_0 == 1) ((FACP_20*) Facp2)->FIRMWARE_CTRL = (UINT32) gxFacs;
+ else ((FACP_20*) Facp2)->FIRMWARE_CTRL = (UINT32) gFacs;
+
+ ((FACP_20*) Facp2)->DSDT = (UINT32) Dsdt1;
+
+ if (ACPI_BUILD_TABLES_4_0 != 1)((FACP_20*) Facp2)->X_FIRMWARE_CTRL = (UINT64) ((UINTN) gxFacs);
+
+ ((FACP_20*) Facp2)->X_DSDT = (UINT64) ((UINTN)Dsdt2);
+ Facp2->Checksum = 0;
+ Facp2->Checksum = ChsumTbl((UINT8*)Facp2, Facp2->Length);
+ return Status;
+}// end of UpdateFacp
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: FindAcpiTblByHandle
+//
+// Description: Finds ACPI table by Handle and returns its entry number in
+// gAcpiData structure
+//
+// Input: UINTN *Handle - Handle (pointer to ACPI table header)
+//
+//
+// Output: UINTN - Entry number in gAcpiData structure
+// ACPI_TABLE_NOT_FOUND if not found
+//
+//-----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINTN FindAcpiTblByHandle (UINTN *Handle)
+{
+ UINTN i;
+
+ for (i = 0; i < gAcpiData.AcpiEntCount; i++)
+ {
+ if (*Handle == (UINTN)gAcpiData.AcpiEntries[i]->BtHeaderPtr) // Handle is the address of ACPI table
+ {
+ return i;
+ }
+ }
+
+ return ACPI_TABLE_NOT_FOUND;
+}// end of FindAcpiTblByHandle
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetBtTable
+//
+// Description: Founds ACPI Table with defined Signature (Sig) and Version in gAcpiData structure.
+//
+//
+// Input: OUT ACPI_TBL_ITEM **TblPtr - pointer to the ACPI entrie in gAcpiData,
+// modifided by this function
+// IN UINT32 Sig - Signature of a table to search for
+// IN EFI_ACPI_TABLE_VERSION - Version of a table to be found
+//
+// Output: EFI_SUCCESS - table with corresponding signature was found
+// EFI_NOT_FOUND - otherwise
+//
+//-----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetBtTable (OUT ACPI_TBL_ITEM **TblPtr, IN UINT32 Sig, IN EFI_ACPI_TABLE_VERSION Versiov)
+{
+ UINTN i;
+
+ for (i = 0; i < gAcpiData.AcpiEntCount; i++)
+ {
+ if ((gAcpiData.AcpiEntries[i]->BtHeaderPtr->Signature == Sig)
+ && (gAcpiData.AcpiEntries[i]->AcpiTblVer & Versiov))
+ {
+ *TblPtr = gAcpiData.AcpiEntries[i];
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}// end of GetBtTable
+
+#if defined(PI_SPECIFICATION_VERSION)&&(PI_SPECIFICATION_VERSION>=0x00010014)
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: DispatchSdtNotify
+//
+// Description: Checks if Notify function(s) present dispatches it.
+//
+//
+// Input: EFI_ACPI_SDT_HEADER *TableHeaderPtr - pointer to the ACPI Table header,
+// modifided by this function
+// Output: EFI_STATAUS - From the function dispatched.
+//
+//-----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS DispatchSdtNotify(ACPI_TBL_ITEM* TableItemPtr){
+ EFI_STATUS Status=EFI_SUCCESS;
+ UINTN i;
+//--------
+ for(i=0;i<gAcpiData.NotifyFnCount; i++){
+ Status=gAcpiData.AcpiNotifyFn[i]((EFI_ACPI_SDT_HEADER*)TableItemPtr->BtHeaderPtr,TableItemPtr->AcpiTblVer,(UINTN)TableItemPtr);
+
+ ASSERT_EFI_ERROR(Status);
+ }
+
+ return Status;
+}
+#endif
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: FillAcpiStr
+//
+// Description: Copys table from position pointed by FromPtr to a position pointed
+// by ToPtr (which is in EfiACPIReclaimMemory) and fills RSDT and XSDT
+// pointers with ToPtr value
+//
+//
+// Input: RSDT32 *RsdtPtr - pionter to RSDT
+// XSDT_20 *XsdtPtr - pionter to XSDT
+// VOID *FromPtr - pointer to a table which should be copyed
+// VOID *ToPtr - pointer to EfiACPIReclaimMemory where table should be placed
+//
+// Output: UINT8* - Pointer to the next avaiable space in allocated EfiACPIReclaimMemory
+// right after copyed table (alligned already)
+// If NUUL - Invalid parameters.
+//
+//-----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+UINT8 *FillAcpiStr (RSDT32 *RsdtPtr, XSDT_20 *XsdtPtr, VOID *FromPtr, VOID *ToPtr)
+{
+ UINT8 *NextPtr;
+ UINTN i;
+
+
+ if ((RsdtPtr == NULL) && (XsdtPtr == NULL)) return NULL;
+
+ if ((FromPtr == NULL) || (ToPtr == NULL)) ASSERT(0);
+
+ pBS->CopyMem(ToPtr, FromPtr, ((ACPI_HDR*)FromPtr)->Length);
+
+ if (RsdtPtr != NULL)
+ {
+ for (i = 0; RsdtPtr->Ptrs[i] != 0; i++); // Find first unfilled (last) entry in RSDT
+
+ RsdtPtr->Ptrs[i] = (UINT32) ToPtr;
+ }
+
+ if (XsdtPtr != NULL)
+ {
+ for (i = 0; XsdtPtr->Ptrs[i] != 0; i++); // Find first unfilled (last) entry in XSDT
+
+ XsdtPtr->Ptrs[i] = (UINT64) ((UINTN)ToPtr);
+ }
+
+ NextPtr = (UINT8*) ((UINT8*)ToPtr+((ACPI_HDR*)ToPtr)->Length + 7);
+ (UINTN) NextPtr &= (~0x7);
+
+ return NextPtr;
+
+}//end of FillAcpiStr
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: PublishTbl
+//
+// Description: Creates or rewrites RSDT_PTR structure and copys tables, stored
+// in gAcpiData structure in allocated EfiACPIReclaimMemory.
+//
+//
+// Input: IN UINTN RsdtBuild - if 1 - Build RSDT and copy tables of Ver 1.1
+// IN UINTN XsdtBuild - if 1 - Build XSDT and copy tables of Ver 2+
+//
+// Output: EFI_OUT_OF_RESOURCES - not enough memory
+// EFI_ABORTED - invalid parameters
+// EFI_SUCCESS - RSDT_PTR structure was successfully build
+//
+//-----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS PublishTbl (IN UINTN RsdtBuild, IN UINTN XsdtBuild)
+{
+ ACPI_HDR *Facp = NULL, *FacpX = NULL, *Dsdt = NULL, *DsdtX = NULL;
+ RSDT32 *Rsdt = NULL;
+ XSDT_20 *Xsdt = NULL;
+ UINTN i, j, RsdtCnt = 0, XsdtCnt = 0, SpaceNeeded = 0, RsdtSize = 0, XsdtSize = 0, Skip;
+ EFI_STATUS Status;
+ UINT8 *Ptr = NULL, *Dummy = NULL, OneDsdt = 0;
+ EFI_PHYSICAL_ADDRESS Memory = 0x00000000ffffffff;
+
+ if (((RsdtBuild == 0) && (XsdtBuild == 0)) || (RsdtBuild > 1 ) || (XsdtBuild > 1)) return EFI_ABORTED;
+#if defined(OemActivation_SUPPORT) && (OemActivation_SUPPORT == 1)
+ if (!gOA3Variable)
+ {
+ UINTN SizeOfMsdm = sizeof(EFI_OA3_MSDM_STRUCTURE);
+ //Looking for Var which signals that MSDM table may be updated on runtime
+ Status = pRS->GetVariable(
+ EFI_OA3_MSDM_VARIABLE,
+ &gAmiGlobalVariableGuid,
+ NULL,
+ &SizeOfMsdm,
+ &gMsdmVariable
+ );
+ if (Status == EFI_SUCCESS)
+ {
+ gOA3Variable = TRUE;
+ XsdtCnt++; // Reserving Entry for MSDM (OEM Activation)
+ }
+ }
+ else XsdtCnt++;
+#endif
+ for (i = 0; i < gAcpiData.AcpiEntCount; i++)
+ {
+ if (gAcpiData.AcpiEntries[i]->AcpiTblVer < EFI_ACPI_TABLE_VERSION_1_0B) continue;
+
+ if (gAcpiData.AcpiEntries[i]->AcpiTblVer == EFI_ACPI_TABLE_VERSION_1_0B)
+ {
+ RsdtCnt ++;
+
+ if (gAcpiData.AcpiEntries[i]->BtHeaderPtr->Signature == FACP_SIG)
+ Facp = gAcpiData.AcpiEntries[i]->BtHeaderPtr;
+
+ if (gAcpiData.AcpiEntries[i]->BtHeaderPtr->Signature == DSDT_SIG)
+ Dsdt = gAcpiData.AcpiEntries[i]->BtHeaderPtr;
+ }
+
+ if (gAcpiData.AcpiEntries[i]->AcpiTblVer > EFI_ACPI_TABLE_VERSION_1_0B)
+ {
+ XsdtCnt ++;
+ RsdtCnt ++;
+
+ if (gAcpiData.AcpiEntries[i]->BtHeaderPtr->Signature == FACP_SIG)
+ {
+ FacpX = gAcpiData.AcpiEntries[i]->BtHeaderPtr;
+ //if (Facp != NULL) RsdtCnt --;
+ //continue;
+ }
+
+ if (gAcpiData.AcpiEntries[i]->BtHeaderPtr->Signature == DSDT_SIG)
+ {
+ DsdtX = gAcpiData.AcpiEntries[i]->BtHeaderPtr;
+ }
+
+ for (j = 0; j < gAcpiData.AcpiEntCount; j++)
+ {
+ if (j == i) continue;
+
+ if ((gAcpiData.AcpiEntries[j]->BtHeaderPtr->Signature == gAcpiData.AcpiEntries[i]->BtHeaderPtr->Signature)
+ && (gAcpiData.AcpiEntries[j]->AcpiTblVer == EFI_ACPI_TABLE_VERSION_1_0B)) RsdtCnt --;
+ }
+ }
+ }
+
+ if ((Dsdt == NULL) || (DsdtX == NULL)) OneDsdt = 1;
+
+ if (Dsdt == NULL) Dsdt = DsdtX;
+
+ if (DsdtX == NULL) DsdtX = Dsdt;
+
+ RsdtSize = RsdtBuild * (sizeof(ACPI_HDR) + (RsdtCnt-1) * sizeof(UINT32) + 7); //DSDT does not goes in RSDT (RsdtCnt-1)
+
+ XsdtSize = XsdtBuild * (sizeof(ACPI_HDR) + (XsdtCnt-1) * sizeof(UINT64) + 7); //DSDT does not goes in XSDT (XsdtCnt-1)
+ SpaceNeeded = sizeof(RSDT_PTR_20) + RsdtSize + XsdtSize + gAcpiData.AcpiLength + (gAcpiData.AcpiEntCount + 1) * 8;
+
+ if (gRsdtPtrStr != NULL)
+ {
+ Status = pBS->FreePages((EFI_PHYSICAL_ADDRESS)(UINTN) gRsdtPtrStr, gAcpiTblPages);
+ ASSERT_EFI_ERROR(Status);
+ }
+ /*
+ Status = pBS->AllocatePool(EfiACPIReclaimMemory, SpaceNeeded, (VOID**)&gRsdtPtrStr);
+ ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR(Status)) return EFI_OUT_OF_RESOURCES;
+ */
+ gAcpiTblPages = EFI_SIZE_TO_PAGES(SpaceNeeded);
+#if defined(OemActivation_SUPPORT) && (OemActivation_SUPPORT == 1)
+ if (gOA3Variable)
+ Status = pBS->AllocatePages(AllocateMaxAddress, EfiACPIMemoryNVS, gAcpiTblPages , &Memory);
+ else
+#endif
+ Status = pBS->AllocatePages(AllocateMaxAddress, EfiACPIReclaimMemory, gAcpiTblPages , &Memory);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return EFI_OUT_OF_RESOURCES;
+
+ gRsdtPtrStr = (RSDT_PTR_20*)Memory;
+
+ pBS->SetMem(gRsdtPtrStr, SpaceNeeded, 0);
+
+ if (RsdtBuild)
+ {
+ Dummy = (UINT8*) ((UINT8*)gRsdtPtrStr + sizeof(RSDT_PTR_20) + 7);
+ (UINTN) Dummy &= (~0x7);
+ Rsdt = (RSDT32*) Dummy;
+ Ptr = (UINT8*)gRsdtPtrStr + sizeof(RSDT_PTR_20) + RsdtSize + XsdtSize + 7;
+ (UINTN) Ptr &= (~0x7);
+ Dummy = FillAcpiStr (Rsdt, NULL, (VOID*) Facp, (VOID*) Ptr);// The first table in RSDT must be Facp
+ Facp = (ACPI_HDR*) Ptr;
+ Ptr = Dummy;
+ pBS->CopyMem((VOID*)Ptr, (VOID*)Dsdt, Dsdt->Length);
+
+ if (Dsdt == DsdtX) Dsdt = DsdtX = (ACPI_HDR*) Ptr;
+ else Dsdt = (ACPI_HDR*) Ptr;
+
+ Ptr += (Dsdt->Length + 7);
+ (UINTN) Ptr &= (~0x7);
+ ((FACP32*)Facp)->FIRMWARE_CTRL = (UINT32) gFacs;
+ ((FACP32*)Facp)->DSDT = (UINT32) Dsdt;
+ Facp->Checksum = 0;
+ Facp->Checksum = ChsumTbl((UINT8*)Facp, Facp->Length);
+ }
+
+ if ((XsdtBuild) && (!gForceAcpi1))
+ {
+ Dummy = (UINT8*) ((UINT8*)gRsdtPtrStr + sizeof(RSDT_PTR_20) + RsdtSize + 7);
+ (UINTN) Dummy &= (~0x7);
+ Xsdt = (XSDT_20*) Dummy;
+
+ if (Ptr == NULL)
+ {
+ Ptr = (UINT8*) ((UINT8*)gRsdtPtrStr + sizeof(RSDT_PTR_20) + RsdtSize + XsdtSize + 7);
+ //else Ptr += (((ACPI_HDR*)Ptr)->Length + 7);
+ (UINTN) Ptr &= (~0x7);
+ }
+
+ Dummy = FillAcpiStr (NULL, Xsdt, (VOID*) FacpX,( VOID*) Ptr);
+ FacpX = (ACPI_HDR*) Ptr;
+ Ptr = Dummy;
+
+ if ((!OneDsdt) || (!RsdtBuild))
+ {
+ pBS->CopyMem((VOID*)Ptr, (VOID*)DsdtX, DsdtX->Length);
+ DsdtX = (ACPI_HDR*) Ptr;
+ Ptr += (DsdtX->Length + 7);
+ (UINTN) Ptr &= (~0x7);
+ }
+
+ if (ACPI_BUILD_TABLES_4_0 == 1) ((FACP_20*)FacpX)->FIRMWARE_CTRL = (UINT32) gxFacs;
+ else ((FACP_20*)FacpX)->FIRMWARE_CTRL = (UINT32) gFacs;
+
+ ((FACP_20*)FacpX)->DSDT = (UINT32) Dsdt;
+
+ if (ACPI_BUILD_TABLES_4_0 != 1)((FACP_20*)FacpX)->X_FIRMWARE_CTRL = (UINT64) ((UINTN)gxFacs);
+
+ ((FACP_20*)FacpX)->X_DSDT = (UINT64) ((UINTN)DsdtX);
+ FacpX->Checksum = 0;
+ FacpX->Checksum = ChsumTbl((UINT8*)FacpX, FacpX->Length);
+ }
+
+ for (i = 0; i < gAcpiData.AcpiEntCount; i++)
+ {
+ if ((gAcpiData.AcpiEntries[i]->BtHeaderPtr->Signature == FACP_SIG) ||
+ (gAcpiData.AcpiEntries[i]->BtHeaderPtr->Signature == DSDT_SIG) ||
+ (gAcpiData.AcpiEntries[i]->AcpiTblVer < EFI_ACPI_TABLE_VERSION_1_0B)) continue;
+
+ if (gAcpiData.AcpiEntries[i]->AcpiTblVer == EFI_ACPI_TABLE_VERSION_1_0B)
+ {
+ Dummy = FillAcpiStr (Rsdt, NULL, (VOID*) gAcpiData.AcpiEntries[i]->BtHeaderPtr,( VOID*) Ptr);
+
+ if (Dummy != NULL) Ptr = Dummy;
+ }
+
+ else
+ {
+ Skip = 0;
+
+ for (j = 0; j < gAcpiData.AcpiEntCount; j++)
+ {
+ if (j == i) continue;
+
+ if ((gAcpiData.AcpiEntries[j]->BtHeaderPtr->Signature == gAcpiData.AcpiEntries[i]->BtHeaderPtr->Signature)
+ && (gAcpiData.AcpiEntries[j]->AcpiTblVer == EFI_ACPI_TABLE_VERSION_1_0B)) Skip = 1;
+ }
+
+ if (Skip) Dummy = FillAcpiStr (NULL, Xsdt, (VOID*) gAcpiData.AcpiEntries[i]->BtHeaderPtr,( VOID*) Ptr);
+ else Dummy = FillAcpiStr (Rsdt, Xsdt, (VOID*) gAcpiData.AcpiEntries[i]->BtHeaderPtr,( VOID*) Ptr);
+
+ if (Dummy != NULL) Ptr = Dummy;
+ }
+ }
+
+ if (Ptr > ((UINT8*)gRsdtPtrStr + SpaceNeeded)) Status = EFI_OUT_OF_RESOURCES;
+
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return Status;
+
+ gRsdtPtrStr->Signature = RSDP_SIG;
+
+ if ((!XsdtBuild) || (gForceAcpi1)) gRsdtPtrStr->Revision = 0; //Reserved in ver 1
+ else gRsdtPtrStr->Revision = ACPI_REV2; // 2 for ver 2 and 3
+
+ gRsdtPtrStr->Length = sizeof(RSDT_PTR_20);//this is the length of entire structure
+
+ for (i=0; i<6; i++) gRsdtPtrStr->OEMID[i]=ACPI_OEM_ID[i];
+
+ gRsdtPtrStr->RsdtAddr = (UINT32) Rsdt;
+ gRsdtPtrStr->XsdtAddr = (UINT64) ((UINTN)Xsdt);
+ gRsdtPtrStr->Checksum = ChsumTbl((UINT8*)gRsdtPtrStr, 20);
+ gRsdtPtrStr->XtdChecksum = ChsumTbl((UINT8*)gRsdtPtrStr, sizeof (RSDT_PTR_20));
+
+ if (RsdtBuild)
+ {
+ PrepareHdr1 (RSDT_SIG, (ACPI_HDR*) Rsdt);
+ Rsdt->Header.Length = (UINT32) (RsdtSize - 7);
+ Rsdt->Header.Checksum = 0;
+ Rsdt->Header.Checksum = ChsumTbl((UINT8*)Rsdt, Rsdt->Header.Length);
+ Status = pBS->InstallConfigurationTable(&gAcpi11TAbleGuid, (VOID*) gRsdtPtrStr);
+ TRACE((-1,"Installing ACPI 1.1: %r, %X\n",Status,gRsdtPtrStr));////-----------------------------------------
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return Status;
+ }
+
+ if (XsdtBuild)
+ {
+ if (ACPI_BUILD_TABLES_3_0 == 1) PrepareHdr20 (XSDT_SIG, (ACPI_HDR*) Xsdt, 3);
+ else PrepareHdr20 (XSDT_SIG, (ACPI_HDR*) Xsdt, 2);
+#if defined(OemActivation_SUPPORT) && (OemActivation_SUPPORT == 1)
+ if (gOA3Variable)
+ Xsdt->Header.Length = (UINT32) (XsdtSize - sizeof(UINT64) - 7);//one reserved position for MSDM
+ else
+#endif
+ Xsdt->Header.Length = (UINT32) (XsdtSize - 7);
+ Xsdt->Header.Checksum = 0;
+ Xsdt->Header.Checksum = ChsumTbl((UINT8*)Xsdt, Xsdt->Header.Length);
+// if (RsdtBuild) Status = pBS->InstallConfigurationTable(&gAcpi11TAbleGuid, NULL); // Delete V1.1 entry - Only one
+ Status = pBS->InstallConfigurationTable(&gAcpi20TAbleGuid, (VOID*) gRsdtPtrStr);
+ }
+
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return Status;
+#if defined(OemActivation_SUPPORT) && (OemActivation_SUPPORT == 1)
+ if ((Xsdt != NULL) && gOA3Variable)
+ {
+ gMsdmVariable.XsdtAddress = (EFI_PHYSICAL_ADDRESS) Xsdt;
+ Status = pRS->SetVariable(
+ EFI_OA3_MSDM_VARIABLE,
+ &gAmiGlobalVariableGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ sizeof(EFI_OA3_MSDM_STRUCTURE),
+ &gMsdmVariable
+ );
+ ASSERT_EFI_ERROR(Status);
+ }
+#endif
+ return EFI_SUCCESS;
+
+}// end of PublishTbl
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: UpdateAml
+//
+// Description:
+// This function updates AML objects with values provided in ACPI_AML_UPD_INFO
+// structure
+//
+// Input:
+// IN ACPI_AML_UPD_INFO *AmlUpdInfo - pointer to ACPI_AML_UPD_INFO structure
+//
+// Output:
+// EFI_SUCCESS - AML objects updated successfully
+// EFI_ERROR - some error occured during update process
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS UpdateAml(ACPI_AML_UPD_INFO *AmlUpdInfo)
+{
+ UINTN i;
+ ACPI_HDR *Dsdt;
+ EFI_STATUS Status = 0;
+
+//-------------------------
+
+ for (i = 0; i < 2; i++)
+ {
+ if (i) Dsdt = (ACPI_HDR*)AmlUpdInfo->Dsdt1Addr;
+ else Dsdt = (ACPI_HDR*)AmlUpdInfo->Dsdt2Addr;
+
+ if (Dsdt)
+ {
+ //Update TOPM Object
+ Status = UpdateAslNameObject(Dsdt, "TOPM", AmlUpdInfo->TopOfMemory);
+ ASSERT_EFI_ERROR (Status)
+
+ if (EFI_ERROR(Status)) return Status;
+
+ //Update ROMS Object
+ //Status = UpdateNameObject(Dsdt, AML_NAME_ROMS, AmlUpdInfo->RomStart);
+ //ASSERT_EFI_ERROR(Status)
+ //if(EFI_ERROR(Status)) return Status;
+//TODO: IOST and SSx Objects update
+ //Update IOST Object
+ Status = UpdateAslNameObject(Dsdt, "IOST", (UINT64)AmlUpdInfo->SioDevStatusVar.DEV_STATUS);
+ ASSERT_EFI_ERROR(Status)
+
+ if (EFI_ERROR(Status)) return Status;
+
+ Status = UpdateAslNameObject(Dsdt, "SS4", (UINT64)AmlUpdInfo->SS4);
+ ASSERT_EFI_ERROR(Status)
+
+ if (EFI_ERROR(Status)) return Status;
+#if ATAD_SUPPORT == 1
+ if (AtadBuffPtr)
+ {
+ TRACE((-1, "AtadBuffPtr=0x%lX ", (UINT64)AtadBuffPtr));
+ Status = UpdateAslNameObject(Dsdt, "ATBF", (UINT64)AtadBuffPtr);
+ ASSERT_EFI_ERROR (Status);
+ if (!EFI_ERROR(Status))
+ Status = UpdateAslNameObject(Dsdt, "BUFU", 1);
+ ASSERT_EFI_ERROR (Status);
+ }
+#endif
+
+ Status = UpdateAslNameObject(Dsdt, "SS3", (UINT64)AmlUpdInfo->SS3);
+ ASSERT_EFI_ERROR(Status)
+
+ if (EFI_ERROR(Status)) return Status;
+
+ Status = UpdateAslNameObject(Dsdt, "SS2", (UINT64)AmlUpdInfo->SS2);
+ ASSERT_EFI_ERROR(Status)
+
+ if (EFI_ERROR(Status)) return Status;
+
+ Status = UpdateAslNameObject(Dsdt, "SS1", (UINT64)AmlUpdInfo->SS1);
+ ASSERT_EFI_ERROR(Status)
+
+ if (EFI_ERROR(Status)) return Status;
+
+ Dsdt->Checksum = 0;
+ Dsdt->Checksum = ChsumTbl((UINT8*)Dsdt, Dsdt->Length);
+ }
+ }
+
+ return Status;
+
+
+}//end of UpdateAml
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: LockLegacyRes
+//
+// Description:
+// This function Hides Legacy Resources from OS by destroing _PRS method
+// in each Legacy Device ASL Object in DSDT
+//
+// Input:
+// IN ACPI_AML_UPD_INFO *AmlUpdInfo - pointer to ACPI_AML_UPD_INFO structure
+//
+// Output:
+// None
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+VOID LockLegacyRes (ACPI_AML_UPD_INFO *AmlUpdInfo)
+
+{
+
+ UINTN HandleCnt, j, i;
+ EFI_HANDLE *HandleBuffer = NULL;
+ SPIO_DEV *SpIoDev;
+ ASL_OBJ_INFO AslObj={0};
+ ACPI_HDR *Dsdt;
+ EFI_STATUS Status = 0;
+#if PI_SPECIFICATION_VERSION >= 0x10014
+ EFI_SIO_DATA *EfiSioData;
+
+ Status = pBS->LocateHandleBuffer(ByProtocol,&gEfiSioProtocolGuid, NULL, &HandleCnt, &HandleBuffer);
+#else
+ AMI_SIO_PROTOCOL *AmiSio;
+
+ Status = pBS->LocateHandleBuffer(ByProtocol,&gEfiAmiSioProtocolGuid, NULL, &HandleCnt, &HandleBuffer);
+#endif
+ //Locate all handles for SIO
+
+ if ((EFI_ERROR(Status)) || (HandleBuffer == NULL)) return;
+
+ for (j = 0; j < HandleCnt; j++)
+ {
+#if PI_SPECIFICATION_VERSION >= 0x10014
+ Status = pBS->HandleProtocol(HandleBuffer[j], &gEfiSioProtocolGuid, &EfiSioData);
+#else
+ Status = pBS->HandleProtocol(HandleBuffer[j], &gEfiAmiSioProtocolGuid, &AmiSio);
+#endif
+ if (EFI_ERROR(Status)) continue;
+#if PI_SPECIFICATION_VERSION >= 0x10014
+ SpIoDev = EfiSioData->Owner;
+#else
+ SpIoDev = (SPIO_DEV*)(UINTN)AmiSio;
+#endif
+ if (SpIoDev->DeviceInfo->AslName[0])
+// TRACE ((-1,"Found SIO Protocol. Name: %s\n",(UINT32)SpIoDev->DeviceInfo->AslName));
+ // If this device has ASL Name and is present in DSDT
+ {
+ for (i = 0; i < 2; i++)
+ {
+ if (i) Dsdt = (ACPI_HDR*)AmlUpdInfo->Dsdt1Addr;
+ else Dsdt = (ACPI_HDR*)AmlUpdInfo->Dsdt2Addr;
+
+ if (Dsdt)
+ {
+// TRACE ((-1,"Looking DSDT for Name: %s\n", SpIoDev->DeviceInfo->AslName));
+ Status = GetAslObj((UINT8*)Dsdt+sizeof(ACPI_HDR),
+ Dsdt->Length-sizeof(ACPI_HDR)-1, &SpIoDev->DeviceInfo->AslName[0],
+ otDevice, &AslObj);
+ // Get Asl object associated with this Legacy device
+ ASSERT_EFI_ERROR(Status);
+
+// TRACE ((-1,"Going to hide object Data statr= %x, Length= %x\n",AslObj.DataStart, AslObj.Length));
+ if (!EFI_ERROR(Status)) HideAslMethodFromOs (&AslObj, "_PRS");
+
+ // Lock this Device by destroing _PRS method of this object
+ }
+ }
+ }
+ }
+
+ for (i = 0; i < 2; i++)
+ {
+ if (i) Dsdt = (ACPI_HDR*)AmlUpdInfo->Dsdt1Addr;
+ else Dsdt = (ACPI_HDR*)AmlUpdInfo->Dsdt2Addr;
+
+ if (Dsdt)
+ {
+ Dsdt->Checksum = 0;
+ Dsdt->Checksum = ChsumTbl((UINT8*)Dsdt, Dsdt->Length);
+ }
+ }
+
+ pBS->FreePool(HandleBuffer);
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: CollectAmlUpdInfo
+//
+// Description:
+// This function will be called when ReadyToBoot event will be signaled and
+// will update IO devices status and then update AML binary. It allso publish all
+// ACPI tables.
+//
+// Input:
+// IN EFI_EVENT Event - signalled event
+// IN VOID *Context - calling context
+//
+// Output:
+// VOID
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+VOID CollectAmlUpdInfo(EFI_EVENT Event, VOID *Context)
+{
+ ACPI_AML_UPD_INFO *Aui=Context;
+ FACP_20 *xFacp = NULL;
+// ACPI_HDR *Dsdt1 = NULL, *Dsdt2 = NULL;
+// FACP32 *Facp = NULL;
+ FACP_20 *Facp = NULL;
+ UINTN i;
+ EFI_STATUS Status;
+ SETUP_DATA *SetupData=NULL;
+ UINTN SioDevStatusVarSize = sizeof(SIO_DEV_STATUS);
+ EFI_GUID SioDevStatusVarGuid = SIO_DEV_STATUS_VAR_GUID;
+//-------------------------------------------
+ //Init Setup Sleep States with Default Values;
+ TRACE((-1,"IN Collect AML Info: %x\n",0));
+
+ //we need to recreate MADT table instances on READY_TO_BOOT event.
+ for (i=0; i<gAcpiData.AcpiEntCount; i++)
+ {
+ ACPI_TBL_ITEM *AcpiTable = gAcpiData.AcpiEntries[i];
+ UINTN AcpiVer;
+ //-------------------------------------------
+
+ if (gAcpiData.AcpiEntries[i]->BtHeaderPtr->Signature == FACP_SIG)
+ {
+ if (gAcpiData.AcpiEntries[i]->AcpiTblVer == EFI_ACPI_TABLE_VERSION_1_0B)
+ Facp = (FACP_20*) gAcpiData.AcpiEntries[i]->BtHeaderPtr; // Find FACP for V 1.1
+ else
+ xFacp = (FACP_20*) gAcpiData.AcpiEntries[i]->BtHeaderPtr; // Find FACP for V 2+
+ }
+
+ if (gAcpiData.AcpiEntries[i]->BtHeaderPtr->Signature == DSDT_SIG)
+ {
+ if (gAcpiData.AcpiEntries[i]->AcpiTblVer == EFI_ACPI_TABLE_VERSION_1_0B)
+ Aui->Dsdt1Addr = (UINT64) gAcpiData.AcpiEntries[i]->BtHeaderPtr; // Find DSDT for V 1.1
+ else
+ Aui->Dsdt2Addr = (UINT64) gAcpiData.AcpiEntries[i]->BtHeaderPtr; // Find DSDT for V 2+
+ }
+
+ if (AcpiTable->BtHeaderPtr->Signature == APIC_SIG )
+ {
+
+ switch (AcpiTable->AcpiTblVer)
+ {
+ case EFI_ACPI_TABLE_VERSION_1_0B: AcpiVer=1; break;
+ case EFI_ACPI_TABLE_VERSION_2_0: AcpiVer=2; break;
+ case EFI_ACPI_TABLE_VERSION_3_0: AcpiVer=3; break;
+ case EFI_ACPI_TABLE_VERSION_4_0: AcpiVer=4; break;
+ default: AcpiVer=0;
+ }
+
+ gAcpiData.AcpiLength -= AcpiTable->BtHeaderPtr->Length;
+
+ pBS->FreePool(AcpiTable->BtHeaderPtr);
+ AcpiTable->BtHeaderPtr=NULL;
+
+
+ Status = BuildMadtAll (AcpiVer, &AcpiTable->BtHeaderPtr);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return;
+
+ gAcpiData.AcpiLength += AcpiTable->BtHeaderPtr->Length;
+ }
+ }
+
+
+ ASSERT_EFI_ERROR(Status);
+ TRACE((-1,"IN Collect AML Info after PT: %x\n",Status));
+
+ Aui->SS1=DEFAULT_SS1;
+ Aui->SS2=DEFAULT_SS2;
+ Aui->SS3=DEFAULT_SS3;
+ Aui->SS4=DEFAULT_SS4;
+
+ Status = GetEfiVariable(L"Setup",&gSetupGuid,NULL,&i,&SetupData);
+
+ if (!EFI_ERROR(Status))
+ {
+ //Such Variable exists so use customer choices
+ if (!SetupData->AcpiAuto)
+ {
+ Aui->SS4=SetupData->AcpiHibernate;
+
+ switch (SetupData->AcpiSleepState)
+ {
+ case 0:
+ Aui->SS3=0;
+ Aui->SS1=0;
+ break;
+ case 1:
+ Aui->SS1=1;
+ Aui->SS3=0;
+ break;
+ case 2:
+ Aui->SS3=1;
+ Aui->SS1=0;
+ break;
+ case 3:
+ Aui->SS3=1;
+ Aui->SS1=1;
+ break;
+ }
+ }
+ }
+
+//TODO//TODO//TODO//TODO//TODO
+// Check Setup options (if any) to enable/disable some onboard devices
+//TODO//TODO//TODO//TODO//TODO
+
+ Status = pRS->GetVariable(SIO_DEV_STATUS_VAR_NAME, &SioDevStatusVarGuid, NULL,
+ &SioDevStatusVarSize, &Aui->SioDevStatusVar.DEV_STATUS);
+
+ if (EFI_ERROR(Status)) Aui->SioDevStatusVar.DEV_STATUS = 0;
+ gAcpiIaBootArch &= (~((UINT16)(IA_LEGACY | IA_8042)));// clear first 2 bits of gAcpiIaBootArch,
+ // while preserving others. This 2 bits will be updated later.
+
+ //Dynamically update IA_PC_BOOT_ARCHITECTURE flag based on SIO_DEV_STATUS_VAR
+ if (
+ (Aui->SioDevStatusVar.SerialA == 1 ) ||
+ (Aui->SioDevStatusVar.SerialB == 1 ) ||
+ (Aui->SioDevStatusVar.Lpt == 1 ) ||
+ (Aui->SioDevStatusVar.Fdd == 1 ) ||
+ (Aui->SioDevStatusVar.Game1 == 1 ) ||
+ (Aui->SioDevStatusVar.Game2 == 1 )
+ )
+ gAcpiIaBootArch |= IA_LEGACY;
+
+ if (
+ (Aui->SioDevStatusVar.Key60_64 == 1) ||
+ (Aui->SioDevStatusVar.Ps2Mouse == 1) ||
+ (Aui->SioDevStatusVar.Ec62_66 == 1)
+ )
+ gAcpiIaBootArch |= IA_8042;
+
+
+ if ( xFacp != NULL)
+ {
+ xFacp->IAPC_BOOT_ARCH &= gAcpiIaBootArch;
+ xFacp->Header.Checksum = 0;
+ xFacp->Header.Checksum = ChsumTbl((UINT8*)&xFacp->Header, xFacp->Header.Length);
+ }
+
+ if ((UINT8*) xFacp != (UINT8*) Facp)
+ {
+ //ACPI v1.0b don't have IAPC_BOOT_ARCH flag field!
+ //Legacy free extension has but.. 1.1b Legacy free extension has. REV==2 and higher
+ if (Facp->Header.Revision > ACPI_REV1)
+ {
+ Facp->IAPC_BOOT_ARCH &= gAcpiIaBootArch;
+ Facp->Header.Checksum = 0;
+ Facp->Header.Checksum = ChsumTbl((UINT8*)&Facp->Header, Facp->Header.Length);
+ }
+ }
+
+ Status=UpdateAml(Aui);
+ ASSERT_EFI_ERROR(Status);
+
+ if (SetupData->AcpiLockLegacyRes) LockLegacyRes (Aui); // LockLegacyDev
+
+ if (!gForceAcpi1) Status = PublishTbl (1, 1);
+ else Status = PublishTbl (1, 0);
+ ASSERT_EFI_ERROR(Status);
+ gPublishedOnReadyToBoot = 1;
+// pBS->CloseEvent()
+// pBS->FreePool(Aui);
+}// end of CollectAmlUpdInfo
+
+
+//#pragma warning ( pop )
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+// ACPI SUPPORT PPROTOCOL function Implementation
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: AcpiSupportGetAcpiTable
+//
+// Description:
+// This function returns ACPI table
+//
+// Input:
+// IN EFI_ACPI_SUPPORT_PROTOCOL *This - pointer to EFI_ACPI_SUPPORT_PROTOCOL instance
+// IN INTN Index - Index of ACPI table to return
+// OUT VOID **Table - Pointer where to place found table
+// OUT EFI_ACPI_TABLE_VERSION Version - requested ACPI table version
+// OUT UINTN *Handle - requested ACPI table handle
+//
+// Output:
+// EFI_SUCCESS - Function executed successfully
+// EFI_OUT_OF_RESOURCES - not enough memory to allocate table
+// EFI_INVALID_PARAMETER - invalid EFI_ACPI_SUPPORT_PROTOCOL pointer
+// EFI_NOT_FOUND - requested ACPI table not found
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS AcpiSupportGetAcpiTable (
+ IN EFI_ACPI_SUPPORT_PROTOCOL *This,
+ IN INTN Index,
+ OUT VOID **Table,
+ OUT EFI_ACPI_TABLE_VERSION *Version,
+ OUT UINTN *Handle )
+{
+ ACPI_HDR *HdrPtr;
+ VOID *Ptr;
+ UINTN i;
+
+//----------------------
+
+ if (This!=&gAcpiData.AcpiSupportProtocol) return EFI_INVALID_PARAMETER;
+
+ if (Index > ((INTN)gAcpiData.AcpiEntCount - 1)) return EFI_NOT_FOUND;
+
+ for (i = Index; i < (UINTN) gAcpiData.AcpiEntCount; i++)
+ {
+ if (gAcpiData.AcpiEntries[i]->AcpiTblVer < ACPI_TABLE_NOT_REMOVABLE)
+ {
+ // means this table was added by EFI_ACPI_TABLE_PROTOCOL.InstallAcpiTable
+ // So it is illegal for EFI_ACPI_SUPPORT_PROTOCOL to receive a Handle for it
+ HdrPtr = gAcpiData.AcpiEntries[i]->BtHeaderPtr;
+ Ptr = Malloc(HdrPtr->Length);
+ ASSERT(Ptr);
+
+ if (!Ptr) return EFI_OUT_OF_RESOURCES;
+
+ *Version = gAcpiData.AcpiEntries[i]->AcpiTblVer;
+ *Handle = (UINTN) HdrPtr;
+ pBS->CopyMem(Ptr, HdrPtr, HdrPtr->Length);
+ *Table = Ptr;
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}//end of AcpiSupportGetAcpiTable
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: AcpiSupportSetAcpiTable
+//
+// Description:
+// This function allows to add, remove of modify ACPI table
+//
+// Input:
+// IN EFI_ACPI_SUPPORT_PROTOCOL *This - pointer to EFI_ACPI_SUPPORT_PROTOCOL instance
+// IN OPTIONAL VOID *Table - Pointer to update data. If NULL, corresponded table
+// should be removed
+// IN BOOLEAN Checksum - if TRUE, function will recalculate checksum before adding table
+// IN EFI_ACPI_TABLE_VERSION Version - requested ACPI table version
+// IN OUT UINTN *Handle - requested ACPI table handle
+//
+// Output:
+// EFI_SUCCESS - Function executed successfully
+// EFI_OUT_OF_RESOURCES - not enough memory to perform operation
+// EFI_INVALID_PARAMETER - invalid EFI_ACPI_SUPPORT_PROTOCOL pointer or ACPI table
+// content
+// EFI_ABORTED - provided ACPI table already present
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS AcpiSupportSetAcpiTable(
+ IN EFI_ACPI_SUPPORT_PROTOCOL *This,
+ IN VOID *Table OPTIONAL,
+ IN BOOLEAN Checksum,
+ IN EFI_ACPI_TABLE_VERSION Version,
+ IN OUT UINTN *Handle )
+{
+ ACPI_TBL_ITEM *AcpiTableAdded = NULL, *TblDummy = NULL;
+ ACPI_HDR *Hdr1 = NULL, *Hdr2 = NULL, *Dsdt = NULL, *XtDsdt = NULL;
+ VOID *Ptr = NULL;
+ EFI_ACPI_TABLE_VERSION XtDsdtVer = 0, DsdtVer = 0, MultyVer = 0;
+ EFI_STATUS Status = 0;
+ UINTN TblNum = ACPI_TABLE_NOT_FOUND;
+ BOOLEAN CorrectFacp = FALSE, WasChecksummed = FALSE;
+
+
+ //Handle == NULL Table != NULL add the table
+ //Handle != NULL Table != NULL replace the table
+ //Handle != NULL Table == NULL remove the table
+//-----------------------------------------------------------------------------------
+ if ((This != &gAcpiData.AcpiSupportProtocol) || (Handle==NULL) || (*Handle == 0 && Table == NULL )) //---------------------------------------------------------------
+ {
+ Status = EFI_INVALID_PARAMETER;
+ ASSERT_EFI_ERROR(Status);
+ return Status;
+ }
+
+ TRACE((-1, "ACPI: SetAcpiTable() Table=0x%X; Handle=0x%X; *Handle=0x%X\n", Table, Handle, *Handle));
+ if (Table != NULL)
+ {
+ Hdr1 = (ACPI_HDR*) Table;
+
+ //Check is we are getting a "special" table that needs a specific care
+ if (Hdr1->Signature == FACS_SIG)
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (Hdr1->Signature == FACP_SIG)
+ {
+ if (*Handle == 0) // --- Do not delete or add FACP - only replace it
+ {
+ Status = GetBtTable(&TblDummy, FACP_SIG, ( EFI_ACPI_TABLE_VERSION_X ));
+ ASSERT_EFI_ERROR(Status); // --- Or if new version > 2 and old version of FACP = 2
+ // --- And action = add table - replace old one with the new one
+ if (EFI_ERROR (Status))
+ {
+ return EFI_ABORTED;
+ }
+
+ if (TblDummy->AcpiTblVer >= Version)
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+ else
+ {
+ *Handle = (UINTN)TblDummy->BtHeaderPtr;
+ CorrectFacp = TRUE;
+ }
+ }
+ }
+
+ if (Hdr1->Signature == DSDT_SIG)
+ {
+
+ //Just in case reset
+ TblDummy=NULL;
+
+ if (*Handle == 0) // --- Do not delete or add DSDT - only replace it
+ {
+ Status = GetBtTable(&TblDummy, DSDT_SIG, (EFI_ACPI_TABLE_VERSION_X));
+
+ // --- Or if new version > 2 and old version of FACP = 2
+ if (!EFI_ERROR (Status)) // --- And action = add table - replace old one with the new one
+ {
+ XtDsdt = TblDummy->BtHeaderPtr;
+ XtDsdtVer = TblDummy->AcpiTblVer;
+ }
+
+ Status = GetBtTable(&TblDummy, DSDT_SIG, EFI_ACPI_TABLE_VERSION_1_0B);
+
+ if (!EFI_ERROR (Status))
+ {
+ Dsdt = TblDummy->BtHeaderPtr;
+ DsdtVer = TblDummy->AcpiTblVer;
+ }
+
+ if ((Version == EFI_ACPI_TABLE_VERSION_1_0B) && DsdtVer)
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+ else
+ {
+ if ((Version > DsdtVer) && (Version > XtDsdtVer))
+ {
+ if (XtDsdtVer)
+ *Handle = (UINTN) XtDsdt;
+ }
+
+ else
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ }
+
+ CorrectFacp = TRUE;
+ }
+
+ if (Version == EFI_ACPI_TABLE_VERSION_NONE)
+ Status = pBS->AllocatePool(EfiACPIMemoryNVS, Hdr1->Length, &Ptr);
+ else
+ Ptr = Malloc(Hdr1->Length);
+
+ ASSERT(Ptr);
+
+ if (Ptr==NULL)
+ {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ pBS->CopyMem(Ptr, Hdr1, Hdr1->Length);
+ AcpiTableAdded = MallocZ (sizeof (ACPI_TBL_ITEM));
+ ASSERT(AcpiTableAdded);
+
+ if (!AcpiTableAdded)
+ {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ AcpiTableAdded->AcpiTblVer = Version;
+ AcpiTableAdded->BtHeaderPtr = (ACPI_HDR*) Ptr;
+ if (!Checksum)
+ if (!ChsumTbl((UINT8*)Ptr, ((ACPI_HDR*) Ptr)->Length))
+ WasChecksummed = TRUE;
+ //If table was checksumed and Checksum parameter of SetTable function was not set
+ //to TRUE in next string OemAcpiSetPlatformId may modify the table - let's
+ //remember was it checksumed or not
+
+ if (EFI_ERROR(OemAcpiSetPlatformId ((ACPI_HDR*) Ptr))) WasChecksummed = FALSE;
+ //If OemAcpiSetPlatformId did not modifies table - reset WasChecksummed to FALSE
+
+#if defined(PI_SPECIFICATION_VERSION)&&(PI_SPECIFICATION_VERSION>=0x00010014)
+ Status = DispatchSdtNotify(AcpiTableAdded);
+ ASSERT_EFI_ERROR(Status);
+#endif
+
+ Status = AppendItemLst ((T_ITEM_LIST*)&gAcpiData, (VOID*) AcpiTableAdded);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status))
+ {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+
+ if (Version != EFI_ACPI_TABLE_VERSION_NONE)
+ gAcpiData.AcpiLength += ((ACPI_HDR*) Ptr)->Length;
+
+ if (Checksum || WasChecksummed)
+ {
+ ((ACPI_HDR*) Ptr)->Checksum = 0;
+ ((ACPI_HDR*) Ptr)->Checksum = ChsumTbl((UINT8*)Ptr, ((ACPI_HDR*) Ptr)->Length);
+ }
+ }
+
+ if (*Handle)
+ {
+ Status=EFI_SUCCESS;
+
+ TRACE((-1, "ACPI: SetAcpiTable() Hnd!=0, Removing Tbl. Ver=0x%X, ",Version));
+
+ Hdr2 = (ACPI_HDR*)(*Handle);
+
+ //Check is we are getting a "special" table that needs a specific care
+ if (Hdr2->Signature == FACS_SIG)
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Hdr2->Signature == FACP_SIG) && (!Table))
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((Hdr2->Signature == DSDT_SIG) && (!Table))
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ TblNum = FindAcpiTblByHandle (Handle);
+ TRACE((-1, "TblNum=0x%X ", TblNum));
+
+ if (TblNum == ACPI_TABLE_NOT_FOUND) Status=EFI_INVALID_PARAMETER;
+
+ TRACE((-1,"Status = %r\n", Status));
+
+ // Table with this Handle does not exist
+ if (EFI_ERROR(Status))
+ {
+ return Status;
+ }
+
+ //if sombody is trying to replace or delete table with version
+ //which is a combination of bits (for example V1 and 2 or V2 and 3, etc)
+ if ((Version != gAcpiData.AcpiEntries[TblNum]->AcpiTblVer) && (Version != ACPI_TABLE_NOT_REMOVABLE))
+ {
+ MultyVer = gAcpiData.AcpiEntries[TblNum]->AcpiTblVer;
+
+ if ((MultyVer == EFI_ACPI_TABLE_VERSION_1_0B) ||
+ (MultyVer == EFI_ACPI_TABLE_VERSION_2_0) ||
+ (MultyVer == EFI_ACPI_TABLE_VERSION_3_0) || (MultyVer == EFI_ACPI_TABLE_VERSION_4_0))
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ else MultyVer ^= Version;
+ }
+
+ if (Version != EFI_ACPI_TABLE_VERSION_NONE)
+ gAcpiData.AcpiLength -= gAcpiData.AcpiEntries[TblNum]->BtHeaderPtr->Length;
+
+ Status = DeleteItemLst((T_ITEM_LIST*) &gAcpiData, TblNum, TRUE);
+ TRACE((-1,"ACPI: Deleting Table From Storage: Status = %r\n", Status));
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR (Status))
+ {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ if (MultyVer)
+ {
+ AcpiTableAdded = MallocZ (sizeof (ACPI_TBL_ITEM));
+ ASSERT(AcpiTableAdded);
+
+ if (!AcpiTableAdded)
+ {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ AcpiTableAdded->AcpiTblVer = MultyVer;
+
+ AcpiTableAdded->BtHeaderPtr = Hdr2;
+ OemAcpiSetPlatformId(Hdr2);
+ Status = AppendItemLst ((T_ITEM_LIST*)&gAcpiData, (VOID*) AcpiTableAdded);
+ ASSERT_EFI_ERROR(Status);
+
+#if defined(PI_SPECIFICATION_VERSION)&&(PI_SPECIFICATION_VERSION>=0x00010014)
+ Status = DispatchSdtNotify(AcpiTableAdded);
+ ASSERT_EFI_ERROR(Status);
+#endif
+
+ if (EFI_ERROR(Status))
+ {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ gAcpiData.AcpiLength += gAcpiData.AcpiEntries[TblNum]->BtHeaderPtr->Length;
+ }
+
+ else pBS->FreePool(Hdr2);
+ }
+
+ //Update Handle with New Table Instance.
+ *Handle=(UINTN)Ptr;
+
+ if (CorrectFacp)
+ {
+ Status = UpdateFacp ();
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status))
+ {
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ TRACE((-1,"ACPI: SetAcpiTable() Exiting... Status = %r\n", Status));
+
+ if (gPublishedOnReadyToBoot)
+ {
+ if (!gForceAcpi1) Status = PublishTbl (1, 1);
+ else Status = PublishTbl (1, 0);
+ }
+ TRACE((-1,"ACPI: PublishTables in SetAcpiTable() Status = %r\n", Status));
+ ASSERT_EFI_ERROR(Status);
+
+ return Status;
+//--- !!!!!!!!!!!!!!!!!!!!!!!!!! Version none Done ???? !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+}// end of AcpiSupportSetAcpiTable
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: AcpiSupportPublishTables
+//
+// Description: Causes one or more versions of the ACPI tables to be published in
+// the EFI system configuration tables.
+//
+// Input:
+// IN EFI_ACPI_SUPPORT_PROTOCOL *This - pointer to EFI_ACPI_SUPPORT_PROTOCOL instance
+// IN EFI_ACPI_TABLE_VERSION Version - ACPI table version
+//
+// Output:
+// EFI_SUCCESS - Function executed successfully
+// EFI_ABORTED - invalid EFI_ACPI_SUPPORT_PROTOCOL pointer or
+// an error occurred and the function could not complete successfully.
+// EFI_UNSUPPORTED - passed ACPI table version invalid
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS AcpiSupportPublishTables(
+ IN EFI_ACPI_SUPPORT_PROTOCOL *This,
+ IN EFI_ACPI_TABLE_VERSION Version )
+{
+ EFI_STATUS Status;
+
+ if ((Version < EFI_ACPI_TABLE_VERSION_1_0B) || (Version > EFI_ACPI_TABLE_VERSION_ALL) || (This!=&gAcpiData.AcpiSupportProtocol))
+ return EFI_UNSUPPORTED;
+ if (Version == EFI_ACPI_TABLE_VERSION_1_0B)
+ {
+ if ((gRsdtPtrStr != NULL) && (gRsdtPtrStr->XsdtAddr != 0)) Status = PublishTbl (1, 1);
+ else Status = PublishTbl (1, 0);
+ }
+
+ if ((Version > EFI_ACPI_TABLE_VERSION_1_0B) && (!gForceAcpi1))
+ {
+ if ((gRsdtPtrStr != NULL) && (gRsdtPtrStr->RsdtAddr != 0)) Status = PublishTbl (1, 1);
+ else Status = PublishTbl (0, 1);
+ }
+ ASSERT_EFI_ERROR (Status);
+
+ if (EFI_ERROR (Status)) return EFI_ABORTED;
+ else return EFI_SUCCESS;
+}
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: AcpiInstallAcpiTable
+//
+// Description: Installs an ACPI table into the RSDT/XSDT.
+//
+// Input:
+// IN EFI_ACPI_TABLE_PROTOCOL *This - A pointer to a EFI_ACPI_TABLE_PROTOCOL.
+// IN VOID *AcpiTableBuffer - A pointer to a buffer containing the ACPI table to be installed.
+// IN UINTN AcpiTableBufferSize - Specifies the size, in bytes, of the AcpiTableBuffer buffer.
+// OUT UINTN *TableKey - Returns a key to refer to the ACPI table.
+//
+// Output:
+// EFI_SUCCESS - Function executed successfully
+// EFI_INVALID_PARAMETER - Either AcpiTableBuffer is NULL, TableKey is NULL, or
+// AcpiTableBufferSize and the size field embedded in the ACPI
+// table pointed to by AcpiTableBuffer are not in sync
+// EFI_OUT_OF_RESOURCES - Insufficient resources exist to complete the request.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS AcpiInstallAcpiTable(
+ IN CONST EFI_ACPI_TABLE_PROTOCOL *This,
+ IN CONST VOID *AcpiTableBuffer,
+ IN UINTN AcpiTableBufferSize,
+ OUT UINTN *TableKey)
+{
+ EFI_STATUS Status;
+ UINTN IntTableKey = 0;
+ // Update for LPT PCH Refcode. >>>
+ EFI_ACPI_TABLE_VERSION AcpiVersion = ACPI_TABLE_NOT_REMOVABLE;
+ UINTN TblNum = ACPI_TABLE_NOT_FOUND;
+ // <<< Update for LPT PCH Refcode.
+
+
+ if ((AcpiTableBuffer == NULL) || (AcpiTableBufferSize != (UINTN)((ACPI_HDR*)AcpiTableBuffer)->Length)
+ || (TableKey == NULL)) return EFI_INVALID_PARAMETER;
+ // Update for LPT PCH Refcode. >>>
+ if (*TableKey != 0)
+ {
+ TblNum = FindAcpiTblByHandle(TableKey);
+ if (TblNum != ACPI_TABLE_NOT_FOUND)
+ {
+ AcpiVersion = gAcpiData.AcpiEntries[TblNum]->AcpiTblVer;
+ IntTableKey = *TableKey;
+ }
+ }
+
+ Status = AcpiSupportSetAcpiTable(&gAcpiData.AcpiSupportProtocol,
+ (VOID*)AcpiTableBuffer,
+ TRUE,
+ // This is the mark, that means, that this table was added by the new protocol
+ AcpiVersion,
+ &IntTableKey);
+ ASSERT_EFI_ERROR(Status);
+ // <<< Update for LPT PCH Refcode.
+
+ if (EFI_ERROR(Status)) return EFI_OUT_OF_RESOURCES;
+ *TableKey = IntTableKey;
+
+ if (!gForceAcpi1) Status = PublishTbl (1, 1);
+ else PublishTbl (1, 0);
+ return Status;
+}// end of AcpiInstallAcpiTable
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: AcpiUninstallAcpiTable
+//
+// Description: Function allows a caller to remove an ACPI table.
+//
+// Input:
+// IN EFI_ACPI_TABLE_PROTOCOL *This - A pointer to a EFI_ACPI_TABLE_PROTOCOL.
+// IN UINTN *TableKey - Specifies the table to uninstall. The key was returned from
+// InstallAcpiTable().
+//
+// Output:
+// EFI_SUCCESS - Function executed successfully
+// EFI_NOT_FOUND - TableKey does not refer to a valid key for a table entry.
+// EFI_OUT_OF_RESOURCES - Insufficient resources exist to complete the request.
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS AcpiUninstallAcpiTable(
+ IN CONST EFI_ACPI_TABLE_PROTOCOL *This,
+ IN UINTN TableKey)
+{
+ EFI_STATUS Status;
+
+ Status = AcpiSupportSetAcpiTable(&gAcpiData.AcpiSupportProtocol,
+ NULL,
+ FALSE,
+ // This is the mark, that means, that this table was added by the new protocol
+ ACPI_TABLE_NOT_REMOVABLE,
+ &TableKey);
+ if (EFI_ERROR(Status))
+ return (EFI_NOT_FOUND);
+ else
+ return Status;
+}//end of AcpiUninstallAcpiTable
+
+
+//
+// ACPI SDT Protocol functions implementation.
+//
+
+#if defined(PI_SPECIFICATION_VERSION)&&(PI_SPECIFICATION_VERSION>=0x00010014)
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: GetAcpiTable2
+//
+// Description:
+// Returns a requested ACPI table.
+// The GetAcpiTable() function returns a pointer to a buffer containing the ACPI table associated
+// with the Index that was input. The following structures are not considered elements in the list of
+// ACPI tables:
+// - Root System Description Pointer (RSD_PTR)
+// - Root System Description Table (RSDT)
+// - Extended System Description Table (XSDT)
+// Version is updated with a bit map containing all the versions of ACPI of which the table is a
+// member.
+//
+// Input:
+// Index The zero-based index of the table to retrieve.
+// Table Pointer for returning the table buffer.
+// Version On return, updated with the ACPI versions to which this table belongs. Type
+// EFI_ACPI_TABLE_VERSION is defined in "Related Definitions" in the
+// EFI_ACPI_SDT_PROTOCOL.
+// TableKey On return, points to the table key for the specified ACPI system definition table. This
+// is identical to the table key used in the EFI_ACPI_TABLE_PROTOCOL.
+// Output:
+// EFI_SUCCESS The function completed successfully.
+// EFI_NOT_FOUND The requested index is too large and a table was not found.
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetAcpiTable2 (
+ IN UINTN Index,
+ OUT EFI_ACPI_SDT_HEADER **Table,
+ OUT EFI_ACPI_TABLE_VERSION *Version,
+ OUT UINTN *TableKey)
+{
+
+ return AcpiSupportGetAcpiTable (&gAcpiData.AcpiSupportProtocol, Index,
+ Table, Version,TableKey);
+
+}
+
+EFI_STATUS RegisterNotify(
+ IN BOOLEAN Register,
+ IN EFI_ACPI_NOTIFICATION_FN Notification)
+{
+ if(Notification == NULL) return EFI_INVALID_PARAMETER;
+
+ if(Register){
+ return AppendItemLst((T_ITEM_LIST*)&gAcpiData.NotifyInitCount, Notification);
+ } else {
+ UINTN i;
+ //-----------------
+ for(i=0; i<gAcpiData.NotifyFnCount; i++){
+ if(gAcpiData.AcpiNotifyFn[i]==Notification){
+ return DeleteItemLst((T_ITEM_LIST*)&gAcpiData.NotifyInitCount,i,FALSE);
+ }
+ }
+ //can't found matching notify function.
+ return EFI_INVALID_PARAMETER;
+ }
+}
+#endif
+
+
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+// Driver entry point
+//!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+// Procedure: AcpiNewCoreEntry
+//
+// Description:
+// This function is ACPI driver entry point
+//
+// Input:
+// IN EFI_HANDLE ImageHandle - Image handle
+// IN EFI_SYSTEM_TABLE *SystemTable - pointer to system table
+//
+// Output:
+// EFI_SUCCESS - Function executed successfully, ACPI_SUPPORT_PROTOCOL installed
+// EFI_ABORTED - Dsdt table not found or table publishing failed
+// EFI_ALREADY_STARTED - driver already started
+// EFI_OUT_OF_RESOURCES - not enough memory to perform operation
+//
+// Notes:
+// This function also creates ReadyToBoot event to update AML objects before booting
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS AcpiNewCoreEntry (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+ ACPI_HDR *Dsdt1Ptr = NULL, *Dsdt2Ptr = NULL;
+ VOID *DummyPtr;
+ static EFI_GUID Acpisupguid = EFI_ACPI_SUPPORT_GUID;
+ static EFI_GUID AcpiTableProtocolGuid = EFI_ACPI_TABLE_PROTOCOL_GUID;
+ UINTN AcpiVer;
+ EFI_ACPI_TABLE_VERSION EfiAcpiVer;
+ ACPI_TBL_ITEM *AcpiTable = NULL;
+#if FORCE_TO_ACPI1_SETUP_ENABLE
+ SETUP_DATA *SetupData = NULL;
+ UINTN SetupSize = 0;
+#endif
+//------------------------
+ InitAmiLib(ImageHandle,SystemTable);
+ PROGRESS_CODE(DXE_ACPI_INIT);
+ TRACE((-1,"IN ACPI Start: %x\n", Status));
+ //it must be ony one instance of this protocol
+ Status = pBS->LocateProtocol(&Acpisupguid,NULL,&DummyPtr);
+
+ if (!EFI_ERROR(Status)) return EFI_ALREADY_STARTED;
+
+#ifdef ACPI_INFO2_PROTOCOL_PUBLISHED
+ //Use AMI_CPU_INFO_2_PROTOCOL if published.
+ Status = pBS->LocateProtocol(&gAmiCpuInfo2ProtocolGuid, NULL, &gAmiCpu2Info);
+
+ if (EFI_ERROR(Status)) gAmiCpu2Info = NULL;
+
+#endif
+
+
+ Status = pBS->LocateProtocol(&gAmiBoardInfoGuid, NULL,(VOID**)&gAmiBoardInfoProtocol);
+
+ if (EFI_ERROR(Status))
+ {
+ gAmiBoardInfoProtocol = NULL;
+ TRACE((-1, "ACPI: Can't find AMI Board Info Protocol %r EXITING!",Status));
+ return Status;
+ }
+
+
+
+ AcpiVer = 2;
+ EfiAcpiVer = EFI_ACPI_TABLE_VERSION_2_0;
+
+ if (ACPI_BUILD_TABLES_3_0 == 1)
+ {
+ AcpiVer = 3;
+ EfiAcpiVer = EFI_ACPI_TABLE_VERSION_3_0;
+ }
+
+ if (ACPI_BUILD_TABLES_4_0 == 1)
+ {
+ AcpiVer = 4;
+ EfiAcpiVer = EFI_ACPI_TABLE_VERSION_4_0;
+ }
+#if ATAD_SUPPORT == 1
+
+ Status = pBS->AllocatePool(EfiRuntimeServicesData, 4, &AtadBuffPtr);
+ if (!EFI_ERROR(Status) && AtadBuffPtr)
+ {
+ EFI_GUID AtadSmiGuid = ATAD_SMI_GUID;
+ UINTN AtadVarSize = sizeof(AtadBuffPtr);
+ Status = pRS->SetVariable ( L"AtadSmiBuffer",
+ &AtadSmiGuid,
+ EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ AtadVarSize,
+ &AtadBuffPtr );
+ ASSERT_EFI_ERROR(Status);
+ }
+
+#endif
+
+#if FORCE_TO_ACPI1_SETUP_ENABLE
+ Status = GetEfiVariable(L"Setup",&gSetupGuid,NULL,&SetupSize,&SetupData);
+ ASSERT_EFI_ERROR(Status);
+ if (!EFI_ERROR (Status))
+ if (SetupData->ForceToAcpi1 ==1)
+ {
+ AcpiVer = gForceAcpi1 = 1;
+ EfiAcpiVer = EFI_ACPI_TABLE_VERSION_1_0B;
+ }
+#endif
+ Status = BuildFacs ();
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR (Status)) return EFI_OUT_OF_RESOURCES;
+
+ AcpiTable = MallocZ (sizeof (ACPI_TBL_ITEM));
+ ASSERT(AcpiTable);
+
+ if (!AcpiTable) return EFI_OUT_OF_RESOURCES;
+
+ Status = BuildFacpiAll (1, &AcpiTable->BtHeaderPtr);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR (Status)) return EFI_OUT_OF_RESOURCES;
+
+ AcpiTable->AcpiTblVer = EFI_ACPI_TABLE_VERSION_1_0B;
+ Status = AppendItemLst ((T_ITEM_LIST*)&gAcpiData, (VOID*) AcpiTable);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return EFI_OUT_OF_RESOURCES;
+
+ gAcpiData.AcpiLength += gAcpiData.AcpiEntries[gAcpiData.AcpiEntCount-1]->BtHeaderPtr->Length;
+ if (!gForceAcpi1)
+ {
+ AcpiTable = MallocZ (sizeof (ACPI_TBL_ITEM));
+ ASSERT(AcpiTable);
+
+ if (!AcpiTable) return EFI_OUT_OF_RESOURCES;
+
+ Status = BuildFacpiAll (AcpiVer, &AcpiTable->BtHeaderPtr);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR (Status)) return EFI_OUT_OF_RESOURCES;
+
+ AcpiTable->AcpiTblVer = EfiAcpiVer;
+ Status = AppendItemLst ((T_ITEM_LIST*)&gAcpiData, (VOID*) AcpiTable);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return EFI_OUT_OF_RESOURCES;
+
+ gAcpiData.AcpiLength += gAcpiData.AcpiEntries[gAcpiData.AcpiEntCount-1]->BtHeaderPtr->Length;
+ }
+ TRACE((-1,"IN ACPI 1: %x\n", Status));
+
+ Status = GetDsdtFv(&Dsdt1Ptr, &Dsdt2Ptr);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return EFI_ABORTED;
+
+ if ((Dsdt2Ptr != NULL) && (Dsdt1Ptr != NULL))
+ {
+ TRACE((-1,"DSDT1 addres 0x%X; -> %r \n", Dsdt1Ptr, Status));
+ TRACE((-1,"DSDT2 addres 0x%X; -> %r \n", Dsdt2Ptr, Status));
+
+ Dsdt1Ptr->Checksum = 0;
+ Dsdt2Ptr->Checksum = 0;
+ Dsdt1Ptr->Checksum = ChsumTbl((UINT8*)Dsdt1Ptr, Dsdt1Ptr->Length);
+ AcpiTable = MallocZ (sizeof (ACPI_TBL_ITEM));
+ ASSERT(AcpiTable);
+
+ if (!AcpiTable) return EFI_OUT_OF_RESOURCES;
+
+ AcpiTable->BtHeaderPtr = Dsdt1Ptr;
+ AcpiTable->AcpiTblVer = EFI_ACPI_TABLE_VERSION_1_0B;
+ Status = AppendItemLst ((T_ITEM_LIST*)&gAcpiData, (VOID*) AcpiTable);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return EFI_OUT_OF_RESOURCES;
+
+ gAcpiData.AcpiLength += gAcpiData.AcpiEntries[gAcpiData.AcpiEntCount-1]->BtHeaderPtr->Length;
+
+ Dsdt2Ptr->Checksum = ChsumTbl((UINT8*)Dsdt2Ptr, Dsdt2Ptr->Length);
+ AcpiTable = MallocZ (sizeof (ACPI_TBL_ITEM));
+ ASSERT(AcpiTable);
+
+ if (!AcpiTable) return EFI_OUT_OF_RESOURCES;
+
+ AcpiTable->BtHeaderPtr = Dsdt2Ptr;
+ AcpiTable->AcpiTblVer = EFI_ACPI_TABLE_VERSION_2_0;
+ Status = AppendItemLst ((T_ITEM_LIST*)&gAcpiData, (VOID*) AcpiTable);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return EFI_OUT_OF_RESOURCES;
+
+ gAcpiData.AcpiLength += gAcpiData.AcpiEntries[gAcpiData.AcpiEntCount-1]->BtHeaderPtr->Length;
+ }
+
+ if (Dsdt1Ptr == NULL)
+ {
+ TRACE((-1,"DSDT21 addres 0x%lX; -> %r \n", Dsdt2Ptr, Status));
+ Dsdt2Ptr->Checksum = 0;
+ Dsdt2Ptr->Checksum = ChsumTbl((UINT8*)Dsdt2Ptr, Dsdt2Ptr->Length);
+ AcpiTable = MallocZ (sizeof (ACPI_TBL_ITEM));
+ ASSERT(AcpiTable);
+
+ if (!AcpiTable) return EFI_OUT_OF_RESOURCES;
+
+ AcpiTable->BtHeaderPtr = Dsdt2Ptr;
+ AcpiTable->AcpiTblVer = EFI_ACPI_TABLE_VERSION_2_0;
+ Status = AppendItemLst ((T_ITEM_LIST*)&gAcpiData, (VOID*) AcpiTable);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return EFI_OUT_OF_RESOURCES;
+
+ gAcpiData.AcpiLength += gAcpiData.AcpiEntries[gAcpiData.AcpiEntCount-1]->BtHeaderPtr->Length;
+ }
+
+ if (Dsdt2Ptr == NULL)
+ {
+ TRACE((-1,"DSDT11 addres 0x%lX; -> %r \n", Dsdt1Ptr, Status));
+ Dsdt1Ptr->Checksum = 0;
+ Dsdt1Ptr->Checksum = ChsumTbl((UINT8*)Dsdt1Ptr, Dsdt1Ptr->Length);
+ AcpiTable = MallocZ (sizeof (ACPI_TBL_ITEM));
+ ASSERT(AcpiTable);
+
+ if (!AcpiTable) return EFI_OUT_OF_RESOURCES;
+
+ AcpiTable->BtHeaderPtr = Dsdt1Ptr;
+ AcpiTable->AcpiTblVer = EFI_ACPI_TABLE_VERSION_1_0B;
+ Status = AppendItemLst ((T_ITEM_LIST*)&gAcpiData, (VOID*) AcpiTable);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return EFI_OUT_OF_RESOURCES;
+
+ gAcpiData.AcpiLength += gAcpiData.AcpiEntries[gAcpiData.AcpiEntCount-1]->BtHeaderPtr->Length;
+ }
+
+ Status = UpdateFacp ();
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return EFI_ABORTED;
+
+#if ACPI_APIC_TBL == 1
+ AcpiTable = MallocZ (sizeof (ACPI_TBL_ITEM));
+ ASSERT(AcpiTable);
+
+ if (!AcpiTable) return EFI_OUT_OF_RESOURCES;
+
+ Status = BuildMadtAll (AcpiVer, &AcpiTable->BtHeaderPtr);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return EFI_ABORTED;
+
+ AcpiTable->AcpiTblVer = EfiAcpiVer;
+ Status = AppendItemLst ((T_ITEM_LIST*)&gAcpiData, (VOID*) AcpiTable);
+ ASSERT_EFI_ERROR(Status);
+
+ if (EFI_ERROR(Status)) return EFI_OUT_OF_RESOURCES;
+
+ gAcpiData.AcpiLength += gAcpiData.AcpiEntries[gAcpiData.AcpiEntCount-1]->BtHeaderPtr->Length;
+#endif
+
+#if MPS_TABLE_SUPPORT == 1
+ Status = MpsTableBuilderInit(ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR(Status);
+#endif
+//------ Performance Measurment ------------------------------------
+
+ AcpiTable = MallocZ (sizeof (ACPI_TBL_ITEM));
+ ASSERT(AcpiTable);
+
+ if (AcpiTable)
+ {
+ Status = BuildFPDT (AcpiVer, &AcpiTable->BtHeaderPtr);
+
+ if (!EFI_ERROR(Status))
+ {
+ AcpiTable->AcpiTblVer = EfiAcpiVer;
+ Status = AppendItemLst ((T_ITEM_LIST*)&gAcpiData, (VOID*) AcpiTable);
+ ASSERT_EFI_ERROR(Status);
+ gAcpiData.AcpiLength += gAcpiData.AcpiEntries[gAcpiData.AcpiEntCount-1]->BtHeaderPtr->Length;
+ }
+ }
+//------ Performance Measurment End --------------------------------
+
+//------ FID Table Start -------------------------------------------
+ AcpiTable = MallocZ (sizeof (ACPI_TBL_ITEM));
+ ASSERT(AcpiTable);
+
+ if (AcpiTable)
+ {
+ Status = BuildFIDT (&AcpiTable->BtHeaderPtr);
+
+ if (!EFI_ERROR(Status))
+ {
+ AcpiTable->AcpiTblVer = EfiAcpiVer;
+ Status = AppendItemLst ((T_ITEM_LIST*)&gAcpiData, (VOID*) AcpiTable);
+ ASSERT_EFI_ERROR(Status);
+ gAcpiData.AcpiLength += gAcpiData.AcpiEntries[gAcpiData.AcpiEntCount-1]->BtHeaderPtr->Length;
+ }
+ }
+
+//------ FID Table End --------------------------------------------
+
+ gAuiGlob = MallocZ(sizeof(ACPI_AML_UPD_INFO));
+ ASSERT(gAuiGlob);
+
+
+
+ //free temporary space used during this routine execution ??????
+
+ // ???? Publish all tbls 1,1 ??????
+ Status = CreateReadyToBootEvent(
+ TPL_CALLBACK, CollectAmlUpdInfo, gAuiGlob, &gEvtReadyToBoot
+ );
+ ASSERT_EFI_ERROR(Status);
+
+
+
+ if (EFI_ERROR(Status))return EFI_ABORTED;
+
+
+ gAcpiData.AcpiSupportProtocol.GetAcpiTable = AcpiSupportGetAcpiTable;
+ gAcpiData.AcpiSupportProtocol.SetAcpiTable = AcpiSupportSetAcpiTable;
+ gAcpiData.AcpiSupportProtocol.PublishTables = AcpiSupportPublishTables;
+
+ gAcpiData.AcpiTableProtocol.InstallAcpiTable = AcpiInstallAcpiTable;
+ gAcpiData.AcpiTableProtocol.UninstallAcpiTable = AcpiUninstallAcpiTable;
+
+#if defined(PI_SPECIFICATION_VERSION)&&(PI_SPECIFICATION_VERSION>=0x00010014)
+ gAcpiData.AcpiSdtProtocol.GetAcpiTable=GetAcpiTable2;
+ gAcpiData.AcpiSdtProtocol.RegisterNotify=RegisterNotify;
+ gAcpiData.AcpiSdtProtocol.Open=Open;
+ gAcpiData.AcpiSdtProtocol.OpenSdt=OpenSdt;
+ gAcpiData.AcpiSdtProtocol.Close=Close;
+ gAcpiData.AcpiSdtProtocol.GetChild=GetChild;
+ gAcpiData.AcpiSdtProtocol.GetOption=GetOption;
+ gAcpiData.AcpiSdtProtocol.SetOption=SetOption;
+ gAcpiData.AcpiSdtProtocol.FindPath=FindPath;
+ gAcpiData.AcpiSdtProtocol.AcpiVersion=EFI_ACPI_TABLE_VERSION_ALL;
+#endif
+
+ gAcpiData.AcpiSupportHandle = NULL;
+ //Instasll ProtocolInterface;
+ Status=pBS->InstallMultipleProtocolInterfaces(
+ &gAcpiData.AcpiSupportHandle,
+ &Acpisupguid,
+ &gAcpiData.AcpiSupportProtocol,
+ &AcpiTableProtocolGuid,
+ &gAcpiData.AcpiTableProtocol,
+#if defined(PI_SPECIFICATION_VERSION)&&(PI_SPECIFICATION_VERSION>=0x00010014)
+ &gEfiAcpiSdtProtocolGuid,
+ &gAcpiData.AcpiSdtProtocol,
+#endif
+ NULL);
+ ASSERT_EFI_ERROR(Status);
+ //TRACE((-1,"Before PublishTbl: %x\n", Status));
+ //Status = PublishTbl (1, 1);
+ //TRACE((-1,"After PublishTbl: %x\n", Status));
+ return Status;
+
+//return EFI_SUCCESS;
+}
+
+
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Core/EM/ACPI/AcpiCore.h b/Core/EM/ACPI/AcpiCore.h
new file mode 100644
index 0000000..598b8bf
--- /dev/null
+++ b/Core/EM/ACPI/AcpiCore.h
@@ -0,0 +1,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 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Core/EM/ACPI/AcpiS3.h b/Core/EM/ACPI/AcpiS3.h
new file mode 100644
index 0000000..8fcbe7c
--- /dev/null
+++ b/Core/EM/ACPI/AcpiS3.h
@@ -0,0 +1,170 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/AcpiS3.h 6 3/26/09 4:51p Oleksiyy $
+//
+// $Revision: 6 $
+//
+// $Date: 3/26/09 4:51p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/AcpiS3.h $
+//
+// 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:15p Yakovlevs
+// Functions Headers added
+//
+// 4 4/09/08 5:14p Yakovlevs
+// Make S3 Save code remember all possible locations of FACS.
+//
+// 3 11/20/06 4:14a Yakovlevs
+// updated structure of ACPI_CPU_DATA to match with declared in MRC code
+//
+// 2 9/22/06 6:10p Markw
+// 64-bit fix.
+//
+// 1 5/04/05 12:24p Markw
+//
+//**********************************************************************
+
+//<AMI_FHDR_START>
+//---------------------------------------------------------------------------
+//
+// Name: AcpiS3.h
+//
+// Description: ACPI S3 data structures definitions
+//
+//---------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#ifndef __ACPI_S3_H__
+#define __ACPI_S3_H__
+
+#include <Efi.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define ACPI_GLOBAL_VARIABLE L"AcpiGlobalVariable"
+#define EFI_ACPI_VARIABLE_GUID \
+ {0xaf9ffd67,0xec10,0x488a,0x9d,0xfc,0x6c,0xbf,0x5e,0xe2,0x2c,0x2e}
+
+#pragma pack (1)
+typedef struct {
+ UINT16 Limit;
+ UINT32 Base;
+} PSEUDO_DESCRIPTOR;
+#pragma pack()
+
+//<AMI_THDR_START>
+//----------------------------------------------------------------------------
+// Name: ACPI_CPU_DATA
+//
+// Description: ACPI Cpu related data
+//
+// Fields: Name Type Description
+//----------------------------------------------------------------------------
+// APState BOOLEAN
+// S3BootPath BOOLEAN
+// WakeUpBuffer EFI_PHYSICAL_ADDRESS
+// GdtrProfile EFI_PHYSICAL_ADDRESS
+// IdtrProfile EFI_PHYSICAL_ADDRESS
+// CpuPrivateData EFI_PHYSICAL_ADDRESS
+// StackAddress EFI_PHYSICAL_ADDRESS
+// MicrocodePointerBuffer EFI_PHYSICAL_ADDRESS
+// SmramBase EFI_PHYSICAL_ADDRESS
+// SmmStartImageBase EFI_PHYSICAL_ADDRESS
+// SmmStartImageSize UINT32
+// NumberOfCpus UINT32
+//
+//----------------------------------------------------------------------------
+//<AMI_THDR_END>
+
+typedef struct ACPI_CPU_DATA {
+ BOOLEAN APState;
+ BOOLEAN S3BootPath;
+ EFI_PHYSICAL_ADDRESS WakeUpBuffer;
+ EFI_PHYSICAL_ADDRESS GdtrProfile;
+ EFI_PHYSICAL_ADDRESS IdtrProfile;
+ EFI_PHYSICAL_ADDRESS CpuPrivateData;
+ EFI_PHYSICAL_ADDRESS StackAddress;
+ EFI_PHYSICAL_ADDRESS MicrocodePointerBuffer;
+ EFI_PHYSICAL_ADDRESS SmramBase;
+ EFI_PHYSICAL_ADDRESS SmmStartImageBase;
+ UINT32 SmmStartImageSize;
+ UINT32 NumberOfCpus;
+} ACPI_CPU_DATA;
+
+//<AMI_THDR_START>
+//----------------------------------------------------------------------------
+// Name: ACPI_VARIABLE_SET
+//
+// Description: The structure combine all ACPI related variables into one
+// in order to boost performance
+//
+// Fields: Name Type Description
+//----------------------------------------------------------------------------
+// AcpiReservedMemoryBase EFI_PHYSICAL_ADDRESS
+// AcpiReservedMemorySize UINT32
+// S3ReservedLowMemoryBase EFI_PHYSICAL_ADDRESS
+// AcpiBootScriptTable EFI_PHYSICAL_ADDRESS
+// RuntimeScriptTableBase EFI_PHYSICAL_ADDRESS
+// AcpiFacsTable[3] EFI_PHYSICAL_ADDRESS
+// SystemMemoryLength UINT64
+// AcpiCpuData ACPI_CPU_DATA
+//
+//----------------------------------------------------------------------------
+//<AMI_THDR_END>
+
+typedef struct _ACPI_VARIABLE_SET {
+ //
+ // Acpi Related variables
+ //
+ EFI_PHYSICAL_ADDRESS AcpiReservedMemoryBase;
+ UINT32 AcpiReservedMemorySize;
+ EFI_PHYSICAL_ADDRESS S3ReservedLowMemoryBase;
+ EFI_PHYSICAL_ADDRESS AcpiBootScriptTable;
+ EFI_PHYSICAL_ADDRESS RuntimeScriptTableBase;
+ EFI_PHYSICAL_ADDRESS AcpiFacsTable[3];
+ UINT64 SystemMemoryLength;
+ ACPI_CPU_DATA AcpiCpuData;
+} ACPI_VARIABLE_SET;
+
+
+
+
+/****** 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 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Core/EM/ACPI/AcpiSdt.c b/Core/EM/ACPI/AcpiSdt.c
new file mode 100644
index 0000000..5e5c8bb
--- /dev/null
+++ b/Core/EM/ACPI/AcpiSdt.c
@@ -0,0 +1,821 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/BIN/Modules/ACPI/Template/Core/AcpiSdt.c 3 12/04/12 2:29p Oleksiyy $
+//
+// $Revision: 3 $
+//
+// $Date: 12/04/12 2:29p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/AcpiSdt.c $
+//
+// 3 12/04/12 2:29p Oleksiyy
+// [TAG] EIP108375
+// [Category] Bug Fix
+// [Severity:] Normal
+// [Symptom:] SdtOpenSdtTable function in AcpiSdt.c returns
+// EFI_OUT_OF_RESOURCES.
+// [Root Cause] Error in "if"condition after locating memory.
+// [Solution] Condition is fixed from "!=" to "=="
+// [Files] AcpiSdt.c
+//
+// 2 5/14/11 2:14p Yakovlevs
+// [TAG] EIP 56526
+// [Category] New Feature
+// [Description] ACPI Manipulation Protocol. PI 1.2 Spec Vol 5 Section
+// 9. Initial checkin.
+// [Files] AcpiCore.c; AcpiCore.h; AcpiSdtPrivate.h; Aml.c; AmlChild.c;
+// AmlNamespace.c; AmlOption.c; AmlString.c AcpiSdt.c;
+// Protocol\AcpiSdt.h.
+//
+//**********************************************************************
+
+
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: AcpiSdt.c
+//
+// Description:
+// ACPI SDT protocol Implementation.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+//
+// Includes
+//
+#include "AcpiCore.h"
+
+extern ACPI_DB gAcpiData;
+
+
+/**
+ This function finds the table specified by the buffer.
+
+ @param[in] Buffer Table buffer to find.
+
+ @return ACPI table list.
+**/
+/*
+EFI_ACPI_TABLE_LIST *
+FindTableByBuffer (
+ IN VOID *Buffer
+ )
+{
+ EFI_ACPI_TABLE_INSTANCE *AcpiTableInstance;
+ LIST_ENTRY *CurrentLink;
+ EFI_ACPI_TABLE_LIST *CurrentTableList;
+ LIST_ENTRY *StartLink;
+
+ //
+ // Get the instance of the ACPI Table
+ //
+ AcpiTableInstance = SdtGetAcpiTableInstance ();
+
+ //
+ // Find the notify
+ //
+ StartLink = &AcpiTableInstance->TableList;
+ CurrentLink = StartLink->ForwardLink;
+
+ while (CurrentLink != StartLink) {
+ CurrentTableList = EFI_ACPI_TABLE_LIST_FROM_LINK (CurrentLink);
+ if (((UINTN)CurrentTableList->PageAddress <= (UINTN)Buffer) &&
+ ((UINTN)CurrentTableList->PageAddress + EFI_PAGES_TO_SIZE(CurrentTableList->NumberOfPages) > (UINTN)Buffer)) {
+ //
+ // Good! Found Table.
+ //
+ return CurrentTableList;
+ }
+
+ CurrentLink = CurrentLink->ForwardLink;
+ }
+
+ return NULL;
+}
+*/
+
+/**
+ This function updates AML table checksum.
+ It will search the ACPI table installed by ACPI_TABLE protocol.
+
+ @param[in] Buffer A piece of AML code buffer pointer.
+
+ @retval EFI_SUCCESS The table holds the AML buffer is found, and checksum is updated.
+ @retval EFI_NOT_FOUND The table holds the AML buffer is not found.
+**/
+/*
+EFI_STATUS
+SdtUpdateAmlChecksum (
+ IN VOID *Buffer
+ )
+{
+ EFI_ACPI_TABLE_LIST *CurrentTableList;
+
+ CurrentTableList = FindTableByBuffer (Buffer);
+ if (CurrentTableList == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ AcpiPlatformChecksum (
+ (VOID *)CurrentTableList->Table,
+ CurrentTableList->Table->Length,
+ OFFSET_OF (EFI_ACPI_DESCRIPTION_HEADER, Checksum)
+ );
+ return EFI_SUCCESS;
+}
+*/
+
+/**
+ This function finds MAX AML buffer size.
+ It will search the ACPI table installed by ACPI_TABLE protocol.
+
+ @param[in] Buffer A piece of AML code buffer pointer.
+ @param[out] MaxSize On return it holds the MAX size of buffer.
+
+ @retval EFI_SUCCESS The table holds the AML buffer is found, and MAX size if returned.
+ @retval EFI_NOT_FOUND The table holds the AML buffer is not found.
+**/
+/*
+EFI_STATUS
+SdtGetMaxAmlBufferSize (
+ IN VOID *Buffer,
+ OUT UINTN *MaxSize
+ )
+{
+ EFI_ACPI_TABLE_LIST *CurrentTableList;
+
+ CurrentTableList = FindTableByBuffer (Buffer);
+ if (CurrentTableList == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ *MaxSize = (UINTN)CurrentTableList->Table + CurrentTableList->Table->Length - (UINTN)Buffer;
+ return EFI_SUCCESS;
+}
+*/
+
+
+/**
+ Create a handle for the first ACPI opcode in an ACPI system description table.
+
+ @param[in] TableKey The table key for the ACPI table, as returned by GetTable().
+ @param[out] Handle On return, points to the newly created ACPI handle.
+
+ @retval EFI_SUCCESS Handle created successfully.
+ @retval EFI_NOT_FOUND TableKey does not refer to a valid ACPI table.
+**/
+EFI_STATUS
+SdtOpenSdtTable (IN UINTN TableKey, OUT EFI_ACPI_HANDLE *Handle)
+{
+ ACPI_TBL_ITEM *TableItem;
+ EFI_ACPI_SDT_HEADER *Table;
+ EFI_AML_HANDLE *AmlHandle;
+ UINTN i;
+//-----------------------
+
+ // Get the instance of the ACPI Table
+ i=FindAcpiTblByHandle(&TableKey);
+
+ // Find the table
+ if(i==ACPI_TABLE_NOT_FOUND) return EFI_INVALID_PARAMETER;
+
+ TableItem=gAcpiData.AcpiEntries[i];
+ Table=(EFI_ACPI_SDT_HEADER*)TableItem->BtHeaderPtr;
+
+ if(Table->Signature!=DSDT_SIG || Table->Signature!=SSDT_SIG)
+
+
+ AmlHandle = MallocZ(sizeof(*AmlHandle));
+ ASSERT (AmlHandle != NULL);
+ if(AmlHandle == NULL) return EFI_OUT_OF_RESOURCES;
+
+
+ AmlHandle->Signature = EFI_AML_ROOT_HANDLE_SIGNATURE;
+ AmlHandle->Buffer = (VOID *)((UINTN)Table + sizeof(EFI_ACPI_SDT_HEADER));
+ AmlHandle->Size = Table->Length - sizeof(EFI_ACPI_SDT_HEADER);
+// AmlHandle->AmlByteEncoding = NULL;
+// AmlHandle->Modified = FALSE;
+ AmlHandle->Table = Table;
+
+
+ //
+ // return the ACPI handle
+ //
+ *Handle = (EFI_ACPI_HANDLE)AmlHandle;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Create a handle for the first ACPI opcode in an ACPI system description table.
+
+ @param[in] TableKey The table key for the ACPI table, as returned by GetTable().
+ @param[out] Handle On return, points to the newly created ACPI handle.
+
+ @retval EFI_SUCCESS Handle created successfully.
+ @retval EFI_NOT_FOUND TableKey does not refer to a valid ACPI table.
+**/
+EFI_STATUS
+EFIAPI
+OpenSdt (
+ IN UINTN TableKey,
+ OUT EFI_ACPI_HANDLE *Handle
+ )
+{
+ if (Handle == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return SdtOpenSdtTable (TableKey, Handle);
+}
+
+/*
+/**
+ Create a handle from an ACPI opcode
+
+ @param[in] Buffer Points to the ACPI opcode.
+ @param[in] BufferSize Max buffer size.
+ @param[out] Handle Upon return, holds the handle.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER Buffer is NULL or Handle is NULL or Buffer points to an
+ invalid opcode.
+
+**/
+EFI_STATUS
+SdtOpenEx (
+ IN VOID *Buffer,
+ IN UINTN BufferSize,
+ OUT EFI_ACPI_HANDLE *Handle
+ )
+{
+ AML_BYTE_ENCODING *AmlByteEncoding;
+ EFI_AML_HANDLE *AmlHandle;
+
+ AmlByteEncoding = AmlSearchByOpByte (Buffer);
+ if (AmlByteEncoding == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Do not open NameString as handle
+ //
+ if ((AmlByteEncoding->Attribute & AML_IS_NAME_CHAR) != 0) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Good, find it
+ //
+ AmlHandle = Malloc (sizeof(*AmlHandle));
+ ASSERT (AmlHandle != NULL);
+
+ AmlHandle->Signature = EFI_AML_HANDLE_SIGNATURE;
+ AmlHandle->Buffer = Buffer;
+ AmlHandle->AmlByteEncoding = AmlByteEncoding;
+ AmlHandle->Modified = FALSE;
+
+ AmlHandle->Size = AmlGetObjectSize (AmlByteEncoding, Buffer, BufferSize);
+ if (AmlHandle->Size == 0) {
+ pBS->FreePool (AmlHandle);
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *Handle = (EFI_ACPI_HANDLE)AmlHandle;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Create a handle from an ACPI opcode
+
+ @param[in] Buffer Points to the ACPI opcode.
+ @param[out] Handle Upon return, holds the handle.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER Buffer is NULL or Handle is NULL or Buffer points to an
+ invalid opcode.
+
+**/
+EFI_STATUS
+EFIAPI
+Open (
+ IN VOID *Buffer,
+ OUT EFI_ACPI_HANDLE *Handle
+ )
+{
+/*
+ EFI_STATUS Status;
+ UINTN MaxSize;
+
+ MaxSize = 0;
+
+ //
+ // Check for invalid input parameters
+ //
+ if (Buffer == NULL || Handle == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = SdtGetMaxAmlBufferSize (Buffer, &MaxSize);
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return SdtOpenEx (Buffer, MaxSize, Handle);
+*/
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ Close an ACPI handle.
+
+ @param[in] Handle Returns the handle.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+EFIAPI
+Close (
+ IN EFI_ACPI_HANDLE Handle
+ )
+{
+ EFI_AML_HANDLE *AmlHandle;
+
+ //
+ // Check for invalid input parameters
+ //
+ if (Handle == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ AmlHandle = (EFI_AML_HANDLE *)Handle;
+ if ((AmlHandle->Signature != EFI_AML_ROOT_HANDLE_SIGNATURE) &&
+ (AmlHandle->Signature != EFI_AML_HANDLE_SIGNATURE)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Update Checksum only if modified
+ //
+ if (AmlHandle->Modified) {
+ AmlHandle->Table->Checksum=0;
+ AmlHandle->Table->Checksum=ChsumTbl((UINT8*)&AmlHandle->Table->Signature, AmlHandle->Table->Length);
+ }
+
+ pBS->FreePool(AmlHandle);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Retrieve information about an ACPI object.
+
+ @param[in] Handle ACPI object handle.
+ @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
+ in the ACPI encoding, with index 0 always being the ACPI opcode.
+ @param[out] DataType Points to the returned data type or EFI_ACPI_DATA_TYPE_NONE if no data exists
+ for the specified index.
+ @param[out] Data Upon return, points to the pointer to the data.
+ @param[out] DataSize Upon return, points to the size of Data.
+
+ @retval EFI_SUCCESS Success.
+ @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+EFIAPI
+GetOption (
+ IN EFI_ACPI_HANDLE Handle,
+ IN UINTN Index,
+ OUT EFI_ACPI_DATA_TYPE *DataType,
+ OUT CONST VOID **Data,
+ OUT UINTN *DataSize
+ )
+{
+ EFI_AML_HANDLE *AmlHandle;
+ AML_BYTE_ENCODING *AmlByteEncoding;
+ EFI_STATUS Status;
+
+ ASSERT (DataType != NULL);
+ ASSERT (Data != NULL);
+ ASSERT (DataSize != NULL);
+
+ //
+ // Check for invalid input parameters
+ //
+ if (Handle == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ AmlHandle = (EFI_AML_HANDLE *)Handle;
+ //
+ // Do not check EFI_AML_ROOT_HANDLE_SIGNATURE because there is no option for Root handle
+ //
+ if (AmlHandle->Signature != EFI_AML_HANDLE_SIGNATURE) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ AmlByteEncoding = AmlHandle->AmlByteEncoding;
+ if (Index > AmlByteEncoding->MaxIndex) {
+ *DataType = EFI_ACPI_DATA_TYPE_NONE;
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Parse option
+ //
+ Status = AmlParseOptionHandleCommon (AmlHandle, (AML_OP_PARSE_INDEX)Index, DataType, (VOID **)Data, DataSize);
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Change information about an ACPI object.
+
+ @param[in] Handle ACPI object handle.
+ @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
+ in the ACPI encoding, with index 0 always being the ACPI opcode.
+ @param[in] Data Points to the data.
+ @param[in] DataSize The size of the Data.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
+ @retval EFI_BAD_BUFFER_SIZE Data cannot be accommodated in the space occupied by
+ the option.
+
+**/
+EFI_STATUS
+EFIAPI
+SetOption (
+ IN EFI_ACPI_HANDLE Handle,
+ IN UINTN Index,
+ IN CONST VOID *Data,
+ IN UINTN DataSize
+ )
+{
+ EFI_AML_HANDLE *AmlHandle;
+ AML_BYTE_ENCODING *AmlByteEncoding;
+ EFI_STATUS Status;
+ EFI_ACPI_DATA_TYPE DataType;
+ VOID *OrgData;
+ UINTN OrgDataSize;
+
+ ASSERT (Data != NULL);
+
+ //
+ // Check for invalid input parameters
+ //
+ if (Handle == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ AmlHandle = (EFI_AML_HANDLE *)Handle;
+ //
+ // Do not check EFI_AML_ROOT_HANDLE_SIGNATURE because there is no option for Root handle
+ //
+ if (AmlHandle->Signature != EFI_AML_HANDLE_SIGNATURE) {
+ return EFI_INVALID_PARAMETER;
+ }
+ AmlByteEncoding = AmlHandle->AmlByteEncoding;
+
+ if (Index > AmlByteEncoding->MaxIndex) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Parse option
+ //
+ Status = AmlParseOptionHandleCommon (AmlHandle, (AML_OP_PARSE_INDEX)Index, &DataType, &OrgData, &OrgDataSize);
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (DataType == EFI_ACPI_DATA_TYPE_NONE) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (DataSize > OrgDataSize) {
+ return EFI_BAD_BUFFER_SIZE;
+ }
+
+ //
+ // Update
+ //
+
+ pBS->CopyMem(OrgData, (VOID*)Data, DataSize);
+ AmlHandle->Modified = TRUE;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Return the child ACPI objects.
+
+ @param[in] ParentHandle Parent handle.
+ @param[in, out] Handle On entry, points to the previously returned handle or NULL to start with the first
+ handle. On return, points to the next returned ACPI handle or NULL if there are no
+ child objects.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
+**/
+
+EFI_STATUS
+EFIAPI
+GetChild (
+ IN EFI_ACPI_HANDLE ParentHandle,
+ IN OUT EFI_ACPI_HANDLE *Handle
+ )
+{
+ EFI_AML_HANDLE *AmlParentHandle;
+ EFI_AML_HANDLE *AmlHandle;
+ VOID *Buffer;
+ EFI_STATUS Status;
+
+ ASSERT (Handle != NULL);
+
+ //
+ // Check for invalid input parameters
+ //
+ if (ParentHandle == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ AmlHandle = *Handle;
+ if ((AmlHandle != NULL) && (AmlHandle->Signature != EFI_AML_HANDLE_SIGNATURE)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ AmlParentHandle = (EFI_AML_HANDLE *)ParentHandle;
+ if (AmlParentHandle->Signature == EFI_AML_ROOT_HANDLE_SIGNATURE) {
+ //
+ // Root handle
+ //
+ Status = AmlGetChildFromRoot (AmlParentHandle, AmlHandle, &Buffer);
+ } else if (AmlParentHandle->Signature == EFI_AML_HANDLE_SIGNATURE) {
+ //
+ // Non-root handle
+ //
+ Status = AmlGetChildFromNonRoot (AmlParentHandle, AmlHandle, &Buffer);
+ } else {
+ //
+ // Invalid
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (Buffer == NULL) {
+ *Handle = NULL;
+ return EFI_SUCCESS;
+ }
+ return SdtOpenEx (Buffer, (UINTN)AmlParentHandle->Buffer + AmlParentHandle->Size - (UINTN)Buffer, Handle);
+}
+
+
+/**
+ Returns the handle of the ACPI object representing the specified ACPI path
+
+ @param[in] HandleIn Points to the handle of the object representing the starting point for the path search.
+ @param[in] AmlPath Points to the AML path.
+ @param[out] HandleOut On return, points to the ACPI object which represents AcpiPath, relative to
+ HandleIn.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.
+**/
+
+EFI_STATUS
+SdtFindPathFromNonRoot (
+ IN EFI_ACPI_HANDLE HandleIn,
+ IN UINT8 *AmlPath,
+ OUT EFI_ACPI_HANDLE *HandleOut
+ )
+{
+ EFI_AML_HANDLE *AmlHandle;
+ VOID *Buffer;
+ EFI_STATUS Status;
+
+ AmlHandle = (EFI_AML_HANDLE *)HandleIn;
+
+ //
+ // For non-root handle, we need search from THIS node instead of ROOT.
+ //
+ Status = AmlFindPath (AmlHandle, AmlPath, &Buffer, FALSE);
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (Buffer == NULL) {
+ *HandleOut = NULL;
+ return EFI_SUCCESS;
+ }
+ return SdtOpenEx (Buffer, (UINTN)AmlHandle->Buffer + AmlHandle->Size - (UINTN)Buffer, HandleOut);
+}
+
+
+/**
+ Duplicate AML handle.
+
+ @param[in] AmlHandle Handle to be duplicated.
+
+ @return Duplicated AML handle.
+**/
+
+EFI_AML_HANDLE *
+SdtDuplicateHandle (
+ IN EFI_AML_HANDLE *AmlHandle
+ )
+{
+ EFI_AML_HANDLE *DstAmlHandle;
+
+ DstAmlHandle = Malloc(sizeof(*DstAmlHandle));
+ ASSERT (DstAmlHandle != NULL);
+ pBS->CopyMem(DstAmlHandle, (VOID *)AmlHandle, sizeof(*DstAmlHandle));
+
+ return DstAmlHandle;
+}
+
+/**
+ Returns the handle of the ACPI object representing the specified ACPI path
+
+ @param[in] HandleIn Points to the handle of the object representing the starting point for the path search.
+ @param[in] AmlPath Points to the AML path.
+ @param[out] HandleOut On return, points to the ACPI object which represents AcpiPath, relative to
+ HandleIn.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.
+**/
+
+EFI_STATUS
+SdtFindPathFromRoot (
+ IN EFI_ACPI_HANDLE HandleIn,
+ IN UINT8 *AmlPath,
+ OUT EFI_ACPI_HANDLE *HandleOut
+ )
+{
+ EFI_ACPI_HANDLE ChildHandle;
+ EFI_AML_HANDLE *AmlHandle;
+ EFI_STATUS Status;
+ VOID *Buffer;
+
+ AmlHandle = (EFI_AML_HANDLE *)HandleIn;
+
+ //
+ // Handle case that AcpiPath is Root
+ //
+ if (AmlIsRootPath (AmlPath)) {
+ //
+ // Duplicate RootHandle
+ //
+ *HandleOut = (EFI_ACPI_HANDLE)SdtDuplicateHandle (AmlHandle);
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Let children find it.
+ //
+ ChildHandle = NULL;
+ while (TRUE) {
+ Status = GetChild (HandleIn, &ChildHandle);
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ChildHandle == NULL) {
+ //
+ // Not found
+ //
+ *HandleOut = NULL;
+ return EFI_SUCCESS;
+ }
+
+ //
+ // More child
+ //
+ AmlHandle = (EFI_AML_HANDLE *)ChildHandle;
+ Status = AmlFindPath (AmlHandle, AmlPath, &Buffer, TRUE);
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Buffer != NULL) {
+ //
+ // Great! Find it, open
+ //
+ Status = SdtOpenEx (Buffer, (UINTN)AmlHandle->Buffer + AmlHandle->Size - (UINTN)Buffer, HandleOut);
+ if (!EFI_ERROR (Status)) {
+ return EFI_SUCCESS;
+ }
+ //
+ // Not success, try next one
+ //
+ }
+ }
+
+ //
+ // Should not run here
+ //
+}
+
+
+/**
+ Returns the handle of the ACPI object representing the specified ACPI path
+
+ @param[in] HandleIn Points to the handle of the object representing the starting point for the path search.
+ @param[in] AcpiPath Points to the ACPI path, which conforms to the ACPI encoded path format.
+ @param[out] HandleOut On return, points to the ACPI object which represents AcpiPath, relative to
+ HandleIn.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.
+**/
+
+EFI_STATUS
+EFIAPI
+FindPath (
+ IN EFI_ACPI_HANDLE HandleIn,
+ IN VOID *AcpiPath,
+ OUT EFI_ACPI_HANDLE *HandleOut
+ )
+{
+ EFI_AML_HANDLE *AmlHandle;
+ EFI_STATUS Status;
+ UINT8 *AmlPath;
+
+ //
+ // Check for invalid input parameters
+ //
+ if (HandleIn == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ AmlHandle = (EFI_AML_HANDLE *)HandleIn;
+
+ //
+ // Convert ASL path to AML path
+ //
+ AmlPath = AmlNameFromAslName (AcpiPath);
+ if (AmlPath == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+// DEBUG_CODE_BEGIN ();
+// DEBUG ((EFI_D_ERROR, "AcpiSdt: FindPath - "));
+// AmlPrintNameString (AmlPath);
+// DEBUG ((EFI_D_ERROR, "\n"));
+// DEBUG_CODE_END ();
+
+ if (AmlHandle->Signature == EFI_AML_ROOT_HANDLE_SIGNATURE) {
+ //
+ // Root Handle
+ //
+ Status = SdtFindPathFromRoot (HandleIn, AmlPath, HandleOut);
+ } else if (AmlHandle->Signature == EFI_AML_HANDLE_SIGNATURE) {
+ //
+ // Non-Root handle
+ //
+ Status = SdtFindPathFromNonRoot (HandleIn, AmlPath, HandleOut);
+ } else {
+ Status = EFI_INVALID_PARAMETER;
+ }
+
+ pBS->FreePool (AmlPath);
+
+ return Status;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Core/EM/ACPI/AcpiSdtPrivate.h b/Core/EM/ACPI/AcpiSdtPrivate.h
new file mode 100644
index 0000000..17ea790
--- /dev/null
+++ b/Core/EM/ACPI/AcpiSdtPrivate.h
@@ -0,0 +1,798 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/BIN/Modules/ACPI/Template/Core/AcpiSdtPrivate.h 2 5/14/11 2:15p Yakovlevs $
+//
+// $Revision: 2 $
+//
+// $Date: 5/14/11 2:15p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/AcpiSdtPrivate.h $
+//
+// 2 5/14/11 2:15p Yakovlevs
+// [TAG] EIP 56526
+// [Category] New Feature
+// [Description] ACPI Manipulation Protocol. PI 1.2 Spec Vol 5 Section
+// 9. Initial checkin.
+// [Files] AcpiCore.c; AcpiCore.h; AcpiSdtPrivate.h; Aml.c; AmlChild.c;
+// AmlNamespace.c; AmlOption.c; AmlString.c AcpiSdt.c;
+// Protocol\AcpiSdt.h.
+//
+//**********************************************************************
+
+
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: AcpiSdtPrivate.h
+//
+// Description:
+// ACPI SDT protocol Private data Definitions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#ifndef _ACPI_SDT_H_
+#define _ACPI_SDT_H_
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "AcpiCore.h"
+//
+// ACPI AML definition
+//
+
+//
+// Primary OpCode
+//
+#define AML_ZERO_OP 0x00
+#define AML_ONE_OP 0x01
+#define AML_ALIAS_OP 0x06
+#define AML_NAME_OP 0x08
+#define AML_BYTE_PREFIX 0x0a
+#define AML_WORD_PREFIX 0x0b
+#define AML_DWORD_PREFIX 0x0c
+#define AML_STRING_PREFIX 0x0d
+#define AML_QWORD_PREFIX 0x0e
+#define AML_SCOPE_OP 0x10
+#define AML_BUFFER_OP 0x11
+#define AML_PACKAGE_OP 0x12
+#define AML_VAR_PACKAGE_OP 0x13
+#define AML_METHOD_OP 0x14
+#define AML_DUAL_NAME_PREFIX 0x2e
+#define AML_MULTI_NAME_PREFIX 0x2f
+#define AML_NAME_CHAR_A 0x41
+#define AML_NAME_CHAR_B 0x42
+#define AML_NAME_CHAR_C 0x43
+#define AML_NAME_CHAR_D 0x44
+#define AML_NAME_CHAR_E 0x45
+#define AML_NAME_CHAR_F 0x46
+#define AML_NAME_CHAR_G 0x47
+#define AML_NAME_CHAR_H 0x48
+#define AML_NAME_CHAR_I 0x49
+#define AML_NAME_CHAR_J 0x4a
+#define AML_NAME_CHAR_K 0x4b
+#define AML_NAME_CHAR_L 0x4c
+#define AML_NAME_CHAR_M 0x4d
+#define AML_NAME_CHAR_N 0x4e
+#define AML_NAME_CHAR_O 0x4f
+#define AML_NAME_CHAR_P 0x50
+#define AML_NAME_CHAR_Q 0x51
+#define AML_NAME_CHAR_R 0x52
+#define AML_NAME_CHAR_S 0x53
+#define AML_NAME_CHAR_T 0x54
+#define AML_NAME_CHAR_U 0x55
+#define AML_NAME_CHAR_V 0x56
+#define AML_NAME_CHAR_W 0x57
+#define AML_NAME_CHAR_X 0x58
+#define AML_NAME_CHAR_Y 0x59
+#define AML_NAME_CHAR_Z 0x5a
+#define AML_ROOT_CHAR 0x5c
+#define AML_PARENT_PREFIX_CHAR 0x5e
+#define AML_NAME_CHAR__ 0x5f
+#define AML_LOCAL0 0x60
+#define AML_LOCAL1 0x61
+#define AML_LOCAL2 0x62
+#define AML_LOCAL3 0x63
+#define AML_LOCAL4 0x64
+#define AML_LOCAL5 0x65
+#define AML_LOCAL6 0x66
+#define AML_LOCAL7 0x67
+#define AML_ARG0 0x68
+#define AML_ARG1 0x69
+#define AML_ARG2 0x6a
+#define AML_ARG3 0x6b
+#define AML_ARG4 0x6c
+#define AML_ARG5 0x6d
+#define AML_ARG6 0x6e
+#define AML_STORE_OP 0x70
+#define AML_REF_OF_OP 0x71
+#define AML_ADD_OP 0x72
+#define AML_CONCAT_OP 0x73
+#define AML_SUBTRACT_OP 0x74
+#define AML_INCREMENT_OP 0x75
+#define AML_DECREMENT_OP 0x76
+#define AML_MULTIPLY_OP 0x77
+#define AML_DIVIDE_OP 0x78
+#define AML_SHIFT_LEFT_OP 0x79
+#define AML_SHIFT_RIGHT_OP 0x7a
+#define AML_AND_OP 0x7b
+#define AML_NAND_OP 0x7c
+#define AML_OR_OP 0x7d
+#define AML_NOR_OP 0x7e
+#define AML_XOR_OP 0x7f
+#define AML_NOT_OP 0x80
+#define AML_FIND_SET_LEFT_BIT_OP 0x81
+#define AML_FIND_SET_RIGHT_BIT_OP 0x82
+#define AML_DEREF_OF_OP 0x83
+#define AML_CONCAT_RES_OP 0x84
+#define AML_MOD_OP 0x85
+#define AML_NOTIFY_OP 0x86
+#define AML_SIZE_OF_OP 0x87
+#define AML_INDEX_OP 0x88
+#define AML_MATCH_OP 0x89
+#define AML_CREATE_DWORD_FIELD_OP 0x8a
+#define AML_CREATE_WORD_FIELD_OP 0x8b
+#define AML_CREATE_BYTE_FIELD_OP 0x8c
+#define AML_CREATE_BIT_FIELD_OP 0x8d
+#define AML_OBJECT_TYPE_OP 0x8e
+#define AML_CREATE_QWORD_FIELD_OP 0x8f
+#define AML_LAND_OP 0x90
+#define AML_LOR_OP 0x91
+#define AML_LNOT_OP 0x92
+#define AML_LEQUAL_OP 0x93
+#define AML_LGREATER_OP 0x94
+#define AML_LLESS_OP 0x95
+#define AML_TO_BUFFER_OP 0x96
+#define AML_TO_DEC_STRING_OP 0x97
+#define AML_TO_HEX_STRING_OP 0x98
+#define AML_TO_INTEGER_OP 0x99
+#define AML_TO_STRING_OP 0x9c
+#define AML_COPY_OBJECT_OP 0x9d
+#define AML_MID_OP 0x9e
+#define AML_CONTINUE_OP 0x9f
+#define AML_IF_OP 0xa0
+#define AML_ELSE_OP 0xa1
+#define AML_WHILE_OP 0xa2
+#define AML_NOOP_OP 0xa3
+#define AML_RETURN_OP 0xa4
+#define AML_BREAK_OP 0xa5
+#define AML_BREAK_POINT_OP 0xcc
+#define AML_ONES_OP 0xff
+
+//
+// Extended OpCode
+//
+#define AML_EXT_OP 0x5b
+
+#define AML_EXT_MUTEX_OP 0x01
+#define AML_EXT_EVENT_OP 0x02
+#define AML_EXT_COND_REF_OF_OP 0x12
+#define AML_EXT_CREATE_FIELD_OP 0x13
+#define AML_EXT_LOAD_TABLE_OP 0x1f
+#define AML_EXT_LOAD_OP 0x20
+#define AML_EXT_STALL_OP 0x21
+#define AML_EXT_SLEEP_OP 0x22
+#define AML_EXT_ACQUIRE_OP 0x23
+#define AML_EXT_SIGNAL_OP 0x24
+#define AML_EXT_WAIT_OP 0x25
+#define AML_EXT_RESET_OP 0x26
+#define AML_EXT_RELEASE_OP 0x27
+#define AML_EXT_FROM_BCD_OP 0x28
+#define AML_EXT_TO_BCD_OP 0x29
+#define AML_EXT_UNLOAD_OP 0x2a
+#define AML_EXT_REVISION_OP 0x30
+#define AML_EXT_DEBUG_OP 0x31
+#define AML_EXT_FATAL_OP 0x32
+#define AML_EXT_TIMER_OP 0x33
+#define AML_EXT_REGION_OP 0x80
+#define AML_EXT_FIELD_OP 0x81
+#define AML_EXT_DEVICE_OP 0x82
+#define AML_EXT_PROCESSOR_OP 0x83
+#define AML_EXT_POWER_RES_OP 0x84
+#define AML_EXT_THERMAL_ZONE_OP 0x85
+#define AML_EXT_INDEX_FIELD_OP 0x86
+#define AML_EXT_BANK_FIELD_OP 0x87
+#define AML_EXT_DATA_REGION_OP 0x88
+
+//
+// Privacy data structure
+//
+#define LIST_ENTRY EFI_LIST_ENTRY
+
+typedef struct _AML_BYTE_ENCODING AML_BYTE_ENCODING;
+typedef struct _EFI_AML_NODE_LIST EFI_AML_NODE_LIST;
+
+//
+// AML Node Linked List Signature.
+//
+#define EFI_AML_NODE_LIST_SIGNATURE SIGNATURE_32 ('E', 'A', 'M', 'L')
+
+//
+// AML Node Linked List Entry definition.
+//
+// Signature must be set to EFI_AML_NODE_LIST_SIGNATURE
+// Link is the linked list data.
+// Name is the ACPI node name.
+// This is listed for PATH finding.
+// Buffer is the ACPI node buffer pointer, the first/second bytes are opcode.
+// This buffer should not be freed.
+// Size is the total size of this ACPI node buffer.
+// Children is the children linked list of this node.
+//
+#define AML_NAME_SEG_SIZE 4
+
+struct _EFI_AML_NODE_LIST {
+ UINT32 Signature;
+ UINT8 Name[AML_NAME_SEG_SIZE];
+ UINT8 *Buffer;
+ UINTN Size;
+ LIST_ENTRY Link;
+ LIST_ENTRY Children;
+ EFI_AML_NODE_LIST *Parent;
+ AML_BYTE_ENCODING *AmlByteEncoding;
+};
+
+//
+// CONTAINING_RECORD - returns a pointer to the structure
+// from one of it's elements.
+//
+#ifndef _CR
+#define _CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field)))
+#endif
+
+#ifndef CR
+#define CR(record, TYPE, field, signature) _CR(record, TYPE, field)
+#endif
+
+//
+// Define macros to build data structure signatures from characters.
+//
+#define SIGNATURE_16(A, B) ((A) | (B << 8))
+#define SIGNATURE_32(A, B, C, D) (SIGNATURE_16 (A, B) | (SIGNATURE_16 (C, D) << 16))
+#define SIGNATURE_64(A, B, C, D, E, F, G, H) \
+ (SIGNATURE_32 (A, B, C, D) | ((UINT64) (SIGNATURE_32 (E, F, G, H)) << 32))
+
+
+//
+// Containment record for AML Node linked list.
+//
+#define EFI_AML_NODE_LIST_FROM_LINK(_link) CR (_link, EFI_AML_NODE_LIST, Link, EFI_AML_NODE_LIST_SIGNATURE)
+
+//
+// AML Handle Signature.
+//
+#define EFI_AML_HANDLE_SIGNATURE SIGNATURE_32 ('E', 'A', 'H', 'S')
+#define EFI_AML_ROOT_HANDLE_SIGNATURE SIGNATURE_32 ('E', 'A', 'R', 'H')
+
+//
+// AML Handle Entry definition.
+//
+// Signature must be set to EFI_AML_HANDLE_SIGNATURE or EFI_AML_ROOT_HANDLE_SIGNATURE
+// Buffer is the ACPI node buffer pointer, the first/second bytes are opcode.
+// This buffer should not be freed.
+// Size is the total size of this ACPI node buffer.
+//
+typedef struct {
+ UINT32 Signature;
+ UINT8 *Buffer;
+ UINTN Size;
+ AML_BYTE_ENCODING *AmlByteEncoding;
+ EFI_ACPI_SDT_HEADER *Table;
+ BOOLEAN Modified;
+ BOOLEAN OnBuffer;
+} EFI_AML_HANDLE;
+
+typedef UINT32 AML_OP_PARSE_INDEX;
+
+#define AML_OP_PARSE_INDEX_GET_OPCODE 0
+#define AML_OP_PARSE_INDEX_GET_TERM1 1
+#define AML_OP_PARSE_INDEX_GET_TERM2 2
+#define AML_OP_PARSE_INDEX_GET_TERM3 3
+#define AML_OP_PARSE_INDEX_GET_TERM4 4
+#define AML_OP_PARSE_INDEX_GET_TERM5 5
+#define AML_OP_PARSE_INDEX_GET_TERM6 6
+#define AML_OP_PARSE_INDEX_GET_SIZE (AML_OP_PARSE_INDEX)-1
+
+typedef UINT32 AML_OP_PARSE_FORMAT;
+#define AML_NONE 0
+#define AML_OPCODE 1
+#define AML_UINT8 2
+#define AML_UINT16 3
+#define AML_UINT32 4
+#define AML_UINT64 5
+#define AML_NAME 6
+#define AML_STRING 7
+#define AML_OBJECT 8
+
+typedef UINT32 AML_OP_ATTRIBUTE;
+#define AML_HAS_PKG_LENGTH 0x1 // It is ACPI attribute - if OpCode has PkgLength
+#define AML_IS_NAME_CHAR 0x2 // It is ACPI attribute - if this is NameChar
+#define AML_HAS_CHILD_OBJ 0x4 // it is ACPI attribute - if OpCode has Child Object.
+#define AML_IN_NAMESPACE 0x10000 // It is UEFI SDT attribute - if OpCode will be in NameSpace
+ // NOTE; Not all OBJECT will be in NameSpace
+ // For example, BankField | CreateBitField | CreateByteField | CreateDWordField |
+ // CreateField | CreateQWordField | CreateWordField | Field | IndexField.
+
+struct _AML_BYTE_ENCODING {
+ UINT8 OpCode;
+ UINT8 SubOpCode;
+ AML_OP_PARSE_INDEX MaxIndex;
+ AML_OP_PARSE_FORMAT Format[6];
+ AML_OP_ATTRIBUTE Attribute;
+};
+
+//
+// AcpiSdt protocol declaration
+//
+
+/**
+ Returns a requested ACPI table.
+
+ The GetAcpiTable() function returns a pointer to a buffer containing the ACPI table associated
+ with the Index that was input. The following structures are not considered elements in the list of
+ ACPI tables:
+ - Root System Description Pointer (RSD_PTR)
+ - Root System Description Table (RSDT)
+ - Extended System Description Table (XSDT)
+ Version is updated with a bit map containing all the versions of ACPI of which the table is a
+ member.
+
+ @param[in] Index The zero-based index of the table to retrieve.
+ @param[out] Table Pointer for returning the table buffer.
+ @param[out] Version On return, updated with the ACPI versions to which this table belongs. Type
+ EFI_ACPI_TABLE_VERSION is defined in "Related Definitions" in the
+ EFI_ACPI_SDT_PROTOCOL.
+ @param[out] TableKey On return, points to the table key for the specified ACPI system definition table. This
+ is identical to the table key used in the EFI_ACPI_TABLE_PROTOCOL.
+
+ @retval EFI_SUCCESS The function completed successfully.
+ @retval EFI_NOT_FOUND The requested index is too large and a table was not found.
+**/
+EFI_STATUS
+EFIAPI
+GetAcpiTable2 (
+ IN UINTN Index,
+ OUT EFI_ACPI_SDT_HEADER **Table,
+ OUT EFI_ACPI_TABLE_VERSION *Version,
+ OUT UINTN *TableKey
+ );
+
+/**
+ Register or unregister a callback when an ACPI table is installed.
+
+ This function registers or unregisters a function which will be called whenever a new ACPI table is
+ installed.
+
+ @param[in] Register If TRUE, then the specified function will be registered. If FALSE, then the specified
+ function will be unregistered.
+ @param[in] Notification Points to the callback function to be registered or unregistered.
+
+ @retval EFI_SUCCESS Callback successfully registered or unregistered.
+ @retval EFI_INVALID_PARAMETER Notification is NULL
+ @retval EFI_INVALID_PARAMETER Register is FALSE and Notification does not match a known registration function.
+**/
+EFI_STATUS
+EFIAPI
+RegisterNotify (
+ IN BOOLEAN Register,
+ IN EFI_ACPI_NOTIFICATION_FN Notification
+ );
+
+/**
+ Create a handle for the first ACPI opcode in an ACPI system description table.
+
+ @param[in] TableKey The table key for the ACPI table, as returned by GetTable().
+ @param[out] Handle On return, points to the newly created ACPI handle.
+
+ @retval EFI_SUCCESS Handle created successfully.
+ @retval EFI_NOT_FOUND TableKey does not refer to a valid ACPI table.
+**/
+EFI_STATUS
+EFIAPI
+OpenSdt (
+ IN UINTN TableKey,
+ OUT EFI_ACPI_HANDLE *Handle
+ );
+
+/**
+ Create a handle from an ACPI opcode
+
+ @param[in] Buffer Points to the ACPI opcode.
+ @param[out] Handle Upon return, holds the handle.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER Buffer is NULL or Handle is NULL or Buffer points to an
+ invalid opcode.
+
+**/
+EFI_STATUS
+EFIAPI
+Open (
+ IN VOID *Buffer,
+ OUT EFI_ACPI_HANDLE *Handle
+ );
+
+/**
+ Close an ACPI handle.
+
+ @param[in] Handle Returns the handle.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+EFIAPI
+Close (
+ IN EFI_ACPI_HANDLE Handle
+ );
+
+/**
+ Retrieve information about an ACPI object.
+
+ @param[in] Handle ACPI object handle.
+ @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
+ in the ACPI encoding, with index 0 always being the ACPI opcode.
+ @param[out] DataType Points to the returned data type or EFI_ACPI_DATA_TYPE_NONE if no data exists
+ for the specified index.
+ @param[out] Data Upon return, points to the pointer to the data.
+ @param[out] DataSize Upon return, points to the size of Data.
+
+ @retval EFI_SUCCESS Success.
+ @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+EFIAPI
+GetOption (
+ IN EFI_ACPI_HANDLE Handle,
+ IN UINTN Index,
+ OUT EFI_ACPI_DATA_TYPE *DataType,
+ OUT CONST VOID **Data,
+ OUT UINTN *DataSize
+ );
+
+/**
+ Change information about an ACPI object.
+
+ @param[in] Handle ACPI object handle.
+ @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
+ in the ACPI encoding, with index 0 always being the ACPI opcode.
+ @param[in] Data Points to the data.
+ @param[in] DataSize The size of the Data.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER Handle is NULL or does not refer to a valid ACPI object.
+ @retval EFI_BAD_BUFFER_SIZE Data cannot be accommodated in the space occupied by
+ the option.
+
+**/
+EFI_STATUS
+EFIAPI
+SetOption (
+ IN EFI_ACPI_HANDLE Handle,
+ IN UINTN Index,
+ IN CONST VOID *Data,
+ IN UINTN DataSize
+ );
+
+/**
+ Return the child ACPI objects.
+
+ @param[in] ParentHandle Parent handle.
+ @param[in, out] Handle On entry, points to the previously returned handle or NULL to start with the first
+ handle. On return, points to the next returned ACPI handle or NULL if there are no
+ child objects.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+EFIAPI
+GetChild (
+ IN EFI_ACPI_HANDLE ParentHandle,
+ IN OUT EFI_ACPI_HANDLE *Handle
+ );
+
+/**
+ Returns the handle of the ACPI object representing the specified ACPI path
+
+ @param[in] HandleIn Points to the handle of the object representing the starting point for the path search.
+ @param[in] AcpiPath Points to the ACPI path, which conforms to the ACPI encoded path format.
+ @param[out] HandleOut On return, points to the ACPI object which represents AcpiPath, relative to
+ HandleIn.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER HandleIn is NULL or does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+EFIAPI
+FindPath (
+ IN EFI_ACPI_HANDLE HandleIn,
+ IN VOID *AcpiPath,
+ OUT EFI_ACPI_HANDLE *HandleOut
+ );
+
+//
+// ACPI SDT function
+//
+
+/**
+ Create a handle from an ACPI opcode
+
+ @param[in] Buffer Points to the ACPI opcode.
+ @param[in] BufferSize Max buffer size.
+ @param[out] Handle Upon return, holds the handle.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER Buffer is NULL or Handle is NULL or Buffer points to an
+ invalid opcode.
+
+**/
+EFI_STATUS
+SdtOpenEx (
+ IN VOID *Buffer,
+ IN UINTN BufferSize,
+ OUT EFI_ACPI_HANDLE *Handle
+ );
+
+//
+// AML support function
+//
+
+/**
+ Get AML NameString size.
+
+ @param[in] Buffer AML NameString.
+ @param[out] BufferSize AML NameString size
+
+ @retval EFI_SUCCESS Success.
+ @retval EFI_INVALID_PARAMETER Buffer does not refer to a valid AML NameString.
+**/
+EFI_STATUS
+AmlGetNameStringSize (
+ IN UINT8 *Buffer,
+ OUT UINTN *BufferSize
+ );
+
+/**
+ This function retuns package length from the buffer.
+
+ @param[in] Buffer AML buffer
+ @param[out] PkgLength The total length of package.
+
+ @return The byte data count to present the package length.
+**/
+UINTN
+AmlGetPkgLength (
+ IN UINT8 *Buffer,
+ OUT UINTN *PkgLength
+ );
+
+/**
+ This function returns AcpiDataType according to AmlType.
+
+ @param[in] AmlType AML Type.
+
+ @return AcpiDataType
+**/
+EFI_ACPI_DATA_TYPE
+AmlTypeToAcpiType (
+ IN AML_OP_PARSE_FORMAT AmlType
+ );
+
+/**
+ This function returns AmlByteEncoding according to OpCode Byte.
+
+ @param[in] OpByteBuffer OpCode byte buffer.
+
+ @return AmlByteEncoding
+**/
+AML_BYTE_ENCODING *
+AmlSearchByOpByte (
+ IN UINT8 *OpByteBuffer
+ );
+
+/**
+ Return object size.
+
+ @param[in] AmlByteEncoding AML Byte Encoding.
+ @param[in] Buffer AML object buffer.
+ @param[in] MaxBufferSize AML object buffer MAX size. The parser can not parse any data exceed this region.
+
+ @return Size of the object.
+**/
+UINTN
+AmlGetObjectSize (
+ IN AML_BYTE_ENCODING *AmlByteEncoding,
+ IN UINT8 *Buffer,
+ IN UINTN MaxBufferSize
+ );
+
+/**
+ Return object name.
+
+ @param[in] AmlHandle AML handle.
+
+ @return Name of the object.
+**/
+CHAR8 *
+AmlGetObjectName (
+ IN EFI_AML_HANDLE *AmlHandle
+ );
+
+/**
+ Retrieve information according to AmlHandle
+
+ @param[in] AmlHandle AML handle.
+ @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
+ in the ACPI encoding, with index 0 always being the ACPI opcode.
+ @param[out] DataType Points to the returned data type or EFI_ACPI_DATA_TYPE_NONE if no data exists
+ for the specified index.
+ @param[out] Data Upon return, points to the pointer to the data.
+ @param[out] DataSize Upon return, points to the size of Data.
+
+ @retval EFI_SUCCESS Success.
+ @retval EFI_INVALID_PARAMETER AmlHandle does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+AmlParseOptionHandleCommon (
+ IN EFI_AML_HANDLE *AmlHandle,
+ IN AML_OP_PARSE_INDEX Index,
+ OUT EFI_ACPI_DATA_TYPE *DataType,
+ OUT VOID **Data,
+ OUT UINTN *DataSize
+ );
+
+/**
+ Return offset of last option.
+
+ @param[in] AmlHandle AML Handle.
+ @param[out] Buffer Upon return, points to the offset after last option.
+
+ @retval EFI_SUCCESS Success.
+ @retval EFI_INVALID_PARAMETER AmlHandle does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+AmlGetOffsetAfterLastOption (
+ IN EFI_AML_HANDLE *AmlHandle,
+ OUT UINT8 **Buffer
+ );
+
+/**
+ Return the child ACPI objects from Root Handle.
+
+ @param[in] AmlParentHandle Parent handle. It is Root Handle.
+ @param[in] AmlHandle The previously returned handle or NULL to start with the first handle.
+ @param[out] Buffer On return, points to the next returned ACPI handle or NULL if there are no
+ child objects.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+AmlGetChildFromRoot (
+ IN EFI_AML_HANDLE *AmlParentHandle,
+ IN EFI_AML_HANDLE *AmlHandle,
+ OUT VOID **Buffer
+ );
+
+/**
+ Return the child ACPI objects from Non-Root Handle.
+
+ @param[in] AmlParentHandle Parent handle. It is Non-Root Handle.
+ @param[in] AmlHandle The previously returned handle or NULL to start with the first handle.
+ @param[out] Buffer On return, points to the next returned ACPI handle or NULL if there are no
+ child objects.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+AmlGetChildFromNonRoot (
+ IN EFI_AML_HANDLE *AmlParentHandle,
+ IN EFI_AML_HANDLE *AmlHandle,
+ OUT VOID **Buffer
+ );
+
+/**
+ Return AML name according to ASL name.
+ The caller need free the AmlName returned.
+
+ @param[in] AslPath ASL name.
+
+ @return AmlName
+**/
+UINT8 *
+AmlNameFromAslName (
+ IN UINT8 *AslPath
+ );
+
+/**
+ Returns the handle of the ACPI object representing the specified ACPI AML path
+
+ @param[in] AmlHandle Points to the handle of the object representing the starting point for the path search.
+ @param[in] AmlPath Points to the ACPI AML path.
+ @param[out] Buffer On return, points to the ACPI object which represents AcpiPath, relative to
+ HandleIn.
+ @param[in] FromRoot TRUE means to find AML path from \ (Root) Node.
+ FALSE means to find AML path from this Node (The HandleIn).
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER HandleIn does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+AmlFindPath (
+ IN EFI_AML_HANDLE *AmlHandle,
+ IN UINT8 *AmlPath,
+ OUT VOID **Buffer,
+ IN BOOLEAN FromRoot
+ );
+
+/**
+ Print AML NameString.
+
+ @param[in] Buffer AML NameString.
+**/
+VOID
+AmlPrintNameString (
+ IN UINT8 *Buffer
+ );
+
+/**
+ Print AML NameSeg.
+
+ @param[in] Buffer AML NameSeg.
+**/
+VOID
+AmlPrintNameSeg (
+ IN UINT8 *Buffer
+ );
+
+/**
+ Check if it is AML Root name
+
+ @param[in] Buffer AML path.
+
+ @retval TRUE AML path is root.
+ @retval FALSE AML path is not root.
+**/
+BOOLEAN
+AmlIsRootPath (
+ IN UINT8 *Buffer
+ );
+
+/****** DO NOT WRITE BELOW THIS LINE *******/
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Core/EM/ACPI/Aml.c b/Core/EM/ACPI/Aml.c
new file mode 100644
index 0000000..a5510cb
--- /dev/null
+++ b/Core/EM/ACPI/Aml.c
@@ -0,0 +1,350 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/BIN/Modules/ACPI/Template/Core/Aml.c 2 5/14/11 2:08p Yakovlevs $
+//
+// $Revision: 2 $
+//
+// $Date: 5/14/11 2:08p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/Aml.c $
+//
+// 2 5/14/11 2:08p Yakovlevs
+// [TAG] EIP 56526
+// [Category] New Feature
+// [Description] ACPI Manipulation Protocol. PI 1.2 Spec Vol 5 Section
+// 9. Initial checkin.
+// [Files] AcpiCore.c; AcpiCore.h; AcpiSdtPrivate.h; Aml.c; AmlChild.c;
+// AmlNamespace.c; AmlOption.c; AmlString.c AcpiSdt.c;
+// Protocol\AcpiSdt.h.
+//
+//**********************************************************************
+
+
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: Aml.c
+//
+// Description:
+// Generic AML Parsing functions.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+
+#include "AcpiCore.h"
+
+GLOBAL_REMOVE_IF_UNREFERENCED
+AML_BYTE_ENCODING mAmlByteEncoding[] = {
+ // OpCode SubOpCode Num 1 2 3 4 5 6 Attribute
+/* ZeroOp - 0x00 */ {AML_ZERO_OP, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* OneOp - 0x01 */ {AML_ONE_OP, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* AliasOp - 0x06 */ {AML_ALIAS_OP, 0, 2, AML_NAME, AML_NAME, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IN_NAMESPACE},
+/* NameOp - 0x08 */ {AML_NAME_OP, 0, 2, AML_NAME, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IN_NAMESPACE},
+/* BytePrefix - 0x0A */ {AML_BYTE_PREFIX, 0, 1, AML_UINT8, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* WordPrefix - 0x0B */ {AML_WORD_PREFIX, 0, 1, AML_UINT16, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* DWordPrefix - 0x0C */ {AML_DWORD_PREFIX, 0, 1, AML_UINT32, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* StringPrefix - 0x0D */ {AML_STRING_PREFIX, 0, 1, AML_STRING, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* QWordPrefix - 0x0E */ {AML_QWORD_PREFIX, 0, 1, AML_UINT64, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* ScopeOp - 0x10 */ {AML_SCOPE_OP, 0, 1, AML_NAME, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ | AML_IN_NAMESPACE},
+/* BufferOp - 0x11 */ {AML_BUFFER_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH},
+/* PackageOp - 0x12 */ {AML_PACKAGE_OP, 0, 1, AML_UINT8, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ},
+/* VarPackageOp - 0x13 */ {AML_VAR_PACKAGE_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ},
+/* MethodOp - 0x14 */ {AML_METHOD_OP, 0, 2, AML_NAME, AML_UINT8, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ | AML_IN_NAMESPACE},
+/* DualNamePrefix - 0x2F */ {AML_DUAL_NAME_PREFIX, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* MultiNamePrefix - 0x2F */ {AML_MULTI_NAME_PREFIX, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x41 */ {'A', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x42 */ {'B', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x43 */ {'C', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x44 */ {'D', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x45 */ {'E', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x46 */ {'F', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x47 */ {'G', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x48 */ {'H', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x49 */ {'I', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x4A */ {'J', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x4B */ {'K', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x4C */ {'L', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x4D */ {'M', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x4E */ {'N', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x4F */ {'O', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x50 */ {'P', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x51 */ {'Q', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x52 */ {'R', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x53 */ {'S', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x54 */ {'T', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x55 */ {'U', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x56 */ {'V', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x57 */ {'W', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x58 */ {'X', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x59 */ {'Y', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x5A */ {'Z', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* MutexOp - 0x5B 0x01 */ {AML_EXT_OP, AML_EXT_MUTEX_OP, 2, AML_NAME, AML_UINT8, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IN_NAMESPACE},
+/* EventOp - 0x5B 0x02 */ {AML_EXT_OP, AML_EXT_EVENT_OP, 1, AML_NAME, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IN_NAMESPACE},
+/* CondRefOfOp - 0x5B 0x12 */ {AML_EXT_OP, AML_EXT_COND_REF_OF_OP, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* CreateFieldOp - 0x5B 0x13 */ {AML_EXT_OP, AML_EXT_CREATE_FIELD_OP,4, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NAME, AML_NONE, AML_NONE, 0},
+/* LoadTableOp - 0x5B 0x1F */ {AML_EXT_OP, AML_EXT_LOAD_TABLE_OP, 6, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_OBJECT, 0},
+/* LoadOp - 0x5B 0x20 */ {AML_EXT_OP, AML_EXT_LOAD_OP, 2, AML_NAME, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* StallOp - 0x5B 0x21 */ {AML_EXT_OP, AML_EXT_STALL_OP, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* SleepOp - 0x5B 0x22 */ {AML_EXT_OP, AML_EXT_SLEEP_OP, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* AcquireOp - 0x5B 0x23 */ {AML_EXT_OP, AML_EXT_ACQUIRE_OP, 2, AML_OBJECT, AML_UINT16, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* SignalOp - 0x5B 0x24 */ {AML_EXT_OP, AML_EXT_SIGNAL_OP, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* WaitOp - 0x5B 0x25 */ {AML_EXT_OP, AML_EXT_WAIT_OP, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* ResetOp - 0x5B 0x26 */ {AML_EXT_OP, AML_EXT_RESET_OP, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* ReleaseOp - 0x5B 0x27 */ {AML_EXT_OP, AML_EXT_RELEASE_OP, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* FromBCDOp - 0x5B 0x28 */ {AML_EXT_OP, AML_EXT_FROM_BCD_OP, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* ToBCDOp - 0x5B 0x29 */ {AML_EXT_OP, AML_EXT_TO_BCD_OP, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* UnloadOp - 0x5B 0x2A */ {AML_EXT_OP, AML_EXT_UNLOAD_OP, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* RevisionOp - 0x5B 0x30 */ {AML_EXT_OP, AML_EXT_REVISION_OP, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* DebugOp - 0x5B 0x31 */ {AML_EXT_OP, AML_EXT_DEBUG_OP, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* FatalOp - 0x5B 0x32 */ {AML_EXT_OP, AML_EXT_FATAL_OP, 3, AML_UINT8, AML_UINT32, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
+/* TimerOp - 0x5B 0x33 */ {AML_EXT_OP, AML_EXT_TIMER_OP, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* OpRegionOp - 0x5B 0x80 */ {AML_EXT_OP, AML_EXT_REGION_OP, 4, AML_NAME, AML_UINT8, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_IN_NAMESPACE},
+/* FieldOp - 0x5B 0x81 */ {AML_EXT_OP, AML_EXT_FIELD_OP, 2, AML_NAME, AML_UINT8, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH},
+/* DeviceOp - 0x5B 0x82 */ {AML_EXT_OP, AML_EXT_DEVICE_OP, 1, AML_NAME, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ | AML_IN_NAMESPACE},
+/* ProcessorOp - 0x5B 0x83 */ {AML_EXT_OP, AML_EXT_PROCESSOR_OP, 4, AML_NAME, AML_UINT8, AML_UINT32, AML_UINT8, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ | AML_IN_NAMESPACE},
+/* PowerResOp - 0x5B 0x84 */ {AML_EXT_OP, AML_EXT_POWER_RES_OP, 3, AML_NAME, AML_UINT8, AML_UINT16, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ | AML_IN_NAMESPACE},
+/* ThermalZoneOp - 0x5B 0x85 */ {AML_EXT_OP, AML_EXT_THERMAL_ZONE_OP,1, AML_NAME, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ | AML_IN_NAMESPACE},
+/* IndexFieldOp - 0x5B 0x86 */ {AML_EXT_OP, AML_EXT_INDEX_FIELD_OP, 3, AML_NAME, AML_NAME, AML_UINT8, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH},
+/* BankFieldOp - 0x5B 0x87 */ {AML_EXT_OP, AML_EXT_BANK_FIELD_OP, 4, AML_NAME, AML_NAME, AML_OBJECT, AML_UINT8, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH},
+/* DataRegionOp - 0x5B 0x88 */ {AML_EXT_OP, AML_EXT_DATA_REGION_OP, 4, AML_NAME, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_IN_NAMESPACE},
+/* RootChar - 0x5C */ {AML_ROOT_CHAR, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* ParentPrefixChar - 0x5E */ {AML_PARENT_PREFIX_CHAR, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* NameChar - 0x5F */ {'_', 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_IS_NAME_CHAR},
+/* Local0Op - 0x60 */ {AML_LOCAL0, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* Local1Op - 0x61 */ {AML_LOCAL1, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* Local2Op - 0x62 */ {AML_LOCAL2, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* Local3Op - 0x63 */ {AML_LOCAL3, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* Local4Op - 0x64 */ {AML_LOCAL4, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* Local5Op - 0x65 */ {AML_LOCAL5, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* Local6Op - 0x66 */ {AML_LOCAL6, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* Local7Op - 0x67 */ {AML_LOCAL7, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* Arg0Op - 0x68 */ {AML_ARG0, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* Arg1Op - 0x69 */ {AML_ARG1, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* Arg2Op - 0x6A */ {AML_ARG2, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* Arg3Op - 0x6B */ {AML_ARG3, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* Arg4Op - 0x6C */ {AML_ARG4, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* Arg5Op - 0x6D */ {AML_ARG5, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* Arg6Op - 0x6E */ {AML_ARG6, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* StoreOp - 0x70 */ {AML_STORE_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* RefOfOp - 0x71 */ {AML_REF_OF_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* AddOp - 0x72 */ {AML_ADD_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
+/* ConcatOp - 0x73 */ {AML_CONCAT_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
+/* SubtractOp - 0x74 */ {AML_SUBTRACT_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
+/* IncrementOp - 0x75 */ {AML_INCREMENT_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* DecrementOp - 0x76 */ {AML_DECREMENT_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* MultiplyOp - 0x77 */ {AML_MULTIPLY_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
+/* DivideOp - 0x78 */ {AML_DIVIDE_OP, 0, 4, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, 0},
+/* ShiftLeftOp - 0x79 */ {AML_SHIFT_LEFT_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
+/* ShiftRightOp - 0x7A */ {AML_SHIFT_RIGHT_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
+/* AndOp - 0x7B */ {AML_AND_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
+/* NAndOp - 0x7C */ {AML_NAND_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
+/* OrOp - 0x7D */ {AML_OR_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
+/* NorOp - 0x7E */ {AML_NOR_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
+/* XOrOp - 0x7F */ {AML_XOR_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
+/* NotOp - 0x80 */ {AML_NOT_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* FindSetLeftBitOp - 0x81 */ {AML_FIND_SET_LEFT_BIT_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* FindSetRightBitOp - 0x82 */ {AML_FIND_SET_RIGHT_BIT_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* DerefOfOp - 0x83 */ {AML_DEREF_OF_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* ConcatResOp - 0x84 */ {AML_CONCAT_RES_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
+/* ModOp - 0x85 */ {AML_MOD_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
+/* NotifyOp - 0x86 */ {AML_NOTIFY_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* SizeOfOp - 0x87 */ {AML_SIZE_OF_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* IndexOp - 0x88 */ {AML_INDEX_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
+/* MatchOp - 0x89 */ {AML_MATCH_OP, 0, 6, AML_OBJECT, AML_UINT8, AML_OBJECT, AML_UINT8, AML_OBJECT, AML_OBJECT, 0},
+/* CreateDWordFieldOp - 0x8A */ {AML_CREATE_DWORD_FIELD_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_NAME, AML_NONE, AML_NONE, AML_NONE, 0},
+/* CreateWordFieldOp - 0x8B */ {AML_CREATE_WORD_FIELD_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_NAME, AML_NONE, AML_NONE, AML_NONE, 0},
+/* CreateByteFieldOp - 0x8C */ {AML_CREATE_BYTE_FIELD_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_NAME, AML_NONE, AML_NONE, AML_NONE, 0},
+/* CreateBitFieldOp - 0x8D */ {AML_CREATE_BIT_FIELD_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_NAME, AML_NONE, AML_NONE, AML_NONE, 0},
+/* ObjectTypeOp - 0x8E */ {AML_OBJECT_TYPE_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* CreateQWordFieldOp - 0x8F */ {AML_CREATE_QWORD_FIELD_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_NAME, AML_NONE, AML_NONE, AML_NONE, 0},
+/* LAndOp - 0x90 */ {AML_LAND_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* LOrOp - 0x91 */ {AML_LOR_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* LNotOp - 0x92 */ {AML_LNOT_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* LEqualOp - 0x93 */ {AML_LEQUAL_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* LGreaterOp - 0x94 */ {AML_LGREATER_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* LLessOp - 0x95 */ {AML_LLESS_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* ToBufferOp - 0x96 */ {AML_TO_BUFFER_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* ToDecimalStringOp - 0x97 */ {AML_TO_DEC_STRING_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* ToHexStringOp - 0x98 */ {AML_TO_HEX_STRING_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* ToIntegerOp - 0x99 */ {AML_TO_INTEGER_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* ToStringOp - 0x9C */ {AML_TO_STRING_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
+/* CopyObjectOp - 0x9D */ {AML_COPY_OBJECT_OP, 0, 2, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* MidOp - 0x9E */ {AML_MID_OP, 0, 3, AML_OBJECT, AML_OBJECT, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, 0},
+/* ContinueOp - 0x9F */ {AML_CONTINUE_OP, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* IfOp - 0xA0 */ {AML_IF_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ},
+/* ElseOp - 0xA1 */ {AML_ELSE_OP, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ},
+/* WhileOp - 0xA2 */ {AML_WHILE_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_HAS_PKG_LENGTH | AML_HAS_CHILD_OBJ},
+/* NoopOp - 0xA3 */ {AML_NOOP_OP, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* ReturnOp - 0xA4 */ {AML_RETURN_OP, 0, 1, AML_OBJECT, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* BreakOp - 0xA5 */ {AML_BREAK_OP, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* BreakPointOp - 0xCC */ {AML_BREAK_POINT_OP, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+/* OnesOp - 0xFF */ {AML_ONES_OP, 0, 0, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, AML_NONE, 0},
+};
+
+GLOBAL_REMOVE_IF_UNREFERENCED
+EFI_ACPI_DATA_TYPE mAmlTypeToAcpiType[] = {
+ EFI_ACPI_DATA_TYPE_NONE, // AML_NONE
+ EFI_ACPI_DATA_TYPE_OPCODE, // AML_OPCODE
+ EFI_ACPI_DATA_TYPE_UINT, // AML_UINT8
+ EFI_ACPI_DATA_TYPE_UINT, // AML_UINT16
+ EFI_ACPI_DATA_TYPE_UINT, // AML_UINT32
+ EFI_ACPI_DATA_TYPE_UINT, // AML_UINT64
+ EFI_ACPI_DATA_TYPE_NAME_STRING, // AML_NAME
+ EFI_ACPI_DATA_TYPE_STRING, // AML_STRING
+ EFI_ACPI_DATA_TYPE_CHILD // AML_OBJECT
+};
+
+/**
+ This function returns AmlByteEncoding according to OpCode Byte.
+
+ @param[in] OpByteBuffer OpCode byte buffer.
+
+ @return AmlByteEncoding
+**/
+AML_BYTE_ENCODING *
+AmlSearchByOpByte (
+ IN UINT8 *OpByteBuffer
+ )
+{
+ UINT8 OpCode;
+ UINT8 SubOpCode;
+ UINTN Index;
+
+ //
+ // Get OpCode and SubOpCode
+ //
+ OpCode = OpByteBuffer[0];
+ if (OpCode == AML_EXT_OP) {
+ SubOpCode = OpByteBuffer[1];
+ } else {
+ SubOpCode = 0;
+ }
+
+ //
+ // Search the table
+ //
+ for (Index = 0; Index < sizeof(mAmlByteEncoding)/sizeof(mAmlByteEncoding[0]); Index++) {
+ if ((mAmlByteEncoding[Index].OpCode == OpCode) && (mAmlByteEncoding[Index].SubOpCode == SubOpCode)) {
+ return &mAmlByteEncoding[Index];
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ This function returns AcpiDataType according to AmlType.
+
+ @param[in] AmlType AML Type.
+
+ @return AcpiDataType
+**/
+EFI_ACPI_DATA_TYPE
+AmlTypeToAcpiType (
+ IN AML_OP_PARSE_FORMAT AmlType
+ )
+{
+ if (AmlType >= sizeof(mAmlTypeToAcpiType)/sizeof(mAmlTypeToAcpiType[0])) {
+ ASSERT(FALSE);
+ return EFI_ACPI_DATA_TYPE_NONE;
+ }
+ return mAmlTypeToAcpiType [AmlType];
+}
+
+/**
+ This function retuns package length from the buffer.
+
+ @param[in] Buffer AML buffer
+ @param[out] PkgLength The total length of package.
+
+ @return The byte data count to present the package length.
+**/
+UINTN
+AmlGetPkgLength (
+ IN UINT8 *Buffer,
+ OUT UINTN *PkgLength
+ )
+{
+ UINT8 LeadByte;
+ UINT8 ByteCount;
+ UINTN RealLength;
+ UINTN Offset;
+
+ //
+ // <bit 7-6: ByteData count that follows (0-3)>
+ // <bit 5-4: Only used if PkgLength < 63>
+ // <bit 3-0: Least significant package length nybble>
+ //
+ // Note: The high 2 bits of the first byte reveal how many follow bytes are in the
+ // If the PkgLength has only one byte, bit 0 through 5 are used to encode the
+ // package length (in other words, values 0-63). If the package length value is more than
+ // 63, more than one byte must be used for the encoding in which case bit 4 and 5 of the
+ // PkgLeadByte are reserved and must be zero. If the multiple bytes encoding is used,
+ // bits 0-3 of the PkgLeadByte become the least significant 4 bits of the resulting
+ // package length value. The next ByteData will become the next least significant 8 bits
+ // of the resulting value and so on, up to 3 ByteData bytes. Thus, the maximum package
+ // length is 2**28.
+ //
+
+ LeadByte = *Buffer;
+ ByteCount = (UINT8)((LeadByte >> 6) & 0x03);
+ Offset = ByteCount + 1;
+ RealLength = 0;
+
+ switch (ByteCount) {
+ case 0:
+ RealLength = (UINT32)LeadByte;
+ break;
+ case 1:
+ RealLength = *(Buffer + 1);
+ RealLength = (RealLength << 4) | (LeadByte & 0xF);
+ break;
+ case 2:
+ RealLength = *(Buffer + 1);
+ RealLength |= (*(Buffer + 2)) << 8;
+ RealLength = (RealLength << 4) | (LeadByte & 0xF);
+ break;
+ case 3:
+ RealLength = *(Buffer + 1);
+ RealLength |= (*(Buffer + 2)) << 8;
+ RealLength |= (*(Buffer + 3)) << 16;
+ RealLength = (RealLength << 4) | (LeadByte & 0xF);
+ break;
+ default:
+ ASSERT (0);
+ break;
+ }
+
+ *PkgLength = RealLength;
+ return Offset;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Core/EM/ACPI/AmlChild.c b/Core/EM/ACPI/AmlChild.c
new file mode 100644
index 0000000..1c6ecc2
--- /dev/null
+++ b/Core/EM/ACPI/AmlChild.c
@@ -0,0 +1,326 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/BIN/Modules/ACPI/Template/Core/AmlChild.c 2 5/14/11 2:10p Yakovlevs $
+//
+// $Revision: 2 $
+//
+// $Date: 5/14/11 2:10p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/AmlChild.c $
+//
+// 2 5/14/11 2:10p Yakovlevs
+// [TAG] EIP 56526
+// [Category] New Feature
+// [Description] ACPI Manipulation Protocol. PI 1.2 Spec Vol 5 Section
+// 9. Initial checkin.
+// [Files] AcpiCore.c; AcpiCore.h; AcpiSdtPrivate.h; Aml.c; AmlChild.c;
+// AmlNamespace.c; AmlOption.c; AmlString.c AcpiSdt.c;
+// Protocol\AcpiSdt.h.
+//
+//**********************************************************************
+
+
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: AmlChild.c
+//
+// Description:
+// ACPI AML Name space parsing/manipulation functions for ACPI SDT.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#include "AcpiCore.h"
+
+/**
+ Return the child objects buffer from AML Handle's buffer.
+
+ @param[in] AmlParentHandle Parent handle.
+ @param[in] CurrentBuffer The current child buffer.
+ @param[out] Buffer On return, points to the next returned child buffer or NULL if there are no
+ child buffer.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER AmlParentHandle does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+AmlGetChildFromObjectBuffer (
+ IN EFI_AML_HANDLE *AmlParentHandle,
+ IN UINT8 *CurrentBuffer,
+ OUT VOID **Buffer
+ )
+{
+ AML_BYTE_ENCODING *AmlByteEncoding;
+ UINTN DataSize;
+
+ //
+ // Root is considered as SCOPE, which has TermList.
+ // We need return only Object in TermList.
+ //
+ while ((UINTN)CurrentBuffer < (UINTN)(AmlParentHandle->Buffer + AmlParentHandle->Size)) {
+ AmlByteEncoding = AmlSearchByOpByte (CurrentBuffer);
+ if (AmlByteEncoding == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // NOTE: We need return everything, because user might need parse the returned object.
+ //
+ if ((AmlByteEncoding->Attribute & AML_IS_NAME_CHAR) == 0) {
+ *Buffer = CurrentBuffer;
+ return EFI_SUCCESS;
+ }
+
+ DataSize = AmlGetObjectSize (
+ AmlByteEncoding,
+ CurrentBuffer,
+ (UINTN)AmlParentHandle->Buffer + AmlParentHandle->Size - (UINTN)CurrentBuffer
+ );
+ if (DataSize == 0) {
+ return EFI_INVALID_PARAMETER;
+ }
+ CurrentBuffer += DataSize;
+ }
+
+ //
+ // No more
+ //
+ *Buffer = NULL;
+ return EFI_SUCCESS;
+}
+
+/**
+ Return the child ACPI objects from Root Handle.
+
+ @param[in] AmlParentHandle Parent handle. It is Root Handle.
+ @param[in] AmlHandle The previously returned handle or NULL to start with the first handle.
+ @param[out] Buffer On return, points to the next returned ACPI handle or NULL if there are no
+ child objects.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+AmlGetChildFromRoot (
+ IN EFI_AML_HANDLE *AmlParentHandle,
+ IN EFI_AML_HANDLE *AmlHandle,
+ OUT VOID **Buffer
+ )
+{
+ UINT8 *CurrentBuffer;
+
+ if (AmlHandle == NULL) {
+ //
+ // First One
+ //
+ CurrentBuffer = (VOID *)AmlParentHandle->Buffer;
+ } else {
+ CurrentBuffer = (VOID *)(AmlHandle->Buffer + AmlHandle->Size);
+ }
+
+ return AmlGetChildFromObjectBuffer (AmlParentHandle, CurrentBuffer, Buffer);
+}
+
+/**
+ Return the child objects buffer from AML Handle's option list.
+
+ @param[in] AmlParentHandle Parent handle.
+ @param[in] AmlHandle The current child handle.
+ @param[out] Buffer On return, points to the next returned child buffer or NULL if there are no
+ child buffer.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER AmlParentHandle does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+AmlGetChildFromOptionList (
+ IN EFI_AML_HANDLE *AmlParentHandle,
+ IN EFI_AML_HANDLE *AmlHandle,
+ OUT VOID **Buffer
+ )
+{
+ EFI_ACPI_DATA_TYPE DataType;
+ VOID *Data;
+ UINTN DataSize;
+ AML_OP_PARSE_INDEX Index;
+ EFI_STATUS Status;
+ AML_OP_PARSE_INDEX MaxTerm;
+
+ Index = AML_OP_PARSE_INDEX_GET_TERM1;
+ MaxTerm = AmlParentHandle->AmlByteEncoding->MaxIndex;
+ while (Index <= MaxTerm) {
+ Status = AmlParseOptionHandleCommon (
+ AmlParentHandle,
+ (AML_OP_PARSE_INDEX)Index,
+ &DataType,
+ (VOID **)&Data,
+ &DataSize
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (DataType == EFI_ACPI_DATA_TYPE_NONE) {
+ //
+ // Not found
+ //
+ break;
+ }
+
+ //
+ // Find it, and Check Data
+ //
+ if ((DataType == EFI_ACPI_DATA_TYPE_CHILD) &&
+ ((UINTN)AmlHandle->Buffer < (UINTN)Data)) {
+ //
+ // Buffer < Data means current node is next one
+ //
+ *Buffer = Data;
+ return EFI_SUCCESS;
+ }
+ //
+ // Not Child
+ //
+ Index ++;
+ }
+
+ *Buffer = NULL;
+ return EFI_SUCCESS;
+}
+
+/**
+ Return the child objects buffer from AML Handle's object child list.
+
+ @param[in] AmlParentHandle Parent handle.
+ @param[in] AmlHandle The current child handle.
+ @param[out] Buffer On return, points to the next returned child buffer or NULL if there are no
+ child buffer.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER AmlParentHandle does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+AmlGetChildFromObjectChildList (
+ IN EFI_AML_HANDLE *AmlParentHandle,
+ IN EFI_AML_HANDLE *AmlHandle,
+ OUT VOID **Buffer
+ )
+{
+ EFI_STATUS Status;
+ UINT8 *CurrentBuffer;
+
+ if ((AmlParentHandle->AmlByteEncoding->Attribute & AML_HAS_CHILD_OBJ) == 0) {
+ //
+ // No ObjectList
+ //
+ *Buffer = NULL;
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Do we need add node within METHOD?
+ // Yes, just add Object is OK. But we need filter NameString for METHOD invoke.
+ //
+
+ //
+ // Now, we get the last node.
+ //
+ Status = AmlGetOffsetAfterLastOption (AmlParentHandle, &CurrentBuffer);
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Go through all the reset buffer.
+ //
+ if ((UINTN)AmlHandle->Buffer < (UINTN)CurrentBuffer) {
+ //
+ // Buffer < Data means next node is first object
+ //
+ } else if ((UINTN)AmlHandle->Buffer + AmlHandle->Size < (UINTN)AmlParentHandle->Buffer + AmlParentHandle->Size) {
+ //
+ // There is still more node
+ //
+ CurrentBuffer = AmlHandle->Buffer + AmlHandle->Size;
+ } else {
+ //
+ // No more data
+ //
+ *Buffer = NULL;
+ return EFI_SUCCESS;
+ }
+
+ return AmlGetChildFromObjectBuffer (AmlParentHandle, CurrentBuffer, Buffer);
+}
+
+/**
+ Return the child ACPI objects from Non-Root Handle.
+
+ @param[in] AmlParentHandle Parent handle. It is Non-Root Handle.
+ @param[in] AmlHandle The previously returned handle or NULL to start with the first handle.
+ @param[out] Buffer On return, points to the next returned ACPI handle or NULL if there are no
+ child objects.
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER ParentHandle is NULL or does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+AmlGetChildFromNonRoot (
+ IN EFI_AML_HANDLE *AmlParentHandle,
+ IN EFI_AML_HANDLE *AmlHandle,
+ OUT VOID **Buffer
+ )
+{
+ EFI_STATUS Status;
+
+ if (AmlHandle == NULL) {
+ //
+ // NULL means first one
+ //
+ AmlHandle = AmlParentHandle;
+ }
+
+ //
+ // 1. Get Option
+ //
+ Status = AmlGetChildFromOptionList (AmlParentHandle, AmlHandle, Buffer);
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (*Buffer != NULL) {
+ return EFI_SUCCESS;
+ }
+
+ //
+ // 2. search ObjectList
+ //
+ return AmlGetChildFromObjectChildList (AmlParentHandle, AmlHandle, Buffer);
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Core/EM/ACPI/AmlNamespace.c b/Core/EM/ACPI/AmlNamespace.c
new file mode 100644
index 0000000..2c72400
--- /dev/null
+++ b/Core/EM/ACPI/AmlNamespace.c
@@ -0,0 +1,659 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/BIN/Modules/ACPI/Template/Core/AmlNamespace.c 2 5/14/11 2:11p Yakovlevs $
+//
+// $Revision: 2 $
+//
+// $Date: 5/14/11 2:11p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/AmlNamespace.c $
+//
+// 2 5/14/11 2:11p Yakovlevs
+// [TAG] EIP 56526
+// [Category] New Feature
+// [Description] ACPI Manipulation Protocol. PI 1.2 Spec Vol 5 Section
+// 9. Initial checkin.
+// [Files] AcpiCore.c; AcpiCore.h; AcpiSdtPrivate.h; Aml.c; AmlChild.c;
+// AmlNamespace.c; AmlOption.c; AmlString.c AcpiSdt.c;
+// Protocol\AcpiSdt.h.
+//
+//**********************************************************************
+
+
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: AmlNamespace.c
+//
+// Description:
+// ACPI AML Name space parsing/manipulation functions for ACPI SDT.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#include "AcpiCore.h"
+
+/**
+ Construct node list according to the AML handle.
+
+ @param[in] AmlHandle AML handle.
+ @param[in] AmlRootNodeList AML root node list.
+ @param[in] AmlParentNodeList AML parent node list.
+
+ @retval EFI_SUCCESS Success.
+ @retval EFI_INVALID_PARAMETER AML handle does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+AmlConstructNodeList (
+ IN EFI_AML_HANDLE *AmlHandle,
+ IN EFI_AML_NODE_LIST *AmlRootNodeList,
+ IN EFI_AML_NODE_LIST *AmlParentNodeList
+ );
+
+/**
+ Create AML Node.
+
+ @param[in] NameSeg AML NameSeg.
+ @param[in] Parent AML parent node list.
+ @param[in] AmlByteEncoding AML Byte Encoding.
+
+ @return AML Node.
+**/
+EFI_AML_NODE_LIST *
+AmlCreateNode (
+ IN UINT8 *NameSeg,
+ IN EFI_AML_NODE_LIST *Parent,
+ IN AML_BYTE_ENCODING *AmlByteEncoding
+ )
+{
+ EFI_AML_NODE_LIST *AmlNodeList;
+
+ AmlNodeList = Malloc(sizeof(*AmlNodeList));
+ ASSERT (AmlNodeList != NULL);
+
+ AmlNodeList->Signature = EFI_AML_NODE_LIST_SIGNATURE;
+ pBS->CopyMem (AmlNodeList->Name, NameSeg, AML_NAME_SEG_SIZE);
+ AmlNodeList->Buffer = NULL;
+ AmlNodeList->Size = 0;
+ InitializeListHead (&AmlNodeList->Link);
+ InitializeListHead (&AmlNodeList->Children);
+ AmlNodeList->Parent = Parent;
+ AmlNodeList->AmlByteEncoding = AmlByteEncoding;
+
+ return AmlNodeList;
+}
+
+/**
+ Find the AML NameSeg in the children of AmlParentNodeList.
+
+ @param[in] NameSeg AML NameSeg.
+ @param[in] AmlParentNodeList AML parent node list.
+ @param[in] Create TRUE means to create node if not found.
+
+ @return AmlChildNode whoes name is same as NameSeg.
+**/
+EFI_AML_NODE_LIST *
+AmlFindNodeInThis (
+ IN UINT8 *NameSeg,
+ IN EFI_AML_NODE_LIST *AmlParentNodeList,
+ IN BOOLEAN Create
+ )
+{
+ EFI_AML_NODE_LIST *CurrentAmlNodeList;
+ LIST_ENTRY *CurrentLink;
+ LIST_ENTRY *StartLink;
+ EFI_AML_NODE_LIST *AmlNodeList;
+
+ StartLink = &AmlParentNodeList->Children;
+ CurrentLink = StartLink->ForwardLink;
+
+ while (CurrentLink != StartLink) {
+ CurrentAmlNodeList = EFI_AML_NODE_LIST_FROM_LINK (CurrentLink);
+ //
+ // AML name is same as the one stored
+ //
+ if (MemCmp (CurrentAmlNodeList->Name, NameSeg, AML_NAME_SEG_SIZE) == 0) {
+ //
+ // Good! Found it
+ //
+ return CurrentAmlNodeList;
+ }
+ CurrentLink = CurrentLink->ForwardLink;
+ }
+
+ //
+ // Not found
+ //
+ if (!Create) {
+ return NULL;
+ }
+
+ //
+ // Create new node with NULL buffer - it means namespace not be returned.
+ //
+ AmlNodeList = AmlCreateNode (NameSeg, AmlParentNodeList, NULL);
+ InsertTailList (&AmlParentNodeList->Children, &AmlNodeList->Link);
+
+ return AmlNodeList;
+}
+
+/**
+ Find the AML NameString in the children of AmlParentNodeList or AmlRootNodeList.
+
+ @param[in] NameString AML NameString.
+ @param[in] AmlRootNodeList AML root node list.
+ @param[in] AmlParentNodeList AML parent node list.
+ @param[in] Create TRUE means to create node if not found.
+
+ @return AmlChildNode whoes name is same as NameSeg.
+**/
+EFI_AML_NODE_LIST *
+AmlFindNodeInTheTree (
+ IN UINT8 *NameString,
+ IN EFI_AML_NODE_LIST *AmlRootNodeList,
+ IN EFI_AML_NODE_LIST *AmlParentNodeList,
+ IN BOOLEAN Create
+ )
+{
+ UINT8 *Buffer;
+ EFI_AML_NODE_LIST *AmlNodeList;
+ EFI_AML_NODE_LIST *AmlCurrentNodeList;
+ UINT8 Index;
+ UINT8 SegCount;
+
+ Buffer = NameString;
+
+ //
+ // Handle root or parent prefix
+ //
+ if (*Buffer == AML_ROOT_CHAR) {
+ AmlCurrentNodeList = AmlRootNodeList;
+ Buffer += 1;
+ } else if (*Buffer == AML_PARENT_PREFIX_CHAR) {
+ AmlCurrentNodeList = AmlParentNodeList;
+ do {
+ if (AmlCurrentNodeList->Parent != NULL) {
+ AmlCurrentNodeList = AmlCurrentNodeList->Parent;
+ } else {
+ //
+ // Only root has no parent
+ //
+ ASSERT (AmlCurrentNodeList == AmlRootNodeList);
+ }
+ Buffer += 1;
+ } while (*Buffer == AML_PARENT_PREFIX_CHAR);
+ } else {
+ AmlCurrentNodeList = AmlParentNodeList;
+ }
+
+ //
+ // Handle name segment
+ //
+ if (*Buffer == AML_DUAL_NAME_PREFIX) {
+ Buffer += 1;
+ SegCount = 2;
+ } else if (*Buffer == AML_MULTI_NAME_PREFIX) {
+ Buffer += 1;
+ SegCount = *Buffer;
+ Buffer += 1;
+ } else if (*Buffer == 0) {
+ //
+ // NULL name, only for Root
+ //
+ ASSERT (AmlCurrentNodeList == AmlRootNodeList);
+ return AmlCurrentNodeList;
+ } else {
+ SegCount = 1;
+ }
+
+ //
+ // Handle NamePath
+ //
+ Index = 0;
+ do {
+ AmlNodeList = AmlFindNodeInThis (Buffer, AmlCurrentNodeList, Create);
+ if (AmlNodeList == NULL) {
+ return NULL;
+ }
+ AmlCurrentNodeList = AmlNodeList;
+ Buffer += AML_NAME_SEG_SIZE;
+ Index ++;
+ } while (Index < SegCount);
+
+ return AmlNodeList;
+}
+
+/**
+ Insert the NameString to the AmlNodeList.
+
+ @param[in] NameString AML NameString.
+ @param[in] Buffer Buffer for the Node.
+ @param[in] Size Size for the Node.
+ @param[in] AmlRootNodeList AML root node list.
+ @param[in] AmlParentNodeList AML parent node list.
+
+ @return AmlChildNode whoes name is NameString.
+**/
+EFI_AML_NODE_LIST *
+AmlInsertNodeToTree (
+ IN UINT8 *NameString,
+ IN VOID *Buffer,
+ IN UINTN Size,
+ IN EFI_AML_NODE_LIST *AmlRootNodeList,
+ IN EFI_AML_NODE_LIST *AmlParentNodeList
+ )
+{
+ EFI_AML_NODE_LIST *AmlNodeList;
+
+ AmlNodeList = AmlFindNodeInTheTree (
+ NameString,
+ AmlRootNodeList,
+ AmlParentNodeList,
+ TRUE // Find and Create
+ );
+ ASSERT (AmlNodeList != NULL);
+ if (AmlNodeList == NULL) {
+ return NULL;
+ }
+
+ //
+ // Check buffer
+ //
+ if (AmlNodeList->Buffer == NULL) {
+ //
+ // NULL means new added one or SCOPE_OP
+ //
+ if (*(UINT8 *)Buffer != AML_SCOPE_OP) {
+ //
+ // We need check if new one is SCOPE_OP, because SCOPE_OP just means namespace, not a real device.
+ // We should not return SCOPE_OP.
+ //
+ AmlNodeList->Buffer = Buffer;
+ AmlNodeList->Size = Size;
+ AmlNodeList->AmlByteEncoding = AmlSearchByOpByte (Buffer);
+ }
+ return AmlNodeList;
+ }
+
+ //
+ // Already added
+ //
+ if (*(UINT8 *)Buffer == AML_SCOPE_OP) {
+ //
+ // The new one is SCOPE_OP, OK just return;
+ //
+ return AmlNodeList;
+ }
+
+ //
+ // Oops!!!, There must be something wrong.
+ //
+ TRACE ((-1, "AML: Override Happen - %a!\n", NameString));
+ TRACE ((-1, "AML: Existing Node - %x\n", AmlNodeList->Buffer));
+ TRACE ((-1, "AML: New Buffer - %x\n", Buffer));
+
+ return NULL;
+}
+
+/**
+ Construct child node list according to the AML handle.
+
+ @param[in] AmlHandle AML handle.
+ @param[in] AmlRootNodeList AML root node list.
+ @param[in] AmlParentNodeList AML parent node list.
+
+ @retval EFI_SUCCESS Success.
+ @retval EFI_INVALID_PARAMETER AML handle does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+AmlConstructNodeListForChild (
+ IN EFI_AML_HANDLE *AmlHandle,
+ IN EFI_AML_NODE_LIST *AmlRootNodeList,
+ IN EFI_AML_NODE_LIST *AmlParentNodeList
+ )
+{
+ AML_BYTE_ENCODING *AmlByteEncoding;
+ UINT8 *Buffer;
+ UINTN BufferSize;
+ UINT8 *CurrentBuffer;
+ EFI_AML_HANDLE *AmlChildHandle;
+ EFI_STATUS Status;
+
+ AmlByteEncoding = AmlHandle->AmlByteEncoding;
+ Buffer = AmlHandle->Buffer;
+ BufferSize = AmlHandle->Size;
+
+ //
+ // Check if we need recursively add node
+ //
+ if ((AmlByteEncoding->Attribute & AML_HAS_CHILD_OBJ) == 0) {
+ //
+ // No more node need to be added
+ //
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Do we need add node within METHOD?
+ // Yes, just add Object is OK. But we need filter NameString for METHOD invoke.
+ //
+
+ //
+ // Now, we get the last node.
+ //
+ Status = AmlGetOffsetAfterLastOption (AmlHandle, &CurrentBuffer);
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Go through all the reset buffer.
+ //
+ while ((UINTN)CurrentBuffer < (UINTN)Buffer + BufferSize) {
+ //
+ // Find the child node.
+ //
+ Status = SdtOpenEx (CurrentBuffer, (UINTN)Buffer + BufferSize - (UINTN)CurrentBuffer, (EFI_ACPI_HANDLE *)&AmlChildHandle);
+ if (EFI_ERROR (Status)) {
+ //
+ // No child found, break now.
+ //
+ break;
+ }
+
+ //
+ // Good, find the child. Construct node recursively
+ //
+ Status = AmlConstructNodeList (
+ AmlChildHandle,
+ AmlRootNodeList,
+ AmlParentNodeList
+ );
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+
+ //
+ // Parse next one
+ //
+ CurrentBuffer += AmlChildHandle->Size;
+
+ Close ((EFI_ACPI_HANDLE)AmlChildHandle);
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Construct node list according to the AML handle.
+
+ @param[in] AmlHandle AML handle.
+ @param[in] AmlRootNodeList AML root node list.
+ @param[in] AmlParentNodeList AML parent node list.
+
+ @retval EFI_SUCCESS Success.
+ @retval EFI_INVALID_PARAMETER AML handle does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+AmlConstructNodeList (
+ IN EFI_AML_HANDLE *AmlHandle,
+ IN EFI_AML_NODE_LIST *AmlRootNodeList,
+ IN EFI_AML_NODE_LIST *AmlParentNodeList
+ )
+{
+ VOID *NameString;
+ EFI_AML_NODE_LIST *AmlNodeList;
+
+ //
+ // 1. Check if there is need to construct node for this OpCode.
+ //
+ if ((AmlHandle->AmlByteEncoding->Attribute & AML_IN_NAMESPACE) == 0) {
+ //
+ // No need to construct node, so we just skip this OpCode.
+ //
+ return EFI_SUCCESS;
+ }
+
+ //
+ // 2. Now, we need construct node for this OpCode.
+ //
+ NameString = AmlGetObjectName (AmlHandle);
+ if (NameString == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Now, we need to insert node to the node list.
+ // NOTE: The name here could be AML NameString. So the callee need parse it.
+ //
+ AmlNodeList = AmlInsertNodeToTree (NameString, AmlHandle->Buffer, AmlHandle->Size, AmlRootNodeList, AmlParentNodeList);
+ ASSERT (AmlNodeList != NULL);
+
+ //
+ // 3. Ok, we need to parse the object list to see if there are more node to be added.
+ //
+ return AmlConstructNodeListForChild (AmlHandle, AmlRootNodeList, AmlNodeList);
+}
+
+/**
+ Destruct node list
+
+ @param[in] AmlParentNodeList AML parent node list.
+**/
+VOID
+AmlDestructNodeList (
+ IN EFI_AML_NODE_LIST *AmlParentNodeList
+ )
+{
+ EFI_AML_NODE_LIST *CurrentAmlNodeList;
+ LIST_ENTRY *CurrentLink;
+ LIST_ENTRY *StartLink;
+
+ //
+ // Get the children link
+ //
+ StartLink = &AmlParentNodeList->Children;
+ CurrentLink = StartLink->ForwardLink;
+
+ //
+ // Go through all the children
+ //
+ while (CurrentLink != StartLink) {
+ //
+ // Destruct the child's list recursively
+ //
+ CurrentAmlNodeList = EFI_AML_NODE_LIST_FROM_LINK (CurrentLink);
+ CurrentLink = CurrentLink->ForwardLink;
+
+ //
+ // Remove this child from list and free the node
+ //
+ RemoveEntryList (&(CurrentAmlNodeList->Link));
+
+ AmlDestructNodeList (CurrentAmlNodeList);
+ }
+
+ //
+ // Done.
+ //
+ pBS->FreePool (AmlParentNodeList);
+ return ;
+}
+
+/**
+ Dump node list
+
+ @param[in] AmlParentNodeList AML parent node list.
+ @param[in] Level Output debug level.
+**/
+VOID
+AmlDumpNodeInfo (
+ IN EFI_AML_NODE_LIST *AmlParentNodeList,
+ IN UINTN Level
+ )
+{
+ EFI_AML_NODE_LIST *CurrentAmlNodeList;
+ volatile LIST_ENTRY *CurrentLink;
+ UINTN Index;
+
+ CurrentLink = AmlParentNodeList->Children.ForwardLink;
+
+ if (Level == 0) {
+ TRACE ((-1, "\\"));
+ } else {
+ for (Index = 0; Index < Level; Index++) {
+ TRACE ((-1, " "));
+ }
+ AmlPrintNameSeg (AmlParentNodeList->Name);
+ }
+ TRACE ((-1, "\n"));
+
+ while (CurrentLink != &AmlParentNodeList->Children) {
+ CurrentAmlNodeList = EFI_AML_NODE_LIST_FROM_LINK (CurrentLink);
+ AmlDumpNodeInfo (CurrentAmlNodeList, Level + 1);
+ CurrentLink = CurrentLink->ForwardLink;
+ }
+
+ return ;
+}
+
+/**
+ Returns the handle of the ACPI object representing the specified ACPI AML path
+
+ @param[in] AmlHandle Points to the handle of the object representing the starting point for the path search.
+ @param[in] AmlPath Points to the ACPI AML path.
+ @param[out] Buffer On return, points to the ACPI object which represents AcpiPath, relative to
+ HandleIn.
+ @param[in] FromRoot TRUE means to find AML path from \ (Root) Node.
+ FALSE means to find AML path from this Node (The HandleIn).
+
+ @retval EFI_SUCCESS Success
+ @retval EFI_INVALID_PARAMETER HandleIn does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+AmlFindPath (
+ IN EFI_AML_HANDLE *AmlHandle,
+ IN UINT8 *AmlPath,
+ OUT VOID **Buffer,
+ IN BOOLEAN FromRoot
+ )
+{
+ EFI_AML_NODE_LIST *AmlRootNodeList;
+ EFI_STATUS Status;
+ EFI_AML_NODE_LIST *AmlNodeList;
+ UINT8 RootNameSeg[AML_NAME_SEG_SIZE];
+ EFI_AML_NODE_LIST *CurrentAmlNodeList;
+ LIST_ENTRY *CurrentLink;
+
+ //
+ // 1. create tree
+ //
+
+ //
+ // Create root handle
+ //
+ RootNameSeg[0] = AML_ROOT_CHAR;
+ RootNameSeg[1] = 0;
+ AmlRootNodeList = AmlCreateNode (RootNameSeg, NULL, AmlHandle->AmlByteEncoding);
+
+ Status = AmlConstructNodeList (
+ AmlHandle,
+ AmlRootNodeList, // Root
+ AmlRootNodeList // Parent
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+#if EFI_DEBUG
+ TRACE ((-1, "AcpiSdt: NameSpace:\n"));
+ AmlDumpNodeInfo (AmlRootNodeList, 0);
+#endif
+ //
+ // 2. Search the node in the tree
+ //
+ if (FromRoot) {
+ //
+ // Search from Root
+ //
+ CurrentAmlNodeList = AmlRootNodeList;
+ } else {
+ //
+ // Search from this node, NOT ROOT.
+ // Since we insert node to ROOT one by one, we just get the first node and search from it.
+ //
+ CurrentLink = AmlRootNodeList->Children.ForwardLink;
+ if (CurrentLink != &AmlRootNodeList->Children) {
+ //
+ // First node
+ //
+ CurrentAmlNodeList = EFI_AML_NODE_LIST_FROM_LINK (CurrentLink);
+ } else {
+ //
+ // No child
+ //
+ CurrentAmlNodeList = NULL;
+ }
+ }
+
+ //
+ // Search
+ //
+ if (CurrentAmlNodeList != NULL) {
+#if EFI_DEBUG
+ TRACE ((-1, "AcpiSdt: Search from: \\"));
+ AmlPrintNameSeg (CurrentAmlNodeList->Name);
+ TRACE ((-1, "\n"));
+#endif
+ AmlNodeList = AmlFindNodeInTheTree (
+ AmlPath,
+ AmlRootNodeList, // Root
+ CurrentAmlNodeList, // Parent
+ FALSE
+ );
+ } else {
+ AmlNodeList = NULL;
+ }
+
+ *Buffer = NULL;
+ Status = EFI_SUCCESS;
+ if (AmlNodeList != NULL && AmlNodeList->Buffer != NULL) {
+ *Buffer = AmlNodeList->Buffer;
+ }
+
+ //
+ // 3. free the tree
+ //
+ AmlDestructNodeList (AmlRootNodeList);
+
+ return Status;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Core/EM/ACPI/AmlOption.c b/Core/EM/ACPI/AmlOption.c
new file mode 100644
index 0000000..55ef7f7
--- /dev/null
+++ b/Core/EM/ACPI/AmlOption.c
@@ -0,0 +1,500 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/BIN/Modules/ACPI/Template/Core/AmlOption.c 2 5/14/11 2:12p Yakovlevs $
+//
+// $Revision: 2 $
+//
+// $Date: 5/14/11 2:12p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/AmlOption.c $
+//
+// 2 5/14/11 2:12p Yakovlevs
+// [TAG] EIP 56526
+// [Category] New Feature
+// [Description] ACPI Manipulation Protocol. PI 1.2 Spec Vol 5 Section
+// 9. Initial checkin.
+// [Files] AcpiCore.c; AcpiCore.h; AcpiSdtPrivate.h; Aml.c; AmlChild.c;
+// AmlNamespace.c; AmlOption.c; AmlString.c AcpiSdt.c;
+// Protocol\AcpiSdt.h.
+//
+//**********************************************************************
+
+
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: AmlOption.c
+//
+// Description:
+// ACPI AML Name space parsing/manipulation functions for ACPI SDT.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#include "AcpiCore.h"
+
+/**
+ Retrieve option term according to AmlByteEncoding and Buffer.
+
+ @param[in] AmlByteEncoding AML Byte Encoding.
+ @param[in] Buffer AML buffer.
+ @param[in] MaxBufferSize AML buffer MAX size. The parser can not parse any data exceed this region.
+ @param[in] TermIndex Index of the data to retrieve from the object.
+ @param[out] DataType Points to the returned data type or EFI_ACPI_DATA_TYPE_NONE if no data exists
+ for the specified index.
+ @param[out] Data Upon return, points to the pointer to the data.
+ @param[out] DataSize Upon return, points to the size of Data.
+
+ @retval EFI_SUCCESS Success.
+ @retval EFI_INVALID_PARAMETER Buffer does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+AmlParseOptionTerm (
+ IN AML_BYTE_ENCODING *AmlByteEncoding,
+ IN UINT8 *Buffer,
+ IN UINTN MaxBufferSize,
+ IN AML_OP_PARSE_INDEX TermIndex,
+ OUT EFI_ACPI_DATA_TYPE *DataType,
+ OUT VOID **Data,
+ OUT UINTN *DataSize
+ )
+{
+ AML_BYTE_ENCODING *ChildAmlByteEncoding;
+ EFI_STATUS Status;
+
+ if (DataType != NULL) {
+ *DataType = AmlTypeToAcpiType (AmlByteEncoding->Format[TermIndex - 1]);
+ }
+ if (Data != NULL) {
+ *Data = Buffer;
+ }
+ //
+ // Parse term according to AML type
+ //
+ switch (AmlByteEncoding->Format[TermIndex - 1]) {
+ case AML_UINT8:
+ *DataSize = sizeof(UINT8);
+ break;
+ case AML_UINT16:
+ *DataSize = sizeof(UINT16);
+ break;
+ case AML_UINT32:
+ *DataSize = sizeof(UINT32);
+ break;
+ case AML_UINT64:
+ *DataSize = sizeof(UINT64);
+ break;
+ case AML_STRING:
+ *DataSize = (Strlen((CHAR8 *)Buffer)+1);
+ break;
+ case AML_NAME:
+ Status = AmlGetNameStringSize (Buffer, DataSize);
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+ break;
+ case AML_OBJECT:
+ ChildAmlByteEncoding = AmlSearchByOpByte (Buffer);
+ if (ChildAmlByteEncoding == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // NOTE: We need override DataType here, if there is a case the AML_OBJECT is AML_NAME.
+ // We need convert type from EFI_ACPI_DATA_TYPE_CHILD to EFI_ACPI_DATA_TYPE_NAME_STRING.
+ // We should not return CHILD because there is NO OpCode for NameString.
+ //
+ if ((ChildAmlByteEncoding->Attribute & AML_IS_NAME_CHAR) != 0) {
+ if (DataType != NULL) {
+ *DataType = AmlTypeToAcpiType (AML_NAME);
+ }
+ Status = AmlGetNameStringSize (Buffer, DataSize);
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+ break;
+ }
+
+ //
+ // It is real AML_OBJECT
+ //
+ *DataSize = AmlGetObjectSize (
+ ChildAmlByteEncoding,
+ Buffer,
+ MaxBufferSize
+ );
+ if (*DataSize == 0) {
+ return EFI_INVALID_PARAMETER;
+ }
+ break;
+ case AML_NONE:
+ //
+ // No term
+ //
+ case AML_OPCODE:
+ default:
+ ASSERT (FALSE);
+ return EFI_INVALID_PARAMETER;
+ }
+ if (*DataSize > MaxBufferSize) {
+ return EFI_INVALID_PARAMETER;
+ }
+ return EFI_SUCCESS;
+}
+
+/**
+ Retrieve information according to AmlByteEncoding and Buffer.
+
+ @param[in] AmlByteEncoding AML Byte Encoding.
+ @param[in] Buffer AML buffer.
+ @param[in] MaxBufferSize AML buffer MAX size. The parser can not parse any data exceed this region.
+ @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
+ in the ACPI encoding, with index 0 always being the ACPI opcode.
+ @param[out] DataType Points to the returned data type or EFI_ACPI_DATA_TYPE_NONE if no data exists
+ for the specified index.
+ @param[out] Data Upon return, points to the pointer to the data.
+ @param[out] DataSize Upon return, points to the size of Data.
+
+ @retval EFI_SUCCESS Success.
+ @retval EFI_INVALID_PARAMETER Buffer does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+AmlParseOptionCommon (
+ IN AML_BYTE_ENCODING *AmlByteEncoding,
+ IN UINT8 *Buffer,
+ IN UINTN MaxBufferSize,
+ IN AML_OP_PARSE_INDEX Index,
+ OUT EFI_ACPI_DATA_TYPE *DataType,
+ OUT VOID **Data,
+ OUT UINTN *DataSize
+ )
+{
+ UINT8 *CurrentBuffer;
+ UINTN PkgLength;
+ UINTN OpLength;
+ UINTN PkgOffset;
+ AML_OP_PARSE_INDEX TermIndex;
+ EFI_STATUS Status;
+
+ ASSERT ((Index <= AmlByteEncoding->MaxIndex) || (Index == AML_OP_PARSE_INDEX_GET_SIZE));
+
+ //
+ // 0. Check if this is NAME string.
+ //
+ if ((AmlByteEncoding->Attribute & AML_IS_NAME_CHAR) != 0) {
+ //
+ // Only allow GET_SIZE
+ //
+ if (Index != AML_OP_PARSE_INDEX_GET_SIZE) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // return NameString size
+ //
+ Status = AmlGetNameStringSize (Buffer, DataSize);
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (*DataSize > MaxBufferSize) {
+ return EFI_INVALID_PARAMETER;
+ }
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Not NAME string, start parsing
+ //
+ CurrentBuffer = Buffer;
+
+ //
+ // 1. Get OpCode
+ //
+ if (Index != AML_OP_PARSE_INDEX_GET_SIZE) {
+ *DataType = EFI_ACPI_DATA_TYPE_OPCODE;
+ *Data = (VOID *)CurrentBuffer;
+ }
+ if (*CurrentBuffer == AML_EXT_OP) {
+ OpLength = 2;
+ } else {
+ OpLength = 1;
+ }
+ *DataSize = OpLength;
+ if (Index == AML_OP_PARSE_INDEX_GET_OPCODE) {
+ return EFI_SUCCESS;
+ }
+ if (OpLength > MaxBufferSize) {
+ return EFI_INVALID_PARAMETER;
+ }
+ CurrentBuffer += OpLength;
+
+ //
+ // 2. Skip PkgLength field, if have
+ //
+ if ((AmlByteEncoding->Attribute & AML_HAS_PKG_LENGTH) != 0) {
+ PkgOffset = AmlGetPkgLength(CurrentBuffer, &PkgLength);
+ //
+ // Override MaxBufferSize if it is valid PkgLength
+ //
+ if (OpLength + PkgLength > MaxBufferSize) {
+ return EFI_INVALID_PARAMETER;
+ } else {
+ MaxBufferSize = OpLength + PkgLength;
+ }
+ } else {
+ PkgOffset = 0;
+ PkgLength = 0;
+ }
+ CurrentBuffer += PkgOffset;
+
+ //
+ // 3. Get Term one by one.
+ //
+ TermIndex = AML_OP_PARSE_INDEX_GET_TERM1;
+ while ((Index >= TermIndex) && (TermIndex <= AmlByteEncoding->MaxIndex) && ((UINTN)CurrentBuffer < (UINTN)Buffer + MaxBufferSize)) {
+ Status = AmlParseOptionTerm (
+ AmlByteEncoding,
+ CurrentBuffer,
+ (UINTN)Buffer + MaxBufferSize - (UINTN)CurrentBuffer,
+ TermIndex,
+ DataType,
+ Data,
+ DataSize
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Index == TermIndex) {
+ //
+ // Done
+ //
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Parse next one
+ //
+ CurrentBuffer += *DataSize;
+ TermIndex ++;
+ }
+
+ //
+ // Finish all options, but no option found.
+ //
+ if ((UINTN)CurrentBuffer > (UINTN)Buffer + MaxBufferSize) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if ((UINTN)CurrentBuffer == (UINTN)Buffer + MaxBufferSize) {
+ if (Index != AML_OP_PARSE_INDEX_GET_SIZE) {
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ //
+ // 4. Finish parsing all node, return size
+ //
+ ASSERT (Index == AML_OP_PARSE_INDEX_GET_SIZE);
+ if ((AmlByteEncoding->Attribute & AML_HAS_PKG_LENGTH) != 0) {
+ *DataSize = OpLength + PkgLength;
+ } else {
+ *DataSize = (UINTN)CurrentBuffer - (UINTN)Buffer;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Return object size.
+
+ @param[in] AmlByteEncoding AML Byte Encoding.
+ @param[in] Buffer AML object buffer.
+ @param[in] MaxBufferSize AML object buffer MAX size. The parser can not parse any data exceed this region.
+
+ @return Size of the object.
+**/
+UINTN
+AmlGetObjectSize (
+ IN AML_BYTE_ENCODING *AmlByteEncoding,
+ IN UINT8 *Buffer,
+ IN UINTN MaxBufferSize
+ )
+{
+ EFI_STATUS Status;
+ UINTN DataSize;
+
+ Status = AmlParseOptionCommon (
+ AmlByteEncoding,
+ Buffer,
+ MaxBufferSize,
+ AML_OP_PARSE_INDEX_GET_SIZE,
+ NULL,
+ NULL,
+ &DataSize
+ );
+ if (EFI_ERROR (Status)) {
+ return 0;
+ } else {
+ return DataSize;
+ }
+}
+
+/**
+ Return object name.
+
+ @param[in] AmlHandle AML handle.
+
+ @return Name of the object.
+**/
+CHAR8 *
+AmlGetObjectName (
+ IN EFI_AML_HANDLE *AmlHandle
+ )
+{
+ AML_BYTE_ENCODING *AmlByteEncoding;
+ VOID *NameString;
+ UINTN NameSize;
+ AML_OP_PARSE_INDEX TermIndex;
+ EFI_STATUS Status;
+ EFI_ACPI_DATA_TYPE DataType;
+
+ AmlByteEncoding = AmlHandle->AmlByteEncoding;
+
+ ASSERT ((AmlByteEncoding->Attribute & AML_IN_NAMESPACE) != 0);
+
+ //
+ // Find out Last Name index, accroding to OpCode table.
+ // The last name will be the node name by design.
+ //
+ TermIndex = AmlByteEncoding->MaxIndex;
+ for (TermIndex = AmlByteEncoding->MaxIndex; TermIndex > 0; TermIndex--) {
+ if (AmlByteEncoding->Format[TermIndex - 1] == AML_NAME) {
+ break;
+ }
+ }
+ ASSERT (TermIndex != 0);
+
+ //
+ // Get Name for this node.
+ //
+ Status = AmlParseOptionHandleCommon (
+ AmlHandle,
+ TermIndex,
+ &DataType,
+ &NameString,
+ &NameSize
+ );
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+ ASSERT (DataType == EFI_ACPI_DATA_TYPE_NAME_STRING);
+
+ return NameString;
+}
+
+/**
+ Return offset of last option.
+
+ @param[in] AmlHandle AML Handle.
+ @param[out] Buffer Upon return, points to the offset after last option.
+
+ @retval EFI_SUCCESS Success.
+ @retval EFI_INVALID_PARAMETER AmlHandle does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+AmlGetOffsetAfterLastOption (
+ IN EFI_AML_HANDLE *AmlHandle,
+ OUT UINT8 **Buffer
+ )
+{
+ EFI_ACPI_DATA_TYPE DataType;
+ VOID *Data;
+ UINTN DataSize;
+ EFI_STATUS Status;
+
+ Status = AmlParseOptionHandleCommon (
+ AmlHandle,
+ AmlHandle->AmlByteEncoding->MaxIndex,
+ &DataType,
+ &Data,
+ &DataSize
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // We need to parse the rest buffer after last node.
+ //
+ *Buffer = (UINT8 *)((UINTN)Data + DataSize);
+
+ //
+ // We need skip PkgLength if no Option
+ //
+ if (DataType == EFI_ACPI_DATA_TYPE_OPCODE) {
+ *Buffer += AmlGetPkgLength (*Buffer, &DataSize);
+ }
+ return EFI_SUCCESS;
+}
+
+/**
+ Retrieve information according to AmlHandle
+
+ @param[in] AmlHandle AML handle.
+ @param[in] Index Index of the data to retrieve from the object. In general, indexes read from left-to-right
+ in the ACPI encoding, with index 0 always being the ACPI opcode.
+ @param[out] DataType Points to the returned data type or EFI_ACPI_DATA_TYPE_NONE if no data exists
+ for the specified index.
+ @param[out] Data Upon return, points to the pointer to the data.
+ @param[out] DataSize Upon return, points to the size of Data.
+
+ @retval EFI_SUCCESS Success.
+ @retval EFI_INVALID_PARAMETER AmlHandle does not refer to a valid ACPI object.
+**/
+EFI_STATUS
+AmlParseOptionHandleCommon (
+ IN EFI_AML_HANDLE *AmlHandle,
+ IN AML_OP_PARSE_INDEX Index,
+ OUT EFI_ACPI_DATA_TYPE *DataType,
+ OUT VOID **Data,
+ OUT UINTN *DataSize
+ )
+{
+ return AmlParseOptionCommon (
+ AmlHandle->AmlByteEncoding,
+ AmlHandle->Buffer,
+ AmlHandle->Size,
+ Index,
+ DataType,
+ Data,
+ DataSize
+ );
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Core/EM/ACPI/AmlString.c b/Core/EM/ACPI/AmlString.c
new file mode 100644
index 0000000..b3640f3
--- /dev/null
+++ b/Core/EM/ACPI/AmlString.c
@@ -0,0 +1,600 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/BIN/Modules/ACPI/Template/Core/AmlString.c 3 12/13/12 12:00p Oleksiyy $
+//
+// $Revision: 3 $
+//
+// $Date: 12/13/12 12:00p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/AmlString.c $
+//
+// 3 12/13/12 12:00p Oleksiyy
+// [TAG] EIP109290
+// [Category] Improvement
+// [Description] Issues found by CppCheck in ACPI eModule
+// [Files] AcpiCore.c, mptable.c, AmlString.c, BootScriptSave.c and
+// BootScriptExecuter.c
+//
+// 2 5/14/11 2:13p Yakovlevs
+// [TAG] EIP 56526
+// [Category] New Feature
+// [Description] ACPI Manipulation Protocol. PI 1.2 Spec Vol 5 Section
+// 9. Initial checkin.
+// [Files] AcpiCore.c; AcpiCore.h; AcpiSdtPrivate.h; Aml.c; AmlChild.c;
+// AmlNamespace.c; AmlOption.c; AmlString.c AcpiSdt.c;
+// Protocol\AcpiSdt.h.
+//
+//**********************************************************************
+
+
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: AmlString.c
+//
+// Description:
+// ACPI AML Name space parsing/manipulation functions for ACPI SDT.
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#include "AcpiCore.h"
+
+/**
+ Check if it is AML Root name
+
+ @param[in] Buffer AML path.
+
+ @retval TRUE AML path is root.
+ @retval FALSE AML path is not root.
+**/
+BOOLEAN
+AmlIsRootPath (
+ IN UINT8 *Buffer
+ )
+{
+ if ((Buffer[0] == AML_ROOT_CHAR) && (Buffer[1] == 0)) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+/**
+ Check if it is AML LeadName.
+
+ @param[in] Ch Char.
+
+ @retval TRUE Char is AML LeadName.
+ @retval FALSE Char is not AML LeadName.
+**/
+BOOLEAN
+AmlIsLeadName (
+ IN CHAR8 Ch
+ )
+{
+ if ((Ch == '_') || (Ch >= 'A' && Ch <= 'Z')) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+/**
+ Check if it is AML Name.
+
+ @param[in] Ch Char.
+
+ @retval TRUE Char is AML Name.
+ @retval FALSE Char is not AML Name.
+**/
+BOOLEAN
+AmlIsName (
+ IN CHAR8 Ch
+ )
+{
+ if (AmlIsLeadName (Ch) || (Ch >= '0' && Ch <= '9')) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+/**
+ Return is buffer is AML NameSeg.
+
+ @param[in] Buffer AML NameSement.
+
+ @retval TRUE It is AML NameSegment.
+ @retval FALSE It is not AML NameSegment.
+**/
+BOOLEAN
+AmlIsNameSeg (
+ IN UINT8 *Buffer
+ )
+{
+ UINTN Index;
+ if (!AmlIsLeadName (Buffer[0])) {
+ return FALSE;
+ }
+ for (Index = 1; Index < AML_NAME_SEG_SIZE; Index++) {
+ if (!AmlIsName (Buffer[Index])) {
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
+
+/**
+ Get AML NameString size.
+
+ @param[in] Buffer AML NameString.
+ @param[out] BufferSize AML NameString size
+
+ @retval EFI_SUCCESS Success.
+ @retval EFI_INVALID_PARAMETER Buffer does not refer to a valid AML NameString.
+**/
+EFI_STATUS
+AmlGetNameStringSize (
+ IN UINT8 *Buffer,
+ OUT UINTN *BufferSize
+ )
+{
+ UINTN SegCount;
+ UINTN Length;
+ UINTN Index;
+
+ Length = 0;
+
+ //
+ // Parse root or parent prefix
+ //
+ if (*Buffer == AML_ROOT_CHAR) {
+ Buffer ++;
+ Length ++;
+ } else if (*Buffer == AML_PARENT_PREFIX_CHAR) {
+ do {
+ Buffer ++;
+ Length ++;
+ } while (*Buffer == AML_PARENT_PREFIX_CHAR);
+ }
+
+ //
+ // Parse name segment
+ //
+ if (*Buffer == AML_DUAL_NAME_PREFIX) {
+ Buffer ++;
+ Length ++;
+ SegCount = 2;
+ } else if (*Buffer == AML_MULTI_NAME_PREFIX) {
+ Buffer ++;
+ Length ++;
+ SegCount = *Buffer;
+ Buffer ++;
+ Length ++;
+ } else if (*Buffer == 0) {
+ //
+ // NULL Name, only for Root
+ //
+ SegCount = 0;
+ Buffer --;
+ if ((Length == 1) && (*Buffer == AML_ROOT_CHAR)) {
+ *BufferSize = 2;
+ return EFI_SUCCESS;
+ } else {
+ return EFI_INVALID_PARAMETER;
+ }
+ } else {
+ //
+ // NameSeg
+ //
+ SegCount = 1;
+ }
+
+ Index = 0;
+ do {
+ if (!AmlIsNameSeg (Buffer)) {
+ return EFI_INVALID_PARAMETER;
+ }
+ Buffer += AML_NAME_SEG_SIZE;
+ Length += AML_NAME_SEG_SIZE;
+ Index ++;
+ } while (Index < SegCount);
+
+ *BufferSize = Length;
+ return EFI_SUCCESS;
+}
+
+/**
+ Check if it is ASL LeadName.
+
+ @param[in] Ch Char.
+
+ @retval TRUE Char is ASL LeadName.
+ @retval FALSE Char is not ASL LeadName.
+**/
+BOOLEAN
+AmlIsAslLeadName (
+ IN CHAR8 Ch
+ )
+{
+ if (AmlIsLeadName (Ch) || (Ch >= 'a' && Ch <= 'z')) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+/**
+ Check if it is ASL Name.
+
+ @param[in] Ch Char.
+
+ @retval TRUE Char is ASL Name.
+ @retval FALSE Char is not ASL Name.
+**/
+BOOLEAN
+AmlIsAslName (
+ IN CHAR8 Ch
+ )
+{
+ if (AmlIsAslLeadName (Ch) || (Ch >= '0' && Ch <= '9')) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+/**
+ Get ASL NameString size.
+
+ @param[in] Buffer ASL NameString.
+
+ @return ASL NameString size.
+**/
+UINTN
+AmlGetAslNameSegLength (
+ IN UINT8 *Buffer
+ )
+{
+ UINTN Length;
+ UINTN Index;
+
+ if (*Buffer == 0) {
+ return 0;
+ }
+
+ Length = 0;
+ //
+ // 1st
+ //
+ if (AmlIsAslLeadName (*Buffer)) {
+ Length ++;
+ Buffer ++;
+ }
+ if ((*Buffer == 0) || (*Buffer == '.')) {
+ return Length;
+ }
+ //
+ // 2, 3, 4 name char
+ //
+ for (Index = 0; Index < 3; Index++) {
+ if (AmlIsAslName (*Buffer)) {
+ Length ++;
+ Buffer ++;
+ }
+ if ((*Buffer == 0) || (*Buffer == '.')) {
+ return Length;
+ }
+ }
+
+ //
+ // Invalid ASL name
+ //
+ return 0;
+}
+
+/**
+ Get ASL NameString size.
+
+ @param[in] Buffer ASL NameString.
+ @param[out] Root On return, points to Root char number.
+ @param[out] Parent On return, points to Parent char number.
+ @param[out] SegCount On return, points to Segment count.
+
+ @return ASL NameString size.
+**/
+UINTN
+AmlGetAslNameStringSize (
+ IN UINT8 *Buffer,
+ OUT UINTN *Root,
+ OUT UINTN *Parent,
+ OUT UINTN *SegCount
+ )
+{
+ UINTN NameLength;
+ UINTN TotalLength;
+
+ *Root = 0;
+ *Parent = 0;
+ *SegCount = 0;
+ TotalLength = 0;
+ NameLength = 0;
+ if (*Buffer == AML_ROOT_CHAR) {
+ *Root = 1;
+ Buffer ++;
+ } else if (*Buffer == AML_PARENT_PREFIX_CHAR) {
+ do {
+ Buffer ++;
+ (*Parent) ++;
+ } while (*Buffer == AML_PARENT_PREFIX_CHAR);
+ }
+
+ //
+ // Now parse name
+ //
+ while (*Buffer != 0) {
+ NameLength = AmlGetAslNameSegLength (Buffer);
+ if ((NameLength == 0) || (NameLength > AML_NAME_SEG_SIZE)) {
+ return 0;
+ }
+ (*SegCount) ++;
+ Buffer += NameLength;
+ if (*Buffer == 0) {
+ break;
+ }
+ Buffer ++;
+ }
+
+ //
+ // Check SegCoount
+ //
+ if (*SegCount > 0xFF) {
+ return 0;
+ }
+
+ //
+ // Calculate total length
+ //
+ TotalLength = *Root + *Parent + (*SegCount) * AML_NAME_SEG_SIZE;
+ if (*SegCount > 2) {
+ TotalLength += 2;
+ } else if (*SegCount == 2) {
+ TotalLength += 1;
+ }
+
+ //
+ // Add NULL char
+ //
+ TotalLength ++;
+
+ return TotalLength;
+}
+
+/**
+ Copy mem, and cast all the char in dest to be upper case.
+
+ @param[in] DstBuffer Destination buffer.
+ @param[in] SrcBuffer Source buffer.
+ @param[in] Length Buffer length.
+**/
+VOID
+AmlUpperCaseCopyMem (
+ IN UINT8 *DstBuffer,
+ IN UINT8 *SrcBuffer,
+ IN UINTN Length
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; Index < Length; Index++) {
+ if (SrcBuffer[Index] >= 'a' && SrcBuffer[Index] <= 'z') {
+ DstBuffer[Index] = (UINT8)(SrcBuffer[Index] - 'a' + 'A');
+ } else {
+ DstBuffer[Index] = SrcBuffer[Index];
+ }
+ }
+}
+
+/**
+ Return AML name according to ASL name.
+ The caller need free the AmlName returned.
+
+ @param[in] AslPath ASL name.
+
+ @return AmlName
+**/
+UINT8 *
+AmlNameFromAslName (
+ IN UINT8 *AslPath
+ )
+{
+ UINTN Root;
+ UINTN Parent;
+ UINTN SegCount;
+ UINTN TotalLength;
+ UINTN NameLength;
+ UINT8 *Buffer;
+ UINT8 *AmlPath;
+ UINT8 *AmlBuffer;
+
+ TotalLength = AmlGetAslNameStringSize (AslPath, &Root, &Parent, &SegCount);
+ if (TotalLength == 0) {
+ return NULL;
+ }
+
+ AmlPath = Malloc (TotalLength);
+ ASSERT (AmlPath != NULL);
+
+ AmlBuffer = AmlPath;
+ Buffer = AslPath;
+
+ //
+ // Handle Root and Parent
+ //
+ if (Root == 1) {
+ *AmlBuffer = AML_ROOT_CHAR;
+ AmlBuffer ++;
+ Buffer ++;
+ } else if (Parent > 0) {
+ MemSet (AmlBuffer, Parent, AML_PARENT_PREFIX_CHAR);
+ AmlBuffer += Parent;
+ Buffer += Parent;
+ }
+
+ //
+ // Handle SegCount
+ //
+ if (SegCount > 2) {
+ *AmlBuffer = AML_MULTI_NAME_PREFIX;
+ AmlBuffer ++;
+ *AmlBuffer = (UINT8)SegCount;
+ AmlBuffer ++;
+ } else if (SegCount == 2) {
+ *AmlBuffer = AML_DUAL_NAME_PREFIX;
+ AmlBuffer ++;
+ }
+
+ //
+ // Now to name
+ //
+ while (*Buffer != 0) {
+ NameLength = AmlGetAslNameSegLength (Buffer);
+ ASSERT ((NameLength != 0) && (NameLength <= AML_NAME_SEG_SIZE));
+ AmlUpperCaseCopyMem (AmlBuffer, Buffer, NameLength);
+ MemSet (AmlBuffer + NameLength, AML_NAME_SEG_SIZE - NameLength, AML_NAME_CHAR__);
+ Buffer += NameLength;
+ AmlBuffer += AML_NAME_SEG_SIZE;
+ if (*Buffer == 0) {
+ break;
+ }
+ Buffer ++;
+ }
+
+ //
+ // Add NULL
+ //
+ AmlPath[TotalLength - 1] = 0;
+
+ return AmlPath;
+}
+
+/**
+ Print AML NameSeg.
+
+ @param[in] Buffer AML NameSeg.
+**/
+VOID
+AmlPrintNameSeg (
+ IN UINT8 *Buffer
+ )
+{
+ TRACE ((-1, "%c", Buffer[0]));
+ if ((Buffer[1] == '_') && (Buffer[2] == '_') && (Buffer[3] == '_')) {
+ return ;
+ }
+ TRACE ((-1, "%c", Buffer[1]));
+ if ((Buffer[2] == '_') && (Buffer[3] == '_')) {
+ return ;
+ }
+ TRACE ((-1, "%c", Buffer[2]));
+ if (Buffer[3] == '_') {
+ return ;
+ }
+ TRACE ((-1, "%c", Buffer[3]));
+ return ;
+}
+
+/**
+ Print AML NameString.
+
+ @param[in] Buffer AML NameString.
+**/
+VOID
+AmlPrintNameString (
+ IN UINT8 *Buffer
+ )
+{
+ UINT8 SegCount;
+ UINT8 Index;
+
+ if (*Buffer == AML_ROOT_CHAR) {
+ //
+ // RootChar
+ //
+ Buffer ++;
+ TRACE ((-1, "\\"));
+ } else if (*Buffer == AML_PARENT_PREFIX_CHAR) {
+ //
+ // ParentPrefixChar
+ //
+ do {
+ Buffer ++;
+ TRACE ((-1, "^"));
+ } while (*Buffer == AML_PARENT_PREFIX_CHAR);
+ }
+
+ if (*Buffer == AML_DUAL_NAME_PREFIX) {
+ //
+ // DualName
+ //
+ Buffer ++;
+ SegCount = 2;
+ } else if (*Buffer == AML_MULTI_NAME_PREFIX) {
+ //
+ // MultiName
+ //
+ Buffer ++;
+ SegCount = *Buffer;
+ Buffer ++;
+ } else if (*Buffer == 0) {
+ //
+ // NULL Name
+ //
+ return ;
+ } else {
+ //
+ // NameSeg
+ //
+ SegCount = 1;
+ }
+
+ AmlPrintNameSeg (Buffer);
+ Buffer += AML_NAME_SEG_SIZE;
+ for (Index = 0; Index < SegCount - 1; Index++) {
+ TRACE ((-1, "."));
+ AmlPrintNameSeg (Buffer);
+ Buffer += AML_NAME_SEG_SIZE;
+ }
+
+ return ;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2011, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Core/EM/ACPI/AtadSmi.c b/Core/EM/ACPI/AtadSmi.c
new file mode 100644
index 0000000..31d57a5
--- /dev/null
+++ b/Core/EM/ACPI/AtadSmi.c
@@ -0,0 +1,254 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/BIN/Modules/ACPI/Template/Core/AtadSmi.c 1 1/23/14 5:47p Oleksiyy $
+//
+// $Revision: 1 $
+//
+// $Date: 1/23/14 5:47p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/AtadSmi.c $
+//
+// 1 1/23/14 5:47p Oleksiyy
+// [TAG] EIP113941
+// [Category] New Feature
+// [Description] Time and Alarm ACPI device implemented.
+// [Files] AtadSmi.cif
+// AtadSmi.sdl
+// AtadSmi.mak
+// AtadSmi.dxs
+// AtadSmi.h
+// AtadSmi.c
+//
+// 6 1/13/10 2:13p Felixp
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: <AtadSmi.c>
+//
+// Description:
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+#include <AmiDxeLib.h>
+#include <AmiSmm.h>
+#include "AtadSmi.h"
+#include <token.h>
+
+#if PI_SPECIFICATION_VERSION<0x0001000A
+ #include <Protocol/SmmSwDispatch.h>
+ #include <Protocol/SmmControl.h>
+#else
+ #include <Protocol/SmmSwDispatch2.h>
+ #include <Protocol/SmmControl2.h>
+ #include <Protocol/SmmCpu.h>
+#endif
+
+
+
+EFI_HANDLE VarSmiHandle = NULL;
+
+VOID *gAtadBuffer = NULL;
+EFI_EVENT EvtAtadSmi;
+VOID *RegAtadSmi;
+UINT32 i=0;
+UINT32 j=0;
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: AtadSmiHandler
+//
+// Description: The SMI handler for Nvram services.
+//
+// Input: NONE
+//
+//
+// Output: EFI_STATUS
+//
+//----------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS AtadSmiHandler ()
+{
+ EFI_STATUS Status = EFI_DEVICE_ERROR;
+ ATAD_VARIABLE *SmmVarBuffer;
+ EFI_GUID gEfiTimeVariableGuid = EFI_TIME_VARIABLE_GUID;
+ TIME_VARIABLE TimeVar;
+ UINTN TimeVarSize = sizeof(TIME_VARIABLE);
+ UINT32 TimeVarFlags = EFI_VARIABLE_NON_VOLATILE |
+ EFI_VARIABLE_BOOTSERVICE_ACCESS |
+ EFI_VARIABLE_RUNTIME_ACCESS;
+ //TRACE((-1,"AtadSmiHandler . 1.\n"));
+ //checkpoint(0x24);
+ if (gAtadBuffer == NULL) return EFI_SUCCESS;
+
+ SmmVarBuffer = (ATAD_VARIABLE*)gAtadBuffer;
+
+
+
+
+ //checkpoint(0x25);
+ switch (SmmVarBuffer->Signature){
+
+ case ATAD_SW_SMI_UPDATE:
+ //TRACE((-1,"AtadSmiHandler . ATAD_SW_SMI_UPDATE.\n"));
+ TimeVar.TimeZone = SmmVarBuffer->TimeZone;
+ TimeVar.Daylight = SmmVarBuffer->DayLight;
+ Status = pRS->SetVariable( L"EfiTime",
+ &gEfiTimeVariableGuid,
+ TimeVarFlags,
+ TimeVarSize,
+ &TimeVar );
+
+ if (!EFI_ERROR(Status)) SmmVarBuffer->Signature = ATAD_SW_SMI_OK;
+ else SmmVarBuffer->Signature = ATAD_SW_SMI_NOT_GOOD;
+ //checkpoint(0x30+i++);
+ break;
+
+ case ATAD_SW_SMI_GET:
+ //TRACE((-1,"AtadSmiHandler . ATAD_SW_SMI_GET.\n"));
+ Status = pRS->GetVariable( L"EfiTime",
+ &gEfiTimeVariableGuid,
+ &TimeVarFlags,
+ &TimeVarSize,
+ &TimeVar );
+ if (!EFI_ERROR(Status))
+ {
+ SmmVarBuffer->TimeZone = TimeVar.TimeZone;
+ SmmVarBuffer->DayLight = TimeVar.Daylight;
+ SmmVarBuffer->Signature = ATAD_SW_SMI_OK;
+ }
+ else SmmVarBuffer->Signature = ATAD_SW_SMI_NOT_GOOD;
+ //checkpoint(0x40+j++);
+ break;
+
+ default:
+ SmmVarBuffer->Signature = ATAD_SW_SMI_NOT_GOOD;
+ }
+ //checkpoint(0x26);
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS AtadSmiHandler2 (
+ IN EFI_HANDLE DispatchHandle,
+ IN CONST VOID *Context OPTIONAL,
+ IN OUT VOID *CommBuffer OPTIONAL,
+ IN OUT UINTN *CommBufferSize OPTIONAL
+)
+
+{
+
+ CONST EFI_SMM_SW_REGISTER_CONTEXT *DispatchContext = Context;
+ //checkpoint(0x22);
+ //TRACE((-1,"AtadSmiHandler2\n"));
+ if ((gAtadBuffer == NULL) || ((UINT8)DispatchContext->SwSmiInputValue != ACPI_TIME_AND_ALARM_SW_SMI))
+ return EFI_DEVICE_ERROR;
+ //TRACE((-1,"AtadSmiHandler22\n"));
+ //checkpoint(0x23);
+ return AtadSmiHandler();
+
+}
+
+EFI_STATUS AtadInSmmFunction(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE Handle = 0;
+
+#if PI_SPECIFICATION_VERSION<0x0001000A
+ EFI_GUID EfiSmmSwDispatchProtocolGuid = EFI_SMM_SW_DISPATCH_PROTOCOL_GUID;
+ EFI_SMM_SW_DISPATCH_PROTOCOL *SwDispatch = NULL;
+ EFI_SMM_SW_DISPATCH_CONTEXT SwContext;
+ Status = pBS->LocateProtocol(
+#else
+ EFI_GUID EfiSmmSwDispatchProtocolGuid = EFI_SMM_SW_DISPATCH2_PROTOCOL_GUID;
+ EFI_SMM_SW_DISPATCH2_PROTOCOL *SwDispatch = NULL;
+ EFI_SMM_SW_REGISTER_CONTEXT SwContext;
+ Status = pSmst->SmmLocateProtocol(
+#endif
+ &EfiSmmSwDispatchProtocolGuid,
+ NULL,
+ &SwDispatch
+ );
+ ASSERT_EFI_ERROR(Status);
+ if (EFI_ERROR(Status))
+ return Status;
+
+ SwContext.SwSmiInputValue = ACPI_TIME_AND_ALARM_SW_SMI;
+ Status = SwDispatch->Register ( SwDispatch,
+ AtadSmiHandler2,
+ &SwContext,
+ &Handle );
+ ASSERT_EFI_ERROR(Status);
+ TRACE((TRACE_ALWAYS,"AtadInitSmmHandler pSwDispatch->Register Status=%r\n",Status));
+ return Status;
+}
+
+
+EFI_STATUS
+AtadSmiEntry(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+)
+{
+
+
+ EFI_STATUS Status;
+ EFI_GUID AtadSmiGuid = ATAD_SMI_GUID;
+ UINTN VariableSize = sizeof(gAtadBuffer);
+
+ InitAmiLib(ImageHandle, SystemTable);
+
+ TRACE((TRACE_ALWAYS,"AtadSmiEntry\n"));
+
+ Status = pRS->GetVariable ( L"AtadSmiBuffer",
+ &AtadSmiGuid,
+ NULL,
+ &VariableSize,
+ &gAtadBuffer );
+ if ((EFI_ERROR(Status)) || (gAtadBuffer == NULL)) return EFI_NOT_FOUND;
+ //TRACE((-1, "AtadSmiEntry2 \n"));
+ Status = InitSmmHandler(
+ ImageHandle,
+ SystemTable,
+ AtadInSmmFunction,
+ NULL
+ );
+ TRACE((TRACE_ALWAYS,"AtadInitSmmHandler Status=%r\n",Status));
+ ASSERT_EFI_ERROR(Status);
+
+ return EFI_SUCCESS;
+}
+
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//********************************************************************** \ No newline at end of file
diff --git a/Core/EM/ACPI/AtadSmi.cif b/Core/EM/ACPI/AtadSmi.cif
new file mode 100644
index 0000000..7708ac1
--- /dev/null
+++ b/Core/EM/ACPI/AtadSmi.cif
@@ -0,0 +1,12 @@
+<component>
+ name = "AtadSmi"
+ category = ModulePart
+ LocalRoot = "Core\EM\ACPI\"
+ RefName = "AtadSmi"
+[files]
+"AtadSmi.sdl"
+"AtadSmi.mak"
+"AtadSmi.dxs"
+"AtadSmi.h"
+"AtadSmi.c"
+<endComponent>
diff --git a/Core/EM/ACPI/AtadSmi.dxs b/Core/EM/ACPI/AtadSmi.dxs
new file mode 100644
index 0000000..a8e9ba3
--- /dev/null
+++ b/Core/EM/ACPI/AtadSmi.dxs
@@ -0,0 +1,98 @@
+//****************************************************************************
+//****************************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone (770)-246-8600 **
+//** **
+//****************************************************************************
+//****************************************************************************
+
+//*****************************************************************************
+// $Header: /Alaska/BIN/Modules/ACPI/Template/Core/AtadSmi.dxs 1 1/23/14 5:47p Oleksiyy $
+//
+// $Revision: 1 $
+//
+// $Date: 1/23/14 5:47p $
+//*****************************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/AtadSmi.dxs $
+//
+// 1 1/23/14 5:47p Oleksiyy
+// [TAG] EIP113941
+// [Category] New Feature
+// [Description] Time and Alarm ACPI device implemented.
+// [Files] AtadSmi.cif
+// AtadSmi.sdl
+// AtadSmi.mak
+// AtadSmi.dxs
+// AtadSmi.h
+// AtadSmi.c
+//
+// 3 1/12/12 9:35a Vyacheslava
+//
+//
+//
+//*****************************************************************************
+//<AMI_FHDR_START>
+//
+// Name: SmmOemActivation.dxs
+//
+// Description: This file is the dependency file for OemActivation module.
+//
+//<AMI_FHDR_END>
+//*****************************************************************************
+
+//---------------------------------------------------------------------------
+// Header files for GUID definitions
+//---------------------------------------------------------------------------
+
+#if PI_SPECIFICATION_VERSION<0x0001000A
+//---------------------------------------------------------------------------
+
+#include <Protocol/SmmBase.h>
+#include <Protocol/SmmSwDispatch.h>
+#include <Protocol/AcpiTable.h>
+
+DEPENDENCY_START
+ EFI_SMM_BASE_PROTOCOL_GUID AND
+ EFI_SMM_SW_DISPATCH_PROTOCOL_GUID AND
+ EFI_ACPI_TABLE_PROTOCOL_GUID
+DEPENDENCY_END
+
+//---------------------------------------------------------------------------
+#else
+//---------------------------------------------------------------------------
+
+#include <Protocol/SmmBase2.h>
+#include <Protocol/SmmSwDispatch2.h>
+#include <Protocol/AcpiTable.h>
+
+DEPENDENCY_START
+ EFI_SMM_BASE2_PROTOCOL_GUID AND
+ EFI_SMM_SW_DISPATCH2_PROTOCOL_GUID AND
+ EFI_ACPI_TABLE_PROTOCOL_GUID
+DEPENDENCY_END
+
+//---------------------------------------------------------------------------
+#endif
+
+
+//****************************************************************************
+//****************************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone (770)-246-8600 **
+//** **
+//****************************************************************************
+//****************************************************************************
diff --git a/Core/EM/ACPI/AtadSmi.h b/Core/EM/ACPI/AtadSmi.h
new file mode 100644
index 0000000..546399a
--- /dev/null
+++ b/Core/EM/ACPI/AtadSmi.h
@@ -0,0 +1,91 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+
+//**********************************************************************
+// $Header: /Alaska/BIN/Modules/ACPI/Template/Core/AtadSmi.h 1 1/23/14 5:47p Oleksiyy $
+//
+// $Revision: 1 $
+//
+// $Date: 1/23/14 5:47p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/AtadSmi.h $
+//
+// 1 1/23/14 5:47p Oleksiyy
+// [TAG] EIP113941
+// [Category] New Feature
+// [Description] Time and Alarm ACPI device implemented.
+// [Files] AtadSmi.cif
+// AtadSmi.sdl
+// AtadSmi.mak
+// AtadSmi.dxs
+// AtadSmi.h
+// AtadSmi.c
+//
+// 6 1/13/10 2:13p Felixp
+//
+//**********************************************************************
+//<AMI_FHDR_START>
+//
+// Name: <Atad.h>
+//
+// Description:
+//
+//<AMI_FHDR_END>
+//**********************************************************************
+
+//---------------------------------------------------------------------------
+
+#define ATAD_SW_SMI_UPDATE 2
+#define ATAD_SW_SMI_GET 1
+#define ATAD_SW_SMI_OK 3
+#define ATAD_SW_SMI_NOT_GOOD 0xA5
+
+
+#define ATAD_SMI_GUID \
+{0x6F431B9F, 0x57E2, 0x1049, 0x5A, 0x3B, 0x69, 0x50, 0x4A, 0xED, 0x4F, 0x57}
+#define EFI_TIME_VARIABLE_GUID \
+{0x9d0da369, 0x540b, 0x46f8, 0x85, 0xa0, 0x2b, 0x5f, 0x2c, 0x30, 0x1e, 0x15}
+
+#pragma pack(push, 1)
+typedef struct {
+ INT16 TimeZone;
+ UINT8 Daylight;
+ } TIME_VARIABLE;
+
+
+typedef struct
+{
+ UINT8 Signature;
+ UINT8 DayLight;
+ UINT16 TimeZone;
+
+} ATAD_VARIABLE;
+
+#pragma pack(pop)
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//********************************************************************** \ No newline at end of file
diff --git a/Core/EM/ACPI/AtadSmi.mak b/Core/EM/ACPI/AtadSmi.mak
new file mode 100644
index 0000000..0117e76
--- /dev/null
+++ b/Core/EM/ACPI/AtadSmi.mak
@@ -0,0 +1,82 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2013, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/BIN/Modules/ACPI/Template/Core/AtadSmi.mak 1 1/23/14 5:47p Oleksiyy $
+#
+# $Revision: 1 $
+#
+# $Date: 1/23/14 5:47p $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/BIN/Modules/ACPI/Template/Core/AtadSmi.mak $
+#
+# 1 1/23/14 5:47p Oleksiyy
+# [TAG] EIP113941
+# [Category] New Feature
+# [Description] Time and Alarm ACPI device implemented.
+# [Files] AtadSmi.cif
+# AtadSmi.sdl
+# AtadSmi.mak
+# AtadSmi.dxs
+# AtadSmi.h
+# AtadSmi.c
+#
+# 6 1/13/10 2:13p Felixp
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: <ComponentName>.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+all: AtadSmi
+
+AtadSmi: $(BUILD_DIR)\AtadSmi.mak AtadSmiBin
+
+$(BUILD_DIR)\AtadSmi.mak : $(AtadSmi_DIR)\$(@B).cif $(AtadSmi_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(AtadSmi_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+AtadSmiBin : $(AMIDXELIB)
+ $(MAKE) /$(MAKEFLAGS) $(BUILD_DEFAULTS)\
+ /f $(BUILD_DIR)\AtadSmi.mak all\
+ GUID=88F34ACA-3A7B-FF3C-D401-16A3B6834F2A\
+ ENTRY_POINT=AtadSmiEntry\
+!IF $(PI_SPECIFICATION_VERSION)<0x00001000A
+ TYPE=BS_DRIVER\
+!ELSE
+ TYPE=SMM_DRIVER\
+!ENDIF
+ DEPEX1=$(AtadSmi_DIR)\AtadSmi.dxs\
+ DEPEX1_TYPE=EFI_SECTION_SMM_DEPEX\
+ "EXT_HEADERS=$(BUILD_DIR)\Token.h"\
+ COMPRESS=1
+
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2013, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/Core/EM/ACPI/AtadSmi.sdl b/Core/EM/ACPI/AtadSmi.sdl
new file mode 100644
index 0000000..0c7c2f4
--- /dev/null
+++ b/Core/EM/ACPI/AtadSmi.sdl
@@ -0,0 +1,25 @@
+TOKEN
+ Name = AtadSmi_SUPPORT
+ Value = 1
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+ Help = "Main switch to enable AtadSmi support in Project"
+ Token = "ATAD_SUPPORT" "=" "1"
+End
+
+PATH
+ Name = "AtadSmi_DIR"
+End
+
+MODULE
+ Help = "Includes AtadSmi.mak to Project"
+ File = "AtadSmi.mak"
+End
+
+ELINK
+ Name = "$(BUILD_DIR)\AtadSmi.ffs"
+ Parent = "FV_MAIN"
+ InvokeOrder = AfterParent
+End \ No newline at end of file
diff --git a/Core/EM/ACPI/CIR.ASL b/Core/EM/ACPI/CIR.ASL
new file mode 100644
index 0000000..6b83461
--- /dev/null
+++ b/Core/EM/ACPI/CIR.ASL
@@ -0,0 +1,168 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/CIR.ASL 4 3/26/09 4:53p Oleksiyy $
+//
+// $Revision: 4 $
+//
+// $Date: 3/26/09 4:53p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/CIR.ASL $
+//
+// 4 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 3 4/19/06 1:37p Stacyh
+//
+// 2 4/03/06 4:05p Felixp
+// New Super I/O infrastructure Support
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:42p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 1 03/04/07 5:48p Chung
+// Add ASL core for new all I/O beta version
+//
+// 4 9/06/02 10:53a Alexp
+// Add SourceSafe headers to all core asl files
+//
+//**********************************************************************;
+// Standalone InfraRed device //
+//**********************************************************************;
+// Category # :0x10 (Generic IO range 1)
+Device(CIR){
+ Name(_HID, EISAID("PNP0510")) //PnP Device ID IrDA
+ Method(_STA, 0) {Return(IRST(0x10))} //Get status
+ Method(_DIS, 0) {DCNT(0x10, 0)} //Disable
+ Method(_CRS, 0) {Return(IRCR(0x10))} //Get CIR current resources
+ Method(_SRS, 1) {IRSR(Arg0, 0x10)} //Set CIR recources
+// Method(_PRS, 0) {Return(IRPR)} //Return possible resources
+
+//-----------------------------------------------------------------------
+// IRST - GET SIO DEVICE STATUS according to ACTR/IOAH/IOAL
+//
+// Input - Arg0 : Device's category #
+// Return- Device Status Byte
+//-----------------------------------------------------------------------
+ Method(IRST, 1){
+ ENFG(CGLD(Arg0)) //Enter Config Mode, Select LDN
+ If(ACTR)
+ {Store(0x0F, Local0)} //Present & Active
+ Else{
+ If(IOAH)
+ {Store(0x0D, Local0)} //Then present & not active
+ Else
+ {Store(0, Local0)} //Not present
+ }
+ EXFG() //Exit Config Mode
+ Return(Local0) //Return device status
+ } // End Of IRST
+
+//-----------------------------------------------------------------------
+// IrDa Possible Resources
+//-----------------------------------------------------------------------
+//NOTE: _PRS MUST be the NAME not a METHOD object
+//to have GENERICSIO.C working right!
+//-----------------------------------------------------------------------
+ Name(_PRS, ResourceTemplate(){
+ StartDependentFn(0, 0){
+ IO(Decode16, 0x3E0, 0x3E0, 8, 8)
+ IRQNoFlags() {10}
+ }
+ StartDependentFnNoPri(){
+ IO(Decode16, 0x3E0, 0x3E0, 8, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ }
+ StartDependentFnNoPri(){
+ IO(Decode16, 0x2E0, 0x2E0, 8, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ }
+ StartDependentFnNoPri(){
+ IO(Decode16, 0x298, 0x298, 8, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ }
+ EndDependentFn()
+ })
+
+//-----------------------------------------------------------------------
+// IRCR - Returns Byte stream of Current resources. May contain Resources such:
+//
+// Input - Arg0 : Device's category #
+// Return- Buffer
+//-----------------------------------------------------------------------
+ Name(PBUF, ResourceTemplate() {
+ IO(Decode16, 0, 0, 1, 8, PBP1)
+ IRQNoFlags(PBI1) {0}
+ })
+
+ Method(IRCR, 1){
+ // Arg0 - LDN
+ CreateByteField(PBUF, 0x02, IOLO) //Range Min Base LSB
+ CreateByteField(PBUF, 0x03, IOHI) //Range Min Base MSB
+ CreateWordField(PBUF, 0x02, IOHL) //Range Min Base Word
+ CreateWordField(PBUF, 0x04, IORL) //Range Max Base Word
+ CreateByteField(PBUF, 0x06, ALMN) //Alignment
+ CreateByteField(PBUF, 0x07, LENG) //Number of IO ports
+ CreateWordField(PBUF, 0x09, IRQL) //IRQ Mask
+
+ ENFG(CGLD(Arg0)) //Enter Config Mode, Select LDN
+
+ // Write Current Settings into Buffer for IO Descriptor
+ Store(IOAH, IOHI) //Get IO Base MSB
+ Store(IOAL, IOLO) //Get IO Base LSB
+ Store(IOHL, IORL) //Set MaxBase = MinBase
+ Store(0x01, ALMN) //Set alignment
+ Store(0x08, LENG) //Set IO length
+
+ // Write Current Settings into IRQ descriptor
+ Store(One, Local0)
+ ShiftLeft(Local0, INTR, IRQL)
+
+ EXFG() //Exit Config Mode
+ Return(PBUF) //Return Byte Stream
+ }
+
+//-----------------------------------------------------------------------
+// IRSR - Configures new Resources to be decoded by a Device
+//
+// Input - Arg0 : PnP Resource String to set
+// Arg1 : Device's category #
+// Return- nothing
+//-----------------------------------------------------------------------
+ Method(IRSR, 2){
+ CreateByteField (Arg0, 0x02, POLB) //Range Min Base LSB
+ CreateByteField (Arg0, 0x03, POHB) //Range Min Base MSB
+ CreateWordField (Arg0, 0x09, PIRQ) //IRQ number
+
+ ENFG(CGLD(Arg1)) //Enter Config Mode, Select LDN
+
+ // Set Base IO Address
+ Store(POLB, IOAL) //Set IO Base LSB
+ Store(POHB, IOAH) //Set IO Base MSB
+
+ // Set IRQ
+ FindSetRightBit(PIRQ, Local0)
+ Subtract(Local0, 1, INTR)
+
+ Store(One, ACTR) //Activate
+ EXFG() //Exit Config Mode
+ }
+
+} // End Of IRDA //
diff --git a/Core/EM/ACPI/Fdc.asl b/Core/EM/ACPI/Fdc.asl
new file mode 100644
index 0000000..e53e9e4
--- /dev/null
+++ b/Core/EM/ACPI/Fdc.asl
@@ -0,0 +1,150 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Fdc.asl 4 6/12/12 12:13p Oleksiyy $
+//
+// $Revision: 4 $
+//
+// $Date: 6/12/12 12:13p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/Fdc.asl $
+//
+// 4 6/12/12 12:13p Oleksiyy
+// [TAG] EIP89379
+// [Category] Improvement
+// [Description] Added token for support to changing iasl compiler.
+// [Files] ACPI.sdl, Fdc.asl and AmiBoardinfo.mak
+//
+// 3 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 2 4/03/06 4:05p Felixp
+// New Super I/O infrastructure Support
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:42p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 9 03/04/07 5:39p Chung
+// Modify all I/O beta version
+//
+// 4 9/06/02 10:53a Alexp
+// Add SourceSafe headers to all core asl files
+//
+//
+//**********************************************************************;
+// Floppy Disk Controller - FDC //
+//**********************************************************************;
+// Category # :0x03
+Device(FDC) {
+ Name(_HID, EISAID("PNP0700")) //PnP Device ID
+// _FDE : 5 Dword Package (1-4 are for each FDD present, #5 is for optional tape drive)
+// 0 - Device is not present
+// 1 - Device is Present
+// 2 - Device is never Present
+// >2- Reserved
+// Tape drive is never present
+ Name(_FDE, BUFFER(){1,0,2,2,2}) //_FDE - Floppy Disk Enumerate
+
+ Method(_STA, 0) {Return(^^SIO1.DSTA(3))} //Get status
+
+ Method(_DIS, 0) {^^SIO1.DCNT(3, 0)} //Disable FDC
+
+ Method(_CRS, 0) { //Return FDC Current Resources
+ ^^SIO1.DCRS(3, 1) //Fill in Return buffer with DMA, Irq and 1st IO
+ //Move resources from CRS1 ro CRS2 buffer
+ Store(^^SIO1.IRQM, ^^SIO1.IRQE) //IRQ mask 0x1
+ Store(^^SIO1.DMAM, ^^SIO1.DMAE) //DMA 0x04
+ Store(^^SIO1.IO11, ^^SIO1.IO21) //1st IO Range Min Base Word 0x8
+ Store(^^SIO1.IO12, ^^SIO1.IO22) // Max Base Word 0xa
+ Store(6, ^^SIO1.LEN2)
+
+ Add(^^SIO1.IO21, 0x07, ^^SIO1.IO31) //2nd IO range
+ Store(^^SIO1.IO31, ^^SIO1.IO32)
+ Store(1, ^^SIO1.LEN3)
+ Return(^^SIO1.CRS2)
+ }
+
+//------------------------------------------------------------------------
+//NOTE: _PRS MUST be the NAME not a METHOD object
+//to have GENERICSIO.C working right!
+//-----------------------------------------------------------------------
+ Name(_PRS, ResourceTemplate() { //FDC Possible Resources
+ StartDependentFn(0, 0) {
+ IO(Decode16, 0x3F0, 0x3F0, 1, 6)
+ IO(Decode16, 0x3F7, 0x3F7, 1, 1)//0x3F6 port reserved for Legacy IDE
+ IRQNoFlags() {6}
+ DMA(Compatibility, NotBusMaster, Transfer8) {2}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3F0, 0x3F0, 1, 6)
+ IO(Decode16, 0x3F7, 0x3F7, 1, 1)//0x3F6 port reserved for Legacy IDE
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {2,3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x370, 0x370, 1, 6)
+ IO(Decode16, 0x377, 0x377, 1, 1)//0x376 port reserved for Legacy IDE
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {2,3}
+ }
+ EndDependentFn()
+ })
+
+ Method(_SRS, 1) { //Set resources/Enable FDC
+ ^^SIO1.DSRS(Arg0, 3)
+
+ CreateWordField(Arg0, ^^SIO1.IRQ2._INT, IRQE) //IRQ mask 0x1
+ CreateByteField(Arg0, ^^SIO1.DMA2._DMA, DMAE) //DMA 0x4
+
+ ^^SIO1.ENFG(^^SIO1.CGLD(3)) //Enter Config Mode, Select LDN
+// Set IRQ
+ If(IRQE){
+ FindSetRightBit(IRQE, Local0)
+ Subtract(Local0, 1, ^^SIO1.INTR)
+ }Else{
+ Store(0, ^^SIO1.INTR) // No IRQ used
+ }
+// Set DMA
+ If(DMAE){
+ FindSetRightBit(DMAE, Local0)
+ Subtract(Local0, 1, ^^SIO1.DMCH)
+ }Else{
+ Store(4, ^^SIO1.DMCH)// No DMA
+ }
+ ^^SIO1.EXFG() //Exit Config Mode
+ }
+
+
+//---------Power Resources for FDD -------------------------
+/*
+ PowerResource(FDDP, 0, 0) { // SystemLevel Parameter=0,
+ Method(_STA, 0) {
+ Return(FDCP) // Get Power Status
+ } // end of _STA
+ Method(_ON) {
+ Store(1, FDCP) // Power on
+ } // end of _ON
+ Method(_OFF){
+ Store(0, FDCP) // Power off
+ } // end of _OFF
+ }
+ Name(_PR0, Package(){FDDP}) // Reference to PowerResources
+*/
+} // End Of FDC0 ////////////////////////////////////////////////////////
diff --git a/Core/EM/ACPI/GameMpu.asl b/Core/EM/ACPI/GameMpu.asl
new file mode 100644
index 0000000..7364e8c
--- /dev/null
+++ b/Core/EM/ACPI/GameMpu.asl
@@ -0,0 +1,185 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/GameMpu.asl 3 3/26/09 4:53p Oleksiyy $
+//
+// $Revision: 3 $
+//
+// $Date: 3/26/09 4:53p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/GameMpu.asl $
+//
+// 3 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 2 4/03/06 4:05p Felixp
+// New Super I/O infrastructure Support
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:42p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 4 03/04/07 5:40p Chung
+// Modify all I/O beta version
+//
+// 3 9/06/02 10:53a Alexp
+// Add SourceSafe headers to all core asl files
+//
+//
+//**********************************************************************;
+// Combined Game & Midi Logical Device
+//**********************************************************************;
+// Generic Game Port
+//-----------------------------------------------------------------------
+// Category # :0x08
+Device(GAME){
+ Name(_HID, EISAID("PNPB02F")) //PnP ID for GamePort
+ Method(_STA, 0) {Return(DSTA(8))} //Get status
+// Method(_DIS, 0) {DCNT(8,0)} //Disable
+//-----------------------------------------------------------------------
+// GamePort Current Resource template (to be returned by _CRS)
+//-----------------------------------------------------------------------
+ Name(GMCR, ResourceTemplate(){
+ IO(Decode16, 0x201, 0x201, 1, 8, GMIO)
+ })
+
+ Method(_CRS, 0){
+ CreateByteField(GMCR, 0x02, IOLO) //Range Min Base LSB
+ CreateByteField(GMCR, 0x03, IOHI) //Range Min Base MSB
+ CreateWordField(GMCR, 0x02, IOHL) //Range Min Base Word
+ CreateWordField(GMCR, 0x04, IORL) //Range Max Base Word
+
+ ENFG(CGLD(8)) //Enter Config Mode, Select LDN
+
+// Write Current Settings into Buffer for IO Descriptor
+ Store(IOAH, IOHI) //Get IO Base MSB
+ Store(IOAL, IOLO) //Get IO Base LSB
+ Store(IOHL, IORL) //Set MaxBase = MinBase
+
+ EXFG() //Exit Config Mode
+ Return(GMCR) //Return Byte Stream
+ }
+
+ Method(_SRS, 1){
+ CreateByteField (Arg0, 0x02, POLB) // Range Min Base LSB
+ CreateByteField (Arg0, 0x03, POHB) // Range Min Base MSB
+
+ ENFG(CGLD(8)) // Enter Config Mode, Select LDN
+
+// Set Base IO Address
+ Store(POLB, IOAL) // Set IO Base LSB
+ Store(POHB, IOAH) // Set IO Base MSB
+// Enable ACTR
+ DCNT(8, 1) // Enable Device (Routing)
+ EXFG() // Exit Config Mode
+ }
+//-----------------------------------------------------------------------
+// GamePort Possible Resources (returned by _PRS)
+//-----------------------------------------------------------------------
+//NOTE: _PRS MUST be the NAME not a METHOD object
+//to have GENERICSIO.C working right!
+//-----------------------------------------------------------------------
+ Name(_PRS, ResourceTemplate(){
+ StartDependentFn(0,0) {
+ IO(Decode16, 0x201, 0x201, 1, 8)
+ }
+ StartDependentFnNoPri(){
+ IO(Decode16, 0x209, 0x209, 1, 8)
+ }
+ EndDependentFn()
+ })
+}
+// End Of GamePort //////////////////////////////////////////////////////
+// Win627 specific Combined Game & Midi Logical Device
+// IO ports are defined at offset 0x62, 0x63 of LDN configuratsion space
+//**********************************************************************;
+// Generic MPU 401 Device
+//**********************************************************************;
+// Category # :0x05
+Device(MIDI){
+ Name(_HID, EISAID("PNPB006")) //PnP ID for GamePort
+ Method(_STA, 0) {Return(DSTA(5))} //Get status
+// Method(_DIS, 0) {DCNT(5,0)} //Disable
+//-----------------------------------------------------------------------
+// MIDIPort Current Resources template (returned by _CRS)
+//-----------------------------------------------------------------------
+ Name(MDCR, ResourceTemplate(){
+ IO(Decode16, 0x300, 0x300, 1, 2, MDIO)
+ IRQNoFlags(MBI1) {5}
+ })
+
+ Method(_CRS, 0){
+ CreateByteField(MDCR, 0x02, IOLO) //Range Min Base LSB
+ CreateByteField(MDCR, 0x03, IOHI) //Range Min Base MSB
+ CreateWordField(MDCR, 0x02, IOHL) //Range Min Base Word
+ CreateWordField(MDCR, 0x04, IORL) //Range Max Base Word
+ CreateWordField(MDCR, 0x09, MIRQ) //IRQ Mask (word)
+
+ ENFG(CGLD(5)) //Enter Config Mode, Select LDN
+
+// Write Current Settings into Buffer for IO Descriptor
+ Store(IOH2, IOHI) //Get IO Base MSB
+ Store(IOL2, IOLO) //Get IO Base LSB
+ Store(IOHL, IORL) //Set MaxBase = MinBase
+// Write Current Settings into IRQ descriptor
+ ShiftLeft(1, INTR, MIRQ)
+
+ EXFG() //Exit Config Mode
+ Return(MDCR) //Return Byte Stream
+ }
+
+ Method(_SRS, 1){
+// Arg0 - PnP Resource String to set
+ CreateByteField (Arg0, 0x02, POLB) //Range Min Base LSB
+ CreateByteField (Arg0, 0x03, POHB) //Range Min Base MSB
+ CreateWordField (Arg0, 0x09, MIRQ) //IRQ mask (word)
+
+ ENFG(CGLD(5)) //Enter Config Mode, Select LDN
+
+// Set Base IO Address
+ Store(POLB, IOL2) //Set IO Base LSB
+ Store(POHB, IOH2) //Set IO Base MSB
+
+// Set IRQ
+ FindSetRightBit(MIRQ, Local0)
+ Subtract(Local0, 1, INTR)
+
+ DCNT(5, 1) //Enable Device (Routing)
+ EXFG() //Exit Config Mode
+ }
+
+//-----------------------------------------------------------------------
+// MIDIPort Possible Resources (returned by _PRS)
+//------------------------------------------------------------------------
+//NOTE: _PRS MUST be the NAME not a METHOD object
+//to have GENERICSIO.C working right!
+//-----------------------------------------------------------------------
+ Name(_PRS, ResourceTemplate(){
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x300, 0x300, 1, 2)
+ IRQNoFlags() {5,7,9,10,11}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x330, 0x330, 1, 2)
+ IRQNoFlags() {5,7,9,10,11}
+ }
+ EndDependentFn()
+ })
+}
+// End Of Midi //////////////////////////////////////////////////////////
diff --git a/Core/EM/ACPI/LM75.ASL b/Core/EM/ACPI/LM75.ASL
new file mode 100644
index 0000000..afffa64
--- /dev/null
+++ b/Core/EM/ACPI/LM75.ASL
@@ -0,0 +1,179 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/LM75.ASL 2 3/26/09 4:53p Oleksiyy $
+//
+// $Revision: 2 $
+//
+// $Date: 3/26/09 4:53p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/LM75.ASL $
+//
+// 2 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:42p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 2 9/06/02 10:53a Alexp
+// Add SourceSafe headers to all core asl files
+//
+//
+//;**********************************************************************;
+//**********************************************************************;
+// ASL interface to LM75 thermal sensor over SMBus
+//**********************************************************************;
+
+// change LM75 trip points
+ Method(TCHG, 0) {
+
+ Store(RBYT(TSAD, 0x00), Local0) // Read Current temp
+/*
+If(LGreaterEqual(Local0,TMAX)) {
+ Store(TCRT, Local1) // Tcrt
+ }
+ Else {
+ If(LGreaterEqual(Local0,TMIN)) {
+ Store(TMAX, Local1) // Thigh
+ }
+ Else {
+ Store(TMIN, Local1) // TLow
+ }
+ }
+ STOS(0,Local1) // Set Thigh
+
+ STHY(0, Add(Local0, 2)) // Set TLow T + 2.0C to arm the Thermal int
+
+// Subtract(TMIN, 5, Local2) // Set Thyst as TMIN-5.0
+
+// Add(Local0, 0x5, Local1) // Set Thigh T + 5.0 C
+ Subtract(Local0, 0x1, Local2) // Set Tlow T - 1.0 C
+ Subtract(TMIN, 0x5, Local3) // Set Tlow TMIN - 5.0 C
+// If(LGreater(Local2,Local3))
+// {
+// Store(Local3, Local2)
+// }
+
+ STHY(0,Local2) // Set TLow
+*/
+ STOS(TCRT) // Set Thigh TCRT
+ STHY(Subtract(Local0, 5)) // Set TLow TMIN-5.0C
+
+ Notify(\_TZ.THRM, 0x81) // Notify of trip point change
+ }
+
+// Set configuration register
+Method(SCFG, 1) {
+ // Arg0 = configuration byte
+
+ WBYT(TSAD, 0x01, Arg0)
+ }
+
+// Set Tos register
+
+Method(STOS, 1) {
+ // Arg0 = temperature word data
+
+ // Set pointer register (occupy the command byte) to 0x03
+ // Somehow LM75 wants to send out the MSB byte first !
+
+ WWRD(TSAD, 0x03, Arg0)
+ }
+
+// Set Thyst register
+
+Method(STHY, 1) {
+ // Arg0 = temperature word data
+
+ // Set pointer register (occupy the command byte) to 0x02
+ // Somehow LM75 wants to send out the MSB byte first !
+
+ WWRD(TSAD, 0x02, Arg0)
+ }
+
+// Read temperature register
+
+Method(RTMP, 0) {
+ // Set pointer register (occupy the command byte) to 0x00
+
+ Store(RWRD(TSAD, 0x00), Local0)
+
+Store(Local0, DBG8)
+
+ // Somehow LM75 returns right byte first!
+
+ If(Not(Local0)) // Read command completed
+ {
+ Return( Local0 )
+ }
+ Else // Read command failed
+ {
+ Store("_TMP Read ERROR", Debug)
+ Return(Add(TMIN, 2)) // MIN trip point + 2.0 C
+ }
+
+ } // Method(RTMP)
+
+// LM75 Thermal interrupt handler
+Method(THDL,0) {
+//**********************************************************************;
+// Trip point handler
+// TPOL status bit applys for PIIX4 based design only
+// PMBS is an ACPI I/O Base address
+// PM controller IO space
+ OperationRegion(PMRG, SystemIO, PMBS, 0x40)
+ Field(PMRG,ByteAcc,NoLock,Preserve)
+ {
+ Offset(0x28),
+ ,2,
+ TPOL,1, // 28.2h Thermal Polarity bit
+ }
+
+ If(TPOL)
+// Temp goes up, Tos threshold being crossed
+ {
+ \GFAN._ON() // Turn FAN On
+ }
+ Else
+// Temp goes down, Thyst threshold being crossed
+ {
+ \GFAN._OFF() // Turn FAN Off
+ }
+
+ TCHG() // Reevaluate Thigh/TLow for LM75
+ Not(TPOL,TPOL) // Toggle the Polarity pin
+}
+//**********************************************************************;
+// *****************************************************************;
+// *****************************************************************;
+// ** **;
+// ** (C)Copyright 1985-1996, American Megatrends, Inc. **;
+// ** **;
+// ** All Rights Reserved. **;
+// ** **;
+// ** 6145-F Northbelt Pkwy, Norcross, GA 30071 **;
+// ** **;
+// ** Phone (770)-246-8600 **;
+// ** **;
+// *****************************************************************;
+// *****************************************************************;
+//**********************************************************************;
+// DON'T CHANGE ANY CODE UNLESS REQUIRED !!!
+//**********************************************************************;
diff --git a/Core/EM/ACPI/Lpte.asl b/Core/EM/ACPI/Lpte.asl
new file mode 100644
index 0000000..164c9a1
--- /dev/null
+++ b/Core/EM/ACPI/Lpte.asl
@@ -0,0 +1,199 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Lpte.asl 3 3/26/09 4:53p Oleksiyy $
+//
+// $Revision: 3 $
+//
+// $Date: 3/26/09 4:53p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/Lpte.asl $
+//
+// 3 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 2 4/03/06 4:05p Felixp
+// New Super I/O infrastructure Support
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:42p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 7 03/04/07 5:41p Chung
+// Modify all I/O beta version
+//
+// 4 9/06/02 10:53a Alexp
+// Add SourceSafe headers to all core asl files
+//
+//**********************************************************************;
+// Parallel port - LPT or ECP(Extended mode)/////////////////////////////
+//**********************************************************************;
+// Category # :0x02
+Device(LPTE) {
+ Method(_HID, 0){ //PnP Device ID
+ If(^^SIO1.LPTM(2)) //Get LPT mode : 0-plain LPT, non Zero-ECP mode
+ {Return(EISAID("PNP0401"))} //PnP ID for ECP Port
+ Else
+ {Return(EISAID("PNP0400"))} //PnP ID for LPT Port
+ }
+
+ Method(_STA, 0) {Return(^^SIO1.DSTA(2))} //Get Device status
+
+ Method(_DIS, 0) {^^SIO1.DCNT(2,0)} //Disable LPT, arg0 - LDN, arg1 - 1(disable)
+
+ Method(_CRS, 0) { //Get LPT current resources
+ ^^SIO1.DCRS(2, 1) //Fill in Return buffer with DMA, Irq and 1st IO
+ If(^^SIO1.LPTM(2)){ //Extended LPT mode ?
+ //Move resources from CRS1 ro CRS2 buffer
+ Store(^^SIO1.IRQM, ^^SIO1.IRQE) //IRQ mask 0x1
+ Store(^^SIO1.DMAM, ^^SIO1.DMAE) //DMA 0x04
+
+ Store(^^SIO1.IO11, ^^SIO1.IO21) //1st IO Range Min Base Word 0x8
+ Store(^^SIO1.IO12, ^^SIO1.IO22) // Max Base Word 0xa
+ Store(^^SIO1.LEN1, ^^SIO1.LEN2)
+
+ Add(^^SIO1.IO21, 0x400, ^^SIO1.IO31) //2nd IO range
+ Store(^^SIO1.IO31, ^^SIO1.IO32)
+ Store(^^SIO1.LEN2, ^^SIO1.LEN3)
+ Return(^^SIO1.CRS2)
+ }else{
+ Return(^^SIO1.CRS1)
+ }
+ }
+
+ Method(_SRS, 1) { //Set LPT resources
+ ^^SIO1.DSRS(Arg0, 2)
+ }
+
+ Method(_PRS, 0) { //Return Possible resources
+ If(^^SIO1.LPTM(2)) //Get LPT mode : 0-plain LPT, non Zero-ECP mode
+ {Return(EPPR)} //ECP mode resources
+ Else
+ {Return(LPPR)} //LPT mode resources
+ }
+
+
+//-----------------------------------------------------------------------
+// LPT Possible Resources
+//-----------------------------------------------------------------------
+//------------------------------------------------------------------------
+//NOTE: _PRS MUST be the NAME not a METHOD object
+//to have GENERICSIO.C working right!
+//-----------------------------------------------------------------------
+ Name(LPPR, ResourceTemplate(){
+// IRQ
+ StartDependentFn(0,0) {
+ IO(Decode16, 0x378, 0x378, 1, 8)
+ IRQNoFlags() {5}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x378, 0x378, 1, 8)
+ IRQNoFlags() {5,6,7,10,11,12}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x278, 0x278, 1, 8)
+ IRQNoFlags() {5,6,7,10,11,12}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3BC, 0x3BC, 1, 4)
+ IRQNoFlags() {5,6,7,10,11,12}
+ }
+// No IRQ
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x378, 0x378, 1, 8)
+ IRQNoFlags() {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x278, 0x278, 1, 8)
+ IRQNoFlags() {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3BC, 0x3BC, 1, 4)
+ IRQNoFlags() {}
+ }
+ EndDependentFn()
+ })
+
+//-----------------------------------------------------------------------
+// ECP Possible Resources
+//-----------------------------------------------------------------------
+ Name(EPPR, ResourceTemplate() {
+ StartDependentFn(0, 0) {
+ IO(Decode16, 0x378, 0x378, 1, 8)
+ IO(Decode16, 0x778, 0x778, 1, 8)
+ IRQNoFlags() {5}
+ DMA(Compatibility, NotBusMaster, Transfer8) {3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x378, 0x378, 1, 8)
+ IO(Decode16, 0x778, 0x778, 1, 8)
+ IRQNoFlags() {5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {1,3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x278, 0x278, 1, 8)
+ IO(Decode16, 0x678, 0x678, 1, 8)
+ IRQNoFlags() {5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {1,3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3BC, 0x3BC, 1, 4)
+ IO(Decode16, 0x7BC, 0x7BC, 1, 4)
+ IRQNoFlags() {5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {1,3}
+ }
+// No IRQ
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x378, 0x378, 1, 8)
+ IO(Decode16, 0x778, 0x778, 1, 8)
+ IRQNoFlags() {}
+ DMA(Compatibility, NotBusMaster, Transfer8) {1,3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x278, 0x278, 1, 8)
+ IO(Decode16, 0x678, 0x678, 1, 8)
+ IRQNoFlags() {}
+ DMA(Compatibility, NotBusMaster, Transfer8) {1,3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3BC, 0x3BC, 1, 4)
+ IO(Decode16, 0x7BC, 0x7BC, 1, 4)
+ IRQNoFlags() {}
+ DMA(Compatibility, NotBusMaster, Transfer8) {1,3}
+ }
+ EndDependentFn()
+ })
+
+/*
+//---------Power Resources for LPT -------------------------
+ PowerResource(LPTP, 0, 0) { // SystemLevel Parameter=0,
+ Method(_STA, 0) {
+ Return(LPTP) // Get Power Status
+ } // end of _STA
+ Method(_ON) {
+ Store(1,LPTP)
+ } // end of _ON
+ Method(_OFF){
+ Store(0,LPTP)
+ } // end of _OFF
+ }
+ Name(_PR0, Package(){LPTP}) // Reference to PowerResources
+*/
+//**********************************************************************;
+} // End Of LPTE ////////////////////////////////////////////////////////
diff --git a/Core/EM/ACPI/MAX1617L.ASL b/Core/EM/ACPI/MAX1617L.ASL
new file mode 100644
index 0000000..193e19c
--- /dev/null
+++ b/Core/EM/ACPI/MAX1617L.ASL
@@ -0,0 +1,219 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/MAX1617L.ASL 2 3/26/09 4:53p Oleksiyy $
+//
+// $Revision: 2 $
+//
+// $Date: 3/26/09 4:53p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/MAX1617L.ASL $
+//
+// 2 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:42p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 2 9/06/02 10:53a Alexp
+// Add SourceSafe headers to all core asl files
+//
+//
+//;**********************************************************************;
+//**********************************************************************;
+// ASL interface to MAX1617 thermal sensor over SMBus
+// Local sensor
+//**********************************************************************;
+// change max1617 trip point
+ Method(TCHG, 0) {
+
+ Store(RBYT(TSAD, 0x00), Local0) // Read local Current temp
+
+ Add(Local0, 0x1, Local1) // Set Thigh T + 1.0 C
+ Subtract(Local0, 0x1, Local2) // Set Tlow T - 1.0 C
+
+ STOS(Local1) // Set Thigh
+ STHY(Local2) // Set Tlow
+// STOS(0x7f) // Set Thigh
+// STHY(0xbf) // Set Tlow
+ RBYT(TSAD, 0x02) // Read status byte after limit changes
+ // Clears ALARM bit
+/*
+ Store(RBYT(TSAD, 0x07), Local0) // remote high limit
+ Store(RBYT(TSAD, 0x08), Local1) // remote low limit
+ Store(RBYT(TSAD, 0x01), Local2) // remote current temp
+ RBYT(TSAD, 0x02) // Read status byte
+ if( LGreaterEqual(Local2,Local0) ) {
+ // High limit alert
+ if( LEqual(Local0, TMIN) ) {
+ // Set TMAX to high limit & TMIN-2 to low limit
+ STOS(TMAX) // Set Thigh to TMAX
+ Subtract(TMIN, 2, Local3)
+ STHY(Local3) // Set Tlow to TMIN-2
+ }
+ else {
+ if( LEqual(Local0, TMAX) ) {
+ // Set TCRT to high limit & TMAX-2 to low limit
+ STOS(TCRT) // Set Thigh to TCRT
+ Subtract(TMAX, 2, Local3)
+ STHY(Local3) // Set Tlow to TMAX-2
+ }
+ else {
+ if( LEqual(Local0, TCRT) ) {
+ // Notify OS to shutdown
+ // Set Extreeme high to high limit & TCRT-2 to low limit
+ STOS(0x7f) // Set Thigh to extreeme high (127C)
+ Subtract(TCRT, 2, Local3)
+ STHY(Local3) // Set Tlow to TCRT-2
+ }
+// else {
+// // This from init. set TMIN to high & Extreeme to low limit
+// STOS(TMIN) // Set Thigh to TMIN
+// STHY(0xc9) // Set Tlow to extreeme low (-55C)
+// }
+ }
+ }
+ }
+ else {
+ if( LLessEqual(Local2, Local1) ) {
+ // Low limit alert
+ if( LLess(Local1, TMIN) ) {
+ // Set TMIN to high limit & Extreeme to low limit
+ STOS(TMIN) // Set Thigh to TMIN
+ STHY(0xc9) // Set Tlow to extreeme low (-55C)
+ }
+ else {
+ if( LLess(Local1, TMAX) ) {
+ // Set TMAX to high limit & TMIN-2 to low limit
+ STOS(TMAX) // Set Thigh to TMAX
+ Subtract(TMIN, 2, Local3)
+ STHY(Local3) // Set Tlow to TMIN-2
+ }
+ else {
+ if( LLess(Local1, TCRT) ) {
+ // Set TCRT to high limit & TMAX-2 to low limit
+ STOS(TCRT) // Set Thigh to TCRT
+ Subtract(TMAX, 2, Local3)
+ STHY(Local3) // Set Tlow to TMAX-2
+ }
+// else {
+// // This from init. set TMIN to high & Extreeme to low
+// STOS(TMIN) // Set Thigh to TMIN
+// STHY(0xc9) // Set Tlow to extreeme low (-55C)
+// }
+ }
+ }
+ }
+ }
+
+
+ RBYT(TSAD, 0x02) // Read status byte after limit changes
+ RSBT(0x19, 0) // Receive Byte, Addr 0x18
+*/
+ Notify(\_TZ.THRM, 0x81) // Notify of trip point change
+ }
+
+// Set configuration register #0x9
+Method(SCFG, 1) {
+ // Arg0 = configuration byte
+
+ WBYT(TSAD, 0x09, Arg0)
+ }
+
+// Read Status Byte
+Method(RSTS, 0) {
+ // Arg0 = configuration byte
+
+ Return(RBYT(TSAD, 0x02))
+ }
+
+// Set Tos register #0xb
+Method(STOS, 1) {
+ // Arg0 = temperature low byte
+
+ // Set pointer register (occupy the command byte) to 0x0B
+
+ WBYT(TSAD, 0x0B, Arg0)
+ }
+
+// Set Thyst register #0xC
+Method(STHY, 1) {
+ // Arg0 = temperature low byte
+
+ // Set pointer register (occupy the command byte) to 0x0C
+ WBYT(TSAD, 0x0C, Arg0)
+ }
+// Get Tos register #0x5
+Method(GTOS, 0) {
+
+ Store(RBYT(TSAD, 0x05), Debug)
+ }
+
+// Set Thyst register #0x6
+Method(GTHY, 0) {
+
+ Store(RBYT(TSAD, 0x06), Debug)
+ }
+
+// Read local temperature register
+
+Method(RTMP, 0) {
+ // Set pointer register (occupy the command byte) to 0x00
+
+ Store(RBYT(TSAD, 0x00), Local0)
+
+Store(Local0, DBG8)
+
+ If(Not(Local0)) // Read command completed
+ {
+ Return( Local0 )
+ }
+ Else // Read command failed
+ {
+ Store("_TMP Read ERROR", Debug)
+ Return(Add(TMIN, 2)) // MIN trip point + 2.0 C
+ }
+} // Method(RTMP)
+
+// MAX1617 Thermal interrupt handler
+Method(THDL,0) {
+//**********************************************************************;
+ TCHG() // change Trip points
+ // Clear ALARM bit
+ RSBT(0x19, 0) // Receive Byte, Addr 0x18
+//**********************************************************************;
+}
+//**********************************************************************;
+// *****************************************************************;
+// *****************************************************************;
+// ** **;
+// ** (C)Copyright 1985-1996, American Megatrends, Inc. **;
+// ** **;
+// ** All Rights Reserved. **;
+// ** **;
+// ** 6145-F Northbelt Pkwy, Norcross, GA 30071 **;
+// ** **;
+// ** Phone (770)-246-8600 **;
+// ** **;
+// *****************************************************************;
+// *****************************************************************;
+//**********************************************************************;
+// DON'T CHANGE ANY CODE UNLESS REQUIRED !!!
+//**********************************************************************;
diff --git a/Core/EM/ACPI/MAX1617R.ASL b/Core/EM/ACPI/MAX1617R.ASL
new file mode 100644
index 0000000..aa60f73
--- /dev/null
+++ b/Core/EM/ACPI/MAX1617R.ASL
@@ -0,0 +1,222 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/MAX1617R.ASL 2 3/26/09 4:53p Oleksiyy $
+//
+// $Revision: 2 $
+//
+// $Date: 3/26/09 4:53p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/MAX1617R.ASL $
+//
+// 2 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:42p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 2 9/06/02 10:53a Alexp
+// Add SourceSafe headers to all core asl files
+//
+//
+//;**********************************************************************;
+//**********************************************************************;
+// ASL interface to MAX1617 thermal sensor over SMBus
+// Remote sensor
+//**********************************************************************;
+
+// change max1617 trip point
+/*
+// Original TCHG method
+ Method(TCHG, 0) {
+
+ Store(RBYT(TSAD, 0x01), Local0) // Read remote Current temp
+
+ Add(Local0, 0x5, Local1) // Set Thigh T + 5.0 C
+
+ Subtract(Local0, 0x5, Local2) // Set Tlow T - 5.0 C
+// Subtract(Local0, 0x2, Local2) // Set Tlow T - 2.0 C
+
+ Subtract(TMIN, 0x5, Local3) // Set Tlow TMIN - 5.0 C
+// If(LGreater(Local2,Local3))
+// {Store(Local3,Local2)}
+
+ STOS(Local1) // Set Thigh
+ STHY(Local2) // Set Tlow
+ // Clear ALARM bit
+ Notify(\_TZ.THRM, 0x81) // Notify of trip point change
+ }
+*/
+// Customized Method
+ Method(TCHG, 0) {
+
+ Store(RBYT(TSAD, 0x07), Local0) // remote high limit
+ Store(RBYT(TSAD, 0x08), Local1) // remote low limit
+ Store(RBYT(TSAD, 0x01), Local2) // remote current temp
+ RBYT(TSAD, 0x02) // Read status byte
+ if( LGreaterEqual(Local2,Local0) ) {
+ // High limit alert
+ if( LEqual(Local0, TMIN) ) {
+ // Set TMAX to high limit & TMIN-2 to low limit
+ STOS(TMAX) // Set Thigh to TMAX
+ Subtract(TMIN, 2, Local3)
+ STHY(Local3) // Set Tlow to TMIN-2
+ }
+ else {
+ if( LEqual(Local0, TMAX) ) {
+ // Set TCRT to high limit & TMAX-2 to low limit
+ STOS(TCRT) // Set Thigh to TCRT
+ Subtract(TMAX, 2, Local3)
+ STHY(Local3) // Set Tlow to TMAX-2
+ }
+ else {
+ if( LEqual(Local0, TCRT) ) {
+ // Notify OS to shutdown
+ // Set Extreeme high to high limit & TCRT-2 to low limit
+ STOS(0x7f) // Set Thigh to extreeme high (127C)
+ Subtract(TCRT, 2, Local3)
+ STHY(Local3) // Set Tlow to TCRT-2
+ }
+// else {
+// // This from init. set TMIN to high & Extreeme to low limit
+// STOS(TMIN) // Set Thigh to TMIN
+// STHY(0xc9) // Set Tlow to extreeme low (-55C)
+// }
+ }
+ }
+ }
+ else {
+ if( LLessEqual(Local2, Local1) ) {
+ // Low limit alert
+ if( LLess(Local1, TMIN) ) {
+ // Set TMIN to high limit & Extreeme to low limit
+ STOS(TMIN) // Set Thigh to TMIN
+ STHY(0xc9) // Set Tlow to extreeme low (-55C)
+ }
+ else {
+ if( LLess(Local1, TMAX) ) {
+ // Set TMAX to high limit & TMIN-2 to low limit
+ STOS(TMAX) // Set Thigh to TMAX
+ Subtract(TMIN, 2, Local3)
+ STHY(Local3) // Set Tlow to TMIN-2
+ }
+ else {
+ if( LLess(Local1, TCRT) ) {
+ // Set TCRT to high limit & TMAX-2 to low limit
+ STOS(TCRT) // Set Thigh to TCRT
+ Subtract(TMAX, 2, Local3)
+ STHY(Local3) // Set Tlow to TMAX-2
+ }
+// else {
+// // This from init. set TMIN to high & Extreeme to low
+// STOS(TMIN) // Set Thigh to TMIN
+// STHY(0xc9) // Set Tlow to extreeme low (-55C)
+// }
+ }
+ }
+ }
+ }
+
+
+ RBYT(TSAD, 0x02) // Read status byte after limit changes
+ RSBT(0x19, 0) // Receive Byte, Addr 0x18
+ Notify(\_TZ.THRM, 0x81) // Notify of trip point change
+ }
+
+// Set configuration register #0x9
+Method(SCFG, 1) {
+ // Arg0 = configuration byte
+
+ WBYT(TSAD, 0x09, Arg0)
+ }
+
+// Read Status Byte
+Method(RSTS, 0) {
+ // Arg0 = configuration byte
+
+ Return(RBYT(TSAD, 0x02))
+ }
+
+// Set remote Thigh register #0x0d
+Method(STOS, 1) {
+ // Arg0 = temperature low byte
+
+ // Set pointer register (occupy the command byte) to 0x0d
+ // Somehow max1617 wants to send out the MSB byte first !
+
+ WBYT(TSAD, 0x0d, Arg0)
+ }
+
+// Set remote Tlow register #0x0e
+Method(STHY, 1) {
+ // Arg0 = temperature low byte
+
+ // Set pointer register (occupy the command byte) to 0x0C
+ // Somehow max1617 wants to send out the MSB byte first !
+
+ WBYT(TSAD, 0x0e, Arg0)
+ }
+
+// Read remote temperature register
+Method(RTMP, 0) {
+ // Set pointer register (occupy the command byte) to 0x00
+ // DATW, DB00 and DB01 are defined as global buffer fields
+
+ Store(RBYT(TSAD, 0x01), Local0)
+
+Store(Local0, DBG8)
+
+ If(Not(Local0)) // Read command completed
+ {
+ Return( Local0 )
+ }
+ Else // Read command failed
+ {
+ Store("_TMP Read ERROR", Debug)
+ Return(Add(TMIN, 2)) // MIN trip point + 2.0 C
+ }
+
+} // Method(RTMP)
+
+// MAX1617 Thermal interrupt handler
+Method(THDL,0) {
+//**********************************************************************;
+ // Clear ALARM bit
+ RSBT(0x19, 0) // Receive Byte, Addr 0x18
+ TCHG() // change Trip points
+//**********************************************************************;
+}
+//**********************************************************************;
+// *****************************************************************;
+// *****************************************************************;
+// ** **;
+// ** (C)Copyright 1985-1996, American Megatrends, Inc. **;
+// ** **;
+// ** All Rights Reserved. **;
+// ** **;
+// ** 6145-F Northbelt Pkwy, Norcross, GA 30071 **;
+// ** **;
+// ** Phone (770)-246-8600 **;
+// ** **;
+// *****************************************************************;
+// *****************************************************************;
+//**********************************************************************;
+// DON'T CHANGE ANY CODE UNLESS REQUIRED !!!
+//**********************************************************************;
diff --git a/Core/EM/ACPI/Mathco.asl b/Core/EM/ACPI/Mathco.asl
new file mode 100644
index 0000000..3885d93
--- /dev/null
+++ b/Core/EM/ACPI/Mathco.asl
@@ -0,0 +1,50 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Mathco.asl 2 3/26/09 4:53p Oleksiyy $
+//
+// $Revision: 2 $
+//
+// $Date: 3/26/09 4:53p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/Mathco.asl $
+//
+// 2 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:42p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 4 9/06/02 10:53a Alexp
+// Add SourceSafe headers to all core asl files
+//
+//
+//;**********************************************************************;
+//-------------------------
+// Math Coprocessor Device
+//-------------------------
+Device(COPR) {
+ Name(_HID,EISAID("PNP0C04"))
+ Name(_CRS, ResourceTemplate()
+ {
+ IO(Decode16, 0xf0, 0xf0, 0, 0x10)
+ IRQNoFlags(){13}
+ })
+} // End of Math Coprocessor
diff --git a/Core/EM/ACPI/MpPciIrq.asm b/Core/EM/ACPI/MpPciIrq.asm
new file mode 100644
index 0000000..e0f5d94
--- /dev/null
+++ b/Core/EM/ACPI/MpPciIrq.asm
@@ -0,0 +1,99 @@
+;**********************************************************************
+;**********************************************************************
+;** **
+;** (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/MpPciIrq.asm 3 3/26/09 4:51p Oleksiyy $
+;
+; $Revision: 3 $
+;
+; $Date: 3/26/09 4:51p $
+;**********************************************************************
+; Revision History
+; ----------------
+; $Log: /Alaska/BIN/Modules/ACPI/Template/Core/MpPciIrq.asm $
+;
+; 3 3/26/09 4:51p Oleksiyy
+; New ACPI Core implementation - improves logic, execution time and
+; memory usage of ACPI module.
+;
+; 2 2/08/07 12:47p Artems
+;
+; 1 2/06/07 4:54p Artems
+;
+;**********************************************************************
+;<AMI_FHDR_START>
+;
+; Name: MpPciIrq.asm
+;
+; Description: This file includes MPS related tables, generated by AMISDL
+;
+;<AMI_FHDR_END>
+;**********************************************************************
+
+IFNDEF EFIx64
+.586P
+option language:c
+ENDIF
+
+; MPS PCI IRQ - APIC description table
+;------------------------------------------------------------------------------
+MP_IRI STRUC
+ PciBusNumber db ?
+ DeviceNumber db ?
+ IntA_ApicItin db ?
+ IntA_ApicId db ?
+ IntB_ApicItin db ?
+ IntB_ApicId db ?
+ IntC_ApicItin db ?
+ IntC_ApicId db ?
+ IntD_ApicItin db ?
+ IntD_ApicId db ?
+ Reserved db ?
+MP_IRI ENDS
+
+MP_IAI STRUC
+ ApicAddress dd ?
+ ApicId db ?
+ Reserved db ?
+MP_IAI ENDS
+
+;IFDEF MpsTable_SUPPORT
+
+IFNDEF EFIx64
+MPSDATA_SEG SEGMENT USE32 'DATA'
+ELSE
+MPSDATA_SEG SEGMENT 'DATA'
+ENDIF
+ include mppciirq.inc
+MPSDATA_SEG ENDS
+
+;ENDIF
+
+end
+
+
+
+;**********************************************************************
+;**********************************************************************
+;** **
+;** (C)Copyright 1985-2009, American Megatrends, Inc. **
+;** **
+;** All Rights Reserved. **
+;** **
+;** 5555 Oakbrook Pkwy, Norcross, GA 30093 **
+;** **
+;** Phone: (770)-246-8600 **
+;** **
+;**********************************************************************
+;********************************************************************** \ No newline at end of file
diff --git a/Core/EM/ACPI/OSCM.asl b/Core/EM/ACPI/OSCM.asl
new file mode 100644
index 0000000..9a3e76f
--- /dev/null
+++ b/Core/EM/ACPI/OSCM.asl
@@ -0,0 +1,124 @@
+// The ASL file for _OSC Method Implementation
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+//-----------------------------------------------------------------------
+
+//;<AMI_PHDR_START>
+//;------------------------------------------------------------------------
+//;
+//; Procedure: _OSC
+//; Description: METHOD CALLED ON SYSTEM STARTUP TO NEGOTIATE OS/BIOS
+//; SUPPORTED FEATURES
+//; Input: Arg0 (Buffer): UUID
+//; Arg1 (Integer): Revision ID
+//; Arg2 (Integer): Count
+//; Arg3 (Buffer): Capabilities Buffer,
+//;
+//; Output: Returns modified Arg3.
+//;
+//;-------------------------------------------------------------------------
+//;<AMI_PHDR_END>
+
+ Method(_OSC,4)
+ {
+ Name(SUPP,0) // PCI _OSC Support Field value
+ Name(CTRL,0) // PCI _OSC Control Field value
+ // Create DWord-adressable fields from the Capabilities Buffer
+ CreateDWordField(Arg3,0,CDW1)
+ CreateDWordField(Arg3,4,CDW2)
+ CreateDWordField(Arg3,8,CDW3)
+ // Check for proper UUID
+ If(LEqual(Arg0,ToUUID("33DB4D5B-1FF7-401C-9657-7441C03DD766")))
+ {
+ // Save Capabilities DWord2 & 3
+ Store(CDW2,SUPP)
+ Store(CDW3,CTRL)
+ //Support Bits:
+ //0 - extended pci config operation region
+ //1 - ASPM supported
+ //2 - Clock Power Management Capability supported
+ //3 - Pci Segment Groups supported
+ //4 - MSI supported
+
+ //Control Bits:
+ //0 - Pci Express Native Hot Plug control
+ //1 - SHPC Native Hot Plug control
+ //2 - Pci Express Native Power Management Events control
+ //3 - Pci Express Advanced Error Reporting control
+ //4 - Pci Express Capability Structure control
+
+ // Only allow native hot plug control if OS supports:
+ // * ASPM
+ // * Clock PM
+ // * MSI/MSI-X
+
+ If(LNotEqual(And(SUPP, 0x16), 0x16))
+ {
+ And(CTRL,0x1E, CTRL) // Mask bit 0 (and undefined bits)
+ }
+ //Tokens ACPI.sdl
+ if (LNot(PEHP))//BIOS Supports PCI Express HP?
+ {
+ And(CTRL,0x1E,CTRL)
+ }
+ if (LNot(SHPC)) //BIOS Supports SHPC Hot Plug ?
+ {
+ And(CTRL,0x1D,CTRL)
+ }
+ if (LNot(PEPM)) //BIOS Supports PCI Express ASPM?
+ {
+ And(CTRL,0x1B,CTRL)
+ }
+ if (LNot(PEER)) //BIOS Supports PCI Express Adv Error Reporting?
+ {
+ And(CTRL,0x15,CTRL)
+ }
+ if (LNot(PECS)) //BIOS Provides PCI Express MCFG Table?
+ {
+ And(CTRL,0xF,CTRL)
+ }
+
+ If(LNotEqual(Arg1,One))
+ { // Unknown revision
+ Or(CDW1,0x08,CDW1)
+ }
+ If(LNotEqual(CDW3,CTRL))
+ { // Certain Capabilities bits were masked
+ Or(CDW1,0x10,CDW1)
+ }
+
+ // Update DWORD3 in the buffer
+ Store(CTRL,CDW3)
+
+ Return(Arg3)
+ } Else {
+ Or(CDW1,4,CDW1) // Unrecognized UUID
+ Return(Arg3)
+ }
+ } // End _OSC
+
+//-----------------------------------------------------------------------
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Core/EM/ACPI/PCIEACCESS.ASL b/Core/EM/ACPI/PCIEACCESS.ASL
new file mode 100644
index 0000000..65ac844
--- /dev/null
+++ b/Core/EM/ACPI/PCIEACCESS.ASL
@@ -0,0 +1,170 @@
+//**********************************************************************;
+// *****************************************************************;
+// ** **;
+// ** (C)Copyright 1985-2003, American Megatrends, Inc. **;
+// ** **;
+// ** All Rights Reserved. **;
+// ** **;
+// ** 6145-F Northbelt Pkwy, Norcross, GA 30071 **;
+// ** **;
+// ** Phone (770)-246-8600 **;
+// ** **;
+// *****************************************************************;
+//-----------------------------------------------------------------------
+// $Header: /Alaska/BIN/Modules/ACPI/Template/Core/PCIEACCESS.ASL 1 5/07/09 2:44p Yakovlevs $
+//
+// $Revision: 1 $
+//
+// $Date: 5/07/09 2:44p $
+//****************************************************************;
+//*****************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/PCIEACCESS.ASL $
+//
+// 1 5/07/09 2:44p Yakovlevs
+//
+// 1 12/10/03 2:40p Srinin
+// PCIe access routines added.
+//
+// 1 12/10/03 12:21p Srinin
+// PCIe access routines added.
+//
+//
+//
+//-----------------------------------------------------------------------
+
+Scope (\_SB) {
+
+//PCIe Capability Structure pointer
+
+Name (XCPD, 0x0) // PCIe Cap ID
+Name (XNPT, 0x1) // Next Pointer Cap Pointer
+Name (XCAP, 0x2) // PCIe Capability pointer
+Name (XDCP, 0x4) // Device Capability
+Name (XDCT, 0x8) // Device Control
+Name (XDST, 0xa) // Device Status
+Name (XLCP, 0xc) // Link Capability
+Name (XLCT, 0x10) // Link Control
+Name (XLST, 0x12) // Link Status
+Name (XSCP, 0x14) // Slot Capability
+Name (XSCT, 0x18) // Slot Control
+Name (XSST, 0x1A) // Slot Status
+Name (XRCT, 0x1C) // Root Control
+Mutex(MUTe, 0) //Mutex object to syncronize Memory mapped access
+
+
+
+// Read PCIe Byte Arg0 : Offset (Zero based)
+
+ Method (RbPe, 1) {
+ Acquire(MUTe, 1000)
+ Add (Arg0, \PEBS, Local0) // PEBS : PCIe MM base address
+ OperationRegion (PCFG, SystemMemory, Local0, 0x1)
+
+ Field (PCFG, ByteAcc, Nolock, Preserve){
+ XCFG, 8 ,
+ }
+ Release (MUTe)
+ Return (XCFG)
+ } // End of \SB.RbPe
+
+// Read PCIe Word Arg0 : Offset (Zero based)
+ Method (RwPe, 1) {
+ Acquire(MUTe, 1000)
+ And (Arg0, 0xFFFFFFFE, Arg0)
+ Add (Arg0, \PEBS, Local0) // PEBS : PCIe MM base address
+ OperationRegion (PCFG, SystemMemory, Local0, 0x2)
+
+ Field (PCFG, WordAcc, Nolock, Preserve){
+ XCFG, 16 ,
+ }
+ Release (MUTe)
+ Return (XCFG)
+ } // End of \SB.RwPe
+
+// Read PCIe Dword Arg0 : Offset (Zero based)
+ Method (RdPe, 1) {
+ Acquire(MUTe, 1000)
+ And (Arg0, 0xFFFFFFFC, Arg0)
+ Add (Arg0, \PEBS, Local0) // PEBS : PCIe MM base address
+ OperationRegion (PCFG, SystemMemory, Local0, 0x4)
+
+ Field (PCFG, DwordAcc, Nolock, Preserve){
+ XCFG, 32 ,
+ }
+ Release (MUTe)
+ Return (XCFG)
+ } // End of \SB.RdPe
+
+// Write PCIe byte Arg0 : Offset (Zero based), Arg1 : Value (Byte)
+ Method (WbPe, 2) {
+ Acquire(MUTe, 0xfff)
+ Add (Arg0, \PEBS, Local0)
+ OperationRegion (PCFG, SystemMemory, Local0, 0x1)
+ Field (PCFG, ByteAcc, Nolock, Preserve){
+ XCFG, 8 ,
+ }
+ Store (Arg1,XCFG)
+ Release (MUTe)
+ } // End of \SB.WbPe
+
+// Write PCIe word Arg0 : Offset (Zero based), Arg1 : Value (word)
+ Method (WwPe, 2) {
+ Acquire(MUTe, 1000)
+ And (Arg0, 0xFFFFFFFE, Arg0)
+ Add (Arg0, \PEBS, Local0)
+ OperationRegion (PCFG, SystemMemory, Local0, 0x2)
+ Field (PCFG, WordAcc, Nolock, Preserve){
+ XCFG, 16 ,
+ }
+ Store (Arg1,XCFG)
+ Release (MUTe)
+ } // End of \SB.WwPe
+
+// Write PCIe Dword Arg0 : Offset (Zero based), Arg1 : Value (Dword)
+ Method (WdPe, 2) {
+ Acquire(MUTe, 1000)
+ And (Arg0, 0xFFFFFFFC, Arg0)
+ Add (Arg0, \PEBS, Local0)
+ OperationRegion (PCFG, SystemMemory, Local0, 0x4)
+
+ Field (PCFG, DwordAcc, Nolock, Preserve){
+ XCFG, 32 ,
+ }
+ Store (Arg1,XCFG)
+ Release (MUTe)
+ } // End of \SB.WdPe
+
+
+// RW PCIe Dword Arg0 : Offset (Zero based), Arg1 : Value (Dword), Arg2 : Mask (Dword)
+ Method (RWdP, 3) {
+ Acquire(MUTe, 1000)
+ And (Arg0, 0xFFFFFFFC, Arg0)
+ Add (Arg0, \PEBS, Local0)
+ OperationRegion (PCFG, SystemMemory, Local0, 0x4)
+
+ Field (PCFG, DwordAcc, Nolock, Preserve){
+ XCFG, 32 ,
+ }
+ And (XCFG, Arg2, Local1)
+ Or (Local1, Arg1, XCFG)
+ Release (MUTe)
+ } // End of \_SB.RWdP
+
+// Checks for PME status in Root port status register
+ Method (RPME, 1) { // Arg0 Enhanced config. memory address map
+ add (Arg0, 0x84, Local0)
+ Store (\_SB.RdPe(Local0), Local1)
+ if (LEQUAL(Local1, 0xffffffff)) {
+ Return (0) // PME not asserted
+ }
+ else {
+ if (Land(Local1, 0x10000)) {
+ \_SB.WdPe(Local0, And(Local1, 0x10000))
+ Return (1) // PME asserted
+ }
+ Return (0) // PME not asserted
+ }
+ } // End of RPME
+} // End of \_SB
diff --git a/Core/EM/ACPI/PCIEHP.ASL b/Core/EM/ACPI/PCIEHP.ASL
new file mode 100644
index 0000000..c5b69ee
--- /dev/null
+++ b/Core/EM/ACPI/PCIEHP.ASL
@@ -0,0 +1,346 @@
+//**********************************************************************;
+// *****************************************************************;
+// ** **;
+// ** (C)Copyright 1985-2004, American Megatrends, Inc. **;
+// ** **;
+// ** All Rights Reserved. **;
+// ** **;
+// ** 6145-F Northbelt Pkwy, Norcross, GA 30071 **;
+// ** **;
+// ** Phone (770)-246-8600 **;
+// ** **;
+// *****************************************************************;
+//-----------------------------------------------------------------------
+// $Header: /Alaska/BIN/Modules/ACPI/Template/Core/PCIEHP.ASL 1 5/07/09 2:44p Yakovlevs $
+//
+// $Revision: 1 $
+//
+// $Date: 5/07/09 2:44p $
+//****************************************************************;
+//*****************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/PCIEHP.ASL $
+//
+// 1 5/07/09 2:44p Yakovlevs
+//
+// 1 1/15/09 2:11p Vasudevans
+// Initial check-in for Tylersburg PCIe Hotplug support.
+//
+// 1 12/10/03 2:40p Srinin
+// PCIe HP support added.
+//
+// 1 12/10/03 12:21p Srinin
+// PCIe Hot plug support added.
+//
+//
+//
+//-----------------------------------------------------------------------
+//Constants
+
+Name (SLHC, 0x040) // Slot Hot plug capable
+
+Name (SPDS, 0x040) // Slot Presence Detect state
+Name (MRLS, 0x020) // MRL open
+Name (CCOM, 0x010) // Command complete
+Name (SPDC, 0x08) // Slot Presence Detect Changes
+Name (MRLC, 0x04) // Slot MRL changed
+Name (SPFD, 0x02) // Slot power fault Detected
+Name (SABP, 0x01) // Slot attention button pressed
+
+Name (SPOF, 0x400) // Slot Power off
+Name (SPON, 0x3FF) // Slot Power on Mask
+
+
+Name (ALMK, 0xFF3F) // Slot atten. LED Mask
+Name (ALON, 0x0040) // Slot atten. LED on
+Name (ALBL, 0x0080) // Slot atten. LED Blink
+Name (ALOF, 0x00C0) // Slot atten. LED off
+
+Name (PLMK, 0xFCFF) // Slot Pwr. LED Mask
+Name (PLON, 0x100) // Slot Pwr. LED on
+Name (PLBL, 0x200) // Slot Pwr. LED Blink
+Name (PLOF, 0x300) // Slot Pwr. LED off
+
+Name (HPEV, 0x0F) // Possible interrupt events (all)
+
+
+Scope (\_SB.PCI0) {
+
+ Mutex (MUTH, 0)
+
+//---------------------------------------
+// Hot plug controller command
+//---------------------------------------
+ Method (HPCC, 2) {
+// Arg0 : Memory mapped Address to PCIe Feature capability Structure
+// ARG1 : Slot Control Register value
+ Acquire(MUTH, 0xFFF)
+ Store (Rwpe(Add(Arg0, XSCT)), Local0)
+ Store (Arg1, Local1)
+ And (Local0, 0x7C0, Local0)
+ And (Local1, 0x7C0, Local1)
+// If (LNotEqual(Local1, Local0)) {
+ Wbpe(Add(Arg0,XSST), CCOM) // Clear the command complete status
+ Wwpe(Add(Arg0, XSCT), Arg1)
+ Store (0, Local0)
+ Sleep (2) // Give time to complete the command
+ While (LLess(Local0, 100)){ // Command completed ?
+ Sleep (10)
+ Add (Local0, 10, Local0)
+ if(LEqual(And(Rwpe(Add(Arg0, XSST)), CCOM), CCOM)){ // Command completed ?
+ If (LGreaterEqual(Local0, 100)) {
+ Break // May not work in all OSes
+ }
+ Store (100, Local0)
+ }
+ }
+ Wbpe(Add(Arg0,XSST), CCOM) // Clear the command complete status
+// }
+// else { // Don't wait for command status to update
+// Wwpe(Add(Arg0, XSCT), Arg1)
+// }
+ Release(MUTH)
+ } // end of HPCC
+
+//---------------------------------------
+// Attention button Indicator
+//---------------------------------------
+ Method (ATCM, 2) {
+// Arg0 : Memory mapped Address to PCIe Feature capability Structure
+// Arg1 : Attention Indicator Value
+// Check if Attention Indicator is present
+ Store (Rwpe(Add(Arg0, XSCP)), Local0) // Read Slot Capability Register
+ if (And(Local0, 0x08)) { // Attention indicator present
+ Store (Rwpe(Add(Arg0, XSCT)), Local0)// Read Slot Control Register
+ And (Local0, ALMK, Local0) // Clear Attention indicator control
+ If (LEqual(Arg1, 0x01)) { // Attention indicator "ON"?
+ Or (Local0, ALON, Local0)
+ }
+ If (LEqual(Arg1, 0x02)) { // Attention indicator "BLINK"?
+ Or (Local0, ALBL, Local0)
+ }
+ If (LEqual(Arg1, 0x03)) { // Attention indicator "OFF"?
+ Or (Local0, ALOF, Local0)
+ }
+ HPCC (Arg0, local0)
+ }
+ } // End of ATCM
+
+//---------------------------------------
+// Power Indicator
+//---------------------------------------
+ Method (PWCM, 2) {
+// Arg0 : Memory mapped Address to PCIe Feature capability Structure
+// Arg1 : Power Indicator Value
+// Check if Power Indicator is present
+ Store (Rwpe(Add(Arg0, XSCP)), Local0) // Read Slot Capability Register
+ if (And(Local0, 0x10)) { // Power indicator present
+ Store (Rwpe(Add(Arg0, XSCT)), Local0)
+ And (Local0, PLMK, Local0)
+ If (LEqual(Arg1, 0x01)) { // Power indicator "ON"?
+ Or (Local0, PLON, Local0)
+ }
+ If (LEqual(Arg1, 0x02)) { // Power indicator "BLINK"?
+ Or (Local0, PLBL, Local0)
+ }
+ If (LEqual(Arg1, 0x03)) { // Power indicator "OFF"?
+ Or (Local0, PLOF, Local0)
+ }
+ HPCC (Arg0, local0)
+ }
+ } // End of PWCM
+
+//---------------------------------------
+// Slot Power Control
+//---------------------------------------
+ Method (PWSL, 2) {
+// Arg0 : Memory mapped Address to PCIe Feature capability Structure
+// Arg1 : Power Controller on/off
+// Check if Power controller is present?
+ Store (Rwpe(Add(Arg0, XSCP)), Local0) // Read Slot Capability Register
+ if (And(Local0, 0x2)) { // Power controller present
+ Store (Rwpe(Add(Arg0, XSCT)), Local0)
+ If (LEqual(Arg1, 0x0)) { // Power slot "OFF"?
+ Or (Local0, SPOF, Local0)
+ }
+ If (LEqual(Arg1, 0x01)) { // Power Slot "ON"?
+ And (Local0, SPON, Local0)
+ }
+ HPCC (Arg0, local0)
+ }
+ } // End of PWSL
+
+//---------------------------------------
+// Attention button Interupt Enable/Disable
+//---------------------------------------
+ Method (ABIE, 2) {
+// Arg0 : Memory mapped Address to PCIe Feature capability Structure
+// Arg1 : Attention button Interrupt Enable/Disable
+// Check if Attention Button present
+ Store (Rwpe(Add(Arg0, XSCP)), Local0) // Read Slot Capability Register
+ if (And(Local0, SABP)) { // Attention button present
+ Store (Rwpe(Add(Arg0, XSCT)), Local0)
+ If (LEqual(Arg1, 0x0)) { // Disable Attention button interrupt
+ And (Local0, 0xFFFE, Local0)
+ }
+ If (LEqual(Arg1, 0x01)) { // Enable Attention button interrupt
+ Or (Local0, SABP, Local0)
+ }
+ HPCC (Arg0, local0)
+ }
+ } // End of ABIE
+
+
+//---------------------------------------
+// EJection Main Handler
+//---------------------------------------
+ Method (EJMH, 1) {
+ Store(0x62, DBG8) // DBG8 name translates to IO port 80h
+// Arg0 : Memory mapped Address to PCIe Feature capability Structure
+ Store (Rwpe(Add(Arg0, XSCT)), Local0)
+ Or (Local0, SPOF, Local0) // Power COntroller to Power OFF
+ Or (Local0, PLOF, Local0) // Power Indicator to OFF
+ Or (Local0, ALOF, Local0) // Attention "OFF"
+ HPCC (Arg0, Local0)
+ } // End of EJMH
+
+//---------------------------------------
+// Hnadler of Hot Plug Event
+//---------------------------------------
+ Method (HHPE, 1){
+// Arg0 : Memory mapped Address to PCIe Feature capability Structure
+ Store (RdPe(Arg0), Local0)
+ If (Lequal(Local0, 0xFFFFFFFF)) {Return (0xFF)}
+ Store (RbPe(Add(Arg0,XSST)), Local0)
+ If (And(HPEV, Local0)) { // Check for Slot status
+ Store (PP4H(Arg0), Local0) // Hot plug interrupt Handler
+ Return (Local0) // Return PP4H information
+ }
+ Else {
+ Return (0xFF) // This controller didn't interrupt
+ }
+ }
+
+ Method (PP4H, 1) {
+// Arg0 : Memory mapped Address to PCIe Feature capability Structure 1
+ Store (RbPe(Add(Arg0,XSST)), Local0)
+ If (And(Local0, SABP)) { // Attention button pressed? 2
+ Wbpe(Add(Arg0,XSST),SABP) // Clear interrupt status
+ If (LEqual(And(Local0, SPDS), 0x00)) { // Slot empty? 3
+ PWSL (Arg0, 0x0) // Power off
+ PWCM (Arg0, 0x3) // Power indicator off
+ ATCM (Arg0, 0x3) // Attention indicator off
+ Return (0x03) // Eject Request
+ } // 3
+// Card is present and slot is already powered. User presses attention button to eject the card
+ Store (RwPe(Add(Arg0,XSCT)), Local0)
+ If (LEqual(And(Local0,SPOF), 0x00)) { // Slot already powered 4
+ ABIE (Arg0, 0x0) // Disable Attention button interrupt
+ PWCM (Arg0, 0x02) // Set power Indicator to blink
+ Store (0x0, Local0) // 5sec counter
+ While (LNotEqual(And(Rwpe(Add(Arg0, XSST)), SABP), SABP)){ //Check for Attention button again 5
+ Sleep (200) // Wiat 200msec
+ Add (Local0, 200, Local0)
+ If (Lequal (5000, Local0)){ // 6
+ ABIE (Arg0, 0x1) // Enable Attention button interrupt
+ Return (0x03) // Continue with Eject Request
+ } // 6
+ } // 5
+// User presses attention button again to abort eject request
+ PWCM (Arg0, 0x01) // Set power indicator off
+ Wbpe (Add(Arg0, XSST), SABP) // Clear attention status
+ ABIE (Arg0, 1) // Enable Attention button interrupt
+ Return (0xff) // Do nothing and abort
+ } // 4
+// Card is present and slot is not powered
+// User presses attention button to indicate card is inserted
+ Else { // Slot power is "OFF". So power up the slot 7
+ ABIE (Arg0, 0) // Disable Attention button interrupt
+ PWCM(Arg0, 0x2) // Set power indicator to blink
+// Check if user presses attention button again to cancel the insertion
+ Store (0x0, Local0) // Set 5 sec accumulator to 0
+ While (LNotEqual(And(Rwpe(Add(Arg0, XSST)), SABP), SABP)){ //Check for Attention button again 8
+ Sleep(200)
+ Add(Local0, 200, Local0)
+ if (LEqual(5000, Local0)){ // 9
+ ABIE (Arg0, 1) // Enable Attention button interrupt
+ ATCM (Arg0, 0x3) // Set attention indicator off
+ PWSL (Arg0, 0x1) // Power the slot
+ Sleep (500) // Wait for .5sec for the power to stabilize
+// Check for Power fault Detection
+ If (LNotEqual(And(Rwpe(Add(Arg0, XSST)), SPFD), SPFD)) { // No power fault
+ PWCM (Arg0, 0x1) // Set power indicator to "ON"
+ Return (0x0) // Insertion request
+ }
+ Else { // Power Fault present 10
+ PWCM (Arg0, 0x3) // Set power indicator to OFF
+ PWSL (Arg0, 0x0) // Set power off
+ ATCM (Arg0, 0x2) // Set attention indicator to Blink
+ Return (0x3) // Eject Request
+ } // 10
+ } // 9
+ } // 8
+// User presses attention button again, Leave slot unpowered
+ Wbpe (Add(Arg0, XSST), SABP) // Clear attention status
+ ABIE (Arg0, 1) // Enable Attention button interrupt
+ PWCM (Arg0, 0x3) // Set Power indicator back to "OFF"
+ Return (0xff) //
+ } // End if Slot power if "OFF" 7
+ } // End for Attention button Hot plug interrupt 2
+
+ If (And(Rwpe(Add(Arg0, XSST)), SPFD)) { // Check if power fault detected
+ Wbpe (Add(Arg0, XSST), SPFD) // Clear the power fault Status
+ PWCM (Arg0, 0x3) // Set power indicator to "OFF"
+ PWSL (Arg0, 0x0) // Set power off
+ ATCM (Arg0, 0x2) // Set attention indicator "Blink"
+ Return (0x3) // Eject request
+ } // End for Power Fault Interrupt
+
+
+ If (And(Rwpe(Add(Arg0, XSST)), MRLC)) { // Check if interrupt caused by the MRL sensor
+ Wbpe (Add(Arg0, XSST), MRLC) // Clear the MRL status
+ Return (0x3) // Eject request
+ }
+
+ If (And(Rwpe(Add(Arg0, XSST)), SPDC)) { // Check if Presence Detect changed status 11
+ Wbpe (Add(Arg0, XSST), SPDC) // Clear Presence Detect Changed status
+ If (LEqual(And(Rwpe(Add(Arg0, XSST)), SPDS), 0x00)) { // Check if Slot empty
+ PWSL (Arg0, 0x0) // Set power slot "OFF"
+ PWCM (Arg0, 0x3) // Set power indicator to "OFF"
+ Return (0x3) // Eject Request
+ }
+ Else { // Card is present 12
+ ABIE (Arg0, 0) // Attention button Interrupt disable
+ PWCM (Arg0, 0x2) // Set power indicator to blink
+ Store (0x0, Local0) // set 5 sec accumulator to 0
+ While (LEqual(And(Rwpe(Add(Arg0, XSST)), SABP), 0x00)){ //Check for Attention button again 13
+ Sleep (200) // wait 200ms
+ Add (Local0, 200, Local0)
+ If (LEqual(5000, Local0)){ // 14
+ ABIE (Arg0, 1) // Enable Attention button interrupt
+ ATCM (Arg0, 0x3) // Set attention indicator "OFF"
+ PWSL (Arg0, 0x1) // Power the slot
+ Sleep (500) // wair for 0.5 sec for power to stabilize
+ If (LEqual(And(Rwpe(Add(Arg0, XSST)), SPFD), 0x00)) { // No power fault 16
+ PWCM (Arg0, 0x1) // Set power indicator to "ON"
+ Return (0x0) // Notify OS to load the driver
+ } // 16
+ Else { // Power Fault detected // 15
+ PWCM (Arg0, 0x3) // Set power indicator to "OFF"
+ PWSL (Arg0, 0x0) // Set power "OFF"
+ ATCM (Arg0, 0x2) // Set attention indicator to "Blink"
+ Return (0x3) // Eject request
+ } // End of Power Fault 15
+ } // 14
+ } // 13
+// Attention button pressed to abort the process
+ ABIE (Arg0, 1) // Enable Attention button interrupt
+ PWCM (Arg0, 0x3) // Set power indicator back to "OFF"
+ Return (0xff) //
+ } // End of Slot power on/off 12
+ } // End of Presence Detect changed Hot plug interrupt 11
+ Return (0xff) // Control should not come here
+ } // End of PP4H 1
+} // End of \_SB.PCI0
+
diff --git a/Core/EM/ACPI/PS2kb.asl b/Core/EM/ACPI/PS2kb.asl
new file mode 100644
index 0000000..55cc136
--- /dev/null
+++ b/Core/EM/ACPI/PS2kb.asl
@@ -0,0 +1,121 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/PS2kb.asl 10 5/07/12 10:49a Oleksiyy $
+//
+// $Revision: 10 $
+//
+// $Date: 5/07/12 10:49a $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/PS2kb.asl $
+//
+// 10 5/07/12 10:49a Oleksiyy
+// [TAG] EIP88686
+// [Category] Improvement
+// [Description] Add tokens for _CID and _HID to pass the WHCK
+// [Files] ACPI.sdl, PS2kb.asl and PS2ms.asl
+//
+// 9 2/09/12 2:08p Oleksiyy
+// [TAG] EIP82016
+// [Category] Improvement
+// [Description] Change ASL macro FixedIO to IO
+// [Files] PS2kb.asl and GenericSio.c
+//
+// 8 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 7 4/16/08 12:09p Yakovlevs
+// Changed 0x60 0x64 resources to clame 16 bit IO.
+//
+// 6 4/15/08 9:25p Yakovlevs
+// Moved from OEMDSDT device specific 2nd Level wake up control method and
+// wake flag
+//
+// 5 4/09/08 6:05p Yakovlevs
+//
+// 4 4/09/08 5:10p Yakovlevs
+//
+// 3 4/03/06 4:05p Felixp
+// New Super I/O infrastructure Support
+//
+// 2 7/12/05 10:57a Girim
+// Updated and Cleaned up the code.
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:42p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 4 9/06/02 10:53a Alexp
+// Add SourceSafe headers to all core asl files
+//
+//
+//**********************************************************************;
+// PS2 Keyboard Device, IO category # - 10
+//---------------------------------------------------------------------
+
+
+Device(PS2K) {
+ //Name(_HID,EISAID("PNP0303")) // Standard Keyboard 101/102
+ Method(_HID,0){
+ Return (\HIDK)
+ }
+
+ //Name(_CID,EISAID("PNP030b")) // Compatible ID, PC/AT Enhanced Keyboard 101/102
+ Method(_CID,0){
+ Return (\CIDK)
+ }
+
+ Method(_STA,0) {
+ If(And(\IOST, 0x0400)){
+ Return (0x0F)
+ } else {
+ Return (0x00)
+ }
+ }
+
+ Name(_CRS,ResourceTemplate()
+ {
+ IO(Decode16, 0x60, 0x60, 0, 0x1) //PS2 resource
+ IO(Decode16, 0x64, 0x64, 0, 0x1)
+ IRQNoFlags(){1}
+ })
+
+//-----------------------------------------------------------------------
+//NOTE: _PRS MUST be the NAME not a METHOD object
+//to have GENERICSIO.C working right!
+//-----------------------------------------------------------------------
+ Name(_PRS, ResourceTemplate(){
+ StartDependentFn(0, 0) {
+ IO(Decode16, 0x60, 0x60, 0, 0x1)
+ IO(Decode16, 0x64, 0x64, 0, 0x1)
+ IRQNoFlags(){1}
+ }
+ EndDependentFn()
+ })
+
+ // Keyboard 2nd Level wake up control method
+ Method(_PSW, 1){
+ Store(Arg0, \KBFG)
+ }
+
+}// End of PS2K
+
+Scope(\){
+ Name(\KBFG, 0x01) //Keyboard wake-up flag default enable
+}
diff --git a/Core/EM/ACPI/PS2ms.asl b/Core/EM/ACPI/PS2ms.asl
new file mode 100644
index 0000000..41bf925
--- /dev/null
+++ b/Core/EM/ACPI/PS2ms.asl
@@ -0,0 +1,128 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/PS2ms.asl 8 5/07/12 10:50a Oleksiyy $
+//
+// $Revision: 8 $
+//
+// $Date: 5/07/12 10:50a $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/PS2ms.asl $
+//
+// 8 5/07/12 10:50a Oleksiyy
+// [TAG] EIP88686
+// [Category] Improvement
+// [Description] Add tokens for _CID and _HID to pass the WHCK
+// [Files] ACPI.sdl, PS2kb.asl and PS2ms.asl
+//
+// 7 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 6 4/16/08 12:08p Yakovlevs
+// Added 60, 64 resources when KB is not present.
+//
+// 5 4/15/08 9:22p Yakovlevs
+// Moved from OEMDSDT device specific 2nd Level wake up control method and
+// wake flag
+//
+// 4 4/09/08 6:04p Yakovlevs
+//
+// 3 4/09/08 5:09p Yakovlevs
+// Made _STA return bit set value from \IOST object
+//
+// 2 4/03/06 4:05p Felixp
+// New Super I/O infrastructure Support
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:42p Sivagarn
+// 0ABHI001 Check in
+//
+// 2 9/17/04 12:10p Yakovlevs
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 6 9/06/02 10:53a Alexp
+// Add SourceSafe headers to all core asl files
+//
+//
+//**********************************************************************;
+// PS2 Mouse Device, IO category # - 12
+//---------------------------------------------------------------------
+Device(PS2M) {
+
+// Name(_HID, EISAID("PNP0F03")) // Hardware Device ID - Microsoft mouse
+ // check if MSFT Mouse driver supports D3 properly on all MSFT OSes.
+ // It may prevent OS to go to S3 sleep state
+ // Use Logitech _HID instead if OS rejecting to go to S3.
+ Method(_HID,0){
+ Return (\HIDM)
+ }
+// Name(_HID, EISAID("PNP0F12")) // Logitech PS2 Mouse ID
+// Name(_CID, EISAID("PNP0F13")) // Compatible ID
+ Method(_CID,0){
+ Return (\CIDM)
+ }
+
+ Method(_STA, 0) {
+ // Check if PS2Mouse detected in BIOS Post
+ // IOST - bit mask of enabled devices, 0x4000 - PS2M mask
+ If(And(\IOST, 0x4000)){ // Check if PS2MS detected in BIOS Post
+ Return(0x0f)
+ } else {
+ Return(0x00)// device's not present
+ }
+ }
+ Name(CRS1, ResourceTemplate()
+ {
+ IRQNoFlags(){12}
+ })
+ Name(CRS2, ResourceTemplate()
+ {
+ IO(Decode16, 0x60, 0x60, 0, 0x1)
+ IO(Decode16, 0x64, 0x64, 0, 0x1)
+ IRQNoFlags(){12}
+ })
+ Method(_CRS,0)
+ {
+ If(And(\IOST, 0x0400)){ // PS2K is present, I/O resources 0x60 & 0x64 are reserved there
+ Return(CRS1)
+ } else { // single PS/2 mouse(no PS/2 kbd), need to supply I/O resources 0x60 & 0x64 for PS/2 Controller.
+ Return(CRS2)
+ }
+ }
+
+//-----------------------------------------------------------------------
+//NOTE: _PRS MUST be the NAME not a METHOD object
+//to have GENERICSIO.C working right!
+//-----------------------------------------------------------------------
+ Name(_PRS, ResourceTemplate(){
+ StartDependentFn(0, 0) {
+ IRQNoFlags(){12}
+ }
+ EndDependentFn()
+ })
+
+ // Mouse 2nd Level wake up control method
+ Method(_PSW, 1){
+ Store(Arg0, \MSFG)
+ }
+
+}// End of PS2M
+
+Scope(\){
+ Name(\MSFG, 0x01) //Mouse wake-up flag default enable
+}
diff --git a/Core/EM/ACPI/RbRes.asl b/Core/EM/ACPI/RbRes.asl
new file mode 100644
index 0000000..b2b8d6a
--- /dev/null
+++ b/Core/EM/ACPI/RbRes.asl
@@ -0,0 +1,501 @@
+//****************************************************************************
+//****************************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone (770)-246-8600 **
+//** **
+//****************************************************************************
+//****************************************************************************
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: NBRes.ASL
+//
+// Description: PCI Root Bridge resources buffer and CRS Method
+// MUST be included from NB.ASL directly using "include" ASL term
+// Suppose to be already in ROOT BRIDGE Device ASL Scope.
+//
+// NOTE: NO Porting needed
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+
+//Defining some place holders, we need to updte at runtime.
+ Name(CPRB, 0x0) //BOOLEAN Compatible Root Bridge if !=0
+ Name(LVGA, 0x55) //BOOLEAN Legacy Video Present if !=0
+ Name(STAV,0x0F)
+//Information Provided in RootBridgeIo->Configuration() function.
+ Name(BRB, 0x0100) //Bus Range Base
+ Name(BRL, 0x0100) //Bus Range Length
+
+ Name(IOB, 0x0100) //IO Range BASE (16bit resource)
+ Name(IOL, 0x0100) //IO Range LENGTH
+
+ Name(MBB, 0x10000) //Memory Range Below 4G BASE (32bit resource)
+ Name(MBL, 0x10000) //Memory Range Below 4G LENGTH (32bit resource)
+
+ Name(MABL, 0x10000) //Memory Range Above 4G BASE LSDW (32bit resource)
+ Name(MABH, 0x10000) //Memory Range Above 4G BASE MSDW (32bit resource)
+
+ Name(MALL, 0x10000) //Memory Range Above 4G LENGTH LSDW (32bit resource)
+ Name(MALH, 0x10000) //Memory Range Above 4G LENGTH LSDW (32bit resource)
+
+ Name(MAML, 0x10000) //Memory Range Above 4G LENGTH LSDW (32bit resource)
+ Name(MAMH, 0x10000) //Memory Range Above 4G LENGTH LSDW (32bit resource)
+
+//---------------------------------------------------------------------------
+ //Resource buffer to be used for COMPATIBILITY ROOT BRIDGE (one that decodes ISA resources)
+ Name(CRS1, ResourceTemplate() {
+ WORDBusNumber( //Bus number resource (0); the bridge produces bus numbers for its subsequent buses
+ ResourceProducer, // bit 0 of general flags is 1
+ MinFixed, // Range is not fixed
+ MaxFixed, // Range is not fixed
+ PosDecode, // PosDecode
+ 0x0000, // Granularity
+ 0x0000, // Min
+ 0x007f, // Max; half of the available bus numbers are reserved for this root bus
+ 0x0000, // Translation
+ 0x0080, // Range Length
+ ,,
+ BUS1
+ )
+
+ // CF8 - CFC
+ IO( //Consumed resource for 1st root bus(CF8-CFF)
+ Decode16,
+ 0x0cf8,
+ 0xcf8,
+ 1,
+ 8
+ )
+
+ // All IO below 3B0
+ WORDIO( //Consumed-and-produced resource (all I/O below 3B0 is assigned to this root bus)
+ ResourceProducer, // bit 0 of general flags is 0
+ MinFixed, // Range is fixed
+ MaxFixed, // Range is fixed
+ PosDecode,
+ EntireRange,
+ 0x0000, // Granularity
+ 0x0000, // Min
+ 0x03af, // Max
+ 0x0000, // Translation
+ 0x03b0 // Range Length
+ )
+
+ // 3E0 - CF7
+ WORDIO( //Consumed-and-produced resource (all I/O between 3E0 and CF8 is assigned to this root bus)
+ ResourceProducer, // bit 0 of general flags is 0
+ MinFixed, // Range is fixed
+ MaxFixed, // Range is fixed
+ PosDecode,
+ EntireRange,
+ 0x0000, // Granularity
+ 0x03e0, // Min
+ 0x0cf7, // Max
+ 0x0000, // Translation
+ 0x0918 // Range Length
+ )
+
+ // For Legacy Video IO (3B0 - 3DF)
+ WORDIO( //Consumed-and-produced resource (Used for legacy video)
+ ResourceProducer, // bit 0 of general flags is 0
+ MinFixed, // Range is fixed
+ MaxFixed, // Range is fixed
+ PosDecode,
+ EntireRange,
+ 0x0000, // Granularity
+ 0x0000, // Min
+ 0x0000, // Max
+ 0x0000, // Translation
+ 0x0000, // Range Length
+ ,,
+ VIO1
+ )
+
+ // Other IO used by this root bridge
+ WORDIO( //Consumed-and-produced resource
+ ResourceProducer, // bit 0 of general flags is 0
+ MinFixed, // Range is fixed
+ MaxFixed, // Range is fixed
+ PosDecode,
+ EntireRange,
+ 0x0000, // Granularity
+ 0x0d00, // Min
+ 0x0fff, // Max
+ 0x0000, // Translation
+ 0x0300, // Range Length
+ ,,
+ IOW2
+ )
+
+ // For Legacy Video Memory (A000 - BFFF)
+ DWORDMEMORY( // descriptor for video RAM behind ISA bus
+ ResourceProducer, // bit 0 of general flags is 0
+ PosDecode,
+ MinFixed, // Range is fixed
+ MaxFixed, // Range is Fixed
+ Cacheable,
+ ReadWrite,
+ 0x00000000, // Granularity
+ 0x00000000, // Min
+ 0x00000000, // Max
+ 0x00000000, // Translation
+ 0x00000000, // Range Length
+ ,,
+ VGA1
+ )
+
+ // ISA Option ROMs
+ DWORDMEMORY( // for device ROMs for ISA plugins devices
+ ResourceProducer, // bit 0 of general flags is 0
+ PosDecode,
+ MinFixed, // Range is fixed
+ MaxFixed, // Range is Fixed
+ NonCacheable,
+ ReadWrite,
+ 0x00000000, // Granularity
+ 0x000c0000, // Min
+ 0x000dffff, // Max
+ 0x00000000, // Translation
+ 0x00020000 // Range Length
+ )
+
+ // Memory < 4GB
+ DWORDMEMORY( // Consumed-and-produced resource(all of memory space)
+ ResourceProducer, // bit 0 of general flags is 0
+ PosDecode, // positive Decode
+ MinFixed, // Range is fixed
+ MaxFixed, // Range is fixed
+ Cacheable,
+ ReadWrite,
+ 0x00000000, // Granularity
+ 0x02000000, // Min (calculated dynamically)
+ 0xffdfffff, // Max = 4GB - 2MB
+ 0x00000000, // Translation
+ 0xfdfc0000, // Range Length (calculated dynamically)
+ , // Optional field left blank
+ , // Optional field left blank
+ MEM3 // Name declaration for this descriptor
+ )
+
+ // Memory > 4GB
+ QWORDMEMORY( // descriptor for MMIO ABOVE 4G
+ ResourceProducer, // bit 0 of general flags is 0
+ PosDecode,
+ MinFixed, // Range is fixed
+ MaxFixed, // Range is Fixed
+ Cacheable,
+ ReadWrite,
+ 0x00000000, // Granularity
+ 0x00000000, // Min
+ 0x00000000, // Max
+ 0x00000000, // Translation
+ 0x00000000, // Range Length
+ ,,
+ MEM8
+ )
+
+ })//End resource template Name CRS1
+
+
+ //Resource buffer to be used for NONE COMPATIBILITY ROOT BRIDGE
+ Name(CRS2, ResourceTemplate() {
+ WORDBusNumber( //Bus number resource (0); the bridge produces bus numbers for its subsequent buses
+ ResourceProducer, // bit 0 of general flags is 1
+ MinFixed, // Range is not fixed
+ MaxFixed, // Range is not fixed
+ PosDecode, // PosDecode
+ 0x0000, // Granularity
+ 0x0080, // Min
+ 0x00ff, // Max; half of the available bus numbers are reserved for this root bus
+ 0x0000, // Translation
+ 0x0080, // Range Length
+ ,,
+ BUS2
+ )
+
+ // For Legacy Video IO (3B0 - 3DF)
+ WORDIO( //Consumed-and-produced resource (Used for legacy video)
+ ResourceProducer, // bit 0 of general flags is 0
+ MinFixed, // Range is fixed
+ MaxFixed, // Range is fixed
+ PosDecode,
+ EntireRange,
+ 0x0000, // Granularity
+ 0x0000, // Min
+ 0x0000, // Max
+ 0x0000, // Translation
+ 0x0000, // Range Length
+ ,,
+ VIO2
+ )
+
+ // Other IO used by this root bridge
+ WORDIO( //Consumed-and-produced resource
+ ResourceProducer, // bit 0 of general flags is 0
+ MinFixed, // Range is fixed
+ MaxFixed, // Range is fixed
+ PosDecode,
+ EntireRange,
+ 0x0000, // Granularity
+ 0x0000, // Min
+ 0x0000, // Max
+ 0x0000, // Translation
+ 0x0000, // Range Length
+ ,,
+ IOW3
+ )
+
+ // For Legacy Video Memory (A000 - BFFF)
+ DWORDMEMORY( // descriptor for video RAM behind ISA bus
+ ResourceProducer, // bit 0 of general flags is 0
+ PosDecode,
+ MinFixed, // Range is fixed
+ MaxFixed, // Range is Fixed
+ Cacheable,
+ ReadWrite,
+ 0x00000000, // Granularity
+ 0x00000000, // Min
+ 0x00000000, // Max
+ 0x00000000, // Translation
+ 0x00000000, // Range Length
+ ,,
+ VGA2
+ )
+
+ // Memory < 4GB
+ DWORDMEMORY( // descriptor for video RAM behind ISA bus
+ ResourceProducer, // bit 0 of general flags is 0
+ PosDecode,
+ MinFixed, // Range is fixed
+ MaxFixed, // Range is Fixed
+ Cacheable,
+ ReadWrite,
+ 0x00000000, // Granularity
+ 0x80000000, // Min
+ 0xffffffff, // Max
+ 0x00000000, // Translation
+ 0x80000000, // Range Length
+ ,,
+ MEM1
+ )
+
+ // Memory > 4GB
+ QWORDMEMORY( // descriptor for MMIO ABOVE 4G
+ ResourceProducer, // bit 0 of general flags is 0
+ PosDecode,
+ MinFixed, // Range is fixed
+ MaxFixed, // Range is Fixed
+ Cacheable,
+ ReadWrite,
+ 0x00000000, // Granularity
+ 0x00000000, // Min
+ 0x00000000, // Max
+ 0x00000000, // Translation
+ 0x00000000, // Range Length
+ ,,
+ MEM9
+ )
+ } ) //End resource template Name CRS2
+
+ Method(_STA, 0){
+ Return(STAV)
+ }
+
+ Method(_CRS, 0) {
+
+ //breakpoint
+
+
+ //This is for compatibility bridges
+ If(CPRB){
+
+ //Bus Range
+ CreateWordField(CRS1, ^BUS1._MIN, MIN0) // Min
+ CreateWordField(CRS1, ^BUS1._MAX, MAX0) // Max
+ CreateWordField(CRS1, ^BUS1._LEN, LEN0) // Length
+
+ Store(BRB, MIN0)
+ Store(BRL, LEN0)
+ Store(LEN0,Local0)
+ Add(MIN0, Decrement(Local0), MAX0)
+
+ //Update Upper IO from 0x0D00 up to IOB+IOL
+ CreateWordField(CRS1, ^IOW2._MIN, MIN1) // Min
+ CreateWordField(CRS1, ^IOW2._MAX, MAX1) // Max
+ CreateWordField(CRS1, ^IOW2._LEN, LEN1) // Length
+
+
+ If(LEqual(IOB, 0x1000)){
+ Store(IOL, Local0)
+ Add(IOB, Decrement(Local0), MAX1)
+ Subtract(MAX1,MIN1,Local0)
+ Add(Local0,1,LEN1)
+ } else {
+ Store(IOB, MIN1)
+ Store(IOL, LEN1)
+ Store(LEN1,Local0)
+ Add(MIN1, Decrement(Local0), MAX1)
+ }
+
+ If(LOr(LEqual(LVGA,1),LEqual(LVGA,0x55))){
+ if(VGAF){//will update this only once.
+ CreateWordField(CRS1, ^VIO1._MIN, IMN1) // Min
+ CreateWordField(CRS1, ^VIO1._MAX, IMX1) // Max
+ CreateWordField(CRS1, ^VIO1._LEN, ILN1) // Length
+
+ Store(0x03b0, IMN1)
+ Store(0x03df, IMX1)
+ Store(0x0030, ILN1)
+
+ CreateDWordField(CRS1, ^VGA1._MIN, VMN1) // Min
+ CreateDWordField(CRS1, ^VGA1._MAX, VMX1) // Max
+ CreateDWordField(CRS1, ^VGA1._LEN, VLN1) // Length
+
+ Store(0x000a0000, VMN1)
+ Store(0x000bffff, VMX1)
+ Store(0x00020000, VLN1)
+ Store(0, VGAF)
+ }
+ }
+
+ //Update MMIO Below 4G
+ CreateDWordField(CRS1, ^MEM3._MIN, MIN3) // Min
+ CreateDWordField(CRS1, ^MEM3._MAX, MAX3) // Max
+ CreateDWordField(CRS1, ^MEM3._LEN, LEN3) // Length
+
+ Store(MBB, MIN3)
+ Store(MBL, LEN3)
+ Store(LEN3,Local0)
+ Add(MIN3, Decrement(Local0), MAX3)
+
+ If(LOr(MALH,MALL)){
+ CreateDWordField(CRS1, ^MEM8._MIN, MN8L) // Min_LO
+ Add(^MEM8._MIN,4,Local0)
+ CreateDWordField(CRS1, Local0, MN8H) // Min_HI
+ Store(MABL, MN8L)
+ Store(MABH, MN8H)
+
+ CreateDwordField(CRS1, ^MEM8._MAX, MX8L) // Max_LO
+ Add(^MEM8._MAX,4,Local1)
+ CreateDWordField(CRS1, Local1, MX8H) // Max_HI
+
+ CreateDwordField(CRS1, ^MEM8._LEN, LN8L) // Len_LO
+ Add(^MEM8._LEN,4,Local2)
+ CreateDWordField(CRS1, Local2, LN8H) // Len_HI
+
+ //Update fields.
+ //1. _MIN 64bits...
+ Store(MABL, MN8L)
+ Store(MABH, MN8H)
+ //2. _LEN 64Bits
+ Store(MALL, LN8L)
+ Store(MALH, LN8H)
+ //2. _MAX 64Bits
+ Store(MAML, MX8L)
+ Store(MAMH, MX8H)
+ }
+
+ Return(CRS1)
+ } else {
+ //Bus Range
+ CreateWordField(CRS2, ^BUS2._MIN, MIN2) // Min
+ CreateWordField(CRS2, ^BUS2._MAX, MAX2) // Max
+ CreateWordField(CRS2, ^BUS2._LEN, LEN2) // Length
+
+ Store(BRB, MIN2)
+ Store(BRL, LEN2)
+ Store(LEN2,Local1)
+ Add(MIN2, Decrement(Local1), MAX2)
+
+ //Update Upper IO from IOB up to IOB+IOL
+ CreateWordField(CRS2, ^IOW3._MIN, MIN4) // Min
+ CreateWordField(CRS2, ^IOW3._MAX, MAX4) // Max
+ CreateWordField(CRS2, ^IOW3._LEN, LEN4) // Length
+
+ Store(IOB, MIN4)
+ Store(IOL, LEN4)
+ Store(LEN4,Local1)
+ Add(MIN4, Decrement(Local1), MAX4)
+
+ If(LVGA){
+ CreateWordField(CRS2, ^VIO2._MIN, IMN2) // Min
+ CreateWordField(CRS2, ^VIO2._MAX, IMX2) // Max
+ CreateWordField(CRS2, ^VIO2._LEN, ILN2) // Length
+
+ Store(0x03b0, IMN2)
+ Store(0x03df, IMX2)
+ Store(0x0030, ILN2)
+
+ CreateDWordField(CRS2, ^VGA2._MIN, VMN2) // Min
+ CreateDWordField(CRS2, ^VGA2._MAX, VMX2) // Max
+ CreateDWordField(CRS2, ^VGA2._LEN, VLN2) // Length
+
+ Store(0x000a0000, VMN2)
+ Store(0x000bffff, VMX2)
+ Store(0x00020000, VLN2)
+ }
+
+ //Update MMIO Below 4G
+ CreateDWordField(CRS2, ^MEM1._MIN, MIN5) // Min
+ CreateDWordField(CRS2, ^MEM1._MAX, MAX5) // Max
+ CreateDWordField(CRS2, ^MEM1._LEN, LEN5) // Length
+
+ Store(MBB, MIN5)
+ Store(MBL, LEN5)
+ Store(LEN5,Local1)
+ Add(MIN5, Decrement(Local1), MAX5)
+
+ //Update Above 4G memory space if any
+ If(LOr(MALH, MALL)){
+ CreateDWordField(CRS2, ^MEM9._MIN, MN9L) // Min_LO
+ Add(^MEM9._MIN,4,Local0)
+ CreateDWordField(CRS2, Local0, MN9H) // Min_HI
+
+ CreateDwordField(CRS2, ^MEM9._MAX, MX9L) // Max_LO
+ Add(^MEM9._MAX,4,Local1)
+ CreateDWordField(CRS2, Local1, MX9H) // Max_HI
+
+ CreateDwordField(CRS2, ^MEM9._LEN, LN9L) // Len_LO
+ Add(^MEM9._LEN,4,Local2)
+ CreateDWordField(CRS2, Local2, LN9H) // Len_HI
+
+ //Update fields.
+ //1. _MIN 64bits...
+ Store(MABL, MN9L)
+ Store(MABH, MN9H)
+ //2. _LEN 64Bits
+ Store(MALL, LN9L)
+ Store(MALH, LN9H)
+ //2. _MAX 64Bits
+ Store(MAML, MX9L)
+ Store(MAMH, MX9H)
+ }
+
+ Return(CRS2)
+ }
+
+ } // end ROOT BRIDGE PCIx._CRS Method
+//----------------------------------------------------------------------------
+
+//****************************************************************************
+//****************************************************************************
+//** **
+//** (C)Copyright 1985-2010, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+//** **
+//** Phone (770)-246-8600 **
+//** **
+//****************************************************************************
+//****************************************************************************
diff --git a/Core/EM/ACPI/SMB_EC.ASL b/Core/EM/ACPI/SMB_EC.ASL
new file mode 100644
index 0000000..b82bdfb
--- /dev/null
+++ b/Core/EM/ACPI/SMB_EC.ASL
@@ -0,0 +1,91 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/SMB_EC.ASL 2 3/26/09 4:53p Oleksiyy $
+//
+// $Revision: 2 $
+//
+// $Date: 3/26/09 4:53p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/SMB_EC.ASL $
+//
+// 2 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:42p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 2 9/06/02 10:53a Alexp
+// Add SourceSafe headers to all core asl files
+//
+//
+//**********************************************************************;
+//**********************************************************************;
+// DON'T CHANGE ANY NAMES UNLESS REQUIRED !!!
+//**********************************************************************;
+// ACPI Embedded controller SMBus interface methods
+//**********************************************************************;
+
+// SMBR - SMBus read method
+//
+// Arg0 - Device address
+// Arg1 - Command Code
+// Arg2 - Data to write
+// Arg3 - Protocol (basically RDWD, WRWD or RDBL)
+
+ Method(SMBR,4) {
+ If (LEqual(Arg3,RDBL)) {Store(0,DATB)}
+ Store(5, Local0)
+ While(Local0) {
+ Store(Arg0, ADDR) // Set the device address
+ Store(Arg1, SCMD) // Read Power unit value 0x3 offset
+ If (LEqual(Arg3, WRWD)) {Store(Arg2, DAT0)}
+ Store(Arg3, PRTC) // Set protocol - start SMBus transaction
+ Wait(SMBF, 0xFFF) // Wait till SMBus transaction completed
+
+ Reset(SMBF)
+
+// One of known problems - ReadBlock of GLW SmartBattery may return BCNT=3
+// and data as FF FF FF with no any SMBus errors. To avoid this:
+// If(Or(SSTS,And(LEqual(Arg2,RDBL),And(LEqual(BCNT,3),LEqual(DAT0,0xFFFF)))))
+ If(SSTS)
+ {Decrement(Local0)} // If any SMBus error
+
+ Else {
+ Return(Ones) // exit on OK
+ }
+ }
+ Return(Zero) // exit on failure
+ }
+
+//**********************************************************************;
+// *****************************************************************;
+// *****************************************************************;
+// ** **;
+// ** (C)Copyright 1985-1996, American Megatrends, Inc. **;
+// ** **;
+// ** All Rights Reserved. **;
+// ** **;
+// ** 6145-F Northbelt Pkwy, Norcross, GA 30071 **;
+// ** **;
+// ** Phone (770)-246-8600 **;
+// ** **;
+// *****************************************************************;
+// *****************************************************************;
diff --git a/Core/EM/ACPI/TimeAndAlarm.asl b/Core/EM/ACPI/TimeAndAlarm.asl
new file mode 100644
index 0000000..31ecd78
--- /dev/null
+++ b/Core/EM/ACPI/TimeAndAlarm.asl
@@ -0,0 +1,523 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2014, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+// $Header: /Alaska/BIN/Modules/ACPI/Template/Core/TimeAndAlarm.asl 1 1/23/14 5:25p Oleksiyy $
+//
+// $Revision: 1 $
+//
+// $Date: 1/23/14 5:25p $
+
+
+
+ // !!! IMPORTANT !!! !!! IMPORTANT !!! !!! IMPORTANT !!! !!! IMPORTANT !!!
+ // This is an example of ACPI Time and Alarm Device implementation, proven to be working on Sharkbay platform.
+ // On different platforms this code may not work "as is" and may require light or heavy modification
+
+
+ // ACPI RTC device
+ //
+ // Note: we assume 24-hr mode and date/time in BCD.
+
+ Device(TAAD)
+ {
+ Name (_HID, "ACPI000E")
+ Name (_CID, "ACPI000E")
+ Name (_UID, 1)
+
+ Name(PRWP, Package(){Zero, 4})
+ Method(_PRW, 0) { Return(PRWP) } // can wakeup from S4 state
+
+ Name (TMZN, 2047) // Timezone - set to 2047 to indicate value not specified. Will be used if no buffer for SMI was found
+ Name (DAYL, 0) // daylight - bit field to indicate daylight adjustment requirement. Will be used if no buffer for SMI was found
+ Name (ALWS, 0xF) // Init Alarm wake status - Stores alarm wake status; 0xF to indicate contents are invalid
+
+ Name (ATBF, 0x100000000) //Adress of communication buffer
+ Name (BUFU, 0x0) //Indicator that buffer was allocated and usable.
+
+ //Mutex used to synchronize between methods accessing RTC
+ Mutex(RTCL, 0)
+
+ // Region for SW SMI port
+ OperationRegion (CSMI, SystemIO, SMIP , 0x1)
+ Field (CSMI, ByteAcc, NoLock, Preserve)
+ {
+ INQ,8
+ }
+
+ OperationRegion (ADPS, SystemIO, PMBS, 4)
+ Field (ADPS, ByteAcc,NoLock,Preserve)
+ {
+ PMS, 16,
+ PMEN, 16
+ }
+
+ // Regions for SW SMI data buffer. Need two, one for byte access, one for nibble access.
+ OperationRegion (DSMI, SystemMemory, ATBF, 0x4)
+ Field (DSMI, AnyAcc, NoLock, Preserve)
+ {
+ BSTA, 8,
+ BDLY, 8,
+ BTZN, 16
+ }
+
+
+ OperationRegion(VRTC, SystemCMOS, 0, 0x10)
+ Field(VRTC, ByteAcc, Lock, Preserve)
+ {
+
+ SEC, 8,
+ SECA, 8,
+
+ MIN, 8,
+ MINA, 8,
+
+ HOR, 8,
+ HORA, 8,
+
+ DAYW, 8,
+ DAY, 8,
+
+ MON, 8,
+ YEAR, 8,
+
+ STAA, 8,
+ STAB, 8,
+ STAC, 8,
+ STAD, 8
+ }
+
+ Method(_S1W, 0) {
+ return (0)
+ }
+ Method(_S2W, 0) {
+ return (0)
+ }
+ Method(_S3W, 0) {
+ return (3)
+ }
+ Method(_S4W, 0) {
+ return (3)
+ }
+
+ Method(_DSW, 3) {
+
+ // Disable the device's wake capabilities
+ if( LEqual(Arg0, 0) ) {
+ And(PMEN, 0x0400, PMEN)
+ }
+ if( LEqual(Arg0, 1) ) {
+ if( LLessEqual(Arg1, 4) ){
+ Or(PMEN, 0x400, PMEN)
+ }
+ }
+ return
+ }
+
+ // RTC Allow Update
+ Method (ALLW, 0x0, Serialized) {
+ Acquire(RTCL, 2000)
+
+ And(STAB, 0x7F, STAB)
+
+ Release(RTCL)
+ Return (One)
+ }
+
+ // RTC Inhibit Update
+ Method (INHB, 0x00, Serialized) {
+ Acquire(RTCL, 2000)
+ Or(STAB, 0x80, STAB)
+ Release(RTCL)
+ Return (One)
+ }
+
+ Method (RTWT, 0x00) {
+ Acquire(RTCL, 2000)
+
+ // Loop until an update completes (the Update-Ended Flag (UF) is set)
+ While( LNotEqual(And(STAC, 0x10), 0x10 )){
+ NoOp
+ }
+
+ Release(RTCL)
+ return (One)
+ }
+
+ // Get Capability
+ // This object is required and provides the OSPM with a bit mask of the device capabilities. The device
+ // can implement the time function inaddition to the wake function. The capabilities bitmask will
+ // indicate to the OSPM what support is implemented. If the platform implements both AC and DC
+ // timers then it is capable of waking up based on the power source
+
+ // Only AC timer here, so it will be the wake source regardless of the power source
+ Method (_GCP, 0x0, NotSerialized)
+ {
+ //Store(0x11, DBG8)
+ Return (0x5) //Get/Set real time features implemented, real time accuracy in seconds and AC timer only;
+ }
+
+
+ // Get Real time Method
+ // This object is required ifthe capabilities bit 2 is set to 1. The OSPM can use this object to get time.
+ // The return value is a buffer containing the time information
+ Method (_GRT, 0x0, Serialized)
+ {
+ Name(RBUF, Buffer(16) {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}) //Buffer of 16 bytes - return value
+
+ // Create fields to address different offsets in the buffer
+ CreateWordField(RBUF, 0x0, TYAR)
+ CreateByteField(RBUF, 0x2, TMON)
+ CreateByteField(RBUF, 0x3, TDAY)
+ CreateByteField(RBUF, 0x4, THOR)
+ CreateByteField(RBUF, 0x5, TMIN)
+ CreateByteField(RBUF, 0x6, TSEC)
+ CreateByteField(RBUF, 0x7, TVAL) // Time Valid if 1, not valid if 0
+ CreateWordField(RBUF, 0xA, TZN) // Timezone not supported through rRTC - return value stored in ASL
+ CreateByteField(RBUF, 0xC, DYL) // Daylight not supported through rRTC - emulate in ASL
+
+ if (BUFU)
+ {
+ // Read value from NVRAM
+ Store (0x01, BSTA)
+ Store (ATAA, INQ)
+ Sleep (100)
+
+ if( LEqual(BSTA, 0x03 ) ) {
+ Store (BDLY, DAYL)
+ Store (BTZN, TMZN)
+ } else {
+ Store(2047, TMZN)
+ Store (0, DAYL)
+ }
+ }
+
+ RTWT()
+
+ FromBCD(YEAR, TYAR) // Get Year
+ FromBCD (MON, TMON) // Get Month
+ FromBCD (DAY, TDAY) // Get Day
+ FromBCD (HOR, THOR)
+ FromBCD (MIN, TMIN)
+ FromBCD (SEC, TSEC)
+
+ Store (TMZN, TZN)
+ Store (DAYL, DYL)
+
+ // we don't have centry byte
+ ADD(TYAR, 2000, TYAR)
+
+ Store (0x1, TVAL) // Data valid
+ return (RBUF)
+ }
+
+ // Set Real Time
+ // This object is required if the capabilities bit 2 is set to 1. The OSPM can use this object to set the
+ // time. The argument is a buffer containingthe time information
+
+ Method (_SRT, 0x1, Serialized)
+ {
+ CreateWordField(Arg0, 0x0, TYAR)
+ CreateByteField(Arg0, 0x2, TMON)
+ CreateByteField(Arg0, 0x3, TDAY)
+ CreateByteField(Arg0, 0x4, THOR)
+ CreateByteField(Arg0, 0x5, TMIN)
+ CreateByteField(Arg0, 0x6, TSEC)
+ CreateWordField(Arg0, 0xA, TZN) // Timezone not supported through rRTC - return value stored in ASL
+ CreateByteField(Arg0, 0xC, DYL) // Daylight not supported through rRTC
+
+ // TODO: Adjust the timezone, daylight, date and time based on the daylight bitmask
+
+ if (BUFU)
+ {
+ // Send Daylight to NVRAM
+ Store (0x2, BSTA)
+ Store (DYL, BDLY)
+ Store (TZN, BTZN)
+
+ Store (ATAA, INQ)
+ }
+
+ RTWT()
+
+ ToBCD(Subtract(TYAR, 2000), YEAR)
+ ToBCD (TMON, MON) // Set month
+ ToBCD (TDAY, DAY) // Set day
+ ToBCD (THOR, HOR) // Set hour
+ ToBCD (TMIN, MIN) // Set minute
+ ToBCD (TSEC, SEC) // Set second
+
+ Store (TZN, TMZN)
+ Store (DYL, DAYL)
+
+ If(LEqual(BSTA, 0x3)) // SMI handler set status to OK
+ {
+ return (0x0) // return success
+ }
+
+ return (0xFFFFFFFF) // return error
+ }
+
+ // Get wake Status
+ //This object is required and enables the OSPM to read the status ofwake alarms. Expired wake timers
+ //will wake the platform even if the transition to a sleep state was completed after the wake timer has
+ //expired. This method enables the OSPM to retrieve the status of wake timers and clear any of them if
+ //needed.
+
+ Method (_GWS, 0x1, Serialized)
+ {
+ // From the ACPI specification
+ // "Writes to the DC timer when AC only wake is supported will be ignored"
+ if (LEqual(0x1, Arg0)) {
+ return (0x0)
+ }
+
+ // read alarm status from Register C and remember if it was set
+ // if it wasn't set, keep alarm wake status field invalid
+ // if it was set, indicate to the OS that the alarm expired and that it woke the system.
+ // TODO: Find out if the alarm woke the system, for now assume it did (this will need usage of SMI
+ // handlers.)
+
+ if (LEqual(0xF, ALWS)) {
+ if (LAnd (STAC, 0x20)) {
+ Store (0x3, ALWS)
+ return (ALWS)
+ }
+ }
+
+ return (0x0)
+ }
+
+ // Clear Wake alarm status.
+ //This object is required and enables the OSPM to clear the status of wake alarms. Expired wake
+ //timers will wake the platform even if the transition to a sleep state was completed after the wake
+ //timer has expired. This method enables the OSPMto clear the status of expired wake timers.
+ Method (_CWS, 0x1, Serialized)
+ {
+ // From the ACPI specification
+ // "Writes to the DC timer when AC only wake is supported will be ignored"
+ if (LEqual(1, Arg0)) {
+ return (0)
+ }
+
+ RTWT()
+
+ INHB()
+ // Clear the alarm seconds, alarm minutes and alarm hours
+ Store (0x00, SECA)
+ Store (0x00, MINA)
+ Store (0x00, HORA)
+ ALLW()
+
+ // Clear the "Date Alarm" in RTC_REGD (bits 5:0)
+ And (STAD, 0x80, STAD)
+
+ // Reading Register C should clear the "Alarm Flag (AF)" (Bit5)
+ if (LEqual(0xF, ALWS)) {
+ Store (STAC, Local0)
+ }
+
+ // Disable the "Alarm Interrupt Enable" (AIE) bit in RTC_REGB
+ And(STAB, 0xDF, STAB)
+
+ // Mark ALWS invalid
+ Store (0xF, ALWS)
+
+ return (0x0)
+ }
+
+ // Sets the timer wake policy.
+
+ //This object is required and sets the expired timer wake policy.The policy is applied when a
+ //corresponding timer expired but the wake signal was not asserted as a result of the power source.
+ //The platform accumulates elapsed time on the power source and asserts the wake signal when the
+ //elapsed timer on the power source exceeds the expired timer wake policy value. Power source
+ //transitions do not reset the expired timer wake policy values. When the Wake Alarm device asserts
+ //the wake, the expired timer wake policy values ofboth the AC timer and DC timer are reset to
+ //0xFFFFFFFF automatically by hardware.
+
+ Method (_STP, 0x2, Serialized)
+ {
+ // From the ACPI specification
+ // "Writes to the DC timer when AC only wake is supported will be ignored"
+ if (LEqual(0x1, Arg0)) {
+ return (0)
+ }
+
+ //
+ if (LGreater(Arg1, 0x01)) {
+ return (0x1)
+ }
+
+ return (0x0)
+ }
+
+ // Set the value in specified timer
+
+ //This object is required and setsthe timer to the specified value. As defined in _TIV, the value
+ //indicates the number of seconds between the time when the timer is programmed and the time when
+ //it expires. When the Wake Alarm device asserts the wake signal, the timer value is automatically
+ //reset to 0xFFFFFFFF (disabled).
+ Method (_STV, 0x2, Serialized)
+ {
+ Name(THOR, 0)
+ Name(TMIN, 0)
+ Name(TSEC, 0)
+
+ // From the ACPI specification
+ // "Writes to the DC timer when AC only wake is supported will be ignored"
+ if (LEqual(0x01, Arg0)) {
+ return (0x0)
+ }
+
+
+ // RTC hours/minutes/seconds cannot be set for more than 23 hours, 59 minutes
+ // and 59 seconds in the future, otherwise we would be setting the current time
+ // and the alarm would tigger immediatly
+ if (LGreater(Arg1, 86399)) {
+ return (0x1)
+ }
+
+ // Divide the time (which is passed in seconds) into hours, minutes and seconds
+ Divide(Arg1, 60, TSEC, TMIN)
+ Divide(TMIN, 60, TMIN, THOR)
+
+ RTWT()
+ // Add the current seconds to the number of seconds in the future to set the alarm
+ // and check if its greater than 59
+ if( LGreater(Add(FromBCD(SEC), TSEC, TSEC), 59) ){
+ // It is greater than 59, so get the mod 60 and convert to BCD and store into the
+ // the seconds alarm. Increment the TMIN too
+ ToBCD(Mod(TSEC, 60), Local1)
+ INCREMENT(TMIN)
+ } else {
+ // Its less than 60, just conver to BCD and store it
+ ToBCD(TSEC, Local1)
+ }
+ Store(Local1, TSEC)
+
+ // Add the current minutes to the number of minutes in the future
+ // and check if its greater than 59
+ if( LGreater(Add(FromBCD(MIN), TMIN, TMIN), 59) ){
+ // It is greater than 59, so get the mod 60 and store it into
+ // the minutes alarm and increment the THORs
+ ToBCD(Mod(TMIN, 60), Local1)
+ INCREMENT(THOR)
+ } else {
+ // Its less than 60, just conver to BCD and store it
+ ToBCD(TMIN, Local1)
+ }
+ Store(Local1, TMIN)
+
+ // Add the current hours to the number of hours in the future
+ // and check if its greater than 24
+ if( LGreater(Add(FromBCD(HOR), THOR, THOR), 23) ){
+ // It is greater than 63, so get the mod 24 and store it into
+ // the hours alarm
+ ToBCD(Mod(THOR, 60), Local1)
+ } else {
+ ToBCD(THOR, Local1)
+ }
+ Store(Local1, THOR)
+
+ // Inhibit updating and then program the Alarm
+ INHB()
+ Store(THOR, HORA)
+ Store(TMIN, MINA)
+ Store(TSEC, SECA)
+
+ // Clear the Date Alarm in RTC_REGD (bits 5:0) to ensure they do not
+ // interfere the RTC alarm
+ And (STAD, 0x80, STAD)
+
+ // Write the Alarm Interrupt Enable (AIE) bit in RTC_REGB
+ OR(STAB, 0x20, STAB)
+ ALLW()
+
+ Or(PMEN, 0x0400, PMEN)
+ Or(PMS, 0x0400, PMS)
+
+ return (0x0)
+ }
+
+ // Get the timer wake policy of the specified timer
+ //This object returns the current expired timer wake policy setting ofthe specified timer.
+
+ // Ret Value is an Integer (DWORD) containing current expired timer wake policy:
+ //0x00000000 - The timer will wake up the system instantly after the power source changes
+ //0x00000001 - 0xFFFFFFFE: Time between the power source changes and the timer wakes up the
+ //system ( in units of seconds)
+ //0xFFFFFFFF - The timer will never wake up the system after the power source changes
+
+ Method (_TIP, 0x1, Serialized) {
+
+ if( LEqual(Arg0, 1)) {
+ return (0xFFFFFFFF)
+ }
+
+ return (0x0)
+ }
+
+
+ // Get the remaining timer value
+ Method (_TIV, 0x1, Serialized)
+ {
+ Name(TTIM, 0x00000000)
+
+ // If queried about the DC timer, return
+ if (LEqual(0x01, Arg0)) {
+ return (0xFFFFFFFF)
+ }
+
+ RTWT()
+
+ if( LGreaterEqual(HORA, HOR) ) {
+ FromBCD(Subtract(HORA, HOR), Local0)
+ } else {
+ Subtract(24, FromBCD(HOR), Local0)
+ Add(FromBCD(HORA), Local0, Local0)
+ }
+ Add(Multiply(Local0, 3600), TTIM, TTIM)
+
+ if( LGreaterEqual(MINA, MIN) ) {
+ FromBCD(Subtract(MINA, MIN), Local0)
+ } else {
+ Subtract(60, FromBCD(MIN), Local0)
+ Add(FromBCD(MINA), Local0, Local0)
+ }
+ Add(Multiply(Local0, 60), TTIM, TTIM)
+
+ if( LGreaterEqual(SECA, SEC) ) {
+ FromBCD(Subtract(SECA, SEC), Local0)
+ } else {
+ Subtract(60, FromBCD(SEC), Local0)
+ Add(FromBCD(SECA), Local0, Local0)
+ }
+ Add(Local0, TTIM, TTIM)
+
+ return (TTIM)
+ }
+ }
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2014, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//********************************************************************** \ No newline at end of file
diff --git a/Core/EM/ACPI/Uart1.asl b/Core/EM/ACPI/Uart1.asl
new file mode 100644
index 0000000..61344f7
--- /dev/null
+++ b/Core/EM/ACPI/Uart1.asl
@@ -0,0 +1,159 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Uart1.asl 7 10/01/10 3:43p Oleksiyy $
+//
+// $Revision: 7 $
+//
+// $Date: 10/01/10 3:43p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/Uart1.asl $
+//
+// 7 10/01/10 3:43p Oleksiyy
+// Issue Number: 39752
+//
+// Category: Improvement
+//
+// Description: File modified to support Status Code in Runtime by hiding
+// COM0 from OS.
+//
+// Files: Uart1.asl, Tokens.c, Runtime.c, GenericSio.c, EfiLib.c,
+// CsmLib.c, AmiDxeLib.h and StatusCode eModule.
+//
+// 6 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 5 8/03/06 12:45p Stacyh
+// Updated to allow the use of SI1P for systems with 2 SIOs. Now contains
+// generic methods assuming SI1P to be 0 as well as methods which check
+// SI1P (these are commented out).
+//
+// 4 4/21/06 12:38p Felixp
+//
+// 2 4/03/06 4:05p Felixp
+// New Super I/O infrastructure Support
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:42p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 7 03/04/07 5:41p Chung
+// Modify all I/O beta version
+//
+// 5 9/06/02 10:53a Alexp
+// Add SourceSafe headers to all core asl files
+//
+//**********************************************************************;
+// UART1 //
+// Category # :0x00
+Device(UAR1) {
+ Name(_UID, 1) //Generic ID for COMA
+
+// Use the following if not using SI1P or only have 1 SIO
+ Method(_HID, 0) {Return(^^SIO1.UHID(0))} //PnP Device ID
+ Method(_STA,0,Serialized)
+ {
+ If(And(\IOST,0x01)){
+ Return (0x0F) // UART1 device Present
+ } else {
+ Return(0x00) // Device not present
+ }
+ }
+
+ Method(_DIS, 0) {^^SIO1.DCNT(0, 0)} //Disable UART
+ Method(_CRS, 0) {Return(^^SIO1.DCRS(0, 0))} //Get UART current resources
+ Method(_SRS, 1) {^^SIO1.DSRS(Arg0, 0)} //Set UART recources
+
+// Use the following if using SI1P
+// Method(_HID, 0) { //PnP Device ID
+// if(SI1P){Return(^^SIO1.UHID(0))}
+// else{Return(^^SIO2.UHID(0))}
+// }
+// Method(_STA, 0) { //Get UART status
+// if(SI1P){Return(^^SIO1.DSTA(0))}
+// else{Return(^^SIO2.DSTA(0))}
+// }
+// Method(_DIS, 0) { //Disable UART
+// if(SI1P){^^SIO1.DCNT(0, 0)}
+// else{^^SIO2.DCNT(0, 0)}
+// }
+// Method(_CRS, 0) { //Get UART current resources
+// if(SI1P){Return(^^SIO1.DCRS(0, 0))}
+// else{Return(^^SIO2.DCRS(0, 0))}
+// }
+// Method(_SRS, 1) { //Set UART resources
+// if(SI1P){^^SIO1.DSRS(Arg0, 0)}
+// else{^^SIO2.DSRS(Arg0, 0)}
+// }
+
+//-----------------------------------------------------------------------
+// UART1 Possible Resources
+//-----------------------------------------------------------------------
+//NOTE: _PRS MUST be the NAME not a METHOD object
+//to have GENERICSIO.C working right!
+//-----------------------------------------------------------------------
+ Name(_PRS, ResourceTemplate() {
+ StartDependentFn(0, 0) {
+ IO(Decode16, 0x3F8, 0x3F8, 1, 8)
+ IRQNoFlags() {4}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3F8, 0x3F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2F8, 0x2F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3E8, 0x3E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2E8, 0x2E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ EndDependentFn()
+ })
+
+
+/*
+//---------Power Resources for UART1 -------------------------
+ PowerResource(URP1, 0, 0) { //SystemLevel Parameter=0,
+ //which means UART can be turned off
+ //in any sleep state
+ Method(_STA, 0) {
+ Return(URAP) //Get Power Status
+ } //end of _STA
+ Method(_ON) {
+ Store(1, URAP) //Power on
+ } //end of _ON
+ Method(_OFF){
+ Store(0, URAP) //Power off
+ } //end of _OFF
+ }
+ Name(_PR0, Package(){URP1}) //Reference to PowerResources
+*/
+} // End Of UAR1
+//-----------------------------------------------------------------------
diff --git a/Core/EM/ACPI/Uart1ir.asl b/Core/EM/ACPI/Uart1ir.asl
new file mode 100644
index 0000000..de5e165
--- /dev/null
+++ b/Core/EM/ACPI/Uart1ir.asl
@@ -0,0 +1,143 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Uart1ir.asl 4 3/26/09 4:53p Oleksiyy $
+//
+// $Revision: 4 $
+//
+// $Date: 3/26/09 4:53p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/Uart1ir.asl $
+//
+// 4 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 3 8/03/06 12:45p Stacyh
+// Updated to allow the use of SI1P for systems with 2 SIOs. Now contains
+// generic methods assuming SI1P to be 0 as well as methods which check
+// SI1P (these are commented out).
+//
+// 2 4/03/06 4:05p Felixp
+// New Super I/O infrastructure Support
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:42p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 7 03/04/07 5:42p Chung
+// Modify all I/O beta version
+//
+// 6 9/06/02 10:53a Alexp
+// Add SourceSafe headers to all core asl files
+//
+//**********************************************************************;
+// UART + IrDa = COMA //
+// Category # :0x00
+// Cannot be included along with UART1.ASL. Only one UART1 can be present in ASL.
+Device(UAR1) {
+ Name(_UID, 1) //Generic ID for COMA
+
+// Use the following if not using SI1P or only have 1 SIO
+ Method(_HID, 0) {Return(^^SIO1.UHID(0))} //PnP Device ID
+ Method(_STA, 0) {Return(^^SIO1.DSTA(0))} //Get UART status
+ Method(_DIS, 0) {^^SIO1.DCNT(0, 0)} //Disable UART
+ Method(_CRS, 0) {Return(^^SIO1.DCRS(0, 1))} //Get UART current resources
+ Method(_SRS, 1) {^^SIO1.DSRS(Arg0, 0)} //Set UART resources
+
+// Use the following if using SI1P
+// Method(_HID, 0) { //PnP Device ID
+// if(SI1P){Return(^^SIO1.UHID(0))}
+// else{Return(^^SIO2.UHID(0))}
+// }
+// Method(_STA, 0) { //Get UART status
+// if(SI1P){Return(^^SIO1.DSTA(0))}
+// else{Return(^^SIO2.DSTA(0))}
+// }
+// Method(_DIS, 0) { //Disable UART
+// if(SI1P){^^SIO1.DCNT(0, 0)}
+// else{^^SIO2.DCNT(0, 0)}
+// }
+// Method(_CRS, 0) { //Get UART current resources
+// if(SI1P){Return(^^SIO1.DCRS(0, 1))}
+// else{Return(^^SIO2.DCRS(0, 1))}
+// }
+// Method(_SRS, 1) { //Set UART resources
+// if(SI1P){^^SIO1.DSRS(Arg0, 0)}
+// else{^^SIO2.DSRS(Arg0, 0)}
+// }
+
+//------------------------------------------------------------------------
+// UART1/2 , IrDa Possible Resources
+//------------------------------------------------------------------------
+//NOTE: _PRS MUST be the NAME not a METHOD object
+//to have GENERICSIO.C working right!
+//-----------------------------------------------------------------------
+
+ Name(_PRS, ResourceTemplate() {
+// IRQ, No DMA
+ StartDependentFn(0, 0) {
+ IO(Decode16, 0x3F8, 0X3F8, 1, 8)
+ IRQNoFlags() {4}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0X3F8, 0X3F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2F8, 0X2F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3E8, 0X3E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2E8, 0X2E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+// DMA,IRQ
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3F8, 0X3F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {0,1,2,3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2F8, 0X2F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {0,1,2,3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3E8, 0X3E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {0,1,2,3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2E8, 0X2E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {0,1,2,3}
+ }
+ EndDependentFn()
+ })
+} // End Of UAR1
+//------------------------------------------------------------------------
diff --git a/Core/EM/ACPI/Uart2.asl b/Core/EM/ACPI/Uart2.asl
new file mode 100644
index 0000000..eda0bb6
--- /dev/null
+++ b/Core/EM/ACPI/Uart2.asl
@@ -0,0 +1,137 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Uart2.asl 4 3/26/09 4:53p Oleksiyy $
+//
+// $Revision: 4 $
+//
+// $Date: 3/26/09 4:53p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/Uart2.asl $
+//
+// 4 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 3 8/03/06 12:45p Stacyh
+// Updated to allow the use of SI1P for systems with 2 SIOs. Now contains
+// generic methods assuming SI1P to be 0 as well as methods which check
+// SI1P (these are commented out).
+//
+// 2 4/03/06 4:05p Felixp
+// New Super I/O infrastructure Support
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:42p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 7 03/04/07 5:42p Chung
+// Modify all I/O beta version
+//
+// 5 9/06/02 10:53a Alexp
+// Add SourceSafe headers to all core asl files
+//
+//**********************************************************************;
+// UART2 - COMB or Infrared //
+// Requires Uart1(ir).asl component present as well
+// Category # :0x01
+Device(UAR2) {
+ Name(_UID, 2) //Generic ID for COMB
+
+// Use the following if not using SI1P or only have 1 SIO
+ Method(_HID, 0) {Return(^^SIO1.UHID(1))} //PnP Device ID
+ Method(_STA, 0) {Return(^^SIO1.DSTA(1))} //Get UART status
+ Method(_DIS, 0) {^^SIO1.DCNT(1, 0)} //Disable UART
+ Method(_CRS, 0) {Return(^^SIO1.DCRS(1, 0))} //Get UART current resources
+ Method(_SRS, 1) {^^SIO1.DSRS(Arg0, 1)} //Set UART resources
+
+// Use the following if using SI1P
+// Method(_HID, 0) { //PnP Device ID
+// if(SI1P){Return(^^SIO1.UHID(1))}
+// else{Return(^^SIO2.UHID(1))}
+// }
+// Method(_STA, 0) { //Get UART status
+// if(SI1P){Return(^^SIO1.DSTA(1))}
+// else{Return(^^SIO2.DSTA(1))}
+// }
+// Method(_DIS, 0) { //Disable UART
+// if(SI1P){^^SIO1.DCNT(1, 0)}
+// else{^^SIO2.DCNT(1, 0)}
+// }
+// Method(_CRS, 0) { //Get UART current resources
+// if(SI1P){Return(^^SIO1.DCRS(1, 0))}
+// else{Return(^^SIO2.DCRS(1, 0))}
+// }
+// Method(_SRS, 1) { //Set UART resources
+// if(SI1P){^^SIO1.DSRS(Arg0, 1)}
+// else{^^SIO2.DSRS(Arg0, 1)}
+// }
+
+//------------------------------------------------------------------------
+// UART2 Possible Resources
+//------------------------------------------------------------------------
+//NOTE: _PRS MUST be the NAME not a METHOD object
+//to have GENERICSIO.C working right!
+//-----------------------------------------------------------------------
+
+ Name(_PRS, ResourceTemplate() {
+ StartDependentFn(0, 0) {
+ IO(Decode16, 0x2F8, 0x2F8, 1, 8)
+ IRQNoFlags() {3}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3F8, 0x3F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2F8, 0x2F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3E8, 0x3E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2E8, 0x2E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ EndDependentFn()
+ })
+
+
+/*
+//---------Power Resources for UART2 -------------------------
+ PowerResource(URP2, 0, 0) { //SystemLevel Parameter=0,
+ Method(_STA, 0) {
+ Return(URBP) //Get Power Status
+ } //end of _STA
+ Method(_ON) {
+ Store(1, URBP) //Power on
+ } //end of _ON
+ Method(_OFF){
+ Store(0, URBP) //Power off
+ } //end of _OFF
+ }
+ Name(_PR0, Package(){URP2}) //Reference to PowerResources
+*/
+} // End Of UAR2
diff --git a/Core/EM/ACPI/Uart2ir.asl b/Core/EM/ACPI/Uart2ir.asl
new file mode 100644
index 0000000..5aa5b86
--- /dev/null
+++ b/Core/EM/ACPI/Uart2ir.asl
@@ -0,0 +1,467 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Uart2ir.asl 7 3/26/09 4:53p Oleksiyy $
+//
+// $Revision: 7 $
+//
+// $Date: 3/26/09 4:53p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/Uart2ir.asl $
+//
+// 7 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 6 4/09/08 5:05p Yakovlevs
+//
+// 5 9/18/07 10:13a Pats
+// Removed unnecessary decode range code.
+//
+// 4 3/30/07 12:00p Pats
+// Modified to support Fast IR.
+//
+// 3 8/03/06 12:45p Stacyh
+// Updated to allow the use of SI1P for systems with 2 SIOs. Now contains
+// generic methods assuming SI1P to be 0 as well as methods which check
+// SI1P (these are commented out).
+//
+// 2 4/03/06 4:05p Felixp
+// New Super I/O infrastructure Support
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:42p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 6 03/04/07 5:42p Chung
+// Modify all I/O beta version
+//
+// 5 9/06/02 10:53a Alexp
+// Add SourceSafe headers to all core asl files
+//
+//**********************************************************************;
+// UART2 - COMB or Infrared //
+// Requires Uart1(ir).asl component present as well
+// Cannot be included along with UART2.ASL. Only one UART2 Device can be present in ASL.
+// Category # :0x01
+Device(UAR2) // SMSC N207 UART 2.
+{
+
+OperationRegion(IOID, // Name of Operation Region for SuperIO device
+ SystemIO, // Type of address space
+ SP1O, // Offset to start of region
+ 2) // Size of region in bytes
+ // End of Operation Region
+Field(IOID, ByteAcc, NoLock,Preserve){
+ INDX, 8, // Field named INDX is 8 bit wide
+ DATA, 8 // Field DATA is 8 bit wide
+}
+
+
+//----------------------------------------------------------------------
+// Set of Field names to be used to access SIO configuration space.
+//----------------------------------------------------------------------
+IndexField(INDX, DATA, ByteAcc, NoLock, Preserve){
+ Offset(0x02),
+ CR02, 8, // UART Power Management
+ Offset(0x0C),
+ CR0C, 8, // UARTMODE
+ Offset(0x24),
+ CR24, 8, // UART 1 Base Address
+ CR25, 8, // UART 2 Base Address
+ Offset(0x28),
+ CR28, 8, // UART IRQ Select
+ Offset(0x2B),
+ CR2B, 8, // FIR Base address
+ CR2C, 8, // FIR DMA
+ Offset(0x3A),
+ CR3A, 8, // LPC Docking Activate
+ CR3B, 8, // LPC Docking Base (High)
+ CR3C, 8, // LPC Docking Base (Low)
+// Offset(0x55),
+// CR55, 8, // Configuration Enable Key
+// Offset(0xAA),
+// CRAA, 8 // Configuration Disable Key
+} //End of indexed field
+
+
+//------------------------------------------------------------------------
+// Entry Config Mode
+//------------------------------------------------------------------------
+Method(ENFG) {
+ Store(0x55, INDX)
+}
+
+
+//------------------------------------------------------------------------
+// Exit Config Mode
+//------------------------------------------------------------------------
+Method(EXFG, 0) {
+ Store(0xAA, INDX)
+}
+
+ // Identify UART 2 as an IR Device.
+ Name(_UID, 2) //Generic ID for COMA
+// Name(_HID, EISAID("PNP0510"))
+
+ Method(_HID, 0){
+ ENFG()
+ And(CR0C, 0x18, Local0)
+ Store(CR2B, Local1)
+ EXFG()
+ If(Local0){
+ If(Local1)
+ {Return(EISAID("SMCF010"))} //PnP Device ID FIR Type
+ Else
+ {Return(EISAID("PNP0510"))} //PnP Device ID InfraRed Type
+ }Else
+ {Return(EISAID("PNP0501"))} //PnP Device ID 16550 Type
+ }
+
+
+ // Status Method for UART 2.
+ Method(_STA,0,Serialized)
+ {
+ //
+ //Check SIR Base Address, If ADR9 and ADR8 are 0, SIR disabled.
+ //
+
+ If(And(\IOST,0x02)){
+ Return (0x0F) // UART2 device Present
+ } else {
+ Return(0x00) // Device not present
+ }
+
+ }
+
+ // Disable Method for UART 2.
+ Method(_DIS,0,Serialized)
+ {
+ ENFG()
+ Store(And(CR02,0x0F),CR02)
+ EXFG()
+ }
+
+
+ //
+ // Current Resource Setting Method for UART 2.
+ //
+ Method(_CRS,0,Serialized)
+ {
+
+ ENFG()
+ Store(CR2B, Local0)
+ EXFG()
+ If(Local0)
+ {
+ // Create the FIR Buffer that stores the Resources to
+ // be returned.
+ Name(BUF0,ResourceTemplate()
+ {
+ IO(Decode16, 0x0000, 0x0000, 0x01, 0x08)
+ IO(Decode16, 0x0000, 0x0000, 0x01, 0x08)
+ IRQNoFlags() {7}
+ DMA(Compatibility, NotBusMaster, Transfer8, ) {2}
+ })
+
+ // Create pointers to the specific byte.
+ //
+ CreateByteField(BUF0,0x02,IO10)
+ CreateByteField(BUF0,0x03,IO11)
+ CreateByteField(BUF0,0x04,IO12)
+ CreateByteField(BUF0,0x05,IO13)
+ CreateByteField(BUF0,0x0a,IO20)
+ CreateByteField(BUF0,0x0b,IO21)
+ CreateByteField(BUF0,0x0c,IO22)
+ CreateByteField(BUF0,0x0d,IO23)
+ CreateWordField(BUF0,0x11,IRQW)
+ CreateByteField(BUF0,0x14,DMA0)
+
+ ENFG()
+
+ //
+ // Write the Base Address into the Buffer.
+ //
+ ShiftLeft(CR25,2,IO10) // Low Byte.
+ ShiftRight(And(CR25,0xC0), 6, IO11)
+ Store(IO10, IO12)
+ Store(IO11, IO13)
+
+ ShiftLeft(CR2B,3,IO20) // Low Byte.
+ ShiftRight(And(CR2B,0xE0), 5, IO21)
+ Store(IO20, IO22)
+ Store(IO21, IO23)
+
+ //
+ // Write the IRQ value into the Buffer.
+ //
+ Store(0x0,Local1)
+ And(CR28,0x0F,Local1)
+ ShiftLeft(1, Local1, IRQW)
+
+ // Write DMA value into buffer
+ Store(0x0,Local1)
+ And(CR2C,0x0F,Local1)
+ If(LEqual(Local1, 0x0F)){
+ Store(0, DMA0) //No DMA
+ }Else{
+ ShiftLeft(1, Local1, DMA0)
+ }
+
+ EXFG()
+
+ Return(BUF0)
+ }
+ Else
+ {
+ // Create the SIR Buffer that stores the Resources to
+ // be returned.
+ Name(BUF1,ResourceTemplate()
+ {
+ IO(Decode16,0x0000, 0x0000, 0x01, 0x08)
+ IRQNoFlags(){7}
+ })
+
+ // Create pointers to the specific byte.
+ //
+ CreateByteField(BUF1,0x02,IOL0)
+ CreateByteField(BUF1,0x03,IOL1)
+ CreateByteField(BUF1,0x04,IOL2)
+ CreateByteField(BUF1,0x05,IOL3)
+ CreateWordField(BUF1,0x09,IRQR)
+
+ ENFG()
+
+ //
+ // Write the Base Address into the Buffer.
+ //
+ ShiftLeft(CR25,2,IOL0) // Low Byte.
+ ShiftRight(And(CR25,0xC0), 6, IOL1)
+ Store(IOL0, IOL2)
+ Store(IOL0, IOL3)
+
+ //
+ // Write the IRQ value into the Buffer.
+ //
+ Store(0x0,Local1)
+ And(CR28,0x0F,Local1)
+ ShiftLeft(One,Local1,IRQR)
+
+ EXFG()
+
+ Return(BUF1)
+ }
+ }
+
+ //
+ // Possible Resource Setting Method for UART 2.
+ //
+ Name(_PRS, ResourceTemplate() {
+// IRQ, No DMA
+ StartDependentFn(0, 0)
+ {
+ IO(Decode16,0x3E8,0x3E8,0x01,0x08)
+ IRQNoFlags(){7}
+ }
+
+ StartDependentFnNoPri()
+ {
+ IO(Decode16,0x2F8,0x2F8,0x01,0x08)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ }
+
+ StartDependentFnNoPri()
+ {
+ IO(Decode16,0x3F8,0x3F8,0x01,0x08)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ }
+
+ StartDependentFnNoPri()
+ {
+ IO(Decode16,0x2E8,0x2E8,0x01,0x08)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ }
+
+//IRA and DMA
+ StartDependentFn(0, 0) {
+ IO(Decode16,0x3E8,0x3E8,0x01,0x08)
+ IO(Decode16,0x7E8,0x7E8,0x01,0x08)
+ IRQNoFlags(){7}
+ DMA(Compatibility, NotBusMaster, Transfer8) {3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3F8, 0x3F8, 1, 8)
+ IO(Decode16,0x7E8,0x7E8,0x01,0x08)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {1,2,3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2F8, 0x3F8, 1, 8)
+ IO(Decode16,0x7E8,0x7E8,0x01,0x08)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {1,2,3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3E8, 0x3E8, 1, 8)
+ IO(Decode16,0x7E8,0x7E8,0x01,0x08)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {1,2,3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2E8, 0x3E8, 1, 8)
+ IO(Decode16,0x7E8,0x7E8,0x01,0x08)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {1,2,3}
+ }
+ EndDependentFn()
+ })
+
+
+ // Set Resource Setting Method for UART 2.
+ Method(_SRS,1,Serialized)
+ {
+ ENFG()
+ Store(CR2B, Local0)
+ EXFG()
+ If(Local0)
+ {
+ // Point to the specific information in the passed
+ // in Buffer.
+ CreateByteField(Arg0,0x02,IO10)
+ CreateByteField(Arg0,0x03,IO11)
+ CreateByteField(Arg0,0x0a,IO20)
+ CreateByteField(Arg0,0x0b,IO21)
+ CreateWordField(Arg0,0x11,IRQW)
+ CreateByteField(Arg0,0x14,DMA0)
+
+ ENFG()
+
+ //
+ // Disable the device.
+ //
+ And(CR02,0x0F,CR02)
+
+ //
+ // Set UART2 mode
+ //
+// Store(0x0B, CR0C)
+// Store(0x40, CR0A)
+// Store(0x0C, CR0C)
+
+ //
+ // Set the Base IO Address.
+ //
+ Store(ShiftRight(IO10,2),CR25)
+ Or(CR25,ShiftLeft(IO11,6),CR25)
+ If(IO20){
+ Store(ShiftRight(IO20,3),CR2B)
+ Or(CR2B,ShiftLeft(IO21,5),CR2B)
+ }
+
+
+ //
+ // Set the IRQ.
+ //
+ And(CR28,0xF0,CR28)
+ Or(CR28,Subtract(FindSetRightBit(IRQW),1),CR28)
+
+ // Set DMA
+ And(CR2C,0xF0,CR2C)
+ If(DMA0)
+ {
+ Or(CR2C,Subtract(FindSetRightBit(DMA0),1),CR2C)
+ }
+ Else
+ {
+ Or(CR2C,0x0F,CR2C) // No DMA
+ }
+
+ //
+ // Enable the device.
+ //
+ Or(CR02,0x80,CR02)
+
+ EXFG()
+
+ }
+ Else
+ {
+ // Point to the specific information in the passed
+ // in Buffer.
+ CreateByteField(Arg0,0x02,IOLO)
+ CreateByteField(Arg0,0x03,IOHI)
+ CreateWordField(Arg0,0x09,IRQR)
+
+ ENFG()
+
+ //
+ // Disable the device.
+ //
+ And(CR02,0x0F,CR02)
+
+ //
+ // Set UART2 mode
+ //
+// Store(0x0B, CR0C)
+// Store(0x40, CR0A)
+// Store(0x0C, CR0C)
+
+ //
+ // Set the Base IO Address.
+ //
+ Store(ShiftRight(IOLO,2),CR25)
+ Or(CR25,ShiftLeft(IOHI,6),CR25)
+
+ //
+ // Set the IRQ.
+ //
+ And(CR28,0xF0,CR28)
+ Or(CR28,Subtract(FindSetRightBit(IRQR),1),CR28)
+
+ //
+ // Enable the device.
+ //
+ Or(CR02,0x80,CR02)
+
+ EXFG()
+ }
+ }
+
+ //
+ // D0 Method for UART 2.
+ //
+ Method(_PS0,0,Serialized)
+ {
+ ENFG()
+ Store(Or(CR02,0x80),CR02)
+ EXFG()
+ }
+
+
+
+ //
+ // D3 Method for UART 2.
+ //
+ Method(_PS3,0,Serialized)
+ {
+ ENFG()
+ Store(And(CR02,0x0F),CR02)
+ EXFG()
+ }
+
+} \ No newline at end of file
diff --git a/Core/EM/ACPI/Uart3.asl b/Core/EM/ACPI/Uart3.asl
new file mode 100644
index 0000000..4163521
--- /dev/null
+++ b/Core/EM/ACPI/Uart3.asl
@@ -0,0 +1,103 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Uart3.asl 3 3/26/09 4:53p Oleksiyy $
+//
+// $Revision: 3 $
+//
+// $Date: 3/26/09 4:53p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/Uart3.asl $
+//
+// 3 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 2 4/03/06 4:05p Felixp
+// New Super I/O infrastructure Support
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:41p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 1 03/04/07 5:54p Chung
+// Add ASL core for new all I/O beta version
+//
+//**********************************************************************;
+// UART3 //
+// Category # :0x00
+Device(UAR3) {
+ Name(_UID, 3) //Generic ID for COMC
+ Method(_HID, 0) { //PnP Device ID
+ if(SI1P){Return(^^SIO2.UHID(0))}
+ else{Return(^^SIO1.UHID(0))}
+ }
+ Method(_STA, 0) { //Get UART status
+ if(SI1P){Return(^^SIO2.DSTA(0))}
+ else{Return(^^SIO1.DSTA(0))}
+ }
+ Method(_DIS, 0) { //Disable UART
+ if(SI1P){^^SIO2.DCNT(0, 0)}
+ else{^^SIO1.DCNT(0, 0)}
+ }
+ Method(_CRS, 0) { //Get UART current resources
+ if(SI1P){Return(^^SIO2.DCRS(0, 0))}
+ else{Return(^^SIO1.DCRS(0, 0))}
+ }
+ Method(_SRS, 1) { //Set UART resources
+ if(SI1P){^^SIO2.DSRS(Arg0, 0)}
+ else{^^SIO1.DSRS(Arg0, 0)}
+ }
+
+
+//-----------------------------------------------------------------------
+// UART3 Possible Resources
+//-----------------------------------------------------------------------
+//NOTE: _PRS MUST be the NAME not a METHOD object
+//to have GENERICSIO.C working right!
+//-----------------------------------------------------------------------
+
+ Name(_PRS, ResourceTemplate() {
+ StartDependentFn(0, 0) {
+ IO(Decode16, 0x3E8, 0x3E8, 1, 8)
+ IRQNoFlags() {7}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3F8, 0x3F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2F8, 0x2F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3E8, 0x3E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2E8, 0x2E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ EndDependentFn()
+ })
+} // End Of UAR3 //------------------------------------------------------
diff --git a/Core/EM/ACPI/Uart3ir.asl b/Core/EM/ACPI/Uart3ir.asl
new file mode 100644
index 0000000..11f2c4e
--- /dev/null
+++ b/Core/EM/ACPI/Uart3ir.asl
@@ -0,0 +1,127 @@
+//**********************************************************************;
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Uart3ir.asl 3 3/26/09 4:53p Oleksiyy $
+//
+// $Revision: 3 $
+//
+// $Date: 3/26/09 4:53p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/Uart3ir.asl $
+//
+// 3 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 2 4/03/06 4:05p Felixp
+// New Super I/O infrastructure Support
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:41p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 1 03/04/07 5:55p Chung
+// Add ASL core for new all I/O beta version
+//
+//**********************************************************************;
+// UART3 //
+// Category # :0x00
+Device(UAR3) {
+ Name(_UID, 3) //Generic ID for COMC
+ Method(_HID, 0) { //PnP Device ID
+ if(SI1P){Return(^^SIO2.UHID(0))}
+ else{Return(^^SIO1.UHID(0))}
+ }
+ Method(_STA, 0) { //Get UART status
+ if(SI1P){Return(^^SIO2.DSTA(0))}
+ else{Return(^^SIO1.DSTA(0))}
+ }
+ Method(_DIS, 0) { //Disable UART
+ if(SI1P){^^SIO2.DCNT(0, 0)}
+ else{^^SIO1.DCNT(0, 0)}
+ }
+ Method(_CRS, 0) { //Get UART current resources
+ if(SI1P){Return(^^SIO2.DCRS(0, 1))}
+ else{Return(^^SIO1.DCRS(0, 1))}
+ }
+ Method(_SRS, 1) { //Set UART resources
+ if(SI1P){^^SIO2.DSRS(Arg0, 0)}
+ else{^^SIO1.DSRS(Arg0, 0)}
+ }
+
+
+//-----------------------------------------------------------------------
+// UART3 IrDa Possible Resources
+//-----------------------------------------------------------------------
+//NOTE: _PRS MUST be the NAME not a METHOD object
+//to have GENERICSIO.C working right!
+//-----------------------------------------------------------------------
+
+ Name(_PRS, ResourceTemplate() {
+// IRQ, No DMA
+ StartDependentFn(0, 0) {
+ IO(Decode16, 0x3E8, 0X3E8, 1, 8)
+ IRQNoFlags() {11}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3F8, 0X3F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2F8, 0X2F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3E8, 0X3E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2E8, 0X2E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+// IRQ, DMA
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3F8, 0X3F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {0,1,2,3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2F8, 0X2F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {0,1,2,3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3E8, 0X3E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {0,1,2,3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2E8, 0X2E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {0,1,2,3}
+ }
+ EndDependentFn()
+ })
+} // End Of UAR3 //------------------------------------------------------
diff --git a/Core/EM/ACPI/Uart4.asl b/Core/EM/ACPI/Uart4.asl
new file mode 100644
index 0000000..ee2ce3a
--- /dev/null
+++ b/Core/EM/ACPI/Uart4.asl
@@ -0,0 +1,109 @@
+//**********************************************************************;
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Uart4.asl 3 3/26/09 4:53p Oleksiyy $
+//
+// $Revision: 3 $
+//
+// $Date: 3/26/09 4:53p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/Uart4.asl $
+//
+// 3 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 2 4/03/06 4:05p Felixp
+// New Super I/O infrastructure Support
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:41p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 1 03/04/07 5:56p Chung
+// Add ASL core for new all I/O beta version
+//
+// 5 9/06/02 10:53a Alexp
+// Add SourceSafe headers to all core asl files
+//
+//**********************************************************************;
+// UART4 - COMD or Infrared //
+// Requires Uart4(ir).asl component present as well
+// Category # :0x01
+Device(UAR4) {
+ Name(_UID, 4) //Generic ID for COMD
+ Method(_HID, 0) { //PnP Device ID
+ if(SI1P){Return(^^SIO2.UHID(1))}
+ else{Return(^^SIO1.UHID(1))}
+ }
+ Method(_STA, 0) { //Get UART status
+ if(SI1P){Return(^^SIO2.DSTA(1))}
+ else{Return(^^SIO1.DSTA(1))}
+ }
+ Method(_DIS, 0) { //Disable UART
+ if(SI1P){^^SIO2.DCNT(1, 0)}
+ else{^^SIO1.DCNT(1, 0)}
+ }
+ Method(_CRS, 0) { //Get UART current resources
+ if(SI1P){Return(^^SIO2.DCRS(1, 0))}
+ else{Return(^^SIO1.DCRS(1, 0))}
+ }
+ Method(_SRS, 1) { //Set UART resources
+ if(SI1P){^^SIO2.DSRS(Arg0, 1)}
+ else{^^SIO1.DSRS(Arg0, 1)}
+ }
+
+//------------------------------------------------------------------------
+// UART4 Possible Resources
+//------------------------------------------------------------------------
+//NOTE: _PRS MUST be the NAME not a METHOD object
+//to have GENERICSIO.C working right!
+//-----------------------------------------------------------------------
+
+ Name(_PRS, ResourceTemplate() {
+// IRQ, No DMA
+ StartDependentFn(0, 0) {
+ IO(Decode16, 0x2E8, 0X2E8, 1, 8)
+ IRQNoFlags() {10}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3F8, 0X3F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2F8, 0X2F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3E8, 0X3E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2E8, 0X2E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ EndDependentFn()
+ })
+} // End Of UAR4
diff --git a/Core/EM/ACPI/Uart4ir.asl b/Core/EM/ACPI/Uart4ir.asl
new file mode 100644
index 0000000..eba59b0
--- /dev/null
+++ b/Core/EM/ACPI/Uart4ir.asl
@@ -0,0 +1,128 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/Uart4ir.asl 3 3/26/09 4:53p Oleksiyy $
+//
+// $Revision: 3 $
+//
+// $Date: 3/26/09 4:53p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/Uart4ir.asl $
+//
+// 3 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 2 4/03/06 4:05p Felixp
+// New Super I/O infrastructure Support
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:41p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 1 03/04/07 5:57p Chung
+// Add ASL core for new all I/O beta version
+//
+//**********************************************************************;
+// UART4 - COMD or Infrared //
+// Requires Uart4(ir).asl component present as well
+// Cannot be included along with UART4IR.ASL. Only one UART4 Device can be present in ASL.
+// Category # :0x01
+Device(UAR4) {
+ Name(_UID, 4) //Generic ID for COMD
+ Method(_HID, 0) { //PnP Device ID
+ if(SI1P){Return(^^SIO2.UHID(1))}
+ else{Return(^^SIO1.UHID(1))}
+ }
+ Method(_STA, 0) { //Get UART status
+ if(SI1P){Return(^^SIO2.DSTA(1))}
+ else{Return(^^SIO1.DSTA(1))}
+ }
+ Method(_DIS, 0) { //Disable UART
+ if(SI1P){^^SIO2.DCNT(1, 0)}
+ else{^^SIO1.DCNT(1, 0)}
+ }
+ Method(_CRS, 0) { //Get UART current resources
+ if(SI1P){Return(^^SIO2.DCRS(1, 1))}
+ else{Return(^^SIO1.DCRS(1, 1))}
+ }
+ Method(_SRS, 1) { //Set UART resources
+ if(SI1P){^^SIO2.DSRS(Arg0, 1)}
+ else{^^SIO1.DSRS(Arg0, 1)}
+ }
+
+
+//-----------------------------------------------------------------------
+// UART4 IrDa Possible Resources
+//-----------------------------------------------------------------------
+//NOTE: _PRS MUST be the NAME not a METHOD object
+//to have GENERICSIO.C working right!
+//-----------------------------------------------------------------------
+
+ Name(_PRS, ResourceTemplate() {
+// IRQ, No DMA
+ StartDependentFn(0, 0) {
+ IO(Decode16, 0x2E8, 0x2E8, 1, 8)
+ IRQNoFlags() {10}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3F8, 0x3F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2F8, 0x2F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3E8, 0x3E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2E8, 0x2E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+// IRQ, DMA
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3F8, 0x3F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {0,1,2,3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2F8, 0x2F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {0,1,2,3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3E8, 0x3E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {0,1,2,3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2E8, 0x2E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,9,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {0,1,2,3}
+ }
+ EndDependentFn()
+ })
+} // End Of UAR4 //------------------------------------------------------
diff --git a/Core/EM/ACPI/asllib.asl b/Core/EM/ACPI/asllib.asl
new file mode 100644
index 0000000..a90c541
--- /dev/null
+++ b/Core/EM/ACPI/asllib.asl
@@ -0,0 +1,325 @@
+// ASL generic library objects
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
+// $Header: /Alaska/BIN/Modules/ACPI/Template/Core/asllib.asl 10 6/04/13 4:39p Oleksiyy $
+//
+// $Revision: 10 $
+//
+// $Date: 6/04/13 4:39p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/asllib.asl $
+//
+// 10 6/04/13 4:39p Oleksiyy
+// [TAG] EIP125640
+// [Category] Improvement
+// [Description] Adding Win 8.1 to the OS list in OSFL method.
+// [Files] asllib.asl
+//
+// 9 7/20/12 5:00p Oleksiyy
+// [TAG] EIP92404
+// [Category] Improvement
+// [Description] ACPI method _OSI("Linux") should no longer be used
+// [Files] asllib.asl
+//
+// 8 4/10/12 6:23p Oleksiyy
+// [TAG] EIP87370
+// [Category] Improvement
+// [Description] Operation System Vendor String for Win8
+// [Files] asllib.asl
+//
+// 7 9/29/09 5:06p Oleksiyy
+// EIP 20586: RRIO and rDMA methods removed. They are implemented in
+// SB.asl file.
+//
+// 6 9/08/09 11:16a Yakovlevs
+// Fixed issue in OSVR detection. Because of "ElseIf" statement it use to
+// return wrong (Lovest) value.
+//
+// 4 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 3 5/24/06 3:50p Ambikas
+//
+// 2 5/05/05 7:10p Yakovlevs
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:42p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 18 1/22/03 3:38p Alexp
+// Modify GPRW() method
+//
+// 17 1/15/03 6:09p Alexp
+// GPRW-> modify code to make use of Sleep State Bit mask field inside
+// BIOS OpRegion.
+//
+// 16 10/08/02 10:44a Mirk
+// missing bracket in OSFL method
+//
+// 15 10/08/02 10:38a Mirk
+// Display proper cp ACPI in PIC mode : AC and for APIC mode : AA
+//
+// 14 9/20/02 10:04a Alexp
+// Uncomment code to store detected WinME to OSFL OS flag.
+//
+// 13 9/06/02 10:53a Alexp
+// Add SourceSafe headers to all core asl files
+//
+//
+//;**********************************************************************;
+// File to be included to root ASL scope of DSDT.ASL
+//**********************************************************************;
+// 1. RRIO(4) & rDMA(3) Dummy control methods. Required when I/O Positive decoding's disabled
+// 2. Name PICM - Global Name returns current Interrupt controller mode; updated from _PIC control method
+// 3. Method _PIC(1) - Updates PICM with current Interrupt controller mode
+// 4. Method MCTH(Str1, Str2) - Compare Str1 and Str2.
+// 5. Method GPRW(Package(x,y)) Generic Wake up Control Method to detect the Max Sleep State available in ASL Name scope
+// and Return the Package compatible with _PRW format
+// 6. Method WAKP(Package) - Return package for _WAK method
+// 7. Debug OperationRegions used to display ASL checkpoints int LED CheckPoint Card
+//----------------------------------------------------------------------
+
+/*
+;<AMI_PHDR_START>
+;------------------------------------------------------------------------
+;
+; Procedure: _PIC
+;
+; Description: Interrupt mode Control method, returns current Interrupt controller mode; updated from _PIC control method
+; OS invokes _PIC to notify ASL of current Interrupt controller mode
+; _PIC Input arguments : 0-PIC mode (Default), 1-APIC mode
+; Input: Arg0 - Interrupt mode
+; Output: Nothing
+;
+;-------------------------------------------------------------------------
+;<AMI_PHDR_END>
+*/
+ Name(PICM, 0) // Global Name, returns current Interrupt controller mode; updated from _PIC control method
+// OS invokes _PIC to notify ASL of current Interrupt controller mode
+// _PIC Input arguments : 0-PIC mode (Default), 1-APIC mode
+ Method(_PIC, 1) {
+ if(Arg0) {
+ Store(0xAA, DBG8) // APIC
+ } else {
+ Store(0xAC, DBG8) // PIC
+ }
+ Store(Arg0, PICM)
+ }
+
+/*
+;<AMI_PHDR_START>
+;------------------------------------------------------------------------
+;
+; Procedure: OSFL
+;
+; Description: OSFL object is used to detect the currently running OS
+; Input: Nothing
+; Output: OS type
+; running under 0 - Win 2000
+; 1 - Win 98/Se
+; 2 - Win Me
+; 3 - Linux
+; 4 - WinXP
+; 5 - Windows Server 2003
+; 6 - FreeBSD
+; 7 - HP-UX
+; 8 - OpenVMS
+;-------------------New Values Added -----------------------------
+; 9 - WinXP SP1
+; 10 - WinXP SP2
+; 11 - WinXP SP3
+; 12 - Vista
+; 13 - Vista SP1
+; 14 - Win7
+; 15 - Win8
+; 16 - Win8.1
+; 17..n - reserved
+;
+;-------------------------------------------------------------------------
+;<AMI_PHDR_END>
+*/
+ Name(OSVR, Ones) // Global Name, returns current OS version ID
+ Method(OSFL, 0){
+ if(LNotEqual(OSVR, Ones)) {Return(OSVR)} // OS version was already detected
+ if(LEqual(PICM,0)) {Store(0xAC, DBG8)} // to indicate OS is running in ACPI PIC mode
+ Store(3, OSVR) // default - Linux
+//// Detect currently running OS
+ if(CondRefOf(\_OSI,Local0))
+ {
+ //If(\_OSI("Linux")){Store(3, OSVR)} // Tested on the Redhat Linux
+ If(\_OSI("Windows 2001")){Store(4, OSVR)}
+ If(\_OSI("Windows 2001.1")){Store(5, OSVR)}
+ If(\_OSI("FreeBSD")){Store(6, OSVR)}
+ If(\_OSI("HP-UX")){Store(7, OSVR)}
+ If(\_OSI("OpenVMS")){Store(8, OSVR)}
+ If(\_OSI("Windows 2001 SP1")){Store(9,OSVR)}
+ If(\_OSI("Windows 2001 SP2")){Store(10,OSVR)}
+ If(\_OSI("Windows 2001 SP3")){Store(11,OSVR)}
+ If(\_OSI("Windows 2006")){Store(12,OSVR)}
+ If(\_OSI("Windows 2006 SP1")){Store(13,OSVR)}
+ If(\_OSI("Windows 2009")){Store(14,OSVR)}
+ If(\_OSI("Windows 2012")){Store(15,OSVR)}
+ If(\_OSI("Windows 2013")){Store(16,OSVR)}
+ } else {
+ If(MCTH(\_OS,"Microsoft Windows NT")){Store(0, OSVR)}
+ If(MCTH(\_OS,"Microsoft Windows")){Store(1, OSVR)}
+ If(MCTH(\_OS,"Microsoft WindowsME: Millennium Edition")){Store(2, OSVR)}
+ If(MCTH(\_OS,"Linux")){Store(3, OSVR)} // Tested on the Redhat Linux
+ If(MCTH(\_OS,"FreeBSD")){Store(6, OSVR)}
+ If(MCTH(\_OS,"HP-UX")){Store(7, OSVR)}
+ If(MCTH(\_OS,"OpenVMS")){Store(8, OSVR)}
+ }
+ Return(OSVR)
+ }
+
+/*
+;<AMI_PHDR_START>
+;-------------------------------------------------------------------------
+;
+; Procedure: MCTH
+;
+; Description: Generic control Method. Used to compare two strings and return TRUE/FALSE result
+; MCTH(Str1, Str2) - Compare Str1 and Str2.
+; Input: Arg0 - str1, Arg1 - str2
+; Output: string comparison result
+; One if Str1 == Str2
+; Zero if Str1 != Str2
+;-------------------------------------------------------------------------
+;<AMI_PHDR_END>
+*/
+ Method(MCTH, 2) {
+//1. If Length str1 < Str2 - Return (Zero)
+ If(LLess(Sizeof(Arg0), Sizeof(Arg1)))
+ {
+ Return(Zero)
+ }
+//2. Convert str1 & str2 into buffer with length of str2
+ Add(Sizeof(Arg0), 1, Local0)
+// Local0 contains length of string + NULL character.
+ Name(BUF0, Buffer(Local0) {})
+ Name(BUF1, Buffer(Local0) {})
+ Store(Arg0, BUF0)
+ Store(Arg1, BUF1)
+ While(Local0)
+ {
+ Decrement(Local0)
+ If(LNotEqual(Derefof(Index(BUF0, Local0)), Derefof(Index(BUF1, Local0))))
+ { Return(Zero) }
+ }
+ Return(One) // Str1 & Str2 are match
+ }
+
+/*
+;<AMI_PHDR_START>
+;------------------------------------------------------------------------
+;
+; Procedure: GPRW
+;
+; Description: Generic Wake up Control Method ("Big brother") to detect the Max Sleep State available in ASL Name scope
+; and Return the Package compatible with _PRW format.
+; Input: Arg0 = bit offset within GPE register space device event will be triggered to
+; Arg1 = Max Sleep state, device can resume the System from
+; If Arg1 = 0 , Update Arg1 with Max _Sx state enabled in the System
+; Output: _PRW package
+;
+;-------------------------------------------------------------------------
+;<AMI_PHDR_END>
+*/
+ Name(PRWP, Package(){Zero, Zero}) // _PRW Package
+ Method(GPRW, 2)
+ {
+ Store(Arg0, Index(PRWP, 0)) // copy GPE#
+// SS1-SS4 - enabled in BIOS Setup Sleep states
+ Store(ShiftLeft(SS1,1),Local0) // S1 ?
+ Or(Local0,ShiftLeft(SS2,2),Local0) // S2 ?
+ Or(Local0,ShiftLeft(SS3,3),Local0) // S3 ?
+ Or(Local0,ShiftLeft(SS4,4),Local0) // S4 ?
+// Local0 has a bit mask of enabled Sx(1 based)
+ // bit mask of enabled in BIOS Setup Sleep states(1 based)
+ If(And(ShiftLeft(1, Arg1), Local0)){ // Requested wake up value (Arg1) is present in Sx list of available Sleep states
+ Store(Arg1, Index(PRWP, 1)) // copy Sx#
+ } Else { // Not available -> match Wake up value to the higher Sx state
+ ShiftRight(Local0, 1, Local0)
+ If(LOr(LEqual(OSFL, 1), LEqual(OSFL, 2))) { // ??? Win9x
+ FindSetLeftBit(Local0, Index(PRWP,1)) // Arg1 == Max Sx
+ } Else { // ??? Win2k / XP
+ FindSetRightBit(Local0, Index(PRWP,1)) // Arg1 == Min Sx
+ }
+ }
+ Return(PRWP)
+ }
+
+/*
+;<AMI_PHDR_START>
+;------------------------------------------------------------------------
+;
+; Procedure: WAKP
+;
+; Description: Return package for _WAK method. Contains 2 DWORDS
+; 0 - Status
+; 0x00000001 - wake was signaled but failed due to lack of power
+; 0x00000002 - wake was signaled but failed due to thermal condition
+; other bits are reserved
+; 1 - PSS if non-zero, the effective S-state the Power Supply realy entered
+; Output: _WAK return package
+;-------------------------------------------------------------------------
+;<AMI_PHDR_END>
+*/
+// Return package for _WAK method 2 DWORDS
+ Name(WAKP, Package(){Zero, Zero})
+
+//--------------------------//
+// Debug output registers //
+//--------------------------//
+
+/*
+;<AMI_PHDR_START>
+;------------------------------------------------------------------------
+; Procedure: DBG8
+; Procedure: DBG9
+; Description: Logical names for Debug ports 0x80 (byte) and 0x90(word).
+; If such debug ports exist in the System, the value, stored into the Port will be displayed to LED
+; Input: Nothing
+; Output: Nothing
+;-------------------------------------------------------------------------
+;<AMI_PHDR_END>
+*/
+
+ OperationRegion (DEB0, SystemIO, 0x80, 1)
+ Field (DEB0, ByteAcc,NoLock,Preserve)
+ { DBG8,8,}
+
+ OperationRegion (DEB1, SystemIO, 0x90, 2)
+ Field (DEB1, WordAcc,NoLock,Preserve)
+ { DBG9,16,}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2012, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************
diff --git a/Core/EM/ACPI/game.asl b/Core/EM/ACPI/game.asl
new file mode 100644
index 0000000..3e7a2e2
--- /dev/null
+++ b/Core/EM/ACPI/game.asl
@@ -0,0 +1,101 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/game.asl 3 3/26/09 4:53p Oleksiyy $
+//
+// $Revision: 3 $
+//
+// $Date: 3/26/09 4:53p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/game.asl $
+//
+// 3 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 2 4/03/06 4:05p Felixp
+// New Super I/O infrastructure Support
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:42p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 5 03/04/07 5:39p Chung
+// Modify all I/O beta version
+//
+// 4 9/06/02 10:53a Alexp
+// Add SourceSafe headers to all core asl files
+//
+//
+//**********************************************************************;
+//**********************************************************************;
+// Generic Game Port
+//------------------------------------------------------------------------
+// Category # :0x08
+Device(GAME) {
+ Name(_HID, EISAID("PNPB02F")) // PnP ID for GamePort
+ Method(_STA, 0) { Return(DSTA(8))} // Get status
+ Method(_DIS, 0) { DCNT(8,0) } // Disable
+// GamePort Current Resource template (to be returned by _CRS)
+ Name(GMCR, ResourceTemplate() {
+ IO(Decode16, 0, 0, 8, 8, GIO1)
+ })
+
+ Method(_CRS, 0) {
+ CreateWordField(GMCR, ^GIO1._MIN, IOGL) // Min Base Word
+ CreateWordField(GMCR, ^GIO1._MAX, IOGH) // Max Base Word
+
+ ENFG(CGLD(8)) // Enter Config Mode, Select LDN
+
+// Write Current Settings into Buffer for IO Descriptor
+// IO ports for Game
+ ShiftLeft(IOAH, 8, IOGL) // Get IO Base MSB
+ Or(IOAL, IOGL, IOGL) // Get IO Base LSB
+ Store(IOGL, IOGH) // Set Max Base Word
+
+ EXFG() // Exit Config Mode
+ Return(GMCR) // Return Byte Stream
+ }
+
+ Method(_SRS, 1) {
+ CreateWordField(Arg0, ^GIO1._MIN, IO11) // Range 1 Min Base Word
+ ENFG(CGLD(8)) // Enter Config Mode, Select LDN
+// Set Game Base IO Address
+ And(IO11, 0xff, IOAL) // Set IO Base LSB
+ ShiftRight(IO11, 0x8, IOAH) // Set IO Base MSB
+ DCNT(8, 1) // Enable Device (Routing)
+ EXFG() // Exit Config Mode
+ }
+//------------------------------------------------------------------------
+// GamePort Possible Resources
+//------------------------------------------------------------------------
+//NOTE: _PRS MUST be the NAME not a METHOD object
+//to have GENERICSIO.C working right!
+//-----------------------------------------------------------------------
+
+ Name(_PRS, ResourceTemplate() {
+ StartDependentFn(0,0) {
+ IO(Decode16, 0x201, 0x201, 1, 8)
+ }
+ StartDependentFnNoPri(){
+ IO(Decode16, 0x209, 0x209, 1, 8)
+ }
+ EndDependentFn()
+ })
+
+} // End Of GamePort ////////////////////////////////////////////////////
diff --git a/Core/EM/ACPI/irda.asl b/Core/EM/ACPI/irda.asl
new file mode 100644
index 0000000..ba91163
--- /dev/null
+++ b/Core/EM/ACPI/irda.asl
@@ -0,0 +1,115 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/irda.asl 3 3/26/09 4:53p Oleksiyy $
+//
+// $Revision: 3 $
+//
+// $Date: 3/26/09 4:53p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/irda.asl $
+//
+// 3 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 2 4/03/06 4:05p Felixp
+// New Super I/O infrastructure Support
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:42p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 5 03/04/07 5:40p Chung
+// Modify all I/O beta version
+//
+// 4 9/06/02 10:53a Alexp
+// Add SourceSafe headers to all core asl files
+//
+//
+//**********************************************************************;
+// Standalone InfraRed device //
+//**********************************************************************;
+// Category # :0x10 (Generic IO range 1)
+Device(IRDA) {
+ Name(_HID, EISAID("PNP0510")) //PnP Device ID IrDa
+ Name(_UID, 3) //Unique ID for IrDa 3
+ Method(_STA, 0) {Return(DSTA(0x10))} //Get status
+ Method(_DIS, 0) {DCNT(0x10, 0)} //Disable
+ Method(_CRS, 0) {Return(DCRS(0x10, 0))} //Get current resources
+ Method(_SRS, 1) {DSRS(Arg0, 0x10) } //Set recources
+// Method(_PRS, 0) {Return(CMPR)} //Return possible resources
+
+
+//------------------------------------------------------------------------
+// UART1/2 , IrDa Possible Resources
+//------------------------------------------------------------------------
+//NOTE: _PRS MUST be the NAME not a METHOD object
+//to have GENERICSIO.C working right!
+//-----------------------------------------------------------------------
+ Name(_PRS, ResourceTemplate() {
+// IRQ, No DMA
+ StartDependentFn(0, 0) {
+ IO(Decode16, 0x3F8, 0X3F8, 1, 8)
+ IRQNoFlags() {4}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3F8, 0X3F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2F8, 0X2F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3E8, 0X3E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2E8, 0X2E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {}
+ }
+// DMA, IRQ
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3F8, 0X3F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {0,1,2,3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2F8, 0X2F8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {0,1,2,3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x3E8, 0X3E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {0,1,2,3}
+ }
+ StartDependentFnNoPri() {
+ IO(Decode16, 0x2E8, 0X2E8, 1, 8)
+ IRQNoFlags() {3,4,5,6,7,10,11,12}
+ DMA(Compatibility, NotBusMaster, Transfer8) {0,1,2,3}
+ }
+ EndDependentFn()
+})
+} // End Of IRDA //
diff --git a/Core/EM/ACPI/midi.asl b/Core/EM/ACPI/midi.asl
new file mode 100644
index 0000000..12473e2
--- /dev/null
+++ b/Core/EM/ACPI/midi.asl
@@ -0,0 +1,124 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/midi.asl 3 3/26/09 4:53p Oleksiyy $
+//
+// $Revision: 3 $
+//
+// $Date: 3/26/09 4:53p $
+//**********************************************************************;
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/midi.asl $
+//
+// 3 3/26/09 4:53p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 2 4/03/06 4:05p Felixp
+// New Super I/O infrastructure Support
+//
+// 1 3/24/05 5:01p Sivagarn
+//
+// 1 2/03/05 6:42p Sivagarn
+// 0ABHI001 Check in
+//
+// 1 7/27/04 2:48p Yakovlevs
+//
+// 5 03/04/07 5:41p Chung
+// Modify all I/O beta version
+//
+// 4 9/06/02 10:53a Alexp
+// Add SourceSafe headers to all core asl files
+//
+//**********************************************************************;
+//**********************************************************************;
+// Generic MPU 401 Device
+//**********************************************************************;
+// Category # :0x05
+Device(MIDI){
+ Name(_HID, EISAID("PNPB006")) //PnP ID for GamePort
+ Method(_STA, 0) {Return(DSTA(5))} //Get status
+ Method(_DIS, 0) {DCNT(5,0)} //Disable
+
+//-----------------------------------------------------------------------
+// MIDIPort Current Resources template (returned by _CRS)
+//-----------------------------------------------------------------------
+ Name(MDCR, ResourceTemplate(){
+// IO(Decode16, 0, 0, 0x30, 2, GIO1)
+// IRQNoFlags(GIRQ) {10}
+ IO(Decode16, 0, 0, 1, 2, GIO1)
+ IRQNoFlags(GIRQ) {5}
+ })
+
+ Method(_CRS, 0){
+ CreateWordField(MDCR, ^GIO1._MIN, IOML) //Range 2 Min Base Word
+ CreateWordField(MDCR, ^GIO1._MAX, IOMH) //Range 2 Max Base Word
+ CreateWordField(MDCR, ^GIRQ._INT, IRQM) //IRQ mask 0x1
+
+ ENFG(CGLD(5)) //Enter Config Mode, Select LDN
+
+// Write Current Settings into Buffer for IO Descriptor
+// IO ports for MPU 401
+ ShiftLeft(IOAH, 8, IOML) //Get IO Base MSB
+ Or(IOAL, IOML, IOML) //Get IO Base LSB
+ Store(IOML, IOMH) //Set Max Base Word
+// Write Current Settings into IRQ descriptor
+ If(INTR)
+ {ShiftLeft(1, INTR, IRQM)}
+ Else
+ {Store(0, IRQM)} //No IRQ used
+ EXFG() //Exit Config Mode
+ Return(MDCR) //Return Byte Stream
+ }
+
+ Method(_SRS, 1){
+// Arg0 - PnP Resource String to set
+ CreateWordField(Arg0, ^GIO1._MIN, IO11) //Range 1 Min Base Word
+ CreateWordField(Arg0, ^GIRQ._INT, IRQM) //IRQ mask 0x1
+
+ ENFG(CGLD(5)) //Enter Config Mode, Select LDN
+
+ // Set Midi Base IO Address
+ And(IO11, 0xFF, IOAL) //Set IO Base LSB
+ ShiftRight(IO11, 0x08, IOAH) //Set IO Base MSB
+ // Set IRQ
+ If(IRQM){
+ FindSetRightBit(IRQM, Local0)
+ Subtract(Local0, 1, INTR)
+ }
+ Else
+ {Store(0, INTR)} //No IRQ used
+ DCNT(5, 1) //Enable Device (Routing)
+ EXFG() //Exit Config Mode
+ }
+
+//-----------------------------------------------------------------------
+// MIDIPort Possible Resources
+//-----------------------------------------------------------------------
+//-----------------------------------------------------------------------
+//NOTE: _PRS MUST be the NAME not a METHOD object
+//to have GENERICSIO.C working right!
+//-----------------------------------------------------------------------
+ Name(_PRS, ResourceTemplate(){
+ StartDependentFnNoPri(){
+ IO(Decode16, 0x300, 0x300, 1, 2)
+ IRQNoFlags() {5,7,9,10,11}
+ }
+ StartDependentFnNoPri(){
+ IO(Decode16, 0x330, 0x330, 1, 2)
+ IRQNoFlags() {5,7,9,10,11}
+ }
+ EndDependentFn()
+ })
+} // End Of Midi ////////////////////////////////////////////////////////
diff --git a/Core/EM/ACPI/mptable.c b/Core/EM/ACPI/mptable.c
new file mode 100644
index 0000000..66fe0d4
--- /dev/null
+++ b/Core/EM/ACPI/mptable.c
@@ -0,0 +1,1553 @@
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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.c 31 12/13/12 12:01p Oleksiyy $
+//
+// $Revision: 31 $
+//
+// $Date: 12/13/12 12:01p $
+//**********************************************************************
+// Revision History
+// ----------------
+// $Log: /Alaska/BIN/Modules/ACPI/Template/Core/mptable.c $
+//
+// 31 12/13/12 12:01p Oleksiyy
+// [TAG] EIP109290
+// [Category] Improvement
+// [Description] Issues found by CppCheck in ACPI eModule
+// [Files] AcpiCore.c, mptable.c, AmlString.c, BootScriptSave.c and
+// BootScriptExecuter.c
+//
+// 30 1/12/12 4:51p Oleksiyy
+// [TAG] EIP80870
+// [Category] Improvement
+// [Description] MP table entry has a zero sized Address Length.
+// [Files] mptable.c
+//
+// 29 1/12/12 4:15p Oleksiyy
+// [TAG] EIP79240
+// [Category] Improvement
+// [Description] Added Variable to handle the situation when MP table
+// created multiple times.
+// [Files] mptable.c
+//
+// 28 11/29/11 12:20p Oleksiyy
+// [TAG] EIP76814
+// [Category] Bug Fix
+// [Severity] Normal
+// [Symptom] MP_TABLE_LEGACY_REGION_LOCATION = 0 causes build error
+// [RootCause] Unreferenced variable: LegacyBiosProtocol
+// [Solution] Variable declared only if MP_TABLE_LEGACY_REGION_LOCATION
+// != 0
+// [Files] mptable.c
+//
+// 27 7/19/11 11:31a Oleksiyy
+// [TAG] EIP64108
+// [Category] Improvement
+// [Description] ACPI, convert or update all eModules to be compliant
+// with PI 1.2, and UEFI 2.3.1 specifications.
+// [Files] AcpiCore.c, mptable.c, AcpiS3Save.c, S3Resume.dxs,
+// S3Resume.c, AcpiPeiS3Func.c, BootScriptExecuter.c and DxeIpl.c
+//
+// 26 5/25/10 5:07p Yakovlevs
+// Fixed Issue when with Multiple IO APICs, upper IOAPIC's INT_IN 0 was
+// excluded from the table.
+//
+// 25 9/28/09 3:59p Yakovlevs
+//
+// 24 5/27/09 5:41p Yakovlevs
+// CSM Protocol definition moved in #if scope
+//
+// 23 5/18/09 10:11a Yakovlevs
+// Added support of IOAPIC discovery tokens. Some project don't want
+// certain algorithms to be used.
+//
+// 22 5/15/09 12:49p Yakovlevs
+// Fixed logic in IOAPIC discovery ordering.
+//
+// 21 5/14/09 5:39p Yakovlevs
+// Added code to use "USE_BOARD_INFO_APIC_DATA" token
+//
+// 20 5/08/09 1:16p Yakovlevs
+// Made ACPI Driver use AMI Board Info Protocol if available without
+// breaking compatibility.
+//
+// 19 5/07/09 5:46p Markw
+// Use #ifdef ACPI_INFO2_PROTOCOL_PUBLISHED to exclude code that uses ACPI
+// INFO 2 for CPUs that provide the header files.
+//
+// 18 5/04/09 5:49p Markw
+// EIP #17903 If AmiCpuInfo2 Protocol available, MP tables will use this
+// instead of hobs.
+//
+// 17 3/26/09 4:51p Oleksiyy
+// New ACPI Core implementation - improves logic, execution time and
+// memory usage of ACPI module.
+//
+// 16 2/06/09 4:52p Yakovlevs
+// Added Creating EFI Config Table Entry for MPS 14.
+//
+// 15 10/06/08 3:07p Yakovlevs
+// Restored accidentally removed fixes.
+//
+// 14 9/25/08 4:14p Artems
+// Solve problem with non-consecutive IO APIC IDs
+//
+// 13 7/14/08 3:26p Markw
+// In for loop count total number of local apics (hyper-threading) not
+// just number of cores. Code already correctly skips hyper-treading in
+// for loop.
+//
+// 12 7/07/08 5:06p Artems
+// Fixed bug in PCI IOAPIC detection
+//
+// 11 6/11/08 5:58p Markw
+// Update MpsTableAddCpuEntry function to multiple cores and threads to
+// get total CPUs instead just cores.
+//
+// 10 4/15/08 9:16p Yakovlevs
+// Functions Headers added
+//
+// 9 4/11/07 5:44p Artems
+// Multi processor detection added
+//
+// 8 3/28/07 10:42a Artems
+// Fixed bug - added System memory map entry for legacy video
+//
+// 7 3/19/07 12:19p Felixp
+// Clean up
+//
+// 6 3/13/07 6:40p Yakovlevs
+//
+// 5 3/13/07 5:41p Artems
+// MPS 1.4 TABLE SUPPORT added
+//
+// 3 2/06/07 5:38p Artems
+//
+// 2 2/06/07 5:25p Artems
+//
+// 1 2/06/07 4:54p Artems
+//
+
+//<AMI_FHDR_START>
+//----------------------------------------------------------------------------
+//
+// Name: mptable.c
+//
+// Description: MPS table builder functions implementation
+//
+//----------------------------------------------------------------------------
+//<AMI_FHDR_END>
+
+#include <Token.h>
+
+//------------------------ Include files ------------------------------
+
+#include <AmiDxeLib.h>
+#include <AmiHobs.h>
+
+#include <Protocol/LegacyBios.h>
+#include <Protocol/AmiCpuInfo.h>
+
+#ifdef ACPI_INFO2_PROTOCOL_PUBLISHED
+#include <Protocol\AmiCpuInfo2.h>
+#endif
+
+
+#include "acpicore.h"
+#include "mptable.h"
+
+
+#include <Protocol\AmiBoardInfo.h>
+extern AMI_BOARD_INFO_PROTOCOL *gAmiBoardInfoProtocol;
+
+//------------------------ Global variables ---------------------------
+
+static EFI_GUID gMpsTableGuid = MPS_TABLE_GUID;
+static EFI_GUID EfiLegacyBiosProtocolGuid = EFI_LEGACY_BIOS_PROTOCOL_GUID;
+AMI_CPU_INFO_PROTOCOL *AmiCpuInfoProtocol = NULL;
+static EFI_GUID AmiCpuInfoProtocolGuid = AMI_CPU_INFO_PROTOCOL_GUID;
+static EFI_EVENT MpsTableReadyToBootEvent = 0;
+static MP_FLOATING_POINTER MpsTableFloatingPointer;
+static VOID *MpsTablePointer = NULL;
+static VOID *MpsTableCurrentPointer = NULL;
+static VOID *MpsExTablePointer = NULL;
+static VOID *MpsExTableCurrentPointer = NULL;
+static UINT16 BaseTableLength = 0;
+static UINT16 BaseTableEntryCount = 0;
+static UINT16 ExtendedTableLength = 0;
+static UINT8 OemId[8] = CONVERT_TO_STRING(T_ACPI_OEM_TBL_ID); //{ 0,1,2,3,4,5,6,7 };
+static UINT8 ProductId[12] = CONVERT_TO_STRING(T_ACPI_OEM_ID); //{ 0,1,2,3,4,5,6,7,8,9,0xA, 0xB };
+
+static BUS_INFO BusEntry[MP_TABLE_MAX_BUS_ENTRIES];
+static UINT8 MaxBusId = 0;
+static UINT8 CurrentBusEntry = 0;
+static UINT8 IsaBusId = 0;
+static UINT8 *BusTypeString[] = {"CBUS ", "CBUSII", "EISA ", "FUTURE", "INTERN", "ISA ",
+ "MBI ", "MBII ", "MCA ", "MPI ", "MPSA ", "NUBUS ",
+ "PCI ", "PCMCIA", "TC ", "VL ", "VME ", "XPRESS" };
+static UINT8 BridgeBusTypes[] = { 12, 5, 2, 8, 12, 13, 11 }; //each number represents corresponding
+ //number in BusTypeString array, i.e.
+ //bridge subclass 0 - PCI host has number
+ //12 in array, subclass 1 - ISA bridge -
+ //number 5 etc.
+static IO_APIC_INFO IoApicEntry[MP_TABLE_MAX_IO_APIC_ENTRIES];
+static UINT8 CurrentIoApicEntry = 0;
+
+#ifdef ACPI_INFO2_PROTOCOL_PUBLISHED
+extern AMI_CPU_INFO_2_PROTOCOL* gAmiCpu2Info;
+#endif
+
+
+extern ISO_PARAMETER_TABLE IsoTbl[];
+EFI_STATUS MpsTableCreateStatus = EFI_NO_RESPONSE;
+EFI_STATUS MpsTableFloatPointerModifyStatus = EFI_NO_RESPONSE;
+BOOLEAN MpsTableWasCreated = FALSE;
+//------------------------ Functions ----------------------------------
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: MpsTableBuilderInit
+//
+// Description: MPS table builder entry point
+//
+// Input:
+// IN EFI_HANDLE ImageHandle - MPS table builder image handle
+// IN EFI_SYSTEM_TABLE *SystemTaple - pointer to system table
+//
+// Output:
+// EFI_SUCCESS - Initialization completed successfully
+// EFI_ERROR - Initialization failed
+//
+// Modified: MpsTableReadyToBootEvent
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS MpsTableBuilderInit(
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable)
+{
+ EFI_STATUS Status;
+
+ InitAmiLib(ImageHandle,SystemTable);
+
+ Status = CreateReadyToBootEvent(TPL_CALLBACK,
+ MpsTableReadyToBootNotify,
+ NULL,
+ &MpsTableReadyToBootEvent);
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: MpsTableReadyToBootNotify
+//
+// Description: MPS table builder ReadyToBoot notification function
+//
+// Input:
+// IN EFI_EVENT Event - signalled event
+// IN VOID *Context - pointer to calling context
+//
+// Output:
+// VOID
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+VOID MpsTableReadyToBootNotify(
+ IN EFI_EVENT Event,
+ IN VOID *Context)
+{
+ EFI_STATUS Status;
+
+ if(EFI_ERROR(MpsTableCreateStatus))
+ {
+ MpsTableCreateStatus = MpsTableCreate();
+ if(EFI_ERROR(MpsTableCreateStatus))
+ return;
+ }
+ if(EFI_ERROR(MpsTableFloatPointerModifyStatus))
+ MpsTableFloatPointerModifyStatus = MpsTableFloatPointerModify();
+
+ //Install a Configuration table Entry
+ Status=pBS->InstallConfigurationTable(&gMpsTableGuid,MpsTablePointer);
+ ASSERT_EFI_ERROR(Status);
+ if(EFI_ERROR(Status)) return;
+ //After we did everything needed
+ pBS->CloseEvent(Event);
+
+ return;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: MpsTableFloatPointerModify
+//
+// Description: Fills MP_FLOATING_POINTER structure with actual data
+// and places it into F000 segment
+//
+// Input:
+// VOID
+//
+// Output:
+// EFI_SUCCESS - Pointer created and placed successfully
+// EFI_ERROR - Some error occurs
+//
+// Modified: MpsTableFloatingPointer
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+EFI_STATUS MpsTableFloatPointerModify(VOID)
+{
+ EFI_STATUS Status;
+ EFI_LEGACY_BIOS_PROTOCOL *LegacyBiosProtocol;
+ VOID *LegacyRegionAddress;
+
+ MpsTableFloatingPointer.Signature = MP_FLOATING_POINTER_SIGNATURE;
+
+//at this point we have address of MPS table
+ MpsTableFloatingPointer.PhysicalAddresPointer = (UINT32) MpsTablePointer;
+
+//length in 16-byte paragraphs
+ MpsTableFloatingPointer.Length = sizeof(MP_FLOATING_POINTER)/16;
+
+//here must be token
+ MpsTableFloatingPointer.VersionNumber = MP_TABLE_VERSION_1_4;
+
+//force checksum to zero before calculate actual checksum
+ MpsTableFloatingPointer.CheckSum = 0;
+
+//here must be token
+ MpsTableFloatingPointer.DefaultConfiguration = 0;
+
+//here must be token
+ MpsTableFloatingPointer.IMCRflag = 0;
+
+ MpsTableFloatingPointer.Reserved[0] = 0;
+ MpsTableFloatingPointer.Reserved[1] = 0;
+ MpsTableFloatingPointer.Reserved[2] = 0;
+
+//now we are ready to calculate checksum
+ MpsTableFloatingPointer.CheckSum = ChsumTbl((UINT8 *)&MpsTableFloatingPointer,
+ sizeof(MP_FLOATING_POINTER));
+
+ Status = pBS->LocateProtocol(&EfiLegacyBiosProtocolGuid,
+ NULL,
+ &LegacyBiosProtocol);
+ if(EFI_ERROR(Status))
+ return Status;
+
+ Status = LegacyBiosProtocol->GetLegacyRegion(LegacyBiosProtocol,
+ (UINTN)sizeof(MP_FLOATING_POINTER),
+ F0000_BIT,
+ 0x10,
+ &LegacyRegionAddress);
+ if(EFI_ERROR(Status))
+ return Status;
+
+ Status = LegacyBiosProtocol->CopyLegacyRegion(LegacyBiosProtocol,
+ (UINTN) sizeof(MP_FLOATING_POINTER),
+ LegacyRegionAddress,
+ (VOID *) &MpsTableFloatingPointer);
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: MpsTableCreate
+//
+// Description: Allocates space and creates MPS table
+//
+// Input:
+// VOID
+//
+// Output:
+// EFI_SUCCESS - function executed successfully
+// EFI_ERROR - some error occured
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MpsTableCreate(VOID)
+{
+ EFI_STATUS Status;
+ UINT16 EntryCount;
+
+ if (MpsTableWasCreated)
+ return MpsTableAddHeader();
+
+ Status = pBS->AllocatePool(EfiBootServicesData,
+ MP_TBL_TMP_BUFFER_SIZE,
+ &MpsTablePointer);
+ if(EFI_ERROR(Status))
+ return Status;
+
+ MpsTableCurrentPointer = MpsTablePointer;
+
+//split buffer onto two parts for base and extended tables
+ MpsExTablePointer = MpsTablePointer;
+ (UINT8 *)MpsExTablePointer += ((MP_TBL_TMP_BUFFER_SIZE)/2);
+ MpsExTableCurrentPointer = MpsExTablePointer;
+
+//Leave placeholder for header
+ (UINT8 *)MpsTableCurrentPointer += sizeof(MP_CONFIGURATION_TABLE_HEADER);
+ BaseTableLength += sizeof(MP_CONFIGURATION_TABLE_HEADER);
+
+//add CPU Entry
+ EntryCount = MpsTableAddCpuEntry();
+ (UINT8 *)MpsTableCurrentPointer += sizeof(MP_TABLE_CPU_ENTRY) * EntryCount;
+ BaseTableLength += sizeof(MP_TABLE_CPU_ENTRY) * EntryCount;
+ BaseTableEntryCount += EntryCount;
+
+//add Bus Entry
+ EntryCount = MpsTableAddBusEntry();
+ (UINT8 *)MpsTableCurrentPointer += sizeof(MP_TABLE_BUS_ENTRY) * EntryCount;
+ BaseTableLength += sizeof(MP_TABLE_BUS_ENTRY) * EntryCount;
+ BaseTableEntryCount += EntryCount;
+
+//add IO Apic Entry
+ EntryCount = MpsTableAddIoApicEntry();
+ (UINT8 *)MpsTableCurrentPointer += sizeof(MP_TABLE_IO_APIC_ENTRY) * EntryCount;
+ BaseTableLength += sizeof(MP_TABLE_IO_APIC_ENTRY) * EntryCount;
+ BaseTableEntryCount += EntryCount;
+
+//add Interrupt assignment Entry
+ EntryCount = MpsTableAddIntAssignEntry();
+ (UINT8 *)MpsTableCurrentPointer += sizeof(MP_TABLE_INT_ASSIGN_ENTRY) * EntryCount;
+ BaseTableLength += sizeof(MP_TABLE_INT_ASSIGN_ENTRY) * EntryCount;
+ BaseTableEntryCount += EntryCount;
+
+//add Local interrupt assignment Entry
+ EntryCount = MpsTableAddLocalIntAssignEntry();
+ (UINT8 *)MpsTableCurrentPointer += sizeof(MP_TABLE_LOCAL_INT_ASSIGN_ENTRY) * EntryCount;
+ BaseTableLength += sizeof(MP_TABLE_LOCAL_INT_ASSIGN_ENTRY) * EntryCount;
+ BaseTableEntryCount += EntryCount;
+
+ MpsTableAddExtendedTable();
+
+ MpsTableWasCreated = TRUE;
+
+ return MpsTableAddHeader();
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: MpsTableAddHeader
+//
+// Description: Creates MPS table header, allocates space and copies entire
+// table into RuntimeServicesData memory
+//
+// Input:
+// VOID
+//
+// Output:
+// EFI_SUCCESS - function executed successfully
+//
+// Modified: MpsTablePointer
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS MpsTableAddHeader(VOID)
+{
+ EFI_STATUS Status;
+ MP_CONFIGURATION_TABLE_HEADER *HeaderPointer;
+ VOID *AllocationPointer;
+#if MP_TABLE_LEGACY_REGION_LOCATION != 0
+ EFI_LEGACY_BIOS_PROTOCOL *LegacyBiosProtocol;
+#endif
+ HeaderPointer = (MP_CONFIGURATION_TABLE_HEADER *) MpsTablePointer;
+
+ HeaderPointer->Signature = MP_CONFIGURATION_TABLE_SIGNATURE;
+ HeaderPointer->BaseTableLength = BaseTableLength;
+ HeaderPointer->VersionNumber = MP_TABLE_VERSION_1_4;
+ HeaderPointer->CheckSum = 0; //force checksum to zero before calculating
+
+ MemCpy((VOID *)HeaderPointer->OemId, (VOID *)OemId, 8);
+ MemCpy((VOID *)HeaderPointer->ProductId, (VOID *)ProductId, 12);
+
+ HeaderPointer->OemTablePointer = 0;
+ HeaderPointer->OemTableSize = 0;
+ HeaderPointer->BaseTableEntryCount = BaseTableEntryCount;
+ HeaderPointer->LocalApicAddress = LOCAL_APIC_BASE; //sdl token
+ HeaderPointer->ExtendedTableLength = ExtendedTableLength;
+ HeaderPointer->ExtendedCheckSum = 0;
+ HeaderPointer->Reserved = 0;
+
+ HeaderPointer->ExtendedCheckSum = ChsumTbl(MpsExTablePointer, ExtendedTableLength);
+ HeaderPointer->CheckSum = ChsumTbl(MpsTablePointer, BaseTableLength);
+
+#if MP_TABLE_LEGACY_REGION_LOCATION == 0
+
+//publish table in high memory
+ Status = pBS->AllocatePool(EfiRuntimeServicesData,
+ BaseTableLength + ExtendedTableLength,
+ &AllocationPointer);
+
+ if(EFI_ERROR(Status))
+ return Status;
+ MemCpy(AllocationPointer, //memory allocated - copy MPS table to new location
+ MpsTablePointer,
+ (UINTN) (BaseTableLength + ExtendedTableLength));
+
+#else
+
+//publish table in F0000 segment
+ Status = pBS->LocateProtocol(&EfiLegacyBiosProtocolGuid,
+ NULL,
+ &LegacyBiosProtocol);
+ if(EFI_ERROR(Status))
+ return Status;
+
+ Status = LegacyBiosProtocol->GetLegacyRegion(LegacyBiosProtocol,
+ (UINTN)(BaseTableLength + ExtendedTableLength),
+ F0000_BIT,
+ 0x10,
+ &AllocationPointer);
+ if(EFI_ERROR(Status))
+ return Status;
+
+ Status = LegacyBiosProtocol->CopyLegacyRegion(LegacyBiosProtocol,
+ (UINTN) (BaseTableLength + ExtendedTableLength),
+ AllocationPointer,
+ MpsTablePointer);
+#endif
+
+ pBS->FreePool(MpsTablePointer);
+ MpsTablePointer = AllocationPointer;
+
+ return Status;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: MpsTableAddCpuEntryByHob
+//
+// Description: Adds CPU entries to MPS table from HOB.
+//
+// Input:
+// VOID
+//
+// Output:
+// UINT16 - Number of entries added
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+UINT16 MpsTableAddCpuEntryByHob(VOID)
+{
+ MP_TABLE_CPU_ENTRY *EntryPointer;
+ UINT16 EntryCount = 0;
+ static EFI_GUID CpuInfoHobGuid = AMI_CPUINFO_HOB_GUID;
+ static EFI_GUID HobListGuid = HOB_LIST_GUID;
+ CPUINFO_HOB *pCpuInfoHob;
+ CPUINFO CpuInfo;
+ VOID *pHobList;
+ EFI_STATUS Status;
+ INTN i;
+ UINTN CpuIndex = 0;
+ UINT8 NumberOfCores;
+ UINT8 NumberOfThreads;
+
+
+ EntryPointer = (MP_TABLE_CPU_ENTRY *)MpsTableCurrentPointer;
+
+ pHobList = GetEfiConfigurationTable(pST, &HobListGuid);
+ if(pHobList == NULL)
+ Status = EFI_NOT_FOUND;
+ else
+ Status = FindNextHobByGuid(&CpuInfoHobGuid, &pHobList);
+
+ //If no CPU info available, we've got a UniProccessor System
+ if (EFI_ERROR(Status))
+ {
+ EntryPointer->EntryType = MP_TABLE_CPU_ENTRY_TYPE;
+ EntryPointer->LocalApicId = 0;
+ EntryPointer->LocalApicVersion = 0;
+ EntryPointer->CpuFlags.CpuEnable = 1;
+ EntryPointer->CpuFlags.CpuBootStrap = 1;
+ EntryPointer->CpuFlags.Reserved = 0;
+ EntryPointer->CpuSignature = 0;
+ EntryPointer->FeatureFlags = 0;
+ EntryPointer->Reserved[0] = 0;
+ EntryPointer->Reserved[1] = 0;
+
+ return 1; //just one CPU entry
+ }
+
+ pCpuInfoHob = (CPUINFO_HOB *)pHobList;
+
+ while(!EFI_ERROR(GetCpuInfo(CpuIndex, &NumberOfCores, &NumberOfThreads)))
+ {
+ for(i = 0; i < NumberOfCores * NumberOfThreads; i += NumberOfThreads)
+ {
+ CpuInfo = pCpuInfoHob->Cpuinfo[i + CpuIndex];
+
+ EntryPointer->EntryType = MP_TABLE_CPU_ENTRY_TYPE;
+ EntryPointer->LocalApicId = CpuInfo.ApicId;
+ EntryPointer->LocalApicVersion = CpuInfo.ApicVer;
+ EntryPointer->CpuFlags.CpuEnable = (CpuInfo.Disabled) ? 0 : 1;
+ EntryPointer->CpuFlags.CpuBootStrap = ((i + CpuIndex) == pCpuInfoHob->BspNo) ? 1 : 0;
+ EntryPointer->CpuFlags.Reserved = 0;
+ EntryPointer->CpuSignature = CpuInfo.CpuSignature;
+ EntryPointer->FeatureFlags = (UINT32) CpuInfo.CpuFeatureInfo;
+ EntryPointer->Reserved[0] = 0;
+ EntryPointer->Reserved[1] = 0;
+
+ EntryPointer++;
+ EntryCount++;
+ }
+ CpuIndex += NumberOfCores * NumberOfThreads;
+ }
+ return EntryCount;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: MpsTableAddCpuEntryByProtocol.
+//
+// Description: Adds CPU entries to MPS table from protocol.
+//
+// Input:
+// VOID
+//
+// Output:
+// UINT16 - Number of entries added
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+#ifdef ACPI_INFO2_PROTOCOL_PUBLISHED
+UINT16 MpsTableAddCpuEntryByProtocol(VOID)
+{
+ MP_TABLE_CPU_ENTRY *EntryPointer;
+ EFI_STATUS Status;
+ ACPI_PROCESSOR_INFO *AcpiProcInfo;
+ UINT32 NumEntries;
+ UINT32 EntryCount = 0;
+ UINT32 Index;
+
+ if (gAmiCpu2Info->ProtocolVer < 1) return 0;
+
+ Status = gAmiCpu2Info->GetAcpiInfo(
+ gAmiCpu2Info, (VOID**) &AcpiProcInfo, &NumEntries
+ );
+ if (EFI_ERROR(Status)) return 0;
+
+ EntryPointer = (MP_TABLE_CPU_ENTRY *)MpsTableCurrentPointer;
+
+ for (Index = 0; Index < NumEntries; ++Index) {
+ //Note: Only some ACPI_PROCESSOR_INFO fields may only valid for some minimum ACPI_PROCESSOR_INFO.Length.
+ //The ACPI_PROCESSOR_INFO may have additional fields added in later version. Please see comments in
+ //AmiCpuInfo2.h file.
+ if (AcpiProcInfo->Type == ACPI_PROCESSOR_INFO_TYPE
+ && AcpiProcInfo->Thread == 0
+ ) {
+ EntryPointer->EntryType = MP_TABLE_CPU_ENTRY_TYPE;
+ EntryPointer->LocalApicId = AcpiProcInfo->ApicId;
+ EntryPointer->LocalApicVersion = AcpiProcInfo->ApicVer;
+ EntryPointer->CpuFlags.CpuEnable = AcpiProcInfo->Enable;
+ EntryPointer->CpuFlags.CpuBootStrap = AcpiProcInfo->Bsp;
+ EntryPointer->CpuFlags.Reserved = 0;
+ EntryPointer->CpuSignature = AcpiProcInfo->CpuSignature;
+ EntryPointer->FeatureFlags = AcpiProcInfo->FeatureFlags;
+ EntryPointer->Reserved[0] = 0;
+ EntryPointer->Reserved[1] = 0;
+ EntryPointer++;
+ EntryCount++;
+ }
+
+ AcpiProcInfo = (ACPI_PROCESSOR_INFO*)((UINT8*)AcpiProcInfo + AcpiProcInfo->Length);
+ }
+
+ return (UINT16)EntryCount;
+}
+#endif
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: MpsTableAddCpuEntry.
+//
+// Description: Adds CPU entries to MPS table.
+//
+// Input:
+// VOID
+//
+// Output:
+// UINT16 - Number of entries added
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+
+UINT16 MpsTableAddCpuEntry(VOID)
+{
+ UINT16 EntryCount = 0;
+ //First try to build Local APIC information from the protocol.
+#ifdef ACPI_INFO2_PROTOCOL_PUBLISHED
+ if (gAmiCpu2Info != NULL) EntryCount = MpsTableAddCpuEntryByProtocol();
+ //If protocol fails, try CPU INFO HOB.
+#endif
+ if (!EntryCount) EntryCount = MpsTableAddCpuEntryByHob();
+ return EntryCount;
+}
+
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: MpsTableAddBusEntry
+//
+// Description: Adds Bus entries to MPS table
+//
+// Input:
+// VOID
+//
+// Output:
+// UINT16 - Number of entries added
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 MpsTableAddBusEntry(VOID)
+{
+ MP_TABLE_BUS_ENTRY *EntryPointer;
+ UINT16 EntryCount = 0;
+ UINT16 i;
+
+ EntryPointer = (MP_TABLE_BUS_ENTRY *)MpsTableCurrentPointer;
+
+ QueryBusInfo();
+
+ for(i = 0; i < CurrentBusEntry; i++)
+ {
+ EntryPointer->EntryType = MP_TABLE_BUS_ENTRY_TYPE;
+ EntryPointer->BusId = BusEntry[i].BusId;
+
+ MemCpy((VOID *)EntryPointer->BusTypeString, (VOID *)BusTypeString[(BusEntry[i].BusType)], 6);
+
+ EntryPointer++;
+ EntryCount++;
+ }
+ return EntryCount;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: MpsTableAddIoApicEntry
+//
+// Description: Adds IO Apic entries to MPS table
+//
+// Input:
+// VOID
+//
+// Output:
+// UINT16 - Number of entries added
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 MpsTableAddIoApicEntry(VOID)
+{
+ MP_TABLE_IO_APIC_ENTRY *EntryPointer;
+ UINT16 EntryCount = 0;
+ UINT8 i=0;
+#if FEC00000_APIC_AUTODETECT == 1
+ UINT64 SearchAddress=0;
+#endif
+ EntryPointer = (MP_TABLE_IO_APIC_ENTRY *)MpsTableCurrentPointer;
+
+#if FEC00000_APIC_AUTODETECT == 1
+//first we detect IO APICS mapped into default address range
+ for(SearchAddress = IO_APIC_BASE_ADDRESS_BOTTOM;
+ SearchAddress < IO_APIC_BASE_ADDRESS_TOP;
+ SearchAddress += IO_APIC_SEARCH_STEP)
+
+ if(*((UINT8 *)SearchAddress) != 0xFF) //we have something
+ CollectIoApicInfo(NULL, (UINT32)SearchAddress);
+
+//second we arrange IO APIC in their ID ascending order (if there more than one)
+#endif
+
+
+//Check also SDL ceated Structures they might address very none standard IOAPICS.
+//-------------------------------------------------------------------------------------------
+
+#if USE_BOARD_INFO_APIC_DATA == 1
+{
+ AMI_APIC_INFO *BrdApicInfo;
+ BOOLEAN Present;
+ UINTN j;
+ //-----------------
+ for(i=0; i<(gAmiBoardInfoProtocol->ApicInfoLength/sizeof(AMI_APIC_INFO)); i++){
+ BrdApicInfo=&gAmiBoardInfoProtocol->ApicInfoTable[i];
+ //This is a special case it could be a duplicate entries in MadtTblEntries[]
+ //if other options of IOAPIC/IOsAPIC detection was on.
+ //So check if IOAPIC/IOsAPIC entries with the same properties already present in DB.
+ for(j=0,Present=FALSE; j < CurrentIoApicEntry; j++){
+ if(BrdApicInfo->ApicAddress.ADDRESS == IoApicEntry[j].IoApicAddress){
+ Present = TRUE;
+ break;
+ }
+ }
+ //Entry with this address already present in IoApicEntry[] array
+ if(Present) continue;
+
+ //Looks like it is a new IOAPIC/IOSAPIC entry!
+ //Check if something alive at this address
+ CollectIoApicInfo(NULL, BrdApicInfo->ApicAddress.ADDRESS);
+ } // for(...i<(gAmiBoardInfoProtocol->ApicInfoLength/sizeof(AMI_APIC_INFO))
+}
+#endif //USE_BOARD_INFO_APIC_DATA ==1
+
+//-------------------------------------------------------------------------------------------
+
+ if(CurrentIoApicEntry > 1)
+ ArrangeIoApicEntries();
+
+
+//now we are ready to create MPS table IO APIC entries
+ for(i = 0; i < CurrentIoApicEntry; i++)
+ {
+ EntryPointer->EntryType = MP_TABLE_IO_APIC_ENTRY_TYPE;
+ EntryPointer->IoApicId = IoApicEntry[i].IoApicId;
+ EntryPointer->IoApicVersion = IoApicEntry[i].IoApicVersion;
+ EntryPointer->Flags = IoApicEntry[i].IoApicFlags;
+ EntryPointer->IoApicAddress = IoApicEntry[i].IoApicAddress;
+
+ EntryPointer++;
+ EntryCount++;
+ }
+ return EntryCount;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: MpsTableAddIntAssignEntry
+//
+// Description: Adds Interrupt assignment entries to MPS table
+//
+// Input:
+// VOID
+//
+// Output:
+// UINT16 - Number of entries added
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 MpsTableAddIntAssignEntry(VOID)
+{
+
+ MP_TABLE_INT_ASSIGN_ENTRY *EntryPointer;
+ UINT16 EntryCount = 0;
+ UINT16 Dummy;
+ PCI_IRQ_APIC_ROUTE *RouteTable;
+ UINT8 i, j;
+
+ EntryPointer = (MP_TABLE_INT_ASSIGN_ENTRY *)MpsTableCurrentPointer;
+
+//First assign ISA IRQ interrupts
+ AmiIsaIrqMask(&Dummy, TRUE);
+
+ for(i = 0; i < 16; i++)
+ {
+ if((Dummy & 1) && (i != 2)) //create entry only if IRQ is used
+ { //and it isn't IRQ2
+ EntryPointer->EntryType = MP_TABLE_INT_ASSIGN_ENTRY_TYPE;
+ EntryPointer->InterruptType = INT_TYPE_INT;
+ EntryPointer->Flags = (UINT16)IsoTbl[i].Flags;
+ EntryPointer->SourceBusId = IsaBusId;
+ EntryPointer->SourceBusIrq.IsaBusIrq = i;
+//define Apic ID and Itin depends of GLobal sys vector
+ GetIoApicId(IsoTbl[i].ApicInt,
+ &EntryPointer->DestIoApicId,
+ &EntryPointer->DestIoApicItin);
+
+ EntryPointer++;
+ EntryCount++;
+ }
+ Dummy >>= 1;
+ }
+
+//Second assign PCI IRQ Entries
+
+ Dummy = (UINT16)gAmiBoardInfoProtocol->ApicRoutLength/sizeof(PCI_IRQ_APIC_ROUTE);
+ RouteTable = gAmiBoardInfoProtocol->ApicRoutTable;
+
+ for(i = 0; i < Dummy; i++)
+ {
+//define runtime bus number from build bus number
+
+ for(j = 0; j < 4; j++)
+ {
+ if((RouteTable[i].Intn[j].IoApicItin != 0) || (RouteTable[i].Intn[j].IoApicId != 0))
+ {
+ EntryPointer->EntryType = MP_TABLE_INT_ASSIGN_ENTRY_TYPE;
+ EntryPointer->InterruptType = INT_TYPE_INT;
+ EntryPointer->Flags = 0; //always conforms PCI bus specs
+ EntryPointer->SourceBusId = RouteTable[i].PciBusNumber;
+ EntryPointer->SourceBusIrq.PciBusIrq.PciIntSignal = j;
+ EntryPointer->SourceBusIrq.PciBusIrq.PciDeviceNumber = RouteTable[i].DeviceNumber;
+ EntryPointer->SourceBusIrq.PciBusIrq.Reserved = 0;
+ EntryPointer->DestIoApicId = RouteTable[i].Intn[j].IoApicId;
+ EntryPointer->DestIoApicItin = RouteTable[i].Intn[j].IoApicItin;
+
+ EntryPointer++;
+ EntryCount++;
+ }
+ }
+ }
+
+ return EntryCount;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: MpsTableAddLocalIntAssignEntry
+//
+// Description: Adds Local interrupt assignment entries to MPS table
+//
+// Input:
+// VOID
+//
+// Output:
+// UINT16 - Number of entries added
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+UINT16 MpsTableAddLocalIntAssignEntry(VOID)
+{
+ MP_TABLE_LOCAL_INT_ASSIGN_ENTRY *EntryPointer;
+ UINT16 EntryCount = 0;
+
+ EntryPointer = (MP_TABLE_LOCAL_INT_ASSIGN_ENTRY *)MpsTableCurrentPointer;
+
+ EntryPointer->EntryType = MP_TABLE_LOCAL_INT_ASSIGN_ENTRY_TYPE;
+ EntryPointer->InterruptType = INT_TYPE_EXT_INT;
+ EntryPointer->InterruptSignal.Polarity = POLARITY_CONFORM_SPEC;
+ EntryPointer->InterruptSignal.TriggerMode = TRIGGER_MODE_CONFORM_SPEC;
+ EntryPointer->InterruptSignal.Reserved = 0;
+ EntryPointer->SourceBusId = 0;
+ EntryPointer->SourceBusIrq = 0;
+ EntryPointer->DestLocalApicId = 0xFF;
+ EntryPointer->DestLocalApicItin = 0;
+
+ EntryPointer++;
+ EntryCount++;
+
+ EntryPointer->EntryType = MP_TABLE_LOCAL_INT_ASSIGN_ENTRY_TYPE;
+ EntryPointer->InterruptType = INT_TYPE_NMI;
+ EntryPointer->InterruptSignal.Polarity = POLARITY_CONFORM_SPEC;
+ EntryPointer->InterruptSignal.TriggerMode = TRIGGER_MODE_CONFORM_SPEC;
+ EntryPointer->InterruptSignal.Reserved = 0;
+ EntryPointer->SourceBusId = 0;
+ EntryPointer->SourceBusIrq = 0;
+ EntryPointer->DestLocalApicId = 0xFF;
+ EntryPointer->DestLocalApicItin = 1;
+
+ EntryPointer++;
+ EntryCount++;
+
+ return EntryCount;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: MpsTableAddExtendedTable
+//
+// Description: Adds Extended table entries to base table
+//
+// Input:
+// VOID
+//
+// Output:
+// VOID
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID MpsTableAddExtendedTable(VOID)
+{
+ MemCpy(MpsTableCurrentPointer, MpsExTablePointer, ExtendedTableLength);
+ MpsExTablePointer = MpsTableCurrentPointer;
+ return;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: MpsExTableAddSysAddressMapEntry
+//
+// Description: Creates Extended MPS table system address space map entryies
+//
+// Input:
+// IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *pPciRootBridgeIoProtocol
+// IN UINT8 BusId - PCI bus number
+// IN UINT8 BusAttributes - PCI bus attributes
+//
+// Output:
+// VOID
+//
+// Modified: MpsExTableCurrentPointer
+// ExtendedTableLength
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID MpsExTableAddSysAddressMapEntry(
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *pPciRootBridgeIoProtocol,
+ IN UINT8 BusId,
+ IN UINT8 BusAttributes)
+{
+ MP_EX_TABLE_SYS_ADDRESS_MAP_ENTRY *EntryPointer;
+ ACPI_ADDRESS_SPACE_DESC *Resources;
+ BOOLEAN VgaMemoryAdded = FALSE;
+
+ EntryPointer = (MP_EX_TABLE_SYS_ADDRESS_MAP_ENTRY *)MpsExTableCurrentPointer;
+
+ pPciRootBridgeIoProtocol->Configuration(pPciRootBridgeIoProtocol, &Resources);
+
+//add entries to ISA decode
+ if(BusAttributes & 0x3) //support ISA I/O space
+ {
+ EntryPointer->EntryType = MP_EX_TABLE_SYS_ADDRESS_MAP_ENTRY_TYPE;
+ EntryPointer->EntryLength = sizeof(MP_EX_TABLE_SYS_ADDRESS_MAP_ENTRY);
+ EntryPointer->BusId = BusId;
+ EntryPointer->AddressType = 0; //IO descriptor
+ EntryPointer->AddressBase = 0;
+ EntryPointer->AddressLength = 0x1000;
+ EntryPointer++;
+ ExtendedTableLength += sizeof(MP_EX_TABLE_SYS_ADDRESS_MAP_ENTRY);
+ }
+
+ while(Resources->Signature == 0x8A)
+ {
+ if(Resources->ResourceType != 2 && Resources->AddressLength)
+ {
+ if(Resources->ResourceType == 1) //IO descriptor
+ EntryPointer->AddressType = 0;
+ else if(Resources->TypeSpecificFlags & 6) //bits 1 and 2 set
+ EntryPointer->AddressType = 2; //memory prefetch address
+ else
+ EntryPointer->AddressType = 1; //memory descriptor
+
+// VGA region should be at the beginning of Memory range
+ if ((EntryPointer->AddressType == 1) && (BusAttributes & 0x1C) && (!(VgaMemoryAdded))) {
+ EntryPointer->EntryType = MP_EX_TABLE_SYS_ADDRESS_MAP_ENTRY_TYPE;
+ EntryPointer->EntryLength = sizeof(MP_EX_TABLE_SYS_ADDRESS_MAP_ENTRY);
+ EntryPointer->BusId = BusId;
+ EntryPointer->AddressType = 1; //memory descriptor
+ EntryPointer->AddressBase = 0xA0000;
+ EntryPointer->AddressLength = 0x20000;
+ EntryPointer++;
+ ExtendedTableLength += sizeof(MP_EX_TABLE_SYS_ADDRESS_MAP_ENTRY);
+ VgaMemoryAdded = TRUE;
+ EntryPointer->AddressType = 1; //memory descriptor
+ }
+
+ EntryPointer->EntryType = MP_EX_TABLE_SYS_ADDRESS_MAP_ENTRY_TYPE;
+ EntryPointer->EntryLength = sizeof(MP_EX_TABLE_SYS_ADDRESS_MAP_ENTRY);
+ EntryPointer->BusId = BusId;
+ EntryPointer->AddressBase = Resources->AddressRangeMin;
+ EntryPointer->AddressLength = Resources->AddressLength;
+
+ EntryPointer++;
+ ExtendedTableLength += sizeof(MP_EX_TABLE_SYS_ADDRESS_MAP_ENTRY);
+ }
+ Resources++;
+ }
+
+ MpsExTableCurrentPointer = (VOID *)EntryPointer;
+
+ return;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: MpsExTableAddBusHierarchyEntry
+//
+// Description: Creates Extended MPS table bus hierarchy entryies
+//
+// Input:
+// VOID
+//
+// Output:
+// VOID
+//
+// Modified: MpsExTableCurrentPointer
+// ExtendedTableLength
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID MpsExTableAddBusHierarchyEntry(VOID)
+{
+ MP_EX_TABLE_BUS_HIERARCHY_ENTRY *EntryPointer;
+ UINT8 i;
+
+ EntryPointer = (MP_EX_TABLE_BUS_HIERARCHY_ENTRY *)MpsExTableCurrentPointer;
+
+ for(i = 0; i < CurrentBusEntry; i++)
+ {
+ if(BusEntry[i].ParentBusId != 0xFF && BusEntry[i].BusType != 12) //skip root bridge and P2P bridge
+ {
+ EntryPointer->EntryType = MP_EX_TABLE_BUS_HIERARCHY_ENTRY_TYPE;
+ EntryPointer->EntryLength = sizeof(MP_EX_TABLE_BUS_HIERARCHY_ENTRY);
+ EntryPointer->BusId = BusEntry[i].BusId;
+ EntryPointer->BusInfo = BusEntry[i].Flags;
+ EntryPointer->ParentBusId = BusEntry[i].ParentBusId;
+ EntryPointer->Reserved[0] = 0;
+ EntryPointer->Reserved[1] = 0;
+ EntryPointer->Reserved[2] = 0;
+
+ EntryPointer++;
+ ExtendedTableLength += sizeof(MP_EX_TABLE_BUS_HIERARCHY_ENTRY);
+ }
+ }
+ MpsExTableCurrentPointer = (VOID *)EntryPointer;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: MpsExTableAddCompatBusAddressModifierEntry
+//
+// Description: Creates Extended MPS table compatibility bus address space
+// modifier entryies
+//
+// Input:
+// VOID
+//
+// Output:
+// VOID
+//
+// Modified: MpsExTableCurrentPointer
+// ExtendedTableLength
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID MpsExTableAddCompatBusAddressModifierEntry(VOID)
+{
+ MP_EX_TABLE_COMPAT_BUS_ADDRESS_MODIFIER_ENTRY *EntryPointer;
+ UINT8 i;
+
+ EntryPointer = (MP_EX_TABLE_COMPAT_BUS_ADDRESS_MODIFIER_ENTRY *)MpsExTableCurrentPointer;
+
+ for(i = 0; i < CurrentBusEntry; i++)
+ {
+ if(BusEntry[i].ParentBusId == 0xFF)
+ {
+ //add/subtract ISA predefined range
+ EntryPointer->EntryType = MP_EX_TABLE_COMPAT_BUS_ADDRESS_MODIFIER_ENTRY_TYPE;
+ EntryPointer->EntryLength = sizeof(MP_EX_TABLE_COMPAT_BUS_ADDRESS_MODIFIER_ENTRY);
+ EntryPointer->BusId = BusEntry[i].BusId;
+ EntryPointer->RangeList = 0; //isa range list
+ EntryPointer->AddressModifier = (BusEntry[i].Flags & 0x3) ? 0 : 1;
+
+ EntryPointer++;
+ ExtendedTableLength += sizeof(MP_EX_TABLE_COMPAT_BUS_ADDRESS_MODIFIER_ENTRY);
+
+ //add/subtract VGA predefined range
+ EntryPointer->EntryType = MP_EX_TABLE_COMPAT_BUS_ADDRESS_MODIFIER_ENTRY_TYPE;
+ EntryPointer->EntryLength = sizeof(MP_EX_TABLE_COMPAT_BUS_ADDRESS_MODIFIER_ENTRY);
+ EntryPointer->BusId = BusEntry[i].BusId;
+ EntryPointer->RangeList = 1; //vga range list
+ EntryPointer->AddressModifier = (BusEntry[i].Flags & 0x1C) ? 0 : 1;
+
+ EntryPointer++;
+ ExtendedTableLength += sizeof(MP_EX_TABLE_COMPAT_BUS_ADDRESS_MODIFIER_ENTRY);
+ }
+ }
+ MpsExTableCurrentPointer = (VOID *)EntryPointer;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: QueryBusInfo
+//
+// Description: Retreive system info about buses and bus ierarchy and fills
+// BUS_INFO structure. Also creates MPS table extended entries
+//
+// Input:
+// VOID
+//
+// Output:
+// VOID
+//
+// Modified: BusEntry
+// MaxBusId
+// CurrentBusEntry
+// IsaBusId
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID QueryBusInfo(VOID)
+{
+ EFI_STATUS Status;
+ EFI_HANDLE *pHandleBuffer;
+ UINTN NumberOfHandles;
+ UINTN i;
+
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *pPciRootBridgeIoProtocol;
+ static EFI_GUID PciRootBridgeIoProtocolGuid = EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID;
+ ACPI_ADDRESS_SPACE_DESC *pAddressDescriptor;
+
+ EFI_PCI_IO_PROTOCOL *pPciIoProtocol;
+ static EFI_GUID PciIoProtocolGuid = EFI_PCI_IO_PROTOCOL_GUID;
+ UINT8 PciData[4];
+ UINTN BusNumber;
+ UINTN dummy[3];
+ UINT64 SupportedAttributes;
+
+//First detect and retreive bus Id for PCI host (root) buses
+ Status = pBS->LocateHandleBuffer(ByProtocol, &PciRootBridgeIoProtocolGuid,
+ NULL, &NumberOfHandles, &pHandleBuffer);
+ if(EFI_ERROR(Status))
+ return;
+
+ for(i = 0; i < NumberOfHandles; i++)
+ {
+ Status = pBS->HandleProtocol(pHandleBuffer[i], &PciRootBridgeIoProtocolGuid,
+ (VOID**)&pPciRootBridgeIoProtocol);
+ ASSERT_EFI_ERROR(Status);
+ Status = pPciRootBridgeIoProtocol->Configuration(pPciRootBridgeIoProtocol,
+ &pAddressDescriptor);
+ ASSERT_EFI_ERROR(Status);
+ Status = pPciRootBridgeIoProtocol->GetAttributes(pPciRootBridgeIoProtocol,
+ &SupportedAttributes,
+ NULL);
+ ASSERT_EFI_ERROR(Status);
+//find bus range decoding - the min will be host PCI bus Id
+ while((pAddressDescriptor->Signature == 0x8A) && \
+ (pAddressDescriptor->ResourceType != 2))
+ pAddressDescriptor++;
+
+ BusEntry[CurrentBusEntry].BusId = (UINT8)pAddressDescriptor->AddressRangeMin;
+ BusEntry[CurrentBusEntry].ParentBusId = 0xFF; //host bus has no parent
+ BusEntry[CurrentBusEntry].BusType = BridgeBusTypes[0];
+ BusEntry[CurrentBusEntry].Flags = (UINT8)SupportedAttributes; //for host we save ISA/VGA support values
+
+ MaxBusId = (MaxBusId > BusEntry[CurrentBusEntry].BusId) ? \
+ MaxBusId : BusEntry[CurrentBusEntry].BusId;
+
+ MpsExTableAddSysAddressMapEntry(pPciRootBridgeIoProtocol,
+ BusEntry[CurrentBusEntry].BusId,
+ BusEntry[CurrentBusEntry].Flags);
+ CurrentBusEntry++;
+ }
+ pBS->FreePool(pHandleBuffer);
+
+//Second detect all other buses via PCI bridges
+ Status = pBS->LocateHandleBuffer(ByProtocol, &PciIoProtocolGuid,
+ NULL, &NumberOfHandles, &pHandleBuffer);
+ if(EFI_ERROR(Status))
+ return;
+
+ for(i = 0; i < NumberOfHandles; i++)
+ {
+ Status = pBS->HandleProtocol(pHandleBuffer[i], &PciIoProtocolGuid,
+ (VOID**)&pPciIoProtocol);
+ if(EFI_ERROR(Status))
+ continue;
+
+ //read class code information at 0x8 offset in PCI header
+ Status = pPciIoProtocol->Pci.Read(pPciIoProtocol, EfiPciIoWidthUint32,
+ 0x8, 1, (VOID*)PciData);
+ if(EFI_ERROR(Status)) //problem
+ continue;
+#if PCI_BUS_APIC_AUTODETECT == 1
+//if IO APIC device collect info, we will need it later
+ if((PciData[3] == 0x8) && (PciData[2] == 0) && (PciData[1] >= 0x10))
+ {
+ UINT64 Attr=0, OldAttr=0;
+ //----------------------
+ //1. make sure it is Enabled and Decoding it's resources
+ Status=pPciIoProtocol->Attributes(pPciIoProtocol,EfiPciIoAttributeOperationGet, Attr, &OldAttr);
+ ASSERT_EFI_ERROR(Status);
+ if(EFI_ERROR(Status)) continue;
+
+ Status=pPciIoProtocol->Attributes(pPciIoProtocol,EfiPciIoAttributeOperationSupported, 0, &Attr);
+ ASSERT_EFI_ERROR(Status);
+ if(EFI_ERROR(Status)) continue;
+
+ Status=pPciIoProtocol->Attributes(pPciIoProtocol,EfiPciIoAttributeOperationSet, Attr&(EFI_PCI_DEVICE_ENABLE), NULL);
+ ASSERT_EFI_ERROR(Status);
+ if(EFI_ERROR(Status)) continue;
+
+ CollectIoApicInfo(pPciIoProtocol, NULL);
+
+#if PCI_BUS_APIC_LEAVE_ENABLE != 0
+ //Restore attributes of the device
+ Status=pPciIoProtocol->Attributes(pPciIoProtocol,EfiPciIoAttributeOperationSet, OldAttr, NULL);
+ ASSERT_EFI_ERROR(Status);
+ if(EFI_ERROR(Status)) continue;
+#endif//PCI_BUS_APIC_LEAVE_ENABLE
+
+ continue;
+ }
+#endif//PCI_BUS_APIC_AUTODETECT
+
+ if(PciData[3] != 0x6) //not bridge device
+ continue;
+
+ if((PciData[2] == 0) || (PciData[2] > 6)) //PCI host bridge we already know, so skip it
+ continue; //or unknown bridge - skip it also
+
+ BusEntry[CurrentBusEntry].BusType = BridgeBusTypes[(PciData[2])];
+
+ if(PciData[2] == 4) // PCI to PCI bridge
+ {
+ BusEntry[CurrentBusEntry].Flags = PciData[1];
+ //read primary and secondary bus numbers
+ Status = pPciIoProtocol->Pci.Read(pPciIoProtocol, EfiPciIoWidthUint32,
+ 0x18, 1, (VOID*)PciData);
+
+ BusEntry[CurrentBusEntry].BusId = PciData[1]; //bus Id prodused by this bridge
+ BusEntry[CurrentBusEntry].ParentBusId = PciData[0];
+ MaxBusId = (MaxBusId > BusEntry[CurrentBusEntry].BusId) ? \
+ MaxBusId : BusEntry[CurrentBusEntry].BusId;
+ }
+ else //any other bridge
+ {
+ BusEntry[CurrentBusEntry].Flags = 1; //all other buses has this feature
+ BusEntry[CurrentBusEntry].BusId = 0xFF; //we will assign Id after enumerating PCI buses
+ //get bridge location to determine parent bus Id
+ Status = pPciIoProtocol->GetLocation(pPciIoProtocol, &dummy[0], &BusNumber,
+ &dummy[1], &dummy[2]);
+
+ BusEntry[CurrentBusEntry].ParentBusId = (UINT8)BusNumber;
+ }
+ CurrentBusEntry++;
+ }
+ pBS->FreePool(pHandleBuffer);
+
+// Third enumerate all other buses
+ for(i = 0; i < CurrentBusEntry; i++)
+ {
+ if(BusEntry[i].BusId == 0xFF)
+ {
+ BusEntry[i].BusId = MaxBusId + 1;
+ MaxBusId++;
+ if(BusEntry[i].BusType == BUS_TYPE_ISA) //save ISA bus Id for interrupt assign procedure
+ IsaBusId = MaxBusId;
+ }
+ }
+ MpsExTableAddBusHierarchyEntry();
+ MpsExTableAddCompatBusAddressModifierEntry();
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: CollectIoApicInfo
+//
+// Description: Retreive system info about IO APIC
+//
+// Input:
+// IN OPTIONAL EFI_PCI_IO_PROTOCOL *pPciIoProtocol
+// IN OPTIONAL UINT32 BaseAddress - base address of IO APIC
+//
+// Output:
+// VOID
+//
+// Modified: IoApicEntry
+// CurrentIoApicEntry
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID CollectIoApicInfo(
+ IN EFI_PCI_IO_PROTOCOL *pPciIoProtocol OPTIONAL,
+ IN UINT32 BaseAddress OPTIONAL)
+{
+ UINT32 IoApicAddress;
+ EFI_STATUS Status;
+ UINT32 volatile *IoApicMemory32;
+ UINT8 volatile *IoApicMemory8;
+ UINT32 data;
+
+ if(BaseAddress == NULL) //IO APIC visible as PCI device
+ {
+ Status = pPciIoProtocol->Pci.Read(pPciIoProtocol, EfiPciIoWidthUint32,
+ 0x10, 1, (VOID*)&IoApicAddress);
+ if(EFI_ERROR(Status) || (IoApicAddress == 0)) //problem or mapped to default address range
+ return;
+ }
+ else // IO APIC mapped to default range
+ IoApicAddress = BaseAddress;
+
+ IoApicMemory32 = (UINT32 *)IoApicAddress;
+ IoApicMemory8 = (UINT8 *)IoApicAddress;
+
+ IoApicMemory8[IO_APIC_INDEX_REG] = IO_APIC_MAP_ID_REG;
+ data = IoApicMemory32[IO_APIC_DATA_REG];
+
+ IoApicEntry[CurrentIoApicEntry].IoApicId = (UINT8)((data & 0x0F000000) >> 24);
+
+ IoApicMemory8[IO_APIC_INDEX_REG] = IO_APIC_MAP_VERSION_REG;
+ data = IoApicMemory32[IO_APIC_DATA_REG];
+
+ IoApicEntry[CurrentIoApicEntry].IoApicVersion = (UINT8)(data & 0xFF);
+ IoApicEntry[CurrentIoApicEntry].MaxRedirectionEntries = (UINT8)((data & 0x00FF0000) >> 16);
+ IoApicEntry[CurrentIoApicEntry].IoApicFlags = 1;
+ IoApicEntry[CurrentIoApicEntry].IoApicAddress = IoApicAddress;
+
+ CurrentIoApicEntry++;
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: ArrangeIoApicEntries
+//
+// Description: Arranges IO APIC Entries in their ID ascending order
+//
+// Input:
+// VOID
+//
+// Output:
+// VOID
+//
+// Modified: IoApicEntry
+// CurrentIoApicEntry
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID ArrangeIoApicEntries(VOID)
+{
+ UINT8 i;
+ BOOLEAN Swap = TRUE;
+ IO_APIC_INFO Temp;
+
+ while(Swap)
+ {
+ Swap = FALSE;
+ for(i = 0; i < CurrentIoApicEntry - 1; i++)
+ {
+ if(IoApicEntry[i].IoApicId > IoApicEntry[i+1].IoApicId)
+ {
+ Swap = TRUE;
+ MemCpy(&Temp, &IoApicEntry[i], sizeof(IO_APIC_INFO));
+ MemCpy(&IoApicEntry[i], &IoApicEntry[i+1], sizeof(IO_APIC_INFO));
+ MemCpy(&IoApicEntry[i+1], &Temp, sizeof(IO_APIC_INFO));
+ }
+ }
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetIoApicId
+//
+// Description: Returns IO APIC ID and Pin number assosiated with given SysVectorNumber
+//
+// Input:
+// IN UINT16 SysVectorNumber - system interrupt vector number
+// OUT UINT8 *IoApicId - Id of IO APIC which handles that vector
+// OUT UINT8 *IoApicItin - IO APIC Pin number associated with given vector number
+//
+// Output:
+// VOID
+//
+// Modified: IoApicEntry
+// CurrentIoApicEntry
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+VOID GetIoApicId(
+ IN UINT16 SysVectorNumber,
+ OUT UINT8 *IoApicId,
+ OUT UINT8 *IoApicItin)
+{
+ UINT8 i;
+
+ for(i = 0; i < CurrentIoApicEntry; i++)
+ {
+ if(SysVectorNumber < IoApicEntry[i].MaxRedirectionEntries) //this is Apic we need
+ {
+ *IoApicId = IoApicEntry[i].IoApicId;
+ *IoApicItin = (UINT8)SysVectorNumber;
+ return;
+ }
+ SysVectorNumber -= IoApicEntry[i].MaxRedirectionEntries;
+ }
+}
+
+//<AMI_PHDR_START>
+//----------------------------------------------------------------------------
+//
+// Procedure: GetCpuInfo
+//
+// Description: Returns number of cores and threads of given CPU
+//
+// Input:
+// IN UINTN Cpu - Cpu number
+// OUT UINT8 *Cores - number of cores in given Cpu
+// OUT UINT8 *Threads - number of threads in given Cpu
+//
+// Output:
+// EFI_SUCCESS - function executed successfully
+//
+//--------------------------------------------------------------------------
+//<AMI_PHDR_END>
+EFI_STATUS GetCpuInfo(
+ IN UINTN Cpu,
+ OUT UINT8 *Cores,
+ OUT UINT8 *Threads)
+{
+ EFI_STATUS Status;
+ AMI_CPU_INFO *Info;
+
+//find AMICpuInfo protocol
+ if(AmiCpuInfoProtocol == NULL)
+ {
+ Status = pBS->LocateProtocol(&AmiCpuInfoProtocolGuid,
+ NULL,
+ &AmiCpuInfoProtocol);
+ if(EFI_ERROR(Status))
+ return Status;
+ }
+
+ Status = AmiCpuInfoProtocol->GetCpuInfo(AmiCpuInfoProtocol, Cpu, &Info);
+ if(EFI_ERROR(Status))
+ return Status;
+
+ *Cores = Info->NumCores;
+ *Threads = (Info->NumHts == 0) ? 1 : Info->NumHts;
+
+ return EFI_SUCCESS;
+}
+
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//********************************************************************** \ No newline at end of file
diff --git a/Core/EM/ACPI/mptable.h b/Core/EM/ACPI/mptable.h
new file mode 100644
index 0000000..6389c50
--- /dev/null
+++ b/Core/EM/ACPI/mptable.h
@@ -0,0 +1,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 **
+//** **
+//**********************************************************************
+//********************************************************************** \ No newline at end of file
diff --git a/Core/EM/ACPI/rmisc.asl b/Core/EM/ACPI/rmisc.asl
new file mode 100644
index 0000000..07b541c
--- /dev/null
+++ b/Core/EM/ACPI/rmisc.asl
@@ -0,0 +1,120 @@
+// Miscellaneous I/O and memory resources
+// System board extension Device node for ACPI BIOS
+// THIS FILE IS INCLUDED to LPC/ISA PCI bridge scope
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (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/rmisc.asl 5 7/12/10 11:26a Oleksiyy $Revision:
+//
+// $Date: 7/12/10 11:26a $Log:
+//**********************************************************************;
+/*
+;<AMI_PHDR_START>
+;------------------------------------------------------------------------
+;
+; Procedure: RMSC
+;
+; Description: Chipset Miscellaneous I/O and memory resources
+; This table should contain any I/O port that is not used by a specific
+; device but does not return FFh when read. Some examples of I/O ports
+; that should be reserved here are:
+; Any I/O port in the range 00 - FF that is not used by any other dev node
+; The IRQ edge/level control ports (4D0/4D1)
+;
+; Input: Nothing
+;
+; Output: _CRS buffer
+;
+;-------------------------------------------------------------------------
+;<AMI_PHDR_END>
+*/
+ Device(RMSC) {
+
+ Name(_HID, EISAID("PNP0C02")) // System board resources device node ID
+ Name(_UID, 0x10) // Unique ID. Used first I/O range address from _CRS buffer.
+
+ Name(CRS1, ResourceTemplate()
+ {
+ IO(Decode16,0x10, 0x10, 0,0x10)
+ IO(Decode16,0x22, 0x22, 0,0x1e)
+ IO(Decode16,0x44, 0x44, 0,0x1c)
+ IO(Decode16,0x62, 0x62, 0,0x02)
+ IO(Decode16,0x65, 0x65, 0,0x0b)
+ IO(Decode16,0x72, 0x72, 0,0x0e)
+ IO(Decode16,0x80, 0x80, 0,0x01)
+ IO(Decode16,0x84, 0x84, 0,0x03)
+ IO(Decode16,0x88, 0x88, 0,0x01)
+ IO(Decode16,0x8c, 0x8c, 0,0x03)
+ IO(Decode16,0x90, 0x90, 0,0x10)
+ IO(Decode16,0xa2, 0xa2, 0,0x1e)
+ IO(Decode16,0xe0, 0xe0, 0,0x10)
+// Decoded but not used by FDC. Reserved in FDC device node resources
+// IO(Decode16, 0x3f3, 0x3f3, 0, 0x1)
+// Reserve 4D0 and 4D1 for IRQ edge/level control port
+ IO(Decode16, 0x4d0, 0x4d0, 0, 0x2)
+//S.Y Not existing resource
+// SB NVRAM 1 I/O space
+// IO(Decode16, 0xDE00, 0xDE00, 0, 0x80)
+// SB NVRAM 2 I/O space
+// IO(Decode16, 0xDE80, 0xDE80, 0, 0x80)
+
+ } // End of ResourceTemplate
+ ) // end of CRS1
+ Name(CRS2, ResourceTemplate()
+ {
+ IO(Decode16,0x10, 0x10, 0,0x10)
+ IO(Decode16,0x22, 0x22, 0,0x1e)
+ IO(Decode16,0x44, 0x44, 0,0x1c)
+ IO(Decode16,0x72, 0x72, 0,0x0e)
+ IO(Decode16,0x80, 0x80, 0,0x01)
+ IO(Decode16,0x84, 0x84, 0,0x03)
+ IO(Decode16,0x88, 0x88, 0,0x01)
+ IO(Decode16,0x8c, 0x8c, 0,0x03)
+ IO(Decode16,0x90, 0x90, 0,0x10)
+ IO(Decode16,0xa2, 0xa2, 0,0x1e)
+ IO(Decode16,0xe0, 0xe0, 0,0x10)
+// Decoded but not used by FDC. Reserved in FDC device node resources
+// IO(Decode16, 0x3f3, 0x3f3, 0, 0x1)
+// Reserve 4D0 and 4D1 for IRQ edge/level control port
+ IO(Decode16, 0x4d0, 0x4d0, 0, 0x2)
+//S.Y Not existing resource
+// SB NVRAM 1 I/O space
+// IO(Decode16, 0xDE00, 0xDE00, 0, 0x80)
+// SB NVRAM 2 I/O space
+// IO(Decode16, 0xDE80, 0xDE80, 0, 0x80)
+
+ } // End of ResourceTemplate
+ ) // end of CRS2
+ Method (_CRS, 0)
+ {
+ If(And(\MBEC, 0xFFFF)){//Check if there is an EC in system
+ Return(CRS1)
+ }else{
+ Return(CRS2)
+ }
+ }
+}
+//**********************************************************************
+//**********************************************************************
+//** **
+//** (C)Copyright 1985-2009, American Megatrends, Inc. **
+//** **
+//** All Rights Reserved. **
+//** **
+//** 5555 Oakbrook Pkwy, Norcross, GA 30093 **
+//** **
+//** Phone: (770)-246-8600 **
+//** **
+//**********************************************************************
+//**********************************************************************