forked from PAWPAW-Mirror/lib_xua
Added lock files
This commit is contained in:
55
module_usb_aud_shared/locks/lock.S
Normal file
55
module_usb_aud_shared/locks/lock.S
Normal file
@@ -0,0 +1,55 @@
|
||||
/** lock.S
|
||||
* @brief Functions for using hardware locks
|
||||
* @author Ross Owen, XMOS Limited
|
||||
*/
|
||||
|
||||
#include <xs1_user.h>
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// void GetLockResource()
|
||||
.extern GetLockResource
|
||||
.globl GetLockResource.nstackwords
|
||||
.linkset GetLockResource.nstackwords, 0
|
||||
.globl GetLockResource
|
||||
.text
|
||||
GetLockResource:
|
||||
getr r0, XS1_RES_TYPE_LOCK
|
||||
retsp 0
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// void ClaimLock(lock l)
|
||||
.extern ClaimLock
|
||||
.globl ClaimLock.nstackwords
|
||||
.linkset ClaimLock.nstackwords, 0
|
||||
.globl ClaimLock
|
||||
.text
|
||||
ClaimLock:
|
||||
in r0, res[r0]
|
||||
retsp 0
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// void FreeLock(lock l)
|
||||
.extern FreeLock
|
||||
.globl FreeLock.nstackwords
|
||||
.linkset FreeLock.nstackwords, 0
|
||||
.globl FreeLock
|
||||
.text
|
||||
FreeLock:
|
||||
out res[r0], r0
|
||||
retsp 0
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////
|
||||
// void FreeLockResource(lock l)
|
||||
.extern FreeLockResource
|
||||
.globl FreeLockResource.nstackwords
|
||||
.linkset FreeLockResource.nstackwords, 0
|
||||
.globl FreeLockResource
|
||||
.text
|
||||
FreeLockResource:
|
||||
freer res[r0]
|
||||
retsp 0
|
||||
|
||||
|
||||
25
module_usb_aud_shared/locks/lock.h
Normal file
25
module_usb_aud_shared/locks/lock.h
Normal file
@@ -0,0 +1,25 @@
|
||||
/** @file lock.h
|
||||
* @brief Functions for using hardware locks
|
||||
* @author Ross Owen, XMOS Limited
|
||||
*/
|
||||
|
||||
#ifndef _LOCK_H_
|
||||
#define _LOCK_H_ 1
|
||||
|
||||
typedef unsigned lock;
|
||||
|
||||
/* Allocates and returns a lock resource - returns 0 if out of lock */
|
||||
lock GetLockResource() ;
|
||||
|
||||
/* Claims the passed lock, this is a blocking call */
|
||||
void ClaimLock(lock l);
|
||||
|
||||
/* Frees the passed lock */
|
||||
void FreeLock(lock l);
|
||||
|
||||
/* De-allocated the passed lock resource */
|
||||
void FreeLockResource(lock l);
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user