/***************************************************************************
	XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" AS A 
	COURTESY TO YOU.  BY PROVIDING THIS DESIGN, CODE, OR INFORMATION AS
	ONE POSSIBLE   IMPLEMENTATION OF THIS FEATURE, APPLICATION OR 
	STANDARD, XILINX IS MAKING NO REPRESENTATION THAT THIS IMPLEMENTATION
	IS FREE FROM ANY CLAIMS OF INFRINGEMENT, AND YOU ARE RESPONSIBLE 
	FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE FOR YOUR IMPLEMENTATION.  
	XILINX EXPRESSLY DISCLAIMS ANY WARRANTY WHATSOEVER WITH RESPECT TO 
	THE ADEQUACY OF THE IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO 
	ANY WARRANTIES OR REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE 
	FROM CLAIMS OF INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY 
	AND FITNESS FOR A PARTICULAR PURPOSE.
$Id: libmutex.c,v 1.1.2.1 2003/03/12 22:27:45 mohan Exp $
***************************************************************************/
/**************************************************************************/
/**
 * @file libmutex.c
 *
 * This contains system call wrapper functions for Mutex
 * The system call wrapper functions are put in a library libw.a and is used
 * by application program to make system calls.
 ***************************************************************************/
#include <sys/syscall.h>
#include <sys/mutex.h>
#include <os_config.h>
#ifdef MICROBLAZE
#include <sys/mblaze_asm.h>
#define do_syscall(num,p1,p2,p3,p4,p5)  JMP_SYSCALL_HANDLER(num)
/*
 * The register r18 contains the system call number.
 * Branch is then made to the system call handler routine.
 */
#else
void *do_syscall(int syscall_num, void *param1, void *param2, void *param3, void *param4, void *param5);
#endif

#ifdef CONFIG_MUTEX
/**************************************************************************/
/**
 * 
 ***************************************************************************/
int mutex_init( mutex **mymutex ) 
{
	return (int) do_syscall( _MB_Mutex_Init , (void *)mymutex, 0,0,0,0) ;
}

/**************************************************************************/
/**
 * 
 ***************************************************************************/
int mutex_lock( mutex *mymutex ) 
{
	return (int) do_syscall( _MB_Mutex_Lock , (void *)mymutex, 0,0,0,0) ;
}

/**************************************************************************/
/**
 * 
 ***************************************************************************/
int mutex_unlock( mutex *mymutex ) 
{
	return (int) do_syscall( _MB_Mutex_Unlock , (void *)mymutex, 0,0,0,0) ;
}

/**************************************************************************/
/**
 * 
 ***************************************************************************/
int mutex_destroy( mutex *mymutex ) 
{
	return (int) do_syscall( _MB_Mutex_Destroy , (void *)mymutex, 0,0,0,0) ;
}

#endif
