Subversion Repositories HelenOS

Rev

Rev 3343 | Rev 3664 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3343 Rev 3618
Line 434... Line 434...
434
};
434
};
435
 
435
 
436
 
436
 
437
/** Initialize framebuffer as a chardev output device
437
/** Initialize framebuffer as a chardev output device
438
 *
438
 *
439
 * @param addr   Physical address of the framebuffer
439
 * @param props   properties of the framebuffer device
440
 * @param x      Screen width in pixels
-
 
441
 * @param y      Screen height in pixels
-
 
442
 * @param scan   Bytes per one scanline
-
 
443
 * @param visual Color model
-
 
444
 *
440
 *
445
 */
441
 */
446
void fb_init(uintptr_t addr, unsigned int x, unsigned int y, unsigned int scan,
-
 
447
    unsigned int visual)
442
void fb_init(fb_properties_t *props)
448
{
443
{
449
    switch (visual) {
444
    switch (props->visual) {
450
    case VISUAL_INDIRECT_8:
445
    case VISUAL_INDIRECT_8:
451
        rgb2scr = rgb_byte8;
446
        rgb2scr = rgb_byte8;
452
        scr2rgb = byte8_rgb;
447
        scr2rgb = byte8_rgb;
453
        pixelbytes = 1;
448
        pixelbytes = 1;
454
        break;
449
        break;
Line 484... Line 479...
484
        break;
479
        break;
485
    default:
480
    default:
486
        panic("Unsupported visual.\n");
481
        panic("Unsupported visual.\n");
487
    }
482
    }
488
   
483
   
489
    unsigned int fbsize = scan * y;
484
    unsigned int fbsize = (props->scan) * (props->y) + (props->fb_start);
490
   
485
   
491
    /* Map the framebuffer */
486
    /* Map the framebuffer */
492
    fbaddress = (uint8_t *) hw_map((uintptr_t) addr, fbsize);
487
    fbaddress = (uint8_t *) hw_map((uintptr_t) (props->addr), fbsize);
-
 
488
    fbaddress += props->fb_start;
493
   
489
   
494
    xres = x;
490
    xres = props->x;
495
    yres = y;
491
    yres = props->y;
496
    scanline = scan;
492
    scanline = props->scan;
497
   
493
   
498
    rows = y / FONT_SCANLINES;
494
    rows = (props->y) / FONT_SCANLINES;
499
    columns = x / COL_WIDTH;
495
    columns = (props->x) / COL_WIDTH;
500
 
496
 
501
    fb_parea.pbase = (uintptr_t) addr;
497
    fb_parea.pbase = (uintptr_t) (props->addr);
502
    fb_parea.vbase = (uintptr_t) fbaddress;
498
    fb_parea.vbase = (uintptr_t) fbaddress;
503
    fb_parea.frames = SIZE2FRAMES(fbsize);
499
    fb_parea.frames = SIZE2FRAMES(fbsize);
504
    fb_parea.cacheable = false;
500
    fb_parea.cacheable = false;
505
    ddi_parea_register(&fb_parea);
501
    ddi_parea_register(&fb_parea);
506
 
502
 
507
    sysinfo_set_item_val("fb", NULL, true);
503
    sysinfo_set_item_val("fb", NULL, true);
508
    sysinfo_set_item_val("fb.kind", NULL, 1);
504
    sysinfo_set_item_val("fb.kind", NULL, 1);
509
    sysinfo_set_item_val("fb.width", NULL, xres);
505
    sysinfo_set_item_val("fb.width", NULL, xres);
510
    sysinfo_set_item_val("fb.height", NULL, yres);
506
    sysinfo_set_item_val("fb.height", NULL, yres);
511
    sysinfo_set_item_val("fb.scanline", NULL, scan);
507
    sysinfo_set_item_val("fb.scanline", NULL, (props->scan));
512
    sysinfo_set_item_val("fb.visual", NULL, visual);
508
    sysinfo_set_item_val("fb.visual", NULL, (props->visual));
513
    sysinfo_set_item_val("fb.address.physical", NULL, addr);
509
    sysinfo_set_item_val("fb.address.physical", NULL, (props->addr));
514
    sysinfo_set_item_val("fb.invert-colors", NULL, invert_colors);
510
    sysinfo_set_item_val("fb.invert-colors", NULL, invert_colors);
515
 
511
 
516
    /* Allocate double buffer */
512
    /* Allocate double buffer */
517
    unsigned int order = fnzb(SIZE2FRAMES(fbsize) - 1) + 1;
513
    unsigned int order = fnzb(SIZE2FRAMES(fbsize) - 1) + 1;
518
    dbbuffer = (uint8_t *) frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
514
    dbbuffer = (uint8_t *) frame_alloc(order, FRAME_ATOMIC | FRAME_KA);
Line 522... Line 518...
522
 
518
 
523
    /* Initialized blank line */
519
    /* Initialized blank line */
524
    blankline = (uint8_t *) malloc(ROW_BYTES, FRAME_ATOMIC);
520
    blankline = (uint8_t *) malloc(ROW_BYTES, FRAME_ATOMIC);
525
    if (!blankline)
521
    if (!blankline)
526
        panic("Failed to allocate blank line for framebuffer.");
522
        panic("Failed to allocate blank line for framebuffer.");
-
 
523
    unsigned int x, y;
527
    for (y = 0; y < FONT_SCANLINES; y++)
524
    for (y = 0; y < FONT_SCANLINES; y++)
528
        for (x = 0; x < xres; x++)
525
        for (x = 0; x < xres; x++)
529
            (*rgb2scr)(&blankline[POINTPOS(x, y)], COLOR(BGCOLOR));
526
            (*rgb2scr)(&blankline[POINTPOS(x, y)], COLOR(BGCOLOR));
530
   
527
   
531
    clear_screen();
528
    clear_screen();