Beispiel #1
0
/*
 * 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;
}
Beispiel #2
0
/*
 * 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;
}
IOReturn IOPlatformExpert::getConsoleInfo( PE_Video * consoleInfo )
{
    return( PE_current_console( consoleInfo));
}