]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - keystone-rtos/traceframework.git/blobdiff - trace_contract.h
Merge pull request #3 in PROCESSOR-SDK/traceframework from CATREQ-2702 to master
[keystone-rtos/traceframework.git] / trace_contract.h
old mode 100755 (executable)
new mode 100644 (file)
index ee07e4c..49f03ce
@@ -48,31 +48,77 @@ extern "C" {
 #include <string.h>
 /* OSAL Includes */
 #include <ti/instrumentation/traceframework/contract_osal.h>
-/* other includes */
-#include <ti/instrumentation/traceframework/tf_loc.h>
 
 /** @addtogroup TRACEFRAMEWORK_SYMBOL
 @{
 */
 
+/**
+ * @brief   contract cache line size
+ */
+#define  TF_CONTRACT_CACHE_LINEZ             128
+
+/**
+ * @brief   contract memory size requirements
+ *          contract has 12 cache lines
+ */
+#define  TF_CONTRACT_SIZE_BYTES                (TF_CONTRACT_CACHE_LINEZ * 12)
+
 /**
  * @brief   Alignment for the tf_contract memory
  */
+#define  TF_CONTRACT_BUFS_ALIGN                 128
 
-#define  TF_CONTRACT_BUFS_ALIGN            128
+/**
+ * @brief   Ring Buffer Alignment
+ */
+#define TF_PRODUCER_LOGBUF_ALGIN                128
 
 /**
- * @brief   number of bytes allocated for the name of the contract
+ * @brief   Maximum number of Ring buffers supported in the ring
  */
+#define  TF_MAX_RING_BUFS_SUPPORT               1024
 
-#define  TF_CONTRACT_NAME_SIZE_BYTES            128
 
+/**
+ * @brief   maximum consumers allowed per contract
+ */
+#define  TF_MAX_CONSUMERS_PERCONTRACT             4
 
 /**
  * @brief   number of bytes allocated for the Out of Band information
+ *          Out of band information is really for the application to keep some information in the traceframework contract
+ *          and retrive it from either producer/consumers as it is. Traceframework does not alter any information
+ *          stored in 
+ */
+
+#define  TF_CONTRACT_OOB_SIZE_BYTES             TF_CONTRACT_CACHE_LINEZ
+
+/**
+ * @brief   number of bytes allocated for the name of the contract (applicable only for contract version 1)
+ *          since contract version 2 does not handle name within traceframework
  */
 
-#define  TF_CONTRACT_OOB_SIZE_BYTES            128
+#define  TF_CONTRACT_NAME_SIZE_BYTES            TF_CONTRACT_CACHE_LINEZ
+
+
+/**
+ *  @defgroup tfCtrlBitMap Trace Framework Control Bit map Definitions
+ *  @ingroup TRACEFRAMEWORK_API
+ *  @{
+ *
+ *  @name TraceFramework Control Bit Map Definitions
+ *
+ *  Bitmap definition of the ctrlBitMap in @ref tf_StartCfg_t. 
+ */ 
+/*@{*/
+/**
+ *  @def  tf_CONTRACT_BLK_ADDR_TYPE
+ *        Control Info -- 0: The contract block (version 1) base is physical address 
+ *                        1: The contract block (version 1) base is virtual  address 
+ */
+#define tf_CONTRACT_BLK_ADDR_TYPE    0x0001 
+
 
 /**
 @}
@@ -82,6 +128,20 @@ extern "C" {
 @{
 */
 
+ /**
+  * @brief Contract State added here
+  * When contracts are newly created, they are marked Available and
+  * as and when the contracts are used between producers and consumer
+  * instances, they would be marked as not available.
+  */
+ typedef enum {
+       TF_CONTRACT_AVAILABLE = 0x55555555,
+   /**< tf_contract slot is available */       
+       TF_CONTRACT_NOT_AVAILABLE = 0x0
+   /**< tf_contract slot is not available */   
+  }tf_contractState_e;
+
+
  /**
   * @brief Contract Versions added here
   * Contract Version number signifies the set of APIs to be used
@@ -99,6 +159,43 @@ extern "C" {
     /**< Unknown Contract Version which Trace Framework can not understand */
   }tf_contractVersion_e;
 
+/**
+ * @brief Contract Types added here 
+ * Trace framework can support multiple contract types such as
+ * 1. Contracts having streaming producer always ( can have 4 consumers maximum)
+ * 2. Contracts having stream/freeze producer (supports only one consumer per contract)
+ */
+typedef enum {
+   TF_CONTRACT_DSP_ARM = 0,
+   /**< tf_contract between DSP and ARM, where ARM has consumer for DSP producer */
+   TF_CONTRACT_STREAM_FREEZE_PRODUCER = TF_CONTRACT_DSP_ARM, 
+   /**< tf_contract has stream/freeze producer, this is same as DSP ARM contract, kept for backwards compatibility */     
+   TF_CONTRACT_ARM_ARM = 1
+   /**< tf_contract between ARM and ARM, where ARM has both producer and consumers */  
+ }tf_contractType_e;
+
+/**
+ * @brief Trace Framework Ring Buffer Address type
+ */
+typedef enum {
+
+   TF_CONTRACT_RING_BUF_PHYSICAL_ADDR = 0,
+  /**< trace framework contract ring buffer address configured is physical memory */
+   TF_CONTRACT_RING_BUF_NOT_PHYSICAL_ADDR = 1
+  /**< trace framework contract ring buffer address configured is not physical memory */   
+ }tf_ringBufAddrType_e; 
+
+/**
+ * @brief Trace Framework Contract Buffer Address type
+ */
+typedef enum {
+
+   TF_CONTRACT_BUF_PHYSICAL_ADDR = 0,
+  /**< trace framework contract buffer address configured is physical memory */
+   TF_CONTRACT_BUF_NOT_PHYSICAL_ADDR = 1
+  /**< trace framework contract buffer address configured is not physical memory */    
+ }tf_contractBufAddrType_e; 
+
 
 /**
 @}
@@ -139,6 +236,17 @@ typedef struct tf_contractConfig
 } tf_contractConfig_t;   
 
 
+/**
+ * @brief trace framework start configuration structure (to support multi-instance and legacy features)
+ */
+typedef struct {
+  void*     instPoolBaseAddr;        /**< Base address of the global shared memory pool from which global 
+                                               LLD instance & channel instance memory is allocated */
+  uint32_t  instPoolSize;            /**< Pool size of the global shared memory */                                                                                             
+  uint32_t  ctrlBitMap;              /**< Control bit map @ref tfCtrlBitMap */                                                                                                 
+} tf_StartCfg_t;
+
+
 /**
  * @brief get trace framework contract information interface structure
  */
@@ -163,9 +271,6 @@ typedef struct {
 @}
 */
 
-#define DEVICE_REG32_W(x,y)   *(volatile unsigned int *)(x)=(y)
-#define DEVICE_REG32_R(x)    (*(volatile unsigned int *)(x))
-
 /** @addtogroup TRACEFRAMEWORK_FUNCTIONS
 @{
 */
@@ -220,15 +325,17 @@ void tf_contractInit(void* tf_contract_base, uint32_t num);
  *
  * =============================================================================
  */
-tf_contract_HANDLE tf_contractCreate(tf_contractConfig_t tf_contractConfig, char* name);
+tf_contract_HANDLE tf_contractCreate(tf_contractConfig_t *tf_contractConfig, char* name);
 
 /**
  * ============================================================================
  *  @n@b tf_newContract
  *
  *  @b  brief
- *  @n  New API added to create the contract between producer/consumer instances
+ *  @n  API added to create the contract between producer/consumer instances
  *      This API is applicable for the contract version TRACE_CONTRACT_VERSION_2
+ *      Application needs to maintain any names associated with this contract handle 
+ *      outside traceframework
  *
  *  @param[in]  tf_contractConfig
  *      tf_contract configuration structure
@@ -238,7 +345,7 @@ tf_contract_HANDLE tf_contractCreate(tf_contractConfig_t tf_contractConfig, char
  *
  * =============================================================================
  */
-tf_contract_HANDLE tf_newContract(tf_contractConfig_t tf_contractConfig);
+tf_contract_HANDLE tf_newContract(tf_contractConfig_t *tf_contractConfig);
 
     
 
@@ -314,7 +421,7 @@ uint32_t  tf_getOverRunCount(tf_contract_HANDLE contract_handle);
  */
 uint32_t  tf_isLogInfoNextBuf (tf_contract_HANDLE contract_handle);
 
-/*
+/**
  * ============================================================================
  *  @n@b tf_contractGetInfo
  *
@@ -323,7 +430,7 @@ uint32_t  tf_isLogInfoNextBuf (tf_contract_HANDLE contract_handle);
  *
  *      Application Requirements:
  *      Application would need to create valid contract handle before calling this function
- *  @param[in]  hanle
+ *  @param[in]  handle
  *      trace framework contract handle
  *
  *  @param[in]  info
@@ -336,7 +443,7 @@ uint32_t  tf_isLogInfoNextBuf (tf_contract_HANDLE contract_handle);
  */
 void tf_contractGetInfo(tf_contract_HANDLE handle, tf_contractGetInfo_t* info);
 
-/*
+/**
  * ============================================================================
  *  @n@b tf_systemCfg
  *
@@ -344,7 +451,7 @@ void tf_contractGetInfo(tf_contract_HANDLE handle, tf_contractGetInfo_t* info);
  *  @n starts the system with start configurations 
  *
  *      Application Requirements:
- *      Application would need to call this API with proper startCfg arguments
+ *      Application would need to call this API once per process/core with proper startCfg arguments
  *      before Contract Create, Produer Create and Consumer Create functions
  *
  *  @param[in]  startCfg
@@ -362,16 +469,45 @@ void tf_systemCfg (tf_StartCfg_t *startCfg);
 */
 
 /* Define below function alias names for backward compatibility */
-tf_contract_HANDLE TF_CONTRACT_CREATE(tf_contractConfig_t tf_contractConfig, char* name);
+tf_contract_HANDLE TF_CONTRACT_CREATE(tf_contractConfig_t *tf_contractConfig, char* name);
 void TF_CONTRACT_INIT(void* tf_contract_base, uint32_t num);
-tf_contract_HANDLE TF_NEW_CONTRACT(tf_contractConfig_t tf_contractConfig);
+tf_contract_HANDLE TF_NEW_CONTRACT(tf_contractConfig_t *tf_contractConfig);
 tf_contract_HANDLE TF_CONTRACT_FIND (void* tf_contract_start_addr, uint32_t num_contracts, char* name); 
 uint32_t  tf_get_overrun_count(tf_contract_HANDLE contract_handle);
 uint32_t  tf_is_logInfo_next_buf(tf_contract_HANDLE handle);
 
+ /* below is kept for backwards compatibility */
+#define    TRACE_CONTRACT_VERSION_2     TF_CONTRACT_VERSION_2
+#define    TRACE_CONTRACT_VERSION_1     TF_CONTRACT_VERSION_1
+#define    TRACE_CONTRACT_AVAILABLE     TF_CONTRACT_AVAILABLE
+#define    TRACE_CONTRACT_NOT_AVAILABLE TF_CONTRACT_NOT_AVAILABLE
+
+/* Local Errno for Trace Framework */
+#define TF_ERRNO_BASE                           -128
+#define TF_ERRNO_NO_CONTRACT_FOUND              (TF_ERRNO_BASE                           + 1)
+#define TF_ERRNO_ALL_CONTRACTS_FULL             (TF_ERRNO_NO_CONTRACT_FOUND              + 1)
+#define TF_ERRNO_CONSUMER_ALLOC_FAIL            (TF_ERRNO_ALL_CONTRACTS_FULL             + 1)
+#define TF_ERRNO_CONSUMER_INVALID_CONFIG_PARAMS (TF_ERRNO_CONSUMER_ALLOC_FAIL            + 1)
+#define TF_ERRNO_NULL_RING_BUFFER_FOUND         (TF_ERRNO_CONSUMER_INVALID_CONFIG_PARAMS + 1)
+#define TF_ERRNO_MAX_RING_BUFFER_REACHED        (TF_ERRNO_NULL_RING_BUFFER_FOUND         + 1)
+#define TF_ERRNO_INVALID_CONSUMER_HANDLE        (TF_ERRNO_MAX_RING_BUFFER_REACHED        + 1)
+#define TF_ERRNO_INVALID_PRODUCER_HANDLE        (TF_ERRNO_INVALID_CONSUMER_HANDLE        + 1)
+#define TF_ERRNO_MAX_NUM_CONSUMERS_REACHED      (TF_ERRNO_INVALID_PRODUCER_HANDLE        + 1)
+#define TF_ERRNO_UNEXPECTED_NUM_CONSUMERS       (TF_ERRNO_MAX_NUM_CONSUMERS_REACHED      + 1)
+#define TF_ERRNO_PRODUCER_ALLOC_FAIL            (TF_ERRNO_UNEXPECTED_NUM_CONSUMERS       + 1)
+#define TF_ERRNO_INVALID_CONTRACT_HANDLE        (TF_ERRNO_PRODUCER_ALLOC_FAIL            + 1)
+#define TF_ERRNO_INVALID_CONTRACT_ELEMENTS      (TF_ERRNO_INVALID_CONTRACT_HANDLE        + 1)
+#define TF_ERRNO_SYNC_LOCK_ERROR_HANDLE         (TF_ERRNO_INVALID_CONTRACT_ELEMENTS      + 1)
+#define TF_ERRNO_SYNC_LOCK_ERROR_USER_ID        (TF_ERRNO_SYNC_LOCK_ERROR_HANDLE         + 1)
+#define TF_ERRNO_SYNC_LOCK_ERROR_DBL_LOCK       (TF_ERRNO_SYNC_LOCK_ERROR_USER_ID        + 1)
+#define TF_ERRNO_SYNC_LOCK_ERROR_DBL_UNLOCK     (TF_ERRNO_SYNC_LOCK_ERROR_DBL_LOCK       + 1)
+
+
 #ifdef __cplusplus
 }
 #endif
 
 #endif /* CONSPROD_CONTRACT_H_ */
+
 /* Nothing past this point */    
+