* [U-Boot] [PATCH 1/1] efi_loader: correctly support parameter delta in Blt
@ 2018-03-14 18:57 Heinrich Schuchardt
2018-03-15 10:19 ` Alexander Graf
0 siblings, 1 reply; 3+ messages in thread
From: Heinrich Schuchardt @ 2018-03-14 18:57 UTC (permalink / raw)
To: u-boot
In the Blt service of the EFI_GRAPHICS_OUTPUT_PROTOCOL the parameter delta
is measured in bytes and not in pixels.
The coding only supports delta being a multiple of four. The UEFI
specification does not explicitly require this but as pixels have a size of
four bytes we should be able to assume four byte alignment.
The corresponding unit test is corrected, too. It can be launched with
setenv efi_selftest block image transfer
bootefi selftest
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
lib/efi_loader/efi_gop.c | 32 +++++++++++++++++++++++++++-----
lib/efi_selftest/efi_selftest_bitblt.c | 4 ++--
2 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/lib/efi_loader/efi_gop.c b/lib/efi_loader/efi_gop.c
index 154f306540..ac92109f16 100644
--- a/lib/efi_loader/efi_gop.c
+++ b/lib/efi_loader/efi_gop.c
@@ -77,6 +77,24 @@ static inline u16 efi_blt_col_to_vid16(struct efi_gop_pixel *blt)
(u16)(blt->blue >> 3);
}
+/*
+ * Copy rectangle.
+ *
+ * This function implements the Blt service of the EFI_GRAPHICS_OUTPUT_PROTOCOL.
+ * See the Unified Extensible Firmware Interface (UEFI) specification for
+ * details.
+ *
+ * @this: EFI_GRAPHICS_OUTPUT_PROTOCOL
+ * @buffer: pixel buffer
+ * @sx: source x-coordinate
+ * @sy: source y-coordinate
+ * @dx: destination x-coordinate
+ * @dy: destination y-coordinate
+ * @width: width of rectangle
+ * @height: height of rectangle
+ * @delta: length in bytes of a line in the pixel buffer (optional)
+ * @return: status code
+ */
efi_status_t EFIAPI gop_blt(struct efi_gop *this, struct efi_gop_pixel *buffer,
u32 operation, efi_uintn_t sx,
efi_uintn_t sy, efi_uintn_t dx,
@@ -88,14 +106,18 @@ efi_status_t EFIAPI gop_blt(struct efi_gop *this, struct efi_gop_pixel *buffer,
u32 *fb32 = gopobj->fb;
u16 *fb16 = gopobj->fb;
- if (delta)
- linelen = delta;
- else
- linelen = width;
-
EFI_ENTRY("%p, %p, %u, %zu, %zu, %zu, %zu, %zu, %zu, %zu", this,
buffer, operation, sx, sy, dx, dy, width, height, delta);
+ if (delta) {
+ /* Check for 4 byte alignment */
+ if (delta & 3)
+ return EFI_EXIT(EFI_INVALID_PARAMETER);
+ linelen = delta >> 2;
+ } else {
+ linelen = width;
+ }
+
/* Check source rectangle */
switch (operation) {
case EFI_BLT_VIDEO_FILL:
diff --git a/lib/efi_selftest/efi_selftest_bitblt.c b/lib/efi_selftest/efi_selftest_bitblt.c
index 53cc633acc..0fb76cc727 100644
--- a/lib/efi_selftest/efi_selftest_bitblt.c
+++ b/lib/efi_selftest/efi_selftest_bitblt.c
@@ -87,7 +87,7 @@ static void EFIAPI notify(struct efi_event *event, void *context)
/* Copy image to video */
gop->blt(gop, bitmap, EFI_BLT_BUFFER_TO_VIDEO, sx, 0, dx, DEPTH,
- width, HEIGHT, WIDTH);
+ width, HEIGHT, WIDTH * sizeof(struct efi_gop_pixel));
}
/*
@@ -276,7 +276,7 @@ static int execute(void)
/* Copy port holes back to buffer */
ret = gop->blt(gop, bitmap, EFI_BLT_VIDEO_TO_BLT_BUFFER,
94, 57 + DEPTH, 94, 57,
- 90, 26, WIDTH);
+ 90, 26, WIDTH * sizeof(struct efi_gop_pixel));
if (ret != EFI_SUCCESS) {
efi_st_error("EFI_BLT_VIDEO_TO_BLT_BUFFER failed\n");
return EFI_ST_FAILURE;
--
2.14.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH 1/1] efi_loader: correctly support parameter delta in Blt
2018-03-14 18:57 [U-Boot] [PATCH 1/1] efi_loader: correctly support parameter delta in Blt Heinrich Schuchardt
@ 2018-03-15 10:19 ` Alexander Graf
2018-03-15 17:14 ` Ivan Gorinov
0 siblings, 1 reply; 3+ messages in thread
From: Alexander Graf @ 2018-03-15 10:19 UTC (permalink / raw)
To: u-boot
On 03/14/2018 07:57 PM, Heinrich Schuchardt wrote:
> In the Blt service of the EFI_GRAPHICS_OUTPUT_PROTOCOL the parameter delta
> is measured in bytes and not in pixels.
>
> The coding only supports delta being a multiple of four. The UEFI
> specification does not explicitly require this but as pixels have a size of
> four bytes we should be able to assume four byte alignment.
>
> The corresponding unit test is corrected, too. It can be launched with
>
> setenv efi_selftest block image transfer
> bootefi selftest
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
I can verify that this makes grub GOP work again :)
Alex
^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] [PATCH 1/1] efi_loader: correctly support parameter delta in Blt
2018-03-15 10:19 ` Alexander Graf
@ 2018-03-15 17:14 ` Ivan Gorinov
0 siblings, 0 replies; 3+ messages in thread
From: Ivan Gorinov @ 2018-03-15 17:14 UTC (permalink / raw)
To: u-boot
On Thu, 2018-03-15 at 11:19 +0100, Alexander Graf wrote:
> In the Blt service of the EFI_GRAPHICS_OUTPUT_PROTOCOL the parameter delta
> > is measured in bytes and not in pixels.
> >
> > The coding only supports delta being a multiple of four. The UEFI
> > specification does not explicitly require this but as pixels have a size of
> > four bytes we should be able to assume four byte alignment.
> >
> > The corresponding unit test is corrected, too. It can be launched with
> >
> > setenv efi_selftest block image transfer
> > bootefi selftest
> >
> > Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> I can verify that this makes grub GOP work again :)
Kernelflinger works too.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-03-15 17:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-03-14 18:57 [U-Boot] [PATCH 1/1] efi_loader: correctly support parameter delta in Blt Heinrich Schuchardt
2018-03-15 10:19 ` Alexander Graf
2018-03-15 17:14 ` Ivan Gorinov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox