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; }
int i2c_shared_master_write_reg(REFERENCE_PARAM(struct r_i2c, i2cPorts), int device, int reg_addr, const unsigned char data[], int nbytes) { int retval; swlock_acquire(&i2c_swlock); retval = i2c_master_write_reg(device, reg_addr, data, nbytes, i2cPorts); swlock_release(&i2c_swlock); return retval; }
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; }
void i2c_shared_master_init(REFERENCE_PARAM(struct r_i2c, i2cPorts)) { swlock_acquire(&i2c_swlock); i2c_master_init(i2cPorts); swlock_release(&i2c_swlock); }