123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240 |
- /*
- * Copyright (c) 2015 - 2017, Texas Instruments Incorporated
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- *
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- *
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- *
- * * Neither the name of Texas Instruments Incorporated nor the names of
- * its contributors may be used to endorse or promote products derived
- * from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
- * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
- * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
- * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
- /** ============================================================================
- * @file osal.h
- *
- * @brief OS Abstraction Layer header
- *
- * ============================================================================
- */
- #ifndef ti_OSAL__include
- #define ti_OSAL__include
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include <ti/osal/HwiP.h>
- #include <ti/osal/MuxIntcP.h>
- #include <ti/osal/SemaphoreP.h>
- #include <ti/osal/CacheP.h>
- #include <ti/osal/TimerP.h>
- #include <ti/osal/RegisterIntr.h>
- #include <ti/osal/Queue.h>
- #ifdef _TMS320C6X
- #include <ti/osal/EventCombinerP.h>
- #endif
- #define osal_OK (0)
- #define osal_FAILURE (-(int32_t)(1))
- #define osal_UNSUPPORTED (-(int32_t)(2))
- /* Set the number of SemaphoreP_Handles for TIRTOS */
- #ifndef OSAL_TIRTOS_CONFIGNUM_SEMAPHORE
- #define OSAL_TIRTOS_CONFIGNUM_SEMAPHORE ((uint32_t)100U)
- #endif
- /* Set the number of TimerP_Handles for TIRTOS */
- #ifndef OSAL_TIRTOS_CONFIGNUM_TIMER
- #define OSAL_TIRTOS_CONFIGNUM_TIMER ((uint32_t)100U)
- #endif
- /* Set the number of HwiP_Handles for TIRTOS */
- #ifndef OSAL_TIRTOS_CONFIGNUM_HWI
- #define OSAL_TIRTOS_CONFIGNUM_HWI ((uint32_t)100U)
- #endif
- /**
- * \brief This structure holds static memory status parameters of OSAL
- * library
- */
- typedef struct Osal_StaticMemoryStatus
- {
- uint32_t peakSemObjs;
- uint32_t numMaxSemObjs;
- uint32_t numFreeSemObjs;
- uint32_t peakTimerObjs;
- uint32_t numMaxTimerObjs;
- uint32_t numFreeTimerObjs;
- uint32_t peakHwiObjs;
- uint32_t numMaxHwiObjs;
- uint32_t numFreeHwiObjs;
- } Osal_StaticMemStatus;
- typedef enum Osal_ThreadType_e {
- Osal_ThreadType_Hwi, /*!< Current thread is a Hwi */
- Osal_ThreadType_Swi, /*!< Current thread is a Swi */
- Osal_ThreadType_Task, /*!< Current thread is a Task */
- Osal_ThreadType_Main /*!< Current thread is Main */
- } Osal_ThreadType;
- #ifdef __KLOCWORK__
- extern void abort(void);
- /* tell klockwork that OSAL_Assert(1) is fatal */
- #define OSAL_Assert(x) do { if ((x)) { abort(); } } while (0)
- #else
- /* Internal function for assert */
- extern void _DebugP_assert(int32_t expression, const char *file, int32_t line);
- /*!
- * @brief Assert checking function
- *
- * If the expression is evaluated to true, the API does nothing.
- * If it is evaluated to false, the underlying RTOS port implementation
- * handles the assert via its mechanisms.
- *
- * @param expression Expression to evaluate
- */
- /* in real code use TI's version of OSAL_Assert (which is also fatal for OSAL_Assert(1)*/
- #define OSAL_Assert(expression) (_DebugP_assert((expression), \
- __FILE__, __LINE__))
- #endif
- /*!
- * @brief Function to get the current thread type.
- *
- * @param none
- *
- * @return current thread type
- */
- extern Osal_ThreadType Osal_getThreadType(void);
- /*!
- * @brief Function to get the delay/sleep.
- *
- * @param nTicks number of ticks
- *
- * #@note for bare metal application it is number of 1ms ticks
- *
- * Prerequisites: Board_init() to be called before
- * invoking this API
- *
- * @return osal_OK for success, osal_FAILURE on failure
- */
- extern int32_t Osal_delay(uint32_t nTicks);
- /*!
- * @brief Osal hw access type
- *
- */
- typedef enum {
- OSAL_HWACCESS_UNRESTRICTED, /* No restriction on hardware access or configuration */
- OSAL_HWACCESS_RESTRICTED /* Restrictive access to hardware such as GIC */
- } Osal_HwAccessType;
- /*!
- * @brief Osal hw attributes structure
- *
- */
- typedef struct Osal_HwAttrs_s
- {
- /* External Clock value in KHz */
- int32_t extClkKHz;
- #ifdef _TMS320C6X
- int32_t ECM_intNum[4]; /* Interrupt numbers for Event combiner groups (0-3)*/
- #endif
- Osal_HwAccessType hwAccessType;
- /* Below timer base configuration is applicable for only AM335x/AM437x SoCs
- * It is not applicable and should not be set for other SoCs
- * Osal setHwAttrs API would return failure (osal_UNSUPPORTED) if attempted to
- * be set for SoCs other than AM335x and AM437x.
- */
- uintptr_t osalDelayTimerBaseAddr;
- } Osal_HwAttrs;
- /*!
- * bit map to set external clock in Osal_HwAttr default value
- */
- #define OSAL_HWATTR_SET_EXT_CLK (0x00000001U)
- /*!
- * bit map to set Event combiner interrupt numbers in the Osal_HwAttr
- */
- #define OSAL_HWATTR_SET_ECM_INT (0x00000002)
- /*!
- * bit map to set the hardware access type
- */
- #define OSAL_HWATTR_SET_HWACCESS_TYPE (0x00000004)
- /*!
- * bit map to set the osal_delay Timer base address
- */
- #define OSAL_HWATTR_SET_OSALDELAY_TIMER_BASE (0x00000008)
- /*!
- * @brief Function to set the Hw Attributes
- *
- * @param control bit map as defined by the OSAL_HWATTR_SET control bits
- *
- * @param hwAttrs pointer to Osal_HwAttrs structure
- *
- * @return osal_OK for success, osal_FAILURE on failure and
- * osal_UNSUPPORTED for unsupported configurations
- * osal_UNSUPPORTED is a non fatal error and applications
- * can continue processing if they get this error code.
- * Osal would be configured to utilize default timer for
- * Osal_delay() API. The default timer address for AM437x and
- * AM335x SoCs are found under ti/osal/soc/<soc_part>/osal_soc.h
- * For other SoCs the time base address is not applicable and
- * the API returns osal_UNSUPPORTED as the return value.
- */
- extern int32_t Osal_setHwAttrs(uint32_t ctrlBitMap, const Osal_HwAttrs *hwAttrs);
- /*!
- * @brief Function to get the Hw Attributes
- *
- * @param hwAttrs pointer to Osal_HwAttrs structure
- *
- * @return osal_OK for success, osal_FAILURE on failure
- */
- extern int32_t Osal_getHwAttrs(Osal_HwAttrs *hwAttrs);
- /*!
- * @brief Function to get the static memory usage of OSAL library
- *
- * @param pMemStat pointer to Osal_StaticMemStatus structure
- *
- * @return osal_OK for success, osal_FAILURE on failure
- */
- extern int32_t Osal_getStaticMemStatus(Osal_StaticMemStatus *pMemStat);
- #ifdef __cplusplus
- }
- #endif
- #endif /* ti_OSAL__include */
|