コード例 #1
0
ファイル: km.c プロジェクト: PaxGordon/SEDarwin
/*
 * cdevsw interface to km driver.
 */
int
kmopen(
    dev_t dev,
    int flag,
    int devtype,
    struct proc *pp)
{
    int rtn;
    int unit;
    struct tty *tp;
    struct winsize *wp;
    int ret;

    unit = minor(dev);
    if(unit >= 1)
        return (ENXIO);

    tp = (struct tty *)&cons;
    tp->t_oproc = kmstart;
    tp->t_param = NULL;
    tp->t_dev = dev;

    if ( !(tp->t_state & TS_ISOPEN) ) {
        tp->t_iflag = TTYDEF_IFLAG;
        tp->t_oflag = TTYDEF_OFLAG;
        tp->t_cflag = (CREAD | CS8 | CLOCAL);
        tp->t_lflag = TTYDEF_LFLAG;
        tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
        termioschars(&tp->t_termios);
        ttsetwater(tp);
    } else if ((tp->t_state & TS_XCLUDE) && pp->p_ucred->cr_uid != 0)
        return EBUSY;

    tp->t_state |= TS_CARR_ON; /* lie and say carrier exists and is on. */
    ret = ((*linesw[tp->t_line].l_open)(dev, tp));
    {
        PE_Video video;
        wp = &tp->t_winsize;
        /* Magic numbers.  These are CHARWIDTH and CHARHEIGHT
         * from osfmk/ppc/POWERMAC/video_console.c
         */
        wp->ws_xpixel = 8;
        wp->ws_ypixel = 16;

        if (flag & O_POPUP)
            PE_initialize_console(0, kPETextScreen);

        bzero(&video, sizeof(video));
        PE_current_console(&video);
        if( video.v_width != 0 && video.v_height != 0 ) {
            wp->ws_col = video.v_width / wp->ws_xpixel;
            wp->ws_row = video.v_height / wp->ws_ypixel;
        } else {
            wp->ws_col = 100;
            wp->ws_row = 36;
        }
    }
    return ret;
}
コード例 #2
0
isdnbchanattach(void)
#endif
{
	int i;

	rbch_driver_id = isdn_l4_driver_attach("isdnbchan", NISDNBCHAN, &rbch_driver_functions);

	for(i=0; i < NISDNBCHAN; i++)
	{
#if defined(__FreeBSD__)
#if __FreeBSD__ == 3

#ifdef DEVFS
		rbch_softc[i].devfs_token =
			devfs_add_devswf(&isdnbchan_cdevsw, i, DV_CHR,
				     UID_ROOT, GID_WHEEL, 0600,
				     "isdnbchan%d", i);
#endif

#else
		make_dev(&isdnbchan_cdevsw, i,
			UID_ROOT, GID_WHEEL, 0600, "isdnbchan%d", i);
#endif
#endif

#if I4BRBCHACCT
#if defined(__FreeBSD__)
		callout_handle_init(&rbch_softc[i].sc_callout);
#endif
#if defined(__NetBSD__) && __NetBSD_Version__ >= 104230000
		callout_init(&rbch_softc[i].sc_callout, 0);
		selinit(&rbch_softc[i].selp);
#endif
		rbch_softc[i].sc_fn = 1;
#endif
		rbch_softc[i].sc_unit = i;
		rbch_softc[i].sc_devstate = ST_IDLE;
		rbch_softc[i].sc_hdlcq.ifq_maxlen = I4BRBCHMAXQLEN;
		rbch_softc[i].it_in.c_ispeed = rbch_softc[i].it_in.c_ospeed = 64000;
		termioschars(&rbch_softc[i].it_in);
	}
}
コード例 #3
0
ファイル: km.c プロジェクト: aglab2/darwin-xnu
/*
 * cdevsw interface to km driver.
 */
int
kmopen(dev_t dev, int flag, __unused int devtype, proc_t pp)
{
	int             unit;
	struct tty     *tp;
	struct winsize *wp;
	int             ret;

	unit = minor(dev);
	if (unit >= 1)
		return (ENXIO);

	tp = km_tty[unit];

	tty_lock(tp);

	tp->t_oproc = kmstart;
	tp->t_param = NULL;
	tp->t_dev = dev;

	if (!(tp->t_state & TS_ISOPEN)) {
		tp->t_iflag = TTYDEF_IFLAG;
		tp->t_oflag = TTYDEF_OFLAG;
		tp->t_cflag = (CREAD | CS8 | CLOCAL);
		tp->t_lflag = TTYDEF_LFLAG;
		tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
		termioschars(&tp->t_termios);
		ttsetwater(tp);
	} else if ((tp->t_state & TS_XCLUDE) && proc_suser(pp)) {
		ret = EBUSY;
		goto out;
	}

	tp->t_state |= TS_CARR_ON;	/* lie and say carrier exists and is
					 * on. */
	ret = ((*linesw[tp->t_line].l_open) (dev, tp));
	{
		PE_Video        video;
		wp = &tp->t_winsize;
		/*
		 * Magic numbers.  These are CHARWIDTH and CHARHEIGHT from
		 * pexpert/i386/video_console.c
		 */
		wp->ws_xpixel = 8;
		wp->ws_ypixel = 16;

		tty_unlock(tp);		/* XXX race window */

		if (flag & O_POPUP)
			PE_initialize_console(0, kPETextScreen);

		bzero(&video, sizeof(video));
		PE_current_console(&video);

		tty_lock(tp);

		if (serialmode & SERIALMODE_OUTPUT) {
			wp->ws_col = 80;
			wp->ws_row = 24;
		} else if (video.v_width != 0 && video.v_height != 0) {
			wp->ws_col = video.v_width / wp->ws_xpixel;
			wp->ws_row = video.v_height / wp->ws_ypixel;
		} else {
			wp->ws_col = 100;
			wp->ws_row = 36;
		}
	}

out:
	tty_unlock(tp);

	return ret;
}