Changeset View
Changeset View
Standalone View
Standalone View
head/sys/dev/vt/hw/vga/vt_vga.c
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Lines | |||||
* Those addresses are then loaded in the latches once. | * Those addresses are then loaded in the latches once. | ||||
*/ | */ | ||||
#define VT_VGA_BGCOLOR_OFFSET VT_VGA_MEMSIZE | #define VT_VGA_BGCOLOR_OFFSET VT_VGA_MEMSIZE | ||||
static vd_probe_t vga_probe; | static vd_probe_t vga_probe; | ||||
static vd_init_t vga_init; | static vd_init_t vga_init; | ||||
static vd_blank_t vga_blank; | static vd_blank_t vga_blank; | ||||
static vd_bitblt_text_t vga_bitblt_text; | static vd_bitblt_text_t vga_bitblt_text; | ||||
static vd_invalidate_text_t vga_invalidate_text; | |||||
static vd_bitblt_bmp_t vga_bitblt_bitmap; | static vd_bitblt_bmp_t vga_bitblt_bitmap; | ||||
static vd_drawrect_t vga_drawrect; | static vd_drawrect_t vga_drawrect; | ||||
static vd_setpixel_t vga_setpixel; | static vd_setpixel_t vga_setpixel; | ||||
static vd_postswitch_t vga_postswitch; | static vd_postswitch_t vga_postswitch; | ||||
static const struct vt_driver vt_vga_driver = { | static const struct vt_driver vt_vga_driver = { | ||||
.vd_name = "vga", | .vd_name = "vga", | ||||
.vd_probe = vga_probe, | .vd_probe = vga_probe, | ||||
.vd_init = vga_init, | .vd_init = vga_init, | ||||
.vd_blank = vga_blank, | .vd_blank = vga_blank, | ||||
.vd_bitblt_text = vga_bitblt_text, | .vd_bitblt_text = vga_bitblt_text, | ||||
.vd_invalidate_text = vga_invalidate_text, | |||||
.vd_bitblt_bmp = vga_bitblt_bitmap, | .vd_bitblt_bmp = vga_bitblt_bitmap, | ||||
.vd_drawrect = vga_drawrect, | .vd_drawrect = vga_drawrect, | ||||
.vd_setpixel = vga_setpixel, | .vd_setpixel = vga_setpixel, | ||||
.vd_postswitch = vga_postswitch, | .vd_postswitch = vga_postswitch, | ||||
.vd_priority = VD_PRIORITY_GENERIC, | .vd_priority = VD_PRIORITY_GENERIC, | ||||
}; | }; | ||||
/* | /* | ||||
▲ Show 20 Lines • Show All 744 Lines • ▼ Show 20 Lines | vga_bitblt_text_txtmode(struct vt_device *vd, const struct vt_window *vw, | ||||
const term_rect_t *area) | const term_rect_t *area) | ||||
{ | { | ||||
struct vga_softc *sc; | struct vga_softc *sc; | ||||
const struct vt_buf *vb; | const struct vt_buf *vb; | ||||
unsigned int col, row; | unsigned int col, row; | ||||
term_char_t c; | term_char_t c; | ||||
term_color_t fg, bg; | term_color_t fg, bg; | ||||
uint8_t ch, attr; | uint8_t ch, attr; | ||||
size_t z; | |||||
sc = vd->vd_softc; | sc = vd->vd_softc; | ||||
vb = &vw->vw_buf; | vb = &vw->vw_buf; | ||||
for (row = area->tr_begin.tp_row; row < area->tr_end.tp_row; ++row) { | for (row = area->tr_begin.tp_row; row < area->tr_end.tp_row; ++row) { | ||||
for (col = area->tr_begin.tp_col; | for (col = area->tr_begin.tp_col; | ||||
col < area->tr_end.tp_col; | col < area->tr_end.tp_col; | ||||
++col) { | ++col) { | ||||
/* | /* | ||||
* Get next character and its associated fg/bg | * Get next character and its associated fg/bg | ||||
* colors. | * colors. | ||||
*/ | */ | ||||
c = VTBUF_GET_FIELD(vb, row, col); | c = VTBUF_GET_FIELD(vb, row, col); | ||||
vt_determine_colors(c, VTBUF_ISCURSOR(vb, row, col), | vt_determine_colors(c, VTBUF_ISCURSOR(vb, row, col), | ||||
&fg, &bg); | &fg, &bg); | ||||
z = row * PIXEL_WIDTH(VT_FB_MAX_WIDTH) + col; | |||||
if (vd->vd_drawn && (vd->vd_drawn[z] == c) && | |||||
vd->vd_drawnfg && (vd->vd_drawnfg[z] == fg) && | |||||
vd->vd_drawnbg && (vd->vd_drawnbg[z] == bg)) | |||||
continue; | |||||
/* | /* | ||||
* Convert character to CP437, which is the | * Convert character to CP437, which is the | ||||
* character set used by the VGA hardware by | * character set used by the VGA hardware by | ||||
* default. | * default. | ||||
*/ | */ | ||||
ch = vga_get_cp437(TCHAR_CHARACTER(c)); | ch = vga_get_cp437(TCHAR_CHARACTER(c)); | ||||
/* Convert colors to VGA attributes. */ | /* Convert colors to VGA attributes. */ | ||||
attr = | attr = | ||||
cons_to_vga_colors[bg] << 4 | | cons_to_vga_colors[bg] << 4 | | ||||
cons_to_vga_colors[fg]; | cons_to_vga_colors[fg]; | ||||
MEM_WRITE2(sc, (row * 80 + col) * 2 + 0, | MEM_WRITE2(sc, (row * 80 + col) * 2 + 0, | ||||
ch + ((uint16_t)(attr) << 8)); | ch + ((uint16_t)(attr) << 8)); | ||||
if (vd->vd_drawn) | |||||
vd->vd_drawn[z] = c; | |||||
if (vd->vd_drawnfg) | |||||
vd->vd_drawnfg[z] = fg; | |||||
if (vd->vd_drawnbg) | |||||
vd->vd_drawnbg[z] = bg; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
static void | static void | ||||
vga_bitblt_text(struct vt_device *vd, const struct vt_window *vw, | vga_bitblt_text(struct vt_device *vd, const struct vt_window *vw, | ||||
const term_rect_t *area) | const term_rect_t *area) | ||||
{ | { | ||||
if (!(vd->vd_flags & VDF_TEXTMODE)) { | if (!(vd->vd_flags & VDF_TEXTMODE)) { | ||||
vga_bitblt_text_gfxmode(vd, vw, area); | vga_bitblt_text_gfxmode(vd, vw, area); | ||||
} else { | } else { | ||||
vga_bitblt_text_txtmode(vd, vw, area); | vga_bitblt_text_txtmode(vd, vw, area); | ||||
} | |||||
} | |||||
void | |||||
vga_invalidate_text(struct vt_device *vd, const term_rect_t *area) | |||||
{ | |||||
unsigned int col, row; | |||||
size_t z; | |||||
for (row = area->tr_begin.tp_row; row < area->tr_end.tp_row; ++row) { | |||||
for (col = area->tr_begin.tp_col; | |||||
col < area->tr_end.tp_col; | |||||
++col) { | |||||
z = row * PIXEL_WIDTH(VT_FB_MAX_WIDTH) + col; | |||||
if (vd->vd_drawn) | |||||
vd->vd_drawn[z] = 0; | |||||
if (vd->vd_drawnfg) | |||||
vd->vd_drawnfg[z] = 0; | |||||
if (vd->vd_drawnbg) | |||||
vd->vd_drawnbg[z] = 0; | |||||
} | |||||
} | } | ||||
} | } | ||||
static void | static void | ||||
vga_bitblt_bitmap(struct vt_device *vd, const struct vt_window *vw, | vga_bitblt_bitmap(struct vt_device *vd, const struct vt_window *vw, | ||||
const uint8_t *pattern, const uint8_t *mask, | const uint8_t *pattern, const uint8_t *mask, | ||||
unsigned int width, unsigned int height, | unsigned int width, unsigned int height, | ||||
unsigned int x, unsigned int y, term_color_t fg, term_color_t bg) | unsigned int x, unsigned int y, term_color_t fg, term_color_t bg) | ||||
▲ Show 20 Lines • Show All 425 Lines • Show Last 20 Lines |