vsta

Check-in [57a7c9b100]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Get SLIP working a little better. Clean up CVS warnings.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | master | trunk
Files: files | file ages | folders
SHA3-256:57a7c9b1000853002df9d733d5384c3bf52c09eb34844394909126d0d071949e
User & Date: vandys 2002-01-04 18:00:04
Context
2002-01-10
09:56
No such opcode as "pushb"... it's actually a "pushl". check-in: f221206067 user: vandys tags: master, trunk
2002-01-04
18:00
Get SLIP working a little better. Clean up CVS warnings. check-in: 57a7c9b100 user: vandys tags: master, trunk
17:58
Use named for calloc()'s parameters, as I can never remember which is which here, either (see comment for tcsetattr() :->). check-in: 8e0db21cd7 user: vandys tags: master, trunk
Changes
Hide Diffs Side-by-Side Diffs Ignore Whitespace Patch

Changes to vsta/src/srv/ka9q/vsta_io.c.

    42     42   /*
    43     43    * Per async port state
    44     44    */
    45     45   static struct asy {
    46     46   	char *a_tty;		/* Port accessed */
    47     47   	port_t a_txport,	/* Open ports to this name */
    48     48   		a_rxport;
    49         -	char *a_txbuf;		/* When active, buffer being sent */
           49  +	char volatile *
           50  +		a_txbuf;	/* When active, buffer being sent */
    50     51   	int a_txcnt;		/*  ...size */
    51     52   	char *a_rxbuf;		/* Receive buffer */
    52         -	int a_hd, a_tl;		/* Head/tail of rx FIFO */
           53  +	volatile int
           54  +		a_hd, a_tl;	/* Head/tail of rx FIFO */
    53     55   	pid_t a_txpid,		/* Thread serving this port (tx) */
    54     56   		a_rxpid;	/*   ...rx */
    55     57   } asy[ASY_MAX];
    56     58   
    57     59   /*
    58     60    * ioinit()
    59     61    *	Called at startup time to set up console I/O
................................................................................
   145    147    * asy_rx_daemon()
   146    148    *	Thread to watch for incoming bytes, and queue them
   147    149    */
   148    150   static void
   149    151   asy_rx_daemon(struct asy *ap)
   150    152   {
   151    153   	struct msg m;
   152         -	int cnt;
          154  +	int cnt, tl;
   153    155   
   154    156   	for (;;) {
   155    157   		/*
   156    158   		 * See how much we can pull in this time
   157    159   		 */
   158         -		if (ap->a_hd >= ap->a_tl) {
          160  +		tl = ap->a_tl;
          161  +		if (ap->a_hd >= tl) {
   159    162   			cnt = BUFLEN - ap->a_hd;
   160    163   		} else {
   161         -			cnt = (ap->a_tl - ap->a_hd);
          164  +			cnt = (tl - ap->a_hd) - 1;
   162    165   		}
   163         -		if (cnt <= 1) {
          166  +		if (cnt <= 0) {
   164    167   			__msleep(10);
   165    168   			continue;
   166    169   		}
   167         -		cnt -= 1;
   168    170   
   169    171   		/*
   170    172   		 * Do the receive
   171    173   		 */
   172    174   		m.m_op = FS_READ | M_READ;
   173    175   		m.m_arg = m.m_buflen = cnt;
   174    176   		m.m_arg1 = 0;
................................................................................
   213    215   
   214    216   		/*
   215    217   		 * Transmit it
   216    218   		 */
   217    219   		m.m_op = FS_WRITE;
   218    220   		m.m_arg = m.m_buflen = ap->a_txcnt;
   219    221   		m.m_arg1 = 0;
   220         -		m.m_buf = ap->a_txbuf;
          222  +		m.m_buf = (char *)ap->a_txbuf;
   221    223   		m.m_nseg = 1;
   222    224   		(void)msg_send(ap->a_txport, &m);
   223    225   
   224    226   		/*
   225    227   		 * Flag completion
   226    228   		 */
   227    229   		ap->a_txbuf = 0;
................................................................................
   261    263   	/* 
   262    264   	 * Set to default parameters
   263    265   	 */
   264    266   	(void)wstat(p, "baud=9600\n");
   265    267   	(void)wstat(p, "databits=8\n");
   266    268   	(void)wstat(p, "stopbits=1\n");
   267    269   	(void)wstat(p, "parity=none\n");
          270  +	(void)wstat(p, "onlcr=0\n");
   268    271   
   269    272   	/*
   270    273   	 * Initialize tty, launch threads
   271    274   	 */
   272    275   	ap->a_txport = clone(p);
   273    276   	ap->a_rxbuf = malloc(BUFLEN);
   274    277   	ap->a_rxpid = tfork(asy_rx_daemon, (ulong)ap);
................................................................................
   334    337    *
   335    338    * Returns count of characters read
   336    339    */
   337    340   int16
   338    341   asy_recv(int16 dev, char *buf, int cnt)
   339    342   {
   340    343   	struct asy *ap = &asy[dev];
   341         -	int avail;
          344  +	int x, avail;
   342    345   
   343    346   	/*
   344    347   	 * Take the lesser of how much is there and how much
   345    348   	 * they want.
   346    349   	 */
   347         -	if (ap->a_hd < ap->a_tl) {
          350  +	x = ap->a_hd;
          351  +	if (x < ap->a_tl) {
   348    352   		avail = BUFLEN - ap->a_tl;
   349    353   	} else {
   350         -		avail = ap->a_hd - ap->a_tl;
          354  +		avail = x - ap->a_tl;
   351    355   	}
   352    356   	if (avail > cnt) {
   353    357   		avail = cnt;
   354    358   	}
   355    359   	if (avail <= 0) {
   356    360   		return(0);
   357    361   	}
................................................................................
   360    364   	 * Copy it out
   361    365   	 */
   362    366   	bcopy(ap->a_rxbuf + ap->a_tl, buf, avail);
   363    367   
   364    368   	/*
   365    369   	 * Update state
   366    370   	 */
   367         -	ap->a_tl += avail;
   368         -	if (ap->a_tl >= BUFLEN) {
          371  +	x = ap->a_tl + avail;
          372  +	if (x >= BUFLEN) {
   369    373   		ap->a_tl = 0;
          374  +	} else {
          375  +		ap->a_tl = x;
   370    376   	}
   371    377   
   372    378   	return(avail);
   373    379   }
   374    380   
   375    381   /*
   376    382    * asy_ioctl()