coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
bootsplash.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <cbfs.h>
4 #include <vbe.h>
5 #include <console/console.h>
6 #include <endian.h>
7 #include <bootsplash.h>
8 #include <stdlib.h>
9 
10 #include "jpeg.h"
11 
12 
13 void set_bootsplash(unsigned char *framebuffer, unsigned int x_resolution,
14  unsigned int y_resolution, unsigned int fb_resolution)
15 {
16  printk(BIOS_INFO, "Setting up bootsplash in %dx%d@%d\n", x_resolution, y_resolution,
17  fb_resolution);
18  struct jpeg_decdata *decdata;
19  unsigned char *jpeg = cbfs_map("bootsplash.jpg", NULL);
20  if (!jpeg) {
21  printk(BIOS_ERR, "Could not find bootsplash.jpg\n");
22  return;
23  }
24 
25  int image_width, image_height;
26  jpeg_fetch_size(jpeg, &image_width, &image_height);
27 
28  printk(BIOS_DEBUG, "Bootsplash image resolution: %dx%d\n", image_width, image_height);
29 
30  decdata = malloc(sizeof(*decdata));
31  int ret = jpeg_decode(jpeg, framebuffer, x_resolution, y_resolution, fb_resolution,
32  decdata);
33  cbfs_unmap(jpeg);
34  if (ret != 0) {
35  printk(BIOS_ERR, "Bootsplash could not be decoded. jpeg_decode returned %d.\n",
36  ret);
37  return;
38  }
39  printk(BIOS_INFO, "Bootsplash loaded\n");
40 }
void set_bootsplash(unsigned char *framebuffer, unsigned int x_resolution, unsigned int y_resolution, unsigned int fb_resolution)
Sets up the framebuffer with the bootsplash.jpg from cbfs.
Definition: bootsplash.c:13
void cbfs_unmap(void *mapping)
Definition: cbfs.c:86
static void * cbfs_map(const char *name, size_t *size_out)
Definition: cbfs.h:246
#define printk(level,...)
Definition: stdlib.h:16
void * malloc(size_t size)
Definition: malloc.c:53
void jpeg_fetch_size(unsigned char *buf, int *width, int *height)
Definition: jpeg.c:244
int jpeg_decode(unsigned char *buf, unsigned char *pic, int width, int height, int depth, struct jpeg_decdata *decdata)
Definition: jpeg.c:269
#define BIOS_INFO
BIOS_INFO - Expected events.
Definition: loglevel.h:113
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define BIOS_ERR
BIOS_ERR - System in incomplete state.
Definition: loglevel.h:72
#define NULL
Definition: stddef.h:19