Add GateHWSpinlock configuration into qnx/src/cfg
authorvwan@ti.com <vwan@ti.com>
Tue, 14 Apr 2015 21:51:00 +0000 (14:51 -0700)
committerRobert Tivy <rtivy@ti.com>
Mon, 20 Apr 2015 22:11:47 +0000 (15:11 -0700)
This commit adds a configuration structure for GateHWSpinlock into the
qnx/src/cfg directory. Some refactoring of the GateHWSpinlock implementation
is necessary to allow both the user library and the resource manager to
share this common configuration. ipc3x_dev/ti/syslink/Std.h is cleaned up to
eliminate duplication with respect to ti/ipc/Std.h and to fix resulting
build errors.

Signed-off-by: VW <vwan@ti.com>
18 files changed:
qnx/src/api/Ipc.c
qnx/src/api/gates/GateHWSpinlock.c
qnx/src/api/gates/GateHWSpinlock_client.c [new file with mode: 0644]
qnx/src/cfg/dra7xx/GateHWSpinlockCfg.c [new file with mode: 0644]
qnx/src/ipc3x_dev/ti/syslink/Std.h
qnx/src/ipc3x_dev/ti/syslink/build/Qnx/resmgr/common.mk
qnx/src/ipc3x_dev/ti/syslink/build/Qnx/resmgr/dcmd_syslink.h
qnx/src/ipc3x_dev/ti/syslink/build/Qnx/resmgr/syslink_devctl.c
qnx/src/ipc3x_dev/ti/syslink/family/vayu/Platform.c
qnx/src/ipc3x_dev/ti/syslink/inc/GateHWSpinlock.h
qnx/src/ipc3x_dev/ti/syslink/inc/GateHWSpinlockDrvDefs.h [new file with mode: 0644]
qnx/src/ipc3x_dev/ti/syslink/inc/_GateHWSpinlock.h [new file with mode: 0644]
qnx/src/ipc3x_dev/ti/syslink/inc/usr/Qnx/GateHWSpinlockDrv.h [new file with mode: 0644]
qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/GateHWSpinlock_daemon.c
qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/Qnx/gatehwspinlock_devctl.c [new file with mode: 0644]
qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/usr/Qnx/GateHWSpinlockDrv.c [new file with mode: 0644]
qnx/src/ipc3x_dev/ti/syslink/samples/hlos/MessageQCopy/usr/common.mk
qnx/src/ipc3x_dev/ti/syslink/samples/hlos/hwspinlock/usr/common.mk

index bf044655b4bda0dcc176724098f1ebc426e965ae..61989b8af794a3815b4715a5d85221434b7cf825 100644 (file)
 #include <_GateMP.h>
 #include <_GateMP_usr.h>
 #include <_TiIpcFxns.h>
-#include <ti/syslink/inc/GateHWSpinlock.h>
+#include <ti/syslink/inc/_GateHWSpinlock.h>
 #include <ti/syslink/inc/_MultiProc.h>
 
 MultiProc_Config _MultiProc_cfg;
 
+
 static void cleanup(int arg);
 
 /** ============================================================================
@@ -156,6 +157,7 @@ Int Ipc_start (Void)
     /* Start GateMP only if it is setup in the resource manager */
 #if defined(GATEMP_SUPPORT)
     if (GateMP_isSetup()) {
+        /* Get GateHWSpinlock configuration from resource manager */
         status = GateHWSpinlock_start();
         if (status < 0) {
             printf("Ipc_start: GateHWSpinlock_start failed: %d\n",
index 68c1a43ed17899f1afe2419e1d437e6310417804..896a61c04638a1be09d018c4f472de1d7dc925ed 100644 (file)
 #include <ti/ipc/GateMP.h>
 
 #include <ti/syslink/inc/GateHWSpinlock.h>
+#include <ti/syslink/inc/usr/Qnx/GateHWSpinlockDrv.h>
+#include <ti/syslink/inc/GateHWSpinlockDrvDefs.h>
+#include <ti/syslink/inc/_GateHWSpinlock.h>
 
 #include <ti/syslink/utils/IGateProvider.h>
 
-/*
- * TODO: does this belong in ti/ipc/Std.h? We should consider getting rid of
- *       error blocks from the GateMutex.h interface.
- */
-typedef UInt32            Error_Block;
 #include <ti/syslink/utils/GateMutex.h>
 
 /* Module level headers */
@@ -62,25 +60,11 @@ typedef UInt32            Error_Block;
 #include <stdlib.h>
 #include <sys/mman.h>
 
-/*
- * TODO: Hardcoding these for now. In daemon, we should ideally pass these in
- * through config in GateHWSpinlock_setup and user lib can query the daemon.
- */
-#define HWSPINLOCK_BASE             0x4A0F6000
-#define HWSPINLOCK_SIZE             0x1000
-#define HWSPINLOCK_OFFSET           0x800
-
 
 /* =============================================================================
  * Structures & Enums
  * =============================================================================
  */
-/* GateHWSpinlock Module Local State */
-typedef struct {
-    UInt32 *                        baseAddr;   /* base addr lock registers */
-    GateMutex_Handle                gmHandle;   /* handle to gate mutex */
-} GateHWSpinlock_Module_State;
-
 /* GateHWSpinlock instance object */
 struct GateHWSpinlock_Object {
     IGateProvider_SuperObject; /* For inheritance from IGateProvider */
@@ -95,13 +79,18 @@ struct GateHWSpinlock_Object {
  * Globals
  * =============================================================================
  */
-static GateHWSpinlock_Module_State GateHWSpinlock_state =
+GateHWSpinlock_Module_State _GateHWSpinlock_state =
 {
-    .baseAddr = NULL,
-    .gmHandle = NULL
+    .vAddr                  = NULL,
+    .gmHandle               = NULL,
+    .cfg.numLocks           = 128,
+    .cfg.baseAddr           = 0,
+    .cfg.offset             = 0,
+    .cfg.size               = 0,
+    .numLocks               = 128u
 };
 
-static GateHWSpinlock_Module_State *Mod = &GateHWSpinlock_state;
+static GateHWSpinlock_Module_State *Mod = &_GateHWSpinlock_state;
 
 static GateHWSpinlock_Params GateHWSpinlock_defInstParams =
 {
@@ -124,22 +113,24 @@ Bool _GateHWSpinlock_verbose = FALSE;
  */
 Int32 GateHWSpinlock_start(Void)
 {
-    Int32               status = GateHWSpinlock_S_SUCCESS;
-    UInt32              dst;
+    Int32                 status = GateHWSpinlock_S_SUCCESS;
+    UInt32                dst;
+
+    GateHWSpinlock_getConfig(&Mod->cfg);
 
     /* map the hardware lock registers into the local address space */
     if (status == GateHWSpinlock_S_SUCCESS) {
-        dst = (UInt32)mmap(NULL, HWSPINLOCK_SIZE,
+        dst = (UInt32)mmap(NULL, Mod->cfg.size,
                             (PROT_READ | PROT_WRITE | PROT_NOCACHE),
                             (MAP_PHYS|MAP_SHARED), NOFD,
-                            (off_t)HWSPINLOCK_BASE);
+                            (off_t)Mod->cfg.baseAddr);
 
         if (dst == (UInt32)MAP_FAILED) {
             PRINTVERBOSE0("GateHWSpinlock_start: Memory map failed")
             status = GateHWSpinlock_E_OSFAILURE;
         }
         else {
-            Mod->baseAddr = (UInt32 *)(dst + HWSPINLOCK_OFFSET);
+            Mod->vAddr = (UInt32 *)(dst + Mod->cfg.offset);
             status = GateHWSpinlock_S_SUCCESS;
         }
     }
@@ -171,8 +162,8 @@ Int GateHWSpinlock_stop(Void)
     }
 
     /* release lock register mapping */
-    if (Mod->baseAddr != NULL) {
-        munmap((void *)HWSPINLOCK_BASE, HWSPINLOCK_SIZE);
+    if (Mod->vAddr != NULL) {
+        munmap((void *)Mod->vAddr, Mod->cfg.size);
     }
 
     return(status);
@@ -241,7 +232,7 @@ Int GateHWSpinlock_delete (GateHWSpinlock_Handle * handle)
  */
 IArg GateHWSpinlock_enter(GateHWSpinlock_Object *obj)
 {
-    volatile UInt32 *baseAddr = Mod->baseAddr;
+    volatile UInt32 *baseAddr = Mod->vAddr;
     IArg key;
 
     key = IGateProvider_enter(obj->localGate);
@@ -272,7 +263,7 @@ IArg GateHWSpinlock_enter(GateHWSpinlock_Object *obj)
  */
 Int GateHWSpinlock_leave(GateHWSpinlock_Object *obj, IArg key)
 {
-    volatile UInt32 *baseAddr = Mod->baseAddr;
+    volatile UInt32 *baseAddr = Mod->vAddr;
 
     obj->nested--;
 
diff --git a/qnx/src/api/gates/GateHWSpinlock_client.c b/qnx/src/api/gates/GateHWSpinlock_client.c
new file mode 100644 (file)
index 0000000..968a1d1
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (c) 2015, 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.
+ */
+
+/*
+ *  ======== GateHWSpinlock_client.c ========
+ */
+
+/* Standard headers */
+#include <ti/ipc/Std.h>
+
+#include <ti/syslink/inc/GateHWSpinlock.h>
+#include <ti/syslink/inc/_GateHWSpinlock.h>
+#include <ti/syslink/inc/usr/Qnx/GateHWSpinlockDrv.h>
+#include <ti/syslink/inc/GateHWSpinlockDrvDefs.h>
+
+#include <_IpcLog.h>
+#include <assert.h>
+
+/* traces in this file are controlled via _GateHWSpinlock_verbose */
+#define verbose _GateHWSpinlock_verbose
+
+/* =============================================================================
+ * APIS
+ * =============================================================================
+ */
+/*
+ * Function to get configuration address & sizes for the GateHWSpinlock module.
+ */
+Void GateHWSpinlock_getConfig(GateHWSpinlock_Config * cfg)
+{
+    Int status;
+    GateHWSpinlockDrv_CmdArgs cmdArgs;
+
+    assert (cfg != NULL);
+
+    cmdArgs.args.getConfig.config = cfg;
+    status = GateHWSpinlockDrv_ioctl(CMD_GATEHWSPINLOCK_GETCONFIG, &cmdArgs);
+
+    if (status < 0) {
+        PRINTVERBOSE1("GateHWSpinlock_getConfig: API (through IOCTL) failed, \
+            status=%d\n", status)
+    }
+
+    return;
+}
diff --git a/qnx/src/cfg/dra7xx/GateHWSpinlockCfg.c b/qnx/src/cfg/dra7xx/GateHWSpinlockCfg.c
new file mode 100644 (file)
index 0000000..cb9d269
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (c) 2014-2015 Texas Instruments Incorporated - http://www.ti.com
+ * 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.
+ */
+/*
+ * ======== GateHWSpinlockCfg_dra7xx.c ========
+ * GateHWSpinlock configuration for DRA7xx device
+ */
+
+/* Standard IPC headers */
+#include <ti/ipc/Std.h>
+
+#include <GateHWSpinlock.h>
+
+GateHWSpinlock_Config _GateHWSpinlock_cfg =  {
+   .baseAddr = 0x4A0F6000,  /* Base address of HW spinlocks */
+   .size = 0x1000,          /* Size of register set */
+   .offset = 0x800,         /* Offset of register set from base address */
+   .numLocks = 256          /* Number of HW spinlocks supported */
+};
index 037cdc3c1dd6fc796139e90cad6645b1c0b9c115..f6804b55c969df8a05d01c33cae3ed8fe599b5ee 100644 (file)
  *
  */
 
-#if !defined(STD_H)
-#define STD_H
+#if !defined(SYSLINK_STD_H)
+#define SYSLINK_STD_H
 
-#include <std_qnx.h>
+#include <ti/ipc/Std.h>
+#include <ti/syslink/inc/Qnx/std_qnx.h>
 
 #if defined (__cplusplus)
 extern "C" {
 #endif
 
-typedef char              Char;
-typedef unsigned char     UChar;
-typedef short             Short;
-typedef unsigned short    UShort;
-typedef int               Int;
-typedef unsigned int      UInt;
 #ifndef _UINT_DEFINED
 #define _UINT_DEFINED
 typedef unsigned int      uint;
 #endif
 typedef unsigned int      UINT32;
-typedef long              Long;
-typedef unsigned long     ULong;
 typedef unsigned long     ULONG;
 typedef unsigned long     DWORD;
-typedef float             Float;
-typedef double            Double;
-typedef long double       LDouble;
-typedef void              Void;
 typedef void             * HANDLE;
 typedef unsigned int     atomic_t;
 
-typedef unsigned short    Bool;
 typedef unsigned short    BOOL;
-typedef void            * Ptr;       /* data pointer */
-typedef char            * String;    /* null terminated string */
-
-
-typedef int            *  IArg;
-typedef unsigned int   *  UArg;
-typedef char              Int8;
-typedef short             Int16;
-typedef int               Int32;
-
-typedef unsigned char     UInt8;
-typedef unsigned short    UInt16;
-typedef unsigned int      UInt32;
-typedef unsigned int      SizeT;
-typedef unsigned char     Bits8;
-typedef unsigned short    Bits16;
-typedef UInt32            Bits32;
-
-#define TRUE              1
-#define FALSE             0
 
 /*! Data type for errors */
 typedef UInt32            Error_Block;
index 8887bd869e9fedad1193f059460493488c38bbe0..fd7b675d7a221e35d959615c667ef192e82db892 100644 (file)
@@ -139,7 +139,7 @@ EXTRA_SRCVPATH+=$(IPC_ROOT)/ti/syslink/family/common        \
                 $(IPC_REPO)/qnx/src/api/gates \
                 $(IPC_REPO)/qnx/src/cfg/dra7xx
 
-EXCLUDE_OBJS = GateMP.o
+EXCLUDE_OBJS = GateMP.o GateHWSpinlock_client.o
 endif
 
 include $(MKFILES_ROOT)/qtargets.mk
index e43c6873229cca1145e98c9fe9d2cf157d1fbc74..4c4395e4b6d4b73d728befd264361b2778e6dbeb 100644 (file)
@@ -51,7 +51,8 @@ typedef enum {
     _DCMD_IPC_NAMESERVER = 0x2A,
     _DCMD_IPC_MESSAGEQ,
     _DCMD_IPC_MULTIPROC,
-    _DCMD_IPC_GATEMP
+    _DCMD_IPC_GATEMP,
+    _DCMD_IPC_GATEHWSPINLOCK
 } dcmd_class_t_val;
 
 /*  ----------------------------------------------------------------------------
@@ -223,6 +224,18 @@ typedef enum {
                                             6,\
                                             GateMPDrv_CmdArgs)
 
+/*  ----------------------------------------------------------------------------
+*   IOCTL command IDs for GateHWSpinlock
+*   ----------------------------------------------------------------------------
+*/
+
+/*!
+ *  @brief  Command for GateHWSpinlock_getConfig
+*/
+#define DCMD_GATEHWSPINLOCK_GETCONFIG       __DIOTF(_DCMD_IPC_GATEHWSPINLOCK,\
+                                            1,\
+                                            GateHWSpinlockDrv_CmdArgs)
+
 #if defined (__cplusplus)
 }
 #endif
index 036e793dd6f21c15f02b3728c3e2500bad4d637f..32f46506ba11d063868d017326b4741a74a2c09e 100644 (file)
@@ -85,6 +85,8 @@ extern int ipc_multiproc_devctl(resmgr_context_t *ctp, io_devctl_t *msg,
                                      ipc_ocb_t * ocb);
 extern int ipc_gatemp_devctl(resmgr_context_t *ctp, io_devctl_t *msg,
                                  ipc_ocb_t * ocb);
+extern int ipc_gatehwspinlock_devctl(resmgr_context_t *ctp, io_devctl_t *msg,
+                                 ipc_ocb_t * ocb);
 
 /**
  * Handler for devctl() messages.
@@ -138,6 +140,9 @@ int ipc_devctl(resmgr_context_t *ctp, io_devctl_t *msg, ipc_ocb_t *ocb)
         case _DCMD_IPC_GATEMP:
             status = ipc_gatemp_devctl(ctp, msg, ocb);
             break;
+        case _DCMD_IPC_GATEHWSPINLOCK:
+            status = ipc_gatehwspinlock_devctl(ctp, msg, ocb);
+            break;
 #endif
         default:
             status = _RESMGR_ERRNO(ENOSYS);
index 48706678f7726ce18e5380d0012a9f350baf0203..ecfbcb5e227d62fe7f88cf4a5e6b5cee2efc3d9c 100644 (file)
@@ -83,6 +83,7 @@
 #include <IpcKnl.h>
 #include <sys/mman.h>
 #include <GateHWSpinlock.h>
+#include <_GateHWSpinlock.h>
 #include <Gpt.h>
 
 #if defined (__cplusplus)
@@ -94,10 +95,6 @@ extern "C" {
  *  Macros.
  *  ============================================================================
  */
-/* Hardware spinlocks info */
-#define HWSPINLOCK_BASE             0x4A0F6000
-#define HWSPINLOCK_SIZE             0x1000
-#define HWSPINLOCK_OFFSET           0x800
 
 /** ============================================================================
  *  Application specific configuration, please change these value according to
@@ -167,8 +164,6 @@ typedef struct Platform_Module_State {
     /*!< Flag to indicate platform initialization status */
     Bool              gateHWSpinlockInitFlag;
     /*!< GateHWSpinlock Initialize flag */
-    Ptr               gateHWSpinlockVAddr;
-    /*!< GateHWSpinlock Virtual Address */
 } Platform_Module_State;
 
 
@@ -272,7 +267,7 @@ Platform_overrideConfig (Platform_Config * config, Ipc_Config * cfg)
     else {
 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
 
-        /* Set the MultiProc config as defined in SystemCfg.c */
+        /* Set the MultiProc config as defined in MultiProcCfg.c */
         config->multiProcConfig = _MultiProc_cfg;
 
         /* Override the MESSAGEQCOPY default config */
@@ -281,6 +276,9 @@ Platform_overrideConfig (Platform_Config * config, Ipc_Config * cfg)
         config->MQCopyConfig.intId[3] = 173; // 141 + 32
         config->MQCopyConfig.intId[4] = 168; // 136 + 32
 
+        /* Set the GateHWSpinlock config as defined in GateHWSpinlockCfg.c */
+        config->gateHWSpinlockConfig = _GateHWSpinlock_cfg;
+
 #if !defined(IPC_BUILD_OPTIMIZE)
     }
 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
@@ -302,7 +300,6 @@ Platform_setup (Ipc_Config * cfg)
     Platform_Config   _config;
     Platform_Config * config;
     VAYUIpcInt_Config VAYUcfg;
-    Memory_MapInfo    minfo;
 
     Platform_getConfig (&_config);
     config = &_config;
@@ -415,47 +412,31 @@ Platform_setup (Ipc_Config * cfg)
 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
     }
     if (status >= 0) {
-        minfo.src  = HWSPINLOCK_BASE;
-        minfo.size = HWSPINLOCK_SIZE;
-        minfo.isCached = FALSE;
-        status = Memory_map (&minfo);
+        status = GateHWSpinlock_setup (&config->gateHWSpinlockConfig);
+#if !defined(IPC_BUILD_OPTIMIZE)
         if (status < 0) {
-           GT_setFailureReason (curTrace,
-                                GT_4CLASS,
-                                "Platform_setup",
-                                status,
-                                "Memory_map failed!");
+            GT_setFailureReason (curTrace,
+                                 GT_4CLASS,
+                                 "Platform_setup",
+                                 status,
+                                 "GateHWSpinlock_setup failed!");
         }
         else {
-            Platform_module->gateHWSpinlockVAddr = (Ptr)minfo.dst;
-            config->gateHWSpinlockConfig.numLocks = 32;
-            config->gateHWSpinlockConfig.baseAddr = minfo.dst  + HWSPINLOCK_OFFSET;
-            status = GateHWSpinlock_setup (&config->gateHWSpinlockConfig);
-#if !defined(IPC_BUILD_OPTIMIZE)
+#endif /* if !defined(IPC_BUILD_OPTIMIZE) */
+            status = GateHWSpinlock_start();
             if (status < 0) {
                 GT_setFailureReason (curTrace,
-                                     GT_4CLASS,
-                                     "Platform_setup",
-                                     status,
-                                     "GateHWSpinlock_setup failed!");
+                                 GT_4CLASS,
+                                 "Platform_setup",
+                                 status,
+                                 "GateHWSpinlock_start failed!");
             }
             else {
-#endif /* if !defined(IPC_BUILD_OPTIMIZE) */
-                status = GateHWSpinlock_start();
-                if (status < 0) {
-                    GT_setFailureReason (curTrace,
-                                     GT_4CLASS,
-                                     "Platform_setup",
-                                     status,
-                                     "GateHWSpinlock_start failed!");
-                }
-                else {
-                    Platform_module->gateHWSpinlockInitFlag = TRUE;
-                }
-#if !defined(IPC_BUILD_OPTIMIZE)
+                Platform_module->gateHWSpinlockInitFlag = TRUE;
             }
-#endif /* if !defined(IPC_BUILD_OPTIMIZE) */
+#if !defined(IPC_BUILD_OPTIMIZE)
         }
+#endif /* if !defined(IPC_BUILD_OPTIMIZE) */
     }
 
     /* Enable GP timers */
@@ -483,7 +464,6 @@ Int32
 Platform_destroy (void)
 {
     Int32  status = Platform_S_SUCCESS;
-    Memory_UnmapInfo minfo;
 
     GT_0trace (curTrace, GT_ENTER, "Platform_destroy");
 
@@ -619,27 +599,10 @@ Platform_destroy (void)
             else {
 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
                 Platform_module->gateHWSpinlockInitFlag = FALSE;
-            }
 #if !defined(IPC_BUILD_OPTIMIZE)
-        }
+            }
 #endif /* if !defined(IPC_BUILD_OPTIMIZE) */
-    }
-
-    if (Platform_module->gateHWSpinlockVAddr) {
-        minfo.addr = (UInt32)Platform_module->gateHWSpinlockVAddr;
-        minfo.size = HWSPINLOCK_SIZE;
-        minfo.isCached = FALSE;
-        status = Memory_unmap(&minfo);
-#if !defined(IPC_BUILD_OPTIMIZE)
-        if (status < 0) {
-            GT_setFailureReason (curTrace,
-                                 GT_4CLASS,
-                                 "Platform_destroy",
-                                 status,
-                                 "Memory_unmap failed!");
         }
-#endif /* if !defined(IPC_BUILD_OPTIMIZE) */
-        Platform_module->gateHWSpinlockVAddr = NULL;
     }
 
     GT_1trace (curTrace, GT_LEAVE, "Platform_destroy", status);
index 4b4a9b3035b716acd11b33228c392362c57c2909..4f8efa30fe0aebaaa4058eee08d56e897d40c1c1 100644 (file)
@@ -162,18 +162,13 @@ typedef struct GateHWSpinlock_Object * GateHWSpinlock_Handle;
  *  @brief  Structure defining config parameters for the GateHWSpinlock module.
  */
 typedef struct GateHWSpinlock_Config {
-    GateMP_LocalProtect defaultProtection;
-    /*!< Default module-wide local context protection level. The level of
-     * protection specified here determines which local gate is created per
-     * GateHWSpinlock instance for local protection during create. The instance
-     * configuration parameter may be used to override this module setting per
-     * instance.  The configuration used here should reflect both the context
-     * in which enter and leave are to be called, as well as the maximum level
-     * of protection needed locally.
-     */
     UInt32               baseAddr;
     /* Device-specific base address for HW Semaphore subsystem in HOST OS
-     * address space, this is updated in Ipc module */
+     * address space */
+    UInt32               size;
+    /* Device-specific size for HW Semaphore subsystem */
+    UInt32               offset;
+    /* Device-specific offset for HW Semaphore registers */
     UInt                 numLocks;
     /* Device-specific number of semphores in the HW Semaphore subsystem */
 } GateHWSpinlock_Config;
@@ -259,9 +254,6 @@ UInt32 GateHWSpinlock_getNumInstances (Void);
  */
 Void GateHWSpinlock_locksinit(Void);
 
-/* Internal variable to enable/disable tracing throughout GateHWSpinlock */
-extern Bool _GateHWSpinlock_verbose;
-
 #if defined (__cplusplus)
 }
 #endif /* defined (__cplusplus) */
diff --git a/qnx/src/ipc3x_dev/ti/syslink/inc/GateHWSpinlockDrvDefs.h b/qnx/src/ipc3x_dev/ti/syslink/inc/GateHWSpinlockDrvDefs.h
new file mode 100644 (file)
index 0000000..753a8e2
--- /dev/null
@@ -0,0 +1,99 @@
+/*
+ *  Copyright (c) 2015, 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.
+ */
+/*!
+ *  @file       GateHWSpinlockDrvDefs.h
+ *
+ *  @brief      Definitions of GateHWSpinlockDrv types and structures.
+ */
+
+
+#ifndef GATEHWSPINLOCK_DRVDEFS_H
+#define GATEHWSPINLOCK_DRVDEFS_H
+
+
+#include <ti/syslink/inc/GateHWSpinlock.h>
+#include "IpcCmdBase.h"
+#include <ti/syslink/inc/IoctlDefs.h>
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+
+/* =============================================================================
+ *  Macros and types
+ * =============================================================================
+ */
+/*  ----------------------------------------------------------------------------
+ *  IOCTL command IDs for GateHWSpinlock
+ *  ----------------------------------------------------------------------------
+ */
+/*!
+ *  @brief  Base command ID for GateHWSpinlock
+ */
+#define GATEHWSPINLOCK_BASE_CMD                 0x170
+
+/*!
+ *  @brief  Command for GateHWSpinlock_getConfig
+ */
+#define CMD_GATEHWSPINLOCK_GETCONFIG             _IOWR(IPCCMDBASE,\
+                                            GATEHWSPINLOCK_BASE_CMD + 1u,\
+                                            GateHWSpinlockDrv_CmdArgs)
+
+/*  ----------------------------------------------------------------------------
+ *  Command arguments for GateHWSpinlock
+ *  ----------------------------------------------------------------------------
+ */
+/*!
+ *  @brief  Command arguments for GateHWSpinlock
+ */
+typedef struct GateHWSpinlockDrv_CmdArgs {
+    union {
+        struct {
+            GateHWSpinlock_Config * config;
+        } getConfig;
+        /*
+         * Technically we do not need this union but left it there for
+         * consistency and in case we need to add commands in the future.
+         */
+    } args;
+
+    Int32 apiStatus;
+} GateHWSpinlockDrv_CmdArgs;
+
+
+#if defined (__cplusplus)
+}
+#endif /* defined (__cplusplus) */
+
+
+#endif /* GateHWSpinlock_DrvDefs_H */
diff --git a/qnx/src/ipc3x_dev/ti/syslink/inc/_GateHWSpinlock.h b/qnx/src/ipc3x_dev/ti/syslink/inc/_GateHWSpinlock.h
new file mode 100644 (file)
index 0000000..c0de4c1
--- /dev/null
@@ -0,0 +1,75 @@
+/*
+ *  Copyright (c) 2015 Texas Instruments Incorporated - http://www.ti.com
+ *  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.
+ */
+/** ============================================================================
+ *  @file   _GateHWSpinlock.h
+ *
+ *  @brief  Header file for_GateHWSpinlock on HLOS side
+ *  ============================================================================
+ */
+
+
+#ifndef _GATEHWSPINLOCK_H
+#define _GATEHWSPINLOCK_H
+
+#include <ti/syslink/Std.h>
+#include <ti/syslink/inc/GateHWSpinlock.h>
+#include <ti/syslink/utils/GateMutex.h>
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+
+/* =============================================================================
+ *  Macros and types
+ * =============================================================================
+ */
+
+/* GateHWSpinlock Module Local State */
+typedef struct {
+    UInt32 *                  vAddr;     /* virtual addr of lock registers */
+    GateMutex_Handle          gmHandle;  /* handle to gate mutex */
+    GateHWSpinlock_Config     cfg;       /* Module configuration */
+    UInt32                    numLocks;  /* Maximum number of locks */
+} GateHWSpinlock_Module_State;
+
+/* Module configuration structure */
+extern GateHWSpinlock_Config _GateHWSpinlock_cfg;
+
+/* Internal variable to enable/disable tracing throughout GateHWSpinlock */
+extern Bool _GateHWSpinlock_verbose;
+
+#if defined (__cplusplus)
+}
+#endif /* defined (__cplusplus) */
+
+#endif /* if !defined(_GATEHWSPINLOCK_H) */
diff --git a/qnx/src/ipc3x_dev/ti/syslink/inc/usr/Qnx/GateHWSpinlockDrv.h b/qnx/src/ipc3x_dev/ti/syslink/inc/usr/Qnx/GateHWSpinlockDrv.h
new file mode 100644 (file)
index 0000000..0c1be53
--- /dev/null
@@ -0,0 +1,65 @@
+/**
+ *  @file   GateHWSpinlockDrv.h
+ *
+ *  @brief      Declarations of OS-specific functionality for GateHWSpinlock
+ *
+ *              This file contains declarations of OS-specific functions for
+ *              GateHWSpinlock.
+ *
+ */
+/*
+ *  ============================================================================
+ *
+ *  Copyright (c) 2015, Texas Instruments Incorporated
+ *
+ *  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.
+ */
+
+#ifndef GateHWSpinlockDrv_H
+#define GateHWSpinlockDrv_H
+
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+
+/* =============================================================================
+ *  APIs
+ * =============================================================================
+ */
+/* Function to invoke the APIs through ioctl. */
+Int GateHWSpinlockDrv_ioctl (UInt32 cmd, Ptr args);
+
+
+#if defined (__cplusplus)
+}
+#endif /* defined (__cplusplus) */
+
+
+#endif /* GateHWSpinlockDrv_H */
index a3ce4bdb6b38836bcf89a51a3f78ce93e1b26bcc..67f6187416e80dda91ea73c945b72e55973695a2 100644 (file)
@@ -57,6 +57,7 @@
 #include <ti/syslink/utils/String.h>
 
 #include <ti/syslink/utils/GateSpinlock.h>
+#include <_GateHWSpinlock.h>
 #include <GateHWSpinlock.h>
 #include <HwSpinLockCmdBase.h>
 
@@ -66,23 +67,121 @@ extern "C" {
 #endif
 
 #ifdef IPC_PLATFORM_VAYU
-/* TODO: implement these to handle config passed in through Platform.c */
-Void GateHWSpinlock_getConfig (GateHWSpinlock_Config * cfgParams)
+/*!
+ *  @var    GateHWSpinlock_state
+ *
+ *  @brief  GateHWSpinlock Module state object.
+ */
+#if !defined(IPC_BUILD_DEBUG)
+static
+#endif /* if !defined(IPC_BUILD_DEBUG) */
+extern GateHWSpinlock_Module_State _GateHWSpinlock_state;
+GateHWSpinlock_Module_State * GateHWSpinlock_module = &_GateHWSpinlock_state;
+
+
+/* =============================================================================
+ * APIS
+ * =============================================================================
+ */
+/*!
+ *  @brief      Get the default configuration for the GateHWSpinlock module.
+ *
+ *              This function can be called by the application to get their
+ *              configuration parameter to GateHWSpinlock_setup filled in by
+ *              the GateHWSpinlock module.
+ *
+ *  @param      cfgParams  Pointer to the GateHWSpinlock module configuration
+ *                         structure in which the module config is to be
+ *                         returned.
+ */
+Void GateHWSpinlock_getConfig(GateHWSpinlock_Config * cfgParams)
 {
+    GT_1trace (curTrace, GT_ENTER, "GateHWSpinlock_getConfig", cfgParams);
+
+    GT_assert (curTrace, (cfgParams != NULL));
+
+#if !defined(IPC_BUILD_OPTIMIZE)
+    if (cfgParams == NULL) {
+        /* No retVal since this is a Void function. */
+        GT_setFailureReason (curTrace,
+                             GT_4CLASS,
+                             "GateHWSpinlock_getConfig",
+                             GateHWSpinlock_E_INVALIDARG,
+                             "Argument of type (GateHWSpinlock_Config *) passed "
+                             "is null!");
+    }
+    else {
+#endif /* if !defined(IPC_BUILD_OPTIMIZE) */
+        Memory_copy((Ptr) cfgParams,
+                     (Ptr) &GateHWSpinlock_module->cfg,
+                     sizeof (GateHWSpinlock_Config));
+#if !defined(IPC_BUILD_OPTIMIZE)
+    }
+#endif /* if !defined(IPC_BUILD_OPTIMIZE) */
+
+    GT_0trace (curTrace, GT_ENTER, "GateHWSpinlock_getConfig");
+
     return;
 }
 
-
+/*!
+ *  @brief      Setup the GateHWSpinlock module.
+ *
+ *              This function sets up the GateHWSpinlock module. This function
+ *              must be called before any other instance-level APIs can be
+ *              invoked.
+ *              Module-level configuration needs to be provided to this
+ *              function.
+ *
+ *  @param      cfg   GateHWSpinlock module configuration. Cannot be NULL.
+ */
 Int32 GateHWSpinlock_setup(const GateHWSpinlock_Config * cfg)
 {
-    return GateHWSpinlock_S_SUCCESS;
+    Int32                 status = GateHWSpinlock_S_SUCCESS;
+
+    GT_1trace (curTrace, GT_ENTER, "GateHWSpinlock_setup", cfg);
+
+    if (cfg == NULL) {
+        return (GateHWSpinlock_E_INVALIDARG);
+    }
+
+    /* Copy the cfg */
+    Memory_copy((Ptr) &GateHWSpinlock_module->cfg,
+                 (Ptr) cfg,
+                 sizeof (GateHWSpinlock_Config));
+
+    GateHWSpinlock_module->numLocks = cfg->numLocks;
+
+    GT_1trace (curTrace, GT_LEAVE, "GateHWSpinlock_setup", status);
+
+    /*! @retval GateHWSpinlock_S_SUCCESS Operation successful */
+    return status;
 }
 
+
+/*!
+ *  @brief      Function to destroy the GateHWSpinlock module.
+ */
 Int GateHWSpinlock_destroy(Void)
 {
-    return GateHWSpinlock_S_SUCCESS;
+    Int32 status = GateHWSpinlock_S_SUCCESS;
+
+    GT_0trace (curTrace, GT_ENTER, "GateHWSpinlock_destroy");
+    /* Clear cfg area */
+    Memory_set((Ptr) &GateHWSpinlock_module->cfg,
+                0,
+                sizeof (GateHWSpinlock_Config));
+
+    GT_1trace (curTrace, GT_LEAVE, "GateHWSpinlock_destroy", status);
+
+    /*! @retval GateHWSpinlock_S_SUCCESS Operation successful */
+    return status;
 }
 #else
+/*************************************************************************
+ *  Code below is kept for legacy HWSpinlock module
+ *  Deprecated and should be removed at some point along with the module
+ ************************************************************************/
 /* =============================================================================
  * Macros
  * =============================================================================
@@ -147,8 +246,10 @@ static
 #endif /* if !defined(IPC_BUILD_DEBUG) */
 GateHWSpinlock_Module_State GateHWSpinlock_state =
 {
-    .defaultCfg.defaultProtection  = GateHWSpinlock_LocalProtect_INTERRUPT,
     .defaultCfg.numLocks           = 128,
+    .defaultCfg.baseAddr           = 0,
+    .defaultCfg.offset             = 0,
+    .defaultCfg.size               = 0,
     .numLocks                      = 128u,
 };
 
diff --git a/qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/Qnx/gatehwspinlock_devctl.c b/qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/knl/Qnx/gatehwspinlock_devctl.c
new file mode 100644 (file)
index 0000000..6b36666
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ *  @file   gatehwspinlock_devctl.c
+ *
+ *  @brief      OS-specific implementation of GateHWSpinlock driver for Qnx
+ *
+ *
+ *  ============================================================================
+ *
+ *  Copyright (c) 2015, Texas Instruments Incorporated
+ *
+ *  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.
+ */
+
+
+/* Standard headers */
+#include <ti/syslink/Std.h>
+
+/* QNX specific header include */
+#include <ti/syslink/build/Qnx/resmgr/proto.h>
+#include <ti/syslink/build/Qnx/resmgr/dcmd_syslink.h>
+
+/* Module specific header files */
+#include <ti/syslink/inc/GateHWSpinlock.h>
+#include <ti/syslink/inc/GateHWSpinlockDrvDefs.h>
+
+/* Function prototypes */
+int ipc_gatehwspinlock_getconfig(resmgr_context_t *ctp, io_devctl_t *msg,
+    ipc_ocb_t *ocb);
+
+/**
+ * Handler for devctl() messages for gatehwspinlock module.
+ *
+ * Handles special devctl() messages that we export for control.
+ *
+ * \param ctp   Thread's associated context information.
+ * \param msg   The actual devctl() message.
+ * \param ocb   OCB associated with client's session.
+ *
+ * \return POSIX errno value.
+ *
+ * \retval EOK      Success.
+ * \retval ENOTSUP  Unsupported devctl().
+ */
+int ipc_gatehwspinlock_devctl(resmgr_context_t *ctp, io_devctl_t *msg,
+    ipc_ocb_t *ocb)
+{
+    switch (msg->i.dcmd) {
+        case DCMD_GATEHWSPINLOCK_GETCONFIG:
+            return ipc_gatehwspinlock_getconfig(ctp, msg, ocb);
+            break;
+
+        default:
+            fprintf(stderr, "Invalid DEVCTL for gatehwspinlock 0x%x \n", msg->i.
+                dcmd);
+            break;
+    }
+
+    return (_RESMGR_PTR(ctp, &msg->o, sizeof(msg->o) +
+        sizeof(GateHWSpinlockDrv_CmdArgs)));
+}
+
+/**
+ * Handler for gatehwspinlock getconfig API.
+ *
+ * \param ctp   Thread's associated context information.
+ * \param msg   The actual devctl() message.
+ * \param ocb   OCB associated with client's session.
+ *
+ * \return POSIX errno value.
+ *
+ * \retval EOK      Success.
+ * \retval ENOTSUP  Unsupported devctl().
+ */
+int ipc_gatehwspinlock_getconfig(resmgr_context_t *ctp, io_devctl_t *msg,
+    ipc_ocb_t *ocb)
+{
+    GateHWSpinlockDrv_CmdArgs * cargs = (GateHWSpinlockDrv_CmdArgs *)
+        (_DEVCTL_DATA (msg->i));
+    GateHWSpinlock_Config *     config = (GateHWSpinlock_Config *)(cargs+1);
+
+    GateHWSpinlock_getConfig(config);
+
+    cargs->apiStatus = GateHWSpinlock_S_SUCCESS;
+    SETIOV(&ctp->iov[0], &msg->o, sizeof(msg->o) +
+        sizeof(GateHWSpinlockDrv_CmdArgs));
+    SETIOV(&ctp->iov[1], config, sizeof(GateHWSpinlock_Config));
+
+    return _RESMGR_NPARTS(2);
+}
diff --git a/qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/usr/Qnx/GateHWSpinlockDrv.c b/qnx/src/ipc3x_dev/ti/syslink/ipc/hlos/usr/Qnx/GateHWSpinlockDrv.c
new file mode 100644 (file)
index 0000000..8d57d4c
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ *  @file   GateHWSpinlockDrv.c
+ *
+ *  @brief      OS-specific implementation of GateHWSpinlock driver for Qnx
+ *
+ *
+ *  ============================================================================
+ *
+ *  Copyright (c) 2015, Texas Instruments Incorporated
+ *
+ *  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.
+ */
+
+
+/* Standard headers */
+#include <ti/syslink/Std.h>
+
+/* OSAL & Utils headers */
+#include <ti/syslink/utils/Trace.h>
+#include <ti/syslink/inc/GateHWSpinlock.h>
+#include <ti/syslink/inc/GateHWSpinlockDrvDefs.h>
+#include <ti/syslink/build/Qnx/resmgr/dcmd_syslink.h>
+
+/* QNX specific header files */
+#include <sys/types.h>
+#include <unistd.h>
+
+/** ============================================================================
+ *  Globals
+ *  ============================================================================
+ */
+/*!
+ *  @brief  Driver handle for GateHWSpinlock in this process.
+ */
+extern Int32 IpcDrv_handle;
+
+/** ============================================================================
+ *  Functions
+ *  ============================================================================
+ */
+/*!
+ *  @brief  Function to invoke the APIs through ioctl.
+ *
+ *  @param  cmd     Command for driver ioctl
+ *  @param  args    Arguments for the ioctl command
+ *
+ *  @sa
+ */
+Int
+GateHWSpinlockDrv_ioctl (UInt32 cmd, Ptr args)
+{
+    Int status      = GateHWSpinlock_S_SUCCESS;
+    int osStatus    = -1;
+
+    GT_2trace (curTrace, GT_ENTER, "GateHWSpinlockDrv_ioctl", cmd, args);
+
+    switch (cmd) {
+          case CMD_GATEHWSPINLOCK_GETCONFIG:
+          {
+              GateHWSpinlockDrv_CmdArgs *cargs = (GateHWSpinlockDrv_CmdArgs *)args;
+              iov_t getconfig_iov[2];
+
+              SETIOV(&getconfig_iov[0], cargs, sizeof(GateHWSpinlockDrv_CmdArgs));
+              SETIOV(&getconfig_iov[1], cargs->args.getConfig.config,
+                  sizeof(GateHWSpinlock_Config));
+              osStatus = devctlv(IpcDrv_handle, DCMD_GATEHWSPINLOCK_GETCONFIG, 2, 2,
+                  getconfig_iov, getconfig_iov, NULL);
+          }
+          break;
+
+          default:
+          {
+              /* This does not impact return status of this function, so retVal
+               * comment is not used.
+               */
+              status = GateHWSpinlock_E_INVALIDARG;
+              GT_setFailureReason (curTrace,
+                                   GT_4CLASS,
+                                   "GateHWSpinlockDrv_ioctl",
+                                   status,
+                                   "Unsupported ioctl command specified");
+          }
+          break;
+      }
+
+
+    if (osStatus != 0) {
+        /*! @retval GateHWSpinlock_E_OSFAILURE Driver ioctl failed */
+        status = GateHWSpinlock_E_OSFAILURE;
+        GT_setFailureReason (curTrace,
+                             GT_4CLASS,
+                             "GateHWSpinlockDrv_ioctl",
+                             status,
+                             "Driver ioctl failed!");
+    }
+    else {
+        /* First field in the structure is the API status. */
+        status = ((GateHWSpinlockDrv_CmdArgs *) args)->apiStatus;
+    }
+
+    GT_1trace (curTrace, GT_LEAVE, "GateHWSpinlockDrv_ioctl", status);
+
+    return status;
+}
index 63b55e2fe7a292c94bd7a117408bae857f06ad5e..98556aae12c87cbd0e1b239f5e46d6460d2c1be1 100644 (file)
@@ -50,7 +50,8 @@ EXTRA_INCVPATH+=$(IPC_ROOT)   \
                                $(IPC_ROOT)/ti/syslink/inc      \
                                $(IPC_ROOT)/ti/syslink/inc/usr/$(IPC_BUILDOS)   \
                                $(IPC_ROOT)/ti/syslink/inc/usr  \
-                               $(IPC_ROOT)/ti/syslink/inc/$(IPC_BUILDOS)
+                               $(IPC_ROOT)/ti/syslink/inc/$(IPC_BUILDOS)  \
+                                $(IPC_REPO)/qnx/include
 
 EXTRA_SRCVPATH+=$(PROJECT_ROOT)/$(IPC_BUILDOS) \
                                $(PROJECT_ROOT)/..
index ecf2a8138c1e8b706e695fefc5fa080667e3308b..fe420e8eca4b64a5902ccba5064b7ed05cd0b9b8 100644 (file)
@@ -46,7 +46,8 @@ EXTRA_INCVPATH+=$(IPC_ROOT)/inc       \
                 $(IPC_ROOT)/inc/ti/ipc \
                 $(IPC_REPO)/packages   \
                 $(IPC_ROOT)/inc/Qnx \
-                $(IPC_ROOT)/../..
+                $(IPC_ROOT)/../.. \
+                $(IPC_REPO)/qnx/include
 
 CCOPTS+=-g -O0