Skip to content

Commit a7fe284

Browse files
committed
nv41/nv51: add patch for efifb being able to drive libgfxinit/gop driven fb
Signed-off-by: Thierry Laurion <[email protected]>
1 parent 664603c commit a7fe284

File tree

1 file changed

+99
-0
lines changed

1 file changed

+99
-0
lines changed
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
From 295f6bf8d4bc93d1aedef218f14c8f20f101a1af Mon Sep 17 00:00:00 2001
2+
From: Nico Huber <[email protected]>
3+
Date: Fri, 14 Jul 2023 14:20:39 +0200
4+
Subject: [PATCH] linux_trampoline: Handle coreboot framebuffer
5+
6+
Translate the coreboot framebuffer info from coreboot tables to
7+
the Linux zero page.
8+
9+
Tested in QEMU/Q35 with a kernel w/ efifb enabled.
10+
11+
Change-Id: I2447b2366df8dd8ffe741c943de544d8b4d02dff
12+
Signed-off-by: Nico Huber <[email protected]>
13+
Co-authored-by: Bill XIE <[email protected]>
14+
Reviewed-on: https://review.coreboot.org/c/coreboot/+/76431
15+
Reviewed-by: Paul Menzel <[email protected]>
16+
Tested-by: build bot (Jenkins) <[email protected]>
17+
Reviewed-by: Tim Wawrzynczak <[email protected]>
18+
Reviewed-by: Samuel Holland <[email protected]>
19+
Reviewed-by: Bill XIE <[email protected]>
20+
---
21+
22+
diff --git a/util/cbfstool/linux_trampoline.S b/util/cbfstool/linux_trampoline.S
23+
index 767c8be..d36e60d 100644
24+
--- a/util/cbfstool/linux_trampoline.S
25+
+++ b/util/cbfstool/linux_trampoline.S
26+
@@ -102,7 +102,36 @@
27+
.testFramebuffer:
28+
cmp $CB_TAG_FRAMEBUFFER, (%ebx)
29+
jne .endScan
30+
-/* TODO: handle framebuffer tag */
31+
+
32+
+cmpl $0, 0x0c(%ebx) /* check if upper 32-bit of framebuffer address are 0 */
33+
+jne .endScan
34+
+
35+
+mov $LINUX_PARAM_LOC, %edi /* translate the framebuffer entry into Linux' struct screen_info */
36+
+mov 0x08(%ebx), %eax /* physical_address */
37+
+mov %eax, 0x18(%edi) /* -> lfb_base */
38+
+mov 0x10(%ebx), %eax /* x_resolution */
39+
+mov %ax, 0x12(%edi) /* -> lfb_width */
40+
+mov 0x14(%ebx), %eax /* y_resolution */
41+
+mov %ax, 0x14(%edi) /* -> lfb_height */
42+
+mov 0x18(%ebx), %edx /* bytes_per_line */
43+
+mov %dx, 0x24(%edi) /* -> lfb_linelength */
44+
+
45+
+mul %edx /* bytes_per_line * y_resolution */
46+
+mov %eax, 0x1c(%edi) /* -> lfb_size */
47+
+
48+
+movzbw 0x1c(%ebx), %ax /* bits_per_pixel */
49+
+mov %ax, 0x16(%edi) /* -> lfb_depth */
50+
+
51+
+mov $4, %esi /* Copy 4 color components' pos and size, each 1 byte. */
52+
+1:
53+
+mov 0x1b(%ebx, %esi, 2), %ax
54+
+rol %ax /* Order is reversed for Linux, hence swap. */
55+
+mov %ax, 0x24(%edi, %esi, 2)
56+
+dec %esi
57+
+jnz 1b
58+
+
59+
+#define LFB_EFI_SIMPLE 0x70 /* VIDEO_TYPE_EFI in Linux */
60+
+movb $LFB_EFI_SIMPLE, 0x0f(%edi) /* -> orig_video_isVGA */
61+
62+
.endScan:
63+
add 4(%ebx), %ebx
64+
diff --git a/util/cbfstool/linux_trampoline.c b/util/cbfstool/linux_trampoline.c
65+
index 46bb800..87c595a 100644
66+
--- a/util/cbfstool/linux_trampoline.c
67+
+++ b/util/cbfstool/linux_trampoline.c
68+
@@ -3,18 +3,23 @@
69+
unsigned char trampoline[] = {
70+
0xfc, 0x31, 0xd2, 0xb9, 0x00, 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x01, 0x00, 0x01, 0xcb, 0x8b,
71+
0x01, 0x3d, 0x4c, 0x42, 0x49, 0x4f, 0x74, 0x07, 0x83, 0xc1, 0x10, 0x39, 0xcb, 0x75, 0xe9, 0x39,
72+
- 0xcb, 0x0f, 0x84, 0xc5, 0x00, 0x00, 0x00, 0x8b, 0x59, 0x04, 0x01, 0xcb, 0x8b, 0x49, 0x14, 0x83,
73+
+ 0xcb, 0x0f, 0x84, 0x12, 0x01, 0x00, 0x00, 0x8b, 0x59, 0x04, 0x01, 0xcb, 0x8b, 0x49, 0x14, 0x83,
74+
0x3b, 0x11, 0x75, 0x05, 0x8b, 0x4b, 0x08, 0xeb, 0xcf, 0x83, 0x3b, 0x01, 0x75, 0x53, 0x8b, 0x43,
75+
0x04, 0x83, 0xe8, 0x08, 0xc1, 0xe8, 0x02, 0x3d, 0xa0, 0x00, 0x00, 0x00, 0x7e, 0x05, 0xb8, 0xa0,
76+
0x00, 0x00, 0x00, 0x89, 0xc6, 0xbf, 0x05, 0x00, 0x00, 0x00, 0xf7, 0xf7, 0xa3, 0xe8, 0x01, 0x09,
77+
0x00, 0x89, 0xf0, 0x91, 0x8d, 0x73, 0x08, 0xbf, 0xd0, 0x02, 0x09, 0x00, 0xf3, 0xa5, 0x91, 0xa1,
78+
- 0xe8, 0x01, 0x09, 0x00, 0xbf, 0xd0, 0x02, 0x09, 0x00, 0x83, 0xf8, 0x00, 0x74, 0x2f, 0x83, 0x7f,
79+
+ 0xe8, 0x01, 0x09, 0x00, 0xbf, 0xd0, 0x02, 0x09, 0x00, 0x83, 0xf8, 0x00, 0x74, 0x7c, 0x83, 0x7f,
80+
0x10, 0x0c, 0x7e, 0x07, 0xc7, 0x47, 0x10, 0x02, 0x00, 0x00, 0x00, 0x48, 0x83, 0xc7, 0x14, 0xeb,
81+
0xe8, 0x83, 0x3b, 0x43, 0x75, 0x12, 0x8b, 0x43, 0x08, 0xa3, 0x70, 0x00, 0x09, 0x00, 0x8b, 0x43,
82+
- 0x0c, 0xa3, 0x74, 0x00, 0x09, 0x00, 0xeb, 0x05, 0x83, 0x3b, 0x12, 0x75, 0x00, 0x03, 0x5b, 0x04,
83+
- 0x49, 0x0f, 0x85, 0x78, 0xff, 0xff, 0xff, 0xb8, 0x00, 0x00, 0x04, 0x00, 0xc7, 0x40, 0x10, 0xff,
84+
- 0xff, 0x00, 0x00, 0xc7, 0x40, 0x14, 0x00, 0x9b, 0xcf, 0x00, 0xc7, 0x40, 0x18, 0xff, 0xff, 0x00,
85+
- 0x00, 0xc7, 0x40, 0x1c, 0x00, 0x93, 0xcf, 0x00, 0xc6, 0x00, 0x2b, 0x89, 0x40, 0x02, 0x0f, 0x01,
86+
- 0x10, 0xbe, 0x00, 0x00, 0x09, 0x00, 0xff, 0x25, 0x14, 0x02, 0x09, 0x00, 0xf4, 0xeb, 0xfd
87+
+ 0x0c, 0xa3, 0x74, 0x00, 0x09, 0x00, 0xeb, 0x52, 0x83, 0x3b, 0x12, 0x75, 0x4d, 0x83, 0x7b, 0x0c,
88+
+ 0x00, 0x75, 0x47, 0xbf, 0x00, 0x00, 0x09, 0x00, 0x8b, 0x43, 0x08, 0x89, 0x47, 0x18, 0x8b, 0x43,
89+
+ 0x10, 0x66, 0x89, 0x47, 0x12, 0x8b, 0x43, 0x14, 0x66, 0x89, 0x47, 0x14, 0x8b, 0x53, 0x18, 0x66,
90+
+ 0x89, 0x57, 0x24, 0xf7, 0xe2, 0x89, 0x47, 0x1c, 0x66, 0x0f, 0xb6, 0x43, 0x1c, 0x66, 0x89, 0x47,
91+
+ 0x16, 0xbe, 0x04, 0x00, 0x00, 0x00, 0x66, 0x8b, 0x44, 0x73, 0x1b, 0x66, 0xd1, 0xc0, 0x66, 0x89,
92+
+ 0x44, 0x77, 0x24, 0x4e, 0x75, 0xf0, 0xc6, 0x47, 0x0f, 0x70, 0x03, 0x5b, 0x04, 0x49, 0x0f, 0x85,
93+
+ 0x2b, 0xff, 0xff, 0xff, 0xb8, 0x00, 0x00, 0x04, 0x00, 0xc7, 0x40, 0x10, 0xff, 0xff, 0x00, 0x00,
94+
+ 0xc7, 0x40, 0x14, 0x00, 0x9b, 0xcf, 0x00, 0xc7, 0x40, 0x18, 0xff, 0xff, 0x00, 0x00, 0xc7, 0x40,
95+
+ 0x1c, 0x00, 0x93, 0xcf, 0x00, 0xc6, 0x00, 0x2b, 0x89, 0x40, 0x02, 0x0f, 0x01, 0x10, 0xbe, 0x00,
96+
+ 0x00, 0x09, 0x00, 0xff, 0x25, 0x14, 0x02, 0x09, 0x00, 0xf4, 0xeb, 0xfd
97+
};
98+
-unsigned int trampoline_len = 239;
99+
+unsigned int trampoline_len = 316;

0 commit comments

Comments
 (0)