1
// Option rom scanning code.
3
// Copyright (C) 2009-2010 coresystems GmbH
5
// This file may be distributed under the terms of the GNU LGPLv3 license.
7
#include "bregs.h" // struct bregs
8
#include "farptr.h" // FLATPTR_TO_SEG
9
#include "config.h" // CONFIG_*
10
#include "util.h" // dprintf
11
#include "jpeg.h" // splash
13
/****************************************************************
15
****************************************************************/
17
/****************************************************************
19
****************************************************************/
30
u32 oem_vendor_name_ptr;
31
u32 oem_product_name_ptr;
32
u32 oem_product_rev_ptr;
47
u16 bytes_per_scanline;
57
u8 number_of_image_pages;
65
u8 reserved_mask_size;
67
u8 direct_color_mode_info;
69
u32 offscreen_mem_offset;
70
u16 offscreen_mem_size;
74
/****************************************************************
76
****************************************************************/
78
/****************************************************************
79
* VGA text / graphics console
80
****************************************************************/
81
static void enable_vga_text_console(void)
83
dprintf(1, "Turning on vga text mode console\n");
86
/* Enable VGA text mode */
87
memset(&br, 0, sizeof(br));
91
call16_int(0x10, &br);
94
if (CONFIG_BOOTSPLASH) {
95
/* Switch back to start of the framebuffer
96
* (disable "double buffering")
98
memset(&br, 0, sizeof(br));
105
call16_int(0x10, &br);
110
printf("Starting SeaBIOS (version %s)\n\n", VERSION);
113
void enable_vga_console(void)
115
/* Needs coreboot support for CBFS */
116
if (!CONFIG_BOOTSPLASH || !CONFIG_COREBOOT) {
117
enable_vga_text_console();
122
struct vesa_info *vesa_info;
123
struct vesa_mode_info *mode_info;
124
struct jpeg_decdata *decdata;
126
vesa_info = malloc_tmphigh(sizeof(*vesa_info));
127
mode_info = malloc_tmphigh(sizeof(*mode_info));
128
decdata = malloc_tmphigh(sizeof(*decdata));
130
/* Check whether we have a VESA 2.0 compliant BIOS */
131
memset(vesa_info, 0, sizeof(struct vesa_info));
132
memcpy(vesa_info, "VBE2", 4);
134
memset(&br, 0, sizeof(br));
137
br.di = FLATPTR_TO_OFFSET(vesa_info);
138
br.es = FLATPTR_TO_SEG(vesa_info);
140
call16_int(0x10, &br);
143
if(strcmp("VESA", (char *)vesa_info) != 0) {
144
dprintf(1,"No VBE2 found.\n");
148
/* Print some debugging information about our card. */
149
char *vendor, *product;
150
vendor = (char *)(((vesa_info->oem_vendor_name_ptr & 0xffff0000) >> 12) |
151
(vesa_info->oem_vendor_name_ptr & 0xffff));
153
product = (char *)(((vesa_info->oem_product_name_ptr & 0xffff0000) >> 12) |
154
(vesa_info->oem_product_name_ptr & 0xffff));
156
dprintf(8, "VESA %d.%d\nVENDOR: %s\nPRODUCT: %s\n",
157
vesa_info->vesa_version>>8,vesa_info->vesa_version&0xff,
160
/* Get information about our graphics mode, like the
161
* framebuffer start address
163
memset(&br, 0, sizeof(br));
166
br.cx = (1 << 14) | CONFIG_BOOTSPLASH_VESA_MODE;
167
br.di = FLATPTR_TO_OFFSET(mode_info);
168
br.es = FLATPTR_TO_SEG(mode_info);
170
call16_int(0x10, &br);
173
dprintf(1, "get_mode failed.\n");
174
enable_vga_text_console();
177
unsigned char *framebuffer = (unsigned char *) (mode_info->phys_base_ptr);
179
/* Switch to graphics mode */
180
memset(&br, 0, sizeof(br));
183
br.bx = (1 << 14) | CONFIG_BOOTSPLASH_VESA_MODE;
185
call16_int(0x10, &br);
188
dprintf(1, "set_mode failed.\n");
189
enable_vga_text_console();
193
/* Switching Intel IGD to 1MB video memory will break this. Who cares. */
194
int imagesize = CONFIG_BOOTSPLASH_X * CONFIG_BOOTSPLASH_Y *
195
(CONFIG_BOOTSPLASH_DEPTH / 8);
197
/* We use "double buffering" to make things look nicer */
198
framebuffer += imagesize;
200
dprintf(9, "framebuffer: %x\n", (u32)framebuffer);
201
dprintf(9, "bytes per scanline: %d\n", mode_info->bytes_per_scanline);
202
dprintf(9, "bits per pixel: %d\n", mode_info->bits_per_pixel);
204
/* Look for bootsplash.jpg in CBFS and decompress it... */
206
unsigned char *jpeg = NULL;
208
struct cbfs_file *file = cbfs_finddatafile("bootsplash.jpg");
212
filesize = cbfs_datasize(file);
213
jpeg = malloc_tmphigh(filesize);
215
dprintf(1, "Could not find boot splash screen \"bootsplash.jpg\"\n");
218
dprintf(9, "Copying boot splash screen...\n");
219
cbfs_copyfile(file, jpeg, filesize);
220
dprintf(9, "Decompressing boot splash screen...\n");
222
ret = jpeg_decode(jpeg, framebuffer, CONFIG_BOOTSPLASH_X,
223
CONFIG_BOOTSPLASH_Y, CONFIG_BOOTSPLASH_DEPTH, decdata);
226
dprintf(1, "Failed with return code %x...\n", ret);
232
enable_vga_text_console();
236
/* Show the picture */
237
memset(&br, 0, sizeof(br));
243
call16_int(0x10, &br);
246
dprintf(1, "display_start failed.\n");
247
enable_vga_text_console();
257
disable_bootsplash(void)
259
if (! CONFIG_BOOTSPLASH)
261
enable_vga_text_console();