/* Copyright (c) 2018-2023, NVIDIA CORPORATION. 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 NVIDIA CORPORATION 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 ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef OSA__OSA_VALUES_H
#define OSA__OSA_VALUES_H
#define FSP__OSA__OSA_VALUES_H                          1

/* Compiler headers */

/* Early FSP headers */

/* Hardware headers */

/* Late FSP headers */

/* Module-specific FSP headers */
#include <ospl/rtos-port.h>             // for rtosMutexHandle, FSP__OSPL__RTOS_PORT_H
#include <eventGroupsAPI.h>             // for evgrpCLEAR_EVENTS_ON_EXIT_BIT, evgrpWAIT_FO...
#include <taskAPI.h>                    // for taskNOTIFICATION_NO_ACTION
#include <semaphoreAPI.h>               // for semSEM_GIVE_BLOCK_TIME
#include <evtmplxAPI.h>                 // for evtmplxQUEUE_MESSAGE_WAITING, ...
#include <projdefs.h>                   // for pdTRUE, pdFALSE

/**
 * @defgroup RTOS_VALUES Mapping of SafeRTOS values to RTOS value space
 * @{
 */
/** Defines true state of a Boolean variable */
#define rtosTRUE                                ((rtosBool)pdTRUE)
/** Defines false state of a Boolean variable */
#define rtosFALSE                               ((rtosBool)pdFALSE)
/** Defines return value indicating success */
#define rtosPASS                                pdPASS
/** Defines return value indicating failure */
#define rtosFAIL                                pdFAIL
/** @} */

/**
 * @defgroup RTOS_KERNEL_VERSION Mapping of SafeRTOS kernel version values to RTOS value space
 * @{
 */
/** Defines kernel major version number */
#define rtosKERNEL_MAJOR_VERSION                pdKERNEL_MAJOR_VERSION
/** Defines kernel minor version number */
#define rtosKERNEL_MINOR_VERSION                pdKERNEL_MINOR_VERSION
/** @} */

/**
 * @defgroup RTOS_EVENT_GROUP_VALUES Mapping of SafeRTOS event group values to RTOS value space
 * @{
 */
/** Defines bitmask mapped to eventgroup control flag set to clear event group bits on exit */
#define rtosEVENTGRP_CLEAR_EVENTS_ON_EXIT       evgrpCLEAR_EVENTS_ON_EXIT_BIT
/** Defines bitmask mapped to eventgroup control flag, set to wait until all the requested event group bits are set*/
#define rtosEVENTGRP_WAIT_FOR_ALL_BITS          evgrpWAIT_FOR_ALL_BITS
/** @} */

/**
 * @defgroup RTOS_MUTEX_VALUES Mapping of SafeRTOS mutex values to RTOS value space
 * @{
 */
/** Defines state of a mutex object indicating lock is available */
#define rtosMUTEX_TAKEN                         mutexTAKEN
/** Defines state of a mutex object indicating lock is acquired */
#define rtosMUTEX_AVAILABLE                     mutexAVAILABLE
/** @} */

/**
 * Defines macro to be used for setting semaphore block time as 0.
 */
#define rtosSEMA_GIVE_NOBLOCK                   semSEM_GIVE_BLOCK_TIME

/**
 * @defgroup RTOS_TASK_VALUES Mapping of SafeRTOS task values to RTOS value space
 * @{
 */
/** Sending task shall use this macro if no update is needed to the receiving task  notification value */
#define rtosNotification_NO_ACTION                      taskNOTIFICATION_NO_ACTION
/** Sending task shall use this  macro to update notification value of receiving task by  ORing it with the sent value of the receiving task */
#define rtosNotification_SET_BITS                       taskNOTIFICATION_SET_BITS
/** Sending task shall use this macro to increment notification value of the receiving task */
#define rtosNotification_INCREMENT                      taskNOTIFICATION_INCREMENT
/** Sending task shall use this macro to set notification value of the receiving task with overwrite even if the previous notification is pending
*/
#define rtosNotification_SET_VALUE_WITH_OVERWRITE       taskNOTIFICATION_SET_VALUE_WITH_OVERWRITE
/** Sending task shall use this macro to set notification value of the receiving task only if there is no previous notification pending */
#define rtosNotification_SET_VALUE_WITHOUT_OVERWRITE    taskNOTIFICATION_SET_VALUE_WITHOUT_OVERWRITE
/**  Defines state of a task indicating it's not waiting for any notification*/
#define rtosNotification_NOT_WAITING                    taskNOTIFICATION_NOT_WAITING
/** Defines state of a task indicating it's waiting for a notification */
#define rtosNotification_WAITING                        taskNOTIFICATION_WAITING
/** Defines state of a task indicating it has sent the notification */ 
#define rtosNotification_NOTIFIED                       taskNOTIFICATION_NOTIFIED
/** Defines priority of an idle task */
#define rtosIDLE_PRIORITY                               taskIDLE_PRIORITY
/** @} */

/**
 * @defgroup RTOS_EVENTPOLL_VALUES Mapping of SafeRTOS event poll values to RTOS value space
 * @{
 */
/** Defines event for a queue object indicating the queue contains at least one message waiting to be received */
#define rtosEventPollQUEUE_MESSAGE_WAITING         evtmplxQUEUE_MESSAGE_WAITING
/** Defines event for a queue object indicating the queue has space for at least one message to be sent*/
#define rtosEventPollQUEUE_SPACE_AVAILABLE         evtmplxQUEUE_SPACE_AVAILABLE
/** Defines event for a semaphore object indicating it is available*/
#define rtosEventPollSEMAPHORE_AVAILABLE           evtmplxSEMAPHORE_AVAILABLE
/** Defines event for a mutex object indicating it is available*/
#define rtosEventPollMUTEX_AVAILABLE               evtmplxMUTEX_AVAILABLE
/** Defines event for a task indicating it has received a notification */
#define rtosEventPollTASK_NOTIFICATION_RECEIVED    evtmplxTASK_NOTIFICATION_RECEIVED
/** Defines event for an eventgroup object indicating requested eventgroup bits are set*/
#define rtosEventPollEVENT_GROUP_BITS_SET          evtmplxEVENT_GROUP_BITS_SET
/** @} */

#endif
