Changeset a35b458 in mainline for kernel/genarch/src/fb
- Timestamp:
- 2018-03-02T20:10:49Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- f1380b7
- Parents:
- 3061bc1
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
- Location:
- kernel/genarch/src/fb
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/fb/bfb.c
r3061bc1 ra35b458 61 61 (bfb_bpp == 0) || (bfb_scanline == 0)) 62 62 return false; 63 63 64 64 fb_properties_t bfb_props = { 65 65 .addr = bfb_addr, … … 69 69 .scan = bfb_scanline 70 70 }; 71 71 72 72 switch (bfb_bpp) { 73 73 case 8: … … 92 92 return false; 93 93 } 94 94 95 95 outdev_t *fbdev = fb_init(&bfb_props); 96 96 if (!fbdev) 97 97 return false; 98 98 99 99 stdout_wire(fbdev); 100 100 return true; -
kernel/genarch/src/fb/fb.c
r3061bc1 ra35b458 84 84 typedef struct { 85 85 SPINLOCK_DECLARE(lock); 86 86 87 87 parea_t parea; 88 88 89 89 uint8_t *addr; 90 90 uint16_t *backbuf; 91 91 uint8_t *glyphs; 92 92 uint8_t *bgscan; 93 93 94 94 rgb_conv_t rgb_conv; 95 95 96 96 unsigned int xres; 97 97 unsigned int yres; 98 98 99 99 /** Number of rows that fit on framebuffer */ 100 100 unsigned int rowtrim; 101 101 102 102 unsigned int scanline; 103 103 unsigned int glyphscanline; 104 104 105 105 unsigned int pixelbytes; 106 106 unsigned int glyphbytes; 107 107 unsigned int bgscanbytes; 108 108 109 109 /** Number of columns in the backbuffer */ 110 110 unsigned int cols; 111 111 /** Number of rows in the backbuffer */ 112 112 unsigned int rows; 113 113 114 114 /** Starting row in the cyclic backbuffer */ 115 115 unsigned int start_row; 116 116 117 117 /** Top-most visible row (relative to start_row) */ 118 118 unsigned int offset_row; 119 119 120 120 /** Current backbuffer position */ 121 121 unsigned int position; … … 236 236 if (!overlay) 237 237 instance->backbuf[BB_POS(instance, col, row)] = glyph; 238 238 239 239 /* Do not output if the framebuffer is used by user space */ 240 240 if ((instance->parea.mapped) && (!console_override)) 241 241 return; 242 242 243 243 /* Check whether the glyph should be visible */ 244 244 if (row < instance->offset_row) 245 245 return; 246 246 247 247 unsigned int rel_row = row - instance->offset_row; 248 248 if (rel_row >= instance->rowtrim) 249 249 return; 250 250 251 251 unsigned int x = COL2X(col); 252 252 unsigned int y = ROW2Y(rel_row); 253 253 254 254 for (unsigned int yd = 0; yd < FONT_SCANLINES; yd++) 255 255 memcpy(&instance->addr[FB_POS(instance, x, y + yd)], … … 267 267 unsigned int y = ROW2Y(rel_row); 268 268 unsigned int row = rel_row + instance->offset_row; 269 269 270 270 for (unsigned int yd = 0; yd < FONT_SCANLINES; yd++) { 271 271 unsigned int x; 272 272 unsigned int col; 273 273 274 274 for (col = 0, x = 0; col < instance->cols; 275 275 col++, x += FONT_WIDTH) { 276 276 uint16_t glyph; 277 277 278 278 if (row < instance->rows - 1) { 279 279 if (instance->backbuf[BB_POS(instance, col, row)] == 280 280 instance->backbuf[BB_POS(instance, col, row + 1)]) 281 281 continue; 282 282 283 283 glyph = instance->backbuf[BB_POS(instance, col, row + 1)]; 284 284 } else 285 285 glyph = 0; 286 286 287 287 memcpy(&instance->addr[FB_POS(instance, x, y + yd)], 288 288 &instance->glyphs[GLYPH_POS(instance, glyph, yd)], … … 292 292 } 293 293 } 294 294 295 295 /* 296 296 * Implement backbuffer scrolling by wrapping around 297 297 * the cyclic buffer. 298 298 */ 299 299 300 300 instance->start_row++; 301 301 if (instance->start_row == instance->rows) 302 302 instance->start_row = 0; 303 303 304 304 memsetw(&instance->backbuf[BB_POS(instance, 0, instance->rows - 1)], 305 305 instance->cols, 0); … … 310 310 unsigned int col = instance->position % instance->cols; 311 311 unsigned int row = instance->position / instance->cols; 312 312 313 313 glyph_draw(instance, fb_font_glyph(U_CURSOR), col, row, true); 314 314 } … … 318 318 unsigned int col = instance->position % instance->cols; 319 319 unsigned int row = instance->position / instance->cols; 320 320 321 321 glyph_draw(instance, instance->backbuf[BB_POS(instance, col, row)], 322 322 col, row, true); … … 333 333 /* Prerender glyphs */ 334 334 uint16_t glyph; 335 335 336 336 for (glyph = 0; glyph < FONT_GLYPHS; glyph++) { 337 337 uint32_t fg_color; 338 338 339 339 if (glyph == FONT_GLYPHS - 1) 340 340 fg_color = INV_COLOR; 341 341 else 342 342 fg_color = FG_COLOR; 343 343 344 344 unsigned int y; 345 345 346 346 for (y = 0; y < FONT_SCANLINES; y++) { 347 347 unsigned int x; 348 348 349 349 for (x = 0; x < FONT_WIDTH; x++) { 350 350 void *dst = … … 357 357 } 358 358 } 359 359 360 360 /* Prerender background scanline */ 361 361 unsigned int x; 362 362 363 363 for (x = 0; x < instance->xres; x++) 364 364 instance->rgb_conv(&instance->bgscan[x * instance->pixelbytes], BG_COLOR); … … 370 370 unsigned int y = ROW2Y(rel_row); 371 371 unsigned int row = rel_row + instance->offset_row; 372 372 373 373 for (unsigned int yd = 0; yd < FONT_SCANLINES; yd++) { 374 374 unsigned int x; 375 375 unsigned int col; 376 376 377 377 for (col = 0, x = 0; col < instance->cols; 378 378 col++, x += FONT_WIDTH) { … … 385 385 } 386 386 } 387 387 388 388 if (COL2X(instance->cols) < instance->xres) { 389 389 unsigned int y; 390 390 unsigned int size = 391 391 (instance->xres - COL2X(instance->cols)) * instance->pixelbytes; 392 392 393 393 for (y = 0; y < instance->yres; y++) 394 394 memcpy(&instance->addr[FB_POS(instance, COL2X(instance->cols), y)], 395 395 instance->bgscan, size); 396 396 } 397 397 398 398 if (ROW2Y(instance->rowtrim) < instance->yres) { 399 399 unsigned int y; 400 400 401 401 for (y = ROW2Y(instance->rowtrim); y < instance->yres; y++) 402 402 memcpy(&instance->addr[FB_POS(instance, 0, y)], … … 414 414 fb_instance_t *instance = (fb_instance_t *) dev->data; 415 415 spinlock_lock(&instance->lock); 416 416 417 417 switch (ch) { 418 418 case '\n': … … 446 446 instance->position++; 447 447 } 448 448 449 449 if (instance->position >= instance->cols * instance->rows) { 450 450 instance->position -= instance->cols; 451 451 screen_scroll(instance); 452 452 } 453 453 454 454 cursor_put(instance); 455 455 456 456 spinlock_unlock(&instance->lock); 457 457 } … … 464 464 fb_instance_t *instance = (fb_instance_t *) dev->data; 465 465 spinlock_lock(&instance->lock); 466 466 467 467 if (instance->offset_row >= instance->rowtrim / 2) 468 468 instance->offset_row -= instance->rowtrim / 2; 469 469 else 470 470 instance->offset_row = 0; 471 471 472 472 fb_redraw_internal(instance); 473 473 cursor_put(instance); 474 474 475 475 spinlock_unlock(&instance->lock); 476 476 } … … 483 483 fb_instance_t *instance = (fb_instance_t *) dev->data; 484 484 spinlock_lock(&instance->lock); 485 485 486 486 if (instance->offset_row + instance->rowtrim / 2 <= 487 487 instance->rows - instance->rowtrim) … … 489 489 else 490 490 instance->offset_row = instance->rows - instance->rowtrim; 491 491 492 492 fb_redraw_internal(instance); 493 493 cursor_put(instance); 494 494 495 495 spinlock_unlock(&instance->lock); 496 496 } … … 502 502 { 503 503 fb_instance_t *instance = (fb_instance_t *) dev->data; 504 504 505 505 spinlock_lock(&instance->lock); 506 506 fb_redraw_internal(instance); … … 517 517 assert(props->y > 0); 518 518 assert(props->scan > 0); 519 519 520 520 rgb_conv_t rgb_conv; 521 521 unsigned int pixelbytes; 522 522 523 523 switch (props->visual) { 524 524 case VISUAL_INDIRECT_8: … … 570 570 return NULL; 571 571 } 572 572 573 573 outdev_t *fbdev = malloc(sizeof(outdev_t), FRAME_ATOMIC); 574 574 if (!fbdev) 575 575 return NULL; 576 576 577 577 fb_instance_t *instance = malloc(sizeof(fb_instance_t), FRAME_ATOMIC); 578 578 if (!instance) { … … 580 580 return NULL; 581 581 } 582 582 583 583 outdev_initialize("fbdev", fbdev, &fbdev_ops); 584 584 fbdev->data = instance; 585 585 586 586 spinlock_initialize(&instance->lock, "*fb.instance.lock"); 587 587 588 588 instance->rgb_conv = rgb_conv; 589 589 instance->pixelbytes = pixelbytes; … … 591 591 instance->yres = props->y; 592 592 instance->scanline = props->scan; 593 593 594 594 instance->rowtrim = Y2ROW(instance->yres); 595 595 596 596 instance->cols = X2COL(instance->xres); 597 597 instance->rows = FB_PAGES * instance->rowtrim; 598 598 599 599 instance->start_row = instance->rows - instance->rowtrim; 600 600 instance->offset_row = instance->start_row; 601 601 instance->position = instance->start_row * instance->cols; 602 602 603 603 instance->glyphscanline = FONT_WIDTH * instance->pixelbytes; 604 604 instance->glyphbytes = ROW2Y(instance->glyphscanline); 605 605 instance->bgscanbytes = instance->xres * instance->pixelbytes; 606 606 607 607 size_t fbsize = instance->scanline * instance->yres; 608 608 size_t bbsize = instance->cols * instance->rows * sizeof(uint16_t); 609 609 size_t glyphsize = FONT_GLYPHS * instance->glyphbytes; 610 610 611 611 instance->addr = (uint8_t *) km_map((uintptr_t) props->addr, fbsize, 612 612 PAGE_WRITE | PAGE_NOT_CACHEABLE); … … 617 617 return NULL; 618 618 } 619 619 620 620 instance->backbuf = (uint16_t *) malloc(bbsize, 0); 621 621 if (!instance->backbuf) { … … 625 625 return NULL; 626 626 } 627 627 628 628 instance->glyphs = (uint8_t *) malloc(glyphsize, 0); 629 629 if (!instance->glyphs) { … … 634 634 return NULL; 635 635 } 636 636 637 637 instance->bgscan = malloc(instance->bgscanbytes, 0); 638 638 if (!instance->bgscan) { … … 644 644 return NULL; 645 645 } 646 646 647 647 memsetw(instance->backbuf, instance->cols * instance->rows, 0); 648 648 glyphs_render(instance); 649 649 650 650 link_initialize(&instance->parea.link); 651 651 instance->parea.pbase = props->addr; … … 654 654 instance->parea.mapped = false; 655 655 ddi_parea_register(&instance->parea); 656 656 657 657 if (!fb_exported) { 658 658 /* … … 668 668 sysinfo_set_item_val("fb.visual", NULL, props->visual); 669 669 sysinfo_set_item_val("fb.address.physical", NULL, props->addr); 670 670 671 671 fb_exported = true; 672 672 } 673 673 674 674 fb_redraw(fbdev); 675 675 return fbdev; -
kernel/genarch/src/fb/font-8x16.c
r3061bc1 ra35b458 47 47 if (ch == 0x0000) 48 48 return 0; 49 49 50 50 if ((ch >= 0x0020) && (ch <= 0x007f)) 51 51 return (ch - 32); 52 52 53 53 if ((ch >= 0x00a0) && (ch <= 0x021f)) 54 54 return (ch - 64); 55 55 56 56 if ((ch >= 0x0222) && (ch <= 0x0233)) 57 57 return (ch - 66); 58 58 59 59 if ((ch >= 0x0250) && (ch <= 0x02ad)) 60 60 return (ch - 94); 61 61 62 62 if ((ch >= 0x02b0) && (ch <= 0x02cf)) 63 63 return (ch - 96); 64 64 65 65 if ((ch >= 0x02d8) && (ch <= 0x02dd)) 66 66 return (ch - 104); 67 67 68 68 if (ch == 0x02ee) 69 69 return 630; 70 70 71 71 if ((ch >= 0x0300) && (ch <= 0x0301)) 72 72 return (ch - 137); 73 73 74 74 if (ch == 0x0303) 75 75 return 633; 76 76 77 77 if (ch == 0x0309) 78 78 return 634; 79 79 80 80 if ((ch >= 0x0312) && (ch <= 0x0314)) 81 81 return (ch - 151); 82 82 83 83 if (ch == 0x0323) 84 84 return 638; 85 85 86 86 if ((ch >= 0x0340) && (ch <= 0x0341)) 87 87 return (ch - 193); 88 88 89 89 if ((ch >= 0x0374) && (ch <= 0x0375)) 90 90 return (ch - 243); 91 91 92 92 if (ch == 0x037a) 93 93 return 643; 94 94 95 95 if (ch == 0x037e) 96 96 return 644; 97 97 98 98 if ((ch >= 0x0384) && (ch <= 0x038a)) 99 99 return (ch - 255); 100 100 101 101 if (ch == 0x038c) 102 102 return 652; 103 103 104 104 if ((ch >= 0x038e) && (ch <= 0x03a1)) 105 105 return (ch - 257); 106 106 107 107 if ((ch >= 0x03a3) && (ch <= 0x03ce)) 108 108 return (ch - 258); 109 109 110 110 if ((ch >= 0x03d0) && (ch <= 0x03d7)) 111 111 return (ch - 259); 112 112 113 113 if ((ch >= 0x03da) && (ch <= 0x03f3)) 114 114 return (ch - 261); 115 115 116 116 if ((ch >= 0x0400) && (ch <= 0x0486)) 117 117 return (ch - 273); 118 118 119 119 if ((ch >= 0x0488) && (ch <= 0x04ce)) 120 120 return (ch - 274); 121 121 122 122 if ((ch >= 0x04d0) && (ch <= 0x04f5)) 123 123 return (ch - 275); 124 124 125 125 if ((ch >= 0x04f8) && (ch <= 0x04f9)) 126 126 return (ch - 277); 127 127 128 128 if ((ch >= 0x0500) && (ch <= 0x050f)) 129 129 return (ch - 283); 130 130 131 131 if ((ch >= 0x0530) && (ch <= 0x0556)) 132 132 return (ch - 315); 133 133 134 134 if ((ch >= 0x0559) && (ch <= 0x055f)) 135 135 return (ch - 317); 136 136 137 137 if ((ch >= 0x0561) && (ch <= 0x0587)) 138 138 return (ch - 318); 139 139 140 140 if ((ch >= 0x0589) && (ch <= 0x058a)) 141 141 return (ch - 319); 142 142 143 143 if ((ch >= 0x0591) && (ch <= 0x05a1)) 144 144 return (ch - 325); 145 145 146 146 if ((ch >= 0x05a3) && (ch <= 0x05b9)) 147 147 return (ch - 326); 148 148 149 149 if ((ch >= 0x05bb) && (ch <= 0x05c4)) 150 150 return (ch - 327); 151 151 152 152 if ((ch >= 0x05d0) && (ch <= 0x05ea)) 153 153 return (ch - 338); 154 154 155 155 if ((ch >= 0x05f0) && (ch <= 0x05f4)) 156 156 return (ch - 343); 157 157 158 158 if (ch == 0x060c) 159 159 return 1182; 160 160 161 161 if (ch == 0x061b) 162 162 return 1183; 163 163 164 164 if (ch == 0x061f) 165 165 return 1184; 166 166 167 167 if ((ch >= 0x0621) && (ch <= 0x063a)) 168 168 return (ch - 384); 169 169 170 170 if ((ch >= 0x0640) && (ch <= 0x0655)) 171 171 return (ch - 389); 172 172 173 173 if ((ch >= 0x0660) && (ch <= 0x066d)) 174 174 return (ch - 399); 175 175 176 176 if ((ch >= 0x0670) && (ch <= 0x06ed)) 177 177 return (ch - 401); 178 178 179 179 if ((ch >= 0x06f0) && (ch <= 0x06fe)) 180 180 return (ch - 403); 181 181 182 182 if (ch == 0x10d3) 183 183 return 1388; 184 184 185 185 if (ch == 0x10d7) 186 186 return 1389; 187 187 188 188 if (ch == 0x10da) 189 189 return 1390; 190 190 191 191 if (ch == 0x10dd) 192 192 return 1391; 193 193 194 194 if (ch == 0x10e6) 195 195 return 1392; 196 196 197 197 if ((ch >= 0x1e00) && (ch <= 0x1e9b)) 198 198 return (ch - 6287); 199 199 200 200 if ((ch >= 0x1ea0) && (ch <= 0x1ef9)) 201 201 return (ch - 6291); 202 202 203 203 if ((ch >= 0x1f00) && (ch <= 0x1f07)) 204 204 return (ch - 6297); 205 205 206 206 if ((ch >= 0x2000) && (ch <= 0x2027)) 207 207 return (ch - 6545); 208 208 209 209 if ((ch >= 0x2030) && (ch <= 0x2046)) 210 210 return (ch - 6553); 211 211 212 212 if ((ch >= 0x2048) && (ch <= 0x204d)) 213 213 return (ch - 6554); 214 214 215 215 if (ch == 0x2070) 216 216 return 1716; 217 217 218 218 if ((ch >= 0x2074) && (ch <= 0x208f)) 219 219 return (ch - 6591); 220 220 221 221 if ((ch >= 0x20a0) && (ch <= 0x20af)) 222 222 return (ch - 6607); 223 223 224 224 if ((ch >= 0x2100) && (ch <= 0x213a)) 225 225 return (ch - 6687); 226 226 227 227 if ((ch >= 0x2153) && (ch <= 0x2183)) 228 228 return (ch - 6711); 229 229 230 230 if ((ch >= 0x2190) && (ch <= 0x21f3)) 231 231 return (ch - 6723); 232 232 233 233 if ((ch >= 0x2200) && (ch <= 0x22f1)) 234 234 return (ch - 6735); 235 235 236 236 if (ch == 0x2300) 237 237 return 2211; 238 238 239 239 if (ch == 0x2302) 240 240 return 2212; 241 241 242 242 if ((ch >= 0x2308) && (ch <= 0x230b)) 243 243 return (ch - 6755); 244 244 245 245 if (ch == 0x2310) 246 246 return 2217; 247 247 248 248 if (ch == 0x2318) 249 249 return 2218; 250 250 251 251 if ((ch >= 0x231a) && (ch <= 0x231b)) 252 252 return (ch - 6767); 253 253 254 254 if ((ch >= 0x2320) && (ch <= 0x2321)) 255 255 return (ch - 6771); 256 256 257 257 if ((ch >= 0x2329) && (ch <= 0x232a)) 258 258 return (ch - 6778); 259 259 260 260 if ((ch >= 0x239b) && (ch <= 0x23bd)) 261 261 return (ch - 6890); 262 262 263 263 if (ch == 0x23ce) 264 264 return 2260; 265 265 266 266 if ((ch >= 0x2409) && (ch <= 0x240d)) 267 267 return (ch - 6964); 268 268 269 269 if ((ch >= 0x2423) && (ch <= 0x2424)) 270 270 return (ch - 6985); 271 271 272 272 if (ch == 0x2426) 273 273 return 2268; 274 274 275 275 if ((ch >= 0x2500) && (ch <= 0x2595)) 276 276 return (ch - 7203); 277 277 278 278 if ((ch >= 0x25a0) && (ch <= 0x25f7)) 279 279 return (ch - 7213); 280 280 281 281 if ((ch >= 0x2600) && (ch <= 0x2602)) 282 282 return (ch - 7221); 283 283 284 284 if ((ch >= 0x2605) && (ch <= 0x260d)) 285 285 return (ch - 7223); 286 286 287 287 if ((ch >= 0x2610) && (ch <= 0x2613)) 288 288 return (ch - 7225); 289 289 290 290 if (ch == 0x2620) 291 291 return 2523; 292 292 293 293 if (ch == 0x2622) 294 294 return 2524; 295 295 296 296 if (ch == 0x2626) 297 297 return 2525; 298 298 299 299 if ((ch >= 0x2628) && (ch <= 0x262b)) 300 300 return (ch - 7242); 301 301 302 302 if ((ch >= 0x262e) && (ch <= 0x2637)) 303 303 return (ch - 7244); 304 304 305 305 if ((ch >= 0x2639) && (ch <= 0x2653)) 306 306 return (ch - 7245); 307 307 308 308 if ((ch >= 0x2660) && (ch <= 0x2667)) 309 309 return (ch - 7257); 310 310 311 311 if ((ch >= 0x2669) && (ch <= 0x266f)) 312 312 return (ch - 7258); 313 313 314 314 if ((ch >= 0xfb00) && (ch <= 0xfb05)) 315 315 return (ch - 61674); 316 316 317 317 if ((ch >= 0xfb50) && (ch <= 0xfbb1)) 318 318 return (ch - 61748); 319 319 320 320 if ((ch >= 0xfbd3) && (ch <= 0xfbe9)) 321 321 return (ch - 61781); 322 322 323 323 if ((ch >= 0xfbfc) && (ch <= 0xfbff)) 324 324 return (ch - 61799); 325 325 326 326 if ((ch >= 0xfc5b) && (ch <= 0xfc63)) 327 327 return (ch - 61890); 328 328 329 329 if (ch == 0xfc90) 330 330 return 2722; 331 331 332 332 if ((ch >= 0xfcf2) && (ch <= 0xfcf4)) 333 333 return (ch - 62031); 334 334 335 335 if ((ch >= 0xfd3c) && (ch <= 0xfd3f)) 336 336 return (ch - 62102); 337 337 338 338 if (ch == 0xfdf2) 339 339 return 2730; 340 340 341 341 if ((ch >= 0xfe50) && (ch <= 0xfe52)) 342 342 return (ch - 62373); 343 343 344 344 if ((ch >= 0xfe54) && (ch <= 0xfe66)) 345 345 return (ch - 62374); 346 346 347 347 if ((ch >= 0xfe68) && (ch <= 0xfe6b)) 348 348 return (ch - 62375); 349 349 350 350 if ((ch >= 0xfe70) && (ch <= 0xfe72)) 351 351 return (ch - 62379); 352 352 353 353 if (ch == 0xfe74) 354 354 return 2760; 355 355 356 356 if ((ch >= 0xfe76) && (ch <= 0xfefc)) 357 357 return (ch - 62381); 358 358 359 359 if (ch == 0xfeff) 360 360 return 2896; 361 361 362 362 return 2898; 363 363 } … … 3262 3262 {0xf1, 0x35, 0x55, 0x8a, 0xe0, 0x06, 0x95, 0xd6, 0xb5, 0x97, 0x00, 0xee, 0x8a, 0xee, 0x28, 0xe8}, 3263 3263 {0x00, 0x38, 0x7c, 0x7c, 0xc6, 0x92, 0xf2, 0xe6, 0xfe, 0xe6, 0x7c, 0x7c, 0x38, 0x00, 0x00, 0x00}, 3264 3264 3265 3265 /* Special glyph for unknown character */ 3266 3266 {0x00, 0x00, 0x7c, 0xc6, 0xc6, 0x0c, 0x18, 0x18, 0x18, 0x00, 0x18, 0x18, 0x00, 0x00, 0x00, 0x00}
Note:
See TracChangeset
for help on using the changeset viewer.
