File indexing completed on 2025-05-11 08:24:08
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #include <rtems.h>
0023 #include <bsp.h>
0024 #include <shm_driver.h>
0025
0026
0027
0028
0029
0030 void Shm_Initialize_lock(
0031 Shm_Locked_queue_Control *lq_cb
0032 )
0033 {
0034 lq_cb->lock = LQ_UNLOCKED;
0035 }
0036
0037
0038
0039
0040
0041
0042 extern unsigned int LEON3_Atomic_Swap(uint32_t value, uint32_t *address);
0043
0044 __asm__ (
0045 ".text\n"
0046 ".align 4\n"
0047 "LEON3_Atomic_Swap:\n"
0048 " retl\n"
0049 " swapa [%o1] 1, %o0\n"
0050 );
0051
0052
0053
0054 void Shm_Lock(
0055 Shm_Locked_queue_Control *lq_cb
0056 )
0057 {
0058 uint32_t isr_level;
0059 uint32_t *lockptr = (uint32_t *) &lq_cb->lock;
0060 uint32_t lock_value;
0061
0062 lock_value = SHM_LOCK_VALUE;
0063 rtems_interrupt_disable( isr_level );
0064
0065 Shm_isrstat = isr_level;
0066 while ( lock_value ) {
0067 lock_value = LEON3_Atomic_Swap(lock_value, lockptr);
0068
0069
0070
0071 }
0072 }
0073
0074
0075
0076
0077
0078
0079
0080 void Shm_Unlock(
0081 Shm_Locked_queue_Control *lq_cb
0082 )
0083 {
0084 uint32_t isr_level;
0085
0086 lq_cb->lock = SHM_UNLOCK_VALUE;
0087 isr_level = Shm_isrstat;
0088 rtems_interrupt_enable( isr_level );
0089 }
0090