/* * VAS_EBOOT -- GRand Unified Bootloader * Copyright (C) 2005,2006,2007,2008,2009 Free Software Foundation, Inc. * * VAS_EBOOT is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * VAS_EBOOT is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with VAS_EBOOT. If not, see . */ #define VasEBoot_video_render_target VasEBoot_video_fbrender_target #include #include #include #include #include #include #include #include #include struct VasEBoot_linuxbios_table_framebuffer *VasEBoot_video_coreboot_fbtable; static struct { struct VasEBoot_video_mode_info mode_info; VasEBoot_uint8_t *ptr; } framebuffer; static VasEBoot_err_t VasEBoot_video_cbfb_init (void) { VasEBoot_memset (&framebuffer, 0, sizeof(framebuffer)); return VasEBoot_video_fb_init (); } static VasEBoot_err_t VasEBoot_video_cbfb_fill_mode_info (struct VasEBoot_video_mode_info *out) { VasEBoot_memset (out, 0, sizeof (*out)); out->width = VasEBoot_video_coreboot_fbtable->width; out->height = VasEBoot_video_coreboot_fbtable->height; out->pitch = VasEBoot_video_coreboot_fbtable->pitch; out->red_field_pos = VasEBoot_video_coreboot_fbtable->red_field_pos; out->red_mask_size = VasEBoot_video_coreboot_fbtable->red_mask_size; out->green_field_pos = VasEBoot_video_coreboot_fbtable->green_field_pos; out->green_mask_size = VasEBoot_video_coreboot_fbtable->green_mask_size; out->blue_field_pos = VasEBoot_video_coreboot_fbtable->blue_field_pos; out->blue_mask_size = VasEBoot_video_coreboot_fbtable->blue_mask_size; out->reserved_field_pos = VasEBoot_video_coreboot_fbtable->reserved_field_pos; out->reserved_mask_size = VasEBoot_video_coreboot_fbtable->reserved_mask_size; out->mode_type = VAS_EBOOT_VIDEO_MODE_TYPE_RGB; out->bpp = VasEBoot_video_coreboot_fbtable->bpp; out->bytes_per_pixel = (VasEBoot_video_coreboot_fbtable->bpp + 7) / 8; out->number_of_colors = 256; out->blit_format = VasEBoot_video_get_blit_format (out); return VAS_EBOOT_ERR_NONE; } static VasEBoot_err_t VasEBoot_video_cbfb_setup (unsigned int width, unsigned int height, unsigned int mode_type __attribute__ ((unused)), unsigned int mode_mask __attribute__ ((unused))) { VasEBoot_err_t err; if (!VasEBoot_video_coreboot_fbtable) return VasEBoot_error (VAS_EBOOT_ERR_IO, "Couldn't find display device."); if (!((width == VasEBoot_video_coreboot_fbtable->width && height == VasEBoot_video_coreboot_fbtable->height) || (width == 0 && height == 0))) return VasEBoot_error (VAS_EBOOT_ERR_IO, "can't set mode %dx%d", width, height); err = VasEBoot_video_cbfb_fill_mode_info (&framebuffer.mode_info); if (err) { VasEBoot_dprintf ("video", "CBFB: couldn't fill mode info\n"); return err; } framebuffer.ptr = (void *) (VasEBoot_addr_t) VasEBoot_video_coreboot_fbtable->lfb; VasEBoot_dprintf ("video", "CBFB: initialising FB @ %p %dx%dx%d\n", framebuffer.ptr, framebuffer.mode_info.width, framebuffer.mode_info.height, framebuffer.mode_info.bpp); err = VasEBoot_video_fb_setup (mode_type, mode_mask, &framebuffer.mode_info, framebuffer.ptr, NULL, NULL); if (err) return err; VasEBoot_video_fb_set_palette (0, VAS_EBOOT_VIDEO_FBSTD_NUMCOLORS, VasEBoot_video_fbstd_colors); return err; } static VasEBoot_err_t VasEBoot_video_cbfb_get_info_and_fini (struct VasEBoot_video_mode_info *mode_info, void **framebuf) { VasEBoot_memcpy (mode_info, &(framebuffer.mode_info), sizeof (*mode_info)); *framebuf = (char *) framebuffer.ptr; VasEBoot_video_fb_fini (); return VAS_EBOOT_ERR_NONE; } static struct VasEBoot_video_adapter VasEBoot_video_cbfb_adapter = { .name = "Coreboot video driver", .prio = VAS_EBOOT_VIDEO_ADAPTER_PRIO_FIRMWARE_DIRTY, .id = VAS_EBOOT_VIDEO_DRIVER_COREBOOT, .init = VasEBoot_video_cbfb_init, .fini = VasEBoot_video_fb_fini, .setup = VasEBoot_video_cbfb_setup, .get_info = VasEBoot_video_fb_get_info, .get_info_and_fini = VasEBoot_video_cbfb_get_info_and_fini, .set_palette = VasEBoot_video_fb_set_palette, .get_palette = VasEBoot_video_fb_get_palette, .set_viewport = VasEBoot_video_fb_set_viewport, .get_viewport = VasEBoot_video_fb_get_viewport, .set_region = VasEBoot_video_fb_set_region, .get_region = VasEBoot_video_fb_get_region, .set_area_status = VasEBoot_video_fb_set_area_status, .get_area_status = VasEBoot_video_fb_get_area_status, .map_color = VasEBoot_video_fb_map_color, .map_rgb = VasEBoot_video_fb_map_rgb, .map_rgba = VasEBoot_video_fb_map_rgba, .unmap_color = VasEBoot_video_fb_unmap_color, .fill_rect = VasEBoot_video_fb_fill_rect, .blit_bitmap = VasEBoot_video_fb_blit_bitmap, .blit_render_target = VasEBoot_video_fb_blit_render_target, .scroll = VasEBoot_video_fb_scroll, .swap_buffers = VasEBoot_video_fb_swap_buffers, .create_render_target = VasEBoot_video_fb_create_render_target, .delete_render_target = VasEBoot_video_fb_delete_render_target, .set_active_render_target = VasEBoot_video_fb_set_active_render_target, .get_active_render_target = VasEBoot_video_fb_get_active_render_target, .next = 0 }; static int iterate_linuxbios_table (VasEBoot_linuxbios_table_item_t table_item, void *data __attribute__ ((unused))) { if (table_item->tag != VAS_EBOOT_LINUXBIOS_MEMBER_FRAMEBUFFER) return 0; VasEBoot_video_coreboot_fbtable = (struct VasEBoot_linuxbios_table_framebuffer *) (table_item + 1); return 1; } void VasEBoot_video_coreboot_fb_early_init (void) { VasEBoot_linuxbios_table_iterate (iterate_linuxbios_table, 0); } void VasEBoot_video_coreboot_fb_late_init (void) { if (VasEBoot_video_coreboot_fbtable) VasEBoot_video_register (&VasEBoot_video_cbfb_adapter); } void VasEBoot_video_coreboot_fb_fini (void) { if (VasEBoot_video_coreboot_fbtable) VasEBoot_video_unregister (&VasEBoot_video_cbfb_adapter); }