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
|
/* IBM_PROLOG_BEGIN_TAG */
/* This is an automatically generated prolog. */
/* */
/* $Source: src/usr/hwpf/hwp/mvpd_accessors/getMBvpdPhaseRotatorData.C $ */
/* */
/* IBM CONFIDENTIAL */
/* */
/* COPYRIGHT International Business Machines Corp. 2012,2013 */
/* */
/* p1 */
/* */
/* Object Code Only (OCO) source materials */
/* Licensed Internal Code Source Materials */
/* IBM HostBoot Licensed Internal Code */
/* */
/* The source code for this program is not published or otherwise */
/* divested of its trade secrets, irrespective of what has been */
/* deposited with the U.S. Copyright Office. */
/* */
/* Origin: 30 */
/* */
/* IBM_PROLOG_END_TAG */
// $Id: getMBvpdPhaseRotatorData.C,v 1.2 2013/04/29 16:44:00 whs Exp $
/**
* @file getMBvpdPhaseRotatorData.C
*
* @brief get Phase Rotator Data from MBvpd MR keyword
*
*/
#include <stdint.h>
// fapi support
#include <fapi.H>
#include <getMBvpdPhaseRotatorData.H>
extern "C"
{
using namespace fapi;
fapi::ReturnCode getMBvpdPhaseRotatorData(
const fapi::Target &i_mbaTarget,
const fapi::MBvpdPhaseRotatorData i_attr,
uint8_t (&o_val)[2])
{
//MR keyword layout
const uint8_t NUM_MBA = 2; //There are 2 MBAs per Centaur memory buffer
const uint8_t NUM_PORTS = 2; //Each MBA has 2 ports
const uint8_t PHASE_ROTATOR_ATTR_SIZE = 64; //Each port has 64 bytes
// for attributes
struct port_attributes
{
uint8_t port_attr[PHASE_ROTATOR_ATTR_SIZE];
};
struct mba_attributes
{
port_attributes mba_port[NUM_PORTS];
};
struct mr_keyword
{
mba_attributes mb_mba[NUM_MBA];
};
// The actual size of the MR keword is 255 bytes, which is one byte short
// of the mr_keyword struct. One byte is used for the size in the vpd.
// As long as there is at least one reserved attribute, then all will fit.
fapi::ReturnCode l_fapirc;
fapi::Target l_mbTarget;
uint8_t l_pos = NUM_PORTS; //initialize to out of range value (+1)
mr_keyword * l_pMrBuffer = NULL; // MBvpd MR keyword buffer
uint32_t l_MrBufsize = sizeof(mr_keyword);
FAPI_DBG("getMBvpdPhaseRotatorData: entry attr=0x%02x ",
i_attr );
do {
// find the position of the passed mba on the centuar
l_fapirc = FAPI_ATTR_GET(ATTR_CHIP_UNIT_POS,&i_mbaTarget,l_pos);
if (l_fapirc)
{
FAPI_ERR(" getMBvpdPhaseRotatorData: Get MBA position failed ");
break; // break out with fapirc
}
FAPI_DBG("getMBvpdPhaseRotatorData: mba %s position=%d",
i_mbaTarget.toEcmdString(),
l_pos);
// find the Centaur memmory buffer from the passed MBA
l_fapirc = fapiGetParentChip (i_mbaTarget,l_mbTarget);
if (l_fapirc)
{
FAPI_ERR("getMBvpdPhaseRotatorData: Finding the parent mb failed ");
break; // break out with fapirc
}
FAPI_DBG("getMBvpdPhaseRotatorData: parent path=%s ",
l_mbTarget.toEcmdString() );
// Read the MR keyword field
l_pMrBuffer = new mr_keyword;
l_fapirc = fapiGetMBvpdField(fapi::MBVPD_RECORD_VSPD,
fapi::MBVPD_KEYWORD_MR,
l_mbTarget,
reinterpret_cast<uint8_t *>(l_pMrBuffer),
l_MrBufsize);
if (l_fapirc)
{
FAPI_ERR("getMBvpdPhaseRotatorData: Read of MR keyword failed");
break; // break out with fapirc
}
// Check that sufficient MR was returned.
uint32_t l_sizeNeeded = l_pos*sizeof(mba_attributes)+
sizeof(port_attributes)+i_attr;
if (l_MrBufsize < l_sizeNeeded )
{
FAPI_ERR("getMBvpdPhaseRotatorData:"
" less MR keyword returned than expected %d < %d",
l_MrBufsize, l_sizeNeeded);
FAPI_SET_HWP_ERROR(l_fapirc, RC_MBVPD_INSUFFICIENT_MR_KEYWORD );
break; // break out with fapirc
}
// return the requested attributes from the MR keyword buffer
for (uint8_t l_port=0 ; l_port<NUM_PORTS ; l_port++)
{
o_val[l_port]=l_pMrBuffer->
mb_mba[l_pos].mba_port[l_port].port_attr[i_attr];
}
} while (0);
delete l_pMrBuffer;
l_pMrBuffer = NULL;
FAPI_DBG("getMBvpdPhaseRotatorData: exit rc=0x%08x (0x%02x,0x%02x)",
static_cast<uint32_t>(l_fapirc),
o_val[0],o_val[1] );
return l_fapirc;
}
} // extern "C"
|