/************************************************************************/
/* */
/* ***** ***** */
/* ***** ***** */
/* ***** ***** */
/* ***** ***** */
/* *************** *************** */
/* ***************** ***************** */
/* *************** *************** */
/* ***** ***** TheNetNode */
/* ***** ***** Portable */
/* ***** ***** Network */
/* ***** ***** Software */
/* */
/* File os/linux/vanlinux.c (maintained by: DG1KWA) */
/* */
/* This file is part of "TheNetNode" - Software Package */
/* */
/* Copyright (C) 1998 - 2008 NORD>head == l2flp)
{
kick[port] = FALSE;
continue;
}
if (ReadVanW(port, dp_oFProd) != CRAM_VALID) /* CRAM Buffer free */
{
len = 0;
ulink((LEHEAD *)(txfhdl = (MBHEAD *) l2flp->head));/*Zeiger holen*/
while (txfhdl->mbgc < txfhdl->mbpc) /* solange Daten vorhanden sind */
WriteVanB(port, dp_oBuffer + (len++), getchr(txfhdl));
relink((LEHEAD *)txfhdl, /* als gesendet betrachten und in */
(LEHEAD *)stfl.tail); /* die gesendet Liste umhaengen */
kick[port] = ((LHEAD *)l2flp->head != l2flp);
WriteVanW(port, dp_iBufEmpty, 1); /* Frame wird gesendet... */
WriteVanW(port, dp_oLFrm, len); /* set size and .. */
WriteVanW(port, dp_oFProd, CRAM_VALID); /* terminate */
usleep(50);
} /* if CRAM_VALID... */
} /* if kick[port]... */
} /* Port enabled */
else
while (l2flp->head != l2flp)
relink(ulink((LEHEAD *) l2flp->head), (LEHEAD *)stfl.tail);
} /* for (port .... */
} /* for (live .... */
} /* end */
/************************************************************************/
/* vanessa_get_frame() - Frame(s) aus dem VANESSA CRAM holen */
/*----------------------------------------------------------------------*/
void vanessa_get_frame(void)
{
register unsigned int port;
WORD i, l;
MBHEAD *rxfhd;
for (port = 0; port < L2PNUM; ++port)
{
if (van_enabled(port))
{
while (ReadVanW(port, dp_iFProd) == CRAM_VALID)
{
outportb(ledio_adr[port], LED_ON);
l = ReadVanW(port, dp_iLFrm);
if (l > 0)
{
(rxfhd = (MBHEAD *)allocb(ALLOC_MBHEAD))->l2port = port;
for (i = 0; i < l; ++i)
putchr(ReadVanB(port, dp_iBuffer+i), rxfhd);
relink((LEHEAD *)rxfhd, (LEHEAD *)rxfl.tail);
}
WriteVanW(port, dp_iFProd, !CRAM_VALID);
outportb(ledio_adr[port], LED_OFF);
usleep(50);
}
}
}
}
/************************************************************************/
/* VANESSA mit Parametern versorgen */
/*----------------------------------------------------------------------*/
void vanessa_config(WORD port)
{
UWORD portspeed;
if (van_enabled(port))
{
WriteVanW(port, dp_Slottime, portpar[port].slottime & 0xff);
WriteVanW(port, dp_TxDelay, portpar[port].txdelay & 0xff);
WriteVanW(port, dp_Persistance, (dama(port)
? 0Xff : portpar[port].persistance & 0xff));
WriteVanW(port, dp_FullDuplex, fullduplex(port)?1:0);
if (extclock(port))
portspeed = 0xff07;
else
{
switch (portpar[port].speed)
{
case 12: portspeed = 0xff00; break;
case 24: portspeed = 0xff01; break;
case 48: portspeed = 0xff02; break;
case 96: portspeed = 0xff03; break;
case 192: portspeed = 0xff04; break;
case 384: portspeed = 0xff05; break;
default: portspeed = 0xff00; portpar[port].speed = 12;
}
}
WriteVanW(port, dp_vanspeed, portspeed);
WriteVanB((port&0xfe), ((dp_cData)+0x74F), multibaud(port) ? 1 : 0);
WriteVanB(port, ((dp_cData)+0x74F), (multibaud(port) ? 1 : 0));
WriteVanW(port, dp_oMagic, 0);
WriteVanW(port, dp_reReadParams, CRAM_VALID);
outportb(ledio_adr[port], LED_OFF);
WriteVanW(port, dp_iFProd, !CRAM_VALID);
}
}
/************************************************************************/
/* Reset Befehl an alle VANESSA's geben */
/*----------------------------------------------------------------------*/
void vanessa_reset_tnc(void)
{
register unsigned int port;
for (port = 0; port < L2PNUM; ++port) /* Alle FP's durchgehen */
{
if ( portpar[port].reset_port /* soll dieser Reset bekommen? */
&& van_enabled(port)
)
{
portpar[port].reset_port = FALSE; /* rueckstellen */
outportb(reset_adr[port >> 1], 0xFF); /* set RESET and... */
delay(50); /* .. wait some time */
outportb(reset_adr[port >> 1], 0x0); /* remove RESET again */
}
}
}
/************************************************************************/
/* TEST-Befehl ausfuehren, funktioniert nur ab VANESSA Firmware 4.0 !! */
/*----------------------------------------------------------------------*/
void vanessa_send_test(int port)
{
if (van_enabled(port))
{
if (ReadVanW(port, dp_oFProd) != CRAM_VALID) /* CRAM Buffer free */
{
WriteVanW(port, dp_oLFrm, -1); /* Frame Size = -1 */
WriteVanW(port, dp_oFProd, CRAM_VALID); /* CRAM buffer valid */
}
testflag[port] = FALSE; /* TEST fertig */
}
}
/*******************************************************************/
/* Testen ob ueberhaupt ne VAN da ist */
/* Patch dazu gekommen, 22/02/97 DG1KWA */
/* PS: in der alten Routine war auch noch ein Fehler :-) */
/*******************************************************************/
BOOLEAN van_test(int port)
{
van_version[port] = 4; /* aktuelle Version steht nicht im DP */
van_revision[port] = ReadVanB((port&0xFE), dp_cData+0x751) / 16;
van_patch[port] = ReadVanB((port&0xFE), dp_cData+0x74E); /* new */
return(ReadVanW(((port&0xFE)+1), dp_cData+0x750) == 0x3412);
}
WORD vanessa_dcd(int port)
{
WORD state = 0;
if (!van_enabled(port))
return 0;
if (ReadVanW(port,dp_oFProd) == CRAM_VALID) /* Sendedaten in der VAN */
state |= (WORD) TXBFLAG;
if (ReadVanW(port,dp_iFProd) == CRAM_VALID) /* Empfangsdaten in der VAN */
state |= (WORD) RXBFLAG;
if (ReadVanB(port,dp_iPTT)) /* wir senden ! */
state |= (WORD) PTTFLAG;
if (!ReadVanB(port,dp_iDCD)) /* wir empfangen etwas */
state |= (WORD) DCDFLAG;
return(state);
}
static void vanessa_ctl(int req)
{
switch (req)
{
case L1CRES : van_res = TRUE; break;
case L1CCMD : van_cmd = TRUE; break;
case L1CTST : van_tst = TRUE; break;
default : break;
}
}
/************************************************************************/
/* Vanessa EXIT (nur fuer LINUX) */
/************************************************************************/
void vanessa_l1exit(void)
{
register unsigned int port;
/* Mem wieder freigeben... */
munmap(base, 0x10000);
/* und die IO-Ports */
for (port = 0; port < L2PNUM; ++port)
{
ioperm(ledio_adr[port], 3, 0);
ioperm(reset_adr[port / 2], 3, 0);
}
}
void vanessa_l1ctl(int req)
{
vanessa_ctl(req);
}
static BOOLEAN van_enabled(int port)
{
return(portenabled(port) && (kissmode(port) == KISS_VAN));
}
void van_hwstr(int port, MBHEAD *mbp)
{
putprintf(mbp, " v4.%02x%c", van_revision[port], van_patch[port]);
}
#endif