39,7 → 39,6 |
#include <console/console.h> |
#include <sysinfo/sysinfo.h> |
#include <mm/slab.h> |
#include <align.h> |
#include <panic.h> |
#include <memstr.h> |
#include <config.h> |
46,6 → 45,8 |
#include <bitops.h> |
#include <print.h> |
#include <ddi/ddi.h> |
#include <arch/types.h> |
#include <typedefs.h> |
|
#include "helenos.xbm" |
|
57,7 → 58,7 |
|
static uint8_t *blankline = NULL; |
static uint8_t *dbbuffer = NULL; /* Buffer for fast scrolling console */ |
static int dboffset; |
static index_t dboffset; |
|
static unsigned int xres = 0; |
static unsigned int yres = 0; |
110,13 → 111,15 |
|
static void bgr_byte0888(void *dst, int rgb) |
{ |
*((uint32_t *) dst) = BLUE(rgb, 8) << 16 | GREEN(rgb, 8) << 8 | RED(rgb, 8); |
*((uint32_t *) dst) = BLUE(rgb, 8) << 16 | GREEN(rgb, 8) << 8 | RED(rgb, |
8); |
} |
|
static int byte0888_bgr(void *src) |
{ |
int color = *(uint32_t *)(src); |
return ((color & 0xff) << 16) | (((color >> 8) & 0xff) << 8) | ((color >> 16) & 0xff); |
return ((color & 0xff) << 16) | (((color >> 8) & 0xff) << 8) | ((color |
>> 16) & 0xff); |
} |
|
static void rgb_byte888(void *dst, int rgb) |
147,7 → 150,8 |
static void rgb_byte555(void *dst, int rgb) |
{ |
/* 5-bit, 5-bits, 5-bits */ |
*((uint16_t *) dst) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 | BLUE(rgb, 5); |
*((uint16_t *) dst) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 | BLUE(rgb, |
5); |
} |
|
/** 16-bit depth (5:5:5) */ |
154,7 → 158,8 |
static int byte555_rgb(void *src) |
{ |
int color = *(uint16_t *)(src); |
return (((color >> 10) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x1f) << (8 + 3)) | ((color & 0x1f) << 3); |
return (((color >> 10) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x1f) << |
(8 + 3)) | ((color & 0x1f) << 3); |
} |
|
/** 16-bit depth (5:6:5) */ |
168,7 → 173,8 |
static int byte565_rgb(void *src) |
{ |
int color = *(uint16_t *)(src); |
return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3); |
return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << |
(8 + 2)) | ((color & 0x1f) << 3); |
} |
|
/** Put pixel - 8-bit depth (color palette/3:2:3) |
181,7 → 187,8 |
*/ |
static void rgb_byte8(void *dst, int rgb) |
{ |
*((uint8_t *) dst) = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3); |
*((uint8_t *) dst) = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, |
3); |
} |
|
/** Return pixel color - 8-bit depth (color palette/3:2:3) |
191,7 → 198,8 |
static int byte8_rgb(void *src) |
{ |
int color = *(uint8_t *)src; |
return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5); |
return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 |
+ 6)) | ((color & 0x7) << 5); |
} |
|
static void putpixel(unsigned int x, unsigned int y, int color) |
223,7 → 231,8 |
for (y = 0; y < yres; y++) { |
memcpy(&fbaddress[scanline * y], blankline, xres * pixelbytes); |
if (dbbuffer) |
memcpy(&dbbuffer[scanline * y], blankline, xres * pixelbytes); |
memcpy(&dbbuffer[scanline * y], blankline, xres * |
pixelbytes); |
} |
} |
|
231,19 → 240,23 |
/** Scroll screen one row up */ |
static void scroll_screen(void) |
{ |
uint8_t *lastline = &fbaddress[(rows - 1) * ROW_BYTES]; |
int firstsz; |
if (dbbuffer) { |
count_t first; |
|
if (dbbuffer) { |
memcpy(&dbbuffer[dboffset * scanline], blankline, ROW_BYTES); |
|
dboffset = (dboffset + FONT_SCANLINES) % yres; |
firstsz = yres - dboffset; |
first = yres - dboffset; |
|
memcpy(fbaddress, &dbbuffer[scanline * dboffset], firstsz * scanline); |
memcpy(&fbaddress[firstsz * scanline], dbbuffer, dboffset * scanline); |
memcpy(fbaddress, &dbbuffer[scanline * dboffset], first * |
scanline); |
memcpy(&fbaddress[first * scanline], dbbuffer, dboffset * |
scanline); |
} else { |
memcpy((void *) fbaddress, (void *) &fbaddress[ROW_BYTES], scanline * yres - ROW_BYTES); |
uint8_t *lastline = &fbaddress[(rows - 1) * ROW_BYTES]; |
|
memcpy((void *) fbaddress, (void *) &fbaddress[ROW_BYTES], |
scanline * yres - ROW_BYTES); |
/* Clear last row */ |
memcpy((void *) lastline, (void *) blankline, ROW_BYTES); |
} |
277,7 → 290,8 |
unsigned int y; |
|
for (y = 0; y < FONT_SCANLINES; y++) |
draw_glyph_line(fb_font[glyph * FONT_SCANLINES + y], col * COL_WIDTH, row * FONT_SCANLINES + y); |
draw_glyph_line(fb_font[glyph * FONT_SCANLINES + y], col * |
COL_WIDTH, row * FONT_SCANLINES + y); |
} |
|
/** Invert character at given position */ |
288,7 → 302,8 |
|
for (x = 0; x < COL_WIDTH; x++) |
for (y = 0; y < FONT_SCANLINES; y++) |
invert_pixel(col * COL_WIDTH + x, row * FONT_SCANLINES + y); |
invert_pixel(col * COL_WIDTH + x, row * FONT_SCANLINES + |
y); |
} |
|
/** Draw character at default position */ |
311,7 → 326,8 |
byte = helenos_bits[rowbytes * y + x / 8]; |
byte >>= x % 8; |
if (byte & 1) |
putpixel(startx + x, starty + y, COLOR(LOGOCOLOR)); |
putpixel(startx + x, starty + y, |
COLOR(LOGOCOLOR)); |
} |
} |
|
383,7 → 399,8 |
* @param visual Color model |
* |
*/ |
void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int scan, unsigned int visual) |
void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int scan, |
unsigned int visual) |
{ |
switch (visual) { |
case VISUAL_INDIRECT_8: |
455,7 → 472,7 |
sysinfo_set_item_val("fb.invert-colors", NULL, invert_colors); |
|
/* Allocate double buffer */ |
unsigned int order = fnzb(SIZE2FRAMES(ALIGN_UP(fbsize, FRAME_SIZE))) + 1; |
unsigned int order = fnzb(SIZE2FRAMES(fbsize) - 1) + 1; |
dbbuffer = (uint8_t * ) frame_alloc(order, FRAME_ATOMIC | FRAME_KA); |
if (!dbbuffer) |
printf("Failed to allocate scroll buffer.\n"); |