Пример #1
0
int
sc_hist_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
{
	scr_stat *scp;
	int error;

	switch (cmd) {

	case CONS_HISTORY:  	/* set history size */
		scp = SC_STAT(tp);
		if (*(int *)data <= 0)
			return EINVAL;
		if (scp->status & BUFFER_SAVED)
			return EBUSY;
		DPRINTF(5, ("lines:%d, ysize:%d, pool:%d\n",
			    *(int *)data, scp->ysize, extra_history_size));
		error = sc_alloc_history_buffer(scp, 
					       imax(*(int *)data, scp->ysize),
					       scp->ysize, TRUE);
		DPRINTF(5, ("error:%d, rows:%d, pool:%d\n", error,
			    sc_vtb_rows(scp->history), extra_history_size));
		return error;

	case CONS_CLRHIST:
		scp = SC_STAT(tp);
		sc_vtb_clear(scp->history, scp->sc->scr_map[0x20],
		    SC_NORM_ATTR << 8);
		return 0;
	}

	return ENOIOCTL;
}
Пример #2
0
int
sc_set_text_mode(scr_stat *scp, struct tty *tp, int mode, int xsize, int ysize,
                 int fontsize, int fontwidth)
{
    video_info_t info;
    u_char *font;
    int prev_ysize;
    int error;
    int s;

    if (vidd_get_info(scp->sc->adp, mode, &info))
        return ENODEV;

    /* adjust argument values */
    if (fontwidth <= 0)
        fontwidth = info.vi_cwidth;
    if (fontsize <= 0)
        fontsize = info.vi_cheight;
    if (fontsize < 14) {
        fontsize = 8;
#ifndef SC_NO_FONT_LOADING
        if (!(scp->sc->fonts_loaded & FONT_8))
            return EINVAL;
        font = scp->sc->font_8;
#else
        font = NULL;
#endif
    } else if (fontsize >= 16) {
        fontsize = 16;
#ifndef SC_NO_FONT_LOADING
        if (!(scp->sc->fonts_loaded & FONT_16))
            return EINVAL;
        font = scp->sc->font_16;
#else
        font = NULL;
#endif
    } else {
        fontsize = 14;
#ifndef SC_NO_FONT_LOADING
        if (!(scp->sc->fonts_loaded & FONT_14))
            return EINVAL;
        font = scp->sc->font_14;
#else
        font = NULL;
#endif
    }
    if ((xsize <= 0) || (xsize > info.vi_width))
        xsize = info.vi_width;
    if ((ysize <= 0) || (ysize > info.vi_height))
        ysize = info.vi_height;

    /* stop screen saver, etc */
    s = spltty();
    if ((error = sc_clean_up(scp))) {
        splx(s);
        return error;
    }

    if (sc_render_match(scp, scp->sc->adp->va_name, 0) == NULL) {
        splx(s);
        return ENODEV;
    }

    /* set up scp */
#ifndef SC_NO_HISTORY
    if (scp->history != NULL)
        sc_hist_save(scp);
#endif
    prev_ysize = scp->ysize;
    /*
     * This is a kludge to fend off scrn_update() while we
     * muck around with scp. XXX
     */
    scp->status |= UNKNOWN_MODE | MOUSE_HIDDEN;
    scp->status &= ~(GRAPHICS_MODE | PIXEL_MODE | MOUSE_VISIBLE);
    scp->mode = mode;
    scp->xsize = xsize;
    scp->ysize = ysize;
    scp->xoff = 0;
    scp->yoff = 0;
    scp->xpixel = scp->xsize*8;
    scp->ypixel = scp->ysize*fontsize;
    scp->font = font;
    scp->font_size = fontsize;
    scp->font_width = fontwidth;

    /* allocate buffers */
    sc_alloc_scr_buffer(scp, TRUE, TRUE);
    sc_init_emulator(scp, NULL);
#ifndef SC_NO_CUTPASTE
    sc_alloc_cut_buffer(scp, FALSE);
#endif
#ifndef SC_NO_HISTORY
    sc_alloc_history_buffer(scp, 0, prev_ysize, FALSE);
#endif
    splx(s);

    if (scp == scp->sc->cur_scp)
        set_mode(scp);
    scp->status &= ~UNKNOWN_MODE;

    if (tp == NULL)
        return 0;
    DPRINTF(5, ("ws_*size (%d,%d), size (%d,%d)\n",
                tp->t_winsize.ws_col, tp->t_winsize.ws_row, scp->xsize, scp->ysize));
    if (tp->t_winsize.ws_col != scp->xsize
            || tp->t_winsize.ws_row != scp->ysize) {
        tp->t_winsize.ws_col = scp->xsize;
        tp->t_winsize.ws_row = scp->ysize;

        tty_signal_pgrp(tp, SIGWINCH);
    }

    return 0;
}
Пример #3
0
int
sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize, int ysize,
                  int fontsize, int fontwidth)
{
#ifndef SC_PIXEL_MODE
    return ENODEV;
#else
    video_info_t info;
    u_char *font;
    int prev_ysize;
    int error;
    int s;

    if (vidd_get_info(scp->sc->adp, scp->mode, &info))
        return ENODEV;		/* this shouldn't happen */

    /* adjust argument values */
    if (fontsize <= 0)
        fontsize = info.vi_cheight;
    if (fontsize < 14) {
        fontsize = 8;
#ifndef SC_NO_FONT_LOADING
        if (!(scp->sc->fonts_loaded & FONT_8))
            return EINVAL;
        font = scp->sc->font_8;
#else
        font = NULL;
#endif
    } else if (fontsize >= 16) {
        fontsize = 16;
#ifndef SC_NO_FONT_LOADING
        if (!(scp->sc->fonts_loaded & FONT_16))
            return EINVAL;
        font = scp->sc->font_16;
#else
        font = NULL;
#endif
    } else {
        fontsize = 14;
#ifndef SC_NO_FONT_LOADING
        if (!(scp->sc->fonts_loaded & FONT_14))
            return EINVAL;
        font = scp->sc->font_14;
#else
        font = NULL;
#endif
    }
    if (xsize <= 0)
        xsize = info.vi_width/8;
    if (ysize <= 0)
        ysize = info.vi_height/fontsize;

    if ((info.vi_width < xsize*8) || (info.vi_height < ysize*fontsize))
        return EINVAL;

    /*
     * We currently support the following graphic modes:
     *
     * - 4 bpp planar modes whose memory size does not exceed 64K
     * - 15, 16, 24 and 32 bpp linear modes
     */

    if (info.vi_mem_model == V_INFO_MM_PLANAR) {
        if (info.vi_planes != 4)
            return ENODEV;

        /*
         * A memory size >64K requires bank switching to access the entire
         * screen. XXX
         */

        if (info.vi_width * info.vi_height / 8 > info.vi_window_size)
            return ENODEV;
    } else if (info.vi_mem_model == V_INFO_MM_DIRECT) {
        if (!(info.vi_flags & V_INFO_LINEAR) &&
                (info.vi_depth != 15) && (info.vi_depth != 16) &&
                (info.vi_depth != 24) && (info.vi_depth != 32))
            return ENODEV;
    } else
        return ENODEV;

    /* stop screen saver, etc */
    s = spltty();
    if ((error = sc_clean_up(scp))) {
        splx(s);
        return error;
    }

    if (sc_render_match(scp, scp->sc->adp->va_name, PIXEL_MODE) == NULL) {
        splx(s);
        return ENODEV;
    }

#if 0
    if (scp->tsw)
        (*scp->tsw->te_term)(scp, scp->ts);
    scp->tsw = NULL;
    scp->ts = NULL;
#endif

    /* set up scp */
#ifndef SC_NO_HISTORY
    if (scp->history != NULL)
        sc_hist_save(scp);
#endif
    prev_ysize = scp->ysize;
    scp->status |= (UNKNOWN_MODE | PIXEL_MODE | MOUSE_HIDDEN);
    scp->status &= ~(GRAPHICS_MODE | MOUSE_VISIBLE);
    scp->xsize = xsize;
    scp->ysize = ysize;
    scp->xoff = (scp->xpixel/8 - xsize)/2;
    scp->yoff = (scp->ypixel/fontsize - ysize)/2;
    scp->font = font;
    scp->font_size = fontsize;
    scp->font_width = fontwidth;

    /* allocate buffers */
    sc_alloc_scr_buffer(scp, TRUE, TRUE);
    sc_init_emulator(scp, NULL);
#ifndef SC_NO_CUTPASTE
    sc_alloc_cut_buffer(scp, FALSE);
#endif
#ifndef SC_NO_HISTORY
    sc_alloc_history_buffer(scp, 0, prev_ysize, FALSE);
#endif
    splx(s);

    if (scp == scp->sc->cur_scp) {
        sc_set_border(scp, scp->border);
        sc_set_cursor_image(scp);
    }

    scp->status &= ~UNKNOWN_MODE;

    if (tp == NULL)
        return 0;
    if (tp->t_winsize.ws_col != scp->xsize
            || tp->t_winsize.ws_row != scp->ysize) {
        tp->t_winsize.ws_col = scp->xsize;
        tp->t_winsize.ws_row = scp->ysize;
        if (tp->t_pgrp != NULL) {
            PGRP_LOCK(tp->t_pgrp);
            pgsignal(tp->t_pgrp, SIGWINCH, 1);
            PGRP_UNLOCK(tp->t_pgrp);
        }
    }

    return 0;
#endif /* SC_PIXEL_MODE */
}
Пример #4
0
int
sc_set_pixel_mode(scr_stat *scp, struct tty *tp, int xsize, int ysize, 
		  int fontsize, int fontwidth)
{
#ifndef SC_PIXEL_MODE
    return ENODEV;
#else
    video_info_t info;
    ksiginfo_t ksi;
    u_char *font;
    int prev_ysize;
    int error;
    int s;

    if (vidd_get_info(scp->sc->adp, scp->mode, &info))
	return ENODEV;		/* this shouldn't happen */

    /* adjust argument values */
    if (fontsize <= 0)
	fontsize = info.vi_cheight;
    if (fontsize < 14)
	fontsize = 8;
    else if (fontsize >= 16)
	fontsize = 16;
    else
	fontsize = 14;
#ifndef SC_NO_FONT_LOADING
    switch (fontsize) {
    case 8:
	if ((scp->sc->fonts_loaded & FONT_8) == 0)
	    return (EINVAL);
	font = scp->sc->font_8;
	break;
    case 14:
	if ((scp->sc->fonts_loaded & FONT_14) == 0)
	    return (EINVAL);
	font = scp->sc->font_14;
	break;
    case 16:
	if ((scp->sc->fonts_loaded & FONT_16) == 0)
	    return (EINVAL);
	font = scp->sc->font_16;
	break;
    }
#else
    font = NULL;
#endif
    if (xsize <= 0)
	xsize = info.vi_width/8;
    if (ysize <= 0)
	ysize = info.vi_height/fontsize;

    if ((info.vi_width < xsize*8) || (info.vi_height < ysize*fontsize))
	return EINVAL;

    if (!sc_support_pixel_mode(&info))
	return ENODEV;

    /* stop screen saver, etc */
    s = spltty();
    if ((error = sc_clean_up(scp))) {
	splx(s);
	return error;
    }

    if (sc_render_match(scp, scp->sc->adp->va_name, PIXEL_MODE) == NULL) {
	splx(s);
	return ENODEV;
    }

#if 0
    if (scp->tsw)
	(*scp->tsw->te_term)(scp, scp->ts);
    scp->tsw = NULL;
    scp->ts = NULL;
#endif

    /* set up scp */
#ifndef SC_NO_HISTORY
    if (scp->history != NULL)
	sc_hist_save(scp);
#endif
    prev_ysize = scp->ysize;
    scp->status |= (UNKNOWN_MODE | PIXEL_MODE | MOUSE_HIDDEN);
    scp->status &= ~(GRAPHICS_MODE | MOUSE_VISIBLE);
    scp->xsize = xsize;
    scp->ysize = ysize;
    scp->xoff = (scp->xpixel/8 - xsize)/2;
    scp->yoff = (scp->ypixel/fontsize - ysize)/2;
    scp->font = font;
    scp->font_size = fontsize;
    scp->font_width = fontwidth;

    /* allocate buffers */
    sc_alloc_scr_buffer(scp, TRUE, TRUE);
    sc_init_emulator(scp, NULL);
#ifndef SC_NO_CUTPASTE
    sc_alloc_cut_buffer(scp, FALSE);
#endif
#ifndef SC_NO_HISTORY
    sc_alloc_history_buffer(scp, 0, prev_ysize, FALSE);
#endif
    splx(s);

    if (scp == scp->sc->cur_scp) {
	sc_set_border(scp, scp->border);
	sc_set_cursor_image(scp);
    }

    scp->status &= ~UNKNOWN_MODE;

    if (tp == NULL)
	return 0;
    if (tp->t_winsize.ws_col != scp->xsize
	|| tp->t_winsize.ws_row != scp->ysize) {
	tp->t_winsize.ws_col = scp->xsize;
	tp->t_winsize.ws_row = scp->ysize;
	if (tp->t_pgrp != NULL) {
	    ksiginfo_init(&ksi);
	    ksi.ksi_signo = SIGWINCH;
	    ksi.ksi_code = SI_KERNEL;
	    PGRP_LOCK(tp->t_pgrp);
	    pgsignal(tp->t_pgrp, SIGWINCH, 1, &ksi);
	    PGRP_UNLOCK(tp->t_pgrp);
	}
    }

    return 0;
#endif /* SC_PIXEL_MODE */
}