|
|
1.1 ! root 1: /* ! 2: ** Send data to channel ! 3: ** ! 4: ** Assumes count <= MAXPKTDSIZE ! 5: ** & channel <= NLAYERS ! 6: ** ! 7: ** Returns -1 if output queue full, ! 8: ** else value of Pxfunc(). ! 9: */ ! 10: ! 11: #include "pconfig.h" ! 12: #include "proto.h" ! 13: #include "packets.h" ! 14: #include "pstats.h" ! 15: ! 16: /* extern int crc(); */ ! 17: ! 18: ! 19: int ! 20: #ifndef Blit ! 21: psend(channel, bufp, count) ! 22: #else ! 23: psend(channel, bufp, count, type) ! 24: #endif ! 25: int channel; ! 26: # ifdef vax ! 27: char * bufp; ! 28: # else ! 29: register char * bufp; ! 30: # endif ! 31: int count; ! 32: # ifdef Blit ! 33: char type; ! 34: # endif ! 35: { ! 36: register int i; ! 37: # ifndef vax ! 38: register Pbyte *cp; ! 39: # endif ! 40: register Pkt_p pkp; /* WARNING *** used as r10 in "asm" below */ ! 41: register Pch_p pcp = &pconvs[channel]; ! 42: register Pks_p psp; ! 43: # ifdef Blit ! 44: register int x = spl1(); ! 45: # endif ! 46: ! 47: pcp->freepkts = 0; ! 48: ! 49: for ( pkp = 0, psp = pcp->nextpkt, i = NPCBUFS ; i-- ; ) ! 50: { ! 51: if ( psp->state != PX_WAIT ) ! 52: if ( pkp ) ! 53: pcp->freepkts++; ! 54: else ! 55: { ! 56: pkp = &psp->pkt; ! 57: psp->state = PX_WAIT; ! 58: psp->timo = Pxtimeout; ! 59: if ( !Ptflag ) ! 60: { ! 61: Ptflag++; ! 62: # ifndef Blit ! 63: (void)alarm(Pscanrate); ! 64: # endif ! 65: } ! 66: } ! 67: if ( ++psp >= &pcp->pkts[NPCBUFS] ) ! 68: psp = pcp->pkts; ! 69: } ! 70: if ( pkp == 0 ) ! 71: { ! 72: # ifdef Blit ! 73: splx(x); ! 74: # endif ! 75: return(-1); ! 76: } ! 77: ! 78: pkp->header = P_PTYPE; ! 79: pkp->header |= (channel & (MAXPCHAN-1)) << SBITS; ! 80: pkp->header |= (pcp->xseq++ & (SEQMOD-1)); ! 81: ! 82: # ifdef Blit ! 83: splx(x); ! 84: cp = pkp->data; ! 85: *cp++ = type; ! 86: if ( i = count ) ! 87: do *cp++ = *bufp++; while ( --i ); ! 88: count++; ! 89: # else Blit ! 90: # ifdef vax ! 91: {asm(" movc3 12(ap),*8(ap),2(r10) ");} /* WARNING *** assumes "pkp" in r10 */ ! 92: # else vax ! 93: for ( i = count, cp = pkp->data ; i-- ; ) ! 94: *cp++ = *bufp++; ! 95: # endif vax ! 96: # endif Blit ! 97: # ifdef PSTATISTICS ! 98: pstats[PS_XBYTES].count += count; ! 99: # endif ! 100: ! 101: pkp->dsize = count; ! 102: count += 2; /* if bit fields were independent */ ! 103: ! 104: (void)crc((Pbyte *)pkp, count); ! 105: count += EDSIZE; ! 106: ((Pks_p)pkp)->size = count; ! 107: ! 108: plogpkt(pkp, PLOGOUT); ! 109: return Pxfunc(pkp, count); ! 110: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.