00001 00007 /* Embedded XINU, Copyright (C) 2007. All rights reserved. */ 00008 00009 #include <kernel.h> 00010 #include <device.h> 00011 #include <tty.h> 00012 00021 devcall ttyControl(device *pdev, uchar func, uchar arg1, uchar arg2) 00022 { 00023 struct tty *ptty; 00024 device *phw; 00025 char old; 00026 00027 ptty = (struct tty *)pdev->controlblk; 00028 ASSERT((NULL != ptty) && (TTY_STATE_ALLOC == ptty->state)); 00029 00030 phw = ptty->tty_phw; 00031 ASSERT(NULL != phw); 00032 00033 switch (func) 00034 { 00035 /* Set input flags: arg1 = flags to set */ 00036 /* return old value of flags */ 00037 case TTY_IOC_SETIFLAG: 00038 old = ptty->iflags & arg1; 00039 ptty->iflags |= (arg1); 00040 return old; 00041 00042 /* Clear input flags: arg1 = flags to clear */ 00043 /* return old value of flags */ 00044 case TTY_IOC_CLRIFLAG: 00045 old = ptty->iflags & arg1; 00046 ptty->iflags &= ~(arg1); 00047 return old; 00048 00049 /* Get input flags: */ 00050 /* return = current value of flags */ 00051 case TTY_IOC_GETIFLAG: 00052 return ptty->iflags; 00053 00054 /* Set output flags: arg1 = flags to set */ 00055 /* return old value of flags */ 00056 case TTY_IOC_SETOFLAG: 00057 old = ptty->oflags & arg1; 00058 ptty->oflags |= (arg1); 00059 return old; 00060 00061 /* Clear output flags: arg1 = flags to clear */ 00062 /* return old value of flags */ 00063 case TTY_IOC_CLROFLAG: 00064 old = ptty->oflags & arg1; 00065 ptty->oflags &= ~(arg1); 00066 return old; 00067 00068 /* Get output flags: */ 00069 /* return current value of flags */ 00070 case TTY_IOC_GETOFLAG: 00071 return ptty->oflags; 00072 00073 /* Return true if EOF was seen in input */ 00074 case TTY_IOC_EOF: 00075 return (ptty->iflags & TTY_IFLAG_EOF); 00076 00077 /* Return true if CBREAK was seen in input */ 00078 case TTY_IOC_CBREAK: 00079 return (ptty->iflags & TTY_IFLAG_CBREAK); 00080 00081 /* Peek at next input character */ 00082 case TTY_IOC_NEXTC: 00083 if (ptty->icount < 1) 00084 { 00085 old = (*phw->getc)(phw); 00086 ASSERT(old != SYSERR); 00087 } 00088 else 00089 { 00090 old = ptty->inbuf[ptty->istart]; 00091 } 00092 return old; 00093 } 00094 00095 return SYSERR; 00096 }