46 lines
1.2 KiB
C
46 lines
1.2 KiB
C
|
#include <rb2/regbus.h>
|
||
|
#include <sys/spinlock.h>
|
||
|
|
||
|
#include <stdlib.h>
|
||
|
|
||
|
void rb2_handle_response(rb2_telegram_buffer_t *telegram)
|
||
|
{
|
||
|
list_t *iter,
|
||
|
*tmp;
|
||
|
RB2_REQUEST
|
||
|
*pending;
|
||
|
|
||
|
cpustate_t state;
|
||
|
|
||
|
if (!telegram)
|
||
|
return;
|
||
|
|
||
|
spinlock_lock_irq( &(&__rb2_instance)->queues.sl_pending, &state );
|
||
|
|
||
|
for_each_list_entry_save(iter,tmp,(list_t*) &((&__rb2_instance)->queues.pending)){
|
||
|
pending = list_entry(iter,RB2_REQUEST,list);
|
||
|
|
||
|
if (
|
||
|
(pending->telegram.receiver.addr == telegram->telegram.sender.addr) &&
|
||
|
(pending->telegram.regno == telegram->telegram.regno)
|
||
|
) {
|
||
|
list_remove( iter );
|
||
|
|
||
|
spinlock_release_irq( &(&__rb2_instance)->queues.sl_pending, &state );
|
||
|
|
||
|
rb2_convert( telegram->telegram.flags.type, &telegram->telegram.i32, pending->telegram.flags.type, &(pending->telegram.i32) );
|
||
|
|
||
|
pending->telegram.flags.response = telegram->telegram.flags.response;
|
||
|
pending->telegram.flags.fail = telegram->telegram.flags.fail;
|
||
|
|
||
|
thread_wake( pending->waiter );
|
||
|
|
||
|
spinlock_lock_irq( &(&__rb2_instance)->queues.sl_pending, &state );
|
||
|
};
|
||
|
};
|
||
|
|
||
|
spinlock_release_irq( &(&__rb2_instance)->queues.sl_pending, &state );
|
||
|
|
||
|
rb2_pool_push( telegram );
|
||
|
};
|