From a5430bfa1bc1dd90a39c756a49a3f46a56f40e45 Mon Sep 17 00:00:00 2001 From: Ross Owen Date: Mon, 5 Mar 2012 13:15:21 +0000 Subject: [PATCH] Added lock files --- module_usb_aud_shared/locks/lock.S | 55 ++++++++++++++++++++++++++++++ module_usb_aud_shared/locks/lock.h | 25 ++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 module_usb_aud_shared/locks/lock.S create mode 100644 module_usb_aud_shared/locks/lock.h diff --git a/module_usb_aud_shared/locks/lock.S b/module_usb_aud_shared/locks/lock.S new file mode 100644 index 00000000..5e2e10da --- /dev/null +++ b/module_usb_aud_shared/locks/lock.S @@ -0,0 +1,55 @@ +/** lock.S + * @brief Functions for using hardware locks + * @author Ross Owen, XMOS Limited + */ + +#include + +///////////////////////////////////////////////////////////////////////// +// 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 + + diff --git a/module_usb_aud_shared/locks/lock.h b/module_usb_aud_shared/locks/lock.h new file mode 100644 index 00000000..b6712b75 --- /dev/null +++ b/module_usb_aud_shared/locks/lock.h @@ -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