linux_trampoline: Handle coreboot framebuffer

Translate the coreboot framebuffer info from coreboot tables to
the Linux zero page.

Tested in QEMU/Q35 with a kernel w/ efifb enabled.

Change-Id: I2447b2366df8dd8ffe741c943de544d8b4d02dff
Signed-off-by: Nico Huber <nico.h@gmx.de>
Co-authored-by: Bill XIE <persmule@hardenedlinux.org>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/76431
Reviewed-by: Paul Menzel <paulepanter@mailbox.org>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Tim Wawrzynczak <inforichland@gmail.com>
Reviewed-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Bill XIE <persmule@hardenedlinux.org>
This commit is contained in:
Nico Huber
2023-07-14 14:20:39 +02:00
committed by Felix Held
parent d1b8589583
commit 295f6bf8d4
2 changed files with 43 additions and 9 deletions

View File

@ -102,7 +102,36 @@ jmp .endScan
.testFramebuffer:
cmp $CB_TAG_FRAMEBUFFER, (%ebx)
jne .endScan
/* TODO: handle framebuffer tag */
cmpl $0, 0x0c(%ebx) /* check if upper 32-bit of framebuffer address are 0 */
jne .endScan
mov $LINUX_PARAM_LOC, %edi /* translate the framebuffer entry into Linux' struct screen_info */
mov 0x08(%ebx), %eax /* physical_address */
mov %eax, 0x18(%edi) /* -> lfb_base */
mov 0x10(%ebx), %eax /* x_resolution */
mov %ax, 0x12(%edi) /* -> lfb_width */
mov 0x14(%ebx), %eax /* y_resolution */
mov %ax, 0x14(%edi) /* -> lfb_height */
mov 0x18(%ebx), %edx /* bytes_per_line */
mov %dx, 0x24(%edi) /* -> lfb_linelength */
mul %edx /* bytes_per_line * y_resolution */
mov %eax, 0x1c(%edi) /* -> lfb_size */
movzbw 0x1c(%ebx), %ax /* bits_per_pixel */
mov %ax, 0x16(%edi) /* -> lfb_depth */
mov $4, %esi /* Copy 4 color components' pos and size, each 1 byte. */
1:
mov 0x1b(%ebx, %esi, 2), %ax
rol %ax /* Order is reversed for Linux, hence swap. */
mov %ax, 0x24(%edi, %esi, 2)
dec %esi
jnz 1b
#define LFB_EFI_SIMPLE 0x70 /* VIDEO_TYPE_EFI in Linux */
movb $LFB_EFI_SIMPLE, 0x0f(%edi) /* -> orig_video_isVGA */
.endScan:
add 4(%ebx), %ebx