コード例 #1
0
static int
ofwfb_putm32(video_adapter_t *adp, int x, int y, uint8_t *pixel_image,
             uint32_t pixel_mask, int size, int width)
{
    struct ofwfb_softc *sc;
    int i, j, k;
    uint32_t fg, bg;
    uint32_t *addr;

    sc = (struct ofwfb_softc *)adp;
    addr = (uint32_t *)sc->sc_addr
           + (y + sc->sc_ymargin)*(sc->sc_stride/4)
           + x + sc->sc_xmargin;

    fg = ofwfb_pix32(ofwfb_foreground(SC_NORM_ATTR));
    bg = ofwfb_pix32(ofwfb_background(SC_NORM_ATTR));

    for (i = 0; i < size && i+y < sc->sc_height - 2*sc->sc_ymargin; i++) {
        for (j = 0, k = width; j < 8; j++, k--) {
            if (x + j >= sc->sc_width - 2*sc->sc_xmargin)
                continue;

            if (pixel_image[i] & (1 << k))
                *(addr + j) = (*(addr + j) == fg) ? bg : fg;
        }
        addr += (sc->sc_stride/4);
    }

    return (0);
}
コード例 #2
0
static int
ofwfb_putc32(video_adapter_t *adp, vm_offset_t off, uint8_t c, uint8_t a)
{
    struct ofwfb_softc *sc;
    int row;
    int col;
    int i, j, k;
    uint32_t *addr;
    u_char *p;

    sc = (struct ofwfb_softc *)adp;
    row = (off / adp->va_info.vi_width) * adp->va_info.vi_cheight;
    col = (off % adp->va_info.vi_width) * adp->va_info.vi_cwidth;
    p = sc->sc_font + c*sc->sc_font_height;
    addr = (uint32_t *)sc->sc_addr
           + (row + sc->sc_ymargin)*(sc->sc_stride/4)
           + col + sc->sc_xmargin;

    for (i = 0; i < sc->sc_font_height; i++) {
        for (j = 0, k = 7; j < 8; j++, k--) {
            if ((p[i] & (1 << k)) == 0)
                *(addr + j) = ofwfb_pix32(ofwfb_background(a));
            else
                *(addr + j) = ofwfb_pix32(ofwfb_foreground(a));
        }
        addr += (sc->sc_stride/4);
    }

    return (0);
}
コード例 #3
0
static int
ofwfb_putm8(video_adapter_t *adp, int x, int y, uint8_t *pixel_image,
            uint32_t pixel_mask, int size, int width)
{
    struct ofwfb_softc *sc;
    int i, j, k;
    uint8_t *addr;
    u_char fg, bg;

    sc = (struct ofwfb_softc *)adp;
    addr = (u_int8_t *)((uintptr_t)sc->sc_addr
                        + (y + sc->sc_ymargin)*sc->sc_stride
                        + x + sc->sc_xmargin);

    fg = ofwfb_foreground(SC_NORM_ATTR);
    bg = ofwfb_background(SC_NORM_ATTR);

    for (i = 0; i < size && i+y < sc->sc_height - 2*sc->sc_ymargin; i++) {
        /*
         * Calculate 2 x 4-chars at a time, and then
         * write these out.
         */
        for (j = 0, k = width; j < 8; j++, k--) {
            if (x + j >= sc->sc_width - 2*sc->sc_xmargin)
                continue;

            if (pixel_image[i] & (1 << k))
                addr[j] = (addr[j] == fg) ? bg : fg;
        }

        addr += (sc->sc_stride / sizeof(u_int8_t));
    }

    return (0);
}
コード例 #4
0
static int
ofwfb_putc8(video_adapter_t *adp, vm_offset_t off, uint8_t c, uint8_t a)
{
    struct ofwfb_softc *sc;
    int row;
    int col;
    int i;
    uint32_t *addr;
    u_char *p, fg, bg;
    union {
        uint32_t l;
        uint8_t  c[4];
    } ch1, ch2;


    sc = (struct ofwfb_softc *)adp;
    row = (off / adp->va_info.vi_width) * adp->va_info.vi_cheight;
    col = (off % adp->va_info.vi_width) * adp->va_info.vi_cwidth;
    p = sc->sc_font + c*sc->sc_font_height;
    addr = (u_int32_t *)((uintptr_t)sc->sc_addr
                         + (row + sc->sc_ymargin)*sc->sc_stride
                         + col + sc->sc_xmargin);

    fg = ofwfb_foreground(a);
    bg = ofwfb_background(a);

    for (i = 0; i < sc->sc_font_height; i++) {
        u_char fline = p[i];

        /*
         * Assume that there is more background than foreground
         * in characters and init accordingly
         */
        ch1.l = ch2.l = (bg << 24) | (bg << 16) | (bg << 8) | bg;

        /*
         * Calculate 2 x 4-chars at a time, and then
         * write these out.
         */
        if (fline & 0x80) ch1.c[0] = fg;
        if (fline & 0x40) ch1.c[1] = fg;
        if (fline & 0x20) ch1.c[2] = fg;
        if (fline & 0x10) ch1.c[3] = fg;

        if (fline & 0x08) ch2.c[0] = fg;
        if (fline & 0x04) ch2.c[1] = fg;
        if (fline & 0x02) ch2.c[2] = fg;
        if (fline & 0x01) ch2.c[3] = fg;

        addr[0] = ch1.l;
        addr[1] = ch2.l;
        addr += (sc->sc_stride / sizeof(u_int32_t));
    }

    return (0);
}
コード例 #5
0
static int
ofwfb_blank_display32(video_adapter_t *adp, int mode)
{
    struct ofwfb_softc *sc;
    int i;
    uint32_t *addr;

    sc = (struct ofwfb_softc *)adp;
    addr = (uint32_t *) sc->sc_addr;

    for (i = 0; i < (sc->sc_stride/4)*sc->sc_height; i++)
        *(addr + i) = ofwfb_pix32(ofwfb_background(SC_NORM_ATTR));

    return (0);
}
コード例 #6
0
ファイル: ofw_syscons.c プロジェクト: coyizumi/cs111
static int
ofwfb_blank_display8(video_adapter_t *adp, int mode)
{
	struct ofwfb_softc *sc;
	int i;
	uint32_t *addr;
	uint32_t color;
	uint32_t end;

	sc = (struct ofwfb_softc *)adp;
	addr = (uint32_t *) sc->sc_addr;
	end = (sc->sc_stride/4) * sc->sc_height;

	/* Splat 4 pixels at once. */
	color = (ofwfb_background(SC_NORM_ATTR) << 24) |
	    (ofwfb_background(SC_NORM_ATTR) << 16) |
	    (ofwfb_background(SC_NORM_ATTR) << 8) |
	    (ofwfb_background(SC_NORM_ATTR));

	for (i = 0; i < end; i++)
		*(addr + i) = color;

	return (0);
}
コード例 #7
0
static int
ofwfb_blank_display8(video_adapter_t *adp, int mode)
{
    struct ofwfb_softc *sc;
    int i;
    uint8_t *addr;

    sc = (struct ofwfb_softc *)adp;
    addr = (uint8_t *) sc->sc_addr;

    /* Could be done a lot faster e.g. 32-bits, or Altivec'd */
    for (i = 0; i < sc->sc_stride*sc->sc_height; i++)
        *(addr + i) = ofwfb_background(SC_NORM_ATTR);

    return (0);
}
コード例 #8
0
static int
ofwfb_set_border8(video_adapter_t *adp, int border)
{
    struct ofwfb_softc *sc;
    int i, j;
    uint8_t *addr;
    uint8_t bground;

    sc = (struct ofwfb_softc *)adp;

    bground = ofwfb_background(border);

    /* Set top margin */
    addr = (uint8_t *) sc->sc_addr;
    for (i = 0; i < sc->sc_ymargin; i++) {
        for (j = 0; j < sc->sc_width; j++) {
            *(addr + j) = bground;
        }
        addr += sc->sc_stride;
    }

    /* bottom margin */
    addr = (uint8_t *) sc->sc_addr + (sc->sc_height - sc->sc_ymargin)*sc->sc_stride;
    for (i = 0; i < sc->sc_ymargin; i++) {
        for (j = 0; j < sc->sc_width; j++) {
            *(addr + j) = bground;
        }
        addr += sc->sc_stride;
    }

    /* remaining left and right borders */
    addr = (uint8_t *) sc->sc_addr + sc->sc_ymargin*sc->sc_stride;
    for (i = 0; i < sc->sc_height - 2*sc->sc_xmargin; i++) {
        for (j = 0; j < sc->sc_xmargin; j++) {
            *(addr + j) = bground;
            *(addr + j + sc->sc_width - sc->sc_xmargin) = bground;
        }
        addr += sc->sc_stride;
    }

    return (0);
}