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
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/include/usr/sbeio/runtime/sbe_msg_passing.H $ */
/* */
/* OpenPOWER HostBoot Project */
/* */
/* Contributors Listed Below - COPYRIGHT 2017 */
/* [+] 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 SBE_MSG_PASSING_H
#define SBE_MSG_PASSING_H
#include <stdint.h>
#include <map>
#include <errl/errlmanager.H>
#include <targeting/common/target.H>
namespace SBE_MSG
{
// SBE Communication Buffer for Pass-through commands
/**
* @brief SBE Communication package size in number of pages
*/
const uint8_t SBE_COMM_PKG_SIZE = 1;
/**
* @brief SBE Communication buffer size
*/
const uint32_t SBE_COMM_BUFFER_SIZE = SBE_COMM_PKG_SIZE * PAGESIZE;
/**
* @brief SBE Message size / Pass-through Command size
*/
const uint32_t SBE_MSG_SIZE = SBE_COMM_BUFFER_SIZE;
// SBE Header Version enums for SBE Header version field
enum sbeHdrVersion
{
SBEHDRVER_FIRST = 0x00010000, // First SBE Header version
// NOTE: Update SBEHDRVER_LATEST with each new version
SBEHDRVER_LATEST = SBEHDRVER_FIRST
};
#define ENUM_SBEHDRVER_CHECK(version) (((version) >= SBEHDRVER_FIRST) \
&& ((version) <= SBEHDRVER_LATEST))
// Command Header Version enums for Command Header version field
enum cmdHdrVersion
{
CMDHDRVER_FIRST = 0x00010000, // First Command Hdr version
// NOTE: Update CMDHDRVER_LATEST with each new version
CMDHDRVER_LATEST = CMDHDRVER_FIRST
};
#define ENUM_CMDHDRVER_CHECK(version) (((version) >= CMDHDRVER_FIRST) \
&& ((version) <= CMDHDRVER_LATEST))
// Pass-Through Command enums for Command Header command field
enum passThruCmds
{
PASSTHRU_SET_OCC_STATE = 0x00E00001, // Set OCC State
PASSTHRU_GET_OCC_SENSOR = 0x00E00002, // Get OCC Sensor Readings
PASSTHRU_SET_HYPER_ENV = 0x00E00003, // Set Hypervisor Environment
PASSTHRU_QRY_MD_FN = 0x00E00004, // Query Mode and Function
PASSTHRU_RST_PM_COMPLEX = 0x00E00005, // Reset PM Complex
PASSTHRU_CTL_AUTOSLEW = 0x00E00006, // Control Autoslew
PASSTHRU_GET_PSTATE = 0x00E00007, // Get PState Table
};
// SBE Header at start of SBE Message
typedef struct sbeHeader
{
uint32_t version; // SBE header version
uint32_t msgSize; // Message size (Pass-through cmd or rsp)
// Size includes SBE and Command Headers
uint32_t seqId; // Sequence ID
} PACKED sbeHeader_t;
// Command Header following SBE Header in SBE Message
typedef struct cmdHeader
{
uint32_t version; // Command header version
uint32_t status; // Status of processing (rsp only)
uint32_t dataOffset; // Data offset (cmd or rsp)
// Offset is from beginning of Command Header
uint32_t dataSize; // Data size (cmd or rsp)
// Size does NOT include ANY Header fields
uint32_t command; // Pass-through command
} PACKED cmdHeader_t;
// Max Pass-through command/response data size
const uint32_t SBE_MSG_MAX_DATA =
SBE_MSG_SIZE - sizeof(sbeHeader_t) - sizeof(cmdHeader_t);
// SBE Message (Pass-through command or response)
typedef struct sbeMessage
{
sbeHeader_t sbeHdr; // SBE header
cmdHeader_t cmdHdr; // Command header
uint8_t data[SBE_MSG_MAX_DATA]; // Pass-through command/response data
} sbeMessage_t;
/**
* @brief Function to process pass-through command from SBE message
*
* @param[in] i_procTgt HB processor target
* @param[in] i_reqDataSize Pass-through command request data size
* @param[in] i_reqData Pass-through command request data
* @param[out] o_rspStatus Pass-through command response status
* @param[out] o_rspDataSize Pass-through command response data size
* @param[out] o_rspData Pass-through command response data
*
* @return errlHndl_t Error log handle on failure.
*/
typedef errlHndl_t (*processCmdFunction_t)(TARGETING::TargetHandle_t,
uint32_t,
uint8_t*,
uint32_t*,
uint32_t*,
uint8_t*);
// Process Command Map of pass-through command to function used to process
typedef std::map<uint32_t, processCmdFunction_t> ProcessCmdMap_t;
/**
* @brief Set process pass-through command function in Process Command Map
*
* @param[in] i_command Process pass-through command
* @param[in] i_function Function to process pass-through command
*
* @return int Return code.
*/
int setProcessCmdFunction(enum passThruCmds i_command,
processCmdFunction_t i_function);
} // namespace SBE_MSG
#endif
|