summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>2010-02-21 09:30:01 +0000
committerniruiyu <niruiyu@6f19259b-4bc3-4df7-8a09-765794883524>2010-02-21 09:30:01 +0000
commit0e047a2a83d3e4c04f73d26f3978a4efde0b2bc4 (patch)
treeb36827e00942f134465e3defa8f747f93ecefd73
parent450ec0ed87d34dd325b66515dd7530fc59ac6267 (diff)
downloadedk2-platforms-0e047a2a83d3e4c04f73d26f3978a4efde0b2bc4.tar.xz
Port AcpiResetDxe from EDK to EDKII to enable reset function on DUET above legacy free platform.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10034 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--DuetPkg/AcpiResetDxe/Reset.c194
-rw-r--r--DuetPkg/AcpiResetDxe/Reset.h74
-rw-r--r--DuetPkg/AcpiResetDxe/Reset.inf54
-rw-r--r--DuetPkg/AcpiResetDxe/ResetEntry.c88
-rw-r--r--DuetPkg/DuetPkg.dsc4
-rw-r--r--DuetPkg/DuetPkg.fdf2
-rw-r--r--DuetPkg/DxeIpl/LegacyTable.c201
-rw-r--r--DuetPkg/Include/Guid/AcpiDescription.h42
8 files changed, 484 insertions, 175 deletions
diff --git a/DuetPkg/AcpiResetDxe/Reset.c b/DuetPkg/AcpiResetDxe/Reset.c
new file mode 100644
index 0000000000..fe2d0a8da8
--- /dev/null
+++ b/DuetPkg/AcpiResetDxe/Reset.c
@@ -0,0 +1,194 @@
+/*++ @file
+ Reset Architectural Protocol implementation.
+
+Copyright (c) 2006 - 2010, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+--*/
+
+#include "Reset.h"
+
+/**
+ Use ACPI method to reset the sytem. If fail, use legacy 8042 method to reset the system
+
+ @param[in] AcpiDescription Global variable to record reset info
+
+**/
+VOID
+SystemReset (
+ IN EFI_ACPI_DESCRIPTION *AcpiDescription
+ )
+{
+ UINT8 Dev;
+ UINT8 Func;
+ UINT8 Register;
+
+ if ((AcpiDescription->RESET_REG.Address != 0) &&
+ ((AcpiDescription->RESET_REG.AddressSpaceId == EFI_ACPI_3_0_SYSTEM_IO) ||
+ (AcpiDescription->RESET_REG.AddressSpaceId == EFI_ACPI_3_0_SYSTEM_MEMORY) ||
+ (AcpiDescription->RESET_REG.AddressSpaceId == EFI_ACPI_3_0_PCI_CONFIGURATION_SPACE))) {
+ //
+ // Use ACPI System Reset
+ //
+ switch (AcpiDescription->RESET_REG.AddressSpaceId) {
+ case EFI_ACPI_3_0_SYSTEM_IO:
+ IoWrite8 ((UINTN) AcpiDescription->RESET_REG.Address, AcpiDescription->RESET_VALUE);
+ break;
+ case EFI_ACPI_3_0_SYSTEM_MEMORY:
+ MmioWrite8 ((UINTN) AcpiDescription->RESET_REG.Address, AcpiDescription->RESET_VALUE);
+ break;
+ case EFI_ACPI_3_0_PCI_CONFIGURATION_SPACE:
+ Register = (UINT8) AcpiDescription->RESET_REG.Address;
+ Func = (UINT8) (RShiftU64 (AcpiDescription->RESET_REG.Address, 16) & 0x7);
+ Dev = (UINT8) (RShiftU64 (AcpiDescription->RESET_REG.Address, 32) & 0x1F);
+ PciWrite8 (PCI_LIB_ADDRESS (0, Dev, Func, Register), AcpiDescription->RESET_VALUE);
+ break;
+ }
+ }
+
+ //
+ // If system comes here, means ACPI reset fail, do Legacy System Reset, assume 8042 available
+ //
+ Register = 0xfe;
+ IoWrite8 (0x64, Register);
+
+ //
+ // System should reset now
+ //
+
+ return ;
+}
+
+/**
+ Use ACPI method to shutdown the sytem
+
+ @param[in] AcpiDescription Global variable to record reset info
+
+ @retval EFI_UNSUPPORTED Shutdown fails
+
+**/
+EFI_STATUS
+SystemShutdown (
+ IN EFI_ACPI_DESCRIPTION *AcpiDescription
+ )
+{
+ UINT16 Value;
+
+ //
+ // 1. Write SLP_TYPa
+ //
+ if ((AcpiDescription->PM1a_CNT_BLK.Address != 0) && (AcpiDescription->SLP_TYPa != 0)) {
+ switch (AcpiDescription->PM1a_CNT_BLK.AddressSpaceId) {
+ case EFI_ACPI_3_0_SYSTEM_IO:
+ Value = IoRead16 ((UINTN) AcpiDescription->PM1a_CNT_BLK.Address);
+ Value = (Value & 0xc3ff) | 0x2000 | (AcpiDescription->SLP_TYPa << 10);
+ IoWrite16 ((UINTN) AcpiDescription->PM1a_CNT_BLK.Address, Value);
+ break;
+ case EFI_ACPI_3_0_SYSTEM_MEMORY:
+ Value = MmioRead16 ((UINTN) AcpiDescription->PM1a_CNT_BLK.Address);
+ Value = (Value & 0xc3ff) | 0x2000 | (AcpiDescription->SLP_TYPa << 10);
+ MmioWrite16 ((UINTN) AcpiDescription->PM1a_CNT_BLK.Address, Value);
+ break;
+ }
+ }
+
+ //
+ // 2. Write SLP_TYPb
+ //
+ if ((AcpiDescription->PM1b_CNT_BLK.Address != 0) && (AcpiDescription->SLP_TYPb != 0)) {
+ switch (AcpiDescription->PM1b_CNT_BLK.AddressSpaceId) {
+ case EFI_ACPI_3_0_SYSTEM_IO:
+ Value = IoRead16 ((UINTN) AcpiDescription->PM1b_CNT_BLK.Address);
+ Value = (Value & 0xc3ff) | 0x2000 | (AcpiDescription->SLP_TYPb << 10);
+ IoWrite16 ((UINTN) AcpiDescription->PM1b_CNT_BLK.Address, Value);
+ break;
+ case EFI_ACPI_3_0_SYSTEM_MEMORY:
+ Value = MmioRead16 ((UINTN) AcpiDescription->PM1b_CNT_BLK.Address);
+ Value = (Value & 0xc3ff) | 0x2000 | (AcpiDescription->SLP_TYPb << 10);
+ MmioWrite16 ((UINTN) AcpiDescription->PM1b_CNT_BLK.Address, Value);
+ break;
+ }
+ }
+
+ //
+ // Done, if code runs here, mean not shutdown correctly
+ //
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ Reset the system.
+
+ @param[in] ResetType Warm or cold
+ @param[in] ResetStatus Possible cause of reset
+ @param[in] DataSize Size of ResetData in bytes
+ @param[in] ResetData Optional Unicode string
+ @param[in] AcpiDescription Global variable to record reset info
+
+**/
+VOID
+EFIAPI
+AcpiResetSystem (
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN CHAR16 *ResetData, OPTIONAL
+ IN EFI_ACPI_DESCRIPTION *AcpiDescription
+ )
+{
+ EFI_STATUS Status;
+
+ switch (ResetType) {
+ case EfiResetWarm:
+ case EfiResetCold:
+ SystemReset (AcpiDescription);
+ break;
+
+ case EfiResetShutdown:
+ Status = SystemShutdown (AcpiDescription);
+ if (EFI_ERROR (Status)) {
+ SystemReset (AcpiDescription);
+ }
+ break;
+
+ default:
+ return ;
+ }
+
+ //
+ // Given we should have reset getting here would be bad
+ //
+ ASSERT (FALSE);
+}
+
+BOOLEAN
+GetAcpiDescription (
+ IN EFI_ACPI_DESCRIPTION *AcpiDescription
+ )
+{
+ EFI_HOB_GUID_TYPE *HobAcpiDescription;
+ //
+ // Get AcpiDescription Hob
+ //
+ HobAcpiDescription = GetFirstGuidHob (&gEfiAcpiDescriptionGuid);
+ if (HobAcpiDescription == NULL) {
+ return FALSE;
+ }
+
+ //
+ // Copy it to Runtime Memory
+ //
+ ASSERT (sizeof (EFI_ACPI_DESCRIPTION) == GET_GUID_HOB_DATA_SIZE (HobAcpiDescription));
+ CopyMem (AcpiDescription, GET_GUID_HOB_DATA (HobAcpiDescription), sizeof (EFI_ACPI_DESCRIPTION));
+
+ DEBUG ((EFI_D_ERROR, "ACPI Reset Base - %lx\n", AcpiDescription->RESET_REG.Address));
+ DEBUG ((EFI_D_ERROR, "ACPI Reset Value - %02x\n", (UINTN)AcpiDescription->RESET_VALUE));
+ DEBUG ((EFI_D_ERROR, "IAPC support - %x\n", (UINTN)(AcpiDescription->IAPC_BOOT_ARCH)));
+ return TRUE;
+}
diff --git a/DuetPkg/AcpiResetDxe/Reset.h b/DuetPkg/AcpiResetDxe/Reset.h
new file mode 100644
index 0000000000..448c103b2b
--- /dev/null
+++ b/DuetPkg/AcpiResetDxe/Reset.h
@@ -0,0 +1,74 @@
+/*++ @file
+ Some definitions for reset.
+
+Copyright (c) 2006 - 2010, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+--*/
+
+#ifndef _ACPI_RESET_H
+#define _ACPI_RESET_H
+
+#include <PiDxe.h>
+
+#include <Library/BaseLib.h>
+#include <Library/IoLib.h>
+#include <Library/PciLib.h>
+#include <Library/HobLib.h>
+#include <Library/DebugLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+#include <Protocol/Reset.h>
+#include <Guid/AcpiDescription.h>
+
+/**
+ Initialize the state information for the Reset Architectural Protocol.
+
+ @param[in] ImageHandle Image handle of the loaded driver
+ @param[in] SystemTable Pointer to the System Table
+
+ @retval EFI_SUCCESS Thread can be successfully created
+ @retval EFI_UNSUPPORTED Cannot find the info to reset system
+
+**/
+EFI_STATUS
+EFIAPI
+InitializeReset (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+;
+
+/**
+ Reset the system.
+
+ @param[in] ResetType Warm or cold
+ @param[in] ResetStatus Possible cause of reset
+ @param[in] DataSize Size of ResetData in bytes
+ @param[in] ResetData Optional Unicode string
+
+**/
+VOID
+EFIAPI
+AcpiResetSystem (
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN CHAR16 *ResetData, OPTIONAL
+ IN EFI_ACPI_DESCRIPTION *AcpiDescription
+ )
+;
+
+BOOLEAN
+GetAcpiDescription (
+ IN EFI_ACPI_DESCRIPTION *AcpiDescription
+ );
+
+#endif
diff --git a/DuetPkg/AcpiResetDxe/Reset.inf b/DuetPkg/AcpiResetDxe/Reset.inf
new file mode 100644
index 0000000000..3af6becbe3
--- /dev/null
+++ b/DuetPkg/AcpiResetDxe/Reset.inf
@@ -0,0 +1,54 @@
+#/** @file
+# Component description file for AcpiResetDxe module.
+#
+# Copyright (c) 2006 - 2010, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+#--*/
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = AcpiReset
+ FILE_GUID = 6F0198AA-1F1D-426D-AE3E-39AB633FCC28
+ MODULE_TYPE = DXE_RUNTIME_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = InitializeReset
+
+[Packages]
+ MdePkg/MdePkg.dec
+ DuetPkg/DuetPkg.dec
+
+[LibraryClasses]
+ DebugLib
+ UefiBootServicesTableLib
+ UefiDriverEntryPoint
+ IoLib
+ PciLib
+ HobLib
+ BaseLib
+ BaseMemoryLib
+
+[Sources]
+ Reset.c
+ Reset.h
+ ResetEntry.c
+
+[Protocols]
+ gEfiResetArchProtocolGuid
+
+[Guids]
+ gEfiAcpiDescriptionGuid
+
+[Depex]
+ TRUE
+
+[BuildOptions]
+ MSFT:*_*_IA32_CC_FLAGS = /Od
+
+
diff --git a/DuetPkg/AcpiResetDxe/ResetEntry.c b/DuetPkg/AcpiResetDxe/ResetEntry.c
new file mode 100644
index 0000000000..3da08a10d2
--- /dev/null
+++ b/DuetPkg/AcpiResetDxe/ResetEntry.c
@@ -0,0 +1,88 @@
+/*++ @file
+ Entrypoint of AcpiResetDxe driver.
+
+Copyright (c) 2010, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+--*/
+
+#include "Reset.h"
+
+EFI_ACPI_DESCRIPTION mAcpiDescription;
+
+/**
+ Reset the system.
+
+ @param[in] ResetType Warm or cold
+ @param[in] ResetStatus Possible cause of reset
+ @param[in] DataSize Size of ResetData in bytes
+ @param[in] ResetData Optional Unicode string
+
+**/
+VOID
+EFIAPI
+EfiAcpiResetSystem (
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN CHAR16 *ResetData OPTIONAL
+ )
+{
+ AcpiResetSystem (ResetType, ResetStatus, DataSize, ResetData, &mAcpiDescription);
+}
+
+/**
+ Initialize the state information for the Reset Architectural Protocol.
+
+ @param[in] ImageHandle Image handle of the loaded driver
+ @param[in] SystemTable Pointer to the System Table
+
+ @retval EFI_SUCCESS Thread can be successfully created
+ @retval EFI_UNSUPPORTED Cannot find the info to reset system
+
+**/
+EFI_STATUS
+EFIAPI
+InitializeReset (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+ //
+ // Initialize AcpiDescription
+ //
+ if (!GetAcpiDescription (&mAcpiDescription)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // Make sure the Reset Architectural Protocol is not already installed in the system
+ //
+ ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiResetArchProtocolGuid);
+
+ //
+ // Hook the runtime service table
+ //
+ SystemTable->RuntimeServices->ResetSystem = EfiAcpiResetSystem;
+
+ //
+ // Now install the Reset RT AP on a new handle
+ //
+ Handle = NULL;
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &Handle,
+ &gEfiResetArchProtocolGuid,
+ NULL,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ return Status;
+}
diff --git a/DuetPkg/DuetPkg.dsc b/DuetPkg/DuetPkg.dsc
index b2657cfb38..9707dee323 100644
--- a/DuetPkg/DuetPkg.dsc
+++ b/DuetPkg/DuetPkg.dsc
@@ -57,6 +57,8 @@
PeCoffExtraActionLib|MdePkg/Library/BasePeCoffExtraActionLibNull/BasePeCoffExtraActionLibNull.inf
OemHookStatusCodeLib|MdeModulePkg/Library/OemHookStatusCodeLibNull/OemHookStatusCodeLibNull.inf
IoLib|MdePkg/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
+ PciLib|MdePkg/Library/BasePciLibCf8/BasePciLibCf8.inf
+ PciCf8Lib|MdePkg/Library/BasePciCf8Lib/BasePciCf8Lib.inf
TimerLib|DuetPkg/Library/DuetTimerLib/DuetTimerLib.inf
UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
@@ -170,7 +172,7 @@
UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
DuetPkg/CpuDxe/Cpu.inf
PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf
- PcAtChipsetPkg/KbcResetDxe/Reset.inf
+ DuetPkg/AcpiResetDxe/Reset.inf
DuetPkg/LegacyMetronome/Metronome.inf
PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
diff --git a/DuetPkg/DuetPkg.fdf b/DuetPkg/DuetPkg.fdf
index 822116c082..a811bb83a2 100644
--- a/DuetPkg/DuetPkg.fdf
+++ b/DuetPkg/DuetPkg.fdf
@@ -87,7 +87,7 @@ INF UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
INF DuetPkg/CpuDxe/Cpu.inf
INF PcAtChipsetPkg/8259InterruptControllerDxe/8259.inf
-INF PcAtChipsetPkg/KbcResetDxe/Reset.inf
+INF DuetPkg/AcpiResetDxe/Reset.inf
INF DuetPkg/LegacyMetronome/Metronome.inf
INF PcAtChipsetPkg/8254TimerDxe/8254Timer.inf
INF PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
diff --git a/DuetPkg/DxeIpl/LegacyTable.c b/DuetPkg/DxeIpl/LegacyTable.c
index 823a25ac5a..539cf25732 100644
--- a/DuetPkg/DxeIpl/LegacyTable.c
+++ b/DuetPkg/DxeIpl/LegacyTable.c
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006, Intel Corporation
+Copyright (c) 2006 - 2010, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -22,7 +22,6 @@ Revision History:
#include "HobGeneration.h"
#include "Debug.h"
-#define ACPI_RSD_PTR 0x2052545020445352LL
#define MPS_PTR SIGNATURE_32('_','M','P','_')
#define SMBIOS_PTR SIGNATURE_32('_','S','M','_')
@@ -40,7 +39,7 @@ FindAcpiRsdPtr (
// First Seach 0x0e0000 - 0x0fffff for RSD Ptr
//
for (Address = 0xe0000; Address < 0xfffff; Address += 0x10) {
- if (*(UINT64 *)(Address) == ACPI_RSD_PTR) {
+ if (*(UINT64 *)(Address) == EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE) {
return (VOID *)Address;
}
}
@@ -51,7 +50,7 @@ FindAcpiRsdPtr (
Address = (*(UINT16 *)(UINTN)(EBDA_BASE_ADDRESS)) << 4;
for (Index = 0; Index < 0x400 ; Index += 16) {
- if (*(UINT64 *)(Address + Index) == ACPI_RSD_PTR) {
+ if (*(UINT64 *)(Address + Index) == EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE) {
return (VOID *)Address;
}
}
@@ -107,69 +106,38 @@ FindMPSPtr (
}
#pragma pack(1)
-typedef struct {
- UINT8 Signature[8];
- UINT8 Checksum;
- UINT8 OemId[6];
- UINT8 Revision;
- UINT32 RsdtAddress;
- UINT32 Length;
- UINT64 XsdtAddress;
- UINT8 ExtendedChecksum;
- UINT8 Reserved[3];
-} RSDP_TABLE;
-
-typedef struct {
- UINT32 Signature;
- UINT32 Length;
- UINT8 Revision;
- UINT8 Checksum;
- UINT8 OemId[6];
- UINT8 OemTableId[8];
- UINT32 OemRevision;
- UINT8 CreatorId[4];
- UINT32 CreatorRevision;
-} DESCRIPTION_HEADER;
typedef struct {
- DESCRIPTION_HEADER Header;
- UINT32 Entry;
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT32 Entry;
} RSDT_TABLE;
typedef struct {
- DESCRIPTION_HEADER Header;
- UINT64 Entry;
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT64 Entry;
} XSDT_TABLE;
-typedef struct {
- UINT8 Address_Space_ID;
- UINT8 Register_Bit_Width;
- UINT8 Register_Bit_Offset;
- UINT8 Access_Size;
- UINT64 Address;
-} GADDRESS_STRUCTURE;
-
#pragma pack()
VOID
ScanTableInRSDT (
- RSDT_TABLE *Rsdt,
- UINT32 Signature,
- DESCRIPTION_HEADER **FoundTable
+ RSDT_TABLE *Rsdt,
+ UINT32 Signature,
+ EFI_ACPI_DESCRIPTION_HEADER **FoundTable
)
{
- UINTN Index;
- UINT32 EntryCount;
- UINT32 *EntryPtr;
- DESCRIPTION_HEADER *Table;
+ UINTN Index;
+ UINT32 EntryCount;
+ UINT32 *EntryPtr;
+ EFI_ACPI_DESCRIPTION_HEADER *Table;
*FoundTable = NULL;
- EntryCount = (Rsdt->Header.Length - sizeof (DESCRIPTION_HEADER)) / sizeof(UINT32);
+ EntryCount = (Rsdt->Header.Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT32);
EntryPtr = &Rsdt->Entry;
for (Index = 0; Index < EntryCount; Index ++, EntryPtr ++) {
- Table = (DESCRIPTION_HEADER*)((UINTN)(*EntryPtr));
+ Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(*EntryPtr));
if (Table->Signature == Signature) {
*FoundTable = Table;
break;
@@ -181,26 +149,25 @@ ScanTableInRSDT (
VOID
ScanTableInXSDT (
- XSDT_TABLE *Xsdt,
- UINT32 Signature,
- DESCRIPTION_HEADER **FoundTable
+ XSDT_TABLE *Xsdt,
+ UINT32 Signature,
+ EFI_ACPI_DESCRIPTION_HEADER **FoundTable
)
{
- UINTN Index;
- UINT32 EntryCount;
- UINT64 EntryPtr;
- UINTN BasePtr;
-
- DESCRIPTION_HEADER *Table;
+ UINTN Index;
+ UINT32 EntryCount;
+ UINT64 EntryPtr;
+ UINTN BasePtr;
+ EFI_ACPI_DESCRIPTION_HEADER *Table;
*FoundTable = NULL;
- EntryCount = (Xsdt->Header.Length - sizeof (DESCRIPTION_HEADER)) / sizeof(UINT64);
+ EntryCount = (Xsdt->Header.Length - sizeof (EFI_ACPI_DESCRIPTION_HEADER)) / sizeof(UINT64);
BasePtr = (UINTN)(&(Xsdt->Entry));
for (Index = 0; Index < EntryCount; Index ++) {
CopyMem (&EntryPtr, (VOID *)(BasePtr + Index * sizeof(UINT64)), sizeof(UINT64));
- Table = (DESCRIPTION_HEADER*)((UINTN)(EntryPtr));
+ Table = (EFI_ACPI_DESCRIPTION_HEADER*)((UINTN)(EntryPtr));
if (Table->Signature == Signature) {
*FoundTable = Table;
break;
@@ -216,10 +183,10 @@ FindAcpiPtr (
UINT32 Signature
)
{
- DESCRIPTION_HEADER *AcpiTable;
- RSDP_TABLE *Rsdp;
- RSDT_TABLE *Rsdt;
- XSDT_TABLE *Xsdt;
+ EFI_ACPI_DESCRIPTION_HEADER *AcpiTable;
+ EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *Rsdp;
+ RSDT_TABLE *Rsdt;
+ XSDT_TABLE *Xsdt;
AcpiTable = NULL;
@@ -227,7 +194,7 @@ FindAcpiPtr (
// Check ACPI2.0 table
//
if ((int)Hob->Acpi20.Table != -1) {
- Rsdp = (RSDP_TABLE *)(UINTN)Hob->Acpi20.Table;
+ Rsdp = (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)(UINTN)Hob->Acpi20.Table;
Rsdt = (RSDT_TABLE *)(UINTN)Rsdp->RsdtAddress;
Xsdt = NULL;
if ((Rsdp->Revision >= 2) && (Rsdp->XsdtAddress < (UINT64)(UINTN)-1)) {
@@ -251,7 +218,7 @@ FindAcpiPtr (
// Check ACPI1.0 table
//
if ((AcpiTable == NULL) && ((int)Hob->Acpi.Table != -1)) {
- Rsdp = (RSDP_TABLE *)(UINTN)Hob->Acpi.Table;
+ Rsdp = (EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)(UINTN)Hob->Acpi.Table;
Rsdt = (RSDT_TABLE *)(UINTN)Rsdp->RsdtAddress;
//
// Check Rsdt
@@ -265,8 +232,6 @@ FindAcpiPtr (
}
#pragma pack(1)
-//#define MCFG_SIGNATURE 0x4746434D
-#define MCFG_SIGNATURE SIGNATURE_32 ('M', 'C', 'F', 'G')
typedef struct {
UINT64 BaseAddress;
UINT16 PciSegmentGroupNumber;
@@ -274,63 +239,6 @@ typedef struct {
UINT8 EndBusNumber;
UINT32 Reserved;
} MCFG_STRUCTURE;
-
-#define FADT_SIGNATURE SIGNATURE_32 ('F', 'A', 'C', 'P')
-typedef struct {
- DESCRIPTION_HEADER Header;
- UINT32 FIRMWARE_CTRL;
- UINT32 DSDT;
- UINT8 INT_MODEL;
- UINT8 Preferred_PM_Profile;
- UINT16 SCI_INIT;
- UINT32 SMI_CMD;
- UINT8 ACPI_ENABLE;
- UINT8 ACPI_DISABLE;
- UINT8 S4BIOS_REQ;
- UINT8 PSTATE_CNT;
- UINT32 PM1a_EVT_BLK;
- UINT32 PM1b_EVT_BLK;
- UINT32 PM1a_CNT_BLK;
- UINT32 PM1b_CNT_BLK;
- UINT32 PM2_CNT_BLK;
- UINT32 PM_TMR_BLK;
- UINT32 GPE0_BLK;
- UINT32 GPE1_BLK;
- UINT8 PM1_EVT_LEN;
- UINT8 PM1_CNT_LEN;
- UINT8 PM2_CNT_LEN;
- UINT8 PM_TMR_LEN;
- UINT8 GPE0_BLK_LEN;
- UINT8 GPE1_BLK_LEN;
- UINT8 GPE1_BASE;
- UINT8 CST_CNT;
- UINT16 P_LVL2_LAT;
- UINT16 P_LVL3_LAT;
- UINT16 FLUSH_SIZE;
- UINT16 FLUSH_STRIDE;
- UINT8 DUTY_OFFSET;
- UINT8 DUTY_WIDTH;
- UINT8 DAY_ALARM;
- UINT8 MON_ALARM;
- UINT8 CENTRY;
- UINT16 IAPC_BOOT_ARCH;
- UINT8 Reserved_111;
- UINT32 Flags;
- GADDRESS_STRUCTURE RESET_REG;
- UINT8 RESET_VALUE;
- UINT8 Reserved_129[3];
- UINT64 X_FIRMWARE_CTRL;
- UINT64 X_DSDT;
- GADDRESS_STRUCTURE X_PM1a_EVT_BLK;
- GADDRESS_STRUCTURE X_PM1b_EVT_BLK;
- GADDRESS_STRUCTURE X_PM1a_CNT_BLK;
- GADDRESS_STRUCTURE X_PM1b_CNT_BLK;
- GADDRESS_STRUCTURE X_PM2_CNT_BLK;
- GADDRESS_STRUCTURE X_PM_TMR_BLK;
- GADDRESS_STRUCTURE X_GPE0_BLK;
- GADDRESS_STRUCTURE X_GPE1_BLK;
-} FADT_TABLE;
-
#pragma pack()
VOID
@@ -338,18 +246,18 @@ PrepareMcfgTable (
IN HOB_TEMPLATE *Hob
)
{
- DESCRIPTION_HEADER *McfgTable;
- MCFG_STRUCTURE *Mcfg;
- UINTN McfgCount;
- UINTN Index;
+ EFI_ACPI_DESCRIPTION_HEADER *McfgTable;
+ MCFG_STRUCTURE *Mcfg;
+ UINTN McfgCount;
+ UINTN Index;
- McfgTable = FindAcpiPtr (Hob, MCFG_SIGNATURE);
+ McfgTable = FindAcpiPtr (Hob, EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE);
if (McfgTable == NULL) {
return ;
}
- Mcfg = (MCFG_STRUCTURE *)((UINTN)McfgTable + sizeof(DESCRIPTION_HEADER) + sizeof(UINT64));
- McfgCount = (McfgTable->Length - sizeof(DESCRIPTION_HEADER) - sizeof(UINT64)) / sizeof(MCFG_STRUCTURE);
+ Mcfg = (MCFG_STRUCTURE *)((UINTN)McfgTable + sizeof(EFI_ACPI_DESCRIPTION_HEADER) + sizeof(UINT64));
+ McfgCount = (McfgTable->Length - sizeof(EFI_ACPI_DESCRIPTION_HEADER) - sizeof(UINT64)) / sizeof(MCFG_STRUCTURE);
//
// Fill PciExpress info on Hob
@@ -370,10 +278,10 @@ PrepareFadtTable (
IN HOB_TEMPLATE *Hob
)
{
- FADT_TABLE *Fadt;
- EFI_ACPI_DESCRIPTION *AcpiDescription;
+ EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE *Fadt;
+ EFI_ACPI_DESCRIPTION *AcpiDescription;
- Fadt = FindAcpiPtr (Hob, FADT_SIGNATURE);
+ Fadt = FindAcpiPtr (Hob, EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE);
if (Fadt == NULL) {
return ;
}
@@ -383,24 +291,31 @@ PrepareFadtTable (
// Fill AcpiDescription according to FADT
// Currently, only for PM_TMR
//
- AcpiDescription->PM_TMR_LEN = Fadt->PM_TMR_LEN;
+ AcpiDescription->PM_TMR_LEN = Fadt->PmTmrLen;
AcpiDescription->TMR_VAL_EXT = (UINT8)((Fadt->Flags & 0x100) != 0);
- if ((Fadt->Header.Revision >= 3) && (Fadt->Header.Length >= sizeof(FADT_TABLE))) {
+
+ //
+ // For fields not included in ACPI 1.0 spec, we get the value based on table length
+ //
+ if (Fadt->Header.Length >= OFFSET_OF (EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE, XPmTmrBlk) + sizeof (Fadt->XPmTmrBlk)) {
CopyMem (
&AcpiDescription->PM_TMR_BLK,
- &Fadt->X_PM_TMR_BLK,
- sizeof(GADDRESS_STRUCTURE)
+ &Fadt->XPmTmrBlk,
+ sizeof(EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE)
);
+ }
+ if (Fadt->Header.Length >= OFFSET_OF (EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE, ResetValue) + sizeof (Fadt->ResetValue)) {
CopyMem (
&AcpiDescription->RESET_REG,
- &Fadt->RESET_REG,
- sizeof(GADDRESS_STRUCTURE)
+ &Fadt->ResetReg,
+ sizeof(EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE)
);
- AcpiDescription->RESET_VALUE = Fadt->RESET_VALUE;
+ AcpiDescription->RESET_VALUE = Fadt->ResetValue;
}
+
if (AcpiDescription->PM_TMR_BLK.Address == 0) {
- AcpiDescription->PM_TMR_BLK.Address = Fadt->PM_TMR_BLK;
- AcpiDescription->PM_TMR_BLK.AddressSpaceId = ACPI_ADDRESS_ID_IO;
+ AcpiDescription->PM_TMR_BLK.Address = Fadt->PmTmrBlk;
+ AcpiDescription->PM_TMR_BLK.AddressSpaceId = EFI_ACPI_3_0_SYSTEM_IO;
AcpiDescription->PM_TMR_BLK.RegisterBitWidth = (UINT8) ((AcpiDescription->TMR_VAL_EXT == 0) ? 24 : 32);
}
diff --git a/DuetPkg/Include/Guid/AcpiDescription.h b/DuetPkg/Include/Guid/AcpiDescription.h
index d8095b896b..8f0becd7cf 100644
--- a/DuetPkg/Include/Guid/AcpiDescription.h
+++ b/DuetPkg/Include/Guid/AcpiDescription.h
@@ -1,6 +1,6 @@
/** @file
-Copyright (c) 2006 - 2007, Intel Corporation
+Copyright (c) 2006 - 2010, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -23,31 +23,13 @@ Abstract:
#ifndef _EFI_ACPI_DESCRIPTION_H_
#define _EFI_ACPI_DESCRIPTION_H_
+#include <IndustryStandard/Acpi.h>
+
#define EFI_ACPI_DESCRIPTION_GUID \
{ \
0x3c699197, 0x93c, 0x4c69, {0xb0, 0x6b, 0x12, 0x8a, 0xe3, 0x48, 0x1d, 0xc9} \
}
-typedef struct {
- UINT8 AddressSpaceId;
- UINT8 RegisterBitWidth;
- UINT8 RegisterBitOffset;
- UINT8 AccessSize;
- UINT64 Address;
-} EFI_ACPI_GENERIC_ADDRESS_STRUCTURE;
-
-#define ACPI_ADDRESS_ID_MEMORY 0
-#define ACPI_ADDRESS_ID_IO 1
-#define ACPI_ADDRESS_ID_PCI 2
-#define ACPI_ADDRESS_ID_EC 3
-#define ACPI_ADDRESS_ID_SMBUS 4
-
-#define ACPI_ADDRESS_ACCESS_ANY 0
-#define ACPI_ADDRESS_ACCESS_BYTE 1
-#define ACPI_ADDRESS_ACCESS_WORD 2
-#define ACPI_ADDRESS_ACCESS_DWORD 3
-#define ACPI_ADDRESS_ACCESS_QWORD 4
-
//
// Following structure defines ACPI Description information.
// This information is platform specific, may be consumed by DXE generic driver.
@@ -57,7 +39,7 @@ typedef struct _EFI_ACPI_DESCRIPTION {
//
// For Timer
//
- EFI_ACPI_GENERIC_ADDRESS_STRUCTURE PM_TMR_BLK;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE PM_TMR_BLK;
UINT8 PM_TMR_LEN;
UINT8 TMR_VAL_EXT;
@@ -71,17 +53,17 @@ typedef struct _EFI_ACPI_DESCRIPTION {
//
// For Reset
//
- EFI_ACPI_GENERIC_ADDRESS_STRUCTURE RESET_REG;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE RESET_REG;
UINT8 RESET_VALUE;
//
// For Shutdown
//
- EFI_ACPI_GENERIC_ADDRESS_STRUCTURE PM1a_EVT_BLK;
- EFI_ACPI_GENERIC_ADDRESS_STRUCTURE PM1b_EVT_BLK;
- EFI_ACPI_GENERIC_ADDRESS_STRUCTURE PM1a_CNT_BLK;
- EFI_ACPI_GENERIC_ADDRESS_STRUCTURE PM1b_CNT_BLK;
- EFI_ACPI_GENERIC_ADDRESS_STRUCTURE PM2_CNT_BLK;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE PM1a_EVT_BLK;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE PM1b_EVT_BLK;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE PM1a_CNT_BLK;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE PM1b_CNT_BLK;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE PM2_CNT_BLK;
UINT8 PM1_EVT_LEN;
UINT8 PM1_CNT_LEN;
UINT8 PM2_CNT_LEN;
@@ -103,8 +85,8 @@ typedef struct _EFI_ACPI_DESCRIPTION {
//
// GPE
//
- EFI_ACPI_GENERIC_ADDRESS_STRUCTURE GPE0_BLK;
- EFI_ACPI_GENERIC_ADDRESS_STRUCTURE GPE1_BLK;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE GPE0_BLK;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE GPE1_BLK;
UINT8 GPE0_BLK_LEN;
UINT8 GPE1_BLK_LEN;
UINT8 GPE1_BASE;