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
|
/*
* Force specific code
*
* Copyright (c) 2004 by FORCE Computers.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. This
* file and program are licensed under a BSD style license. See
* the Copying file included with the OpenHPI distribution for
* full licensing terms.
*
* Authors:
* Thomas Kanngieser <thomas.kanngieser@fci.com>
*/
#include "ipmi_mc_vendor_force.h"
#include "ipmi_utils.h"
#include "ipmi_log.h"
#include "ipmi_mc.h"
#include <errno.h>
cIpmiMcVendorForceShMc::cIpmiMcVendorForceShMc( unsigned int product_id )
: cIpmiMcVendor( 0x000e48, product_id, "Force ShMc" )
{
}
cIpmiMcVendorForceShMc::~cIpmiMcVendorForceShMc()
{
}
bool
cIpmiMcVendorForceShMc::InitMc( cIpmiMc *mc, const cIpmiMsg &devid )
{
stdlog << "Force ShMc found.\n";
// because we are talking to a ShMC and not the ShM,
// we need to do some setup:
// 1.) set the MC in ShMc mode
// 2.) clear repository SDR
if ( mc->Addr().IsType( eIpmiAddrTypeSystemInterface ) )
{
// we want to go into BMC mode
stdlog << "switch to ShMc mode.\n";
cIpmiMsg msg( (tIpmiNetfn)0x30, (tIpmiCmd)0x03 );
msg.m_data[0] = 0;
msg.m_data_len = 1;
cIpmiMsg rsp;
SaErrorT rv = mc->SendCommand( msg, rsp );
if ( rv != SA_OK )
{
stdlog << "cannot send set BMC mode: " << rv << " !\n";
return false;
}
if ( rsp.m_data_len <= 0 || rsp.m_data[0] != eIpmiCcOk )
{
stdlog << "cannot go into BMC mode: " << rsp.m_data[0] << " !\n";
return false;
}
// check if there is a repository SDR
if ( devid.m_data[6] & 2 )
{
stdlog << "clear repository SDR.\n";
// clear repository SDR
// get a reservation
msg.m_netfn = eIpmiNetfnStorage;
msg.m_cmd = eIpmiCmdReserveSdrRepository;
msg.m_data_len = 0;
rv = mc->SendCommand( msg, rsp );
if ( rv != SA_OK )
{
stdlog << "cannot send reserve reposotory SDR: " << rv << " !\n";
return true;
}
if ( rsp.m_data_len != 3 || rsp.m_data[0] != eIpmiCcOk )
{
stdlog << "cannot reserve repository SDR: " << rsp.m_data[0] << " !\n";
return true;
}
unsigned short reservation = IpmiGetUint16( rsp.m_data + 1 );
// create repository SDR and wait until erase completed
bool first = true;
msg.m_netfn = eIpmiNetfnStorage;
msg.m_cmd = eIpmiCmdClearSdrRepository;
IpmiSetUint16( msg.m_data, reservation );
msg.m_data[2] = 'C';
msg.m_data[3] = 'L';
msg.m_data[4] = 'R';
msg.m_data_len = 6;
do
{
msg.m_data[5] = first ? 0xaa : 0; // initiate erase/ erase status
first = false;
rv = mc->SendCommand( msg, rsp );
if ( rv != SA_OK )
{
stdlog << "cannot send clear SDR reposotory: " << rv << " !\n";
return true;
}
if ( rsp.m_data_len != 2 || rsp.m_data[0] != eIpmiCcOk )
{
stdlog << "cannot reserve repository SDR: " << rsp.m_data[0] << " !\n";
return true;
}
}
// wait until erase is complete
while( (rsp.m_data[1] & 0x7) != 0x1 );
}
}
// this is for debugging only
if ( devid.m_data[6] & 4 )
{
stdlog << "clear SEL.\n";
// get a reservation
cIpmiMsg msg( eIpmiNetfnStorage, eIpmiCmdReserveSel );
msg.m_data_len = 0;
cIpmiMsg rsp;
SaErrorT rv = mc->SendCommand( msg, rsp );
if ( rv != SA_OK )
{
stdlog << "cannot send reserve SEL: " << rv << " !\n";
return true;
}
if ( rsp.m_data_len != 3 || rsp.m_data[0] != eIpmiCcOk )
{
stdlog << "cannot reserve SEL: " << rsp.m_data[0] << " !\n";
return true;
}
unsigned short reservation = IpmiGetUint16( rsp.m_data + 1 );
// clear SEL
msg.m_netfn = eIpmiNetfnStorage;
msg.m_cmd = eIpmiCmdClearSel;
IpmiSetUint16( msg.m_data, reservation );
msg.m_data[2] = 'C';
msg.m_data[3] = 'L';
msg.m_data[4] = 'R';
msg.m_data_len = 6;
bool first = true;
do
{
msg.m_data[5] = first ? 0xaa : 0; // initiate erase/ erase status
first = false;
rv = mc->SendCommand( msg, rsp );
if ( rv != SA_OK )
{
stdlog << "cannot send clear SDR reposotory: " << rv << " !\n";
return true;
}
if ( rsp.m_data_len != 2 || rsp.m_data[0] != eIpmiCcOk )
{
stdlog << "cannot reserve repository SDR: " << rsp.m_data[0] << " !\n";
return true;
}
}
// wait until erase is complete
while( (rsp.m_data[1] & 0x7) != 0x1 );
}
return true;
}
bool
cIpmiMcVendorForceShMc::ProcessSdr( cIpmiDomain *domain, cIpmiMc *mc, cIpmiSdrs *sdrs )
{
if ( mc->GetAddress() != 0x20 )
return true;
// fix slave addr of ShMc at 0x20
// create one resource per mcdlr and fdlr
for( unsigned int i = 0; i < sdrs->NumSdrs(); i++ )
{
cIpmiSdr *sdr = sdrs->Sdr( i );
switch( sdr->m_type )
{
case eSdrTypeMcDeviceLocatorRecord:
sdr->m_data[5] = 0x20;
break;
default:
break;
}
}
return true;
}
|