index 0359382c5f0dfab823d9e0606f5475fe562362a4..b101c62debfcb633c7f50c52691e41eb496b8a3b 100644 (file)
#include <ti/ipc/mm/MmRpc.h>
+
+/* module 'Mx' functions */
+int Mx_initialize(void);
+void Mx_finalize(void);
+
+int32_t Mx_triple(uint32_t a);
+int32_t Mx_add(int32_t a, int32_t b);
+
+MmRpc_Handle Mx_rpcDsp = NULL;
+
+/* static function indicies */
+#define Mx_Fxn_triple (0x80000000 | 1)
+#define Mx_Fxn_add (0x80000000 | 2)
+
+
+/*
+ * ======== main ========
+ */
int main(int argc, char **argv)
{
- MmRpc_Params params;
- MmRpc_Handle dsp_rpc;
+ int status;
+ int32_t ret;
- printf("Hello world\n");
+ printf("mmrpc_test: --> main\n");
- MmRpc_Params_init(¶ms);
+ /* initialize Mx module (setup rpc connection) */
+ status = Mx_initialize();
+
+ if (status < 0) {
+ goto leave;
+ }
+
+ /* invoke Mx functions */
+ ret = Mx_triple(11);
+ printf("mmrpc_test: Mx_triple(11), ret=%d\n", ret);
+
+ if (ret < 0) {
+ status = -1;
+ goto leave;
+ }
- dsp_rpc = MmRpc_create("DSP", "FooServer", ¶ms);
+ ret = Mx_triple(111);
+ printf("mmrpc_test: Mx_triple(111), ret=%d\n", ret);
- MmRpc_delete(&dsp_rpc);
+ if (ret < 0) {
+ status = -1;
+ goto leave;
+ }
+ ret = Mx_add(44, 66);
+ printf("mmrpc_test: Mx_add(44, 66), ret=%d\n", ret);
+
+ if (ret < 0) {
+ status = -1;
+ goto leave;
+ }
+
+leave:
+ /* finalize Mx module (destroy rpc connection) */
+ Mx_finalize();
+
+ if (status < 0) {
+ printf("mmrpc_test: FAILED\n");
+ }
+ else {
+ printf("mmrpc_test: PASSED\n");
+ }
return(0);
}
+
+/*
+ * ======== Mx_initialize ========
+ */
+int Mx_initialize(void)
+{
+ int status;
+ MmRpc_Params params;
+
+ /* create remote server insance */
+ MmRpc_Params_init(¶ms);
+
+ status = MmRpc_create("DSP", "FooServer", ¶ms, &Mx_rpcDsp);
+
+ if (status < 0) {
+ printf("mmrpc_test: Error: MmRpc_create failed\n");
+ status = -1;
+ }
+ else {
+ status = 0;
+ }
+
+ return(status);
+}
+
+/*
+ * ======== Mx_finalize ========
+ */
+void Mx_finalize(void)
+{
+ /* delete remote server instance */
+ if (Mx_rpcDsp != NULL) {
+ MmRpc_delete(&Mx_rpcDsp);
+ }
+}
+
+/*
+ * ======== Mx_triple ========
+ */
+int32_t Mx_triple(uint32_t a)
+{
+ MmRpc_FxnCtx *fxnCtx;
+ int32_t fxnRet;
+ char send_buf[512] = {0};
+ int status;
+
+ /* marshall function arguments into the send buffer */
+ fxnCtx = (MmRpc_FxnCtx *)send_buf;
+
+ fxnCtx->fxn_id = Mx_Fxn_triple;
+ fxnCtx->num_params = 1;
+ fxnCtx->params[0].type = MmRpc_ParamType_Atomic;
+ fxnCtx->params[0].param.atomic.size = sizeof(int);
+ fxnCtx->params[0].param.atomic.data = a;
+ fxnCtx->num_translations = 0;
+
+ /* invoke the remote function call */
+ status = MmRpc_call(Mx_rpcDsp, fxnCtx, &fxnRet);
+
+ if (status < 0) {
+ printf("mmrpc_test: Error: MmRpc_call failed\n");
+ fxnRet = -1;
+ }
+
+ return(fxnRet);
+}
+
+/*
+ * ======== Mx_add ========
+ */
+int32_t Mx_add(int32_t a, int32_t b)
+{
+ MmRpc_FxnCtx *fxnCtx;
+ int32_t fxnRet;
+ char send_buf[512] = {0};
+ int status;
+
+ /* marshall function arguments into the send buffer */
+ fxnCtx = (MmRpc_FxnCtx *)send_buf;
+
+ fxnCtx->fxn_id = Mx_Fxn_add;
+ fxnCtx->num_params = 2;
+ fxnCtx->params[0].type = MmRpc_ParamType_Atomic;
+ fxnCtx->params[0].param.atomic.size = sizeof(int);
+ fxnCtx->params[0].param.atomic.data = a;
+ fxnCtx->params[1].type = MmRpc_ParamType_Atomic;
+ fxnCtx->params[1].param.atomic.size = sizeof(int);
+ fxnCtx->params[1].param.atomic.data = b;
+ fxnCtx->num_translations = 0;
+
+ /* invoke the remote function call */
+ status = MmRpc_call(Mx_rpcDsp, fxnCtx, &fxnRet);
+
+ if (status < 0) {
+ printf("mmrpc_test: Error: MmRpc_call failed\n");
+ fxnRet = -1;
+ }
+
+ return(fxnRet);
+}