+Mon Aug 22 10:42:15 1994 Steve Chamberlain (sac@jonny.cygnus.com)
+
+ Work to reduce the interrupts-off duration when running in DOS.
+ * ser-go32.c: (dos_async_ready): See if anything is in the buffer.
+ (dos_async_rx): rewrite to unpack as many characters from the
+ asynctsr as possible into a local buffer.
+
Fri Aug 19 14:55:45 1994 Stan Shebs (shebs@andros.cygnus.com)
Initial Fortran language support, adapted from work by Farooq Butt
#define disable() asm("cli")
#define enable() asm("sti")
+
struct go32_ttystate
{
int bogus;
#define VERSION 1
#define OFFSET 0x104
+char packet[50];
+int packet_len;
+int packet_idx;
+
unsigned char bb;
unsigned short sb;
unsigned long sl;
#define GET_LONG(x) ( dosmemget((x),4,&sl), sl)
static
-unsigned short
+unsigned short
GET_WORD (x)
{
unsigned short sb;
{
int ret;
+ if (packet_idx < packet_len)
+ return 1;
+
disable ();
#if RDY_CNT
ret = GET_WORD (aindex + AOFF_COUNT);
char rv;
short idx;
- while (!dos_async_ready ())
+ while (1)
{
- if (kbhit ())
+ if (packet_idx < packet_len)
+ {
+ char x = packet[packet_idx++];
+ return x;
+ }
+ while (!dos_async_ready ())
{
- printf_unfiltered ("abort!\n");
- return 0;
+ if (kbhit ())
+ {
+ printf_unfiltered ("abort!\n");
+ return 0;
+ }
}
+ disable ();
+ {
+ /* Sometimes we can read more than one char at a time
+ from the buffer, which is good, cause it'll mean
+ less time with interrupts turned off, which means
+ less dropped characters */
+
+ /* We only do the simplest case here - not bothering with
+ wrap around */
+ int len;
+
+ int getp = GET_WORD (aindex + AOFF_GETP);
+ int putp = GET_WORD (aindex + AOFF_PUTP);
+ int endb = GET_WORD (aindex + AOFF_BUFFER_END);
+ int startb = GET_WORD (aindex + AOFF_BUFFER_START);
+
+ /* We'd like to grab to the end of the the input,
+ but it may have wrapped, so max is to the end
+ of the buffer */
+
+ if (putp > endb || putp < getp)
+ putp = endb;
+
+ /* Work out the length of the suck */
+ len = putp - getp;
+
+ /* But only suck as many as we can hold in one go */
+ if (len > sizeof (packet))
+ len = sizeof (packet);
+
+ dosmemget (aindex - OFFSET + getp, len, packet);
+
+ packet_len = len;
+ packet_idx = 0;
+
+ if (getp + len >= endb)
+ {
+ getp = startb;
+ }
+ else
+ {
+ getp = getp + len;
+ }
+
+ SET_WORD (aindex + AOFF_GETP, getp);
+ SET_WORD (aindex + AOFF_COUNT, GET_WORD (aindex + AOFF_COUNT) - len);
+ }
+ enable ();
}
- disable ();
- idx = GET_WORD (aindex + AOFF_GETP);
- idx++;
- SET_WORD (aindex + AOFF_GETP, idx);
- rv = aptr (idx - 1);
- SET_WORD (aindex + AOFF_COUNT, GET_WORD (aindex + AOFF_COUNT) - 1);
- if (GET_WORD (aindex + AOFF_GETP) > GET_WORD (aindex + AOFF_BUFFER_END))
- SET_WORD (aindex + AOFF_GETP, GET_WORD (aindex + AOFF_BUFFER_START));
- enable ();
- return rv;
}
{
long now, then;
int i;
-
+ int its = 0;
time (&now);
then = now + timeout;
while (!dos_async_ready ())
{
time (&now);
- if (now >= then && timeout > 0)
+ if (now >= then && timeout > 0 && its > 1000)
return i;
+ its++;
}
}
*buf++ = dos_async_rx ();