|
Lines 129-161
Link Here
|
| 129 |
#define PF_NOSTOP 0x40 |
129 |
#define PF_NOSTOP 0x40 |
| 130 |
#define PF_UCNTL 0x80 /* user control mode */ |
130 |
#define PF_UCNTL 0x80 /* user control mode */ |
| 131 |
|
131 |
|
|
|
132 |
/* the opposite of lminor() */ |
| 133 |
#define ptyminor(x) ((((x) &~ 255) << 8) | ((x) & 255)) |
| 134 |
/* *MUST* be the same as in lib/libutil/pty.c and etc/MAKEDEV */ |
| 135 |
#define ptyclassnames "pqrstuwxyzPQRSTUVWXYZ" |
| 136 |
#define ptyinstancenames "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ" |
| 137 |
#define nptyclass (sizeof(ptyclassnames)-1) |
| 138 |
#define nptyinstance (sizeof(ptyinstancenames)-1) |
| 139 |
#define npty (nptyclass*nptyinstance) |
| 140 |
|
| 132 |
/* |
141 |
/* |
| 133 |
* This function creates and initializes a pts/ptc pair |
142 |
* This function creates and initializes a pts/ptc pair |
|
|
143 |
* |
| 144 |
* pts == /dev/tty[p-uw-zP-Z][0-9a-zA-Z] |
| 145 |
* ptc == /dev/pty[p-uw-zP-Z][0-9a-zA-Z] |
| 134 |
* |
146 |
* |
| 135 |
* pts == /dev/tty[pqrsPQRS][0123456789abcdefghijklmnopqrstuv] |
147 |
* don't use the "v" master/slave pair bcoz it clash w/ the syscons driver. |
| 136 |
* ptc == /dev/pty[pqrsPQRS][0123456789abcdefghijklmnopqrstuv] |
148 |
* same assertion about the less used Cronyx/Sigma (xyz) and Rocketport (R) |
|
|
149 |
* drivers. |
| 137 |
* |
150 |
* |
| 138 |
* XXX: define and add mapping of upper minor bits to allow more |
|
|
| 139 |
* than 256 ptys. |
| 140 |
*/ |
151 |
*/ |
| 141 |
static void |
152 |
static void |
| 142 |
ptyinit(n) |
153 |
ptyinit(n) |
| 143 |
int n; |
154 |
int n; |
| 144 |
{ |
155 |
{ |
| 145 |
dev_t devs, devc; |
156 |
dev_t devs, devc; |
| 146 |
char *names = "pqrsPQRS"; |
157 |
char *classes = ptyclassnames; |
|
|
158 |
char *instances = ptyinstancenames; |
| 147 |
struct pt_ioctl *pt; |
159 |
struct pt_ioctl *pt; |
| 148 |
|
160 |
|
| 149 |
/* For now we only map the lower 8 bits of the minor */ |
161 |
#ifdef notdef |
| 150 |
if (n & ~0xff) |
162 |
if (bootverbose) |
|
|
163 |
printf ("ptyinit: n(%d) <= %d\n", n, npty); |
| 164 |
#endif |
| 165 |
/* be safe */ |
| 166 |
if (n >= npty) |
| 151 |
return; |
167 |
return; |
| 152 |
|
168 |
#ifdef notdef |
|
|
169 |
if (bootverbose) |
| 170 |
printf ("ptyinit: makedev([tp]ty%c%c)\n", |
| 171 |
classes[n / nptyinstance], instances[n % nptyinstance]); |
| 172 |
#endif |
| 153 |
pt = malloc(sizeof(*pt), M_PTY, M_WAITOK); |
173 |
pt = malloc(sizeof(*pt), M_PTY, M_WAITOK); |
| 154 |
bzero(pt, sizeof(*pt)); |
174 |
bzero(pt, sizeof(*pt)); |
| 155 |
pt->devs = devs = make_dev(&pts_cdevsw, n, |
175 |
pt->devs = devs = make_dev(&pts_cdevsw, ptyminor(n), |
| 156 |
0, 0, 0666, "tty%c%r", names[n / 32], n % 32); |
176 |
0, 0, 0666, "tty%c%c", |
| 157 |
pt->devc = devc = make_dev(&ptc_cdevsw, n, |
177 |
classes[n / nptyinstance], instances[n % nptyinstance]); |
| 158 |
0, 0, 0666, "pty%c%r", names[n / 32], n % 32); |
178 |
pt->devc = devc = make_dev(&ptc_cdevsw, ptyminor(n), |
|
|
179 |
0, 0, 0666, "pty%c%c", |
| 180 |
classes[n / nptyinstance], instances[n % nptyinstance]); |
| 159 |
|
181 |
|
| 160 |
devs->si_drv1 = devc->si_drv1 = pt; |
182 |
devs->si_drv1 = devc->si_drv1 = pt; |
| 161 |
devs->si_tty = devc->si_tty = &pt->pt_tty; |
183 |
devs->si_tty = devc->si_tty = &pt->pt_tty; |
|
Lines 171-177
Link Here
|
| 171 |
{ |
193 |
{ |
| 172 |
register struct tty *tp; |
194 |
register struct tty *tp; |
| 173 |
int error; |
195 |
int error; |
| 174 |
int minr; |
196 |
int minr, nextminr; |
| 175 |
dev_t nextdev; |
197 |
dev_t nextdev; |
| 176 |
struct pt_ioctl *pti; |
198 |
struct pt_ioctl *pti; |
| 177 |
|
199 |
|
|
Lines 181-194
Link Here
|
| 181 |
* next one too, so people can open it. |
203 |
* next one too, so people can open it. |
| 182 |
*/ |
204 |
*/ |
| 183 |
minr = lminor(dev); |
205 |
minr = lminor(dev); |
| 184 |
if (minr < 255) { |
206 |
nextminr = minr+1; |
| 185 |
nextdev = makedev(major(dev), minr + 1); |
207 |
if (nextminr < npty) { |
| 186 |
if (!nextdev->si_drv1) { |
208 |
nextdev = makedev(major(dev), ptyminor(nextminr)); |
| 187 |
ptyinit(minr + 1); |
209 |
if (!nextdev->si_drv1) |
| 188 |
} |
210 |
ptyinit(nextminr); |
| 189 |
} |
211 |
} |
| 190 |
if (!dev->si_drv1) |
212 |
if (!dev->si_drv1) |
| 191 |
ptyinit(minor(dev)); |
213 |
ptyinit(minr); |
|
|
214 |
#ifdef notdef |
| 215 |
if (bootverbose) |
| 216 |
printf ("ptyopen: makedev(%d:%#x)\n", |
| 217 |
major(dev), ptyminor(minr)); |
| 218 |
#endif |
| 192 |
if (!dev->si_drv1) |
219 |
if (!dev->si_drv1) |
| 193 |
return(ENXIO); |
220 |
return(ENXIO); |
| 194 |
pti = dev->si_drv1; |
221 |
pti = dev->si_drv1; |
|
Lines 351-359
Link Here
|
| 351 |
struct pt_ioctl *pti; |
378 |
struct pt_ioctl *pti; |
| 352 |
|
379 |
|
| 353 |
if (!dev->si_drv1) |
380 |
if (!dev->si_drv1) |
| 354 |
ptyinit(minor(dev)); |
381 |
ptyinit(lminor(dev)); |
| 355 |
if (!dev->si_drv1) |
382 |
if (!dev->si_drv1) |
| 356 |
return(ENXIO); |
383 |
return(ENXIO); |
| 357 |
tp = dev->si_tty; |
384 |
tp = dev->si_tty; |
| 358 |
if (tp->t_oproc) |
385 |
if (tp->t_oproc) |
| 359 |
return (EIO); |
386 |
return (EIO); |