/* original file for GNU */


#include "rt_TypeDef.h"
#include "RTX_Config.h"
#include "rt_HAL_CA.h"


#if defined (__CC_ARM)          /* ARM Compiler */

#elif defined (__GNUC__)        /* GNU Compiler */

#ifndef __CMSIS_GENERIC

/*__attribute__((always_inline)) static inline */void __enable_irq(void)
{
	__asm volatile ("cpsie i");
}

/*__attribute__((always_inline)) static  inline */U32 __disable_irq(void)
{
	uint32_t result;

	__asm volatile ("mrs %0, cpsr" : "=r" (result));
	__asm volatile ("cpsid i");
	 return(result & 0x80);
}

/*__attribute__((always_inline)) static inline */int __strex(unsigned int val, volatile void *ptr)
{
#if 1
	int ret;

    __asm volatile ("strexb %0, %2, [%1]" : "=&r" (ret) : "r" (ptr), "r" (val));

	return ret;
#else
	*(unsigned int *)ptr = val;
	return 0;
#endif
}

/*__attribute__((always_inline)) static inline */void __clrex(void)
{
	__asm volatile ("clrex");
}

/*__attribute__((always_inline)) static inline */unsigned int __ldrex(volatile void *ptr)
{
#if 1
	uint8_t val;

	__asm volatile ("ldrexb %0, [%1]" : "=r" (val) : "r" (ptr));
	return (unsigned int)val;
#else
	return *(unsigned int *)ptr;
#endif
}

#endif

#elif defined (__ICCARM__)      /* IAR Compiler */

#error IAR Compiler support not implemented for Cortex-A

#endif

/*----------------------------------------------------------------------------
 * end of file
 *---------------------------------------------------------------------------*/

