···8989#include "list.h"9090#include "sam.h"91919292-#if 09393-static void ttyseth_pv(struct Port *, struct ttystatics *, struct termios *sg, int);9494-#endif9595-9692static void RIOClearUp(struct Port *PortP);9793int RIOShortCommand(struct rio_info *p, struct Port *PortP, int command, int len, int arg);98949999-#if 0100100-static int RIOCookMode(struct ttystatics *);101101-#endif1029510396extern int conv_vb[]; /* now defined in ttymgr.c */10497extern int conv_bv[]; /* now defined in ttymgr.c */···219226 ** until the RTA is present then we must spin here waiting for220227 ** the RTA to boot.221228 */222222-#if 0223223- if (!(PortP->HostP->Mapping[PortP->RupNum].Flags & RTA_BOOTED)) {224224- if (PortP->WaitUntilBooted) {225225- rio_dprintk(RIO_DEBUG_TTY, "Waiting for RTA to boot\n");226226- do {227227- if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL) {228228- rio_dprintk(RIO_DEBUG_TTY, "RTA EINTR in delay \n");229229- func_exit();230230- return -EINTR;231231- }232232- if (repeat_this-- <= 0) {233233- rio_dprintk(RIO_DEBUG_TTY, "Waiting for RTA to boot timeout\n");234234- RIOPreemptiveCmd(p, PortP, FCLOSE);235235- pseterr(EINTR);236236- func_exit();237237- return -EIO;238238- }239239- } while (!(PortP->HostP->Mapping[PortP->RupNum].Flags & RTA_BOOTED));240240- rio_dprintk(RIO_DEBUG_TTY, "RTA has been booted\n");241241- } else {242242- rio_dprintk(RIO_DEBUG_TTY, "RTA never booted\n");243243- pseterr(ENXIO);244244- func_exit();245245- return 0;246246- }247247- }248248-#else249229 /* I find the above code a bit hairy. I find the below code250230 easier to read and shorter. Now, if it works too that would251231 be great... -- REW ···247281 }248282 }249283 rio_dprintk(RIO_DEBUG_TTY, "RTA has been booted\n");250250-#endif251251-#if 0252252- tp = PortP->TtyP; /* get tty struct */253253-#endif254284 rio_spin_lock_irqsave(&PortP->portSem, flags);255285 if (p->RIOHalted) {256286 goto bombout;257287 }258258-#if 0259259- retval = gs_init_port(&PortP->gs);260260- if (retval) {261261- func_exit();262262- return retval;263263- }264264-#endif265288266289 /*267290 ** If the port is in the final throws of being closed,···318363 command piggybacks the parameters immediately.319364 -- REW */320365 RIOParam(PortP, OPEN, Modem, OK_TO_SLEEP); /* Open the port */321321-#if 0322322- /* This delay of 1 second was annoying. I removed it. -- REW */323323- RIODelay(PortP, HUNDRED_MS * 10);324324- RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP); /* Config the port */325325-#endif326366 rio_spin_lock_irqsave(&PortP->portSem, flags);327367328368 /*···389439 PortP->State |= RIO_WOPEN;390440 rio_spin_unlock_irqrestore(&PortP->portSem, flags);391441 if (RIODelay(PortP, HUNDRED_MS) == RIO_FAIL)392392-#if 0393393- if (sleep((caddr_t) & tp->tm.c_canqo, TTIPRI | PCATCH))394394-#endif395442 {396443 /*397444 ** ACTION: verify that this is a good thing···452505*/453506int riotclose(void *ptr)454507{455455-#if 0456456- register uint SysPort = dev;457457- struct ttystatics *tp; /* pointer to our ttystruct */458458-#endif459508 struct Port *PortP = ptr; /* pointer to the port structure */460509 int deleted = 0;461510 int try = -1; /* Disable the timeouts by setting them to -1 */···477534 end_time = jiffies + MAX_SCHEDULE_TIMEOUT;478535479536 Modem = rio_ismodem(tty);480480-#if 0481481- /* What F.CKING cache? Even then, a higly idle multiprocessor,482482- system with large caches this won't work . Better find out when 483483- this doesn't work asap, and fix the cause. -- REW */484484-485485- RIODelay(PortP, HUNDRED_MS * 10); /* To flush the cache */486486-#endif487537 rio_spin_lock_irqsave(&PortP->portSem, flags);488538489539 /*···639703}640704641705642642-/*643643-** decide if we need to use the line discipline.644644-** This routine can return one of three values:645645-** COOK_RAW if no processing has to be done by the line discipline or the card646646-** COOK_WELL if the line discipline must be used to do the processing647647-** COOK_MEDIUM if the card can do all the processing necessary.648648-*/649649-#if 0650650-static int RIOCookMode(struct ttystatics *tp)651651-{652652- /*653653- ** We can't handle tm.c_mstate != 0 on SCO654654- ** We can't handle mapping655655- ** We can't handle non-ttwrite line disc.656656- ** We can't handle lflag XCASE657657- ** We can handle oflag OPOST & (OCRNL, ONLCR, TAB3)658658- */659659-660660-#ifdef CHECK661661- CheckTtyP(tp);662662-#endif663663- if (!(tp->tm.c_oflag & OPOST)) /* No post processing */664664- return COOK_RAW; /* Raw mode o/p */665665-666666- if (tp->tm.c_lflag & XCASE)667667- return COOK_WELL; /* Use line disc */668668-669669- if (tp->tm.c_oflag & ~(OPOST | ONLCR | OCRNL | TAB3))670670- return COOK_WELL; /* Use line disc for strange modes */671671-672672- if (tp->tm.c_oflag == OPOST) /* If only OPOST is set, do RAW */673673- return COOK_RAW;674674-675675- /*676676- ** So, we need to output process!677677- */678678- return COOK_MEDIUM;679679-}680680-#endif681706682707static void RIOClearUp(PortP)683708struct Port *PortP;···673776 unsigned long flags;674777675778 rio_dprintk(RIO_DEBUG_TTY, "entering shortcommand.\n");676676-#ifdef CHECK677677- CheckPortP(PortP);678678- if (len < 1 || len > 2)679679- cprintf(("STUPID LENGTH %d\n", len));680680-#endif681779682780 if (PortP->State & RIO_DELETED) {683781 rio_dprintk(RIO_DEBUG_TTY, "Short command to deleted RTA ignored\n");···744852}745853746854747747-#if 0748748-/*749749-** This is an ioctl interface. This is the twentieth century. You know what750750-** its all about.751751-*/752752-int riotioctl(struct rio_info *p, struct tty_struct *tty, int cmd, caddr_t arg)753753-{754754- register struct Port *PortP;755755- register struct ttystatics *tp;756756- int current;757757- int ParamSemIncremented = 0;758758- int old_oflag, old_cflag, old_iflag, changed, oldcook;759759- int i;760760- unsigned char sio_regs[5]; /* Here be magic */761761- short vpix_cflag;762762- short divisor;763763- int baud;764764- uint SysPort = rio_minor(tty);765765- int Modem = rio_ismodem(tty);766766- int ioctl_processed;767767-768768- rio_dprintk(RIO_DEBUG_TTY, "port ioctl SysPort %d command 0x%x argument 0x%x %s\n", SysPort, cmd, arg, Modem ? "Modem" : "tty");769769-770770- if (SysPort >= RIO_PORTS) {771771- rio_dprintk(RIO_DEBUG_TTY, "Bad port number %d\n", SysPort);772772- return -ENXIO;773773- }774774-775775- PortP = p->RIOPortp[SysPort];776776- tp = PortP->TtyP;777777-778778- rio_spin_lock_irqsave(&PortP->portSem, flags);779779-780780-#ifdef STATS781781- PortP->Stat.IoctlCnt++;782782-#endif783783-784784- if (PortP->State & RIO_DELETED) {785785- rio_spin_unlock_irqrestore(&PortP->portSem, flags);786786- return -EIO;787787- }788788-789789-790790- if (p->RIOHalted) {791791- RIOClearUp(PortP);792792- rio_spin_unlock_irqrestore(&PortP->portSem, flags);793793- return -EIO;794794- }795795-796796- /*797797- ** Count ioctls for port statistics reporting798798- */799799- if (PortP->statsGather)800800- PortP->ioctls++;801801-802802- /*803803- ** Specialix RIO Ioctl calls804804- */805805- switch (cmd) {806806-807807- case TCRIOTRIAD:808808- if (arg)809809- PortP->State |= RIO_TRIAD_MODE;810810- else811811- PortP->State &= ~RIO_TRIAD_MODE;812812- /*813813- ** Normally, when istrip is set on a port, a config is814814- ** sent to the RTA instructing the CD1400 to do the815815- ** stripping. In TRIAD mode, the interrupt receive routine816816- ** must do the stripping instead, since it has to detect817817- ** an 8 bit function key sequence. If istrip is set with818818- ** TRIAD mode on(off), and 8 bit data is being read by819819- ** the port, the user then turns TRIAD mode off(on), the RTA820820- ** must be reconfigured (not) to do the stripping.821821- ** Hence we call RIOParam here.822822- */823823- rio_spin_unlock_irqrestore(&PortP->portSem, flags);824824- RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);825825- return 0;826826-827827- case TCRIOTSTATE:828828- rio_dprintk(RIO_DEBUG_TTY, "tbusy/tstop monitoring %sabled\n", arg ? "en" : "dis");829829- /* MonitorTstate = 0 ; */830830- rio_spin_unlock_irqrestore(&PortP->portSem, flags);831831- RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);832832- return 0;833833-834834- case TCRIOSTATE: /* current state of Modem input pins */835835- rio_dprintk(RIO_DEBUG_TTY, "TCRIOSTATE\n");836836- if (RIOPreemptiveCmd(p, PortP, MGET) == RIO_FAIL)837837- rio_dprintk(RIO_DEBUG_TTY, "TCRIOSTATE command failed\n");838838- PortP->State |= RIO_BUSY;839839- current = PortP->ModemState;840840- if (copyout((caddr_t) & current, (int) arg, sizeof(current)) == COPYFAIL) {841841- rio_dprintk(RIO_DEBUG_TTY, "Copyout failed\n");842842- rio_spin_unlock_irqrestore(&PortP->portSem, flags);843843- pseterr(EFAULT);844844- }845845- rio_spin_unlock_irqrestore(&PortP->portSem, flags);846846- return 0;847847-848848- case TCRIOMBIS: /* Set modem lines */849849- case TCRIOMBIC: /* Clear modem lines */850850- rio_dprintk(RIO_DEBUG_TTY, "TCRIOMBIS/TCRIOMBIC\n");851851- if (cmd == TCRIOMBIS) {852852- uint state;853853- state = (uint) arg;854854- PortP->ModemState |= (ushort) state;855855- PortP->ModemLines = (ulong) arg;856856- if (RIOPreemptiveCmd(p, PortP, MBIS) == RIO_FAIL)857857- rio_dprintk(RIO_DEBUG_TTY, "TCRIOMBIS command failed\n");858858- } else {859859- uint state;860860-861861- state = (uint) arg;862862- PortP->ModemState &= ~(ushort) state;863863- PortP->ModemLines = (ulong) arg;864864- if (RIOPreemptiveCmd(p, PortP, MBIC) == RIO_FAIL)865865- rio_dprintk(RIO_DEBUG_TTY, "TCRIOMBIC command failed\n");866866- }867867- PortP->State |= RIO_BUSY;868868- rio_spin_unlock_irqrestore(&PortP->portSem, flags);869869- return 0;870870-871871- case TCRIOXPON: /* set Xprint ON string */872872- rio_dprintk(RIO_DEBUG_TTY, "TCRIOXPON\n");873873- if (copyin((int) arg, (caddr_t) PortP->Xprint.XpOn, MAX_XP_CTRL_LEN) == COPYFAIL) {874874- rio_dprintk(RIO_DEBUG_TTY, "Copyin failed\n");875875- PortP->Xprint.XpOn[0] = '\0';876876- rio_spin_unlock_irqrestore(&PortP->portSem, flags);877877- pseterr(EFAULT);878878- }879879- PortP->Xprint.XpOn[MAX_XP_CTRL_LEN - 1] = '\0';880880- PortP->Xprint.XpLen = strlen(PortP->Xprint.XpOn) + strlen(PortP->Xprint.XpOff);881881- rio_spin_unlock_irqrestore(&PortP->portSem, flags);882882- return 0;883883-884884- case TCRIOXPOFF: /* set Xprint OFF string */885885- rio_dprintk(RIO_DEBUG_TTY, "TCRIOXPOFF\n");886886- if (copyin((int) arg, (caddr_t) PortP->Xprint.XpOff, MAX_XP_CTRL_LEN) == COPYFAIL) {887887- rio_dprintk(RIO_DEBUG_TTY, "Copyin failed\n");888888- PortP->Xprint.XpOff[0] = '\0';889889- rio_spin_unlock_irqrestore(&PortP->portSem, flags);890890- pseterr(EFAULT);891891- }892892- PortP->Xprint.XpOff[MAX_XP_CTRL_LEN - 1] = '\0';893893- PortP->Xprint.XpLen = strlen(PortP->Xprint.XpOn) + strlen(PortP->Xprint.XpOff);894894- rio_spin_unlock_irqrestore(&PortP->portSem, flags);895895- return 0;896896-897897- case TCRIOXPCPS: /* set Xprint CPS string */898898- rio_dprintk(RIO_DEBUG_TTY, "TCRIOXPCPS\n");899899- if ((uint) arg > p->RIOConf.MaxXpCps || (uint) arg < p->RIOConf.MinXpCps) {900900- rio_dprintk(RIO_DEBUG_TTY, "%d CPS out of range\n", arg);901901- rio_spin_unlock_irqrestore(&PortP->portSem, flags);902902- pseterr(EINVAL);903903- return 0;904904- }905905- PortP->Xprint.XpCps = (uint) arg;906906- rio_spin_unlock_irqrestore(&PortP->portSem, flags);907907- return 0;908908-909909- case TCRIOXPRINT:910910- rio_dprintk(RIO_DEBUG_TTY, "TCRIOXPRINT\n");911911- if (copyout((caddr_t) & PortP->Xprint, (int) arg, sizeof(struct Xprint)) == COPYFAIL) {912912- rio_spin_unlock_irqrestore(&PortP->portSem, flags);913913- pseterr(EFAULT);914914- }915915- rio_spin_unlock_irqrestore(&PortP->portSem, flags);916916- return 0;917917-918918- case TCRIOIXANYON:919919- rio_dprintk(RIO_DEBUG_TTY, "TCRIOIXANYON\n");920920- PortP->Config |= RIO_IXANY;921921- rio_spin_unlock_irqrestore(&PortP->portSem, flags);922922- return 0;923923-924924- case TCRIOIXANYOFF:925925- rio_dprintk(RIO_DEBUG_TTY, "TCRIOIXANYOFF\n");926926- PortP->Config &= ~RIO_IXANY;927927- rio_spin_unlock_irqrestore(&PortP->portSem, flags);928928- return 0;929929-930930- case TCRIOIXONON:931931- rio_dprintk(RIO_DEBUG_TTY, "TCRIOIXONON\n");932932- PortP->Config |= RIO_IXON;933933- rio_spin_unlock_irqrestore(&PortP->portSem, flags);934934- return 0;935935-936936- case TCRIOIXONOFF:937937- rio_dprintk(RIO_DEBUG_TTY, "TCRIOIXONOFF\n");938938- PortP->Config &= ~RIO_IXON;939939- rio_spin_unlock_irqrestore(&PortP->portSem, flags);940940- return 0;941941-942942-/*943943-** 15.10.1998 ARG - ESIL 0761 part fix944944-** Added support for CTS and RTS flow control ioctls :945945-*/946946- case TCRIOCTSFLOWEN:947947- rio_dprintk(RIO_DEBUG_TTY, "TCRIOCTSFLOWEN\n");948948- PortP->Config |= RIO_CTSFLOW;949949- rio_spin_unlock_irqrestore(&PortP->portSem, flags);950950- RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);951951- return 0;952952-953953- case TCRIOCTSFLOWDIS:954954- rio_dprintk(RIO_DEBUG_TTY, "TCRIOCTSFLOWDIS\n");955955- PortP->Config &= ~RIO_CTSFLOW;956956- rio_spin_unlock_irqrestore(&PortP->portSem, flags);957957- RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);958958- return 0;959959-960960- case TCRIORTSFLOWEN:961961- rio_dprintk(RIO_DEBUG_TTY, "TCRIORTSFLOWEN\n");962962- PortP->Config |= RIO_RTSFLOW;963963- rio_spin_unlock_irqrestore(&PortP->portSem, flags);964964- RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);965965- return 0;966966-967967- case TCRIORTSFLOWDIS:968968- rio_dprintk(RIO_DEBUG_TTY, "TCRIORTSFLOWDIS\n");969969- PortP->Config &= ~RIO_RTSFLOW;970970- rio_spin_unlock_irqrestore(&PortP->portSem, flags);971971- RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);972972- return 0;973973-974974-/* end ESIL 0761 part fix */975975-976976- }977977-978978-979979- /* Lynx IOCTLS */980980- switch (cmd) {981981- case TIOCSETP:982982- case TIOCSETN:983983- case OTIOCSETP:984984- case OTIOCSETN:985985- ioctl_processed++;986986- ttyseth(PortP, tp, (struct old_sgttyb *) arg);987987- break;988988- case TCSETA:989989- case TCSETAW:990990- case TCSETAF:991991- ioctl_processed++;992992- rio_dprintk(RIO_DEBUG_TTY, "NON POSIX ioctl\n");993993- ttyseth_pv(PortP, tp, (struct termios *) arg, 0);994994- break;995995- case TCSETAP: /* posix tcsetattr() */996996- case TCSETAWP: /* posix tcsetattr() */997997- case TCSETAFP: /* posix tcsetattr() */998998- rio_dprintk(RIO_DEBUG_TTY, "NON POSIX SYSV ioctl\n");999999- ttyseth_pv(PortP, tp, (struct termios *) arg, 1);10001000- ioctl_processed++;10011001- break;10021002- }10031003-10041004- /*10051005- ** If its any of the commands that require the port to be in the10061006- ** non-busy state wait until all output has drained10071007- */10081008- if (!ioctl_processed)10091009- switch (cmd) {10101010- case TCSETAW:10111011- case TCSETAF:10121012- case TCSETA:10131013- case TCSBRK:10141014-#define OLD_POSIX ('x' << 8)10151015-#define OLD_POSIX_SETA (OLD_POSIX | 2)10161016-#define OLD_POSIX_SETAW (OLD_POSIX | 3)10171017-#define OLD_POSIX_SETAF (OLD_POSIX | 4)10181018-#define NEW_POSIX (('i' << 24) | ('X' << 16))10191019-#define NEW_POSIX_SETA (NEW_POSIX | 2)10201020-#define NEW_POSIX_SETAW (NEW_POSIX | 3)10211021-#define NEW_POSIX_SETAF (NEW_POSIX | 4)10221022- case OLD_POSIX_SETA:10231023- case OLD_POSIX_SETAW:10241024- case OLD_POSIX_SETAF:10251025- case NEW_POSIX_SETA:10261026- case NEW_POSIX_SETAW:10271027- case NEW_POSIX_SETAF:10281028-#ifdef TIOCSETP10291029- case TIOCSETP:10301030-#endif10311031- case TIOCSETD:10321032- case TIOCSETN:10331033- rio_dprintk(RIO_DEBUG_TTY, "wait for non-BUSY, semaphore set\n");10341034- /*10351035- ** Wait for drain here, at least as far as the double buffer10361036- ** being empty.10371037- */10381038- /* XXX Does the above comment mean that this has10391039- still to be implemented? -- REW */10401040- /* XXX Is the locking OK together with locking10411041- in txenable? (Deadlock?) -- REW */10421042-10431043- RIOTxEnable((char *) PortP);10441044- break;10451045- default:10461046- break;10471047- }10481048-10491049- old_cflag = tp->tm.c_cflag;10501050- old_iflag = tp->tm.c_iflag;10511051- old_oflag = tp->tm.c_oflag;10521052- oldcook = PortP->CookMode;10531053-10541054- if (p->RIOHalted) {10551055- RIOClearUp(PortP);10561056- rio_spin_unlock_irqrestore(&PortP->portSem, flags);10571057- pseterr(EIO);10581058- return 0;10591059- }10601060-10611061- PortP->FlushCmdBodge = 0;10621062-10631063- /*10641064- ** If the port is locked, and it is reconfigured, we want10651065- ** to restore the state of the tty structure so the change is NOT10661066- ** made.10671067- */10681068- if (PortP->Lock) {10691069- tp->tm.c_iflag = PortP->StoredTty.iflag;10701070- tp->tm.c_oflag = PortP->StoredTty.oflag;10711071- tp->tm.c_cflag = PortP->StoredTty.cflag;10721072- tp->tm.c_lflag = PortP->StoredTty.lflag;10731073- tp->tm.c_line = PortP->StoredTty.line;10741074- for (i = 0; i < NCC + 1; i++)10751075- tp->tm.c_cc[i] = PortP->StoredTty.cc[i];10761076- } else {10771077- /*10781078- ** If the port is set to store the parameters, and it is10791079- ** reconfigured, we want to save the current tty struct so it10801080- ** may be restored on the next open.10811081- */10821082- if (PortP->Store) {10831083- PortP->StoredTty.iflag = tp->tm.c_iflag;10841084- PortP->StoredTty.oflag = tp->tm.c_oflag;10851085- PortP->StoredTty.cflag = tp->tm.c_cflag;10861086- PortP->StoredTty.lflag = tp->tm.c_lflag;10871087- PortP->StoredTty.line = tp->tm.c_line;10881088- for (i = 0; i < NCC + 1; i++)10891089- PortP->StoredTty.cc[i] = tp->tm.c_cc[i];10901090- }10911091- }10921092-10931093- changed = (tp->tm.c_cflag != old_cflag) || (tp->tm.c_iflag != old_iflag) || (tp->tm.c_oflag != old_oflag);10941094-10951095- PortP->CookMode = RIOCookMode(tp); /* Set new cooking mode */10961096-10971097- rio_dprintk(RIO_DEBUG_TTY, "RIOIoctl changed %d newcook %d oldcook %d\n", changed, PortP->CookMode, oldcook);10981098-10991099-#ifdef MODEM_SUPPORT11001100- /*11011101- ** kludge to force CARR_ON if CLOCAL set11021102- */11031103- if ((tp->tm.c_cflag & CLOCAL) || (PortP->ModemState & MSVR1_CD)) {11041104- tp->tm.c_state |= CARR_ON;11051105- wakeup((caddr_t) & tp->tm.c_canq);11061106- }11071107-#endif11081108-11091109- if (p->RIOHalted) {11101110- RIOClearUp(PortP);11111111- rio_spin_unlock_irqrestore(&PortP->portSem, flags);11121112- pseterr(EIO);11131113- return 0;11141114- }11151115- /*11161116- ** Re-configure if modes or cooking have changed11171117- */11181118- if (changed || oldcook != PortP->CookMode || (ioctl_processed)) {11191119- rio_spin_unlock_irqrestore(&PortP->portSem, flags);11201120- rio_dprintk(RIO_DEBUG_TTY, "Ioctl changing the PORT settings\n");11211121- RIOParam(PortP, CONFIG, Modem, OK_TO_SLEEP);11221122- rio_spin_lock_irqsave(&PortP->portSem, flags);11231123- }11241124-11251125- if (p->RIOHalted) {11261126- rio_spin_unlock_irqrestore(&PortP->portSem, flags);11271127- RIOClearUp(PortP);11281128- pseterr(EIO);11291129- return 0;11301130- }11311131- rio_spin_unlock_irqrestore(&PortP->portSem, flags);11321132- return 0;11331133-}11341134-11351135-/*11361136- ttyseth -- set hardware dependent tty settings11371137-*/11381138-void ttyseth(PortP, s, sg)11391139-struct Port *PortP;11401140-struct ttystatics *s;11411141-struct old_sgttyb *sg;11421142-{11431143- struct old_sgttyb *tsg;11441144- struct termios *tp = &s->tm;11451145-11461146- tsg = &s->sg;11471147-11481148- if (sg->sg_flags & (EVENP | ODDP)) {11491149- tp->c_cflag &= PARENB;11501150- if (sg->sg_flags & EVENP) {11511151- if (sg->sg_flags & ODDP) {11521152- tp->c_cflag &= V_CS7;11531153- tp->c_cflag &= ~PARENB;11541154- } else {11551155- tp->c_cflag &= V_CS7;11561156- tp->c_cflag &= PARENB;11571157- tp->c_cflag &= PARODD;11581158- }11591159- } else if (sg->sg_flags & ODDP) {11601160- tp->c_cflag &= V_CS7;11611161- tp->c_cflag &= PARENB;11621162- tp->c_cflag &= PARODD;11631163- } else {11641164- tp->c_cflag &= V_CS7;11651165- tp->c_cflag &= PARENB;11661166- }11671167- }11681168-/*11691169- * Use ispeed as the desired speed. Most implementations don't handle 11701170- * separate input and output speeds very well. If the RIO handles this, 11711171- * I will have to use separate sets of flags to store them in the 11721172- * Port structure.11731173- */11741174- if (!sg->sg_ospeed)11751175- sg->sg_ospeed = sg->sg_ispeed;11761176- else11771177- sg->sg_ispeed = sg->sg_ospeed;11781178- if (sg->sg_ispeed > V_EXTB)11791179- sg->sg_ispeed = V_EXTB;11801180- if (sg->sg_ispeed < V_B0)11811181- sg->sg_ispeed = V_B0;11821182- *tsg = *sg;11831183- tp->c_cflag = (tp->c_cflag & ~V_CBAUD) | conv_bv[(int) sg->sg_ispeed];11841184-}11851185-11861186-/*11871187- ttyseth_pv -- set hardware dependent tty settings using either the11881188- POSIX termios structure or the System V termio structure.11891189- sysv = 0 => (POSIX): struct termios *sg11901190- sysv != 0 => (System V): struct termio *sg11911191-*/11921192-static void ttyseth_pv(PortP, s, sg, sysv)11931193-struct Port *PortP;11941194-struct ttystatics *s;11951195-struct termios *sg;11961196-int sysv;11971197-{11981198- int speed;11991199- unsigned char csize;12001200- unsigned char cread;12011201- unsigned int lcr_flags;12021202- int ps;12031203-12041204- if (sysv) {12051205- /* sg points to a System V termio structure */12061206- csize = ((struct termio *) sg)->c_cflag & CSIZE;12071207- cread = ((struct termio *) sg)->c_cflag & CREAD;12081208- speed = conv_vb[((struct termio *) sg)->c_cflag & V_CBAUD];12091209- } else {12101210- /* sg points to a POSIX termios structure */12111211- csize = sg->c_cflag & CSIZE;12121212- cread = sg->c_cflag & CREAD;12131213- speed = conv_vb[sg->c_cflag & V_CBAUD];12141214- }12151215- if (s->sg.sg_ispeed != speed || s->sg.sg_ospeed != speed) {12161216- s->sg.sg_ispeed = speed;12171217- s->sg.sg_ospeed = speed;12181218- s->tm.c_cflag = (s->tm.c_cflag & ~V_CBAUD) | conv_bv[(int) s->sg.sg_ispeed];12191219- }12201220-}12211221-#endif