void spin_lock_release(volatile swlock_t *lock, hwlock_t hwlock) { __hwlock_acquire(hwlock); *lock = 0; __hwlock_release(hwlock); }
int get_queue_entry(mii_queue_t *q) { int i=0; int rdIndex, wrIndex; #ifndef ETHERNET_USE_HARDWARE_LOCKS swlock_acquire((swlock_t *) q->lock); #else __hwlock_acquire(ethernet_memory_lock); #endif rdIndex = q->rdIndex; wrIndex = q->wrIndex; if (rdIndex == wrIndex) i = 0; else { i = q->fifo[rdIndex]; rdIndex++; rdIndex *= (rdIndex != MAC_MAX_ENTRIES); q->rdIndex = rdIndex; } #ifndef ETHERNET_USE_HARDWARE_LOCKS swlock_release((swlock_t *) q->lock); #else __hwlock_release(ethernet_memory_lock); #endif return i; }
void media_input_fifo_enable_fifos(unsigned int enable) { if (!enable_lock) return; __hwlock_acquire(enable_lock); enable_request_state |= enable; __hwlock_release(enable_lock); }
void media_input_fifo_update_enable_ind_state(unsigned int enable, unsigned int mask) { if (!enable_lock) return; __hwlock_acquire(enable_lock); enable_indication_state = (enable_indication_state & ~mask) | enable; __hwlock_release(enable_lock); }
int spin_lock_try_acquire(volatile swlock_t *lock, hwlock_t hwlock) { int value; __hwlock_acquire(hwlock); value = *lock; *lock = 1; __hwlock_release(hwlock); return !value; }
void spin_lock_acquire(volatile swlock_t *lock, hwlock_t hwlock) { int value; do { asm(".xtaloop 1\n"); __hwlock_acquire(hwlock); value = *lock; *lock = 1; __hwlock_release(hwlock); } while (value); }
void incr_transmit_count(int buf0, int incr) { mii_packet_t *buf = (mii_packet_t *) buf0; #ifndef ETHERNET_USE_HARDWARE_LOCKS swlock_acquire(&tc_lock); #else __hwlock_acquire(ethernet_memory_lock); #endif buf->tcount += incr; #ifndef ETHERNET_USE_HARDWARE_LOCKS swlock_release(&tc_lock); #else __hwlock_release(ethernet_memory_lock); #endif }
int get_and_dec_transmit_count(int buf0) { mii_packet_t *buf = (mii_packet_t *) buf0; int count; #ifndef ETHERNET_USE_HARDWARE_LOCKS swlock_acquire(&tc_lock); #else __hwlock_acquire(ethernet_memory_lock); #endif count = buf->tcount; if (count) buf->tcount = count - 1; #ifndef ETHERNET_USE_HARDWARE_LOCKS swlock_release(&tc_lock); #else __hwlock_release(ethernet_memory_lock); #endif return count; }
int mii_packet_get_and_clear_forwarding(int buf0, int ifnum) { mii_packet_t *buf = (mii_packet_t *) buf0; int mask = (1<<ifnum); int ret = (buf->forwarding & mask); #ifndef ETHERNET_USE_HARDWARE_LOCKS swlock_acquire(&tc_lock); #else __hwlock_acquire(ethernet_memory_lock); #endif buf->forwarding &= (~mask); #ifndef ETHERNET_USE_HARDWARE_LOCKS swlock_release(&tc_lock); #else __hwlock_release(ethernet_memory_lock); #endif return ret; }
void add_queue_entry(mii_queue_t *q, int i) { int wrIndex; #ifndef ETHERNET_USE_HARDWARE_LOCKS swlock_acquire((swlock_t *) q->lock); #else __hwlock_acquire(ethernet_memory_lock); #endif wrIndex = q->wrIndex; q->fifo[wrIndex] = i; wrIndex++; wrIndex *= (wrIndex != MAC_MAX_ENTRIES); q->wrIndex = wrIndex; #ifndef ETHERNET_USE_HARDWARE_LOCKS swlock_release((swlock_t *) q->lock); #else __hwlock_release(ethernet_memory_lock); #endif return; }