summaryrefslogtreecommitdiffstats
path: root/src/usr/i2c/errlud_i2c.C
blob: 37787c789a704abe8124734e108c87988d8b9e42 (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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
/* IBM_PROLOG_BEGIN_TAG                                                   */
/* This is an automatically generated prolog.                             */
/*                                                                        */
/* $Source: src/usr/i2c/errlud_i2c.C $                                    */
/*                                                                        */
/* OpenPOWER HostBoot Project                                             */
/*                                                                        */
/* COPYRIGHT International Business Machines Corp. 2013,2014              */
/*                                                                        */
/* 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                                                     */
/**
 *  @file errlud_fsi.C
 *
 *  @brief Implementation of classes to log FSI FFDC
 */
#include "errlud_i2c.H"
#include <i2c/i2creasoncodes.H>
#include <i2c/eepromddreasoncodes.H>
#include <devicefw/driverif.H>
#include "eepromdd.H"
#include "i2c.H"

namespace I2C
{

//------------------------------------------------------------------------------
//  I2C User Details
//------------------------------------------------------------------------------
UdI2CParms::UdI2CParms( uint8_t i_opType,
                        TARGETING::Target * i_target,
                        uint64_t i_buflen,
                        int64_t i_accessType,
                        misc_args_t i_args  )
{
    // Set up Ud instance variables
    iv_CompId = I2C_COMP_ID;
    iv_Version = 1;
    iv_SubSection = I2C_UDT_PARAMETERS;

    //***** Memory Layout *****
    // 1 byte   : Op Type Description
    // 1 byte   : Op Type (DeviceFW::OperationType)
    // 4 bytes  : Target HUID
    // 8 bytes  : Length of In/Out Buffer
    // 8 bytes  : Access Type (DeviceFW::AccessType)
    // 1 byte   : Port
    // 1 byte   : Engine
    // 8 bytes  : Device Address
    // 1 byte   : Flag: skip_mode_setup;
    // 1 byte   : Flag: with_stop;
    // 1 byte   : Flag: read_not_write;
    // 8 bytes  : Bus Speed (kbits/sec)
    // 2 bytes  : Bit Rate Divisor
    // 8 bytes  : Timeout Interval
    // 8 bytes  : Timeout Count;


    char * l_pBuf = reinterpret_cast<char *>(
                          reallocUsrBuf(sizeof(uint8_t)*2
                                        +sizeof(uint32_t)
                                        +sizeof(uint64_t)*2
                                        +sizeof(uint8_t)*2
                                        +sizeof(uint64_t)
                                        +sizeof(uint8_t)*3
                                        +sizeof(uint64_t)
                                        +sizeof(uint16_t)
                                        +sizeof(uint64_t)*2 ) );
    uint64_t tmp64 = 0;
    uint32_t tmp32 = 0;
    uint16_t tmp16 = 0;
    uint8_t tmp8 = 0;

    if( i_opType == DeviceFW::READ )
    {
        tmp8 = 0;
    }
    else if( i_opType == DeviceFW::WRITE )
    {
        tmp8 = 1;
    }
    else
    {
        tmp8 = 2;
    }
    memcpy(l_pBuf, &tmp8, sizeof(tmp8));
    l_pBuf += sizeof(tmp8);

    tmp8 = i_opType;
    memcpy(l_pBuf, &tmp8, sizeof(tmp8));
    l_pBuf += sizeof(tmp8);

    tmp32 = TARGETING::get_huid(i_target);
    memcpy(l_pBuf, &tmp32, sizeof(tmp32));
    l_pBuf += sizeof(tmp32);

    tmp64 = i_buflen;
    memcpy(l_pBuf, &tmp64, sizeof(tmp64));
    l_pBuf += sizeof(tmp64);

    tmp64 = i_accessType;
    memcpy(l_pBuf, &tmp64, sizeof(tmp64));
    l_pBuf += sizeof(tmp64);

    tmp8 = i_args.port;
    memcpy(l_pBuf, &tmp8, sizeof(tmp8));
    l_pBuf += sizeof(tmp8);

    tmp8 = i_args.engine;
    memcpy(l_pBuf, &tmp8, sizeof(tmp8));
    l_pBuf += sizeof(tmp8);

    tmp64 = i_args.devAddr;
    memcpy(l_pBuf, &tmp64, sizeof(tmp64));
    l_pBuf += sizeof(tmp64);

    tmp8 = i_args.skip_mode_setup;
    memcpy(l_pBuf, &tmp8, sizeof(tmp8));
    l_pBuf += sizeof(tmp8);

    tmp8 = i_args.with_stop;
    memcpy(l_pBuf, &tmp8, sizeof(tmp8));
    l_pBuf += sizeof(tmp8);

    tmp8 = i_args.read_not_write;
    memcpy(l_pBuf, &tmp8, sizeof(tmp8));
    l_pBuf += sizeof(tmp8);

    tmp64 = i_args.bus_speed;
    memcpy(l_pBuf, &tmp64, sizeof(tmp64));
    l_pBuf += sizeof(tmp64);

    tmp16 = i_args.bit_rate_divisor;
    memcpy(l_pBuf, &tmp16, sizeof(tmp16));
    l_pBuf += sizeof(tmp16);

    tmp64 = i_args.polling_interval_ns;
    memcpy(l_pBuf, &tmp64, sizeof(tmp64));
    l_pBuf += sizeof(tmp64);

    tmp64 = i_args.timeout_count;
    memcpy(l_pBuf, &tmp64, sizeof(tmp64));
    l_pBuf += sizeof(tmp64);

}

//------------------------------------------------------------------------------
UdI2CParms::~UdI2CParms()
{

}

} // end I2C namespace

namespace EEPROM
{


//------------------------------------------------------------------------------
//  EEPROM User Details
//------------------------------------------------------------------------------
UdEepromParms::UdEepromParms( uint8_t i_opType,
                              TARGETING::Target * i_target,
                              uint64_t i_buflen,
                              eeprom_addr_t i_i2cInfo )
{
    // Set up Ud instance variables
    iv_CompId = EEPROM_COMP_ID;
    iv_Version = 1;
    iv_SubSection = EEPROM_UDT_PARAMETERS;

    //***** Memory Layout *****
    // 1 byte   : Op Type Description
    // 1 byte   : Op Type (DeviceFW::OperationType)
    // 4 bytes  : Target HUID
    // 8 bytes  : Length of In/Out Buffer
    // 8 bytes  : Chip
    // 8 bytes  : Offset
    // 8 bytes  : Port
    // 8 bytes  : Engine
    // 8 bytes  : Device Address
    // 1 byte   : Address Size
    // 8 bytes  : Write Page Size
    // 8 bytes  : Device Size (in KB)
    // 8 bytes  : Write Cycle Time

    char * l_pBuf = reinterpret_cast<char *>(
                          reallocUsrBuf(sizeof(uint8_t)*2
                                        +sizeof(uint32_t)
                                        +sizeof(uint64_t)*6
                                        +sizeof(uint8_t)
                                        +sizeof(uint64_t)*3 ));

    uint64_t tmp64 = 0;
    uint32_t tmp32 = 0;
    uint8_t tmp8 = 0;

    if( i_opType == DeviceFW::READ )
    {
        tmp8 = 0;
    }
    else if( i_opType == DeviceFW::WRITE )
    {
        tmp8 = 1;
    }
    else
    {
        tmp8 = 2;
    }
    memcpy(l_pBuf, &tmp8, sizeof(tmp8));
    l_pBuf += sizeof(tmp8);

    tmp8 = i_opType;
    memcpy(l_pBuf, &tmp8, sizeof(tmp8));
    l_pBuf += sizeof(tmp8);

    tmp32 = TARGETING::get_huid(i_target);
    memcpy(l_pBuf, &tmp32, sizeof(tmp32));
    l_pBuf += sizeof(tmp32);

    tmp64 = i_buflen;
    memcpy(l_pBuf, &tmp64, sizeof(tmp64));
    l_pBuf += sizeof(tmp64);

    tmp64 = i_i2cInfo.chip;
    memcpy(l_pBuf, &tmp64, sizeof(tmp64));
    l_pBuf += sizeof(tmp64);

    tmp64 = i_i2cInfo.offset;
    memcpy(l_pBuf, &tmp64, sizeof(tmp64));
    l_pBuf += sizeof(tmp64);

    tmp64 = i_i2cInfo.port;
    memcpy(l_pBuf, &tmp64, sizeof(tmp64));
    l_pBuf += sizeof(tmp64);

    tmp64 = i_i2cInfo.engine;
    memcpy(l_pBuf, &tmp64, sizeof(tmp64));
    l_pBuf += sizeof(tmp64);

    tmp64 = i_i2cInfo.devAddr;
    memcpy(l_pBuf, &tmp64, sizeof(tmp64));
    l_pBuf += sizeof(tmp64);

    tmp8 = static_cast<uint8_t>(i_i2cInfo.addrSize);
    memcpy(l_pBuf, &tmp8, sizeof(tmp8));
    l_pBuf += sizeof(tmp8);

    tmp64 = i_i2cInfo.writePageSize;
    memcpy(l_pBuf, &tmp64, sizeof(tmp64));
    l_pBuf += sizeof(tmp64);

    tmp64 = i_i2cInfo.devSize_KB;
    memcpy(l_pBuf, &tmp64, sizeof(tmp64));
    l_pBuf += sizeof(tmp64);

    tmp64 = i_i2cInfo.writeCycleTime;
    memcpy(l_pBuf, &tmp64, sizeof(tmp64));
    l_pBuf += sizeof(tmp64);

}

//------------------------------------------------------------------------------
UdEepromParms::~UdEepromParms()
{

}

} // end EEPROM namespace
OpenPOWER on IntegriCloud