Discussion:
[edk2] [Patch 0/2] Fix "reset -s" issue
Guo Dong
2015-06-11 13:33:23 UTC
Permalink
When using coreboot + UEFI payload, sometimes it will be waken up after issuing "reset -s".
This patch disable wake up when shut down.

Guo Dong (2):
CorebootModulePkg: Get power management register addresses.
CorebootPayloadPkg: Fix "reset -s" issue.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Guo Dong <***@intel.com>

CorebootModulePkg/CbSupportPei/CbSupportPei.c | 6 ++++-
CorebootModulePkg/Include/Guid/AcpiBoardInfoGuid.h | 4 ++-
CorebootModulePkg/Include/Library/CbParseLib.h | 6 ++++-
.../Library/ResetSystemLib/ResetSystemLib.c | 31 ++++++++++++++++++++--
4 files changed, 42 insertions(+), 5 deletions(-)
--
1.9.5.msysgit.0


------------------------------------------------------------------------------
Guo Dong
2015-06-11 13:33:24 UTC
Permalink
This patch will get power management event register address and power management GPE enable register address.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Guo Dong <***@intel.com>
---
CorebootModulePkg/CbSupportPei/CbSupportPei.c | 6 +++++-
CorebootModulePkg/Include/Guid/AcpiBoardInfoGuid.h | 4 +++-
CorebootModulePkg/Include/Library/CbParseLib.h | 6 +++++-
3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/CorebootModulePkg/CbSupportPei/CbSupportPei.c b/CorebootModulePkg/CbSupportPei/CbSupportPei.c
index b3705fa..2fb28d4 100755
--- a/CorebootModulePkg/CbSupportPei/CbSupportPei.c
+++ b/CorebootModulePkg/CbSupportPei/CbSupportPei.c
@@ -169,10 +169,12 @@ CbPeiEntryPoint (
SYSTEM_TABLE_INFO* pSystemTableInfo;
FRAME_BUFFER_INFO FbInfo;
FRAME_BUFFER_INFO* pFbInfo;
ACPI_BOARD_INFO* pAcpiBoardInfo;
UINTN PmCtrlRegBase, PmTimerRegBase, ResetRegAddress, ResetValue;
+ UINTN PmEvtBase;
+ UINTN PmGpeEnBase;

LowMemorySize = 0;
HighMemorySize = 0;

Status = CbParseMemoryInfo (&LowMemorySize, &HighMemorySize);
@@ -353,19 +355,21 @@ CbPeiEntryPoint (
DEBUG ((EFI_D_ERROR, "Create system table info guid hob\n"));

//
// Create guid hob for acpi board information
//
- Status = CbParseFadtInfo (&PmCtrlRegBase, &PmTimerRegBase, &ResetRegAddress, &ResetValue);
+ Status = CbParseFadtInfo (&PmCtrlRegBase, &PmTimerRegBase, &ResetRegAddress, &ResetValue, &PmEvtBase, &PmGpeEnBase);
ASSERT_EFI_ERROR (Status);
pAcpiBoardInfo = NULL;
pAcpiBoardInfo = BuildGuidHob (&gUefiAcpiBoardInfoGuid, sizeof (ACPI_BOARD_INFO));
ASSERT (pAcpiBoardInfo != NULL);
pAcpiBoardInfo->PmCtrlRegBase = (UINT64)PmCtrlRegBase;
pAcpiBoardInfo->PmTimerRegBase = (UINT64)PmTimerRegBase;
pAcpiBoardInfo->ResetRegAddress = (UINT64)ResetRegAddress;
pAcpiBoardInfo->ResetValue = (UINT8)ResetValue;
+ pAcpiBoardInfo->PmEvtBase = (UINT64)PmEvtBase;
+ pAcpiBoardInfo->PmGpeEnBase = (UINT64)PmGpeEnBase;
DEBUG ((EFI_D_ERROR, "Create acpi board info guid hob\n"));

//
// Create guid hob for frame buffer information
//
diff --git a/CorebootModulePkg/Include/Guid/AcpiBoardInfoGuid.h b/CorebootModulePkg/Include/Guid/AcpiBoardInfoGuid.h
index 66ebffe..609e989 100644
--- a/CorebootModulePkg/Include/Guid/AcpiBoardInfoGuid.h
+++ b/CorebootModulePkg/Include/Guid/AcpiBoardInfoGuid.h
@@ -18,11 +18,13 @@
///
/// Board information GUID
///
extern EFI_GUID gUefiAcpiBoardInfoGuid;

-typedef struct {
+typedef struct {
+ UINT64 PmEvtBase;
+ UINT64 PmGpeEnBase;
UINT64 PmCtrlRegBase;
UINT64 PmTimerRegBase;
UINT64 ResetRegAddress;
UINT8 ResetValue;
} ACPI_BOARD_INFO;
diff --git a/CorebootModulePkg/Include/Library/CbParseLib.h b/CorebootModulePkg/Include/Library/CbParseLib.h
index 36727d3..170375b 100644
--- a/CorebootModulePkg/Include/Library/CbParseLib.h
+++ b/CorebootModulePkg/Include/Library/CbParseLib.h
@@ -89,21 +89,25 @@ CbParseSmbiosTable (

@param pPmCtrlReg Pointer to the address of power management control register
@param pPmTimerReg Pointer to the address of power management timer register
@param pResetReg Pointer to the address of system reset register
@param pResetValue Pointer to the value to be writen to the system reset register
+ @param pPmEvtReg Pointer to the address of power management event register
+ @param pPmGpeEnReg Pointer to the address of power management GPE enable register

@retval RETURN_SUCCESS Successfully find out all the required fadt information.
@retval RETURN_NOT_FOUND Failed to find the fadt table.

**/
RETURN_STATUS
CbParseFadtInfo (
IN UINTN* pPmCtrlReg,
IN UINTN* pPmTimerReg,
IN UINTN* pResetReg,
- IN UINTN* pResetValue
+ IN UINTN* pResetValue,
+ IN UINTN* pPmEvtReg,
+ IN UINTN* pPmGpeEnReg
);

/**
Find the serial port information
--
1.9.5.msysgit.0


------------------------------------------------------------------------------
Ma, Maurice
2015-06-19 04:33:35 UTC
Permalink
Reviewed-by: Maurice Ma <***@intel.com>

Thanks,
-Maurice

-----Original Message-----
From: Dong, Guo
Sent: Thursday, June 11, 2015 6:33 AM
To: edk2-***@lists.sourceforge.net
Cc: Ma, Maurice
Subject: [Patch 1/2] CorebootModulePkg: Get power management register addresses.

This patch will get power management event register address and power management GPE enable register address.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Guo Dong <***@intel.com>
---
CorebootModulePkg/CbSupportPei/CbSupportPei.c | 6 +++++-
CorebootModulePkg/Include/Guid/AcpiBoardInfoGuid.h | 4 +++-
CorebootModulePkg/Include/Library/CbParseLib.h | 6 +++++-
3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/CorebootModulePkg/CbSupportPei/CbSupportPei.c b/CorebootModulePkg/CbSupportPei/CbSupportPei.c
index b3705fa..2fb28d4 100755
--- a/CorebootModulePkg/CbSupportPei/CbSupportPei.c
+++ b/CorebootModulePkg/CbSupportPei/CbSupportPei.c
@@ -169,10 +169,12 @@ CbPeiEntryPoint (
SYSTEM_TABLE_INFO* pSystemTableInfo;
FRAME_BUFFER_INFO FbInfo;
FRAME_BUFFER_INFO* pFbInfo;
ACPI_BOARD_INFO* pAcpiBoardInfo;
UINTN PmCtrlRegBase, PmTimerRegBase, ResetRegAddress, ResetValue;
+ UINTN PmEvtBase;
+ UINTN PmGpeEnBase;

LowMemorySize = 0;
HighMemorySize = 0;

Status = CbParseMemoryInfo (&LowMemorySize, &HighMemorySize); @@ -353,19 +355,21 @@ CbPeiEntryPoint (
DEBUG ((EFI_D_ERROR, "Create system table info guid hob\n"));

//
// Create guid hob for acpi board information
//
- Status = CbParseFadtInfo (&PmCtrlRegBase, &PmTimerRegBase, &ResetRegAddress, &ResetValue);
+ Status = CbParseFadtInfo (&PmCtrlRegBase, &PmTimerRegBase,
+ &ResetRegAddress, &ResetValue, &PmEvtBase, &PmGpeEnBase);
ASSERT_EFI_ERROR (Status);
pAcpiBoardInfo = NULL;
pAcpiBoardInfo = BuildGuidHob (&gUefiAcpiBoardInfoGuid, sizeof (ACPI_BOARD_INFO));
ASSERT (pAcpiBoardInfo != NULL);
pAcpiBoardInfo->PmCtrlRegBase = (UINT64)PmCtrlRegBase;
pAcpiBoardInfo->PmTimerRegBase = (UINT64)PmTimerRegBase;
pAcpiBoardInfo->ResetRegAddress = (UINT64)ResetRegAddress;
pAcpiBoardInfo->ResetValue = (UINT8)ResetValue;
+ pAcpiBoardInfo->PmEvtBase = (UINT64)PmEvtBase;
+ pAcpiBoardInfo->PmGpeEnBase = (UINT64)PmGpeEnBase;
DEBUG ((EFI_D_ERROR, "Create acpi board info guid hob\n"));

//
// Create guid hob for frame buffer information
//
diff --git a/CorebootModulePkg/Include/Guid/AcpiBoardInfoGuid.h b/CorebootModulePkg/Include/Guid/AcpiBoardInfoGuid.h
index 66ebffe..609e989 100644
--- a/CorebootModulePkg/Include/Guid/AcpiBoardInfoGuid.h
+++ b/CorebootModulePkg/Include/Guid/AcpiBoardInfoGuid.h
@@ -18,11 +18,13 @@
///
/// Board information GUID
///
extern EFI_GUID gUefiAcpiBoardInfoGuid;

-typedef struct {
+typedef struct {
+ UINT64 PmEvtBase;
+ UINT64 PmGpeEnBase;
UINT64 PmCtrlRegBase;
UINT64 PmTimerRegBase;
UINT64 ResetRegAddress;
UINT8 ResetValue;
} ACPI_BOARD_INFO;
diff --git a/CorebootModulePkg/Include/Library/CbParseLib.h b/CorebootModulePkg/Include/Library/CbParseLib.h
index 36727d3..170375b 100644
--- a/CorebootModulePkg/Include/Library/CbParseLib.h
+++ b/CorebootModulePkg/Include/Library/CbParseLib.h
@@ -89,21 +89,25 @@ CbParseSmbiosTable (

@param pPmCtrlReg Pointer to the address of power management control register
@param pPmTimerReg Pointer to the address of power management timer register
@param pResetReg Pointer to the address of system reset register
@param pResetValue Pointer to the value to be writen to the system reset register
+ @param pPmEvtReg Pointer to the address of power management event register
+ @param pPmGpeEnReg Pointer to the address of power management GPE enable register

@retval RETURN_SUCCESS Successfully find out all the required fadt information.
@retval RETURN_NOT_FOUND Failed to find the fadt table.

**/
RETURN_STATUS
CbParseFadtInfo (
IN UINTN* pPmCtrlReg,
IN UINTN* pPmTimerReg,
IN UINTN* pResetReg,
- IN UINTN* pResetValue
+ IN UINTN* pResetValue,
+ IN UINTN* pPmEvtReg,
+ IN UINTN* pPmGpeEnReg
);

/**
Find the serial port information

--
1.9.5.msysgit.0


------------------------------------------------------------------------------
Guo Dong
2015-06-11 13:33:25 UTC
Permalink
This patch will fix reboot issue after issuing shell command "reset -s" from UEFI payload.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Guo Dong <***@intel.com>
---
.../Library/ResetSystemLib/ResetSystemLib.c | 31 ++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.c b/CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.c
index 77b81db..55f5609 100644
--- a/CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.c
+++ b/CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.c
@@ -110,15 +110,42 @@ VOID
EFIAPI
ResetShutdown (
VOID
)
{
- AcpiPmControl (7);
+ EFI_HOB_GUID_TYPE *GuidHob;
+ ACPI_BOARD_INFO *pAcpiBoardInfo;
+ UINTN PmCtrlReg;
+
+ //
+ // Find the acpi board information guid hob
+ //
+ GuidHob = GetFirstGuidHob (&gUefiAcpiBoardInfoGuid);
+ ASSERT (GuidHob != NULL);
+ pAcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob);
+
+ //
+ // GPE0_EN should be disabled to avoid any GPI waking up the system from S5
+ //
+ IoWrite16 ((UINTN)pAcpiBoardInfo->PmGpeEnBase, 0);
+
+ //
+ // Clear Power Button Status
+ //
+ IoWrite16((UINTN) pAcpiBoardInfo->PmEvtBase, BIT8);
+
+ //
+ // Transform system into S5 sleep state
+ //
+ PmCtrlReg = (UINTN)pAcpiBoardInfo->PmCtrlRegBase;
+ IoAndThenOr16 (PmCtrlReg, (UINT16) ~0x3c00, (UINT16) (7 << 10));
+ IoOr16 (PmCtrlReg, BIT13);
+ CpuDeadLoop ();
+
ASSERT (FALSE);
}

-
/**
Calling this function causes the system to enter a power state for capsule
update.

Reset update should not return, if it returns, it means the system does
--
1.9.5.msysgit.0


------------------------------------------------------------------------------
Ma, Maurice
2015-06-19 04:36:06 UTC
Permalink
Reviewed-by: Maurice Ma <***@intel.com>

Thanks,
-Maurice

-----Original Message-----
From: Dong, Guo
Sent: Thursday, June 11, 2015 6:33 AM
To: edk2-***@lists.sourceforge.net
Cc: Ma, Maurice
Subject: [Patch 2/2] CorebootPayloadPkg: Fix "reset -s" issue.

This patch will fix reboot issue after issuing shell command "reset -s" from UEFI payload.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Guo Dong <***@intel.com>
---
.../Library/ResetSystemLib/ResetSystemLib.c | 31 ++++++++++++++++++++--
1 file changed, 29 insertions(+), 2 deletions(-)

diff --git a/CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.c b/CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.c
index 77b81db..55f5609 100644
--- a/CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.c
+++ b/CorebootPayloadPkg/Library/ResetSystemLib/ResetSystemLib.c
@@ -110,15 +110,42 @@ VOID
EFIAPI
ResetShutdown (
VOID
)
{
- AcpiPmControl (7);
+ EFI_HOB_GUID_TYPE *GuidHob;
+ ACPI_BOARD_INFO *pAcpiBoardInfo;
+ UINTN PmCtrlReg;
+
+ //
+ // Find the acpi board information guid hob // GuidHob =
+ GetFirstGuidHob (&gUefiAcpiBoardInfoGuid); ASSERT (GuidHob != NULL);
+ pAcpiBoardInfo = (ACPI_BOARD_INFO *)GET_GUID_HOB_DATA (GuidHob);
+
+ //
+ // GPE0_EN should be disabled to avoid any GPI waking up the system
+ from S5 //
+ IoWrite16 ((UINTN)pAcpiBoardInfo->PmGpeEnBase, 0);
+
+ //
+ // Clear Power Button Status
+ //
+ IoWrite16((UINTN) pAcpiBoardInfo->PmEvtBase, BIT8);
+
+ //
+ // Transform system into S5 sleep state // PmCtrlReg =
+ (UINTN)pAcpiBoardInfo->PmCtrlRegBase;
+ IoAndThenOr16 (PmCtrlReg, (UINT16) ~0x3c00, (UINT16) (7 << 10));
+ IoOr16 (PmCtrlReg, BIT13);
+ CpuDeadLoop ();
+
ASSERT (FALSE);
}

-
/**
Calling this function causes the system to enter a power state for capsule
update.

Reset update should not return, if it returns, it means the system does
--
1.9.5.msysgit.0


------------------------------------------------------------------------------
Loading...