00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #ifndef DZ_SERIAL_H
00011 #define DZ_SERIAL_H
00012
00013
00014
00015
00016 #define DZ_TRDY 0x8000
00017 #define DZ_TIE 0x4000
00018 #define DZ_RDONE 0x0080
00019 #define DZ_RIE 0x0040
00020 #define DZ_MSE 0x0020
00021 #define DZ_CLR 0x0010
00022 #define DZ_MAINT 0x0008
00023
00024
00025
00026
00027 #define DZ_RBUF_MASK 0x00FF
00028 #define DZ_LINE_MASK 0x0300
00029 #define DZ_DVAL 0x8000
00030 #define DZ_OERR 0x4000
00031 #define DZ_FERR 0x2000
00032 #define DZ_PERR 0x1000
00033
00034 #define LINE(x) (x & DZ_LINE_MASK) >> 8
00035 #define UCHAR(x) (unsigned char)(x & DZ_RBUF_MASK)
00036
00037
00038
00039
00040 #define DZ_LINE_KEYBOARD 0x0001
00041 #define DZ_LINE_MOUSE 0x0002
00042 #define DZ_LINE_MODEM 0x0004
00043 #define DZ_LINE_PRINTER 0x0008
00044
00045 #define DZ_MODEM_DTR 0x0400
00046
00047
00048
00049
00050 #define DZ_MODEM_DSR 0x0200
00051
00052
00053
00054
00055 #define DZ_BRK0 0x0100
00056 #define DZ_BRK1 0x0200
00057 #define DZ_BRK2 0x0400
00058 #define DZ_BRK3 0x0800
00059
00060
00061
00062
00063 #define DZ_KEYBOARD 0x0000
00064 #define DZ_MOUSE 0x0001
00065 #define DZ_MODEM 0x0002
00066 #define DZ_PRINTER 0x0003
00067
00068 #define DZ_CSIZE 0x0018
00069 #define DZ_CS5 0x0000
00070 #define DZ_CS6 0x0008
00071 #define DZ_CS7 0x0010
00072 #define DZ_CS8 0x0018
00073
00074 #define DZ_CSTOPB 0x0020
00075
00076 #define DZ_PARENB 0x0040
00077 #define DZ_PARODD 0x0080
00078
00079 #define DZ_CBAUD 0x0E00
00080 #define DZ_B50 0x0000
00081 #define DZ_B75 0x0100
00082 #define DZ_B110 0x0200
00083 #define DZ_B134 0x0300
00084 #define DZ_B150 0x0400
00085 #define DZ_B300 0x0500
00086 #define DZ_B600 0x0600
00087 #define DZ_B1200 0x0700
00088 #define DZ_B1800 0x0800
00089 #define DZ_B2000 0x0900
00090 #define DZ_B2400 0x0A00
00091 #define DZ_B3600 0x0B00
00092 #define DZ_B4800 0x0C00
00093 #define DZ_B7200 0x0D00
00094 #define DZ_B9600 0x0E00
00095
00096 #define DZ_CREAD 0x1000
00097 #define DZ_RXENAB 0x1000
00098
00099
00100
00101 #define DZ_CSR 0x00
00102 #define DZ_RBUF 0x08
00103 #define DZ_LPR 0x08
00104 #define DZ_TCR 0x10
00105 #define DZ_MSR 0x18
00106 #define DZ_TDR 0x18
00107
00108
00109 #define DZ_NB_PORT 4
00110
00111 #define DZ_XMIT_SIZE 4096
00112 #define WAKEUP_CHARS DZ_XMIT_SIZE/4
00113
00114 #define DZ_EVENT_WRITE_WAKEUP 0
00115
00116 #ifndef MIN
00117 #define MIN(a,b) ((a) < (b) ? (a) : (b))
00118
00119 #define DZ_INITIALIZED 0x80000000
00120 #define DZ_CALLOUT_ACTIVE 0x40000000
00121 #define DZ_NORMAL_ACTIVE 0x20000000
00122 #define DZ_BOOT_AUTOCONF 0x10000000
00123 #define DZ_CLOSING 0x08000000
00124 #define DZ_CTS_FLOW 0x04000000
00125 #define DZ_CHECK_CD 0x02000000
00126
00127 #define DZ_CLOSING_WAIT_INF 0
00128 #define DZ_CLOSING_WAIT_NONE 65535
00129
00130 #define DZ_SPLIT_TERMIOS 0x0008
00131 #define DZ_SESSION_LOCKOUT 0x0100
00132 #define DZ_PGRP_LOCKOUT 0x0200
00133
00134 struct dz_serial {
00135 unsigned port;
00136 int type;
00137 int flags;
00138 int baud_base;
00139 int blocked_open;
00140 unsigned short close_delay;
00141 unsigned short closing_wait;
00142 unsigned short line;
00143 unsigned short cflags;
00144 unsigned short x_char;
00145 unsigned short read_status_mask;
00146 unsigned short ignore_status_mask;
00147 unsigned long event;
00148 unsigned char *xmit_buf;
00149 int xmit_head;
00150 int xmit_tail;
00151 int xmit_cnt;
00152 int count;
00153 int magic;
00154
00155 struct async_icount icount;
00156 struct tty_struct *tty;
00157 struct tq_struct tqueue;
00158 struct tq_struct tqueue_hangup;
00159 struct termios normal_termios;
00160 struct termios callout_termios;
00161 struct wait_queue *open_wait;
00162 struct wait_queue *close_wait;
00163
00164 long session;
00165 long pgrp;
00166
00167 unsigned char is_console;
00168 unsigned char is_initialized;
00169 };
00170
00171 static struct dz_serial multi[DZ_NB_PORT];
00172 static struct dz_serial *dz_console;
00173 static struct tty_driver serial_driver, callout_driver;
00174
00175 static struct tty_struct *serial_table[DZ_NB_PORT];
00176 static struct termios *serial_termios[DZ_NB_PORT];
00177 static struct termios *serial_termios_locked[DZ_NB_PORT];
00178
00179 static int serial_refcount;
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190 static unsigned char *tmp_buf;
00191 static struct semaphore tmp_buf_sem = MUTEX;
00192
00193 static char *dz_name = "DECstation DZ serial driver version ";
00194 static char *dz_version = "1.02";
00195
00196 static inline unsigned short dz_in (struct dz_serial *, unsigned);
00197 static inline void dz_out (struct dz_serial *, unsigned, unsigned short);
00198
00199 static inline void dz_sched_event (struct dz_serial *, int);
00200 static inline void receive_chars (struct dz_serial *);
00201 static inline void transmit_chars (struct dz_serial *);
00202 static inline void check_modem_status (struct dz_serial *);
00203
00204 static void dz_stop (struct tty_struct *);
00205 static void dz_start (struct tty_struct *);
00206 static void dz_interrupt (int, void *, struct pt_regs *);
00207 static void do_serial_bh (void);
00208 static void do_softint (void *);
00209 static void do_serial_hangup (void *);
00210 static void change_speed (struct dz_serial *);
00211 static void dz_flush_chars (struct tty_struct *);
00212 static void dz_console_print (struct console *, const char *, unsigned int);
00213 static void dz_flush_buffer (struct tty_struct *);
00214 static void dz_throttle (struct tty_struct *);
00215 static void dz_unthrottle (struct tty_struct *);
00216 static void dz_send_xchar (struct tty_struct *, char);
00217 static void shutdown (struct dz_serial *);
00218 static void send_break (struct dz_serial *, int);
00219 static void dz_set_termios (struct tty_struct *, struct termios *);
00220 static void dz_close (struct tty_struct *, struct file *);
00221 static void dz_hangup (struct tty_struct *);
00222 static void show_serial_version (void);
00223
00224 static int dz_write (struct tty_struct *, int, const unsigned char *, int);
00225 static int dz_write_room (struct tty_struct *);
00226 static int dz_chars_in_buffer (struct tty_struct *);
00227 static int startup (struct dz_serial *);
00228 static int get_serial_info (struct dz_serial *, struct serial_struct *);
00229 static int set_serial_info (struct dz_serial *, struct serial_struct *);
00230 static int get_lsr_info (struct dz_serial *, unsigned int *);
00231 static int dz_ioctl (struct tty_struct *, struct file *, unsigned int, unsigned long);
00232 static int block_til_ready (struct tty_struct *, struct file *, struct dz_serial *);
00233 static int dz_open (struct tty_struct *, struct file *);
00234
00235 #ifdef MODULE
00236 int init_module (void)
00237 void cleanup_module (void)
00238 #endif
00239
00240 #endif
00241
00242 #endif