summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/usr/mbox/mailboxsp.C66
-rw-r--r--src/usr/mbox/test/mboxsptest.H142
2 files changed, 129 insertions, 79 deletions
diff --git a/src/usr/mbox/mailboxsp.C b/src/usr/mbox/mailboxsp.C
index 835de1f2f..5312e6c16 100644
--- a/src/usr/mbox/mailboxsp.C
+++ b/src/usr/mbox/mailboxsp.C
@@ -35,6 +35,7 @@
#include <devicefw/userif.H>
#include <mbox/mbox_reasoncodes.H>
#include <mbox/mboxUdParser.H>
+#include <targeting/common/commontargeting.H>
#define HBMBOX_TRACE_NAME HBMBOX_COMP_NAME
@@ -121,37 +122,57 @@ errlHndl_t MailboxSp::_init()
return err;
}
- // Initialize the mailbox hardware
- err = mboxInit(iv_trgt);
- if (err)
+ bool spless = true;
+
+ TARGETING::Target * sys = NULL;
+ TARGETING::targetService().getTopLevelTarget( sys );
+ TARGETING::SpFunctions spfuncs;
+ if( sys &&
+ sys->tryGetAttr<TARGETING::ATTR_SP_FUNCTIONS>(spfuncs) &&
+ spfuncs.mailboxEnabled)
{
- return err;
+ spless = false;
}
- // Register to get interrupts for mailbox
- err = INTR::registerMsgQ(iv_msgQ, MSG_INTR, INTR::FSP_MAILBOX);
- if(err)
+ if(!spless)
{
- return err;
+ // Initialize the mailbox hardware
+ err = mboxInit(iv_trgt);
+ if (err)
+ {
+ return err;
+ }
+
+ // Register to get interrupts for mailbox
+ err = INTR::registerMsgQ(iv_msgQ, MSG_INTR, INTR::FSP_MAILBOX);
+ if(err)
+ {
+ return err;
+ }
}
task_create(MailboxSp::msg_handler, NULL);
- // Send message to FSP on base DMA buffer zone
- msg_t * msg = msg_allocate();
- msg->type = MSG_INITIAL_DMA;
- msg->data[0] = 0;
- msg->data[1] = reinterpret_cast<uint64_t>(iv_dmaBuffer.getDmaBufferHead());
- msg->extra_data = NULL;
- MBOX::send(FSP_MAILBOX_MSGQ,msg);
- iv_disabled = false;
+ if(!spless)
+ {
+ // Send message to FSP on base DMA buffer zone
+ msg_t * msg = msg_allocate();
+ msg->type = MSG_INITIAL_DMA;
+ msg->data[0] = 0;
+ msg->data[1] = reinterpret_cast<uint64_t>(iv_dmaBuffer.getDmaBufferHead());
+ msg->extra_data = NULL;
+ MBOX::send(FSP_MAILBOX_MSGQ,msg);
+
+ // Register for shutdown
+ INITSERVICE::registerShutdownEvent(iv_msgQ,
+ MSG_MBOX_SHUTDOWN,
+ INITSERVICE::MBOX_PRIORITY);
+
+ iv_disabled = false;
+ }
+ // else leave iv_disabled as true;
- // Register for shutdown
- INITSERVICE::registerShutdownEvent(iv_msgQ,
- MSG_MBOX_SHUTDOWN,
- INITSERVICE::MBOX_PRIORITY);
-
return err;
}
@@ -257,7 +278,7 @@ void MailboxSp::msgHandler()
}
break;
- default: //Huh? Ignore it.
+ default:
TRACFCOMP(g_trac_mbox, ERR_MRK "MailboxSp::msgHandler() "
"invalid message received 0x%08x",msg->type);
@@ -598,7 +619,6 @@ void MailboxSp::recv_msg(mbox_msg_t & i_mbox_msg)
msgq = r->second;
// Check that the type is within range
- // TODO also check if in secure mode msg->type > LAST_SECURE_MSG
if(msg->type < MSG_FIRST_SYS_TYPE) // &&
// (!is_secure() || (is_secure() && msg->type > LAST_SECURE_MSG))
{
diff --git a/src/usr/mbox/test/mboxsptest.H b/src/usr/mbox/test/mboxsptest.H
index 2bc243eb1..322bddffe 100644
--- a/src/usr/mbox/test/mboxsptest.H
+++ b/src/usr/mbox/test/mboxsptest.H
@@ -47,6 +47,22 @@ class MboxSPTest : public CxxTest::TestSuite
{
public:
+ bool mboxEnabled()
+ {
+ bool enabled = false;
+
+ TARGETING::Target * sys = NULL;
+ TARGETING::targetService().getTopLevelTarget( sys );
+ TARGETING::SpFunctions spfuncs;
+ if( sys &&
+ sys->tryGetAttr<TARGETING::ATTR_SP_FUNCTIONS>(spfuncs) &&
+ spfuncs.mailboxEnabled)
+ {
+ enabled = true;
+ }
+ return enabled;
+ }
+
/**
* @brief MBOX - Send asynchronous message
*/
@@ -87,67 +103,71 @@ class MboxSPTest : public CxxTest::TestSuite
nanosleep(0,1000000);
- // late registration to test ability to queue message until
- // a queue is ready
- err = MBOX::msgq_register(MBOX::HB_TEST_MSGQ,msgQ);
- if(err)
- {
- TS_FAIL("MBOX: Could not register message queue");
- errlCommit(err,HBMBOX_COMP_ID);
- }
-
-
- // Send last message
- msg_t * msg = msg_allocate();
- msg->type = 0xff; // use this to terminate while loop below
- msg->extra_data = NULL;
- err = MBOX::send(MBOX::HB_TEST_MSGQ,msg);
- if(err)
- {
- TS_FAIL("MBOX::send returned an error log");
- errlCommit(err,HBMBOX_COMP_ID);
- }
- // now get the messages - they will look like async messages
- // from FSP, even though they are just the echo of the
- // async messages that hostboot just sent above.
- size_t msg_idx = 0;
- while(1)
+ if(mboxEnabled())
{
- msg_t* msg = msg_wait(msgQ);
-
- if(msg->type == 0xff)
+ // late registration to test ability to queue message until
+ // a queue is ready
+ err = MBOX::msgq_register(MBOX::HB_TEST_MSGQ,msgQ);
+ if(err)
{
- msg_free(msg);
- break;
+ TS_FAIL("MBOX: Could not register message queue");
+ errlCommit(err,HBMBOX_COMP_ID);
}
- ++msg_idx;
- if(msg->type != 1 ||
- msg->data[0] != msg_idx ||
- msg->data[1] != 33 * 1024)
+ // Send last message
+ msg_t * msg = msg_allocate();
+ msg->type = 0xff; // use this to terminate while loop below
+ msg->extra_data = NULL;
+ err = MBOX::send(MBOX::HB_TEST_MSGQ,msg);
+ if(err)
{
- TS_FAIL("MBOXTEST: Unexpected message from FSP");
-
- TRACFCOMP(g_trac_mbox,
- "MBOXTEST MSG from FSP: %d %lx %lx %p",
- msg->type,
- msg->data[0],
- msg->data[1],
- msg->extra_data);
+ TS_FAIL("MBOX::send returned an error log");
+ errlCommit(err,HBMBOX_COMP_ID);
}
- if(msg->extra_data)
+
+ // now get the messages - they will look like async messages
+ // from FSP, even though they are just the echo of the
+ // async messages that hostboot just sent above.
+ size_t msg_idx = 0;
+ while(1)
{
- TRACFCOMP(g_trac_mbox,"MBOXTEST Extra data: %s",
- static_cast<char *>(msg->extra_data));
- ::free(msg->extra_data);
- }
+ msg_t* msg = msg_wait(msgQ);
+
+ if(msg->type == 0xff)
+ {
+ msg_free(msg);
+ break;
+ }
+
+ ++msg_idx;
+
+ if(msg->type != 1 ||
+ msg->data[0] != msg_idx ||
+ msg->data[1] != 33 * 1024)
+ {
+ TS_FAIL("MBOXTEST: Unexpected message from FSP");
+
+ TRACFCOMP(g_trac_mbox,
+ "MBOXTEST MSG from FSP: %d %lx %lx %p",
+ msg->type,
+ msg->data[0],
+ msg->data[1],
+ msg->extra_data);
+ }
+ if(msg->extra_data)
+ {
+ TRACFCOMP(g_trac_mbox,"MBOXTEST Extra data: %s",
+ static_cast<char *>(msg->extra_data));
+ ::free(msg->extra_data);
+ }
- msg_free(msg);
- }
+ msg_free(msg);
+ }
- msgQ = MBOX::msgq_unregister(MBOX::HB_TEST_MSGQ);
+ msgQ = MBOX::msgq_unregister(MBOX::HB_TEST_MSGQ);
+ } // end if mboxEnabled
msg_q_destroy(msgQ);
}
@@ -159,7 +179,7 @@ class MboxSPTest : public CxxTest::TestSuite
// This testcase only works if there is no FSP.
// Must be disabled for vpo and
// TODO disble if there is an FSP.
- if( TARGETING::is_vpo() )
+ if( TARGETING::is_vpo())
{
return;
}
@@ -175,8 +195,18 @@ class MboxSPTest : public CxxTest::TestSuite
if(err)
{
- TS_FAIL("MBOX::sendrecv returned an error log %p",err);
- errlCommit(err,HBMBOX_COMP_ID);
+ if(mboxEnabled())
+ {
+ TS_FAIL("MBOX::sendrecv returned an error log %p",err);
+ errlCommit(err,HBMBOX_COMP_ID);
+ }
+ }
+ else
+ {
+ if(!mboxEnabled())
+ {
+ TS_FAIL("MBOX::sendrecv expected an error log when mbox is disabled");
+ }
}
// TODO eventually the return data will be inverted or modified in
@@ -236,9 +266,9 @@ class MboxSPTest : public CxxTest::TestSuite
}
}
-#if defined(__DESTRUCTIVE_MBOX_TEST__)
- void DISABLEtestHardwareError(void)
+ void testHardwareError(void)
{
+#if defined(__DESTRUCTIVE_MBOX_TEST__)
msg_t * msg = msg_allocate();
msg->type = 0x8000ffff;
msg->extra_data = NULL;
@@ -278,8 +308,8 @@ class MboxSPTest : public CxxTest::TestSuite
}
msg_free(msg);
- }
#endif
+ }
};
#endif
OpenPOWER on IntegriCloud