Skip to content

Commit 6310b46

Browse files
committed
work was done over apipc_app() and over apipc_startup_remote() to make
objects initialization more deterministic. cpu1 will transmit objects marked as startup and then notify through ipcflags to apipc on core2 to let it transmit objects also marked as startup. Messages processing is available as soon as the apipc_app() start being called.
1 parent 845fde8 commit 6310b46

File tree

3 files changed

+34
-76
lines changed

3 files changed

+34
-76
lines changed

include/ipc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ enum apipc_rc apipc_flags_clear_bits(uint16_t obj_idx, uint32_t bmask);
6464

6565

6666
/**
67-
* @fn apipc_startup_config
67+
* @fn apipc_startup_remote
6868
*
6969
* @brief Start a comunication over IPC API
7070
*/
71-
enum apipc_rc apipc_startup_config(void);
71+
enum apipc_rc apipc_startup_remote(void);
7272

7373
/**
7474
* @fn apipc_app

include/ipc_defs.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,23 +60,11 @@
6060
enum apipc_sm
6161
{
6262
APIPC_SM_UNKNOWN = 0,
63-
APIPC_SM_INIT,
63+
APIPC_SM_STARTUP_REMOTE,
6464
APIPC_SM_IDLE,
65-
APIPC_SM_STARTUP_REMOTE_CONFIG,
66-
APIPC_SM_READING,
67-
APIPC_SM_WRITING,
68-
APIPC_SM_WAITTING_RESPONSE,
6965
APIPC_SM_STARTED
7066
};
7167

72-
enum apipc_startup_sm
73-
{
74-
APIPC_SU_SM_UNKNOWN = 0,
75-
APIPC_SU_SM_INIT,
76-
APIPC_SU_SM_STARTING,
77-
APIPC_SU_SM_FINISHED,
78-
};
79-
8068
enum apipc_obj_sm
8169
{
8270
APIPC_OBJ_SM_UNKNOWN = 0,
@@ -115,7 +103,7 @@ enum apipc_flags
115103
{
116104
APIPC_FLAG_API_INITED = IPC_FLAG4, /* Local API implementation is inited */
117105
APIPC_FLAG_SRAM_ACCES = IPC_FLAG5, /* Local (CPU1) granted GSMEM acces to CPU2 */
118-
106+
APIPC_FLAG_APP_START = IPC_FLAG6, /* apipc_app started! */
119107

120108
IPC_FLAG_L_R_ADDR = IPC_FLAG19,
121109
IPC_FLAG_BLOCK_RECEIVED = IPC_FLAG21,

src/ipc.c

Lines changed: 30 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,7 @@ static void apipc_message_handler (tIpcMessage *psMessage)
506506
switch(ulCommand)
507507
{
508508
case APIPC_MSG_CMD_FUNC_CALL_RSP:
509+
pusRAddress = probj->paddr;
509510
break;
510511

511512
case APIPC_MSG_CMD_SET_BITS_RSP:
@@ -550,89 +551,58 @@ void apipc_app(void)
550551
static enum apipc_sm apipc_app_sm = APIPC_SM_UNKNOWN;
551552

552553
static struct apipc_obj *plobj;
553-
static uint16_t obj_idx;
554+
uint16_t obj_idx;
555+
556+
plobj = l_apipc_obj;
557+
558+
apipc_process_messages();
554559

555560
switch(apipc_app_sm)
556561
{
557562
case APIPC_SM_UNKNOWN:
558563
if(IPCRtoLFlagBusy(APIPC_FLAG_API_INITED) && IPCLtoRFlagBusy(APIPC_FLAG_API_INITED))
559-
{
560-
plobj = l_apipc_obj;
561-
obj_idx = 0;
562-
apipc_app_sm = APIPC_SM_STARTED;
563-
}
564-
break;
565-
566-
case APIPC_SM_IDLE:
564+
#if defined( CPU2)
565+
if(IPCRtoLFlagBusy(APIPC_FLAG_APP_START))
566+
#endif
567+
apipc_app_sm = APIPC_SM_STARTUP_REMOTE;
567568
break;
568569

569-
case APIPC_SM_STARTUP_REMOTE_CONFIG:
570-
if(!apipc_startup_config())
570+
case APIPC_SM_STARTUP_REMOTE:
571+
if(!apipc_startup_remote())
572+
{
571573
apipc_app_sm = APIPC_SM_STARTED;
574+
IPCLtoRFlagSet(APIPC_FLAG_APP_START);
575+
}
572576
break;
573577

574578
case APIPC_SM_STARTED:
575-
apipc_process_messages();
576-
apipc_proc_obj(plobj++);
577579

578-
if(++obj_idx >= APIPC_MAX_OBJ)
579-
{
580-
plobj = l_apipc_obj;
581-
obj_idx = 0;
582-
}
580+
for(obj_idx = 0; obj_idx < APIPC_MAX_OBJ; obj_idx++, plobj++)
581+
apipc_proc_obj(plobj);
583582

584583
break;
584+
585+
case APIPC_SM_IDLE:
586+
break;
585587
}
586588

587589
}
588590

589-
enum apipc_rc apipc_startup_config(void)
591+
enum apipc_rc apipc_startup_remote(void)
590592
{
591-
static enum apipc_rc rc;
592-
static enum apipc_startup_sm apipc_startup_sm = APIPC_SU_SM_UNKNOWN;
593-
static struct apipc_obj *plobj;
594-
595-
static uint16_t obj_idx;
596-
static uint16_t startup_finished = 0;
593+
enum apipc_rc rc;
594+
struct apipc_obj *plobj;
595+
uint16_t obj_idx;
597596

597+
plobj = l_apipc_obj;
598+
rc = APIPC_RC_SUCCESS;
598599

599-
switch(apipc_startup_sm)
600+
for(obj_idx = 0; obj_idx < APIPC_MAX_OBJ; obj_idx++, plobj++)
600601
{
601-
case APIPC_SU_SM_UNKNOWN:
602-
apipc_startup_sm = APIPC_SU_SM_INIT;
603-
604-
case APIPC_SU_SM_INIT:
605-
606-
rc = APIPC_RC_FAIL;
607-
startup_finished = 1;
608-
plobj = l_apipc_obj;
609-
obj_idx = 0;
610-
apipc_startup_sm = APIPC_SU_SM_STARTING;
611-
break;
612-
613-
case APIPC_SU_SM_STARTING:
614-
615-
apipc_proc_obj(plobj);
616-
617-
if(plobj->obj_sm != APIPC_OBJ_SM_FREE && plobj->obj_sm != APIPC_OBJ_SM_IDLE)
618-
startup_finished = 0;
619-
620-
plobj++;
621-
obj_idx++;
622-
623-
if(obj_idx >= APIPC_MAX_OBJ)
624-
{
625-
if(startup_finished)
626-
apipc_startup_sm = APIPC_SU_SM_FINISHED;
627-
else
628-
apipc_startup_sm = APIPC_SU_SM_INIT;
629-
}
630-
break;
631-
632-
case APIPC_SU_SM_FINISHED:
633-
rc = APIPC_RC_SUCCESS;
634-
break;
602+
apipc_proc_obj(plobj);
635603

604+
if(plobj->obj_sm != APIPC_OBJ_SM_FREE && plobj->obj_sm != APIPC_OBJ_SM_IDLE)
605+
rc = APIPC_RC_FAIL;
636606
}
637607

638608
return rc;

0 commit comments

Comments
 (0)