summaryrefslogtreecommitdiffstats
path: root/sbe/sbefw/sberegaccess.H
blob: e89f4d82bdab5e24f66d85e46be2c54e2b854c5d (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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
/*
 * @file: ppe/sbe/sbefw/sberegaccess.H
 *
 * @brief This file contains interfaces to get/set FW flags either in the
 * scratch registers and/or the FW attributes.
 */

#ifndef __SBEFW_SBEREGACCESS_H
#define __SBEFW_SBEREGACCESS_H

#include <stdint.h>
#include "sbestates.H"

/**
 * @brief Utility singleton that SBEFW can use to read write various scratch
 * registers/FW attributes
 * TODO: via RTC ??????: Need to change the read of scratch registers to FAPI
 * attribute accesses once we have the attributes defined in the HWP code.
 */
class SbeRegAccess
{
    public:
        // Disable copy construction and assignment operators
        SbeRegAccess(const SbeRegAccess&) = delete;
        SbeRegAccess& operator=(const SbeRegAccess&) = delete;

        /**
         * @brief Returns the instance of this class
         *
         * @return A reference to SbeRegAccess
         *
         */
        static SbeRegAccess& theSbeRegAccess()
        {
            static SbeRegAccess iv_instance;
            return iv_instance;
        }

        /**
         * @brief Initializes the class for use
         *
         * @return An RC indicating success/failure
         *
         */
        uint32_t init();

        /**
         * @brief Update the SBE states into the SBE messaging register. The
         * function does a read-modify-write, so any bits other than the state
         * bits are preserved. The current state of the register is set to
         * i_state, whereas the old current state is copied to previous state
         *
         * @param [in] i_state The current SBE state
         *
         * @return RC indicating success/failure.
         *
         */
        uint32_t updateSbeState(const sbeState &i_state);

        /**
         * @brief Update the SBE IPL steps into the SBE messaging register. The
         * function does a read-modify-write, so any bits other than the IPL
         * steps are retianed
         *
         * @param [in] i_major IPL major step number
         * @param [in] i_minor IPL minor step number
         *
         * @return RC indicating success/failure.
         *
         */
        uint32_t updateSbeStep(const uint8_t i_major, const uint8_t i_minor);

        /**
         * @brief Set the SBE ready bit into the SBE messaging register
         * (meaning that SBE control loop is initialized) The function does a
         * read-modify-write, so any bits other than the SBE ready bit remain
         * unchanged.
         *
         * @return RC indicating success/failure.
         *
         */
        uint32_t setSbeReady();

        /**
         * @brief Set the MPIPL mode bit into the mailbox scratch reg. 3
         * The function does a read-modify-write, so any bits other than the
         * SBE ready bit remain unchanged. It also updates the attribute
         * ATTR_MPIPL
         *
         * @param i_set [in] true == set, false == clear
         *
         * @return RC indicating success/failure.
         *
         */
        uint32_t setMpIplMode(const bool i_set);

        /**
         * @brief Check if we are on an FSP attached
         *
         * @return true if FSP attached system, false otherwise
         *
         */
        inline bool isFspSystem() const
        {
            return iv_fspAttached;
        }

        /**
         * @brief Check if we are in ISTEP IPL mode
         *
         * @return true if in istep mode, false otherwise
         *
         */
        inline bool isIstepMode() const
        {
            return iv_istepMode;
        }

        /**
         * @brief Check if SBE should directly go to runtime state
         *
         * @return true if SBE should go directly to runtime state,
         * false otherwise
         *
         */
        inline bool isDestBitRuntime() const
        {
            return iv_sbeDestRuntime;
        }

        /**
         * @brief Check if SBE should collect FFDC
         *
         * @return true if in istep mode, false otherwise
         *
         */
        inline bool isCollectFFDCSet() const
        {
            return iv_collectFFDC;
        }

        /**
         * @brief Check if SBE should send internal FFDC for any chip op
         * failures as a part of the response
         *
         * @return true if in istep mode, false otherwise
         *
         */
        inline bool isSendInternalFFDCSet() const
        {
            return iv_sendFFDC;
        }

        /**
         * @brief Check if SBE is slave/master
         *
         * @return true if SBE is slave, false if master
         *
         */
        inline bool isSbeSlave() const
        {
            return iv_isSlave;
        }

    private:

        /**
         * @brief Constructor
         */
        SbeRegAccess() : iv_mbx3(0), iv_mbx6(0), iv_messagingReg(0)
        {}

        union
        {
            struct
            {
                uint64_t iv_istepMode : 1;
                uint64_t iv_sbeDestRuntime : 1;
                uint64_t iv_mpiplMode : 1;
                uint64_t iv_fspAttached : 1;
                uint64_t iv_collectFFDC : 1;
                uint64_t iv_sendFFDC : 1;
                uint64_t iv_mbx3DontCare : 26;
                uint64_t iv_mbx3Unused : 32;
            };
            uint64_t iv_mbx3;
        };

        union
        {
            struct
            {
                uint64_t iv_mbx6DontCare : 24;
                uint64_t iv_isSlave : 1;
                uint64_t iv_mbx6DontCare2 : 7;
                uint64_t iv_mbx6Unused : 32;
            };
            uint64_t iv_mbx6;
        };

        union
        {
            struct
            {
                uint64_t iv_sbeBooted : 1;
                uint64_t iv_reserved1 : 3;
                uint64_t iv_prevState : 4;
                uint64_t iv_currState : 4;
                uint64_t iv_majorStep : 4;
                uint64_t iv_minorStep : 8;
                uint64_t iv_reserved2 : 8;
                uint64_t iv_unused : 32;
            };
            uint64_t iv_messagingReg;
        };

        // Bit masks defining bits in the above registers that the SBE is
        // interested in
        static const uint64_t SBE_MBX8_MBX3_VALID_MASK = 0x2000000000000000ULL;
        static const uint64_t SBE_MBX8_MBX6_VALID_MASK = 0x0400000000000000ULL;
        static const uint64_t SBE_DEV_ID_C4_PIN_MASK = 0x0000000000800000ULL;
};
#endif //__SBEFW_SBEREGACCESS_H

OpenPOWER on IntegriCloud