diff mbox series

[edk2,edk2-platforms,v1,12/38] Silicon/Hisilicon/D06: Stop watchdog

Message ID 20180724070922.63362-13-ming.huang@linaro.org
State New
Headers show
Series Upload for D06 platform | expand

Commit Message

Ming Huang July 24, 2018, 7:08 a.m. UTC
From: Sun Yuanchen <sunyuanchen@huawei.com>


according as watchdog design on D06, watchdog should be
stoped befor boot a option.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Wang Yue <wangyue41@huawei.com>

Signed-off-by: Ming Huang <ming.huang@linaro.org>

Signed-off-by: Heyi Guo <heyi.guo@linaro.org>

---
 Silicon/Hisilicon/Include/Library/IpmiCmdLib.h                              | 16 ++++++++++++++
 Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c               | 22 ++++++++++++++++++++
 Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |  2 ++
 3 files changed, 40 insertions(+)

-- 
2.17.0

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

Comments

Leif Lindholm Aug. 3, 2018, 10:28 a.m. UTC | #1
On Tue, Jul 24, 2018 at 03:08:56PM +0800, Ming Huang wrote:
> From: Sun Yuanchen <sunyuanchen@huawei.com>

> 

> according as watchdog design on D06, watchdog should be

> stoped befor boot a option.


stopped before

> 

> Contributed-under: TianoCore Contribution Agreement 1.1

> Signed-off-by: Wang Yue <wangyue41@huawei.com>

> Signed-off-by: Ming Huang <ming.huang@linaro.org>

> Signed-off-by: Heyi Guo <heyi.guo@linaro.org>

> ---

>  Silicon/Hisilicon/Include/Library/IpmiCmdLib.h                              | 16 ++++++++++++++

>  Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c               | 22 ++++++++++++++++++++

>  Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |  2 ++

>  3 files changed, 40 insertions(+)

> 

> 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 f7536bfea3..9636f29dce 100644

> --- a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c

> +++ b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c

> @@ -19,8 +19,10 @@

>  #include <Library/BootLogoLib.h>

>  #include <Library/BmcConfigBootLib.h>

>  #include <Library/DevicePathLib.h>

> +#include <Library/OemConfigData.h>

>  #include <Library/PcdLib.h>

>  #include <Library/TimerLib.h>

> +#include <Library/IpmiCmdLib.h>


Please put this line after Library/DevicePathLib.h.

>  #include <Library/UefiBootManagerLib.h>

>  #include <Library/UefiLib.h>

>  #include <Protocol/DevicePath.h>

> @@ -615,6 +617,8 @@ PlatformBootManagerAfterConsole (

>  {

>    EFI_STATUS Status;

>    ESRT_MANAGEMENT_PROTOCOL           *EsrtManagement = NULL;

> +  OEM_CONFIG_DATA                    SetupData;

> +  UINTN                              DataSize = sizeof (OEM_CONFIG_DATA);

>  

>    //

>    // Show the splash screen.

> @@ -651,6 +655,24 @@ PlatformBootManagerAfterConsole (

>      );

>  

>    HandleBmcBootType ();

> +

> +  //Disable POST Watch Dog before enter setup


Before entering setup (as stated here) or before attempting boot (as
stated in commit message)?

> +  Status = gRT->GetVariable (

> +                  OEM_CONFIG_NAME,

> +                  &gOemConfigGuid,

> +                  NULL,

> +                  &DataSize,

> +                  &SetupData

> +                  );

> +

> +  if (!EFI_ERROR (Status)) {

> +    if (SetupData.BmcWdtEnable) {

> +      Status = IpmiCmdStopWatchdogTimer (EfiBiosPost);

> +      if (EFI_ERROR (Status)) {

> +        DEBUG ((DEBUG_ERROR, "%a:%r\n", __FUNCTION__, Status));

> +      }

> +    }

> +  }

>  }

>  

>  /**

> diff --git a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf

> index a093f13fb0..21afb53fc5 100644

> --- a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf

> +++ b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf

> @@ -47,6 +47,7 @@

>    DevicePathLib

>    DxeServicesLib

>    MemoryAllocationLib

> +  IpmiCmdLib


Please move up one line.

/
    Leif

>    PcdLib

>    PrintLib

>    TimerLib

> @@ -69,6 +70,7 @@

>    gEfiEndOfDxeEventGroupGuid

>    gEfiTtyTermGuid

>    gHisiOemVariableGuid

> +  gOemConfigGuid

>  

>  [Protocols]

>    gEfiGenericMemTestProtocolGuid

> -- 

> 2.17.0

> 

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Ard Biesheuvel Aug. 3, 2018, 10:31 a.m. UTC | #2
On 24 July 2018 at 09:08, Ming Huang <ming.huang@linaro.org> wrote:
> From: Sun Yuanchen <sunyuanchen@huawei.com>

>

> according as watchdog design on D06, watchdog should be

> stoped befor boot a option.

>


Why? The DXE core already handles the watchdog, why do you need
something special here?

> Contributed-under: TianoCore Contribution Agreement 1.1

> Signed-off-by: Wang Yue <wangyue41@huawei.com>

> Signed-off-by: Ming Huang <ming.huang@linaro.org>

> Signed-off-by: Heyi Guo <heyi.guo@linaro.org>

> ---

>  Silicon/Hisilicon/Include/Library/IpmiCmdLib.h                              | 16 ++++++++++++++

>  Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c               | 22 ++++++++++++++++++++

>  Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |  2 ++

>  3 files changed, 40 insertions(+)

>

> 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 f7536bfea3..9636f29dce 100644

> --- a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c

> +++ b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c

> @@ -19,8 +19,10 @@

>  #include <Library/BootLogoLib.h>

>  #include <Library/BmcConfigBootLib.h>

>  #include <Library/DevicePathLib.h>

> +#include <Library/OemConfigData.h>

>  #include <Library/PcdLib.h>

>  #include <Library/TimerLib.h>

> +#include <Library/IpmiCmdLib.h>

>  #include <Library/UefiBootManagerLib.h>

>  #include <Library/UefiLib.h>

>  #include <Protocol/DevicePath.h>

> @@ -615,6 +617,8 @@ PlatformBootManagerAfterConsole (

>  {

>    EFI_STATUS Status;

>    ESRT_MANAGEMENT_PROTOCOL           *EsrtManagement = NULL;

> +  OEM_CONFIG_DATA                    SetupData;

> +  UINTN                              DataSize = sizeof (OEM_CONFIG_DATA);

>

>    //

>    // Show the splash screen.

> @@ -651,6 +655,24 @@ PlatformBootManagerAfterConsole (

>      );

>

>    HandleBmcBootType ();

> +

> +  //Disable POST Watch Dog before enter setup

> +  Status = gRT->GetVariable (

> +                  OEM_CONFIG_NAME,

> +                  &gOemConfigGuid,

> +                  NULL,

> +                  &DataSize,

> +                  &SetupData

> +                  );

> +

> +  if (!EFI_ERROR (Status)) {

> +    if (SetupData.BmcWdtEnable) {

> +      Status = IpmiCmdStopWatchdogTimer (EfiBiosPost);

> +      if (EFI_ERROR (Status)) {

> +        DEBUG ((DEBUG_ERROR, "%a:%r\n", __FUNCTION__, Status));

> +      }

> +    }

> +  }

>  }

>

>  /**

> diff --git a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf

> index a093f13fb0..21afb53fc5 100644

> --- a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf

> +++ b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf

> @@ -47,6 +47,7 @@

>    DevicePathLib

>    DxeServicesLib

>    MemoryAllocationLib

> +  IpmiCmdLib

>    PcdLib

>    PrintLib

>    TimerLib

> @@ -69,6 +70,7 @@

>    gEfiEndOfDxeEventGroupGuid

>    gEfiTtyTermGuid

>    gHisiOemVariableGuid

> +  gOemConfigGuid

>

>  [Protocols]

>    gEfiGenericMemTestProtocolGuid

> --

> 2.17.0

>

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Ming Huang Aug. 8, 2018, 9:49 a.m. UTC | #3
在 8/3/2018 6:28 PM, Leif Lindholm 写道:
> On Tue, Jul 24, 2018 at 03:08:56PM +0800, Ming Huang wrote:
>> From: Sun Yuanchen <sunyuanchen@huawei.com>
>>
>> according as watchdog design on D06, watchdog should be
>> stoped befor boot a option.
> 
> stopped before
> 
>>
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Wang Yue <wangyue41@huawei.com>
>> Signed-off-by: Ming Huang <ming.huang@linaro.org>
>> Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
>> ---
>>  Silicon/Hisilicon/Include/Library/IpmiCmdLib.h                              | 16 ++++++++++++++
>>  Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c               | 22 ++++++++++++++++++++
>>  Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |  2 ++
>>  3 files changed, 40 insertions(+)
>>
>> 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 f7536bfea3..9636f29dce 100644
>> --- a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c
>> +++ b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c
>> @@ -19,8 +19,10 @@
>>  #include <Library/BootLogoLib.h>
>>  #include <Library/BmcConfigBootLib.h>
>>  #include <Library/DevicePathLib.h>
>> +#include <Library/OemConfigData.h>
>>  #include <Library/PcdLib.h>
>>  #include <Library/TimerLib.h>
>> +#include <Library/IpmiCmdLib.h>
> 
> Please put this line after Library/DevicePathLib.h.
> 
>>  #include <Library/UefiBootManagerLib.h>
>>  #include <Library/UefiLib.h>
>>  #include <Protocol/DevicePath.h>
>> @@ -615,6 +617,8 @@ PlatformBootManagerAfterConsole (
>>  {
>>    EFI_STATUS Status;
>>    ESRT_MANAGEMENT_PROTOCOL           *EsrtManagement = NULL;
>> +  OEM_CONFIG_DATA                    SetupData;
>> +  UINTN                              DataSize = sizeof (OEM_CONFIG_DATA);
>>  
>>    //
>>    // Show the splash screen.
>> @@ -651,6 +655,24 @@ PlatformBootManagerAfterConsole (
>>      );
>>  
>>    HandleBmcBootType ();
>> +
>> +  //Disable POST Watch Dog before enter setup
> 
> Before entering setup (as stated here) or before attempting boot (as
> stated in commit message)?
> 

Before attempting boot

>> +  Status = gRT->GetVariable (
>> +                  OEM_CONFIG_NAME,
>> +                  &gOemConfigGuid,
>> +                  NULL,
>> +                  &DataSize,
>> +                  &SetupData
>> +                  );
>> +
>> +  if (!EFI_ERROR (Status)) {
>> +    if (SetupData.BmcWdtEnable) {
>> +      Status = IpmiCmdStopWatchdogTimer (EfiBiosPost);
>> +      if (EFI_ERROR (Status)) {
>> +        DEBUG ((DEBUG_ERROR, "%a:%r\n", __FUNCTION__, Status));
>> +      }
>> +    }
>> +  }
>>  }
>>  
>>  /**
>> diff --git a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
>> index a093f13fb0..21afb53fc5 100644
>> --- a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
>> +++ b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
>> @@ -47,6 +47,7 @@
>>    DevicePathLib
>>    DxeServicesLib
>>    MemoryAllocationLib
>> +  IpmiCmdLib
> 
> Please move up one line.
> 
> /
>     Leif
> 

All comments will be apply.
Thanks.

Ming

>>    PcdLib
>>    PrintLib
>>    TimerLib
>> @@ -69,6 +70,7 @@
>>    gEfiEndOfDxeEventGroupGuid
>>    gEfiTtyTermGuid
>>    gHisiOemVariableGuid
>> +  gOemConfigGuid
>>  
>>  [Protocols]
>>    gEfiGenericMemTestProtocolGuid
>> -- 
>> 2.17.0
>>
Ming Huang Aug. 9, 2018, 11:40 a.m. UTC | #4
在 8/3/2018 6:31 PM, Ard Biesheuvel 写道:
> On 24 July 2018 at 09:08, Ming Huang <ming.huang@linaro.org> wrote:
>> From: Sun Yuanchen <sunyuanchen@huawei.com>
>>
>> according as watchdog design on D06, watchdog should be
>> stoped befor boot a option.
>>
> 
> Why? The DXE core already handles the watchdog, why do you need
> something special here?

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.
Thanks.

> 
>> Contributed-under: TianoCore Contribution Agreement 1.1
>> Signed-off-by: Wang Yue <wangyue41@huawei.com>
>> Signed-off-by: Ming Huang <ming.huang@linaro.org>
>> Signed-off-by: Heyi Guo <heyi.guo@linaro.org>
>> ---
>>  Silicon/Hisilicon/Include/Library/IpmiCmdLib.h                              | 16 ++++++++++++++
>>  Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c               | 22 ++++++++++++++++++++
>>  Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf |  2 ++
>>  3 files changed, 40 insertions(+)
>>
>> 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 f7536bfea3..9636f29dce 100644
>> --- a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c
>> +++ b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c
>> @@ -19,8 +19,10 @@
>>  #include <Library/BootLogoLib.h>
>>  #include <Library/BmcConfigBootLib.h>
>>  #include <Library/DevicePathLib.h>
>> +#include <Library/OemConfigData.h>
>>  #include <Library/PcdLib.h>
>>  #include <Library/TimerLib.h>
>> +#include <Library/IpmiCmdLib.h>
>>  #include <Library/UefiBootManagerLib.h>
>>  #include <Library/UefiLib.h>
>>  #include <Protocol/DevicePath.h>
>> @@ -615,6 +617,8 @@ PlatformBootManagerAfterConsole (
>>  {
>>    EFI_STATUS Status;
>>    ESRT_MANAGEMENT_PROTOCOL           *EsrtManagement = NULL;
>> +  OEM_CONFIG_DATA                    SetupData;
>> +  UINTN                              DataSize = sizeof (OEM_CONFIG_DATA);
>>
>>    //
>>    // Show the splash screen.
>> @@ -651,6 +655,24 @@ PlatformBootManagerAfterConsole (
>>      );
>>
>>    HandleBmcBootType ();
>> +
>> +  //Disable POST Watch Dog before enter setup
>> +  Status = gRT->GetVariable (
>> +                  OEM_CONFIG_NAME,
>> +                  &gOemConfigGuid,
>> +                  NULL,
>> +                  &DataSize,
>> +                  &SetupData
>> +                  );
>> +
>> +  if (!EFI_ERROR (Status)) {
>> +    if (SetupData.BmcWdtEnable) {
>> +      Status = IpmiCmdStopWatchdogTimer (EfiBiosPost);
>> +      if (EFI_ERROR (Status)) {
>> +        DEBUG ((DEBUG_ERROR, "%a:%r\n", __FUNCTION__, Status));
>> +      }
>> +    }
>> +  }
>>  }
>>
>>  /**
>> diff --git a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
>> index a093f13fb0..21afb53fc5 100644
>> --- a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
>> +++ b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
>> @@ -47,6 +47,7 @@
>>    DevicePathLib
>>    DxeServicesLib
>>    MemoryAllocationLib
>> +  IpmiCmdLib
>>    PcdLib
>>    PrintLib
>>    TimerLib
>> @@ -69,6 +70,7 @@
>>    gEfiEndOfDxeEventGroupGuid
>>    gEfiTtyTermGuid
>>    gHisiOemVariableGuid
>> +  gOemConfigGuid
>>
>>  [Protocols]
>>    gEfiGenericMemTestProtocolGuid
>> --
>> 2.17.0
>>
Leif Lindholm Aug. 9, 2018, 11:53 a.m. UTC | #5
On Thu, Aug 09, 2018 at 07:40:27PM +0800, Ming wrote:
> 
> 
> 在 8/3/2018 6:31 PM, Ard Biesheuvel 写道:
> > On 24 July 2018 at 09:08, Ming Huang <ming.huang@linaro.org> wrote:
> >> From: Sun Yuanchen <sunyuanchen@huawei.com>
> >>
> >> according as watchdog design on D06, watchdog should be
> >> stoped befor boot a option.
> >>
> > 
> > Why? The DXE core already handles the watchdog, why do you need
> > something special here?
> 
> 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.

OK, that makes sense, thanks.
Please clarify in commit message.

/
    Leif
diff mbox series

Patch

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 f7536bfea3..9636f29dce 100644
--- a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c
+++ b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBm.c
@@ -19,8 +19,10 @@ 
 #include <Library/BootLogoLib.h>
 #include <Library/BmcConfigBootLib.h>
 #include <Library/DevicePathLib.h>
+#include <Library/OemConfigData.h>
 #include <Library/PcdLib.h>
 #include <Library/TimerLib.h>
+#include <Library/IpmiCmdLib.h>
 #include <Library/UefiBootManagerLib.h>
 #include <Library/UefiLib.h>
 #include <Protocol/DevicePath.h>
@@ -615,6 +617,8 @@  PlatformBootManagerAfterConsole (
 {
   EFI_STATUS Status;
   ESRT_MANAGEMENT_PROTOCOL           *EsrtManagement = NULL;
+  OEM_CONFIG_DATA                    SetupData;
+  UINTN                              DataSize = sizeof (OEM_CONFIG_DATA);
 
   //
   // Show the splash screen.
@@ -651,6 +655,24 @@  PlatformBootManagerAfterConsole (
     );
 
   HandleBmcBootType ();
+
+  //Disable POST Watch Dog before enter setup
+  Status = gRT->GetVariable (
+                  OEM_CONFIG_NAME,
+                  &gOemConfigGuid,
+                  NULL,
+                  &DataSize,
+                  &SetupData
+                  );
+
+  if (!EFI_ERROR (Status)) {
+    if (SetupData.BmcWdtEnable) {
+      Status = IpmiCmdStopWatchdogTimer (EfiBiosPost);
+      if (EFI_ERROR (Status)) {
+        DEBUG ((DEBUG_ERROR, "%a:%r\n", __FUNCTION__, Status));
+      }
+    }
+  }
 }
 
 /**
diff --git a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index a093f13fb0..21afb53fc5 100644
--- a/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ b/Silicon/Hisilicon/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
@@ -47,6 +47,7 @@ 
   DevicePathLib
   DxeServicesLib
   MemoryAllocationLib
+  IpmiCmdLib
   PcdLib
   PrintLib
   TimerLib
@@ -69,6 +70,7 @@ 
   gEfiEndOfDxeEventGroupGuid
   gEfiTtyTermGuid
   gHisiOemVariableGuid
+  gOemConfigGuid
 
 [Protocols]
   gEfiGenericMemTestProtocolGuid