/* =========================================================================
 *  Copyright 2019-2022 NXP
 *
 *  NXP Confidential. This software is owned or controlled by NXP and may only
 *  be used strictly in accordance with the applicable license terms. By
 *  expressly accepting such terms or by downloading, installing, activating
 *  and/or otherwise using the software, you are agreeing that you have read,
 *  and that you agree to comply with and are bound by, such license terms. If
 *  you do not agree to be bound by the applicable license terms, then you may
 *  not retain, install, activate or otherwise use the software.
 *  <<< PFE Restricted Software >>>
 *
 * ========================================================================= */

/**
 * @addtogroup  dxgr_OAL_SYNC
 * @{
 *
 * @file        oal_spinlock_qnx.h
 * @brief       The QNX-specific spinlock implementation.
 * @details     This file contains QNX-specific spinlock implementation.
 *
 */

#ifndef PUBLIC_OAL_SPINLOCK_AUTOSAR_H_
#define PUBLIC_OAL_SPINLOCK_AUTOSAR_H_

/*==================================================================================================
*                                     FILE VERSION CHECK
==================================================================================================*/
#ifdef PFE_SRC_VERSION_CHECK
    #if (PFE_SRC_VERSION_CHECK != 43100440)
        #error "This header file was included from incompatible source file (different SW version)"
    #endif
#else
    #define PFE_SRC_VERSION_CHECK 43100440
#endif

#include "oal_mutex_autosar.h"

typedef oal_mutex_t oal_spinlock_t;

#define ETH_43_PFE_START_SEC_CODE
#include "Eth_43_PFE_MemMap.h"

/** @}*/
/*  Implementation continues below to ensure Doxygen will put the API description
    from oal_sync.h at right place (related to oal_sync.h header). */

static inline errno_t oal_spinlock_init(oal_spinlock_t *spinlock)
{
    return oal_mutex_init((oal_mutex_t *)spinlock);
}

static inline errno_t oal_spinlock_destroy(oal_spinlock_t *spinlock)
{
    return oal_mutex_destroy((oal_mutex_t *)spinlock);
}

static inline errno_t oal_spinlock_lock(oal_spinlock_t *spinlock)
{
    return oal_mutex_lock((oal_mutex_t *)spinlock);
}

static inline errno_t oal_spinlock_unlock(oal_spinlock_t *spinlock)
{
    return oal_mutex_unlock((oal_mutex_t *)spinlock);
}

#define ETH_43_PFE_STOP_SEC_CODE
#include "Eth_43_PFE_MemMap.h"

#endif /* PUBLIC_OAL_SPINLOCK_AUTOSAR_H_ */

