coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
graphics.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <boot/coreboot_tables.h>
4 #include <console/console.h>
5 #include <fsp/graphics.h>
6 #include <fsp/util.h>
7 #include <soc/intel/common/vbt.h>
8 #include <types.h>
9 #include <framebuffer_info.h>
10 
14  pixel_bitmask = 2, /* defined by <rgb>_mask values */
15 };
16 
17 static const uint8_t fsp_graphics_info_guid[16] = {
18  0xce, 0x2c, 0xf6, 0x39, 0x25, 0x68, 0x69, 0x46,
19  0xbb, 0x56, 0x54, 0x1a, 0xba, 0x75, 0x3a, 0x07
20 };
21 
28  uint32_t pixel_format; /* See enum pixel_format */
35 
36 struct pixel {
39 };
40 
41 static const struct fsp_framebuffer {
42  struct pixel red;
43  struct pixel green;
44  struct pixel blue;
45  struct pixel rsvd;
47  [pixel_rgbx_8bpc] = { {0, 8}, {8, 8}, {16, 8}, {24, 8} },
48  [pixel_bgrx_8bpc] = { {16, 8}, {8, 8}, {0, 8}, {24, 8} },
49 };
50 
51 
52 void fsp_report_framebuffer_info(const uintptr_t framebuffer_bar,
53  enum lb_fb_orientation orientation)
54 {
55  size_t size;
56  const struct hob_graphics_info *ginfo;
57  const struct fsp_framebuffer *fbinfo;
58 
59  /*
60  * Pci enumeration happens after silicon init.
61  * After enumeration graphic framebuffer base may be relocated.
62  */
63  if (!framebuffer_bar) {
64  printk(BIOS_ALERT, "Framebuffer BAR invalid\n");
65  return;
66  }
67 
69 
70  if (!ginfo) {
71  printk(BIOS_ALERT, "Graphics hand-off block not found\n");
72  return;
73  }
74 
76  printk(BIOS_ALERT, "FSP set unknown framebuffer format: %d\n",
77  ginfo->pixel_format);
78  return;
79  }
80 
81  fbinfo = fsp_framebuffer_format_map + ginfo->pixel_format;
82 
83  const struct lb_framebuffer fb = {
84  .physical_address = framebuffer_bar,
85  .x_resolution = ginfo->horizontal_resolution,
86  .y_resolution = ginfo->vertical_resolution,
87  .bytes_per_line = ginfo->pixels_per_scanline * 4,
88  .bits_per_pixel = fbinfo->rsvd.size + fbinfo->red.size +
89  fbinfo->green.size + fbinfo->blue.size,
90  .red_mask_pos = fbinfo->red.pos,
91  .red_mask_size = fbinfo->red.size,
92  .green_mask_pos = fbinfo->green.pos,
93  .green_mask_size = fbinfo->green.size,
94  .blue_mask_pos = fbinfo->blue.pos,
95  .blue_mask_size = fbinfo->blue.size,
96  .reserved_mask_pos = fbinfo->rsvd.pos,
97  .reserved_mask_size = fbinfo->rsvd.size,
98  .orientation = orientation,
99  };
100 
102 }
#define ARRAY_SIZE(a)
Definition: helpers.h:12
lb_fb_orientation
coreboot framebuffer
#define printk(level,...)
Definition: stdlib.h:16
static const struct fsp_framebuffer fsp_framebuffer_format_map[]
pixel_format
Definition: graphics.c:11
@ pixel_bgrx_8bpc
Definition: graphics.c:13
@ pixel_rgbx_8bpc
Definition: graphics.c:12
@ pixel_bitmask
Definition: graphics.c:14
static const uint8_t fsp_graphics_info_guid[16]
Definition: graphics.c:17
void fsp_report_framebuffer_info(const uintptr_t framebuffer_bar, enum lb_fb_orientation orientation)
Definition: graphics.c:52
struct hob_graphics_info __packed
struct fb_info * fb_add_framebuffer_info_ex(const struct lb_framebuffer *fb)
Definition: edid_fill_fb.c:36
const void * fsp_find_extension_hob_by_guid(const uint8_t *guid, size_t *size)
#define BIOS_ALERT
BIOS_ALERT - Dying / Unrecoverable.
Definition: loglevel.h:41
unsigned int uint32_t
Definition: stdint.h:14
unsigned long uintptr_t
Definition: stdint.h:21
unsigned long long uint64_t
Definition: stdint.h:17
unsigned char uint8_t
Definition: stdint.h:8
struct pixel green
Definition: graphics.c:43
struct pixel rsvd
Definition: graphics.c:45
struct pixel blue
Definition: graphics.c:44
struct pixel red
Definition: graphics.c:42
uint64_t framebuffer_base
Definition: graphics.c:23
uint32_t blue_mask
Definition: graphics.c:31
uint32_t green_mask
Definition: graphics.c:30
uint32_t version
Definition: graphics.c:25
uint32_t red_mask
Definition: graphics.c:29
uint32_t pixel_format
Definition: graphics.c:28
uint32_t pixels_per_scanline
Definition: graphics.c:33
uint32_t vertical_resolution
Definition: graphics.c:27
uint32_t reserved_mask
Definition: graphics.c:32
uint32_t horizontal_resolution
Definition: graphics.c:26
uint32_t framebuffer_size
Definition: graphics.c:24
lb_uint64_t physical_address
Definition: graphics.c:36
uint8_t pos
Definition: graphics.c:37
uint8_t size
Definition: graphics.c:38