1*6bb51422Spooka /* $NetBSD: tty_component.c,v 1.4 2016/01/26 23:12:17 pooka Exp $ */
2e9fb1375Spooka
3e9fb1375Spooka /*
4e9fb1375Spooka * Copyright (c) 2010 Antti Kantee. All Rights Reserved.
5e9fb1375Spooka *
6e9fb1375Spooka * Redistribution and use in source and binary forms, with or without
7e9fb1375Spooka * modification, are permitted provided that the following conditions
8e9fb1375Spooka * are met:
9e9fb1375Spooka * 1. Redistributions of source code must retain the above copyright
10e9fb1375Spooka * notice, this list of conditions and the following disclaimer.
11e9fb1375Spooka * 2. Redistributions in binary form must reproduce the above copyright
12e9fb1375Spooka * notice, this list of conditions and the following disclaimer in the
13e9fb1375Spooka * documentation and/or other materials provided with the distribution.
14e9fb1375Spooka *
15e9fb1375Spooka * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS
16e9fb1375Spooka * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17e9fb1375Spooka * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18e9fb1375Spooka * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19e9fb1375Spooka * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20e9fb1375Spooka * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
21e9fb1375Spooka * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22e9fb1375Spooka * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23e9fb1375Spooka * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24e9fb1375Spooka * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25e9fb1375Spooka * SUCH DAMAGE.
26e9fb1375Spooka */
27e9fb1375Spooka
28e9fb1375Spooka #include <sys/cdefs.h>
29*6bb51422Spooka __KERNEL_RCSID(0, "$NetBSD: tty_component.c,v 1.4 2016/01/26 23:12:17 pooka Exp $");
30e9fb1375Spooka
31e9fb1375Spooka #include <sys/param.h>
32e9fb1375Spooka #include <sys/conf.h>
33e9fb1375Spooka #include <sys/stat.h>
34e9fb1375Spooka #include <sys/tty.h>
35e9fb1375Spooka
36*6bb51422Spooka #include <rump-sys/kern.h>
37*6bb51422Spooka #include <rump-sys/vfs.h>
38e9fb1375Spooka
391a4eecf1Schristos #include "ioconf.h"
40e9fb1375Spooka
RUMP_COMPONENT(RUMP_COMPONENT_KERN)4113f1407fSpooka RUMP_COMPONENT(RUMP_COMPONENT_KERN)
4213f1407fSpooka {
4313f1407fSpooka
4413f1407fSpooka tty_init();
4513f1407fSpooka ttyldisc_init();
4613f1407fSpooka
4713f1407fSpooka rump_ttycomponent = true;
4813f1407fSpooka }
4913f1407fSpooka
RUMP_COMPONENT(RUMP_COMPONENT_KERN_VFS)50e9fb1375Spooka RUMP_COMPONENT(RUMP_COMPONENT_KERN_VFS)
51e9fb1375Spooka {
52e9fb1375Spooka extern const struct cdevsw ctty_cdevsw, ptc_cdevsw, pts_cdevsw;
53e9fb1375Spooka extern const struct cdevsw ptm_cdevsw;
54e9fb1375Spooka devmajor_t cmaj, bmaj;
55e9fb1375Spooka
56e9fb1375Spooka cmaj = bmaj = -1;
57e9fb1375Spooka FLAWLESSCALL(devsw_attach("ctty", NULL, &bmaj, &ctty_cdevsw, &cmaj));
58e9fb1375Spooka FLAWLESSCALL(rump_vfs_makeonedevnode(S_IFCHR, "/dev/tty", cmaj, 0));
59e9fb1375Spooka
60e9fb1375Spooka /* create only 10 nodes. should be enough for everyone ... */
61e9fb1375Spooka cmaj = bmaj = -1;
62e9fb1375Spooka FLAWLESSCALL(devsw_attach("ptc", NULL, &bmaj, &ptc_cdevsw, &cmaj));
63e9fb1375Spooka FLAWLESSCALL(rump_vfs_makedevnodes(S_IFCHR, "/dev/ptyp", '0',
64e9fb1375Spooka cmaj, 0, 9));
65e9fb1375Spooka
66e9fb1375Spooka cmaj = bmaj = -1;
67e9fb1375Spooka FLAWLESSCALL(devsw_attach("pts", NULL, &bmaj, &pts_cdevsw, &cmaj));
68e9fb1375Spooka FLAWLESSCALL(rump_vfs_makedevnodes(S_IFCHR, "/dev/ttyp", '0',
69e9fb1375Spooka cmaj, 0, 9));
70e9fb1375Spooka
71e9fb1375Spooka cmaj = bmaj = -1;
72e9fb1375Spooka FLAWLESSCALL(devsw_attach("ptm", NULL, &bmaj, &ptm_cdevsw, &cmaj));
73e9fb1375Spooka FLAWLESSCALL(rump_vfs_makeonedevnode(S_IFCHR, "/dev/ptmx", cmaj, 0));
74e9fb1375Spooka FLAWLESSCALL(rump_vfs_makeonedevnode(S_IFCHR, "/dev/ptm", cmaj, 1));
75e9fb1375Spooka
76e9fb1375Spooka ptyattach(1);
77e9fb1375Spooka }
78