08/07/2000 Goals: design a user space (and eventually a kernel-space) SCSI Terminal Server driver. Implementation: - use SCSI generic driver to access both LUNs of the STS - use ptys to attach the STS ports to Blocks: - I have no idea how to pass user-changes of termios back to the STS Basic operational outline: - run INQUIRY(s) - verify that we have the proper device pair (by matching bus/cntrlr/id) - query device for # of ports - initialize STS - open, clear, and initialize STS ports - open, clear, and initialize ptys - mark STS write fd as writable - post initial STS read cmd - enter processing loop (bulk of run-time) - exit processing loop - close PTYs safely - shutdown and close STS ports - shutdown STS The processing loop outline: - add PTYs without pending STS writes to read set - add all PTYS to exclusion set - add STS fds to readset - add STS fds to exclusion set - select on fd set - if STS read fd is readable: - process STS packet(s) - repost STS read cmd - for each PTY: - if PTY is readable: - read PTY - buffer reads for future STS writes - if STS write fd is readable - process STS packet(s) - mark STS write fd as writable - if STS write fd is writable - build STS packet(s) - post STS write cmd - mark STS write fd as not writable - repeat from the top Some structures: typeset struct sts_state_t { int bus, ctrlr, id; /* SCSI identifiers */ char * manufacturer; /* SCSI manufacturer string */ char * model; /* SCSI model string */ char * rev; /* SCSI revision */ int writefd, readfd; /* write and read fds (LUN 0 and 1) */ int total_ports; /* how many ports in the STS */ struct port_state_t * ports; /* array of STS port info structures */ int writable:1; /* can I post an STS write cmd? */ int readable:1; /* can I post an STS read cmd? */ struct tty_state_t * ttys; /* array of PTY info structures */ } sts_state; typeset struct port_state_t { int available; /* is this port usable at all? */ int writable; /* is it OK to post an STS writes for this port? */ /* serial stuff should go here ..... */ } port_state; typeset struct tty_state_t { int ptm; /* pseudo terminal master fd */ char * pts_name; /* strdup'd copy of the pt slave name */ /* anything else here? ..... */ } tty_state;