summaryrefslogtreecommitdiffstats
path: root/src/include/usr/ipmi/ipmiwatchdog.H
blob: 56ba1300cb43de9122bfa95061cbe160937303b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/include/usr/ipmi/ipmiwatchdog.H $                         */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2014,2016                        */
/* [+] International Business Machines Corp.                              */
/*                                                                        */
/*                                                                        */
/* Licensed under the Apache License, Version 2.0 (the "License");        */
/* you may not use this file except in compliance with the License.       */
/* You may obtain a copy of the License at                                */
/*                                                                        */
/*     http://www.apache.org/licenses/LICENSE-2.0                         */
/*                                                                        */
/* Unless required by applicable law or agreed to in writing, software    */
/* distributed under the License is distributed on an "AS IS" BASIS,      */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or        */
/* implied. See the License for the specific language governing           */
/* permissions and limitations under the License.                         */
/*                                                                        */
/* IBM_PROLOG_END_TAG                                                     */
#ifndef __IPMIWATCHDOG_IPMIWATCHDOG_H
#define __IPMIWATCHDOG_IPMIWATCHDOG_H
/**
 *  @file ipmiwatchdog.H
 *
 *  IPMI watchdog interface launched from the IStep Dispatcher
 *
 */

/******************************************************************************/
// Includes
/******************************************************************************/
#include <stdint.h>
#include <errl/errlentry.H>

namespace IPMIWATCHDOG
{
/******************************************************************************/
// Globals/Constants
/******************************************************************************/
/**
 * @brief the default watchdog countdown setting it to 120 seconds.
 *
 * @TODO RTC:124499 revisit after performace improvments
 *
 */
// The config option CONFIG_BMC_IPMI_LONG_WATCHDOG allows a tester to use a
// watchdog timer that is several times more than what a customer would desire
// to aid in testing only. This option was initially envisioned for use with
// tracelite enabled, which greatly lengthens IPL time causing the watchdog
// timer to timeout. However this option could have other uses, so its name
// is left generic so as not imply the limited use with tracelite alone.
#ifdef CONFIG_BMC_IPMI_LONG_WATCHDOG
const uint16_t  DEFAULT_WATCHDOG_COUNTDOWN = 2400;
#else
const uint16_t  DEFAULT_WATCHDOG_COUNTDOWN = 120;
#endif

/**
 * @brief the default watchdog countdown for transition between hostboot
 * and OPAL (value is in seconds)
 */
const uint16_t  DEFAULT_HB_OPAL_TRANSITION_COUNTDOWN = 30;

/******************************************************************************/
// Typedef/Enumerations
/******************************************************************************/
/**
 * @brief Used in Byte 1 field of the set watchdog command
 */
enum TIMER_USE
{
    DO_NOT_LOG  =   0x80, // bit 7
    DO_NOT_STOP =   0x40, // bit 6
    BIOS_FRB2   =   0x01, // bit 0
    BIOS_POST   =   0x02, // bit 1
    OS_LOAD     =   0x03, // bits 0 & 1
    SMS_OS      =   0x04, // bit 2
    OEM         =   0x05, // bits 2 & 0

};

/**
 * @brief Used in Byte 2 field of the set watchdog command
 */
enum TIMER_ACTIONS
{
    NO_ACTIONS              =   0x00, // all bits
    PRE_TIMEOUT_INT_SMI     =   0x10, // bit 4
    PRE_TIMEOUT_INT_NMI     =   0x20, // bit 5
    PRE_TIMEOUT_INT_MSG     =   0x30, // bits 4 & 5
    TIMEOUT_HARD_RESET      =   0x01, // bit 0
    TIMEOUT_PWR_DOWN        =   0x02, // bit 1
    TIMEOUT_PWR_CYCLE       =   0x03, // bits 0 & 1

};

/**
 * @brief Used in Byte 4 field of the set watchdog command
 *      set to 1 to clear the flag set to 0 to leave alone
 */
enum TIMER_USE_CLR_FLAGS
{
    OEM_FLAG     =   0x20, // bit 5
    SMS_OS_FLAG  =   0x10, // bit 4
    OS_LOAD_FLAG  =   0x08, // bit 3
    BIOS_POST_FLAG  =   0x04, // bit 2
    BIOS_FRB2_FLAG  =   0x02, // bit 1

};


/******************************************************************************/
// Functions
/******************************************************************************/

/**
 * @brief Sets the ipmi watchdog timer on the BMC
 *
 * Called by hostboot to set a watchdog timer on the BMC
 * @param[in] i_countdown_secs, initial countdown in seconds
 * @param[in] i_timer_use, Sets watchdog timer use bits.
 * @param[in] i_timer_action, Sets watchdog timer experation action.
 * @param[in] i_timer_clr_flag, Sets the Watchdog interrupt flag to clear.
 * @return none
 */

errlHndl_t setWatchDogTimer(  const uint16_t i_countdown_secs,
                        const uint8_t i_timer_use
                                = static_cast<uint8_t>(DO_NOT_STOP | BIOS_FRB2),
                        const TIMER_ACTIONS i_timer_action
                                = TIMEOUT_HARD_RESET,
                        const TIMER_USE_CLR_FLAGS i_timer_clr_flag
                                = BIOS_FRB2_FLAG);

/**
 * @brief Resets the ipmi watchdog timer on the BMC
 *
 * Called by hostboot to reset a watchdog timer countdown on the BMC.
 * If the BMC returns an error code indicating the watchdog timer
 * has not been started, this function will start the watchdog timer.
 *
 * @return error
 */
errlHndl_t resetWatchDogTimer();


} // namespace

#endif
OpenPOWER on IntegriCloud