1 // Option rom scanning code.
3 // Copyright (C) 2009-2010 coresystems GmbH
4 // Copyright (C) 2010 Kevin O'Connor <kevin@koconnor.net>
6 // This file may be distributed under the terms of the GNU LGPLv3 license.
8 #include "bregs.h" // struct bregs
9 #include "farptr.h" // FLATPTR_TO_SEG
10 #include "config.h" // CONFIG_*
11 #include "util.h" // dprintf
12 #include "jpeg.h" // splash
13 #include "biosvar.h" // SET_EBDA
16 /****************************************************************
18 ****************************************************************/
24 struct segoff_s oem_string_ptr;
26 struct segoff_s video_mode_ptr;
29 struct segoff_s oem_vendor_name_ptr;
30 struct segoff_s oem_product_name_ptr;
31 struct segoff_s oem_product_rev_ptr;
36 #define VESA_SIGNATURE 0x41534556 // VESA
37 #define VBE2_SIGNATURE 0x32454256 // VBE2
49 u16 bytes_per_scanline;
59 u8 number_of_image_pages;
67 u8 reserved_mask_size;
69 u8 direct_color_mode_info;
71 u32 offscreen_mem_offset;
72 u16 offscreen_mem_size;
76 /****************************************************************
78 ****************************************************************/
80 // Call int10 vga handler.
82 call16_int10(struct bregs *br)
91 /****************************************************************
92 * VGA text / graphics console
93 ****************************************************************/
95 static void enable_vga_text_console(void)
97 dprintf(1, "Turning on vga text mode console\n");
100 /* Enable VGA text mode */
101 memset(&br, 0, sizeof(br));
106 printf("SeaBIOS (version %s)\n\n", VERSION);
109 void enable_vga_console(void)
111 struct vesa_info *vesa_info = NULL;
112 struct vesa_mode_info *mode_info = NULL;
113 struct jpeg_decdata *decdata = NULL;
114 u8 *jpeg = NULL, *picture = NULL;
116 /* Needs coreboot support for CBFS */
117 if (!CONFIG_BOOTSPLASH || !CONFIG_COREBOOT)
119 struct cbfs_file *file = cbfs_finddatafile("bootsplash.jpg");
122 int filesize = cbfs_datasize(file);
124 int imagesize = (CONFIG_BOOTSPLASH_X * CONFIG_BOOTSPLASH_Y *
125 (CONFIG_BOOTSPLASH_DEPTH / 8));
126 jpeg = malloc_tmphigh(filesize);
127 picture = malloc_tmphigh(imagesize);
128 vesa_info = malloc_tmplow(sizeof(*vesa_info));
129 mode_info = malloc_tmplow(sizeof(*mode_info));
130 decdata = malloc_tmphigh(sizeof(*decdata));
131 if (!jpeg || !picture || !vesa_info || !mode_info || !decdata) {
136 /* Check whether we have a VESA 2.0 compliant BIOS */
137 memset(vesa_info, 0, sizeof(struct vesa_info));
138 vesa_info->vesa_signature = VBE2_SIGNATURE;
140 memset(&br, 0, sizeof(br));
142 br.di = FLATPTR_TO_OFFSET(vesa_info);
143 br.es = FLATPTR_TO_SEG(vesa_info);
145 if (vesa_info->vesa_signature != VESA_SIGNATURE) {
146 dprintf(1,"No VBE2 found.\n");
150 /* Print some debugging information about our card. */
151 char *vendor = SEGOFF_TO_FLATPTR(vesa_info->oem_vendor_name_ptr);
152 char *product = SEGOFF_TO_FLATPTR(vesa_info->oem_product_name_ptr);
153 dprintf(8, "VESA %d.%d\nVENDOR: %s\nPRODUCT: %s\n",
154 vesa_info->vesa_version>>8, vesa_info->vesa_version&0xff,
157 /* Get information about our graphics mode, like the
158 * framebuffer start address
160 memset(&br, 0, sizeof(br));
162 br.cx = (1 << 14) | CONFIG_BOOTSPLASH_VESA_MODE;
163 br.di = FLATPTR_TO_OFFSET(mode_info);
164 br.es = FLATPTR_TO_SEG(mode_info);
167 dprintf(1, "get_mode failed.\n");
170 unsigned char *framebuffer = (unsigned char *) (mode_info->phys_base_ptr);
172 /* Switch to graphics mode */
173 memset(&br, 0, sizeof(br));
175 br.bx = (1 << 14) | CONFIG_BOOTSPLASH_VESA_MODE;
178 dprintf(1, "set_mode failed.\n");
182 dprintf(8, "framebuffer: %x\n", (u32)framebuffer);
183 dprintf(8, "bytes per scanline: %d\n", mode_info->bytes_per_scanline);
184 dprintf(8, "bits per pixel: %d\n", mode_info->bits_per_pixel);
186 /* Decompress jpeg */
187 dprintf(8, "Copying boot splash screen...\n");
188 cbfs_copyfile(file, jpeg, filesize);
189 dprintf(8, "Decompressing boot splash screen...\n");
190 int ret = jpeg_decode(jpeg, picture, CONFIG_BOOTSPLASH_X,
191 CONFIG_BOOTSPLASH_Y, CONFIG_BOOTSPLASH_DEPTH, decdata);
193 dprintf(1, "jpeg_decode failed with return code %d...\n", ret);
197 /* Show the picture */
198 iomemcpy(framebuffer, picture, imagesize);
199 SET_EBDA(bootsplash_active, 1);
209 enable_vga_text_console();
214 disable_bootsplash(void)
216 if (! CONFIG_BOOTSPLASH || !GET_EBDA(bootsplash_active))
218 SET_EBDA(bootsplash_active, 0);
219 enable_vga_text_console();