Changeset 6eb96fce in mainline
- Timestamp:
- 2006-06-10T07:44:21Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fd7faa87
- Parents:
- 4b74488
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
genarch/src/fb/fb.c
r4b74488 r6eb96fce 37 37 #include <memstr.h> 38 38 #include <config.h> 39 #include <bitops.h> 40 #include <print.h> 39 41 40 42 #include "helenos.xbm" … … 45 47 46 48 static __u8 *blankline = NULL; 49 static __u8 *dbbuffer = NULL; /* Buffer for fast scrolling console */ 50 static int dboffset; 47 51 48 52 static unsigned int xres = 0; … … 68 72 #define BLUE(x, bits) ((x >> (8 - bits)) & ((1 << bits) - 1)) 69 73 70 #define POINTPOS(x, y) ( y * scanline + x* pixelbytes)74 #define POINTPOS(x, y) ((y) * scanline + (x) * pixelbytes) 71 75 72 76 /***************************************************************/ 73 77 /* Pixel specific fuctions */ 74 78 75 static void (*putpixel)(unsigned int x, unsigned int y, int color); 76 static int (*getpixel)(unsigned int x, unsigned int y); 77 78 /** Put pixel - 24-bit depth, 1 free byte */ 79 static void putpixel_4byte(unsigned int x, unsigned int y, int color) 80 { 81 *((__u32 *)(fbaddress + POINTPOS(x, y))) = color; 82 } 83 84 /** Return pixel color - 24-bit depth, 1 free byte */ 85 static int getpixel_4byte(unsigned int x, unsigned int y) 86 { 87 return *((__u32 *)(fbaddress + POINTPOS(x, y))) & 0xffffff; 88 } 89 90 /** Put pixel - 24-bit depth */ 91 static void putpixel_3byte(unsigned int x, unsigned int y, int color) 92 { 93 unsigned int startbyte = POINTPOS(x, y); 94 79 static void (*rgb2scr)(void *, int); 80 static int (*scr2rgb)(void *); 81 82 /* Conversion routines between different color representations */ 83 static void rgb_4byte(void *dst, int rgb) 84 { 85 *(int *)dst = rgb; 86 } 87 88 static int byte4_rgb(void *src) 89 { 90 return (*(int *)src) & 0xffffff; 91 } 92 93 static void rgb_3byte(void *dst, int rgb) 94 { 95 __u8 *scr = dst; 95 96 #if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN)) 96 fbaddress[startbyte] = RED(color, 8);97 fbaddress[startbyte + 1] = GREEN(color, 8);98 fbaddress[startbyte + 2] = BLUE(color, 8);97 scr[0] = RED(rgb, 8); 98 scr[1] = GREEN(rgb, 8); 99 scr[2] = BLUE(rgb, 8); 99 100 #else 100 fbaddress[startbyte + 2] = RED(color, 8); 101 fbaddress[startbyte + 1] = GREEN(color, 8); 102 fbaddress[startbyte + 0] = BLUE(color, 8); 101 scr[2] = RED(rgb, 8); 102 scr[1] = GREEN(rgb, 8); 103 scr[0] = BLUE(rgb, 8); 104 #endif 105 } 106 107 static int byte3_rgb(void *src) 108 { 109 __u8 *scr = src; 110 #if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN)) 111 return scr[0] << 16 | scr[1] << 8 | scr[2]; 112 #else 113 return scr[2] << 16 | scr[1] << 8 | scr[0]; 103 114 #endif 104 115 } 105 116 106 /** Return pixel color - 24-bit depth */ 107 static int getpixel_3byte(unsigned int x, unsigned int y) 108 { 109 unsigned int startbyte = POINTPOS(x, y); 110 111 #if (defined(BIG_ENDIAN) || defined(FB_BIG_ENDIAN)) 112 return fbaddress[startbyte] << 16 | fbaddress[startbyte + 1] << 8 | fbaddress[startbyte + 2]; 113 #else 114 return fbaddress[startbyte + 2] << 16 | fbaddress[startbyte + 1] << 8 | fbaddress[startbyte + 0]; 115 #endif 116 } 117 118 /** Put pixel - 16-bit depth (5:6:6) */ 119 static void putpixel_2byte(unsigned int x, unsigned int y, int color) 120 { 121 /* 5-bit, 5-bits, 5-bits */ 122 *((__u16 *)(fbaddress + POINTPOS(x, y))) = RED(color, 5) << 11 | GREEN(color, 6) << 5 | BLUE(color, 5); 123 } 124 125 /** Return pixel color - 16-bit depth (5:6:6) */ 126 static int getpixel_2byte(unsigned int x, unsigned int y) 127 { 128 int color = *((__u16 *)(fbaddress + POINTPOS(x, y))); 117 /** 16-bit depth (5:6:5) */ 118 static void rgb_2byte(void *dst, int rgb) 119 { 120 /* 5-bit, 6-bits, 5-bits */ 121 *((__u16 *)(dst)) = RED(rgb, 5) << 11 | GREEN(rgb, 6) << 5 | BLUE(rgb, 5); 122 } 123 124 /** 16-bit depth (5:6:5) */ 125 static int byte2_rgb(void *src) 126 { 127 int color = *(__u16 *)(src); 129 128 return (((color >> 11) & 0x1f) << (16 + 3)) | (((color >> 5) & 0x3f) << (8 + 2)) | ((color & 0x1f) << 3); 130 129 } 131 130 132 131 /** Put pixel - 8-bit depth (3:2:3) */ 133 static void putpixel_1byte(unsigned int x, unsigned int y, int color)134 { 135 fbaddress[POINTPOS(x, y)] = RED(color, 3) << 5 | GREEN(color, 2) << 3 | BLUE(color, 3);132 static void rgb_1byte(void *dst, int rgb) 133 { 134 *(__u8 *)dst = RED(rgb, 3) << 5 | GREEN(rgb, 2) << 3 | BLUE(rgb, 3); 136 135 } 137 136 138 137 /** Return pixel color - 8-bit depth (3:2:3) */ 139 static int getpixel_1byte(unsigned int x, unsigned int y)140 { 141 int color = fbaddress[POINTPOS(x, y)];138 static int byte1_rgb(void *src) 139 { 140 int color = *(__u8 *)src; 142 141 return (((color >> 5) & 0x7) << (16 + 5)) | (((color >> 3) & 0x3) << (8 + 6)) | ((color & 0x7) << 5); 143 142 } 144 143 145 /** Fill line with color BGCOLOR */ 146 static void clear_line(unsigned int y) 147 { 148 unsigned int x; 149 150 for (x = 0; x < xres; x++) 151 (*putpixel)(x, y, BGCOLOR); 144 static void putpixel(unsigned int x, unsigned int y, int color) 145 { 146 (*rgb2scr)(&fbaddress[POINTPOS(x,y)],color); 147 148 if (dbbuffer) { 149 int dline = (y + dboffset) % yres; 150 (*rgb2scr)(&dbbuffer[POINTPOS(x,dline)],color); 151 } 152 } 153 154 /** Get pixel from viewport */ 155 static int getpixel(unsigned int x, unsigned int y) 156 { 157 if (dbbuffer) { 158 int dline = (y + dboffset) % yres; 159 return (*scr2rgb)(&dbbuffer[POINTPOS(x,dline)]); 160 } 161 return (*scr2rgb)(&fbaddress[POINTPOS(x,y)]); 152 162 } 153 163 … … 158 168 unsigned int y; 159 169 160 for (y = 0; y < yres; y++) 161 clear_line(y); 170 for (y = 0; y < yres; y++) { 171 memcpy(&fbaddress[scanline*y], blankline, xres*pixelbytes); 172 if (dbbuffer) 173 memcpy(&dbbuffer[scanline*y], blankline, xres*pixelbytes); 174 } 162 175 } 163 176 … … 167 180 { 168 181 __u8 *lastline = &fbaddress[(rows - 1) * ROW_BYTES]; 169 170 memcpy((void *) fbaddress, (void *) &fbaddress[ROW_BYTES], scanline * yres - ROW_BYTES); 171 172 /* Clear last row */ 173 memcpy((void *) lastline, (void *) blankline, ROW_BYTES); 182 int firstsz; 183 184 if (dbbuffer) { 185 memcpy(&dbbuffer[dboffset*scanline], blankline, FONT_SCANLINES*scanline); 186 187 dboffset = (dboffset + FONT_SCANLINES) % yres; 188 firstsz = yres-dboffset; 189 190 memcpy(fbaddress, &dbbuffer[scanline*dboffset], firstsz*scanline); 191 memcpy(&fbaddress[firstsz*scanline], dbbuffer, dboffset*scanline); 192 } else { 193 memcpy((void *) fbaddress, (void *) &fbaddress[ROW_BYTES], scanline * yres - ROW_BYTES); 194 /* Clear last row */ 195 memcpy((void *) lastline, (void *) blankline, ROW_BYTES); 196 } 174 197 } 175 198 … … 177 200 static void invert_pixel(unsigned int x, unsigned int y) 178 201 { 179 (*putpixel)(x, y, ~(*getpixel)(x, y));202 putpixel(x, y, ~getpixel(x, y)); 180 203 } 181 204 … … 188 211 for (i = 0; i < 8; i++) 189 212 if (glline & (1 << (7 - i))) { 190 (*putpixel)(x + i, y, FGCOLOR);213 putpixel(x + i, y, FGCOLOR); 191 214 } else 192 (*putpixel)(x + i, y, BGCOLOR);215 putpixel(x + i, y, BGCOLOR); 193 216 } 194 217 … … 236 259 byte >>= x % 8; 237 260 if (byte & 1) 238 (*putpixel)(startx + x, starty + y, LOGOCOLOR);261 putpixel(startx + x, starty + y, LOGOCOLOR); 239 262 } 240 263 } … … 312 335 switch (bpp) { 313 336 case 8: 314 putpixel = putpixel_1byte;315 getpixel = getpixel_1byte;337 rgb2scr = rgb_1byte; 338 scr2rgb = byte1_rgb; 316 339 pixelbytes = 1; 317 340 break; 318 341 case 16: 319 putpixel = putpixel_2byte;320 getpixel = getpixel_2byte;342 rgb2scr = rgb_2byte; 343 scr2rgb = byte2_rgb; 321 344 pixelbytes = 2; 322 345 break; 323 346 case 24: 324 putpixel = putpixel_3byte;325 getpixel = getpixel_3byte;347 rgb2scr = rgb_3byte; 348 scr2rgb = byte3_rgb; 326 349 pixelbytes = 3; 327 350 break; 328 351 case 32: 329 putpixel = putpixel_4byte;330 getpixel = getpixel_4byte;352 rgb2scr = rgb_4byte; 353 scr2rgb = byte4_rgb; 331 354 pixelbytes = 4; 332 355 break; … … 348 371 columns = x / COL_WIDTH; 349 372 350 clear_screen(); 373 /* Allocate double buffer */ 374 int totsize = scanline * yres; 375 int pages = SIZE2FRAMES(totsize); 376 int order; 377 int rc; 378 if (pages == 1) 379 order = 0; 380 else 381 order = fnzb(pages-1)+1; 382 383 pfn_t frame = frame_alloc_rc(order,FRAME_ATOMIC,&rc); 384 if (!rc) 385 dbbuffer = (void *)PA2KA(PFN2ADDR(frame)); 386 else 387 printf("Failed to allocate scroll buffer.\n"); 388 dboffset = 0; 389 390 /* Initialized blank line */ 351 391 blankline = (__u8 *) malloc(ROW_BYTES, FRAME_ATOMIC); 352 392 ASSERT(blankline); 353 memcpy((void *) blankline, (void *) &fbaddress[(rows - 1) * ROW_BYTES], ROW_BYTES); 354 393 for (y=0; y < FONT_SCANLINES; y++) 394 for (x=0; x < xres; x++) 395 (*rgb2scr)(&blankline[POINTPOS(x,y)],BGCOLOR); 396 397 clear_screen(); 398 399 /* Update size of screen to match text area */ 400 yres = rows * FONT_SCANLINES; 401 355 402 draw_logo(xres - helenos_width, 0); 356 403 invert_cursor(); … … 366 413 sysinfo_set_item_val("fb.scanline", NULL, scan); 367 414 sysinfo_set_item_val("fb.address.physical", NULL, addr); 368 } 415 416 } -
generic/src/mm/slab.c
r4b74488 r6eb96fce 594 594 595 595 /* Minimum slab order */ 596 pages = ((cache->size-1) >> PAGE_WIDTH) + 1;596 pages = SIZE2FRAMES(cache->size); 597 597 /* We need the 2^order >= pages */ 598 598 if (pages == 1)
Note:
See TracChangeset
for help on using the changeset viewer.