123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135 |
- /*
- * This file is part of the UCB release of Plan 9. It is subject to the license
- * terms in the LICENSE file found in the top-level directory of this
- * distribution and at http://akaros.cs.berkeley.edu/files/Plan9License. No
- * part of the UCB release of Plan 9, including this file, may be copied,
- * modified, propagated, or distributed except according to the terms contained
- * in the LICENSE file.
- */
- typedef struct Serial Serial;
- typedef struct Serialops Serialops;
- typedef struct Serialport Serialport;
- struct Serialops {
- int (*seteps)(Serialport*);
- int (*init)(Serialport*);
- int (*getparam)(Serialport*);
- int (*setparam)(Serialport*);
- int (*clearpipes)(Serialport*);
- int (*reset)(Serial*, Serialport*);
- int (*sendlines)(Serialport*);
- int (*modemctl)(Serialport*, int);
- int (*setbreak)(Serialport*, int);
- int (*readstatus)(Serialport*);
- int (*wait4data)(Serialport*, u8 *, int);
- int (*wait4write)(Serialport*, u8 *, int);
- };
- enum {
- DataBufSz = 8*1024,
- Maxifc = 16,
- };
- struct Serialport {
- char name[32];
- Serial *s; /* device we belong to */
- int isjtag;
- Dev *epintr; /* may not exist */
- Dev *epin;
- Dev *epout;
- Usbfs fs;
- u8 ctlstate;
- /* serial parameters */
- u32 baud;
- int stop;
- int mctl;
- int parity;
- int bits;
- int fifo;
- int limit;
- int rts;
- int cts;
- int dsr;
- int dcd;
- int dtr;
- int rlsd;
- i64 timer;
- int blocked; /* for sw flow ctl. BUG: not implemented yet */
- int nbreakerr;
- int ring;
- int nframeerr;
- int nparityerr;
- int novererr;
- int enabled;
- int interfc; /* interfc on the device for ftdi */
- Channel *w4data;
- Channel *gotdata;
- Channel *readc; /* to uncouple reads, only used in ftdi... */
- int ndata;
- u8 data[DataBufSz];
- };
- struct Serial {
- QLock QLock;
- Dev *dev; /* usb device*/
- int type; /* serial model subtype */
- int recover; /* # of non-fatal recovery tries */
- Serialops Serialops;
- int hasepintr;
- int jtag; /* index of jtag interface, -1 none */
- int nifcs; /* # of serial interfaces, including JTAG */
- Serialport p[Maxifc];
- int maxrtrans;
- int maxwtrans;
- int maxread;
- int maxwrite;
- int inhdrsz;
- int outhdrsz;
- int baudbase; /* for special baud base settings, see ftdi */
- };
- enum {
- /* soft flow control chars */
- CTLS = 023,
- CTLQ = 021,
- CtlDTR = 1,
- CtlRTS = 2,
- };
- /*
- * !hget http://lxr.linux.no/source/drivers/usb/serial/pl2303.h|htmlfmt
- * !hget http://lxr.linux.no/source/drivers/usb/serial/pl2303.c|htmlfmt
- */
- int serialmain(Dev *d, int argc, char *argv[]);
- typedef struct Cinfo Cinfo;
- struct Cinfo {
- int vid; /* usb vendor id */
- int did; /* usb device/product id */
- int cid; /* controller id assigned by us */
- };
- extern Cinfo plinfo[];
- extern Cinfo uconsinfo[];
- extern int serialdebug;
- #define dsprint if(serialdebug)fprint
- int serialrecover(Serial *ser, Serialport *p, Dev *ep, char *err);
- int serialreset(Serial *ser);
- char *serdumpst(Serialport *p, char *buf, int bufsz);
|