Skip to content

Commit

Permalink
Write firdata to PNOR over IPMI
Browse files Browse the repository at this point in the history
Change-Id: I50c586baf2c2cb2a83ffb30e81304eef3d65119c
Reviewed-on: http://rchgit01.rchland.ibm.com/gerrit1/66620
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: William A. Bryan <wilbryan@us.ibm.com>
  • Loading branch information
dgilbert999 authored and wilbryan committed Oct 2, 2018
1 parent 084756c commit 3cb1ba3
Show file tree
Hide file tree
Showing 12 changed files with 960 additions and 115 deletions.
2 changes: 1 addition & 1 deletion src/occ_405/incl/common_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ typedef int INT;
typedef void VOID;

// Skip this typedef in x86 environment
#ifndef OCC_X86_PARSER
#if !defined(OCC_X86_PARSER) && !defined(__cplusplus)
typedef uint8_t bool;
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/occ_405/occbuildname.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ volatile const char G_occ_buildname[16] __attribute__((section(".buildname"))) =

#else

volatile const char G_occ_buildname[16] __attribute__((section(".buildname"))) = /*<BuildName>*/ "op920_180711a\0" /*</BuildName>*/ ;
volatile const char G_occ_buildname[16] __attribute__((section(".buildname"))) = /*<BuildName>*/ "op_occ_180914a\0" /*</BuildName>*/ ;

#endif
197 changes: 105 additions & 92 deletions src/occ_gpe0/firdata/ast_mboxdd.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@
#include <lpc.h>
#include <gpe_util.h>

int ipmi_sendCommand(mboxMessage_t *io_msg, int i_arg_size);


errorHndl_t writeRegSIO(uint8_t i_regAddr, uint8_t i_data)
{
errorHndl_t l_err = NO_ERROR;
Expand Down Expand Up @@ -105,7 +108,8 @@ errorHndl_t mboxIn(uint64_t i_addr, uint8_t *o_byte)
len );
}

errorHndl_t doMessage( astMbox_t *io_mbox, mboxMessage_t *io_msg )

errorHndl_t doMessage( astMbox_t *io_mbox, mboxMessage_t *io_msg, int i_arg_size )
{
uint8_t* l_data = (uint8_t*)io_msg;
errorHndl_t l_err = NO_ERROR;
Expand All @@ -116,128 +120,137 @@ errorHndl_t doMessage( astMbox_t *io_mbox, mboxMessage_t *io_msg )

io_msg->iv_seq = io_mbox->iv_mboxMsgSeq++;

do
//First try to send the message over IPMI
l_err = ipmi_sendCommand(io_msg, i_arg_size);

// If it didn't work then try to access the AST MBOX via LPC
// This is allowd for the case of an older BMC. Eventually it could
// be removed.
if(l_err)
{
/* Write message out */
for (i = 0; i < BMC_MBOX_DATA_REGS && !l_err; i++)
do
{
l_err = mboxOut(i, l_data[i]);
}
/* Write message out */
for (i = 0; i < BMC_MBOX_DATA_REGS && !l_err; i++)
{
l_err = mboxOut(i, l_data[i]);
}

if ( l_err )
{
break;
}
if ( l_err )
{
break;
}

/* Clear status1 response bit as it was just set via reg write*/
l_err = mboxOut(MBOX_STATUS_1, MBOX_STATUS1_RESP);
/* Clear status1 response bit as it was just set via reg write*/
l_err = mboxOut(MBOX_STATUS_1, MBOX_STATUS1_RESP);

if ( l_err )
{
break;
}
if ( l_err )
{
break;
}

/* Ping BMC */
l_err = mboxOut(MBOX_HOST_CTRL, MBOX_CTRL_INT_SEND);
/* Ping BMC */
l_err = mboxOut(MBOX_HOST_CTRL, MBOX_CTRL_INT_SEND);

if ( l_err )
{
break;
}
if ( l_err )
{
break;
}

/* Wait for response */
while ( l_loops++ < MBOX_MAX_RESP_WAIT_US && !l_err )
{
l_err = mboxIn(MBOX_STATUS_1, &l_stat1);
/* Wait for response */
while ( l_loops++ < MBOX_MAX_RESP_WAIT_US && !l_err )
{
l_err = mboxIn(MBOX_STATUS_1, &l_stat1);

if ( l_err )
{
TRAC_ERR("doMessage error from MBOX_STATUS_1");
break;
}

if ( l_stat1 & MBOX_STATUS1_RESP )
{
break;
}

busy_wait(1000);
}

if ( l_err )
{
TRAC_ERR("doMessage error from MBOX_STATUS_1");
TRAC_ERR( "Got error waiting for response !");
break;
}

if ( l_stat1 & MBOX_STATUS1_RESP )
if ( !(l_stat1 & MBOX_STATUS1_RESP) )
{
TRAC_ERR( "Timeout waiting for response !");

// Don't try to interrupt the BMC anymore
l_err = mboxOut(MBOX_HOST_CTRL, 0);
if ( l_err)
{
//Note the command failed
TRAC_ERR( "Error communicating with MBOX daemon");
TRAC_ERR( "Mbox status 1 reg: %x", l_stat1);
}

// Tell the code below that we generated the error
// (not an LPC error)
l_prot_error = true;
break;
}

busy_wait(1000);
}

if ( l_err )
{
TRAC_ERR( "Got error waiting for response !");
break;
}

if ( !(l_stat1 & MBOX_STATUS1_RESP) )
{
TRAC_ERR( "Timeout waiting for response !");

// Don't try to interrupt the BMC anymore
l_err = mboxOut(MBOX_HOST_CTRL, 0);
if ( l_err)
/* Clear status */
l_err = mboxOut(MBOX_STATUS_1, MBOX_STATUS1_RESP);
if (l_err)
{
//Note the command failed
TRAC_ERR( "Error communicating with MBOX daemon");
TRAC_ERR( "Mbox status 1 reg: %x", l_stat1);
TRAC_ERR( "Got error clearing status");
break;
}

// Tell the code below that we generated the error
// (not an LPC error)
l_prot_error = true;
break;
}
// Remember some message fields before they get overwritten
// by the response
uint8_t old_seq = io_msg->iv_seq;

/* Clear status */
l_err = mboxOut(MBOX_STATUS_1, MBOX_STATUS1_RESP);
if (l_err)
{
TRAC_ERR( "Got error clearing status");
break;
}
// Read response
for (i = 0; i < BMC_MBOX_DATA_REGS && !l_err; i++)
{
l_err = mboxIn(i, &l_data[i]);
}

// Remember some message fields before they get overwritten
// by the response
uint8_t old_seq = io_msg->iv_seq;
if ( l_err )
{
TRAC_ERR( "Got error reading response !");
break;
}

// Read response
for (i = 0; i < BMC_MBOX_DATA_REGS && !l_err; i++)
{
l_err = mboxIn(i, &l_data[i]);
}
if (old_seq != io_msg->iv_seq)
{
TRAC_ERR( "bad sequence number in mbox message, got %d want %d",
io_msg->iv_seq, old_seq);
l_err = -1;
break;
}

if ( l_err )
{
TRAC_ERR( "Got error reading response !");
break;
}
if (io_msg->iv_resp != MBOX_R_SUCCESS)
{
TRAC_ERR( "BMC mbox command failed with err %d",
io_msg->iv_resp);
l_err = -1;
// Tell code below that we generated the error (not an LPC error)
l_prot_error = true;
break;
}

if (old_seq != io_msg->iv_seq)
{
TRAC_ERR( "bad sequence number in mbox message, got %d want %d",
io_msg->iv_seq, old_seq);
l_err = -1;
break;
}
while(0);

if (io_msg->iv_resp != MBOX_R_SUCCESS)
// If we got an LPC error, commit it and generate our own
if ( l_err && !l_prot_error )
{
TRAC_ERR( "BMC mbox command failed with err %d",
io_msg->iv_resp);
l_err = -1;
// Tell code below that we generated the error (not an LPC error)
l_prot_error = true;
break;
}

}
while(0);

// If we got an LPC error, commit it and generate our own
if ( l_err && !l_prot_error )
{
l_err = -1;
}

return l_err;
Expand Down
2 changes: 1 addition & 1 deletion src/occ_gpe0/firdata/ast_mboxdd.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ typedef struct {
*
* @return Error from operation
*/
errorHndl_t doMessage( astMbox_t *io_mbox, mboxMessage_t *io_msg );
errorHndl_t doMessage( astMbox_t *io_mbox, mboxMessage_t *io_msg, int i_arg_size );

enum
{
Expand Down

0 comments on commit 3cb1ba3

Please sign in to comment.