rpi_fb_drv: avoid alignment fault by own blit func

Fix #4331
This commit is contained in:
Stefan Kalkowski 2022-01-11 14:02:14 +01:00 committed by Norman Feske
parent 4cb8c91b08
commit 7248957553
2 changed files with 25 additions and 5 deletions

View File

@ -22,10 +22,30 @@
#include <blit/blit.h>
#include <timer_session/connection.h>
namespace Framebuffer {
using namespace Genode;
struct Main;
};
namespace Framebuffer { struct Main; };
using namespace Genode;
/**
* The blit library is not free of potential mis-aligned pointer access,
* which is not a problem with normal memory. But the Rpi framebuffer driver
* uses ordered I/O memory as backend, where mis-aligned memory access is a problem.
* Therefore, we do not use the blit library here, but implement a simple
* blit function ourselves.
*/
extern "C" void blit(void const * s, unsigned src_w,
void * d, unsigned dst_w, int w, int h)
{
char const *src = (char const *)s;
char *dst = (char *)d;
if (w <= 0 || h <= 0) return;
for (; h--; src += (src_w-w), dst += (dst_w-w))
for (int i = (w >> 2); i--; src += 4, dst += 4)
*(uint32_t *)dst = *(uint32_t const *)src;
}
struct Framebuffer::Main

View File

@ -1,6 +1,6 @@
TARGET = rpi_fb_drv
REQUIRES = arm_v6
SRC_CC = main.cc
LIBS = base blit
LIBS = base
INC_DIR += $(PRG_DIR)
INC_DIR += $(call select_from_repositories,include/spec/rpi)