summaryrefslogtreecommitdiff
path: root/payloads/libpayload/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'payloads/libpayload/drivers')
-rw-r--r--payloads/libpayload/drivers/video/corebootfb.c9
-rw-r--r--payloads/libpayload/drivers/video/graphics.c17
2 files changed, 11 insertions, 15 deletions
diff --git a/payloads/libpayload/drivers/video/corebootfb.c b/payloads/libpayload/drivers/video/corebootfb.c
index c21665d0c0..1865ad37bf 100644
--- a/payloads/libpayload/drivers/video/corebootfb.c
+++ b/payloads/libpayload/drivers/video/corebootfb.c
@@ -60,7 +60,7 @@ static const u32 vga_colors[] = {
(0xFF << 16) | (0xFF << 8) | 0xFF,
};
-struct cb_framebuffer fbinfo;
+static struct cb_framebuffer fbinfo;
static unsigned short *chars;
/* Shorthand for up-to-date virtual framebuffer address */
@@ -223,13 +223,10 @@ static void corebootfb_set_cursor(unsigned int x, unsigned int y)
static int corebootfb_init(void)
{
- if (lib_sysinfo.framebuffer == NULL)
+ if (!lib_sysinfo.framebuffer.physical_address)
return -1;
- fbinfo = *lib_sysinfo.framebuffer;
-
- if (fbinfo.physical_address == 0)
- return -1;
+ fbinfo = lib_sysinfo.framebuffer;
font_init(fbinfo.x_resolution);
diff --git a/payloads/libpayload/drivers/video/graphics.c b/payloads/libpayload/drivers/video/graphics.c
index 21f520c290..2d2ea030ba 100644
--- a/payloads/libpayload/drivers/video/graphics.c
+++ b/payloads/libpayload/drivers/video/graphics.c
@@ -45,8 +45,10 @@ static struct rect screen;
* Framebuffer is assumed to assign a higher coordinate (larger x, y) to
* a higher address
*/
-static struct cb_framebuffer *fbinfo;
-static uint8_t *fbaddr;
+static const struct cb_framebuffer *fbinfo;
+
+/* Shorthand for up-to-date virtual framebuffer address */
+#define FB ((unsigned char *)phys_to_virt(fbinfo->physical_address))
#define LOG(x...) printf("CBGFX: " x)
#define PIVOT_H_MASK (PIVOT_H_LEFT|PIVOT_H_CENTER|PIVOT_H_RIGHT)
@@ -296,7 +298,7 @@ static inline void set_pixel(struct vector *coord, uint32_t color)
break;
}
- uint8_t * const pixel = fbaddr + rcoord.y * bpl + rcoord.x * bpp / 8;
+ uint8_t * const pixel = FB + rcoord.y * bpl + rcoord.x * bpp / 8;
for (i = 0; i < bpp / 8; i++)
pixel[i] = (color >> (i * 8));
}
@@ -310,12 +312,9 @@ static int cbgfx_init(void)
if (initialized)
return 0;
- fbinfo = lib_sysinfo.framebuffer;
- if (!fbinfo)
- return CBGFX_ERROR_FRAMEBUFFER_INFO;
+ fbinfo = &lib_sysinfo.framebuffer;
- fbaddr = phys_to_virt((uint8_t *)(uintptr_t)(fbinfo->physical_address));
- if (!fbaddr)
+ if (!fbinfo->physical_address)
return CBGFX_ERROR_FRAMEBUFFER_ADDR;
switch (fbinfo->orientation) {
@@ -627,7 +626,7 @@ int clear_screen(const struct rgb_color *rgb)
* We assume that for 32bpp the high byte gets ignored anyway. */
if ((((color >> 8) & 0xff) == (color & 0xff)) && (bpp == 16 ||
(((color >> 16) & 0xff) == (color & 0xff)))) {
- memset(fbaddr, color & 0xff, fbinfo->y_resolution * bpl);
+ memset(FB, color & 0xff, fbinfo->y_resolution * bpl);
} else {
for (p.y = 0; p.y < screen.size.height; p.y++)
for (p.x = 0; p.x < screen.size.width; p.x++)