summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 5411870)
raw | patch | inline | side by side (parent: 5411870)
author | G Anthony <a0783926@ti.com> | |
Fri, 1 Mar 2013 18:19:04 +0000 (10:19 -0800) | ||
committer | G Anthony <a0783926@ti.com> | |
Fri, 1 Mar 2013 18:19:04 +0000 (10:19 -0800) |
This is required by the test_omx sample for OMAP5.
Pulled from omapzoom.org, sysbios-rpmsg, master branch, tag: 2.00.11.31.
Signed-off-by: G Anthony <a0783926@ti.com>
Pulled from omapzoom.org, sysbios-rpmsg, master branch, tag: 2.00.11.31.
Signed-off-by: G Anthony <a0783926@ti.com>
14 files changed:
.gitignore | patch | blob | history | |
packages/ti/srvmgr/ServiceMgr.c | [new file with mode: 0644] | patch | blob |
packages/ti/srvmgr/ServiceMgr.h | [new file with mode: 0644] | patch | blob |
packages/ti/srvmgr/omx/OmxSrvMgr.c | [new file with mode: 0644] | patch | blob |
packages/ti/srvmgr/omx/OmxSrvMgr.xdc | [new file with mode: 0644] | patch | blob |
packages/ti/srvmgr/omx/OmxSrvMgr.xs | [new file with mode: 0644] | patch | blob |
packages/ti/srvmgr/omx/package.bld | [new file with mode: 0644] | patch | blob |
packages/ti/srvmgr/omx/package.xdc | [new file with mode: 0644] | patch | blob |
packages/ti/srvmgr/omx/package.xs | [new file with mode: 0644] | patch | blob |
packages/ti/srvmgr/omx_packet.h | [new file with mode: 0644] | patch | blob |
packages/ti/srvmgr/package.bld | [new file with mode: 0644] | patch | blob |
packages/ti/srvmgr/package.xdc | [new file with mode: 0644] | patch | blob |
packages/ti/srvmgr/package.xs | [new file with mode: 0644] | patch | blob |
packages/ti/srvmgr/rpmsg_omx.h | [new file with mode: 0644] | patch | blob |
diff --git a/.gitignore b/.gitignore
index cfc9e02ba09696b8fc09b7a6c2945d827e417287..b81da08d2aa90e93b55ad76b7a3726fc3758a199 100644 (file)
--- a/.gitignore
+++ b/.gitignore
packages/ti/ipc/transports/TransportVirtioSetup.h
packages/ti/trace/SysMin.h
packages/ti/resources/IpcMemory.h
+packages/ti/srvmgr/omx/OmxSrvMgr.h
# Linux stuff
/autom4te.cache
diff --git a/packages/ti/srvmgr/ServiceMgr.c b/packages/ti/srvmgr/ServiceMgr.c
--- /dev/null
@@ -0,0 +1,363 @@
+/*
+ * Copyright (c) 2011-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * ======== ServiceMgr.c ========
+ * Simple server that handles requests to create threads (services) by name
+ * and provide an endpoint to the new thread.
+ *
+ */
+
+#include <xdc/std.h>
+#include <xdc/cfg/global.h>
+#include <xdc/runtime/System.h>
+
+#include <ti/sysbios/knl/Task.h>
+
+#include <ti/grcm/RcmTypes.h>
+#include <ti/grcm/RcmServer.h>
+
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+
+#include <ti/ipc/rpmsg/MessageQCopy.h>
+#include <ti/ipc/rpmsg/NameMap.h>
+#include "rpmsg_omx.h"
+#include "ServiceMgr.h"
+
+#define MAX_NAMELEN 64
+
+/* This artificially limits the number of service instances on this core: */
+#define MAX_TUPLES 256
+#define FREE_TUPLE_KEY 0xFFFFFFFF
+
+#define MAX_SERVICES 4
+
+/* ServiceMgr disconnect hook function */
+static ServiceMgr_disconnectFuncPtr ServiceMgr_disconnectUserFxn = NULL;
+
+struct ServiceDef {
+ Char name[MAX_NAMELEN];
+ RcmServer_Params rcmServerParams;
+ Bool taken;
+};
+
+struct ServiceDef serviceDefs[ServiceMgr_NUMSERVICETYPES];
+
+struct Tuple {
+ UInt32 key;
+ UInt32 value;
+};
+struct Tuple Tuples[MAX_TUPLES];
+
+typedef struct {
+ Task_FuncPtr fxn;
+ Char name[MAX_NAMELEN];
+ Task_Params params;
+ UInt16 reserved;
+ Bool taken;
+} ServiceMgr_ServiceTask;
+
+static ServiceMgr_ServiceTask serviceTasks[MAX_SERVICES];
+
+
+Void ServiceMgr_init()
+{
+ static Int curInit = 0;
+ UInt i;
+
+ if (curInit++ != 0) {
+ return; /* module already initialized */
+ }
+
+ RcmServer_init();
+
+ for (i = 0; i < ServiceMgr_NUMSERVICETYPES; i++) {
+ serviceDefs[i].taken = FALSE;
+ }
+
+ for (i = 0; i < MAX_TUPLES; i++) {
+ Tuples[i].key = FREE_TUPLE_KEY;
+ }
+
+ for (i = 0; i < MAX_SERVICES; i++) {
+ serviceTasks[i].taken = FALSE;
+ serviceTasks[i].fxn = NULL;
+ serviceTasks[i].reserved = (UInt16) -1;
+ }
+}
+
+UInt ServiceMgr_start(UInt16 reserved)
+{
+ UInt i;
+ UInt count = 0;
+ static Bool started = FALSE;
+
+ if (started) {
+ return 0;
+ }
+
+ for (i = 0; (i < MAX_SERVICES) && (serviceTasks[i].taken); i++) {
+ Task_create(serviceTasks[i].fxn, &serviceTasks[i].params, NULL);
+ count++;
+ }
+
+ return (count);
+}
+
+Bool ServiceMgr_registerSrvTask(UInt16 reserved, Task_FuncPtr func,
+ Task_Params *taskParams)
+{
+ UInt i;
+ Bool found = FALSE;
+ ServiceMgr_ServiceTask *st;
+ Task_Params *params;
+
+ /* Search the array for a free slot */
+ for (i = 0; (i < MAX_SERVICES) && (found == FALSE); i++) {
+ if (!serviceTasks[i].taken) {
+ st = &serviceTasks[i];
+ st->fxn = func;
+ strcpy(st->name, taskParams->instance->name);
+
+ /* Deal with the Task_Params to avoid IInstance mismatch */
+ params = &st->params;
+ Task_Params_init(params);
+ memcpy((Void *)(¶ms->arg0), &taskParams->arg0,
+ sizeof(*params) - sizeof(Void *));
+ params->instance->name = st->name;
+
+ st->reserved = reserved;
+ st->taken = TRUE;
+ found = TRUE;
+ break;
+ }
+ }
+
+ return (found);
+}
+
+Bool ServiceMgr_register(String name, RcmServer_Params *rcmServerParams)
+{
+ UInt i;
+ Bool found = FALSE;
+ struct ServiceDef *sd;
+
+ if (strlen(name) >= MAX_NAMELEN) {
+ System_printf("ServiceMgr_register: service name longer than %d\n",
+ MAX_NAMELEN );
+ }
+ else {
+ /* Search the array for a free slot */
+ for (i = 0; (i < ServiceMgr_NUMSERVICETYPES) && (found == FALSE); i++) {
+ if (!serviceDefs[i].taken) {
+ sd = &serviceDefs[i];
+ strcpy(sd->name, name);
+ sd->rcmServerParams = *rcmServerParams;
+ sd->taken = TRUE;
+ found = TRUE;
+ break;
+ }
+ }
+ }
+
+ return(found);
+}
+
+Void ServiceMgr_send(Service_Handle srvc, Ptr data, UInt16 len)
+{
+ UInt32 local;
+ UInt32 remote;
+ struct omx_msg_hdr * hdr = (struct omx_msg_hdr *)data;
+ UInt16 dstProc;
+
+ /* Get reply endpoint and local address for sending: */
+ remote = RcmServer_getRemoteAddress(srvc);
+ dstProc = RcmServer_getRemoteProc(srvc);
+ local = RcmServer_getLocalAddress(srvc);
+
+ /* Set special rpmsg_omx header so Linux side can strip it off: */
+ hdr->type = OMX_RAW_MSG;
+ hdr->len = len;
+ hdr->flags = 0;
+
+ /* Send it off (and no response expected): */
+ MessageQCopy_send(dstProc, remote, local, data, HDRSIZE+len);
+}
+
+Bool ServiceMgr_registerDisconnectFxn(Service_Handle srvc, Ptr data,
+ ServiceMgr_disconnectFuncPtr func)
+{
+ if (func == NULL) {
+ System_printf("ServiceMgr_registerDisconnectFxn: Invalid function.\n");
+ return FALSE;
+ }
+
+ /* Register the user-supplied function */
+ if (!ServiceMgr_disconnectUserFxn) {
+ ServiceMgr_disconnectUserFxn = func;
+ }
+ return TRUE;
+}
+
+/* Tuple store/retrieve fxns: */
+
+static Bool storeTuple(UInt32 key, UInt32 value)
+{
+ UInt i;
+ Bool stored = FALSE;
+
+ if (key == FREE_TUPLE_KEY) {
+ System_printf("storeTuple: reserved key %d\n", key);
+ }
+ else {
+ /* Search the array for a free slot: */
+ for (i = 0; (i < MAX_TUPLES) && (stored == FALSE); i++) {
+ if (Tuples[i].key == FREE_TUPLE_KEY) {
+ Tuples[i].key = key;
+ Tuples[i].value = value;
+ stored = TRUE;
+ break;
+ }
+ }
+ }
+
+ return(stored);
+}
+
+static Bool removeTuple(UInt32 key, UInt32 * value)
+{
+ UInt i;
+ Bool found = FALSE;
+
+ /* Search the array for tuple matching key: */
+ for (i = 0; (i < MAX_TUPLES) && (found == FALSE); i++) {
+ if (Tuples[i].key == key) {
+ found = TRUE;
+ *value = Tuples[i].value;
+ /* and free it... */
+ Tuples[i].value = 0;
+ Tuples[i].key = FREE_TUPLE_KEY;
+ break;
+ }
+ }
+
+ return(found);
+}
+
+UInt32 ServiceMgr_createService(Char * name, UInt32 * endpt)
+{
+ Int i;
+ Int status = 0;
+ struct ServiceDef *sd;
+ RcmServer_Handle rcmSrvHandle;
+
+ for (i = 0; i < ServiceMgr_NUMSERVICETYPES; i++) {
+ if (!strcmp(name, serviceDefs[i].name)) {
+ sd = &serviceDefs[i];
+ break;
+ }
+ }
+
+ if (i >= ServiceMgr_NUMSERVICETYPES) {
+ System_printf("createService: unrecognized service name: %s\n", name);
+ return OMX_NOTSUPP;
+ }
+
+ /* Create the RcmServer instance. */
+#if 0
+ System_printf("createService: Calling RcmServer_create with name = %s\n"
+ "priority = %d\n"
+ "osPriority = %d\n"
+ "rcmServerParams.fxns.length = %d\n",
+ sd->name, sd->rcmServerParams.priority,
+ sd->rcmServerParams.osPriority,
+ sd->rcmServerParams.fxns.length);
+#endif
+ status = RcmServer_create(sd->name, &sd->rcmServerParams, &rcmSrvHandle);
+
+ if (status < 0) {
+ System_printf("createService: RcmServer_create() returned error %d\n",
+ status);
+ return OMX_FAIL;
+ }
+
+ /* Get endpoint allowing clients to send messages to this new server: */
+ *endpt = RcmServer_getLocalAddress(rcmSrvHandle);
+
+ /* Store Server's endpoint with handle so we can cleanup on disconnect: */
+ if (!storeTuple(*endpt, (UInt32)rcmSrvHandle)) {
+ System_printf("createService: Limit reached on max instances!\n");
+ RcmServer_delete(&rcmSrvHandle);
+ return OMX_FAIL;
+ }
+
+ /* start the server */
+ RcmServer_start(rcmSrvHandle);
+
+ System_printf("createService: new OMX Service at endpoint: %d\n", *endpt);
+
+ return OMX_SUCCESS;
+}
+
+
+UInt32 ServiceMgr_deleteService(UInt32 addr)
+{
+ Int status = 0;
+ RcmServer_Handle rcmSrvHandle;
+
+ if (!removeTuple(addr, (UInt32 *)&rcmSrvHandle)) {
+ System_printf("deleteService: could not find service instance at"
+ " address: 0x%x\n", addr);
+ return OMX_FAIL;
+ }
+
+ /* Notify a ServiceMgr client of disconnection.
+ * rcmSrvHandle is same as the ServiceMgr handle
+ */
+ if (ServiceMgr_disconnectUserFxn) {
+ /* Pass NULL data for the moment */
+ ServiceMgr_disconnectUserFxn(rcmSrvHandle, NULL);
+ }
+
+ /* Destroy the RcmServer instance. */
+ status = RcmServer_delete(&rcmSrvHandle);
+ if (status < 0) {
+ System_printf("deleteService: RcmServer_delete() returned error %d\n",
+ status);
+ return OMX_FAIL;
+ }
+
+ System_printf("deleteService: removed RcmServer at endpoint: %d\n", addr);
+
+ return OMX_SUCCESS;
+}
diff --git a/packages/ti/srvmgr/ServiceMgr.h b/packages/ti/srvmgr/ServiceMgr.h
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * Copyright (c) 2011-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * ======== service_mgr.c ========
+ * Simple server that handles requests to create threads (services) by name
+ * and provide an endpoint to the new thread.
+ *
+ */
+
+#ifndef ti_srvmgr_ServiceMgr__include
+#define ti_srvmgr_ServiceMgr__include
+
+#include <xdc/std.h>
+
+#include <ti/sysbios/knl/Task.h>
+#include <ti/grcm/RcmServer.h>
+
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+
+/* Max number of known service types: */
+#define ServiceMgr_NUMSERVICETYPES 16
+
+/*!
+ * @brief Service instance object handle
+ */
+typedef RcmServer_Handle Service_Handle;
+
+/*!
+ * @brief Service disconnect notifier hook function type definition
+ */
+typedef Void (*ServiceMgr_disconnectFuncPtr)(Service_Handle srvc, Ptr data);
+
+/*
+ * ======== ServiceMgr_init ========
+ */
+/*!
+ * @brief Initialize the ServiceMgr.
+ *
+ * Currently, this simply initializes the RcmServer module.a
+ *
+ */
+Void ServiceMgr_init();
+
+/*
+ * ======== ServiceMgr_registerSrvTask ========
+ */
+/*!
+ * @brief Register a task associated with a service
+ *
+ * This function registers a service task function with the ServiceMgr module.
+ * This allows the service tasks to be outside the scope of the ServiceMgr
+ * module, and allow users to define their own services with its associated
+ * task function. After all the registrations are done, a ServiceMgr_start
+ * would start these tasks.
+ *
+ * @param[in] reserved Reserved for future scalability
+ * @param[in] func Task function to run for a particular service task
+ * @param[in] taskParams Initialized task parameters that will be used to
+ * create the task
+ *
+ * @sa ServiceMgr_start
+ */
+Bool ServiceMgr_registerSrvTask(UInt16 reserved, Task_FuncPtr func,
+ Task_Params *taskParams);
+
+/*
+ * ======== ServiceMgr_start ========
+ */
+/*!
+ * @brief Start the ServiceMgr services
+ *
+ * This function creates all the task functions associated with the individual
+ * services. Each of the tasks is responsible for publishing a service to the
+ * remote processor and service all the incoming connection requests on that
+ * service.
+ *
+ * @param[in] reserved Reserved for future scalability
+ *
+ * @sa ServiceMgr_registerTask
+ */
+UInt ServiceMgr_start(UInt16 reserved);
+
+/*
+ * ======== ServiceMgr_register ========
+ */
+/*!
+ * @brief Register a service with its static function table.
+ *
+ * This function stores the RcmServerParams structure with the name key, which
+ * the ServiceMgr will find on a subsequent connect call to instantiate an
+ * RcmServer of this name.
+ *
+ * @param[in] name The name of the server that messages will be sent to for
+ * executing commands. The name must be a system-wide unique name.
+ *
+ * @param[in] rcmServerParams The RcmServer_create params used to initialize
+ * the service instance.
+ *
+ * @sa RcmServer_create
+ */
+Bool ServiceMgr_register(String name, RcmServer_Params *rcmServerParams);
+
+/*
+ * ======== ServiceMgr_send ========
+ */
+/*!
+ * @brief Send an asynchrounous message to a service's client endpoint.
+ *
+ * This function uses the reply endpoint registered with the given service
+ * by the ServiceMgr, to send a message to the client. It is meant to
+ * be used for asynchronous callbacks from service functions, where the
+ * callbacks do not expect a reply (hence, no ServiceMgr_recv is defined).
+ *
+ * @param[in] srvc Handle to a service, passed into every service function.
+ * @param[in] data Data payload to be copied and sent. First structure
+ * must be an omx_hdr
+ * @param[in] len Amount of data to be copied.
+ *
+ */
+Void ServiceMgr_send(Service_Handle srvc, Ptr data, UInt16 len);
+
+/*
+ * ======== ServiceMgr_registerdisconnectFxn =======
+ */
+/*!
+ * @brief Registers a application-specific service disconnect callback function
+ *
+ * @param[in] srvc Handle to a service, passed into every service
+ * function
+ * @param[in] data Pointer to application-specific data passed back
+ * to the disconnect hook function
+ * @param[in] func Hook function to be called on a service disconnect
+ *
+ */
+Bool ServiceMgr_registerDisconnectFxn(Service_Handle srvc, Ptr data,
+ ServiceMgr_disconnectFuncPtr func);
+
+/*
+ * ======== ServiceMgr_createService =======
+ */
+/*!
+ * @brief Create a RCM Server instance associated with a service
+ *
+ * Create a RCM server instance using the set of functions associated with the
+ * name, and returns an end point address registered for the service.
+ *
+ * @param[in] name Name associated with RCM function set
+ * @param[in] endPt Endpoint pointer address
+ *
+ */
+UInt32 ServiceMgr_createService(Char * name, UInt32 * endPt);
+
+/*
+ * ======== ServiceMgr_deleteService =======
+ */
+/*!
+ * @brief Delete the RCM Server instance associated with an endpoint address
+ *
+ * Deletes the RCM Servver instance associated with a particular endpoint
+ * address.
+ *
+ * @param[in] addr EndPoint pointer address associated with the
+ * service to delete.
+ *
+ */
+UInt32 ServiceMgr_deleteService(UInt32 addr);
+
+
+#if defined (__cplusplus)
+}
+#endif /* defined (__cplusplus) */
+
+#endif /* ti_srvmgr_ServiceMgr__include */
diff --git a/packages/ti/srvmgr/omx/OmxSrvMgr.c b/packages/ti/srvmgr/omx/OmxSrvMgr.c
--- /dev/null
@@ -0,0 +1,178 @@
+/*
+ * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * ======== OmxSrvMgr.c ========
+ *
+ * The primary task function that serves the incoming requests on the OMX
+ * Service.
+ */
+
+#include <xdc/std.h>
+#include <xdc/cfg/global.h>
+#include <xdc/runtime/System.h>
+#include <xdc/runtime/Startup.h>
+#include <xdc/runtime/Error.h>
+
+#include <ti/sysbios/knl/Task.h>
+
+#include <ti/ipc/MultiProc.h>
+
+#include <ti/ipc/rpmsg/MessageQCopy.h>
+/* TBD: ONLY WORKS FORM OMAP5 FOR NOW! */
+#include <ti/ipc/family/omap54xx/VirtQueue.h>
+#include <ti/ipc/rpmsg/NameMap.h>
+#include <ti/srvmgr/rpmsg_omx.h>
+#include <ti/srvmgr/ServiceMgr.h>
+
+#include "package/internal/OmxSrvMgr.xdc.h"
+
+/* Hard coded to match rpmsg-omx Host side driver */
+#define OMX_MGR_PORT 60
+
+Void OmxSrvMgr_taskFxn(UArg arg0, UArg arg1)
+{
+ MessageQCopy_Handle msgq;
+ UInt32 local;
+ UInt32 remote;
+ Char msg[HDRSIZE + sizeof(struct omx_connect_req)];
+ struct omx_msg_hdr * hdr = (struct omx_msg_hdr *)msg;
+ struct omx_connect_rsp * rsp = (struct omx_connect_rsp *)hdr->data;
+ struct omx_connect_req * req = (struct omx_connect_req *)hdr->data;
+ struct omx_disc_req * disc_req = (struct omx_disc_req *)hdr->data;
+ struct omx_disc_rsp * disc_rsp = (struct omx_disc_rsp *)hdr->data;
+ UInt16 dstProc;
+ UInt16 len;
+ UInt32 newAddr = 0;
+
+#ifdef BIOS_ONLY_TEST
+ dstProc = MultiProc_self();
+#else
+ dstProc = MultiProc_getId("HOST");
+#endif
+
+ msgq = MessageQCopy_create(OMX_MGR_PORT, NULL, NULL, &local);
+
+ System_printf("OmxSrvMgr: started on port: %d\n", OMX_MGR_PORT);
+
+#ifdef SMP
+ NameMap_register("rpmsg-omx1", OMX_MGR_PORT);
+ System_printf("OmxSrvMgr: Proc#%d sending BOOTINIT_DONE\n",
+ MultiProc_self());
+ VirtQueue_postInitDone();
+#else
+ if (MultiProc_self() == MultiProc_getId("CORE0")) {
+ NameMap_register("rpmsg-omx0", OMX_MGR_PORT);
+ }
+ if (MultiProc_self() == MultiProc_getId("CORE1")) {
+ NameMap_register("rpmsg-omx1", OMX_MGR_PORT);
+ }
+ if (MultiProc_self() == MultiProc_getId("DSP")) {
+ NameMap_register("rpmsg-omx2", OMX_MGR_PORT);
+ }
+
+ if ((MultiProc_self() == MultiProc_getId("CORE1")) ||
+ (MultiProc_self() == MultiProc_getId("DSP"))) {
+ System_printf("OmxSrvMgr: Proc#%d sending BOOTINIT_DONE\n",
+ MultiProc_self());
+ VirtQueue_postInitDone();
+ }
+#endif
+
+ while (1) {
+ MessageQCopy_recv(msgq, (Ptr)msg, &len, &remote, MessageQCopy_FOREVER);
+ System_printf("OmxSrvMgr: received msg type: %d from addr: %d\n",
+ hdr->type, remote);
+ switch (hdr->type) {
+ case OMX_CONN_REQ:
+ /* This is a request to create a new service, and return
+ * it's connection endpoint.
+ */
+ System_printf("OmxSrvMgr: CONN_REQ: len: %d, name: %s\n",
+ hdr->len, req->name);
+
+ rsp->status = ServiceMgr_createService(req->name, &newAddr);
+
+ hdr->type = OMX_CONN_RSP;
+ rsp->addr = newAddr;
+ hdr->len = sizeof(struct omx_connect_rsp);
+ len = HDRSIZE + hdr->len;
+ break;
+
+ case OMX_DISC_REQ:
+ /* Destroy the service instance at given service addr: */
+ System_printf("OmxSrvMgr: OMX_DISCONNECT: len %d, addr: %d\n",
+ hdr->len, disc_req->addr);
+
+ disc_rsp->status = ServiceMgr_deleteService(disc_req->addr);
+
+ /* currently, no response expected from rpmsg_omx: */
+ continue;
+#if 0 // rpmsg_omx is not listening for this ... yet.
+ hdr->type = OMX_DISC_RSP;
+ hdr->len = sizeof(struct omx_disc_rsp);
+ len = HDRSIZE + hdr->len;
+ break;
+#endif
+
+ default:
+ System_printf("unexpected msg type: %d\n", hdr->type);
+ hdr->type = OMX_NOTSUPP;
+ break;
+ }
+
+ System_printf("OmxSrvMgr: Replying with msg type: %d to addr: %d "
+ " from: %d\n",
+ hdr->type, remote, local);
+ MessageQCopy_send(dstProc, remote, local, msg, len);
+ }
+}
+
+Int OmxSrvMgr_Module_startup(Int phase)
+{
+ Task_Params params;
+
+ if (Task_Module_startupDone()) {
+ ServiceMgr_init();
+
+ /* Create our ServiceMgr Thread: */
+ Task_Params_init(¶ms);
+ params.instance->name = "OmxSrvMgr";
+ params.priority = 1; /* Lowest priority thread */
+
+ ServiceMgr_registerSrvTask(0, OmxSrvMgr_taskFxn, ¶ms);
+
+ return (Startup_DONE);
+ }
+ else {
+ return (Startup_NOTDONE);
+ }
+}
diff --git a/packages/ti/srvmgr/omx/OmxSrvMgr.xdc b/packages/ti/srvmgr/omx/OmxSrvMgr.xdc
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+
+/*
+ * ======== OmxSrvMgr.xdc ========
+ *
+ */
+
+package ti.srvmgr.omx;
+
+
+/*!
+ * ======== OmxSrvMgr ========
+ * OMX Service Manager Task module
+ *
+ * Minimal XDC module with only an internal function
+ */
+
+@ModuleStartup /* generate a call to OmxSrvMgr_Module_startup at startup */
+
+module OmxSrvMgr
+{
+internal: /* not for client use */
+
+ Void taskFxn(UArg arg0, UArg arg1);
+}
diff --git a/packages/ti/srvmgr/omx/OmxSrvMgr.xs b/packages/ti/srvmgr/omx/OmxSrvMgr.xs
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ======== OmxServerMgr.xs ========
+ *
+ */
+
+/*
+ * ======== module$use ========
+ * Use other modules required by this module
+ */
+function module$use()
+{
+ xdc.useModule('xdc.runtime.System');
+ xdc.useModule('xdc.runtime.Startup');
+
+ xdc.useModule('ti.sysbios.knl.Task');
+ xdc.useModule('ti.sdo.utils.MultiProc');
+
+ xdc.loadPackage('ti.srvmgr');
+}
diff --git a/packages/ti/srvmgr/omx/package.bld b/packages/ti/srvmgr/omx/package.bld
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+ * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ======== package.bld ========
+ *
+ */
+
+/* explicit references to global objects */
+var Build = xdc.useModule('xdc.bld.BuildEnvironment');
+var Pkg = xdc.useModule('xdc.bld.PackageContents');
+var smpBuild = java.lang.System.getenv("BUILD_SMP");
+
+/* clean lib folder */
+Pkg.generatedFiles.$add("lib/");
+Pkg.libDir = "package/";
+
+/* add custom files to all releases */
+Pkg.attrs.exportSrc = false;
+Pkg.attrs.exportCfg = true;
+
+/* list of libraries to build */
+var libArray = new Array();
+if (smpBuild == "1") {
+ /* omx srvmgr library for IPU SMP target */
+ libArray.push(
+ {
+ name: "ti.srvmgr.omx_smp",
+ sources: [
+ "OmxSrvMgr",
+ ],
+ libAttrs: {
+ defs: " -DSMP"
+ },
+ isas: [ "v7M" ],
+ }
+ );
+}
+else {
+ /* omx srvmgr library for regular targets */
+ libArray.push(
+ {
+ name: "ti.srvmgr.omx",
+ sources: [
+ "OmxSrvMgr",
+ ],
+ }
+ );
+}
+
+/* generate the package libraries */
+/* check if profile specified in XDCARGS */
+/* XDCARGS="... profile=debug ..." */
+var cmdlProf = (" " + arguments.join(" ") + " ").match(/ profile=([^ ]+) /);
+cmdlProf = cmdlProf != null ? cmdlProf[1] : null;
+
+/* ==== loop over array of libraries ==== */
+for (var i = 0; i < libArray.length; i++) {
+ var lib = libArray[i];
+
+ /* ==== loop over all targets in build array ==== */
+ for (var j = 0; j < Build.targets.length; j++) {
+ var targ = Build.targets[j];
+
+ /* skip target if not compatible with source code */
+ if ("icw" in lib) {
+ var skipTarget = true;
+ var targIsaChain = "/" + targ.getISAChain().join("/") + "/";
+ for (var k = 0; k < lib.icw.length; k++) {
+ if (targIsaChain.match("/" + lib.icw[k] + "/")) {
+ skipTarget = false;
+ break;
+ }
+ }
+ if (skipTarget) continue;
+ }
+
+ /* skip target if it does not generate code for the given isa */
+ if ("isas" in lib) {
+ var skipTarget = true;
+ var list = "/" + lib.isas.join("/") + "/";
+ if (list.match("/" + targ.isa + "/")) {
+ skipTarget = false;
+ }
+ if (skipTarget) continue;
+ }
+
+ /* ==== loop over all profiles ==== */
+ for (var profile in targ.profiles) {
+
+ /* skip profile if different than specified on command line */
+ if ((cmdlProf != null) && (profile != cmdlProf)) {
+ continue;
+ }
+
+ /* name = lib/profile/name.a+suffix */
+ var name = "lib/" + profile + "/" + lib.name;
+
+ /* pass along library attributes specified in library array */
+ var libAttrs = "libAttrs" in lib ? lib.libAttrs : {};
+
+ /* must set profile explicitly */
+ libAttrs.profile = profile;
+
+ /* build the library */
+ var library = Pkg.addLibrary(name, targ, libAttrs);
+
+ /* add the source files */
+ library.addObjects(lib.sources);
+ }
+ }
+}
diff --git a/packages/ti/srvmgr/omx/package.xdc b/packages/ti/srvmgr/omx/package.xdc
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ======== package.xdc ========
+ *
+ */
+
+/*!
+ * ======== ti.srvmgr.omx ========
+ * OMX Service Package
+ *
+ * The OMX Service package provides the service task implementation for the
+ * OMX service.
+ *
+ */
+
+package ti.srvmgr.omx [1,0,0] {
+ module OmxSrvMgr;
+}
diff --git a/packages/ti/srvmgr/omx/package.xs b/packages/ti/srvmgr/omx/package.xs
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ * Copyright (c) 2012-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ======== package.xs ========
+ *
+ */
+
+/*
+ * ======== getLibs ========
+ */
+function getLibs(prog)
+{
+ var suffix;
+ var file;
+ var libAry = [];
+ var profile = this.profile;
+ var smp = "";
+
+ suffix = prog.build.target.findSuffix(this);
+ if (suffix == null) {
+ return ""; /* nothing to contribute */
+ }
+
+ if (prog.platformName.match(/ipu/)) {
+ smp = "_smp";
+ }
+
+ /* make sure the library exists, else fallback to a built library */
+ file = "lib/" + profile + "/ti.srvmgr.omx" + smp + ".a" + suffix;
+ if (java.io.File(this.packageBase + file).exists()) {
+ libAry.push(file);
+ }
+ else {
+ file = "lib/release/ti.srvmgr.omx" + smp + ".a" + suffix;
+ if (java.io.File(this.packageBase + file).exists()) {
+ libAry.push(file);
+ }
+ else {
+ /* fallback to a compatible library built by this package */
+ for (var p in this.build.libDesc) {
+ if (suffix == this.build.libDesc[p].suffix) {
+ libAry.push(p);
+ break;
+ }
+ }
+ }
+ }
+
+ return libAry.join(";");
+}
diff --git a/packages/ti/srvmgr/omx_packet.h b/packages/ti/srvmgr/omx_packet.h
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (c) 2011-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * omx_packet.h
+ *
+ * This is the packet structure for messages to/from OMX servers created by the
+ * ServiceMgr on BIOS.
+ *
+ */
+
+#ifndef OMX_PACKET_H
+#define OMX_PACKET_H
+
+
+/*
+ * ======== OMX_Packet ========
+ *
+ * OMX_Packet.desc: the package descriptor field. Note that the
+ * format is different for out-bound and in-bound messages.
+ *
+ * out-bound message descriptor
+ *
+ * Bits Description
+ * --------------------------------------------------------------------
+ * [15:12] reserved
+ * [11:8] omx message type
+ * [7:0] omx client protocol version
+ *
+ *
+ * in-bound message descriptor
+ *
+ * Bits Description
+ * --------------------------------------------------------------------
+ * [15:12] reserved
+ * [11:8] omx server status code
+ * [7:0] omx server protocol version
+ */
+
+/* message type values */
+#define OMX_DESC_MSG 0x1 // exec sync command
+#define OMX_DESC_SYM_ADD 0x3 // symbol add message
+#define OMX_DESC_SYM_IDX 0x4 // query symbox index
+#define OMX_DESC_CMD 0x5 // exec non-blocking command.
+#define OMX_DESC_TYPE_MASK 0x0F00 // field mask
+#define OMX_DESC_TYPE_SHIFT 8 // field shift width
+
+/* omx server status codes must be 0 - 15, it has to fit in a 4-bit field */
+#define OMXSERVER_STATUS_SUCCESS ((uint16_t)0) // success
+#define OMXSERVER_STATUS_INVALID_FXN ((uint16_t)1) // invalid fxn index
+#define OMXSERVER_STATUS_SYMBOL_NOT_FOUND ((uint16_t)2) // symbol not found
+#define OMXSERVER_STATUS_INVALID_MSG_TYPE ((uint16_t)3) // invalid msg type
+#define OMXSERVER_STATUS_MSG_FXN_ERR ((uint16_t)4) // msg function error
+#define OMXSERVER_STATUS_ERROR ((uint16_t)5) // general failure
+#define OMXSERVER_STATUS_UNPROCESSED ((uint16_t)6) // unprocessed message
+
+/* the packet structure (actual message sent to omx service) */
+struct omx_packet {
+ UInt16 desc; // descriptor, and omx service status
+ UInt16 msg_id; // id, can be used to distinguish async replies.
+ UInt32 flags; // Set to a fixed value for now.
+ UInt32 fxn_idx; // Index into OMX service's fxn table.
+ Int32 result; // The OMX function's return value is here.
+ UInt32 data_size; // Set to max size of data in and out of the fxn.
+ UInt32 data[1]; // Payload of data_size char's passed to fxn.
+};
+
+/* define this here to remove size of data[1] field. */
+#define OMXPACKETSIZE (5 * sizeof(UInt32))
+
+#define OMX_POOLID_JOBID_NONE (0x00008000)
+#define OMX_INVALIDFXNIDX ((UInt32)(0xFFFFFFFF))
+
+#endif /* OMX_PACKET_H */
diff --git a/packages/ti/srvmgr/package.bld b/packages/ti/srvmgr/package.bld
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ * Copyright (c) 2011-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ======== package.bld ========
+ *
+ */
+
+/* explicit references to global objects */
+var Build = xdc.useModule('xdc.bld.BuildEnvironment');
+var Pkg = xdc.useModule('xdc.bld.PackageContents');
+var smpBuild = java.lang.System.getenv("BUILD_SMP");
+
+/* clean lib folder */
+Pkg.generatedFiles.$add("lib/");
+Pkg.libDir = "package/";
+
+/* add custom files to all releases */
+Pkg.attrs.exportSrc = false;
+Pkg.attrs.exportCfg = true;
+Pkg.otherFiles = [
+ "ServiceMgr.h",
+ "rpmsg_omx.h",
+ "omx_packet.h"
+];
+
+/* list of libraries to build */
+var libArray = new Array();
+if (smpBuild == "1") {
+ /* srvmgr library for IPU SMP target */
+ libArray.push(
+ {
+ name: "ti.srvmgr_smp",
+ sources: [
+ "ServiceMgr",
+ ],
+ libAttrs: {
+ defs: " -DSMP"
+ },
+ icw: [ "v7M" ],
+ }
+ );
+}
+else {
+ /* srvmgr library for regular targets */
+ libArray.push(
+ {
+ name: "ti.srvmgr",
+ sources: [
+ "ServiceMgr",
+ ],
+ }
+ );
+}
+
+/* generate the package libraries */
+/* check if profile specified in XDCARGS */
+/* XDCARGS="... profile=debug ..." */
+var cmdlProf = (" " + arguments.join(" ") + " ").match(/ profile=([^ ]+) /);
+cmdlProf = cmdlProf != null ? cmdlProf[1] : null;
+
+/* ==== loop over array of libraries ==== */
+for (var i = 0; i < libArray.length; i++) {
+ var lib = libArray[i];
+
+ /* ==== loop over all targets in build array ==== */
+ for (var j = 0; j < Build.targets.length; j++) {
+ var targ = Build.targets[j];
+
+ /* skip target if not compatible with source code */
+ if ("icw" in lib) {
+ var skipTarget = true;
+ var targIsaChain = "/" + targ.getISAChain().join("/") + "/";
+ for (var k = 0; k < lib.icw.length; k++) {
+ if (targIsaChain.match("/" + lib.icw[k] + "/")) {
+ skipTarget = false;
+ break;
+ }
+ }
+ if (skipTarget) continue;
+ }
+
+ /* skip target if it does not generate code for the given isa */
+ if ("isas" in lib) {
+ var skipTarget = true;
+ var list = "/" + lib.isas.join("/") + "/";
+ if (list.match("/" + targ.isa + "/")) {
+ skipTarget = false;
+ }
+ if (skipTarget) continue;
+ }
+
+ /* ==== loop over all profiles ==== */
+ for (var profile in targ.profiles) {
+
+ /* skip profile if different than specified on command line */
+ if ((cmdlProf != null) && (profile != cmdlProf)) {
+ continue;
+ }
+
+ /* name = lib/profile/name.a+suffix */
+ var name = "lib/" + profile + "/" + lib.name;
+
+ /* pass along library attributes specified in library array */
+ var libAttrs = "libAttrs" in lib ? lib.libAttrs : {};
+
+ /* must set profile explicitly */
+ libAttrs.profile = profile;
+
+ /* build the library */
+ var library = Pkg.addLibrary(name, targ, libAttrs);
+
+ /* add the source files */
+ library.addObjects(lib.sources);
+ }
+ }
+}
diff --git a/packages/ti/srvmgr/package.xdc b/packages/ti/srvmgr/package.xdc
--- /dev/null
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2011-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * ======== package.xdc ========
+ *
+ */
+
+requires ti.grcm;
+
+/*!
+ * ======== ti.srvmgr ========
+ * Inter processor communication.
+ *
+ * Contains modules are that OS independent and support
+ * streaming messaging between threads and/or processors.
+ *
+ */
+
+package ti.srvmgr [1,0,0,0] {
+}
diff --git a/packages/ti/srvmgr/package.xs b/packages/ti/srvmgr/package.xs
--- /dev/null
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2011-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/*
+ * ======== package.xs ========
+ *
+ */
+
+/*
+ * ======== close ========
+ */
+function close()
+{
+}
+
+
+/*
+ * ======== getLibs ========
+ */
+function getLibs(prog)
+{
+ var suffix;
+ var file;
+ var libAry = [];
+ var profile = this.profile;
+ var smp = "";
+
+ suffix = prog.build.target.findSuffix(this);
+ if (suffix == null) {
+ return ""; /* nothing to contribute */
+ }
+
+ if (prog.platformName.match(/ipu/)) {
+ smp = "_smp";
+ }
+
+ /* make sure the library exists, else fallback to a built library */
+ file = "lib/" + profile + "/ti.srvmgr" + smp + ".a" + suffix;
+ if (java.io.File(this.packageBase + file).exists()) {
+ libAry.push(file);
+ }
+ else {
+ file = "lib/release/ti.srvmgr" + smp + ".a" + suffix;
+ if (java.io.File(this.packageBase + file).exists()) {
+ libAry.push(file);
+ }
+ else {
+ /* fallback to a compatible library built by this package */
+ for (var p in this.build.libDesc) {
+ if (suffix == this.build.libDesc[p].suffix) {
+ libAry.push(p);
+ break;
+ }
+ }
+ }
+ }
+
+ return libAry.join(";");
+}
diff --git a/packages/ti/srvmgr/rpmsg_omx.h b/packages/ti/srvmgr/rpmsg_omx.h
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * Copyright (c) 2011-2013, Texas Instruments Incorporated
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * * Neither the name of Texas Instruments Incorporated nor the names of
+ * its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * ======== rpmsg_omx.h ========
+ *
+ * These must match definitions in the Linux rpmsg_omx driver.
+ */
+
+#ifndef _RPMSGOMX_H_
+#define _RPMSGOMX_H_
+
+/**
+ * enum omx_msg_types - various message types currently supported
+ *
+ * @OMX_CONN_REQ: a connection request message type. the message should carry
+ * the name of the OMX service which we try to connect to. An instance of
+ * that service will be created remotely, and its address will be sent as
+ * a reply.
+ *
+ * @OMX_CONN_RSP: a response to a connection request. the message will carry
+ * an error code (success/failure), and if connection established successfully,
+ * the addr field will carry the address of the newly created OMX instance.
+ *
+ * @OMX_PING_MSG: a ping message. should trigger a pong message as a response,
+ * with the same payload the ping had, used for testing purposes.
+ *
+ * @OMX_PONG_MSG: a response to a ping. should carry the same payload that
+ * the ping had. used for testing purposes.
+ *
+ * @OMX_DISC_REQ: a disconnect request message type. the message should carry
+ * the address of the OMX service previously received from the OMX_CONN_RSP
+ * message.
+ *
+ * @OMX_RAW_MSG: a message that should be propagated as-is to the user.
+ * this would immediately enable user space development to start.
+ * as we progress, most likely this message won't be needed anymore.
+ *
+ * @OMX_DISC_RSP: a disconnect response message type. the message should carry
+ * the status from the OMX_DISC_REQ message.
+ */
+enum omx_msg_types {
+ OMX_CONN_REQ = 0,
+ OMX_CONN_RSP = 1,
+ OMX_PING_MSG = 2,
+ OMX_PONG_MSG = 3,
+ OMX_DISC_REQ = 4,
+ OMX_RAW_MSG = 5,
+ OMX_DISC_RSP = 6
+};
+
+/**
+ * enum omx_error_codes - various error codes that will be used
+ *
+ * @OMX_SUCCESS: success
+ *
+ * @OMX_NOTSUPP: not supported
+ *
+ * @OMX_NOMEM: remote processor is out of memory
+ *
+ * @OMX_FAIL: general failure.
+ */
+enum omx_error_codes {
+ OMX_SUCCESS = 0,
+ OMX_NOTSUPP = 1,
+ OMX_NOMEM = 2,
+ OMX_FAIL = 3
+};
+
+/**
+ * struct omx_msg_hdr - common header for all OMX messages
+ * @type:type of message, see enum omx_msg_types
+ * @flags:currently unused, should be zero
+ * @len:length of msg payload (in bytes)
+ * @data:the msg payload (depends on the message type)
+ *
+ * All OMX messages will start with this common header (which will begin
+ * right after the standard rpmsg header ends).
+ */
+struct omx_msg_hdr {
+ UInt32 type;
+ UInt32 flags;
+ UInt32 len;
+ Char data[1];
+};
+
+/* define this here because we cannot use data[0] in struct above */
+#define HDRSIZE (3 * sizeof(UInt))
+
+struct omx_connect_req {
+ Char name[48];
+};
+
+struct omx_connect_rsp {
+ UInt32 status;
+ UInt32 addr;
+};
+
+struct omx_disc_req {
+ UInt32 addr;
+};
+
+struct omx_disc_rsp {
+ UInt32 status;
+};
+
+#endif