Changeset 00a020d in mainline


Ignore:
Timestamp:
2009-08-20T16:42:40Z (15 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5360cf0
Parents:
824d6dd
Message:

declare unknown visual type and allow fb_init() to fail gracefully

Location:
kernel/genarch
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/genarch/include/fb/fb.h

    r824d6dd r00a020d  
    6868
    6969void fb_redraw(void);
    70 void fb_init(fb_properties_t *props);
     70bool fb_init(fb_properties_t *props);
    7171
    7272#endif
  • kernel/genarch/include/fb/visuals.h

    r824d6dd r00a020d  
    3737
    3838typedef enum {
     39        VISUAL_UNKNOWN = 0,
    3940        VISUAL_INDIRECT_8,
    4041        VISUAL_RGB_5_5_5_LE,
  • kernel/genarch/src/fb/fb.c

    r824d6dd r00a020d  
    458458 *
    459459 */
    460 void fb_init(fb_properties_t *props)
    461 {
     460bool fb_init(fb_properties_t *props)
     461{
     462        ASSERT(props);
     463        ASSERT(props->x > 0);
     464        ASSERT(props->y > 0);
     465        ASSERT(props->scan > 0);
     466       
    462467        switch (props->visual) {
    463468        case VISUAL_INDIRECT_8:
     
    506511                break;
    507512        default:
    508                 panic("Unsupported visual.");
     513                LOG("Unsupported visual.");
     514                return false;
    509515        }
    510516       
     
    536542        size_t glyphsize = FONT_GLYPHS * glyphbytes;
    537543       
     544        fb_addr = (uint8_t *) hw_map((uintptr_t) props->addr, fbsize);
     545        if (!fb_addr) {
     546                LOG("Unable to map framebuffer.");
     547                return false;
     548        }
     549       
    538550        backbuf = (uint16_t *) malloc(bbsize, 0);
    539         if (!backbuf)
    540                 panic("Unable to allocate backbuffer.");
     551        if (!backbuf) {
     552                LOG("Unable to allocate backbuffer.");
     553                return false;
     554        }
    541555       
    542556        glyphs = (uint8_t *) malloc(glyphsize, 0);
    543         if (!glyphs)
    544                 panic("Unable to allocate glyphs.");
     557        if (!glyphs) {
     558                free(backbuf);
     559                LOG("Unable to allocate glyphs.");
     560                return false;
     561        }
    545562       
    546563        bgscan = malloc(bgscanbytes, 0);
    547         if (!bgscan)
    548                 panic("Unable to allocate background pixel.");
     564        if (!bgscan) {
     565                free(glyphs);
     566                free(backbuf);
     567                LOG("Unable to allocate background pixel.");
     568                return false;
     569        }
    549570       
    550571        memsetw(backbuf, cols * rows, 0);
    551        
    552572        glyphs_render();
    553        
    554         fb_addr = (uint8_t *) hw_map((uintptr_t) props->addr, fbsize);
    555573       
    556574        sysinfo_set_item_val("fb", NULL, true);
     
    566584        outdev_initialize("fb", &fb_console, &fb_ops);
    567585        stdout = &fb_console;
     586       
     587        return true;
    568588}
    569589
Note: See TracChangeset for help on using the changeset viewer.