"Fossies" - the Fresh Open Source Software Archive

Member "dosemu-1.4.0/src/include/serial.h" (4 May 2007, 5525 Bytes) of package /linux/misc/old/dosemu-1.4.0.tgz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "serial.h" see the Fossies "Dox" file reference documentation.

    1 /* 
    2  * All modifications in this file to the original code are
    3  * (C) Copyright 1992, ..., 2007 the "DOSEMU-Development-Team".
    4  *
    5  * for details see file COPYING.DOSEMU in the DOSEMU distribution
    6  */
    7 
    8 /* DANG_BEGIN_MODULE
    9  *
   10  * REMARK
   11  * serial.h: Include file for port data array for DOSEMU serial.
   12  * Please send bug reports and bugfixes to marky@magmacom.com
   13  * Please read the files in the 'serial' subdirectory for more info.
   14  * /REMARK
   15  *
   16  * This module is maintained by Mark Rejhon at these Email addresses:
   17  *      marky@magmacom.com
   18  *      ag115@freenet.carleton.ca
   19  *
   20  * COPYRIGHTS
   21  * ~~~~~~~~~~
   22  *   Copyright (C) 1995 by Mark Rejhon
   23  *
   24  *   All of this code is free software; you can redistribute it and/or
   25  *   modify it under the terms of the GNU General Public License as  
   26  *   published by the Free Software Foundation; either version 2 of 
   27  *   the License, or (at your option) any later version.
   28  *
   29  * DANG_END_MODULE
   30  */
   31 
   32 #ifndef SERIAL_H
   33 #define SERIAL_H
   34 
   35 #include <termios.h>
   36 #include "extern.h"
   37 
   38 /* These are sizes for the internal recieve and transmit buffers.
   39  * They must be at least 16 bytes because these double as FIFO's,
   40  * The 16-byte limitation is emulated, though, for compatibility
   41  * purposes.  (Although this may be configurable eventually)
   42  *
   43  * DANG_FIXTHIS Why does a RX_BUFFER_SIZE of 256 cause slower performance than a size of 128?
   44  */
   45 #define RX_BUFFER_SIZE            128
   46 #define TX_BUFFER_SIZE            64
   47 
   48 extern int no_local_video; /* used by virtual port code */
   49 EXTERN u_char irq_source_num[255];  /* Index to map from IRQ no. to serial port */
   50 EXTERN u_char com_port_used[17];       /* Used for auto-assign comport config */
   51 
   52 typedef struct {
   53                 /*   MAIN VARIABLES  */
   54   char *dev;            /* String to hold path to device file */
   55   int fd;           /* File descriptor of device */
   56   int real_comport;     /* The actual COMx port number. 0 for invalid */
   57   ioport_t base_port;       /* Base port address handled by device */
   58   int interrupt;        /* IRQ line handled by device */
   59   boolean virtual;      /* virtual modem */
   60   boolean pseudo;       /* pseudo-tty is used */
   61   boolean mouse;        /* Flag to turn on mouse sharing features */
   62   boolean dev_locked;           /* Flag to indicate that device is locked */
   63   boolean fossil_active;    /* Flag: FOSSIL emulation active */
   64   u_char fossil_info[19];   /* FOSSIL driver info buffer */
   65   int system_rtscts;        /* Flag: emulate RTS or let system handle it */
   66                 /*   MODEM STATUS  */
   67   long int ms_freq;     /* Frequency of Modem Status (MS) check */
   68   long int ms_timer;            /* Countdown to forced MS check */
   69                 /*   RECEIVE  */
   70   long int rx_timer;        /* Countdown to next read() system call */
   71   u_char rx_timeout;        /* Recieve Interrupt timeout counter */
   72   u_char rx_fifo_trigger;   /* Receive Fifo trigger value */
   73   int rx_fifo_bytes;        /* Receive Fifo bytes-waiting counter */
   74   int rx_fifo_size;     /* Size of receive FIFO to emulate */
   75                 /*   TRANSMIT  */
   76   long int tx_timer;            /* Countdown to next char being xmitted */
   77   long int tx_char_time;        /* Number of 115200ths of sec per char */
   78   u_char tx_trigger;        /* Flag whether Xmit int should be triggered */
   79   u_char tx_overflow;       /* Full outgoing buffer flag. */
   80                 /*   MISCELLANEOUS  */
   81   u_char int_request;       /* Interrupt Request flags - TX/RX/MS/LS */
   82   u_char int_condition;     /* Interrupt Condition flags - TX/RX/MS/LS */
   83   u_char int_enab;      /* Interrupt Enabled flag (OUT2 of MCR) */
   84   u_char fifo_enable;       /* FIFO enabled flag */
   85   u_char uart_full;     /* UART full flag */
   86   speed_t newbaud;      /* Currently set bps rate */
   87 
   88   /* The following are serial port registers */
   89   int dll, dlm;     /* Baudrate divisor LSB and MSB */
   90   u_char DLAB;      /* Divisor Latch enabled */
   91   u_char TX;        /* Transmit Holding Register */
   92   u_char RX;        /* Received Data Register */
   93   u_char IER;       /* Interrupt Enable Register */
   94   u_char IIR;       /* Interrupt Identification Register */
   95   u_char LCR;       /* Line Control Register */
   96   u_char FCReg;     /* Fifo Control Register (.FCR is a name conflict) */
   97   u_char MCR;       /* Modem Control Register */
   98   u_char LSR;       /* Line Status Register */
   99   u_char MSR;       /* Modem Status Register */
  100   u_char SCR;       /* Scratch Pad Register */
  101   u_char LSRqueued;     /* One-byte LSR queue for interrupts */
  102   u_char MSRqueued;     /* One-byte MSR queue for interrupts */
  103 
  104   /* The following are the transmit and receive buffer variables
  105    * They are bigger than the 16 bytes of a real FIFO to improve
  106    * performance, but the 16-byte limitation of the receive FIFO
  107    * is still emulated using a counter, to improve compatibility.
  108    */
  109   u_char rx_buf[RX_BUFFER_SIZE];    /* Receive Buffer */
  110   u_char rx_buf_start;          /* Receive Buffer queue start */
  111   u_char rx_buf_end;            /* Receive Buffer queue end */
  112   u_char tx_buf[TX_BUFFER_SIZE];    /* Transmit Buffer */
  113   u_char tx_buf_start;          /* Transmit Buffer queue start */
  114   u_char tx_buf_end;            /* Transmit Buffer queue end */
  115 
  116   struct termios oldset;        /* Original termios settings */
  117   struct termios newset;        /* Current termios settings */
  118 } serial_t;
  119 
  120 #define MAX_SER 4
  121 EXTERN serial_t com[MAX_SER];
  122 
  123 #define RX_BUF_BYTES(num) (com[num].rx_buf_end - com[num].rx_buf_start)
  124 #define TX_BUF_BYTES(num) (com[num].tx_buf_end - com[num].tx_buf_start)
  125 
  126 extern int int14(void);
  127 extern void serial_run(void);
  128 extern int do_serial_in(int, ioport_t);
  129 extern int do_serial_out(int, ioport_t, int);
  130 extern void serial_helper(void);
  131 extern void child_close_mouse(void);
  132 extern void child_open_mouse(void);
  133 
  134 #endif /* SERIAL_H */