summaryrefslogtreecommitdiffstats
path: root/src/usr/secureboot/node_comm/node_comm_dd.H
blob: 212ab24dfa1024f9251fb477e0e669f7b8dd42ec (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
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/secureboot/node_comm/node_comm_dd.H $                 */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* Contributors Listed Below - COPYRIGHT 2018                             */
/* [+] 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 __NODE_COMM_DD_H
#define __NODE_COMM_DD_H

// ----------------------------------------------
// Includes
// ----------------------------------------------
#include <config.h>
#include <devicefw/userif.H>
#include <secureboot/nodecommif.H>

namespace SECUREBOOT
{

namespace NODECOMM
{

/**
 * @brief Struct used to pass basic Node Communication operations
 *        information between functions
 */
struct node_comm_args_t
{
    TARGETING::Target* tgt;
    uint32_t tgt_huid;
    node_comm_modes_t mode;
    uint8_t linkId;
    uint8_t mboxId;
    uint64_t* data_ptr;

    node_comm_args_t():tgt(nullptr),
                       tgt_huid(0x0),
                       mode(NCDD_MODE_INVALID),
                       linkId(NCDD_INVALID_LINK_MBOX),
                       mboxId(NCDD_INVALID_LINK_MBOX),
                       data_ptr(nullptr){};
};


/**
 * @brief Node Comm Contol (and Status) Register Definition
 *
 * @note  Certain bits are used to start an operation, provide status of the
 *        operation, and flag errors in the operation.
 */
union ctrl_reg_t
{
    uint64_t value;
    struct
    {
        uint64_t start_stop : 1;  // set to start op; HW sets to 0 when op done
        uint64_t write_not_read : 1;
        uint64_t bad_addr : 1;
        uint64_t link_down : 1;
        uint64_t corrupt : 1;
        uint64_t sent : 1;
        uint64_t bad_write : 1;
        uint64_t reset : 1;
        uint64_t mbox_id : 1;
        uint64_t link_id : 3;
        uint64_t reserved : 52;

    } PACKED;
};


/**
*
* @brief Perform a Node Comm operation.  It follows a pre-defined
*       prototype function in order to be registered with the device
*       driver framework.
*
* @param[in] i_opType - Operation Type - See DeviceFW::OperationType in
*       driverif.H
*
* @param[in] i_target - Processor Target
*                       Code will fail if nullptr or not TYPE_PROC
*
* @param [in/out] io_buffer
*       INPUT: Pointer to the data that will be  written to the target device
*       OUTPUT: Pointer to the data that was read from the target device
*
* @param [in/out] io_buflen
*       INPUT: Length of the buffer to be written to target device
*       OUTPUT: Length of buffer that was written, or length of buffer
*           to be read from target device
*       NOTE:  For Both INPUT and OUTPUT this should be 8-bytes (64-bits)
*
* @param [in] i_accessType - Access Type - See DeviceFW::AccessType in
*       userif.H
*
* @param [in] i_args - This is an argument list for the device driver
*       framework.  This list of arguments is documented in userif.H.
*
* @return errlHndl_t - NULL if successful, otherwise a pointer to the
*       error log.
*
*/
errlHndl_t nodeCommPerformOp( DeviceFW::OperationType i_opType,
                         TARGETING::Target * i_target,
                         void * io_buffer,
                         size_t & io_buflen,
                         int64_t i_accessType,
                         va_list i_args );

/**
 * @brief Reads data From ABUS/XBUS Link Mailbox Register
 *
 * @param[in/out] io_args - Structure containing arguments needed for a command
 *                          transaction and it holds the resulting data
 *
 * @return errlHndl_t - nullptr if successful, otherwise a pointer to
 *                      the error log.
 */
errlHndl_t ncddRead (node_comm_args_t & io_args);

/**
 * @brief Writes data to ABUS/XBUS Link Mailbox Data Movement Register and then
 *        sends data via Link Bus Mailbox capability
 *
 * @param[in] i_args - Structure containing arguments needed for a command
 *                     transaction.
 *
 * @return errlHndl_t - nullptr if successful, otherwise a pointer to
 *                      the error log.
 */
errlHndl_t ncddWrite (node_comm_args_t & i_args);

/**
 * @brief Checks the status in the ABUS/XBUS Link Mailbox Control Register
 *
 * @param[in] i_args - Structure containing arguments needed for a command
 *                     transaction.
 *
 * @param[in] i_statusVal - Control/Status Register value to be checked
 *
 * @return errlHndl_t - nullptr if successful and the command is complete;
 *                      otherwise a pointer to the error log.
 */
errlHndl_t ncddCheckStatus (node_comm_args_t & i_args,
                            const ctrl_reg_t & i_statusVal );

/**
 * @brief Waits for the operation to complete or timeout while
 *        periodically checking the status for errors
 *
 * @param[in] i_args - Structure containing arguments needed for a command
 *                     transaction.
 *
 * @param[in] o_statusVal - Last Control/Status Register value that was checked
 *
 * @return errlHndl_t - nullptr if successful and the command is complete;
 *                      otherwise a pointer to the error log.
 */
errlHndl_t ncddWaitForCmdComp (node_comm_args_t & i_args,
                               ctrl_reg_t & o_statusVal);

/**
 * @brief Analyzes an error handle object and performs any
 *        reset activity, if necessary
 *
 * @param[in/out] io_err - The error to analyze
 * @param[in]     i_args - miscellaneous arguments
 *
 * @return void
 */
void ncddHandleError( errlHndl_t & io_err,
                      node_comm_args_t & i_args );


/**
 * @brief This function handles all Node Communications-related SCOM operations
 *
 * @param[in] i_opType - Operation Type - See DeviceFW::OperationType in
 *       driververif.H
 *
 * @param [in/out] io_buffer_64
 *       INPUT: Pointer to 64 bits of data to be  written to the target
 *       OUTPUT: Pointer to the 64 bits of data that was read from the target
 *
 * @param[in] i_reg - The SCOM register of the operation
 *
 * @param[in/out] i_args - Structure containing arguments needed for a command
 *                         transaction and holds resulting data, if applicable
 *
 * @return errHndl_t - NULL if successful, otherwise a pointer to
 *                     the error log.
 */
errlHndl_t ncddRegisterOp ( DeviceFW::OperationType i_opType,
                            uint64_t * io_data_64,
                            uint64_t i_reg,
                            node_comm_args_t & i_args );

} // end NODECOMM namespace

} // end SECUREBOOT namespace

#endif // End __NODE_COMM_DD_H

OpenPOWER on IntegriCloud