Re: [edk2] [PATCH edk2-platforms v2 19/43] Silicon/Hisilicon/D06: Stop watchdog

2018-08-22 Thread Leif Lindholm
On Tue, Aug 14, 2018 at 04:08:39PM +0800, Ming Huang wrote:
> according as watchdog design on D06, watchdog should be
> stopped before boot a option.
> 
> This is an out of band watchdog timer in BMC; it is used
> to monitor the whole BIOS boot process and reset the system
> in case BIOS hangs somewhere, i.e. it is armed when system
> is power on, and disabled before handling system control to
> OS, while UEFI boot services watchdog is only armed before
> invoking a boot option. So they are two different watchdogs.
> 
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Ming Huang 

Reviewed-by: Leif Lindholm 

> ---
>  Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf 
> |  2 ++
>  Silicon/Hisilicon/Include/Library/IpmiCmdLib.h  
> | 16 ++
>  Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c   
> | 22 
>  3 files changed, 40 insertions(+)
> 
> diff --git 
> a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf 
> b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> index a093f13fb0..b9458b0ade 100644
> --- 
> a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> +++ 
> b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> @@ -46,6 +46,7 @@
>DebugLib
>DevicePathLib
>DxeServicesLib
> +  IpmiCmdLib
>MemoryAllocationLib
>PcdLib
>PrintLib
> @@ -69,6 +70,7 @@
>gEfiEndOfDxeEventGroupGuid
>gEfiTtyTermGuid
>gHisiOemVariableGuid
> +  gOemConfigGuid
>  
>  [Protocols]
>gEfiGenericMemTestProtocolGuid
> diff --git a/Silicon/Hisilicon/Include/Library/IpmiCmdLib.h 
> b/Silicon/Hisilicon/Include/Library/IpmiCmdLib.h
> index 8868b76135..b956ee6d07 100644
> --- a/Silicon/Hisilicon/Include/Library/IpmiCmdLib.h
> +++ b/Silicon/Hisilicon/Include/Library/IpmiCmdLib.h
> @@ -19,6 +19,17 @@
>  #define BOOT_OPTION_BOOT_FLAG_VALID 1
>  #define BOOT_OPTION_BOOT_FLAG_INVALID   0
>  
> +typedef enum {
> +  EfiReserved,
> +  EfiBiosFrb2,
> +  EfiBiosPost,
> +  EfiOsLoad,
> +  EfiSmsOs,
> +  EfiOem,
> +  EfiFrbReserved1,
> +  EfiFrbReserved2
> +} EFI_WDT_USER_TYPE;
> +
>  typedef enum {
>NoOverride = 0x0,
>ForcePxe,
> @@ -91,4 +102,9 @@ IpmiCmdGetSysBootOptions (
>IN IPMI_GET_BOOT_OPTION   *BootOption
>);
>  
> +EFI_STATUS
> +IpmiCmdStopWatchdogTimer (
> +  IN EFI_WDT_USER_TYPE  UserType
> +  );
> +
>  #endif
> diff --git a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c 
> b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c
> index d5f6d78fa4..b63818cbe4 100644
> --- a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c
> +++ b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c
> @@ -19,6 +19,8 @@
>  #include 
>  #include 
>  #include 
> +#include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -615,6 +617,8 @@ PlatformBootManagerAfterConsole (
>  {
>EFI_STATUS Status;
>ESRT_MANAGEMENT_PROTOCOL   *EsrtManagement = NULL;
> +  OEM_CONFIG_DATASetupData;
> +  UINTN  DataSize = sizeof (OEM_CONFIG_DATA);
>  
>//
>// Show the splash screen.
> @@ -651,6 +655,24 @@ PlatformBootManagerAfterConsole (
>  );
>  
>HandleBmcBootType ();
> +
> +  //Disable POST Watch Dog before attempting boot
> +  Status = gRT->GetVariable (
> +  OEM_CONFIG_NAME,
> +  ,
> +  NULL,
> +  ,
> +  
> +  );
> +
> +  if (!EFI_ERROR (Status)) {
> +if (SetupData.BmcWdtEnable) {
> +  Status = IpmiCmdStopWatchdogTimer (EfiBiosPost);
> +  if (EFI_ERROR (Status)) {
> +DEBUG ((DEBUG_ERROR, "%a:%r\n", __FUNCTION__, Status));
> +  }
> +}
> +  }
>  }
>  
>  /**
> -- 
> 2.17.0
> 
___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


[edk2] [PATCH edk2-platforms v2 19/43] Silicon/Hisilicon/D06: Stop watchdog

2018-08-14 Thread Ming Huang
according as watchdog design on D06, watchdog should be
stopped before boot a option.

This is an out of band watchdog timer in BMC; it is used
to monitor the whole BIOS boot process and reset the system
in case BIOS hangs somewhere, i.e. it is armed when system
is power on, and disabled before handling system control to
OS, while UEFI boot services watchdog is only armed before
invoking a boot option. So they are two different watchdogs.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ming Huang 
---
 Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |  
2 ++
 Silicon/Hisilicon/Include/Library/IpmiCmdLib.h  | 
16 ++
 Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c   | 
22 
 3 files changed, 40 insertions(+)

diff --git 
a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf 
b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index a093f13fb0..b9458b0ade 100644
--- 
a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ 
b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
@@ -46,6 +46,7 @@
   DebugLib
   DevicePathLib
   DxeServicesLib
+  IpmiCmdLib
   MemoryAllocationLib
   PcdLib
   PrintLib
@@ -69,6 +70,7 @@
   gEfiEndOfDxeEventGroupGuid
   gEfiTtyTermGuid
   gHisiOemVariableGuid
+  gOemConfigGuid
 
 [Protocols]
   gEfiGenericMemTestProtocolGuid
diff --git a/Silicon/Hisilicon/Include/Library/IpmiCmdLib.h 
b/Silicon/Hisilicon/Include/Library/IpmiCmdLib.h
index 8868b76135..b956ee6d07 100644
--- a/Silicon/Hisilicon/Include/Library/IpmiCmdLib.h
+++ b/Silicon/Hisilicon/Include/Library/IpmiCmdLib.h
@@ -19,6 +19,17 @@
 #define BOOT_OPTION_BOOT_FLAG_VALID 1
 #define BOOT_OPTION_BOOT_FLAG_INVALID   0
 
+typedef enum {
+  EfiReserved,
+  EfiBiosFrb2,
+  EfiBiosPost,
+  EfiOsLoad,
+  EfiSmsOs,
+  EfiOem,
+  EfiFrbReserved1,
+  EfiFrbReserved2
+} EFI_WDT_USER_TYPE;
+
 typedef enum {
   NoOverride = 0x0,
   ForcePxe,
@@ -91,4 +102,9 @@ IpmiCmdGetSysBootOptions (
   IN IPMI_GET_BOOT_OPTION   *BootOption
   );
 
+EFI_STATUS
+IpmiCmdStopWatchdogTimer (
+  IN EFI_WDT_USER_TYPE  UserType
+  );
+
 #endif
diff --git a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c 
b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c
index d5f6d78fa4..b63818cbe4 100644
--- a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c
+++ b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c
@@ -19,6 +19,8 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 #include 
 #include 
 #include 
@@ -615,6 +617,8 @@ PlatformBootManagerAfterConsole (
 {
   EFI_STATUS Status;
   ESRT_MANAGEMENT_PROTOCOL   *EsrtManagement = NULL;
+  OEM_CONFIG_DATASetupData;
+  UINTN  DataSize = sizeof (OEM_CONFIG_DATA);
 
   //
   // Show the splash screen.
@@ -651,6 +655,24 @@ PlatformBootManagerAfterConsole (
 );
 
   HandleBmcBootType ();
+
+  //Disable POST Watch Dog before attempting boot
+  Status = gRT->GetVariable (
+  OEM_CONFIG_NAME,
+  ,
+  NULL,
+  ,
+  
+  );
+
+  if (!EFI_ERROR (Status)) {
+if (SetupData.BmcWdtEnable) {
+  Status = IpmiCmdStopWatchdogTimer (EfiBiosPost);
+  if (EFI_ERROR (Status)) {
+DEBUG ((DEBUG_ERROR, "%a:%r\n", __FUNCTION__, Status));
+  }
+}
+  }
 }
 
 /**
-- 
2.17.0

___
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel