Skip to content

Commit

Permalink
rt_xstop_analysis: initial commit to get pnor acceses working
Browse files Browse the repository at this point in the history
Change-Id: I1d0e07bfbbc206b9ade87befdb0d86c5bcc4385a
Reviewed-on: http://ralgit01.raleigh.ibm.com/gerrit1/43045
Reviewed-by: Zane C. Shelley <zshelle@us.ibm.com>
Reviewed-by: ILYA SMIRNOV <ismirno@us.ibm.com>
Reviewed-by: Brian J. Stegmiller <bjs@us.ibm.com>
Tested-by: FSP CI Jenkins <fsp-CI-jenkins+hostboot@us.ibm.com>
Reviewed-by: William A. Bryan <wilbryan@us.ibm.com>
  • Loading branch information
wghoffa authored and wilbryan committed Jul 21, 2017
1 parent 237557e commit c4b8c5c
Show file tree
Hide file tree
Showing 13 changed files with 348 additions and 328 deletions.
63 changes: 12 additions & 51 deletions src/occ_405/firdata/ast_mboxdd.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,20 +35,6 @@
#include <norflash.h>
#include <ast_mboxdd.h>
#include <lpc.h>
extern int TRACE_LPC;
int TRACE_MBOX = 0;

/*****************************************************************************/
/* C o n s t a n t s */
/*****************************************************************************/

/*****************************************************************************/
/* G l o b a l s */
/*****************************************************************************/

/*****************************************************************************/
/* M e t h o d s */
/*****************************************************************************/

errorHndl_t writeRegSIO(uint8_t i_regAddr, uint8_t i_data)
{
Expand Down Expand Up @@ -110,7 +96,7 @@ errorHndl_t mboxOut(uint64_t i_addr, uint8_t i_byte)

errorHndl_t mboxIn(uint64_t i_addr, uint8_t *o_byte)
{
size_t len = sizeof(o_byte);
size_t len = sizeof(uint8_t);

return lpc_read( LPC_TRANS_IO,
i_addr + MBOX_IO_BASE,
Expand All @@ -120,15 +106,13 @@ errorHndl_t mboxIn(uint64_t i_addr, uint8_t *o_byte)

errorHndl_t doMessage( astMbox_t *io_mbox, mboxMessage_t *io_msg )
{
uint8_t* l_data = ((uint8_t*)((char*)&io_msg));
uint8_t* l_data = (uint8_t*)io_msg;
errorHndl_t l_err = NO_ERROR;
uint8_t l_stat1;
uint8_t l_flags;
uint32_t l_loops = 0;
bool l_prot_error = false;
int i;

TRAC_INFO( "doMessage(0x%02x)", io_msg->iv_cmd );
io_msg->iv_seq = io_mbox->iv_mboxMsgSeq++;

do
Expand Down Expand Up @@ -160,52 +144,41 @@ errorHndl_t doMessage( astMbox_t *io_mbox, mboxMessage_t *io_msg )
break;
}

TRAC_INFO( "Command sent, waiting for response...");

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

if ( l_err )
{
break;
}

l_err = mboxIn(MBOX_FLAG_REG, &l_flags);

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

if ( l_stat1 & MBOX_STATUS1_RESP )
{
break;
}

sleep(1000);
}

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

if ( !(l_stat1 & MBOX_STATUS1_RESP) )
{
TRAC_INFO( "Timeout waiting for response !");
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_INFO( "Error communicating with MBOX daemon");
TRAC_INFO( "Mbox status 1 reg: %x", l_stat1);
TRAC_INFO( "Mbox flag reg: %x", l_flags);
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
Expand All @@ -216,10 +189,9 @@ errorHndl_t doMessage( astMbox_t *io_mbox, mboxMessage_t *io_msg )

/* Clear status */
l_err = mboxOut(MBOX_STATUS_1, MBOX_STATUS1_RESP);

if (l_err)
{
TRAC_INFO( "Got error clearing status");
TRAC_ERR( "Got error clearing status");
break;
}

Expand All @@ -228,36 +200,28 @@ errorHndl_t doMessage( astMbox_t *io_mbox, mboxMessage_t *io_msg )
uint8_t old_seq = io_msg->iv_seq;

// Read response
TRAC_INFO( "Reading response data...");

for (i = 0; i < BMC_MBOX_DATA_REGS && !l_err; i++)
{
l_err = mboxIn(i, &l_data[i]);
}

if ( l_err )
{
TRAC_INFO( "Got error reading response !");
TRAC_ERR( "Got error reading response !");
break;
}

TRAC_INFO( "Message: cmd:%02x seq:%02x a:%02x %02x %02x %02x %02x..resp:%02x",
io_msg->iv_cmd, io_msg->iv_seq, io_msg->iv_args[0],
io_msg->iv_args[1], io_msg->iv_args[2], io_msg->iv_args[3],
io_msg->iv_args[4], io_msg->iv_resp);

if (old_seq != io_msg->iv_seq)
{
TRAC_INFO( "bad sequence number in mbox message, got %d want %d",
TRAC_ERR( "bad sequence number in mbox message, got %d want %d",
io_msg->iv_seq, old_seq);

l_err = -1;
break;
}

if (io_msg->iv_resp != MBOX_R_SUCCESS)
{
TRAC_INFO( "BMC mbox command failed with err %d",
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)
Expand All @@ -271,19 +235,16 @@ errorHndl_t doMessage( astMbox_t *io_mbox, mboxMessage_t *io_msg )
// If we got an LPC error, commit it and generate our own
if ( l_err && !l_prot_error )
{
l_err = -1;
}

TRAC_INFO( "doMessage() resp=0x%02x",
io_msg->iv_resp );
return l_err;
}

errorHndl_t initializeMbox(void)
{
errorHndl_t l_errl = NO_ERROR;

TRAC_INFO("initializeMBOX()");

do
{
size_t reg_size = sizeof(uint8_t);
Expand Down
16 changes: 10 additions & 6 deletions src/occ_405/firdata/ast_mboxdd.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ errorHndl_t readRegSIO(uint8_t i_regAddr,
*
* @return data requested
*/
inline uint8_t get8( mboxMessage_t *i_msg, uint8_t i_index)
static inline uint8_t get8( mboxMessage_t *i_msg, uint8_t i_index)
{
if ( i_index >= BMC_MBOX_ARGS_REGS )
{
Expand All @@ -133,7 +133,7 @@ inline uint8_t get8( mboxMessage_t *i_msg, uint8_t i_index)
* @param[in] i_index: Index into args section to be written to
* @param[in] i_value: data to be written
*/
inline void put8( mboxMessage_t *i_msg, uint8_t i_index, uint8_t i_value )
static inline void put8(mboxMessage_t *i_msg, uint8_t i_index, uint8_t i_value)
{
if ( i_index >= BMC_MBOX_ARGS_REGS )
{
Expand All @@ -150,7 +150,7 @@ inline void put8( mboxMessage_t *i_msg, uint8_t i_index, uint8_t i_value )
*
* @return data requested
*/
inline uint16_t get16( mboxMessage_t *i_msg, uint8_t i_index )
static inline uint16_t get16( mboxMessage_t *i_msg, uint8_t i_index )
{
if ( i_index >= (BMC_MBOX_ARGS_REGS-1) )
{
Expand All @@ -167,7 +167,9 @@ inline uint16_t get16( mboxMessage_t *i_msg, uint8_t i_index )
* @param[in] i_index: Index into args section to be written to
* @param[in] i_value: data to be written
*/
inline void put16( mboxMessage_t *i_msg, uint8_t i_index, uint16_t i_value )
static inline void put16(mboxMessage_t *i_msg,
uint8_t i_index,
uint16_t i_value)
{
if ( i_index >= (BMC_MBOX_ARGS_REGS-1) )
{
Expand All @@ -186,7 +188,7 @@ inline void put16( mboxMessage_t *i_msg, uint8_t i_index, uint16_t i_value )
*
* @return data requested
*/
inline uint32_t get32( mboxMessage_t *i_msg, uint8_t i_index )
static inline uint32_t get32( mboxMessage_t *i_msg, uint8_t i_index )
{
if ( i_index >= (BMC_MBOX_ARGS_REGS-3) )
{
Expand All @@ -205,7 +207,9 @@ inline uint32_t get32( mboxMessage_t *i_msg, uint8_t i_index )
* @param[in] i_msg: mboxMessage_t pointer to access args section
* @param[in] i_index: Index into args section to be read from
*/
inline void put32( mboxMessage_t *i_msg, uint8_t i_index, uint32_t i_value )
static inline void put32(mboxMessage_t *i_msg,
uint8_t i_index,
uint32_t i_value)
{
if ( i_index >= (BMC_MBOX_ARGS_REGS-3) )
{
Expand Down

0 comments on commit c4b8c5c

Please sign in to comment.