pty.c (12521) | pty.c (12564) |
---|---|
1/* 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)tty_pty.c 8.2 (Berkeley) 9/23/93 | 1/* 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)tty_pty.c 8.2 (Berkeley) 9/23/93 |
34 * $Id: tty_pty.c,v 1.25 1995/11/29 10:48:28 julian Exp $ | 34 * $Id: tty_pty.c,v 1.26 1995/11/29 14:40:36 julian Exp $ |
35 */ 36 37/* 38 * Pseudo-teletype Driver 39 * (Actually two drivers, requiring two entries in 'cdevsw') 40 */ 41#include "pty.h" /* XXX */ 42 --- 20 unchanged lines hidden (view full) --- 63#if NPTY == 1 64#undef NPTY 65#define NPTY 32 /* crude XXX */ 66#endif 67 68#define BUFSIZ 100 /* Chunk size iomoved to/from user */ 69 70/* | 35 */ 36 37/* 38 * Pseudo-teletype Driver 39 * (Actually two drivers, requiring two entries in 'cdevsw') 40 */ 41#include "pty.h" /* XXX */ 42 --- 20 unchanged lines hidden (view full) --- 63#if NPTY == 1 64#undef NPTY 65#define NPTY 32 /* crude XXX */ 66#endif 67 68#define BUFSIZ 100 /* Chunk size iomoved to/from user */ 69 70/* |
71 * pts == /dev/tty[pqrs]? 72 * ptc == /dev/pty[pqrs]? | 71 * pts == /dev/tty[pqrsPQRS][0123456789abcdefghijklmnopqrstuv] 72 * ptc == /dev/pty[pqrsPQRS][0123456789abcdefghijklmnopqrstuv] |
73 */ 74struct tty pt_tty[NPTY]; /* XXX */ 75struct pt_ioctl { 76 int pt_flags; 77 struct selinfo pt_selr, pt_selw; 78 u_char pt_send; 79 u_char pt_ucntl; 80} pt_ioctl[NPTY]; /* XXX */ --- 671 unchanged lines hidden (view full) --- 752 ptcselect, nommap, NULL }; 753 754static ptc_devsw_installed = 0; 755 756static void ptc_drvinit(void *unused) 757{ 758#ifdef DEVFS 759 int i | 73 */ 74struct tty pt_tty[NPTY]; /* XXX */ 75struct pt_ioctl { 76 int pt_flags; 77 struct selinfo pt_selr, pt_selw; 78 u_char pt_send; 79 u_char pt_ucntl; 80} pt_ioctl[NPTY]; /* XXX */ --- 671 unchanged lines hidden (view full) --- 752 ptcselect, nommap, NULL }; 753 754static ptc_devsw_installed = 0; 755 756static void ptc_drvinit(void *unused) 757{ 758#ifdef DEVFS 759 int i |
760 char jnames[] = "pqrstu" 761 char knames[] = "0123456789abcdef" | 760 char jnames[] = "pqrsPQRS" 761 char knames[] = "0123456789abcdefghijklmnopqrstuv" |
762 char devname[16]; | 762 char devname[16]; |
763#define MAXUNITS (6 * 16) | 763#define MAXUNITS (8 * 32) |
764#endif 765 dev_t dev; 766 dev_t dev_c; 767 768 if( ! ptc_devsw_installed ) { 769 dev = makedev(CDEV_MAJOR_S,0); 770 cdevsw_add(&dev,&pts_cdevsw,NULL); 771 dev_c = makedev(CDEV_MAJOR_C,0); 772 cdevsw_add(&dev_c,&ptc_cdevsw,NULL); 773 ptc_devsw_installed = 1; 774#ifdef DEVFS 775/*XXX*/ 776#if NPTY > MAXUNITS 777#undef NPTY 778#define NPTY MAXUNITS 779#endif 780 for ( i = 0 ; i<NPTY ; i++ ) { 781 int x; 782 | 764#endif 765 dev_t dev; 766 dev_t dev_c; 767 768 if( ! ptc_devsw_installed ) { 769 dev = makedev(CDEV_MAJOR_S,0); 770 cdevsw_add(&dev,&pts_cdevsw,NULL); 771 dev_c = makedev(CDEV_MAJOR_C,0); 772 cdevsw_add(&dev_c,&ptc_cdevsw,NULL); 773 ptc_devsw_installed = 1; 774#ifdef DEVFS 775/*XXX*/ 776#if NPTY > MAXUNITS 777#undef NPTY 778#define NPTY MAXUNITS 779#endif 780 for ( i = 0 ; i<NPTY ; i++ ) { 781 int x; 782 |
783 j = i / 16; 784 k = i % 16; | 783 j = i / 32; 784 k = i % 32; |
785 sprintf(devname,"pty%c%c",jnames[j],knames[k]); 786 x=devfs_add_devsw("/",devname,major(dev_c),0,DV_CHR,0,0,0600); 787 sprintf(devname,"tty%c%c",jnames[j],knames[k]); 788 x=devfs_add_devsw("/",devname,major(dev),0,DV_CHR,0,0,0600); 789 } 790#endif 791 } 792} 793 794SYSINIT(ptcdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR_C,ptc_drvinit,NULL) 795 796#endif /* JREMOD */ 797 | 785 sprintf(devname,"pty%c%c",jnames[j],knames[k]); 786 x=devfs_add_devsw("/",devname,major(dev_c),0,DV_CHR,0,0,0600); 787 sprintf(devname,"tty%c%c",jnames[j],knames[k]); 788 x=devfs_add_devsw("/",devname,major(dev),0,DV_CHR,0,0,0600); 789 } 790#endif 791 } 792} 793 794SYSINIT(ptcdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR_C,ptc_drvinit,NULL) 795 796#endif /* JREMOD */ 797 |