void spin_lock_release(volatile swlock_t *lock,
                                     hwlock_t hwlock)
{
  __hwlock_acquire(hwlock);
  *lock = 0;
  __hwlock_release(hwlock);
}
예제 #2
0
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;
}
예제 #3
0
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);
}
예제 #4
0
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);
}
예제 #7
0
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
}
예제 #8
0
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;
}
예제 #9
0
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;
}
예제 #10
0
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;
}