/*
 * Copyright 2010 Trident Microsystems (Far East) Ltd. All rights reserved.
 * All prior copyright rights in this work and the accompanying software
 * products transferred to Trident Microsystems (Far East) Ltd. by written
 * agreement.
 */
/*****************************************************************************/
/* Copyright (c) 2010 NXP B.V.  All rights are 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 NXP 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          tmosal.h
 *
 * \version       %version:  SOUsb225#26 %
 *
 * \date          %date_modified%
 *
 * \brief         This is the header file for the DVP Operating System
 *                Abstraction Layer.
 *
 * REFERENCE DOCUMENTS : mojo_OSALight.doc
 *                       DVP Software Coding Guidelines
 *                       DVP Build Process Specification
 *
 *
 * \section info Change Information
 *
 * \verbatim
 *   Date          Modified by     CRPRNr     TASKNr  Maintenance description
 *   -------------|-----------|-------------|-------|-----------------------------------
 *    24-Oct-2007 | B.Magnier |CFR_BSS#12407| 21976 | First CPI version
 *    31-Oct-2007 | burningh  |             |       | Fix errors with cache enum
 *    31-Oct-2007 | burningh  |             |       | Merge with Caen version
 *    08-Jan-2008 | barnish   | SOUsb225#865| 3974  | Add error code TMOSAL_ERR_INTERRUPTED
 *    05-Feb-2008 | steel     |             |       | Add sem flag interruptible
 *    20-Feb-2008 | barnish   |             |       | Remove interruptible sem stuff
 *    20-Mar-2008 | laird     |             | 4689  | Remove firmware support if not required.
 *    27-Mar-2008 | laird     |             | 4724  | Changed prototype. 
 *    28-May-2008 | AWEST     |             |       | Add tmosalGetLastInterruptStatus
 *    20-Jan-2009 | batelaan  |             |       | Update file copyright/license text
 *   -------------|-----------|-------------|-------|-----------------------------------
 * \endverbatim
 *
*/

#ifndef TMOSAL_H
#define TMOSAL_H

//-----------------------------------------------------------------------------
// Standard include files:
//-----------------------------------------------------------------------------
//
#include <tmNxTypes.h>
#include <tmCompId.h>

//-----------------------------------------------------------------------------
// Project include files:
//-----------------------------------------------------------------------------
//

#ifdef __cplusplus
extern "C"
{
#endif

//-----------------------------------------------------------------------------
// Types and defines:
//-----------------------------------------------------------------------------
//

/**
 * \defgroup TMOSAL Software Version Number
 *
 *       The TMOSAL compatibility number, major version number, and minor
 *       version number must be kept current with any TMOSAL interface changes.
 *       Changes to the TMOSAL interface that are not backwards compatible
 *       result in a compatibility number incremental change. If interfaces are
 *       changed but remain backwards compatible, the compatibility number
 *       remains the same but the major version number is incremented. Software
 *       that will use the TMOSAL can check these version numbers both at build
 *       time (using the C preprocessor) and at runtime by calling the
 *       tmosalGetSWVersion function. Refer to the DVP Software Versioning
 *       Specification for more details.
 */
/*@{*/
#define TMOSAL_COMPATIBILITY_NR     1 /*!< TMOSAL Compatibility number */
#define TMOSAL_MAJOR_VERSION_NR     1 /*!< TMOSAL Major Version number */
#define TMOSAL_MINOR_VERSION_NR     2 /*!< TMOSAL Minor Version number */
/*@}*/

/**
 * \defgroup TMOSAL Error Codes
 */
/*@{*/
#define TMOSAL_ERR_BASE            (CID_COMP_OSAL | CID_LAYER_NONE)
#define TMOSAL_ERR_UNIQUE_BASE     (TMOSAL_ERR_BASE + TM_ERR_COMP_UNIQUE_START)

#define TMOSAL_ERR_COMPATIBILITY       (TMOSAL_ERR_BASE + TM_ERR_COMPATIBILITY)
#define TMOSAL_ERR_MAJOR_VERSION       (TMOSAL_ERR_BASE + TM_ERR_MAJOR_VERSION)
#define TMOSAL_ERR_BAD_PARAM           (TMOSAL_ERR_BASE + TM_ERR_BAD_PARAMETER)
#define TMOSAL_ERR_HANDLE              (TMOSAL_ERR_BASE + TM_ERR_BAD_HANDLE)
#define TMOSAL_ERR_OUT_OF_MEMORY       (TMOSAL_ERR_BASE + TM_ERR_OUT_OF_MEMORY)
/*@}*/

/**
 * \defgroup TMOSAL Specific Error Codes
 */
/*@{*/
/** the task could not be started                                   */
#define TMOSAL_ERR_TASK_START          (TMOSAL_ERR_UNIQUE_BASE)
/** the maximum number of tasks in the system has been exceeded     */
#define TMOSAL_ERR_TASK_FULL           (TMOSAL_ERR_UNIQUE_BASE + 0x01)
/** the task stack size is too big                                  */
#define TMOSAL_ERR_TASK_HIGH           (TMOSAL_ERR_UNIQUE_BASE + 0x02)
/** the task stack size is too small                                */
#define TMOSAL_ERR_TASK_LOW            (TMOSAL_ERR_UNIQUE_BASE + 0x03)
/** invalid task priority                                           */
#define TMOSAL_ERR_TASK_PRIORITY       (TMOSAL_ERR_UNIQUE_BASE + 0x04)
/** null function pointer                                           */
#define TMOSAL_ERR_TASK_FUNC           (TMOSAL_ERR_UNIQUE_BASE + 0x05)
/** the timeout expired                                             */
#define TMOSAL_ERR_TASK_TIMEOUT        (TMOSAL_ERR_UNIQUE_BASE + 0x06)
#define TMOSAL_ERR_TASK_ALREADY_SETUP  (TMOSAL_ERR_UNIQUE_BASE + 0x07)

/** the interrupt is already owned                                  */
#define TMOSAL_ERR_INT_OWNED           (TMOSAL_ERR_UNIQUE_BASE + 0x08)
/** the interrupt is not owned                                      */
#define TMOSAL_ERR_INT_NOT_OWNED       (TMOSAL_ERR_UNIQUE_BASE + 0x09)
/** the interrupt does not exist                                    */
#define TMOSAL_ERR_INT_INVALID         (TMOSAL_ERR_UNIQUE_BASE + 0x0A)
/** null function handler pointer                                   */
#define TMOSAL_ERR_INT_HANDLER         (TMOSAL_ERR_UNIQUE_BASE + 0x0B)
/** invalid priority                                                */
#define TMOSAL_ERR_INT_PRIORITY        (TMOSAL_ERR_UNIQUE_BASE + 0x0C)

/** the maximum number of semaphores in the system has been exceeded*/
#define TMOSAL_ERR_SEM_FULL            (TMOSAL_ERR_UNIQUE_BASE + 0x0D)
/** the timeout expired                                             */
#define TMOSAL_ERR_SEM_TIMEOUT         (TMOSAL_ERR_UNIQUE_BASE + 0x0E)
#define TMOSAL_ERR_SEM_DEL             (TMOSAL_ERR_UNIQUE_BASE + 0x0F)
#define TMOSAL_ERR_SEM_BOUND           (TMOSAL_ERR_UNIQUE_BASE + 0x10)
#define TMOSAL_ERR_SEM_TASK            (TMOSAL_ERR_UNIQUE_BASE + 0x11)

/** the maximum number of mutex in the system has been exceeded     */
#define TMOSAL_ERR_MUTEX_FULL          (TMOSAL_ERR_UNIQUE_BASE + 0x12)
/** the timeout expired                                             */
#define TMOSAL_ERR_MUTEX_TIMEOUT       (TMOSAL_ERR_UNIQUE_BASE + 0X13)
#define TMOSAL_ERR_MUTEX_DEL           (TMOSAL_ERR_UNIQUE_BASE + 0X14)
#define TMOSAL_ERR_MUTEX_NOTOWNED      (TMOSAL_ERR_UNIQUE_BASE + 0x15)
#define TMOSAL_ERR_MUTEX_TASK          (TMOSAL_ERR_UNIQUE_BASE + 0x16)

/** the maximum number of event in the system has been exceeded     */
#define TMOSAL_ERR_EVT_FULL            (TMOSAL_ERR_UNIQUE_BASE + 0x17)
/** the timeout expired                                             */
#define TMOSAL_ERR_EVT_TIMEOUT         (TMOSAL_ERR_UNIQUE_BASE + 0x18)
#define TMOSAL_ERR_EVT_DEL             (TMOSAL_ERR_UNIQUE_BASE + 0x19)
#define TMOSAL_ERR_EVT_TASK            (TMOSAL_ERR_UNIQUE_BASE + 0x1A)

/** the maximum number of queue in the system has been exceeded     */
#define TMOSAL_ERR_QUE_FULL            (TMOSAL_ERR_UNIQUE_BASE + 0x1B)
/** NULL buffer pointer                                             */
#define TMOSAL_ERR_QUE_BUFFER          (TMOSAL_ERR_UNIQUE_BASE + 0x1C)
/** the timeout expired                                             */
#define TMOSAL_ERR_QUE_TIMEOUT         (TMOSAL_ERR_UNIQUE_BASE + 0x1D)
/** the queue is empty                                              */
#define TMOSAL_ERR_QUE_EMPTY           (TMOSAL_ERR_UNIQUE_BASE + 0x1E)
#define TMOSAL_ERR_QUE_DEL             (TMOSAL_ERR_UNIQUE_BASE + 0x1F)
#define TMOSAL_ERR_QUE_TASK            (TMOSAL_ERR_UNIQUE_BASE + 0x20)

/** the maximum number of timers in the system has been exceeded    */
#define TMOSAL_ERR_TIMER_FULL          (TMOSAL_ERR_UNIQUE_BASE + 0x21)
#define TMOSAL_ERR_TIMER_STOPPED       (TMOSAL_ERR_UNIQUE_BASE + 0x22)

/** os specific failure                                             */
#define TMOSAL_ERR_UNKNOWN             (TMOSAL_ERR_UNIQUE_BASE + 0x23)
#define TMOSAL_ERR_CONTEXT             (TMOSAL_ERR_UNIQUE_BASE + 0x24)
#define TMOSAL_ERR_NOT_SUPPORTED       (TMOSAL_ERR_UNIQUE_BASE + 0x25)
#define TMOSAL_ERR_NOT_INITIALIZED     (TMOSAL_ERR_UNIQUE_BASE + 0x26)
#define TMOSAL_ERR_BAD_CACHE_TYPE      (TMOSAL_ERR_UNIQUE_BASE + 0x27)
/*@}*/


#ifdef TMFL_SW_CODEPERF_ENABLED
extern UInt32 real_queue_id[];
#endif

/** provided for backward compatibility                             */
typedef tmErrorCode_t tmosalErrorCode_t;

/******************************************************************************/
/**\brief This is the type definition that provides the enumerated flags for 
 *        the function tmosalTaskCreate. The following flags are provided, 
 *        the flags can be combined with a logical OR (|).
 *
 */
/******************************************************************************/
typedef enum tmosalTaskCreateFlags_Label
{
    tmosalTaskCreateFlagNone    =   0x00,   /**< the task suspend/resume for the task is will
                                             *  not be counting, the task need to be started
                                             * by calling tmosalTaskStart. */
    tmosalTaskCounting          =   0x01,   /**< task suspend/resume mechanism is counting */
    tmosalTaskStarted           =   0x02,   /**< task is started upon success */
    tmosalTaskIdleScheduler		= 	0x04    /**< task is SCHED_IDLE */
}tmosalTaskCreateFlags_t,*ptmosalTaskCreateFlags_t;

/******************************************************************************/
/**\brief This is the type definition that provides the enumerated flags for 
 *        the function tmosalTaskSetup. The flag type has currently no meaning 
 *        and is reserved for future use.
 *
 */
/******************************************************************************/
typedef enum tmosalTaskSetupFlags_Label
{
    tmosalTaskSetupFlagNone =   0x00
}tmosalTaskSetupFlags_t,*ptmosalTaskSetupFlags_t;

/******************************************************************************/
/**\brief This is the type definition that provides the enumerated flags for 
 *        the function tmosalSemCreate.
 *
 */
/******************************************************************************/
typedef enum tmosalSemCreateFlags_Label
{
    tmosalSemCreateFlagNone     =   0x00,   /**< create semaphore in the context of the current processor */
    tmosalSemCreateGlobal       =   0x01    /**< create a multi-processor shared semaphore */
}tmosalSemCreateFlags_t,*ptmosalSemCreateFlags_t;

/******************************************************************************/
/**\brief This is the type definition that provides the enumerated flags for 
 *        the function tmosalMutexCreate.
 *
 */
/******************************************************************************/
typedef enum tmosalMutexCreateFlags_Label
{
    tmosalMutexCreateFlagNone   =   0x00,   /**< create Mutex in the context of the current processor */
    tmosalMutexCreateGlobal     =   0x01    /**< create a multi-processor shared Mutex */
}tmosalMutexCreateFlags_t,*ptmosalMutexCreateFlags_t;

/******************************************************************************/
/**\brief This is the type definition that provides the enumerated flags for 
 *        the function tmosalIntCreate. The flag type has currently no meaning 
 *        and is reserved for future use.
 *
 */
/******************************************************************************/
typedef enum tmosalIntCreateFlags_Label
{
    tmosalIntCreateFlagNone = 0x00
}tmosalIntCreateFlags_t,*ptmosalIntCreateFlags_t;

/******************************************************************************/
/**\brief This is the type definition that provides the enumerated flags for 
 *        the function tmosalTimerCreate. The flag type has currently no 
 *        meaning and is reserved for future use.
 *
 */
/******************************************************************************/
typedef enum tmosalTimerCreateFlags_Label
{
    tmosalTimerCreateFlagNone = 0x00
}tmosalTimerCreateFlags_t,*ptmosalTimerCreateFlags_t;

/******************************************************************************/
/**\brief This is the type definition that provides the enumerated flags for 
 *        the function tmosalTimerTskCreate. The flag type has currently 
 *        no meaning and is reserved for future use.
 *
 */
/******************************************************************************/
typedef enum tmosalTimerTskCreateFlags_Label
{
    tmosalTimerTskCreateFlagNone = 0x00
}tmosalTimerTskCreateFlags_t,*ptmosalTimerTskCreateFlags_t;

/******************************************************************************/
/**\brief This is the type definition that provides the enumerated flags for 
 *        the function tmosalEventCreate. The following flags are provided, 
 *        the flags can be combined with a logical OR (|).
 *
 */
/******************************************************************************/
typedef enum tmosalEventCreateFlags_Label
{
    tmosalEventCreateFlagNone   = 0x00, /**< create an event in the context of the
                                          * current processor. */
    tmosalEventCreateGlobal     = 0x01, /**< create a multi-processor shared event */
    tmosalEventAutoClear        = 0x02  /**< the event will be automatically cleared
                                           * upon reception. If this flag is not set, a
                                           * call to tmosalEventReset is required in
                                           * in order to clear the event from its sent
                                           * state.*/
}tmosalEventCreateFlags_t,*ptmosalEventCreateFlags_t;

/******************************************************************************/
/**\brief This is the type definition that provides the enumerated flags for 
 *        the function tmosalEventSend. The flag type has currently no meaning 
 *        and is reserved for future use.
 *
 */
/******************************************************************************/
typedef enum tmosalEventSendFlags_Label
{
    tmosalEventSendFlagNone = 0x00
}tmosalEventSendFlags_t,*ptmosalEventSendFlags_t;

/******************************************************************************/
/**\brief This is the type definition that provides the enumerated flags for 
 *        the function tmosalEventWait. The flag type has currently no meaning 
 *        and is reserved for future use.
 *
 */
/******************************************************************************/
typedef enum tmosalEventWaitFlags_Label
{
    tmosalEventWaitFlagNone = 0x00,
    tmosalEventWaitFlagAlways = 0x01	/* Always wait */
}tmosalEventWaitFlags_t,*ptmosalEventWaitFlags_t;

/******************************************************************************/
/**\brief This is the type definition that provides the enumerated flags for 
 *        the function tmosalQueueCreate. The following flags are provided, 
 *        the flags can be combined with a logical OR (|).
 *
 */
/******************************************************************************/
typedef enum tmosalQueueCreateFlags_Label
{
    tmosalQueueCreateFlagNone       = 0x00, /**< create Queue in the context of 
                                              *  the current processor. */
    tmosalQueueCreateGlobal         = 0x01  /**< create a multi-processor shared Queue */
}tmosalQueueCreateFlags_t,*ptmosalQueueCreateFlags_t;


/******************************************************************************/
/**\brief This is the type definition that provides the enumerated flags for 
 *        the function tmosalQueueSend. The flag type has currently no meaning 
 *        and is reserved for future use.
 *
 */
/******************************************************************************/
typedef enum tmosalQueueSendFlags_Label
{
    tmosalQueueSendFlagNone = 0x00
}tmosalQueueSendFlags_t,*ptmosalQueueSendFlags_t;

/******************************************************************************/
/**\brief This is the type definition that provides the enumerated flags for 
 *        the function tmosalQueueReceive. The following flags are provided, 
 *        the flags can be combined with a logical OR (|).
 *
 */
/******************************************************************************/
typedef enum tmosalQueueReceiveFlags_Label
{
    tmosalQueueReceiveFlagNone    = 0x00,   /**< default mode: Once a packet has been
                                              *  detected with a call to tmosalQueueSelect,
                                              *  the packet is not signalled by further
                                              *  calls to tmosalQueueSelect, even if the
                                              *  packet has not been removed from the queue. */
    tmosalQueueSignalPacketAlways = 0x01    /**< Once a packet has been detected with a
                                              *  call to tmosalQueueSelect, the packet will
                                              *  always be signaled by further calls to
                                              *  tmosalQueueSelect, until the packet is
                                              *  removed from the queue. */
}tmosalQueueReceiveFlags_t,*ptmosalQueueReceiveFlags_t;

/******************************************************************************/
/**\brief This is the type definition for the time used within the 
 *        OSAL to define date time values.
 *
 */
/******************************************************************************/
typedef struct tmosalDateTime_Label
{
    UInt32  year;
    UInt32  month;
    UInt32  day;
    UInt32  hour;
    UInt32  minute;
    UInt32  second;
    UInt32  millisecond;
    /** Feature under discussion */
    Bool    daylightSaving;
} tmosalDateTime_t, *ptmosalDateTime_t;

/******************************************************************************/
/**\brief This is the type definition for the time used within the OSAL to 
 *        define time values at the millisecond granularity for the programing 
 *        of OSAL Timers.
 *
 */
/******************************************************************************/
typedef struct tmosalTime_label
{
    UInt32  milliseconds;
    UInt32  seconds;
} tmosalTime_t, *ptmosalTime_t;

/******************************************************************************/
/**\brief This is the type definition for the time used within the OSAL to 
 *        measure time values at the millisecond granularity.
 *
 */
/******************************************************************************/
typedef struct tmosalSysTime_Label
{
    UInt32  msLo;
    UInt32  msHi;
} tmosalSysTime_t, *ptmosalSysTime_t;

/******************************************************************************/
/**\brief This is the type definition of the OSAL handle returned by the 
 *        function tmosalTaskCreate. The handle is used for further operations
 *        on the function.
 *
 */
/******************************************************************************/
typedef UInt32 tmosalTaskHandle_t, *ptmosalTaskHandle_t;

/******************************************************************************/
/**\brief This is the type definition for the OSAL Timer setup structure. 
 *        The function tmosalTimerInstanceSetup takes a setup pointer of type 
 *        ptmosalTimerSetup_t as an input parameter, to setup a specific OSAL 
 *        timer.
 *
 */
/******************************************************************************/
typedef struct tmosalTimerSetup_Label
{
    /** pointer to timer function to be executed when the
      * timer expires. The context of the pTimerHandler is
      * the same as an interrupt service routine context. */
    void            (*pTimerHandler)(void*);
    /** context argument passed to the pTimerHandler upon
      * expiration of the OSAL Timer. */
    void            *pContextArgument;
    /** initial value at which the timer will expire.*/
    tmosalTime_t    value;
    /** periodic value at which the timer will expire at
      * regular intervals after the initial value has
      * expired*/
    tmosalTime_t    modulus;
} tmosalTimerSetup_t, *ptmosalTimerSetup_t;

/******************************************************************************/
/**\brief This is the type definition for OSAL Timer handle
 *
 */
/******************************************************************************/
typedef UInt32 tmosalTimerHandle_t, *ptmosalTimerHandle_t;

/******************************************************************************/
/**\brief This is the type definition for the OSAL Semaphore handle
 *
 */
/******************************************************************************/
typedef UInt32 tmosalSemHandle_t, *ptmosalSemHandle_t;

/******************************************************************************/
/**\brief This is the type definition for the OSAL Mutex handle
 *
 */
/******************************************************************************/
typedef UInt32 tmosalMutexHandle_t, *ptmosalMutexHandle_t;

/******************************************************************************/
/**\brief This is the type definition for the OSAL Event handle
 *
 */
/******************************************************************************/
typedef UInt32 tmosalEventHandle_t, *ptmosalEventHandle_t;

/******************************************************************************/
/**\brief This is the type definition for the OSAL Queue handle
 *
 */
/******************************************************************************/
typedef UInt32 tmosalQueueHandle_t, *ptmosalQueueHandle_t;

/******************************************************************************/
/**\brief This is the type definition for the OSAL Event handle array 
 *        used by tmosalEventSelect
 *
 */
/******************************************************************************/
typedef tmosalEventHandle_t *tmosalEventHandleArray_t;

/******************************************************************************/
/**\brief This is the type definition for the OSAL Queue handle array 
 *        used by tmosalQueueselect
 *
 */
/******************************************************************************/
typedef tmosalQueueHandle_t *tmosalQueueHandleArray_t;

/******************************************************************************/
/**\brief region handle type for connection to tmcr
 *
 */
/******************************************************************************/
typedef UInt32 tmosalRegionHandle_t, *ptmosalRegionHandle_t;

/******************************************************************************/
/**\brief This is the type definition of the OSAL task priority.
 *        The range for the OSAL interrupt priority levels is [0.. 15]. the
 *        table below shows the mapping of the OSAL task priority to the 
 *        native OS task priority for each of the OS currently supported 
 *        by the OSAL.
 *        
 *        |    OSAL    |      CE     |      NT     |   pSOS   |\n
 *        ---------------------------------------------------- \n
 *        |      0     | IDLE        | IDLE        |     0    |\n
 *        ---------------------------------------------------- \n
 *        |      1     | IDLE        | IDLE        |     1    |\n
 *        ---------------------------------------------------- \n
 *        |      2     | IDLE        | IDLE        |     2    |\n
 *        ---------------------------------------------------- \n
 *        |      3     | IDLE        | IDLE        |     4    |\n
 *        ---------------------------------------------------- \n
 *        |      4     | IDLE        | IDLE        |     8    |\n
 *        ---------------------------------------------------- \n
 *        |      5     | IDLE        | IDLE        |    12    |\n
 *        ---------------------------------------------------- \n
 *        |      6     | IDLE        | IDLE        |    16    |\n
 *        ---------------------------------------------------- \n
 *        |      7     | IDLE        | IDLE        |    20    |\n
 *        ---------------------------------------------------- \n
 *        |      8     | IDLE        | IDLE        |    24    |\n
 *        ---------------------------------------------------- \n
 *        |      9     | IDLE        | IDLE        |    28    |\n
 *        ---------------------------------------------------- \n
 *        |     10     | IDLE        | IDLE        |    32    |\n
 *        ---------------------------------------------------- \n
 *        |     11     | ABOVE IDLE  | LOWEST      |    36    |\n
 *        ---------------------------------------------------- \n
 *        |     12     | ABOVE IDLE  | LOWEST      |    40    |\n
 *        ---------------------------------------------------- \n
 *        |     13     | ABOVE IDLE  | LOWEST      |    44    |\n
 *        ---------------------------------------------------- \n
 *        |     14     | ABOVE IDLE  | LOWEST      |    48    |\n
 *        ---------------------------------------------------- \n
 *        |     15     | ABOVE IDLE  | LOWEST      |    52    |\n
 *        ---------------------------------------------------- \n
 *        |     16     | ABOVE IDLE  | LOWEST      |    56    |\n
 *        ---------------------------------------------------- \n
 *        |     17     | ABOVE IDLE  | LOWEST      |    60    |\n
 *        ---------------------------------------------------- \n
 *        |     18     | ABOVE IDLE  | LOWEST      |    64    |\n
 *        ---------------------------------------------------- \n
 *        |     19     | ABOVE IDLE  | LOWEST      |    68    |\n
 *        ---------------------------------------------------- \n
 *        |     20     | ABOVE IDLE  | LOWEST      |    72    |\n
 *        ---------------------------------------------------- \n
 *        |     21     | ABOVE IDLE  | LOWEST      |    76    |\n
 *        ---------------------------------------------------- \n
 *        |     22     | LOWEST      | BELOW_NORMAL|    80    |\n
 *        ---------------------------------------------------- \n
 *        |     23     | LOWEST      | BELOW_NORMAL|    84    |\n
 *        ---------------------------------------------------- \n
 *        |     24     | LOWEST      | BELOW_NORMAL|    88    |\n
 *        ---------------------------------------------------- \n
 *        |     25     | LOWEST      | BELOW_NORMAL|    92    |\n
 *        ---------------------------------------------------- \n
 *        |     26     | LOWEST      | BELOW_NORMAL|    96    |\n
 *        ---------------------------------------------------- \n
 *        |     27     | LOWEST      | BELOW_NORMAL|    100   |\n
 *        ---------------------------------------------------- \n
 *        |     28     | LOWEST      | BELOW_NORMAL|    104   |\n
 *        ---------------------------------------------------- \n
 *        |     29     | LOWEST      | BELOW_NORMAL|    108   |\n
 *        ---------------------------------------------------- \n
 *        |     30     | LOWEST      | BELOW_NORMAL|    112   |\n
 *        ---------------------------------------------------- \n
 *        |     31     | LOWEST      | BELOW_NORMAL|    116   |\n
 *        ---------------------------------------------------- \n
 *        |     32     | LOWEST      | BELOW_NORMAL|    120   |\n
 *        ---------------------------------------------------- \n
 *        |     33     | BELOW_NORMAL| NORMAL      |    124   |\n
 *        ---------------------------------------------------- \n
 *        |     34     | BELOW_NORMAL| NORMAL      |    128   |\n
 *        ---------------------------------------------------- \n
 *        |     35     | BELOW_NORMAL| NORMAL      |    132   |\n
 *        ---------------------------------------------------- \n
 *        |     36     | BELOW_NORMAL| NORMAL      |    136   |\n
 *        ---------------------------------------------------- \n
 *        |     37     | BELOW_NORMAL| NORMAL      |    140   |\n
 *        ---------------------------------------------------- \n
 *        |     38     | BELOW_NORMAL| NORMAL      |    144   |\n
 *        ---------------------------------------------------- \n
 *        |     39     | BELOW_NORMAL| NORMAL      |    148   |\n
 *        ---------------------------------------------------- \n
 *        |     40     | BELOW_NORMAL| NORMAL      |    152   |\n
 *        ---------------------------------------------------- \n
 *        |     41     | BELOW_NORMAL| NORMAL      |    156   |\n
 *        ---------------------------------------------------- \n
 *        |     42     | BELOW_NORMAL| NORMAL      |    160   |\n
 *        ---------------------------------------------------- \n
 *        |     43     | BELOW_NORMAL| NORMAL      |    164   |\n
 *        ---------------------------------------------------- \n
 *        |     44     | NORMAL      | ABOVE NORMAL|    168   |\n
 *        ---------------------------------------------------- \n
 *        |     45     | NORMAL      | ABOVE NORMAL|    172   |\n
 *        ---------------------------------------------------- \n
 *        |     46     | NORMAL      | ABOVE NORMAL|    176   |\n
 *        ---------------------------------------------------- \n
 *        |     47     | NORMAL      | ABOVE NORMAL|    180   |\n
 *        ---------------------------------------------------- \n
 *        |     48     | NORMAL      | ABOVE NORMAL|    184   |\n
 *        ---------------------------------------------------- \n
 *        |     49     | NORMAL      | ABOVE NORMAL|    188   |\n
 *        ---------------------------------------------------- \n
 *        |     50     | NORMAL      | ABOVE NORMAL|    192   |\n
 *        ---------------------------------------------------- \n
 *        |     51     | NORMAL      | ABOVE NORMAL|    196   |\n
 *        ---------------------------------------------------- \n
 *        |     52     | NORMAL      | ABOVE NORMAL|    200   |\n
 *        ---------------------------------------------------- \n
 *        |     53     | NORMAL      | ABOVE NORMAL|    204   |\n
 *        ---------------------------------------------------- \n
 *        |     54     | NORMAL      | ABOVE NORMAL|    208   |\n
 *        ---------------------------------------------------- \n
 *        |     55     | ABOVE_NORMAL| HIGHEST     |    212   |\n
 *        ---------------------------------------------------- \n
 *        |     56     | ABOVE_NORMAL| HIGHEST     |    216   |\n
 *        ---------------------------------------------------- \n
 *        |     57     | ABOVE_NORMAL| HIGHEST     |    220   |\n
 *        ---------------------------------------------------- \n
 *        |     58     | ABOVE_NORMAL| HIGHEST     |    224   |\n
 *        ---------------------------------------------------- \n
 *        |     59     | ABOVE_NORMAL| HIGHEST     |    228   |\n
 *        ---------------------------------------------------- \n
 *        |     60     | ABOVE_NORMAL| HIGHEST     |    232   |\n
 *        ---------------------------------------------------- \n
 *        |     61     | ABOVE_NORMAL| HIGHEST     |    234   |\n
 *        ---------------------------------------------------- \n
 *        |     62     | ABOVE_NORMAL| HIGHEST     |    238   |\n
 *        ---------------------------------------------------- \n
 *        |     63     | ABOVE_NORMAL| HIGHEST     |    239   |\n
 */
/******************************************************************************/
typedef UInt32 tmosalTaskPriority_t, *ptmosalTaskPriority_t;

/******************************************************************************/
/**\brief This is the type definition of the OSAL interrupt priority. 
 *        The range for the OSAL interrupt priority levels is [0.. 15]. the 
 *        table below shows the mapping of the OSAL interrupt priority to 
 *        the OS interrupt priority for each of the OS currently supported 
 *        by the OSAL.
 *
 *         |   OSAL     |     CE        |     NT        |   pSOS   |\n
 *         -------------------------------------------------------- \n
 *         |      0     | HIGHEST       | TIME_CRITICAL |     0    |\n
 *         -------------------------------------------------------- \n
 *         |      1     | HIGHEST       | TIME_CRITICAL |     0    |\n
 *         -------------------------------------------------------- \n
 *         |      2     | HIGHEST       | TIME_CRITICAL |     1    |\n
 *         -------------------------------------------------------- \n
 *         |      3     | HIGHEST       | TIME_CRITICAL |     1    |\n
 *         -------------------------------------------------------- \n
 *         |      4     | HIGHEST       | TIME_CRITICAL |     2    |\n
 *         -------------------------------------------------------- \n
 *         |      5     | HIGHEST       | TIME_CRITICAL |     2    |\n
 *         -------------------------------------------------------- \n
 *         |      6     | HIGHEST       | TIME_CRITICAL |     3    |\n
 *         -------------------------------------------------------- \n
 *         |      7     | HIGHEST       | TIME_CRITICAL |     3    |\n
 *         -------------------------------------------------------- \n
 *         |      8     | TIME_CRITICAL | TIME_CRITICAL |     4    |\n
 *         -------------------------------------------------------- \n
 *         |      9     | TIME_CRITICAL | TIME_CRITICAL |     4    |\n
 *         -------------------------------------------------------- \n
 *         |     10     | TIME_CRITICAL | TIME_CRITICAL |     5    |\n
 *         -------------------------------------------------------- \n
 *         |     11     | TIME_CRITICAL | TIME_CRITICAL |     5    |\n
 *         -------------------------------------------------------- \n
 *         |     12     | TIME_CRITICAL | TIME_CRITICAL |     6    |\n
 *         -------------------------------------------------------- \n
 *         |     13     | TIME_CRITICAL | TIME_CRITICAL |     6    |\n
 *         -------------------------------------------------------- \n
 *         |     14     | TIME_CRITICAL | TIME_CRITICAL |     7    |\n
 *         -------------------------------------------------------- \n
 *         |     15     | TIME_CRITICAL | TIME_CRITICAL |     7    |\n
 */
/******************************************************************************/
typedef UInt32 tmosalIntPriority_t, *ptmosalIntPriority_t;

/******************************************************************************/
/**\brief This is the type definition for the interrupt descriptor provided 
 *        as an input parameter tmosalIntInstanceSetup. An interrupt created 
 *        with a call to tmosalIntCreate must be configured by calling 
 *        tmosalIntSetup.
 *
 *  \sa   tmosalIntPriority_t
 */
/******************************************************************************/
typedef struct tmosalIntDescriptor_Label
{
    /** pointer to the handler function associated with the interrupt */
    void                (*pHandler)(void*);
    /** pointer to the context argument passed to the interrupt handler */
    Pointer             pContextArgument;
    /** priority of the interrupt*/
    tmosalIntPriority_t priority;
    /** flag to enable or disable the interrupt*/
    Bool                enabled;
    /** flag to configure the interrupt as nested*/
    Bool                interruptible;
} tmosalIntDescriptor_t, *ptmosalIntDescriptor_t;

/******************************************************************************/
/**\brief Type definition for the simulation of the SW_IPCx interrupts on
 *        an Iref platform. The SW_IPCx interrupts are only available on the 
 *        viper PIC on an Iref platform, the TriMedia does not have a PIC 
 *        therefore it is necessary to simulate this interrupts by using 
 *        the TMMAN events with PCI interrupt INT_A.
 *
 */
/******************************************************************************/
typedef struct tmmanInt_Label
{
    char                name[32];
    UInt32              tmEvHandle;
    UInt32              semHandle;
    tmosalTaskHandle_t  taskHandle;
    void                (*pHandlerFunc)(void*);
} tmmanInt_t, *pTmmanInt_t;

/******************************************************************************/
/**\brief This is the type definition for the OSAL interrupt handle returned 
 *        by tmosalIntCreate and further used as an input parameter to function 
 *        calls to the OSAL interrupt control API. The fields of the type
 *        definition are only used internally and therefore are not developped 
 *        further
 *
 */
/******************************************************************************/
typedef struct tmosalInterruptDriver_Label *ptmosalInterruptDriver_t;

typedef struct tmosalIntHandle_Label
{
    String                      name;
    Bool                        allocated;
    ptmosalInterruptDriver_t    driver;
    tmosalIntDescriptor_t       setup;
    Pointer                     driverData;
    tmmanInt_t                  tmmanInt;
} *tmosalIntHandle_t, **ptmosalIntHandle_t;

/******************************************************************************/
/** \brief The following type definitions are the prototypes for the OSAL interrupt
 *        driver interface.
 *
 */
/******************************************************************************/
typedef tmErrorCode_t (*tmosalIntDriverInitFun         )(void);
typedef tmErrorCode_t (*tmosalIntDriverDeinitFun       )(void);
typedef tmErrorCode_t (*tmosalIntDriverSetGlobalPrioFun)(tmosalIntPriority_t);
typedef tmErrorCode_t (*tmosalIntDriverGetInstanceFun  )(String,ptmosalIntHandle_t);
typedef tmErrorCode_t (*tmosalIntDriverDelInstanceFun  )(tmosalIntHandle_t);
typedef tmErrorCode_t (*tmosalIntDriverSetIntPrioFun   )(tmosalIntHandle_t, tmosalIntPriority_t);
typedef tmErrorCode_t (*tmosalIntDriverEnableIntFun    )(tmosalIntHandle_t, Bool);
typedef tmErrorCode_t (*tmosalIntRaiseIntFun           )(tmosalIntHandle_t);
typedef tmErrorCode_t (*tmosalIntClearIntFun           )(tmosalIntHandle_t);
typedef tmErrorCode_t (*tmosalIntGetSwVersion          )(UInt32);

/******************************************************************************/
/**\brief This is the type definition for the OSAL interrupt driver type. 
 *        This type provides function pointers to the OSAL interrupt driver 
 *        interface. The interrupt driver interface is not called outside the
 *        context of the OSAL. The interrupt driver interface implementation 
 *        must be provided in the appropriate bsl manager. The bsl manager is 
 *        a dependency of the OSAL and is part of the DVP Infrastructure 
 *        Architecture
 *
 */
/******************************************************************************/
typedef struct tmosalInterruptDriver_Label
{
    tmosalIntDriverInitFun            init;
    tmosalIntDriverDeinitFun          deinit;
    tmosalIntDriverGetInstanceFun     getInstance;
    tmosalIntDriverDelInstanceFun     delInstance;
    tmosalIntDriverSetGlobalPrioFun   setGlobalPrio;
    tmosalIntDriverSetIntPrioFun      setIntPrio;
    tmosalIntDriverEnableIntFun       enableInt;
    tmosalIntRaiseIntFun              raiseInt;
    tmosalIntClearIntFun              clearInt;
    tmosalIntGetSwVersion             getSwVersion;
    ptmosalInterruptDriver_t          next;
} tmosalInterruptDriver_t;

/******************************************************************************/
/**\brief  This structure type defines cache types.(Instruction, data, or unified)
 *
 */
/******************************************************************************/
typedef enum _tmosalCacheType_t{
    tmosalCacheTypeUnified      = 0x0,
    tmosalCacheTypeInstruction  = 0x1,
    tmosalCacheTypeData         = 0x2
}tmosalCacheType_t;

/******************************************************************************/
/**\brief This is the type definition for the OSAL statistic type. 
 *        This type provides counters to the OSAL objetcs : \n 
 *        - Queue \n
 *        - Event \n
 *        - Semaphore \n
 *        - Mutex \n
 *        - Software timer \n
 *        - Task \n
 *
 */
/******************************************************************************/
typedef struct tmosalStatistic_Label
{
    UInt32  curQueueNr;
    UInt32  maxQueueNr;
    UInt32  curMutexNr;
    UInt32  maxMutexNr;
    UInt32  curEventNr;
    UInt32  maxEventNr;
    UInt32  curSemaphoreNr;
    UInt32  maxSemaphoreNr;
    UInt32  curTaskNr;
    UInt32  maxTaskNr;
    UInt32  curTimerNr;
    UInt32  maxTimerNr;
} tmosalStatistic_t, *ptmosalStatistic_t;

#if !defined(TMFL_IC_PNX8335)

/******************************************************************************/
/**\brief This enum contains the possible states for a task at a certain time. 
 *        The state machine model used for this enum is based on 2 states\n 
 *        - Blocked: the task goes into blocked state when it requests an OS\n
 *                   object (mutex/semaphore/queue) but this object is not \n
 *                   available \n
 *        - Ready: the task is candidate for execution when the scheduler will \n
 *                 assing it the CPU according to scheduling rules (priorities...)\n
 */
/******************************************************************************/
typedef enum
{
   TMOSAL_TASK_STATE_RUN,
   TMOSAL_TASK_STATE_SUSP,
   TMOSAL_TASK_STATE_SLEEP,
   TMOSAL_TASK_STATE_CNTSLEEP,
   TMOSAL_TASK_STATE_CREATE,
   TMOSAL_TASK_STATE_EXIT,
   TMOSAL_TASK_STATE_UNKNOWN
} tmosalTaskState_t, *ptmosalTaskState_t;

/******************************************************************************/
/**\brief This type contains all usefull information about the current tasks
 *        in the system. It is used in debugging to be able to extract 
 *        the list of tasks in the system with the following information
 *        - task identifier \n
 *        - task name \n
 *        - task priority at creation time \n
 *        - task current priority \n
 *        - task's stack base address \n
 *        - task's stack maximum size \n
 *        - task's stack usage \n
 *
 */
/******************************************************************************/
typedef struct tmosalTaskListInfo_Label
{
      char                    pTaskName[4];/* task name */
      tmosalTaskHandle_t      taskHandle;/* task identifier */
      tmosalTaskState_t       currentState;/* task current state */
      tmosalTaskPriority_t    initialPrio;/* task initial priority */
      tmosalTaskPriority_t    currentPrio;/* task current priority */
      UInt32                  stackBaseAddr;/* task stack base address */
      UInt32                  stackSize;/* task stack max size */
      UInt32                  stackUsage;/* task stack usage */
      
} tmosalTaskListInfo_t, *ptmosalTaskListInfo_t;

#endif /* #if !defined(TMFL_IC_PNX8335) */

//-----------------------------------------------------------------------------
// Exported functions:
//-----------------------------------------------------------------------------
//

#if !defined(TMFL_IC_PNX8335)

/******************************************************************************/
/** \brief  This function returns the list of tasks with current information.
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                    success
 *          - TMOSAL_ERR_UNKNOWN       an error occured during execution
 *
 */
/******************************************************************************/
tmErrorCode_t
tmosalGetTaskListInfo(
      UInt32 *               ioNbTasks,        /* the number of tasks returned in the list */
      ptmosalTaskListInfo_t  ioTaskListStruct  /* an array containing the tasks information */
      );

/******************************************************************************/
/**\brief This type contains all usefull information about the current mutexes
 *        in the system. It is used in debugging to be able to extract locked
 *        mutexes, task owning this mutex, and other tasks waiting for it
 */
/******************************************************************************/
typedef struct tmosalMutexListInfo_Label
{
      tmosalMutexHandle_t  handle;
      UInt32               isLocked;           /* 1 means Mutex is locked */
      char                 ownerTaskName[4];   /* current mutex owner task name */
      UInt32               waitingTask;        /* 1 mean another task is wating */
} tmosalMutexListInfo_t, *ptmosalMutexListInfo_t;

//-----------------------------------------------------------------------------
// Exported functions:
//-----------------------------------------------------------------------------
//

/******************************************************************************/
/** \brief  This function returns the list of mutexes with current information.
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                    success
 *          - TMOSAL_ERR_UNKNOWN       an error occured during execution
 *
 */
/******************************************************************************/
tmErrorCode_t
tmosalGetMutexListInfo(
      UInt32 * ioNbMutex, /* the number of mutexes returned in the list */
      ptmosalMutexListInfo_t  ioMutexListStruct  /* an array containing the mutexes information */
      );

#endif /* #if !defined(TMFL_IC_PNX8335) */

/******************************************************************************/
/** \brief  this function performs the initialization of the OSAL.
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                     success
 *          - TMOSAL_ERR_OUT_OF_MEMORY  could not allocate control data
 *          - TMOSAL_ERR_UNKNOWN        un-identified error
 *
 */
/******************************************************************************/
tmErrorCode_t
tmosalInit(
    void
    );

/******************************************************************************/
/** \brief  this function performs the de-initialization of the OSAL.
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                     success
 *          - TMOSAL_ERR_OUT_OF_MEMORY  could not allocate control data
 *          - TMOSAL_ERR_UNKNOWN        un-identified error
 *
 */
/******************************************************************************/
void
tmosalExit(
    void
    );

/******************************************************************************/
/** \brief    This function returns the TMOSAL interface compatibility number,
 *            major version, and minor version. It is called to validate the
 *            OSAL interface compatibility and version information before the
 *            interface is used. If the caller of this function detects a
 *            mismatch with its expected interface compatibility number or
 *            major version number, it should not use the interface as
 *            functions and/or parameters are likely to have changed (the
 *            reason for the version number changes).
 *
 *  \param  pVersionInfo : (Out) TMOSAL software version info pointer
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK     success
 *
 */
/******************************************************************************/
tmErrorCode_t
tmosalGetSWVersion(
    ptmSWVersion_t pVersionInfo
    );

/******************************************************************************/
/** \brief  This macro returns the last OS-specific error code returned in
 *          the system.
 *          This macro is intended for debug purposes only and is compiled
 *          out in the production version of the code.
 *
 *  \param  pErrorCode : (Out) Last error code
 *
 *  \return tmErrorCode_t : error code
 *           - TM_OK : the call is successful
 *
 */
/******************************************************************************/
#define tmosalGetLastErrorCode(pErrorCode) (TMOSAL_ERR_NO_ERROR_CODE)

/******************************************************************************/
/** \brief  this function suspends the calling task for the specified time
 *          duration. The sleep time is defined as an Int32 and specifies
 *          a time in milliseconds. A negative value may be provided as a
 *          sleep time, it is equivalent to a value of 0. The granularity
 *          implemented for tmosalSleep is equal to the OS tick
 *          granularity.                                                  
 *
 *  \param  kTime : (In) Time duration in milliseconds.
 *
 *  \return none
 *
 */
/******************************************************************************/
extern void
tmosalTaskSleep(
    const Int32 kTime
    );

/******************************************************************************/
/** \brief  This function holds its execution for the specified time in
 *          microseconds, if the time value is in the range [1us;1000us].
 *          Beyond this range, the implementation switches to
 *          tmosalTaskSleep with a 10ms granularity.
 *
 *  \param  kTime : (Out) time duration in microseconds
 *
 *  \return none
 *
 *  \note   User must allocate software version structure
 */
/******************************************************************************/
extern void
tmosalTaskMicroSleep(
    const Int32 kTime
    );

/******************************************************************************/
/** \brief   This function returns the current real time in the following
 *           format:
 *           
 *           typedef struct tmosalDateTime_Label
 *           {
 *               UInt32  year;
 *               UInt32  month;
 *               UInt32  day;
 *               UInt32  hour;
 *               UInt32  minute;
 *               UInt32  second;
 *               UInt32  millisecond;
 *               Bool    daylightSaving;
 *           } tmosalDateTime_t, *ptmosalDateTime_t;
 *           
 *           The real time is kept in the system RTC. The daylightSaving
 *           setting is used to offset the standard running time twice a
 *           year. Setting this to True activates the bi-yearly offseting:
 *           
 *           * June 21st: date = date + 1 hour.
 *           * Dec 21st: data = date - 1 hour.
 *
 *  \param  pioDateTime : (Out) real time returned upon success
 *
 *  \return tmErrorCode_t : error code
 *           - TMOSAL_ERR_OK           success
 *           - TMOSAL_ERR_BAD_PARAM    invalid input parameter
 *           - TMOSAL_ERR_UNKNOWN      OS-specific error
 *
 *  \note   none
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalGetDateTime(
    ptmosalDateTime_t pioDateTime // O: 
    );

/******************************************************************************/
/** \brief  this function sets the current real time in the following
 *          format:
 *          
 *          typedef struct tmosalDateTime_Label
 *          {
 *              UInt32  year;
 *              UInt32  month;
 *              UInt32  day;
 *              UInt32  hour;
 *              UInt32  minute;
 *              UInt32  second;
 *              UInt32  millisecond;
 *              Bool    daylightSaving;
 *          } tmosalDateTime_t, *ptmosalDateTime_t;
 *          
 *          The real time is kept in the system RTC. The daylightSaving
 *          setting is used to offset the standard running time twice a
 *          year. Setting this to True activates the bi-yearly offseting:
 *          
 *          * June 21st: date = date + 1 hour.
 *          * Dec 21st: data = date - 1 hour.   
 *
 *  \param  pkDateTime : (Out) real time setting.
 *
 *  \return tmErrorCode_t : error code
 *           - TMOSAL_ERR_OK           success
 *           - TMOSAL_ERR_BAD_PARAM    invalid input parameter
 *           - TMOSAL_ERR_UNKNOWN      OS-specific error
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalSetDateTime(
    ptmosalDateTime_t pkDateTime // O: real time setting
    );

/******************************************************************************/
/** \brief  This function returns the time in milliseconds since the system
 *          was last reset. The time is returned under the following format:
 *          
 *          typedef struct tmosalSysTime_Label
 *          {
 *              UInt32  msLo;
 *              UInt32  msHi;
 *          } tmosalSysTime_t, *ptmosalSysTime_t;
 *          
 *          The msHi value is incremented each time the msLo 32 bit value
 *          wraps.
 *
 *  \param  pioSysTime : (Out) sys time returned upon success.
 *
 *  \return tmErrorCode_t : error code
 *           - TMOSAL_ERR_OK           success
 *           - TMOSAL_ERR_BAD_PARAM    invalid input parameter
 *           - TMOSAL_ERR_UNKNOWN      OS-specific error
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalGetSysTime(
    ptmosalSysTime_t pioSysTime // O: sys time returned upon success
    );

/******************************************************************************/
/** \brief  This function creates a software timer. The granularity of OSAL
 *          timers is equal to the OS tick.
 *          
 *          The timer object of type tmosalTimerObject_t has the following
 *          definition:
 *          
 *          typedef struct tmosalTimerSetup_Label \n
 *          {\n
 *              Bool            repeat; \n
 *              void            (*pTimerHandler)(void*); \n
 *              void            *pContextArgument; \n
 *              tmosalTime_t    value; \n
 *              tmosalTime_t    modulus; \n
 *          } tmosalTimerSetup_t, *ptmosalTimerSetup_t;\n
 *          
 *          The pTimerHandler function runs upon expiration of the timer.
 *          The pContextArgument is passed as an input parameter to
 *          pTimerHandler. The field "value" provides the expiration time
 *          for the first timer shoot. After "value" has expired, and if the
 *          field "modulus" is non zero, the timer will expire at regular
 *          intervals specified by the "modulus" value. 
 *
 *  \param  pioHandle : (Out) handle to timer object.
 *  \param kFlags : reserved
 *
 *  \return tmErrorCode_t : error code
 *           - TM_OK                      success
 *           - TMOSAL_ERR_BAD_PARAM       invalid input parameter
 *           - TMOSAL_ERR_TIMER_FULL      the max number of timers was reached
 *
 *  \note   The function handler runs in a task context. Set the flag to 
 *          tmosalTimerCreateFlagNone - flag reserved for future use.
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalTimerCreate(
    ptmosalTimerHandle_t            pioHandle,    // O: handle to timer object
    const tmosalTimerCreateFlags_t  kFlags       // I: reserved
    );

/******************************************************************************/
/** \brief    this function destroys a software timer previously created with
 *            tmosalTimerCreate.
 *
 *  \param  kHandle : (In) handle to timer object to destroy
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                 success
 *          - TMOSAL_ERR_HANDLE     invalid timer handle
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalTimerDestroy(
    const tmosalTimerHandle_t   kHandle  // I: handle to timer object to destroy
    );

/******************************************************************************/
/** \brief    This function starts a software timer previously created with
 *            tmosalTimerCreate.
 *            
 *            Calling tmosalTimerStart more than once on the same handle
 *            (without stoping the timer) has no effect.
 *            
 *            If a tmosalTimerStop/tmosalTimerStart is performed on a timer,
 *            the timer is re-initialized to its creation stage, no context
 *            is saved.
 *
 *  \param  kHandle : (In) handle to timer object to start
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                      success
 *          - TMOSAL_ERR_HANDLE          invalid timer handle
 *          - TMOSAL_ERR_BAD_PARAM       the timer was not successfully
 *                                       initialized
 *          - TMOSAL_ERR_OUT_OF_MEMORY   out of OSAL control memory
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalTimerStart(
    const tmosalTimerHandle_t   kHandle  // I: handle to timer object to start
    );
/******************************************************************************/
/** \brief  this function stops a software timer previously created with
 *          tmosalTimerCreate and previously started with tmosalTimerStart.
 *
 *  \param  kHandle : (In) handle to timer object to stop
 *
 *  \return tmErrorCode_t : error code
 *           - TM_OK                 success
 *           - TMOSAL_ERR_HANDLE     invalid timer handle
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalTimerStop(
    const tmosalTimerHandle_t   kHandle  // I: handle to timer object to stop
    );

/******************************************************************************/
/** \brief  this function returns the current timer value for a specific
 *          timer.
 *
 *  \param  kHandle : (In) handle to timer
 *  \param  pioCurrentValue : (Out) pointer to value
 *
 *  \return tmErrorCode_t : error code
 *           - TM_OK : the call is successful
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalTimerGetTime(
    const tmosalTimerHandle_t kHandle,   // I: handle to timer
    ptmosalTime_t pioCurrentValue         // O: pointer to value
    );
/******************************************************************************/
/** \brief  this function returns the setup for a specific timer previously
 *          created with a call to tmosalTimerCreate and setup with a call
 *          to tmosalTimerInstanceSetup. The setup parameters are the
 *          following:\n*          
 *          - value: value of the timer of type tmosalTime_t.\n
 *          - modulus: periodic value of the timer of type tmosalTime_t.
 *            The modulus may be set to 0 for non-periodic timers.\n
 *          - pTimerHandler: pointer to the function to execute upon
 *            expiration of the timer.\n
 *          - pContextArgument: argument passed to the timer function upon
 *            expiration of the timer.\n
 *
 *  \param  kHandle : (In) handle to timer to 'setup'
 *  \param  pioSetup : (Out) pointer to setup struct
 *
 *  \return tmErrorCode_t : error code
 *           - TM_OK                       success
 *           - TMOSAL_ERR _HANDLE          invalid timer handle
 *           - TMOSAL_ERR_BAD_PARAM        the setup pointer is Null     
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalTimerInstanceGetSetup(
    const tmosalTimerHandle_t kHandle,       // I: handle to timer to 'setup'
    ptmosalTimerSetup_t    pioSetup           // O: pointer to setup struct
    );

/******************************************************************************/
/** \brief  this function sets up a specific timer previously created with
 *          tmosalTimerCreate. The setup parameters are the following:\n
 *          - value: value of the timer of type tmosalTime_t. \n
 *          - modulus: periodic value of the timer of type tmosalTime_t.
 *            The modulus may be set to 0 for non-periodic timers. \n
 *          - pTimerHandler: pointer to function to execute upon expiration
 *            of the timer. \n
 *          - pContextArgument: argument passed to the timer function upon
 *            expiration of the timer. \n
 *          
 *          A Timer may be setup many times to different parameters however,
 *          it is required to stop the timer first (call to tmosalTimerStop).
 *
 *  \param  kHandle : (In) handle to timer to 'setup'
 *  \param  pkSetup : (In) pointer to timer setup struct
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                       success
 *          - TMOSAL_ERR _HANDLE          invalid timer handle
 *          - TMOSAL_ERR_BAD_PARAM        invalid setup param or Null setup
 *                                        pointer
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalTimerInstanceSetup(
    const tmosalTimerHandle_t       kHandle, // I: handle to timer to 'setup'
    const ptmosalTimerSetup_t       pkSetup  // I: pointer to timer setup struct
    );

/******************************************************************************/
/** \brief  this function adds two time values of type tmosalTime_t. If the
 *          addition exceeds the range, the result wraps arounf to zero.
 *
 *  \param  kTimeA : (In) first argument to the addition
 *  \param  kTimeB : (In) second argument to the addition
 *
 *  \return tmosalTime_t : result of the (timeA + timeB) addition.
 *
 */
/******************************************************************************/
tmosalTime_t
tmosalAddTime(
    const tmosalTime_t kTimeA,       // I: first argument to the addition
    const tmosalTime_t kTimeB        // I: second argument to the addition
    );

/******************************************************************************/
/** \brief  this function subtracts two time values of type tmosalTime_t.
 *          if the substraction result is negative, the result is set to
 *          zero
 *
 *  \param  kTimeA : (In) first argument to the substraction
 *  \param  kTimeB : (In) second argument to the substraction
 *
 *  \return tmosalTime_t : result of the (timeA - timeB) subtraction.
 *
 */
/******************************************************************************/
tmosalTime_t
tmosalSubTime(
    const tmosalTime_t kTimeA,       // I: first argument to the substraction
    const tmosalTime_t kTimeB        // I: second argument to the substraction
    );
/******************************************************************************/
/** \brief  this function allocates a new task to the calling process. Upon
 *          success, the created task runs on its own stack, as part of the
 *          calling process context. Task termination must be achieved by
 *          calling tmosalTaskExit as part of the task root function. The
 *          valid task priority range varies from one os specific
 *          implementation to an other, the OSAL provides a virtual
 *          priority range with 64 levels [0..63]. See the definition of
 *          tmosalTaskPriority_t for the mapping information from OSAL
 *          priorities to native OS priorities.
 *          
 *          The following flags may be used upon task creation - the flags
 *          may be OR-ed together:\n
 *          
 *          - tmosalTaskStart: the task is started upon success.\n
 *          - tmosalTaskCounting: the suspend/resume mechanism is counting.\n
 *          - tmosalTaskCreateFlagNone: default; no counting; task not
 *            started. A call to tmosalTaskStart is necessary to start the
 *            task.\n
 *          
 *          The function tmosalTaskCreate may be called with a Null
 *          pStartFunction and pArgument pointers. A call
 *          to tmosalTaskSetup and tmosalTaskStart is then further required
 *          to respectively setup the task control block and start the
 *          function.
 *          
 *          Note: if a task is finished without calling tmosalTaskExit, the
 *          tmosal task control block will not be cleared and the behaviour
 *          of the system becomes undefined.
 *
 *  \param  pkStartFunction : (In) pointer to root function
 *  \param  pkArgument : (In) pointer to argument of the root function
 *  \param  kPriority : (In) Task priority
 *  \param  kStackSize : (In) stack size for the task to create
 *  \param  pioTaskHandle: (Out) pointer to task handle
 *  \param  pkName : (In) task name (4 characters)
 *  \param  kFlags : (In) out of memory for control block allocation
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                       the task was successfully created
 *                                        and started
 *          - TMOSAL_ERR_TASK_START       the task could not be started
 *          - TMOSAL_ERR_TASK_FULL        the max number of tasks in the
 *                                        system has been exceeded
 *          - TMOSAL_ERR_TASK_HIGH        the stack size is too big
 *          - TMOSAL_ERR_TASK_LOW         that stack size is too small
 *          - TMOSAL_ERR_TASK_PRIORITY    invalid priority
 *          - TMOSAL_ERR_OUT_OF_MEMORY    out of memory for control block
 *                                        allocation
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalTaskCreate (
    void    (*pkStartFunction)(void *pArg),  // I: pointer to root function
    void    *pkArgument,                     // I: pointer to argument to root
                                            //    function
    const tmosalTaskPriority_t  kPriority,   // I: task priority
    const UInt32  kStackSize,                // I: stack size for the task to
                                            //    create
    ptmosalTaskHandle_t   pioTaskHandle,      // O: pointer to task handle
    char pkName[4],                           // I: task name (4 characters)
    const tmosalTaskCreateFlags_t   kFlags   // I: flags reserved for future use
    );

/******************************************************************************/
/** \brief  this function must be called for setting up a task control
 *          block for a task that was created with a call to tmosalTaskStart
 *          with a Null pStartFunction and pkArgument pointers.
 *
 *  \param  kTaskHandle : (In) handle to task to setup
 *  \param  pkStartFunction : (In) pointer to root function
 *  \param  pkArgument : (In) pointer to argument to root function
 *  \param  kFlags : (In) attributes
 *
 *  \return tmErrorCode_t : error code
 *           - TM_OK                       the task was successfully setup
 *           - TMOSAL_ERR_TASK_FUNC        Null function pointer
 *           - TMOSAL_ERR_BAD_PARAM        invalid task handle
 *           - TMOSAL_ERR_CONTEXT          the function is used in an interrupt
 *                                         service routine, which is not
 *                                         allowed
 *           - TMOSAL_ERR_TASK_ALREADY_SETUP  the task has already been set up
 *           - TMOSAL_ERR_HANDLE           wrong task handle
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalTaskSetup (
    tmosalTaskHandle_t   kTaskHandle,        // I: handle to task to setup
    void    (*pkStartFunction)(void *pArg),  // I: pointer to root function
    void    *pkArgument,                     // I: pointer to argument to root function
    const tmosalTaskSetupFlags_t    kFlags   // I: attributes
    );

/******************************************************************************/
/** \brief  this function starts a task previously created as dormant with
 *          the function tmosalTaskCreate (called wit the creation flag set
 *          to tmosTaskCreateFlagNone).
 *
 *  \param  kTaskHandle : (In) task handle to start
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                   the task was successfully started
 *          - TMOSAL_ERR_TASK_START   the task could not be started
 *          - TMOSAL_ERR_CONTEXT      the function is used in an interrupt
 *                                   service routine, which is not
 *                                   allowed
 */
/******************************************************************************/
tmErrorCode_t
tmosalTaskStart(
    const tmosalTaskHandle_t   kTaskHandle       // I: task handle to start
    );

/******************************************************************************/
/** \brief  this function returns the OSAL task handle of the calling task.
 *          The returned handle is only valid in the context of the OSAL.    
 *
 *  \param  pioTaskHandle : (Out) pointer to task handle returned
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                 success
 *          - TMOSAL_ERR_UNKNOWN    os specific failure
 *          - TMOSAL_ERR_BAD_PARAM  the task handle pointer is Null
 *          - TMOSAL_ERR_CONTEXT    the function is used in an interrupt
 *                                  service routine, which is not allowed
 */ 
/******************************************************************************/
extern tmErrorCode_t
tmosalTaskIdent(
    ptmosalTaskHandle_t pioTaskHandle  // O: pointer to task handle returned
    );

extern void
tmosalTaskStop(
    const tmosalTaskHandle_t taskHandle
    );


/******************************************************************************/
/** \brief  this function must be called upon termination of each task;
 *          tmosalTaskExit, frees all OS-specific and OSAL resources that
 *          have been allocated for the specific task.
 *
 *  \return none
 *
 *  \note   if a task is finished without calling tmosalTaskExit, the
 *          tmosal task control block will not be cleared and the
 *          behaviour of the system becomes undefined.
 *
 */ 
/******************************************************************************/
extern void
tmosalTaskExit(
    void
    );

#if !defined(TMFL_IC_PNX8335)

/******************************************************************************/
/** \brief  this function enables the calling task to terminate any other 
 *          task, freeing any OS ressource that have been allocated for it  
 *          
 *  \return TM_OK                   success
 *          TMOSAL_ERR_UNKNOWN      un-identified error
 *          
 *
 */ 
/******************************************************************************/
extern tmErrorCode_t
tmosalTaskKill(
    tmosalTaskHandle_t TaskHandle
    );

#endif /* #if !defined(TMFL_IC_PNX8335) */

/******************************************************************************/
/** \brief  this function may be called from a given task to suspend itself
 *          until an other task resumes it. If the specific task was
 *          created with the flag tmosalTaskCounting, the suspend/resume
 *          mechanism implemented is counting.
 *
 *  \return tmErrorCode_t : error code
 *              - TM_OK               the task was successfully suspended
 *              - TMOSAL_ERR_UNKNOWN  os specific failure
 *              - TMOSAL_ERR_CONTEXT  the function is used in an interrupt
 *                                    service routine, which is not
 *                                    allowed
 *
 */ 
/******************************************************************************/
extern tmErrorCode_t
tmosalTaskSuspend(
    void
    );

/******************************************************************************/
/** \brief  this function resumes an existing suspended task. If the
 *          specific task was created with the flag tmosalTaskCounting, the
 *          suspend/resume mechanism implemented is counting.
 *
 *  \param  kTaskHandle : (In) handle to the task to be resumed
 *
 *  \return tmErrorCode_t : error code
 *              - TM_OK                   the task was successfully resumed
 *              - TMOSAL_ERR_TASK_HANDLE  invalid task handle
 *
 */ 
/******************************************************************************/
extern tmErrorCode_t
tmosalTaskResume(
    const tmosalTaskHandle_t    kTaskHandle  // I: handle to the task to be resumed
    );

/******************************************************************************/
/** \brief  this function returns the current priority of a task.
 *
 *  \param  kTaskHandle : (In) handle to a specific task
 *  \param  pioPriority : (Out) task priority
 *
 *  \return tmErrorCode_t : error code
 *           - TM_OK                     the current task priority was
 *                                       successfully returned
 *           - TMOSAL_ERR_BAD_PARAM      invalid input parameter
 *           - TMOSAL_ERR_TASK_HANDLE    invalid handle
 *           - TMOSAL_ERR_CONTEXT        the function is used in an interrupt
 *                                       service routine, which is not allowed
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalTaskGetPriority(
    const tmosalTaskHandle_t kTaskHandle,    // I: handle to a specific task
    ptmosalTaskPriority_t pioPriority         // O: task priority
    );

/******************************************************************************/
/** \brief  this function sets a new priority for a specific running task.
 *
 *  \param  kTaskHandle : (In) handle to a specific task
 *  \param  kPriority : (In) new task priority
 *
 *  \return tmErrorCode_t : error code
 *           - TM_OK                     the current task priority was
 *                                       successfully returned
 *           - TMOSAL_ERR_BAD_PARAM      invalid input parameter
 *           - TMOSAL_ERR_TASK_HANDLE    invalid handle
 *           - TMOSAL_ERR_TASK_PRIORITY   invalid priority
 *           - TMOSAL_ERR_CONTEXT        the function is used in an interrupt
 *                                       service routine, which is not allowed
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalTaskSetPriority(
    const tmosalTaskHandle_t kTaskHandle,    // I: handle to a specific task
    const tmosalTaskPriority_t kPriority     // I: new task priority
    );


/* phStbOsal counters */
extern unsigned int phStbOsal_CreateCounter(const char *name);
extern void phStbOsal_IncrementCounter(unsigned int index);

/******************************************************************************/
/** \brief  this function takes ownership of a given hardware or software
 *          interrupt source. The interrupt name provided as an input 
 *          parameter must correspond to a valid interrupt name supported
 *          in the bsl interrupt driver provided with the dvp stack. 
 *          
 *          Set the flag to tmosalIntCreateFlagNone - flag reserved for
 *          future use.  
 *
 *  \param  pkName : (In) name of the interrupt source
 *  \param  pioHandle : (Out) pointer to Handle returned
 *  \param  kFlags : (In) flags reserved for future use
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                   the interrupt was successfully
 *                                    created
 *          - TMOSAL_ERR_BAD_PARAM    invalid input parameter
 *          - TMOSAL_ERR_INT_OWNED    the interrupt is already owned
 *          - TMOSAL_ERR_INT_INVALID  the interrupt does not exist
 *          - TMOSAL_ERR_CONTEXT	  the function is used in an interrupt
 *            	                      service routine, which is not allowed
 *          - TMOSAL_ERR_UNKNOWN      os specific failure
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalIntCreate(
    const String pkName,                      // I: name of the interrupt source
    ptmosalIntHandle_t pioHandle,             // O: pointer to Handle returned
    const tmosalIntCreateFlags_t    kFlags   // I: flags reserved for future use
    );

/******************************************************************************/
/** \brief  this function releases the ownership of a given interrupt. 
 *
 *  \param  kHandle : (In) Current config SW version.
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                   the interrupt was successfully
 *                                    created
 *          - TMOSAL_ERR_BAD_PARAM    invalid input parameter
 *          - TMOSAL_ERR_INT_OWNED    the interrupt is already owned
 *          - TMOSAL_ERR_INT_INVALID  the interrupt does not exist
 *          - TMOSAL_ERR_CONTEXT	  the function is used in an interrupt
 *            	                      service routine, which is not allowed
 *          - TMOSAL_ERR_UNKNOWN      os specific failure
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalIntDestroy(
    const tmosalIntHandle_t kHandle  // I: handle to interrupt to 'destroy'
    );

/******************************************************************************/
/** \brief  this function must be used to setup a given interrupt. The 
 *          given interrupt must have been previously created with 
 *          tmosalIntCreate;tmosalInInstanceSetup may be further called to 
 *          change the handler for a given interrupt or to change the 
 *          priority or any other setup paramenter. 
 *
 *  \param  kHandle : (In) Current config SW version.
 *  \param  pkDescriptor : (In) pointer to descriptor
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                   the interrupt was successfully
 *                                    created
 *          - TMOSAL_ERR_BAD_PARAM    invalid input parameter
 *          - TMOSAL_ERR_INT_OWNED    the interrupt is already owned
 *          - TMOSAL_ERR_INT_INVALID  the interrupt does not exist
 *          - TMOSAL_ERR_INT_HANDLER    null function handler pointer
 *          - TMOSAL_ERR_INT_PRIORITY   invalid priority
 *          - TMOSAL_ERR_CONTEXT	  the function is used in an interrupt
 *            	                      service routine, which is not allowed
 *          - TMOSAL_ERR_UNKNOWN      os specific failure
 *
 *  \note   the descriptor parameters are the following: 
 *          
 *          pHandler: pointer to interrupt handler
 *          pContextArgument: ptr to context arg; input param to handler
 *          priority: priority of the interrupt in the range [0..15]. 
 *          enabled: enable or disable the interrupt
 *          interruptible: nested interrupt if True
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalIntInstanceSetup(
    const tmosalIntHandle_t kHandle,             // I: interrupt handle
    const ptmosalIntDescriptor_t pkDescriptor   // I: pointer to descriptor
    );

/******************************************************************************/
/** \brief  this function returns the current setup for a given interrupt
 *
 *  \param  kHandle : (In) handle to interrupt
 *  \param  pioDescriptor : (Out) pointer to setup struct
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                     success
 *          - TMOSAL_ERR_BAD_PARAM      invalid input parameter
 *          - TMOSAL_ERR_INT_INVALID    the interrupt does not exist
 *          - TMOSAL_ERR_INT_NOT_OWNED  the interrupt is not owned
 *          - TMOSAL_ERR_CONTEXT        the function is used in an interrupt
 *            	                      service routine, which is not allowed
 *          - TMOSAL_ERR_UNKNOWN        os specific failure
 *
 *  \note  the setup parameters returned are the following: 
 *         
 *         pHandler: pointer to interrupt handler
 *         pContextArgument: ptr to context arg; input param to handler
 *         priority: priority of the interrupt
 *         enabled: enable or disable the interrupt
 *         interruptible: nested interrupt if True
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalIntInstanceGetSetup(
    const tmosalIntHandle_t kHandle,         // I: handle to interrupt
    ptmosalIntDescriptor_t  pioDescriptor     // O: pointer to setup struct
    );

/******************************************************************************/
/** \brief  this function rasies a specific interrupt. The raise mechanism
 *          is currently available only for the context call back interrupt.
 *
 *  \param  kHandle : (In) handle to interrupt to 'raise'
 *
 *  \return tmErrorCode_t : error code
 *          - TMOSAL_ERR_OK               interrupt sucessfully destroyed
 *          - TMOSAL_ERR_INT_INVALID      the interrupt does not exist
 *          - TMOSAL_ERR_INT_NOT_OWNED    the interrupt is not owned
 *          - TMOSAL_ERR_UNKNOWN          os spezifc failure
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalIntRaise(
    const tmosalIntHandle_t kHandle  // I: handle to interrupt to 'raise'
    );

/******************************************************************************/
/** \brief  this function clears a specific interrupt. The clear mechanism
 *          is currently available only for the context call back interrupt.
 *
 *  \param  kHandle : (In) handle to interrupt to 'clear'
 *
 *  \return tmErrorCode_t : error code
 *          - TMOSAL_ERR_OK               interrupt sucessfully cleared
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalIntClear(
    const tmosalIntHandle_t kHandle  // I: handle to interrupt to 'clear'
    );

/******************************************************************************/
/** \brief  this function creates a semaphore and returns a handle upon
 *          success. The creation flags are the following:\n
 *          - tmosalSemCreateFlagNone: create semaphore in the context of
 *            the current processor \n
 *          - tmosalSemGlobal: create a multi-processor shared semaphore
 *
 *  \param  kCount : (In) initial semaphore value
 *  \param  pioSemHandle : (Out) pointer to Handle returned upon success
 *  \param  kFlags : (In) flags
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                  the semaphore was sucessfully created
 *          - TMOSAL_ERR_BAD_PARAM   invalid parameter
 *          - TMOSAL_ERR_SEM_FULL    the max number of semaphores in the
 *                                   system has been exceeded
 *          - TMOSAL_ERR_UNKNOWN     os specific error
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalSemCreate(
    const UInt32 kCount,                    // I: initial semaphore value
    ptmosalSemHandle_t pioSemHandle,        // O: pointer to Handle returned
                                            //    upon success
    const tmosalSemCreateFlags_t    kFlags  // I: flags
    );

/******************************************************************************/
/** \brief  this function destroys a semaphore created by tmosalSemCreate.
 *
 *  \param  kSemHandle : (In) handle to semaphore to destroy
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                   the semaphore was sucessfully destoyed
 *          - TMOSAL_ERR_SEM_HANDLE   invalid semaphore handle
 *          - TMOSAL_ERR_SEM_TASK     tasks were waiting on the semaphore
 *
 *  \note   If one or more tasks are waiting on this semaphore the function
 *          will return an error. This error is informative only;
 *          the semaphore will be deleted and the tasks waiting will return
 *          with an error code
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalSemDestroy(
    const tmosalSemHandle_t kSemHandle   // I: handle to semaphore to destroy
    );

/******************************************************************************/
/** \brief  this function attemps to acquire the specified semaphore.
 *          The time value held in the pTimeout parameter may express
 *          negative time, tmosalSemAcquire treats it as a value of 0.
 *
 *  \param  kSemHandle : (In) handle to semaphore to be acquired
 *  \param  pkTimeout : (In) timeout pointer
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                     the semaphore was sucessfully
 *                                      acquired
 *          - TMOSAL_ERR_HANDLE         invalid semaphore handle
 *          - TMOSAL_ERR_SEM_TIMEOUT    the timeout expired
 *          - TMOSAL_ERR_SEM_DEL        the semaphore was deleted
 *          - TMOSAL_ERR_UNKNOWN        os specific failure
 *
 *  \note   set timeout to Null to wait with no timeout.
 *          set timeout value to 0 to test the semaphore without waiting
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalSemAcquire(
    const tmosalSemHandle_t kSemHandle,  // I: handle to semaphore to be acquired
    const pInt32 pkTimeout               // I: timeout pointer
    );

/******************************************************************************/
/** \brief  this function releases the specified counting semaphore
 *          previously created by tmosalSemCreate.  
 *
 *  \param  kSemHandle : (In) handle to semaphore to be released
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                      the semaphore was released
 *          - TMOSAL_ERR_HANDLE          invalid semaphore handle
 *          - TMOSAL_ERR_SEM_BOUND       attempt to exceed the initial count
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalSemRelease(
    const tmosalSemHandle_t kSemHandle  // I: handle to semaphore to be released
    );

/******************************************************************************/
/** \brief  this function creates a mutex and returns a handle. The
 *          creation flags are the following:
 *
 *          - tmosalMutexCreateFlagNone: create mutex in the context of
 *            the current processor
 *
 *  \param  pioMutexHandle : (Out) mutex handle pointer
 *  \param  kFlags : (In) Flags
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                       the mutex was sucessfully created
 *          - TMOSAL_ERR_BAD_PARAM        invalid parameter
 *          - TMOSAL_ERR_MUTEX_FULL       the max number of mutex in the
 *                                        system hasss been exceeded
 *          - TMOSAL_ERR_OUT_OF_MEMORY    not enough memory to create a mutex
 *          - TMOSAL_ERR_UNKNOWN          os specific error
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalMutexCreate(
    ptmosalMutexHandle_t pioMutexHandle,      // O: mutex handle pointer
    const tmosalMutexCreateFlags_t  kFlags   // I: flags
    );

/******************************************************************************/
/** \brief  this function destroys a mutex created by tmosalMutexCreate.
 *
 *  \param  kMutexHandle : (In) handle to smutex to be destroyed
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                 the mutex was sucessfully destoyed
 *          - TMOSAL_ERR_HANDLE     invalid mutex handle
 *          - TMOSAL_ERR_MUTEX_TASK tasks were waiting for this mutex
 *          - TMOSAL_ERR_UNKNOWN    os specific error
 *
 *  \note   If one or more tasks are waiting on this mutex the function
 *          will return an error. This error is informative only; the mutex
 *          will be deleted and the tasks waiting will return with an error
 *          code
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalMutexDestroy(
    const tmosalMutexHandle_t kMutexHandle // I: handle to mutex to be destroyed
    );

/******************************************************************************/
/** \brief  this function attemps to enter the specified mutex.
 *
 *          The time value held in the pTimeout parameter may express
 *          negative time, tmosalMutexEnter treats it as a value of 0.
 *
 *  \param  kMutexHandle : (In) handle to smutex to be entered
 *  \param  pkTimeout : (In) timeout pointer
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                       the mutex was successfully acquired
 *          - TMOSAL_ERR _HANDLE          invalid mutex handle
 *          - TMOSAL_ERR_MUTEX_TIMEOUT    the timeout expired
 *          - TMOSAL_ERR_UNKNOWN          os specific failure
 *
 *  \note   set timeout to Null to wait with no timeout. \n
 *          set timeout value to 0 to test the mutex without waiting.
 *          will be deleted and the tasks waiting will return with an error
 *          code
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalMutexEnter(
    const tmosalMutexHandle_t kMutexHandle,  // I: handle to mutex to be entered
    const pInt32 pkTimeout                   // I: timeout pointer
    );

/******************************************************************************/
/** \brief  this function exits a specific mutex.
 *
 *  \param  kMutexHandle : (In) handle to mutex to be exited
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK	            the mutex was sucessfully released
 *          - TMOSAL_ERR_HANDLE   invalid mutex handle
 *          - TMOSAL_ERR_MUTEX_NOTOWNED not the owner of the mutex
 *          - TMOSAL_ERR_UNKNOWN  os specific failure
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalMutexExit (
    const tmosalMutexHandle_t kMutexHandle   // I: handle to mutex to be exited
                );

/******************************************************************************/
/** \brief  this function temporarily disables interrupts. No task
 *          scheduling is performed while the interrupts are disabled.
 *
 *  \param  pioIntStatus : (In) pointer to interrupt status
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                       success
 *          - TMOSAL_ERR_BAD_PARAM    the pIntStatus pointer is Null
 *          - TMOSAL_ERR_UNKNOWN          os specific failure
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalDisableInterrupts(
    pUInt32 pioIntStatus          // O: pointer to interrupt status
    );


/******************************************************************************/
/** \brief  this function returns back the previous status 
 *          This can ONLY be used when the interrupts are disabled. 
 *
 *  \param  pioIntStatus : (In) pointer to interrupt status
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                       success
 *          - TMOSAL_ERR_CONTEXT          Not in Interrupt Disabled State
 *
 */
/******************************************************************************/
extern tmErrorCode_t 
tmosalGetLastInterruptStatus(
    pUInt32 pioIntStatus          // O: pointer to interrupt status
    );


/******************************************************************************/
/** \brief  this function enables interrupts.
 *
 *  \param  kIntStatus : (In) interrupt status
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                   success
 *          - TMOSAL_ERR_UNKNOWN      os specific failure
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalEnableInterrupts(
    const UInt32 kIntStatus    // I: pointer to interrupt status
    );

/******************************************************************************/
/** \brief  this function temporarily disables interrupts. No task
 *          scheduling is allowed while the interrupts are disabled.
 *
 *  \param  pioIntStatus : (In) pointer to interrupt status
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                       success
 *          - TMOSAL_ERR_BAD_PARAM        the pIntStatus pointer is Null
 *          - TMOSAL_ERR_UNKNOWN          os specific failure
 *
 */
/******************************************************************************/
tmErrorCode_t
tmosalDisableInterruptsNoSysCall (
    pUInt32 pioIntStatus
    );

/******************************************************************************/
/** \brief  this function enables interrupts.
 *
 *  \param  kIntStatusDummy : (In) dummy parameter
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                   success
 *          - TMOSAL_ERR_UNKNOWN      os specific failure
 *
 */
/******************************************************************************/
tmErrorCode_t
tmosalEnableInterruptsNoSysCall (
    const UInt32 kIntStatusDummy
    );

/******************************************************************************/
/** \brief  this function disables scheduler.
 *
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                   success
 *          - TMOSAL_ERR_UNKNOWN      os specific failure
 *
 */
/******************************************************************************/
tmErrorCode_t
tmosalDisableScheduler (
   void
   );

/******************************************************************************/
/** \brief  this function enables scheduler.
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                   success
 *          - TMOSAL_ERR_UNKNOWN      os specific failure
 *
 */
/******************************************************************************/
tmErrorCode_t
tmosalEnableScheduler (
    void
    );

#if !defined(TMFL_IC_PNX8335)

/******************************************************************************/
/** \brief  this function returns scheduler state.
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                   success
 *          - TMOSAL_ERR_UNKNOWN      os specific failure
 *
 */
/******************************************************************************/
UInt32
tmosalSchedulerState (
    void
    );

#endif /* #if !defined(TMFL_IC_PNX8335) */

/******************************************************************************/
/** \brief  this function creates an event and returns an event identifier.
 *          The creation flags may be used to specify the auto clear
 *          properties of the event. Set the flags to tmosalEventAutoClear
 *          if necessary. Set the flag tmosalEventCreateGlobal to create a
 *          multi-processor-shared event. The flags may be OR-ed together.
 *          Set the flags to tmosalEventCreateFlagNone for local, non auto
 *          clear events. If an event is created as non auto clear, a call
 *          to tmosalEventReset is required to clear the event.
 *
 *  \param  pioEventHandle : (Out) Event pointer
 *  \param  kFlags : (In) flags
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                       the event was sucessfully created
 *          - TMOSAL_ERR_BAD_PARAM        invalid input parameter
 *          - TMOSAL_ERR_EVT_FULL         the max number of events in the
 *                                        system has been exceeded
 *          - TMOSAL_ERR_OUT_OF_MEMORY    out of OSAL control memory
 *          - TMOSAL_ERR_UNKNOWN          os specific error
 *
 */
/******************************************************************************/
tmErrorCode_t
tmosalEventCreate(
    ptmosalEventHandle_t pioEventHandle,     // O: event pointer
    const tmosalEventCreateFlags_t  kFlags   // I: flags
    );

/******************************************************************************/
/** \brief  this function destroys an event created by tmosalEventCreate.
 *
 *  \param  kEventHandle : (In) event handle
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                   the event was sucessfully destoyed
 *          - TMOSAL_ERR_HANDLE       invalid event handle
 *          - TMOSAL_ERR_ERR_EVT_TASK tasks were waiting for the event when
 *                                    the event is deleted
 *          - TMOSAL_ERR_UNKNOWN      OS scpecific error
 *
 *  \note   if an event is destroyed while still in use in some other tasks,
 *          the behavior of the system becomes undefined. This situation
 *          must be avoided.
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalEventDestroy(
    const tmosalEventHandle_t kEventHandle   // I: event handle
    );

/******************************************************************************/
/** \brief  this function sends the event specified by eventHandle. If the
 *          event has already been sent, tmosalEventSend has no effect.
 *          
 *          Set the flag to tmosalEventSendFlagNone - flags reserved for
 *          future use.
 *
 *  \param  kEventHandle : (In) event handle
 *  \param  kFlags : (In) reserved
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                   the event was sucessfully sent
 *          - TMOSAL_ERR_HANDLE		invalid event handle
 *          - TMOSAL_ERR_UNKNOWN      OS specific error
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalEventSend(
    const tmosalEventHandle_t       kEventHandle,    // I: event handle
    const tmosalEventSendFlags_t    kFlags           // I: reserved
    );
/******************************************************************************/
/** \brief  this function waits for the event specified by eventHandle, for
 *          a specified amount of time.
 *          
 *          The time value held in the pTimeout parameter may express
 *          negative time, tmosalEventWait treats it as a value of 0.
 *          
 *          set the flag to tmosalEventWaitFlagNone - flags reserved for
 *          future use.
 *
 *  \param  kEventHandle : (In) event handle
 *  \param  pkTimeOut : (In) timer to wait
 *  \param  kFlags : (In) reserved
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                    the event was successfully received
 *          - TMOSAL_ERR_HANDLE        invalid event handle
 *          - TMOSAL_ERR_EVT_TIMEOUT   the timeout expired
 *          - TMOSAL_ERR_EVT_DEL       the event was deleted while waiting
 *          - TMOSAL_ERR_UNKNOWN       os specific failure
 *
 *  \note   set pTimeout to Null to wait for ever.
 */
/******************************************************************************/
extern tmErrorCode_t tmosalEventWait(
    const tmosalEventHandle_t kEventHandle,
    const pInt32 pkTimeOut,
    const tmosalEventWaitFlags_t kFlags
    );

/******************************************************************************/
/** \brief  this function resets the event specified by eventHandle. If the
 *          event has already been reset, tmosalEventReset has no effect.
 *
 *  \param  kEventHandle : (In) handler to event to be reset
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                   the event was sucessfully reset
 *          - TMOSAL_ERR_HANDLE       invalid event handle
 *          - TMOSAL_ERR_UNKNOWN      OS specific error
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalEventReset(
    tmosalEventHandle_t kEventHandle   // I: handler to event to be reset
    );

/******************************************************************************/
/** \brief  this function creates a queue of the specified size and packet
 *          size. Set the flags to tmosalQueueCreateGlobal to create a
 *          multi-processor shared queue. The flag tmosalQueueCreateFlagNone
 *          must be used for local queues.
 *          
 *          set the flag to tmosalQueueCreateFlagNone - flags reserved for
 *          future use.
 *
 *  \param  kMaxPackets : (In) queue size in packets
 *  \param  kMaxPacketSize : (In) packet size in bytes.
 *  \param  pioQueueHandle : (Out) handle pointer
 *  \param  kFlags : (In) reserved
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                       the queue was sucessfully created
 *          - TMOSAL_ERR_BAD_PARAM        invalid input parameter
 *          - TMOSAL_ERR_QUE_FULL         the max number of queues in the
 *                                        system has been exceeded
 *          - TMOSAL_ERR_UNKNOWN          os specific failure
 *          - TMOSAL_ERR_OUT_OF_MEMORY    out of OSAL control memory
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalQueueCreate(
    const UInt32                    kMaxPackets,     // I: queue size in packets
    const UInt32                    kMaxPacketSize,  // I: packet size in bytes.
    ptmosalQueueHandle_t            pioQueueHandle,   // O: handle pointer
    const tmosalQueueCreateFlags_t  kFlags           // I: reserved
    );

/******************************************************************************/
/** \brief  this function destroys a queue created with tmosalQueueCreate.
 *
 *  \param  kQueueHandle : (In) queue handle
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                   the queue was sucessfully destoyed
 *          - TMOSAL_ERR_HANDLE       invalid queue handle
 *          - TMOSAL_ERR_QUE_TASK     tasks were waiting on the queue
 *          - TMOSAL_ERR_UNKNOWN      os specific failure
 *
 *  \note   If one or more tasks are waiting on this queue the function
 *          will return an error. This error is informative only;the queue
 *          will be deleted and the tasks waiting will return with an error
 *          code.The minimum packet size for the queue packets is 4 bytes
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalQueueDestroy(
    const tmosalQueueHandle_t kQueueHandle   // I: queue handle
    );

/******************************************************************************/
/** \brief  this function enqueues a packet into the specified queue. If
 *          the queue is full it is possible to wait until it has space for
 *          the present packet, by setting the timer value pointed by
 *          pTimeout.
 *          
 *          The time value held in the pTimeout parameter may express
 *          negative time, tmosalQueueSend treats it as a value of 0.
 *          
 *          set the flag to tmosalQueueSendFlagNone - flags reserved for
 *          future use.
 *
 *  \param  kQueueHandle : (In) queue handle
 *  \param  pkBuffer : (In) packet pointer
 *  \param  kPacketSize : (In) packet size
 *  \param  pkTimeout : (In) time-out pointer
 *  \param  kFlags : (In) reserved
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                       the packet was successfully sent
 *          - TMOSAL_ERR_HANDLE           invalid queue handle
 *          - TMOSAL_ERR_QUE_BUFFER       NULL buffer pointer
 *          - TMOSAL_ERR_QUE_TIMEOUT      the timeout expired
 *            TMOSAL_ERR_BAD_PARAM        invalid packet size
 *          -                             (defined upon creation)
 *            TMOSAL_ERR_UNKNOWN          os specific failure
 *
 *  \note   set the pTimeout pointer to Null to send without timeout.
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalQueueSend(
    const tmosalQueueHandle_t kQueueHandle,  // I: queue handle
    const Pointer pkBuffer,                  // I: packet pointer
    const UInt32 kPacketSize,                // I: packet size
    const pInt32 pkTimeout,                  // I: timerout pointer
    const tmosalQueueSendFlags_t kFlags      // I: reserved
    );

/******************************************************************************/
/** \brief  this function dequeues the next packet from the specified queue
 *          
 *          The time value held in the pTimeout parameter may express
 *          negative time; tmosalQueueReceive treats it as a value of 0.
 *          
 *          set the flag to tmosalQueueReceiveFlagNone - flags reserved for
 *          future use.
 *
 *  \param  kQueueHandle : (In) a packet was successfully received
 *  \param  pioBuffer : (In) pointer reception buffer.
 *  \param  pioPacketSize : (In) received packet size
 *  \param  pkTimeout : (In) pointer to timeout value
 *  \param  kFlags : (In) flags reserved for future use
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                       a packet was successfully received
 *          - TMOSAL_ERR_HANDLE           invalid queue handle
 *          - TMOSAL_ERR_BAD_PARAM        invalid input parameter
 *          - TMOSAL_ERR_QUE_TIMEOUT      the timeout expired
 *          - TMOSAL_ERR_QUE_DEL          the queue was deleted while waiting
 *          - TMOSAL_ERR_UNKNOWN          os specific failure
 *
 *  \note   set the pTimeout pointer to Null to receive without timeout.   
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalQueueReceive(
    const tmosalQueueHandle_t kQueueHandle,  // I: handler to queue
    Pointer pioBuffer,                        // I: pointer reception buffer.
    pUInt32 pioPacketSize,                    // I: received packet size
    const pInt32 pkTimeout,                  // I: pointer to timeout value
    const tmosalQueueReceiveFlags_t kFlags   // I: flags reserved for future use
    );

/******************************************************************************/
/** \brief  this function returns the size of the packet present on top of
 *          the queue.
 *
 *  \param  kQueueHandle : (In) a packet was successfully received
 *  \param  pioPacketSize : (In) queue packet size
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK                       a packet was successfully received
 *          - TMOSAL_ERR_QUE_EMPTY        the queue is empty
 *          - TMOSAL_ERR_HANDLE           invalid queue handle
 *          - TMOSAL_ERR_BAD_PARAM        the pPacketSize pointer is Null
 *          - TMOSAL_ERR_UNKNOWN          os specific failure
 *
 */
/******************************************************************************/
extern tmErrorCode_t
tmosalQueueGetPacketSize(
    const tmosalQueueHandle_t kQueueHandle,  // I: handler to queue
    pUInt32 pioPacketSize                     // I: queue packet size
    );

/******************************************************************************/
/** \brief  This function flush the entire cache with Write-Back of the
 *          content of the cache in memory. The cache can be
 *          the instruction, data or unified cache according to the type
 *          of cache chosen as parameter.
 *
 *  \param  cacheType : (In) cache type
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK			The cache was successfully flushed
 *          - TMOSAL_ERR_BAD_CACHE_TYPE	Bad cache type parameter
 *
 */
/******************************************************************************/
tmErrorCode_t	tmosalFlushWithWB (
    tmosalCacheType_t cacheType
    );

/******************************************************************************/
/** \brief  This function flushes the entire cache without Write-Back
 *          of the content of the cache in memory. This function should
 *          be used very carefully, because AFTER its usage, all the
 *          CONTENT of the CACHE IS LOST irrecoverably. The cache can
 *          be the instruction, data or unified cache according to the
 *          type of cache chosen as parameter.
 *
 *  \param  cacheType : (In) cache type
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK			The cache was successfully flushed
 *          - TMOSAL_ERR_BAD_CACHE_TYPE	Bad cache type parameter
 *
 */
/******************************************************************************/
tmErrorCode_t	tmosalFlushWithoutWB (
    tmosalCacheType_t cacheType
    );

/******************************************************************************/
/** \brief  This function invalidates a portion of memory from cache and
 *          Write-Back the content of this portion of cache in memory if
 *          required. The function accepts the base address and size of
 *          the portion of memory to be invalidated. If the lines containing
 *          these memory locations are currently in the cache, they are
 *          invalidated and copy in memory. The cache can be the
 *          instruction, data or unified cache according to the type
 *          of cache chosen as parameter.
 *          
 *  \param  cacheType : (In) cache type
 *  \param  pkAddress : (In) base address
 *  \param  bytesNumber : (In) size of the memory area to invalidate
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK			The cache was successfully flushed
 *          - TMOSAL_ERR_BAD_CACHE_TYPE	Bad cache type parameter
 *
 */
/******************************************************************************/
tmErrorCode_t	tmosalCacheInvalidateWithWB (
    tmosalCacheType_t cacheType,
    pUInt32 pkAddress,
    UInt32 bytesNumber
    );

/******************************************************************************/
/** \brief  This function invalidates a portion of cache but DO NOT
 *          Write-Back the content of this portion in memory. The function
 *          accepts the base address and size of the portion to be
 *          invalidated. If the lines containing these memory locations
 *          are currently in the cache, they are invalidated. This function
 *          should be used very carefully, because after its usage, all
 *          the portion of the cache is lost irrecoverably The cache can
 *          be the instruction, data or unified cache according to the
 *          type of cache chosen as parameter.
 *
 *  \param  cacheType : (In) cache type
 *  \param  pkAddress : (In) base address
 *  \param  bytesNumber : (In) size of the memory area to invalidate
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK			The cache was successfully flushed
 *          - TMOSAL_ERR_BAD_CACHE_TYPE	Bad cache type parameter
 *
 */
/******************************************************************************/
tmErrorCode_t	tmosalCacheInvalidateWithoutWB (
    tmosalCacheType_t cacheType,
    pUInt32 pkAddress,
    UInt32 bytesNumber
    );

/******************************************************************************/
/** \brief  This function returns the statistics (current/max) number of OSAL
 *          objects(queue, mutex, semaphore, event)
 *          created at the time of the function call.
 *
 *  \param  pioStat : (Out) statistic counters
 *
 *  \return tmErrorCode_t : error code
 *          - TM_OK			Statistic successfully retrieved
 *
 *  \note   The statistic counters are updated only when DV_DEBUG is defined.
 */
/******************************************************************************/
tmErrorCode_t	tmosalGetStatistic (
    ptmosalStatistic_t pioStat
    );

#define    TMOSAL_ERR_MUTEX_NOT_OWNED TMOSAL_ERR_MUTEX_NOTOWNED
#define    TMOSAL_ERR_SEM_NOTACQUIRED TMOSAL_ERR_SEM_BOUND

#if TMFL_MODE_KERNEL

/******************************************************************************/
/** \brief  This function checks if given task exists, and if yes, then sleeps
 *          until it exits.
 *
 *  \param  kTaskHandle : (In) Task to look at
 *
 *  \note   Function will sleep forever if the task has crashed.
 */
/******************************************************************************/
void tmosalTaskWaitForExit(tmosalTaskHandle_t kTaskHandle);

#ifdef CONFIG_FW_LOADER
/******************************************************************************/
/** \brief  This function gets firmware binaries
 *          Only enabled if FIRMWARE support is enabled in the kernel.
 *
 *  \param  name           : name of firmware file
 *          firmware       : buffer to receive binary firmware
 *          buffer_size    : size of firmware buffer (in bytes)
 *          recovered_size : size of recovered firmware (in bytes)
 *
 */
/******************************************************************************/
tmErrorCode_t tmosalRequestFirmware(const char *name, uint8_t *firmware, uint32_t buffer_size, uint32_t *recovered_size);
#endif

#endif /* #if TMFL_MODE_KERNEL */

#ifdef __cplusplus
}
#endif

#endif // TMOSAL_H
