Changeset 730376d in mainline for kernel/genarch/src
- Timestamp:
- 2006-12-20T22:07:25Z (19 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0af7a09
- Parents:
- deada67
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/fb/fb.c
rdeada67 r730376d 40 40 #include <sysinfo/sysinfo.h> 41 41 #include <mm/slab.h> 42 #include <align.h>43 42 #include <panic.h> 44 43 #include <memstr.h> … … 47 46 #include <print.h> 48 47 #include <ddi/ddi.h> 48 #include <arch/types.h> 49 #include <typedefs.h> 49 50 50 51 #include "helenos.xbm" … … 57 58 58 59 static uint8_t *blankline = NULL; 59 static uint8_t *dbbuffer = NULL; 60 static in t dboffset;60 static uint8_t *dbbuffer = NULL; /* Buffer for fast scrolling console */ 61 static index_t dboffset; 61 62 62 63 static unsigned int xres = 0; … … 111 112 static void bgr_byte0888(void *dst, int rgb) 112 113 { 113 *((uint32_t *) dst) = BLUE(rgb, 8) << 16 | GREEN(rgb, 8) << 8 | RED(rgb, 8); 114 *((uint32_t *) dst) = BLUE(rgb, 8) << 16 | GREEN(rgb, 8) << 8 | RED(rgb, 115 8); 114 116 } 115 117 … … 117 119 { 118 120 int color = *(uint32_t *)(src); 119 return ((color & 0xff) << 16) | (((color >> 8) & 0xff) << 8) | ((color >> 16) & 0xff); 121 return ((color & 0xff) << 16) | (((color >> 8) & 0xff) << 8) | ((color 122 >> 16) & 0xff); 120 123 } 121 124 … … 148 151 { 149 152 /* 5-bit, 5-bits, 5-bits */ 150 *((uint16_t *) dst) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 | BLUE(rgb, 5); 153 *((uint16_t *) dst) = RED(rgb, 5) << 10 | GREEN(rgb, 5) << 5 | BLUE(rgb, 154 5); 151 155 } 152 156 … … 155 159 { 156 160 int color = *(uint16_t *)(src); 157 return (((color >> 10) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x1f) << (8 + 3)) | ((color & 0x1f) << 3); 161 return (((color >> 10) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x1f) << 162 (8 + 3)) | ((color & 0x1f) << 3); 158 163 } 159 164 … … 162 167 { 163 168 /* 5-bit, 6-bits, 5-bits */ 164 *((uint16_t *) dst) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 | BLUE(rgb, 169 *((uint16_t *) dst) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 | BLUE(rgb, 5); 165 170 } 166 171 … … 169 174 { 170 175 int color = *(uint16_t *)(src); 171 return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3); 176 return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << 177 (8 + 2)) | ((color & 0x1f) << 3); 172 178 } 173 179 … … 182 188 static void rgb_byte8(void *dst, int rgb) 183 189 { 184 *((uint8_t *) dst) = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3); 190 *((uint8_t *) dst) = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 191 3); 185 192 } 186 193 … … 192 199 { 193 200 int color = *(uint8_t *)src; 194 return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5); 201 return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 202 + 6)) | ((color & 0x7) << 5); 195 203 } 196 204 … … 224 232 memcpy(&fbaddress[scanline * y], blankline, xres * pixelbytes); 225 233 if (dbbuffer) 226 memcpy(&dbbuffer[scanline * y], blankline, xres * pixelbytes); 234 memcpy(&dbbuffer[scanline * y], blankline, xres * 235 pixelbytes); 227 236 } 228 237 } … … 232 241 static void scroll_screen(void) 233 242 { 234 uint8_t *lastline = &fbaddress[(rows - 1) * ROW_BYTES];235 int firstsz;236 237 243 if (dbbuffer) { 244 count_t first; 245 238 246 memcpy(&dbbuffer[dboffset * scanline], blankline, ROW_BYTES); 239 247 240 248 dboffset = (dboffset + FONT_SCANLINES) % yres; 241 firstsz = yres - dboffset; 242 243 memcpy(fbaddress, &dbbuffer[scanline * dboffset], firstsz * scanline); 244 memcpy(&fbaddress[firstsz * scanline], dbbuffer, dboffset * scanline); 249 first = yres - dboffset; 250 251 memcpy(fbaddress, &dbbuffer[scanline * dboffset], first * 252 scanline); 253 memcpy(&fbaddress[first * scanline], dbbuffer, dboffset * 254 scanline); 245 255 } else { 246 memcpy((void *) fbaddress, (void *) &fbaddress[ROW_BYTES], scanline * yres - ROW_BYTES); 256 uint8_t *lastline = &fbaddress[(rows - 1) * ROW_BYTES]; 257 258 memcpy((void *) fbaddress, (void *) &fbaddress[ROW_BYTES], 259 scanline * yres - ROW_BYTES); 247 260 /* Clear last row */ 248 261 memcpy((void *) lastline, (void *) blankline, ROW_BYTES); … … 278 291 279 292 for (y = 0; y < FONT_SCANLINES; y++) 280 draw_glyph_line(fb_font[glyph * FONT_SCANLINES + y], col * COL_WIDTH, row * FONT_SCANLINES + y); 293 draw_glyph_line(fb_font[glyph * FONT_SCANLINES + y], col * 294 COL_WIDTH, row * FONT_SCANLINES + y); 281 295 } 282 296 … … 289 303 for (x = 0; x < COL_WIDTH; x++) 290 304 for (y = 0; y < FONT_SCANLINES; y++) 291 invert_pixel(col * COL_WIDTH + x, row * FONT_SCANLINES + y); 305 invert_pixel(col * COL_WIDTH + x, row * FONT_SCANLINES + 306 y); 292 307 } 293 308 … … 312 327 byte >>= x % 8; 313 328 if (byte & 1) 314 putpixel(startx + x, starty + y, COLOR(LOGOCOLOR)); 329 putpixel(startx + x, starty + y, 330 COLOR(LOGOCOLOR)); 315 331 } 316 332 } … … 384 400 * 385 401 */ 386 void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int scan, unsigned int visual) 402 void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int scan, 403 unsigned int visual) 387 404 { 388 405 switch (visual) { … … 456 473 457 474 /* Allocate double buffer */ 458 unsigned int order = fnzb(SIZE2FRAMES( ALIGN_UP(fbsize, FRAME_SIZE))) + 1;459 dbbuffer = (uint8_t * 475 unsigned int order = fnzb(SIZE2FRAMES(fbsize) - 1) + 1; 476 dbbuffer = (uint8_t *) frame_alloc(order, FRAME_ATOMIC | FRAME_KA); 460 477 if (!dbbuffer) 461 478 printf("Failed to allocate scroll buffer.\n");
Note:
See TracChangeset
for help on using the changeset viewer.