83 lines
1.9 KiB
C
Executable File
83 lines
1.9 KiB
C
Executable File
#include <string.h>
|
|
#include <stdlib.h>
|
|
|
|
#include <rb2/regbus.h>
|
|
#include <hwo/utils.h>
|
|
|
|
extern int32_t dbg_rb2_router_ident;
|
|
|
|
void rb2_loop_ident(void)
|
|
{
|
|
uint16_t kep = rb2_known_endpoints();
|
|
list_t *i;
|
|
cpustate_t state;
|
|
|
|
spinlock_lock_irq( &(&__rb2_instance)->links.lock, &state );
|
|
|
|
for_each_list_entry(i,&((&__rb2_instance)->links.list)){
|
|
RB2_LINK *link = list_entry(i,RB2_LINK,list);
|
|
|
|
spinlock_release_irq( &(&__rb2_instance)->links.lock, &state );
|
|
|
|
if (wait_async_test( &link->timeoutIdent) )
|
|
{
|
|
rb2_telegram_buffer_t *telegram = rb2_pool_pop();
|
|
if (telegram){
|
|
|
|
wait_async_set( &link->timeoutIdent, RB2_IDENT_TIMEOUT );
|
|
|
|
if (link->identrx == 0) {
|
|
if (link->ring) {
|
|
(&__rb2_instance)->axes = 0;
|
|
} else {
|
|
link->idmask = 0;
|
|
};
|
|
} else {
|
|
link->identrx--;
|
|
};
|
|
|
|
|
|
telegram->telegram.magic = RB2_MAGIC;
|
|
telegram->telegram.sender.node = rb2_first_id();
|
|
telegram->telegram.sender.ax = (&__rb2_instance)->ax;
|
|
telegram->telegram.flags.byte = 0;
|
|
telegram->telegram.flags.ident = 1;
|
|
|
|
// Ist dieser Link der RING-BUS ?
|
|
if (link->ring)
|
|
{
|
|
// Ist dieser Knoten der RING-BUS Master?
|
|
if ((&__rb2_instance)->ringmaster)
|
|
{
|
|
telegram->telegram.receiver.node = RB_NODE_PROXY;
|
|
telegram->telegram.receiver.ax = 0;
|
|
telegram->telegram.ax = 0;
|
|
|
|
link->send( link, telegram );
|
|
dbg_rb2_router_ident++;
|
|
} else {
|
|
rb2_pool_push( telegram );
|
|
};
|
|
} else // Kein RING-BUS
|
|
{
|
|
telegram->telegram.receiver.node = RB_NODE_BROADCAST;
|
|
telegram->telegram.receiver.ax = RB_AX_LOCAL;
|
|
telegram->telegram.endpoints = kep & ~( link->idmask );
|
|
|
|
link->send( link, telegram );
|
|
|
|
dbg_rb2_router_ident++;
|
|
};
|
|
} else {
|
|
trace_on(3);
|
|
};
|
|
};
|
|
|
|
spinlock_lock_irq( &(&__rb2_instance)->links.lock, &state );
|
|
};
|
|
|
|
spinlock_release_irq( &(&__rb2_instance)->links.lock, &state );
|
|
|
|
};
|
|
|