diff options
author | Wael El-Essawy <welessa@us.ibm.com> | 2015-10-15 17:14:00 -0500 |
---|---|---|
committer | Fadi Kassem <fmkassem@us.ibm.com> | 2015-10-23 10:05:28 -0500 |
commit | 52da94bc4351afea3eb8c9d420c1223a3f60e0eb (patch) | |
tree | 54c6a3ea154725053895439c49beba3ed313b164 /src/occ_gpe0/gpe0_main.c | |
parent | ec0926884623af9fcfef5cbb9ce2de56fa252344 (diff) | |
download | talos-occ-52da94bc4351afea3eb8c9d420c1223a3f60e0eb.tar.gz talos-occ-52da94bc4351afea3eb8c9d420c1223a3f60e0eb.zip |
Implement busy wait and remove TOD access
1. Implement busy_wait() as an alternative to pk_sleep when APSS code runs
in interrupt handlers.
2. Remove the TOD scom register access from the code, since it is not
supported in simics yet.
3. Modify the calls to putscom_abs to take in register values rather
than a pointer to register values, to be compatible with the new
putscom code.
4. Eliminate code that endlessly triggers OCC and other GPEs, and
add instead a counter with the number of ticks (250 usec)
since last reset.
Change-Id: I48414137434dfdc3cc4c038643536c1250fccbf2
RTC: 131177
RTC: 139105
RTC: 137703
Reviewed-on: http://gfw160.aus.stglabs.ibm.com:8080/gerrit/21269
Tested-by: FSP CI Jenkins
Reviewed-by: William A. Bryan <wilbryan@us.ibm.com>
Reviewed-by: Fadi Kassem <fmkassem@us.ibm.com>
Diffstat (limited to 'src/occ_gpe0/gpe0_main.c')
-rw-r--r-- | src/occ_gpe0/gpe0_main.c | 108 |
1 files changed, 7 insertions, 101 deletions
diff --git a/src/occ_gpe0/gpe0_main.c b/src/occ_gpe0/gpe0_main.c index ada93fa..2777a70 100644 --- a/src/occ_gpe0/gpe0_main.c +++ b/src/occ_gpe0/gpe0_main.c @@ -51,110 +51,15 @@ IPC_MSGQ_CREATE(G_gpe0_test_msgq0); IPC_MSGQ_MSG_CREATE(G_test_msg, IPC_ST_TEST_FUNC0, &G_gpe0_test_msgq0); -// Continuously ping each OCC instance +// Main thread of execution. Currently does nothing void main_thread(void* arg) { - uint8_t instance; - int rc; - int func_id; - ipc_msg_t *test_msg; + volatile uint64_t t_ticks = 0; - PK_TRACE("thread started"); - - PK_TRACE("Waiting for ping response from all instances"); - for(instance = 0; instance < OCCHW_MAX_INSTANCES; instance++) - { - // Wait for each instance (including self) to start accepting IPC commands - do - { - pk_sleep(PK_MILLISECONDS(10)); - rc = ipc_ping(&G_ping_cmd, instance); - }while(rc == IPC_RC_TARGET_BLOCKED); - - if(rc && rc != IPC_RC_TARGET_BLOCKED) - { - PK_TRACE("phase 1 ipc_ping(%u) failed with rc = 0x%08x", instance, rc); - PK_TRACE_BIN("G_ping_cmd:", &G_ping_cmd, sizeof(G_ping_cmd)); - pk_halt(); - } - PK_TRACE("Ping response received from instance(%d)", instance); - } - - PK_TRACE("Starting infinite loop test"); while(1) { - for(instance = 0; instance < OCCHW_MAX_INSTANCES; instance++) - { - // Ping each instance (including ourself) - rc = ipc_ping(&G_ping_cmd, instance); - if(rc) - { - PK_TRACE("phase 2 ipc_ping(%u) failed with rc = 0x%08x", instance, rc); - PK_TRACE_BIN("G_ping_cmd:", &G_ping_cmd, sizeof(G_ping_cmd)); - pk_halt(); - } - } - - // Send an IPC_ST_TEST_FUNC0 message (to ourselves) if the message - // isnt' already in-flight. - if(ipc_is_free(&G_test_msg)) - { - rc = ipc_send_cmd(&G_test_msg); - if(rc) - { - pk_halt(); - } - } - - // wait for a IPC_ST_TEST_FUNC0 command or response message to arrive - rc = ipc_msgq_recv(&test_msg, &G_gpe0_test_msgq0, PK_MILLISECONDS(1)); - if(!rc) - { - //verify that the command message type is what we expected - func_id = ipc_get_funcid(test_msg); - if(func_id != IPC_ST_TEST_FUNC0) - { - //unexpected func id - //(probably caused by a mismatch between function table - // and function id ordering) - rc = ipc_send_rsp(test_msg, IPC_RC_CMD_NOT_SUPPORTED); - } - else - { - //Is this a response to the message we sent to ourselves? - if(ipc_is_a_response(test_msg)) - { - //check that the remote end was successful - if(ipc_get_rc(test_msg) != IPC_RC_SUCCESS) - { - pk_halt(); - } - //free up the message for sending again - ipc_free_msg(test_msg); - } - else - { - //successfully recieved the command message. - //Send a response message back. - rc = ipc_send_rsp(test_msg, IPC_RC_SUCCESS); - } - } - if(rc) - { - //failed to send the response back - pk_halt(); - } - } - else - { - //Unless it's a timeout, a non-zero rc is an error - if(rc != IPC_RC_TIMEOUT) - { - //Failure encountered while waiting for a new message - pk_halt(); - } - } - pk_sleep(PK_MILLISECONDS(1)); + pk_sleep(PK_MICROSECONDS(250)); + t_ticks++; } } @@ -188,8 +93,9 @@ int main(int argc, char **argv) pk_halt(); } + //Initialize the thread control block for G_main_thread - pk_thread_create(&G_main_thread, + pk_thread_create(&G_main_thread, (PkThreadRoutine)main_thread, (void*)NULL, (PkAddress)G_main_thread_stack, @@ -206,6 +112,6 @@ int main(int argc, char **argv) // Start running the highest priority thread. // This function never returns pk_start_threads(); - + return 0; } |