@reallroboto/qbbox 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Brewfile +14 -0
- package/firmware/LICENSE +51 -0
- package/firmware/QemuRamfb.c +564 -0
- package/firmware/QemuRamfbDxe.inf +51 -0
- package/firmware/edk2.config +37 -0
- package/golden/SetupComplete.cmd +10 -0
- package/golden/autounattend.xml +97 -0
- package/golden/setup.ps1 +59 -0
- package/guest/install-qbd.ps1 +34 -0
- package/guest/unpack-sdk.ps1 +14 -0
- package/guest/windows-update.ps1 +38 -0
- package/package.json +29 -4
- package/qbbox +427 -0
- package/qemu/0001-ui-60fps-display-refresh.patch +35 -0
- package/README.md +0 -3
package/Brewfile
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
# qbbox build tools and the QEMU runtime: `qbbox` installs what is missing (brew bundle).
|
|
2
|
+
brew "qemu" # keymaps and edk2 vars (-L), qemu-img
|
|
3
|
+
brew "llvm" # firmware: clang
|
|
4
|
+
brew "lld" # firmware: ld.lld
|
|
5
|
+
brew "acpica" # firmware: iasl
|
|
6
|
+
brew "ninja" # qemu build
|
|
7
|
+
brew "pkgconf" # qemu build
|
|
8
|
+
brew "python@3.14" # qemu configure needs Python >= 3.11
|
|
9
|
+
brew "glib" # qemu runtime
|
|
10
|
+
brew "pixman" # qemu runtime
|
|
11
|
+
brew "libslirp" # qemu runtime: user network
|
|
12
|
+
brew "nettle" # qemu runtime: VNC password
|
|
13
|
+
brew "dtc" # qemu runtime: device tree
|
|
14
|
+
brew "wimlib" # golden: split install.wim
|
package/firmware/LICENSE
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
Copyright (c) 2019, TianoCore and contributors. All rights reserved.
|
|
2
|
+
|
|
3
|
+
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice,
|
|
9
|
+
this list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
Subject to the terms and conditions of this license, each copyright holder
|
|
16
|
+
and contributor hereby grants to those receiving rights under this license
|
|
17
|
+
a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
18
|
+
(except for failure to satisfy the conditions of this license) patent
|
|
19
|
+
license to make, have made, use, offer to sell, sell, import, and otherwise
|
|
20
|
+
transfer this software, where such license applies only to those patent
|
|
21
|
+
claims, already acquired or hereafter acquired, licensable by such copyright
|
|
22
|
+
holder or contributor that are necessarily infringed by:
|
|
23
|
+
|
|
24
|
+
(a) their Contribution(s) (the licensed copyrights of copyright holders and
|
|
25
|
+
non-copyrightable additions of contributors, in source or binary form)
|
|
26
|
+
alone; or
|
|
27
|
+
|
|
28
|
+
(b) combination of their Contribution(s) with the work of authorship to
|
|
29
|
+
which such Contribution(s) was added by such copyright holder or
|
|
30
|
+
contributor, if, at the time the Contribution is added, such addition
|
|
31
|
+
causes such combination to be necessarily infringed. The patent license
|
|
32
|
+
shall not apply to any other combinations which include the
|
|
33
|
+
Contribution.
|
|
34
|
+
|
|
35
|
+
Except as expressly stated above, no rights or licenses from any copyright
|
|
36
|
+
holder or contributor is granted under this license, whether expressly, by
|
|
37
|
+
implication, estoppel or otherwise.
|
|
38
|
+
|
|
39
|
+
DISCLAIMER
|
|
40
|
+
|
|
41
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
42
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
43
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
44
|
+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
|
|
45
|
+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
46
|
+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
47
|
+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
48
|
+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
49
|
+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
50
|
+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
51
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
@@ -0,0 +1,564 @@
|
|
|
1
|
+
/** @file
|
|
2
|
+
This driver is a implementation of the Graphics Output Protocol
|
|
3
|
+
for the QEMU ramfb device.
|
|
4
|
+
|
|
5
|
+
Copyright (c) 2018, Red Hat Inc.
|
|
6
|
+
|
|
7
|
+
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
8
|
+
|
|
9
|
+
**/
|
|
10
|
+
|
|
11
|
+
#include <Protocol/GraphicsOutput.h>
|
|
12
|
+
|
|
13
|
+
#include <Library/BaseLib.h>
|
|
14
|
+
#include <Library/BaseMemoryLib.h>
|
|
15
|
+
#include <Library/DebugLib.h>
|
|
16
|
+
#include <Library/DevicePathLib.h>
|
|
17
|
+
#include <Library/FrameBufferBltLib.h>
|
|
18
|
+
#include <Library/MemoryAllocationLib.h>
|
|
19
|
+
#include <Library/PcdLib.h>
|
|
20
|
+
#include <Library/UefiBootServicesTableLib.h>
|
|
21
|
+
#include <Library/QemuFwCfgLib.h>
|
|
22
|
+
|
|
23
|
+
#include <Guid/QemuRamfb.h>
|
|
24
|
+
|
|
25
|
+
#define RAMFB_FORMAT 0x34325258 /* DRM_FORMAT_XRGB8888 */
|
|
26
|
+
#define RAMFB_BPP 4
|
|
27
|
+
|
|
28
|
+
#pragma pack (1)
|
|
29
|
+
typedef struct RAMFB_CONFIG {
|
|
30
|
+
UINT64 Address;
|
|
31
|
+
UINT32 FourCC;
|
|
32
|
+
UINT32 Flags;
|
|
33
|
+
UINT32 Width;
|
|
34
|
+
UINT32 Height;
|
|
35
|
+
UINT32 Stride;
|
|
36
|
+
} RAMFB_CONFIG;
|
|
37
|
+
#pragma pack ()
|
|
38
|
+
|
|
39
|
+
STATIC EFI_HANDLE mRamfbHandle;
|
|
40
|
+
STATIC EFI_HANDLE mGopHandle;
|
|
41
|
+
STATIC FRAME_BUFFER_CONFIGURE *mQemuRamfbFrameBufferBltConfigure;
|
|
42
|
+
STATIC UINTN mQemuRamfbFrameBufferBltConfigureSize;
|
|
43
|
+
STATIC FIRMWARE_CONFIG_ITEM mRamfbFwCfgItem;
|
|
44
|
+
|
|
45
|
+
//
|
|
46
|
+
// SiliconWin: the stock driver only offers 640x480, 800x600 and 1024x768.
|
|
47
|
+
// Windows on Arm has no ramfb driver of its own and keeps whatever GOP mode
|
|
48
|
+
// the firmware picked, so offer the usual desktop/laptop resolutions as well.
|
|
49
|
+
// One extra slot at the end holds a custom resolution requested by the host
|
|
50
|
+
// through the "opt/siliconwin/resolution" fw_cfg file (e.g. "1920x1080").
|
|
51
|
+
//
|
|
52
|
+
#define RAMFB_PREFERRED_FWCFG_FILE "opt/siliconwin/resolution"
|
|
53
|
+
#define RAMFB_DEFAULT_MODE 1 // 800 x 600, as before
|
|
54
|
+
#define RAMFB_MAX_WIDTH 5120
|
|
55
|
+
#define RAMFB_MAX_HEIGHT 2880
|
|
56
|
+
#define RAMFB_STANDARD_MODE_COUNT 18
|
|
57
|
+
|
|
58
|
+
STATIC EFI_GRAPHICS_OUTPUT_MODE_INFORMATION mQemuRamfbModeInfo[RAMFB_STANDARD_MODE_COUNT + 1] = {
|
|
59
|
+
{ 0, 640, 480 },
|
|
60
|
+
{ 0, 800, 600 },
|
|
61
|
+
{ 0, 1024, 768 },
|
|
62
|
+
{ 0, 1280, 720 },
|
|
63
|
+
{ 0, 1280, 800 },
|
|
64
|
+
{ 0, 1280, 1024 },
|
|
65
|
+
{ 0, 1366, 768 },
|
|
66
|
+
{ 0, 1440, 900 },
|
|
67
|
+
{ 0, 1600, 900 },
|
|
68
|
+
{ 0, 1600, 1200 },
|
|
69
|
+
{ 0, 1680, 1050 },
|
|
70
|
+
{ 0, 1920, 1080 },
|
|
71
|
+
{ 0, 1920, 1200 },
|
|
72
|
+
{ 0, 2048, 1152 },
|
|
73
|
+
{ 0, 2560, 1440 },
|
|
74
|
+
{ 0, 2560, 1600 },
|
|
75
|
+
{ 0, 2880, 1800 },
|
|
76
|
+
{ 0, 3840, 2160 },
|
|
77
|
+
{ 0, 0, 0 } // custom resolution from the host, if any
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
STATIC EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE mQemuRamfbMode = {
|
|
81
|
+
RAMFB_STANDARD_MODE_COUNT, // MaxMode
|
|
82
|
+
0, // Mode
|
|
83
|
+
mQemuRamfbModeInfo, // Info
|
|
84
|
+
sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION), // SizeOfInfo
|
|
85
|
+
};
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
Parse "<width>x<height>" (decimal) into its two numbers.
|
|
89
|
+
|
|
90
|
+
@retval TRUE The string held a resolution within the supported limits.
|
|
91
|
+
**/
|
|
92
|
+
STATIC
|
|
93
|
+
BOOLEAN
|
|
94
|
+
QemuRamfbParseResolution (
|
|
95
|
+
IN CONST CHAR8 *String,
|
|
96
|
+
OUT UINT32 *Width,
|
|
97
|
+
OUT UINT32 *Height
|
|
98
|
+
)
|
|
99
|
+
{
|
|
100
|
+
UINT32 Value[2];
|
|
101
|
+
UINTN Part;
|
|
102
|
+
|
|
103
|
+
Value[0] = 0;
|
|
104
|
+
Value[1] = 0;
|
|
105
|
+
Part = 0;
|
|
106
|
+
|
|
107
|
+
for ( ; *String != '\0'; String++) {
|
|
108
|
+
if ((*String >= '0') && (*String <= '9')) {
|
|
109
|
+
if (Value[Part] > 100000) {
|
|
110
|
+
return FALSE;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
Value[Part] = Value[Part] * 10 + (UINT32)(*String - '0');
|
|
114
|
+
} else if (((*String == 'x') || (*String == 'X')) && (Part == 0)) {
|
|
115
|
+
Part = 1;
|
|
116
|
+
} else if ((*String == '\n') || (*String == '\r') || (*String == ' ')) {
|
|
117
|
+
break;
|
|
118
|
+
} else {
|
|
119
|
+
return FALSE;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
if ((Part != 1) || (Value[0] < 640) || (Value[1] < 480) ||
|
|
124
|
+
(Value[0] > RAMFB_MAX_WIDTH) || (Value[1] > RAMFB_MAX_HEIGHT))
|
|
125
|
+
{
|
|
126
|
+
return FALSE;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
*Width = Value[0];
|
|
130
|
+
*Height = Value[1];
|
|
131
|
+
return TRUE;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
Return the GOP mode to start in: the resolution requested by the host via
|
|
136
|
+
fw_cfg (added as a custom mode when it is not a standard one), or the
|
|
137
|
+
historical 800x600 default.
|
|
138
|
+
**/
|
|
139
|
+
STATIC
|
|
140
|
+
UINT32
|
|
141
|
+
QemuRamfbPreferredMode (
|
|
142
|
+
VOID
|
|
143
|
+
)
|
|
144
|
+
{
|
|
145
|
+
FIRMWARE_CONFIG_ITEM Item;
|
|
146
|
+
UINTN Size;
|
|
147
|
+
CHAR8 Buffer[32];
|
|
148
|
+
UINT32 Width;
|
|
149
|
+
UINT32 Height;
|
|
150
|
+
UINT32 Index;
|
|
151
|
+
|
|
152
|
+
if (EFI_ERROR (QemuFwCfgFindFile (RAMFB_PREFERRED_FWCFG_FILE, &Item, &Size)) ||
|
|
153
|
+
(Size == 0) || (Size >= sizeof (Buffer)))
|
|
154
|
+
{
|
|
155
|
+
return RAMFB_DEFAULT_MODE;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
QemuFwCfgSelectItem (Item);
|
|
159
|
+
QemuFwCfgReadBytes (Size, Buffer);
|
|
160
|
+
Buffer[Size] = '\0';
|
|
161
|
+
|
|
162
|
+
if (!QemuRamfbParseResolution (Buffer, &Width, &Height)) {
|
|
163
|
+
DEBUG ((DEBUG_ERROR, "Ramfb: ignoring invalid resolution \"%a\"\n", Buffer));
|
|
164
|
+
return RAMFB_DEFAULT_MODE;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
//
|
|
168
|
+
// GraphicsConsoleDxe switches to PcdVideo*Resolution when it starts (and
|
|
169
|
+
// the OS loader inherits that mode), so make it pick the requested one.
|
|
170
|
+
//
|
|
171
|
+
(VOID)PcdSet32S (PcdVideoHorizontalResolution, Width);
|
|
172
|
+
(VOID)PcdSet32S (PcdVideoVerticalResolution, Height);
|
|
173
|
+
|
|
174
|
+
for (Index = 0; Index < RAMFB_STANDARD_MODE_COUNT; Index++) {
|
|
175
|
+
if ((mQemuRamfbModeInfo[Index].HorizontalResolution == Width) &&
|
|
176
|
+
(mQemuRamfbModeInfo[Index].VerticalResolution == Height))
|
|
177
|
+
{
|
|
178
|
+
return Index;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
mQemuRamfbModeInfo[RAMFB_STANDARD_MODE_COUNT].HorizontalResolution = Width;
|
|
183
|
+
mQemuRamfbModeInfo[RAMFB_STANDARD_MODE_COUNT].VerticalResolution = Height;
|
|
184
|
+
mQemuRamfbMode.MaxMode = RAMFB_STANDARD_MODE_COUNT + 1;
|
|
185
|
+
return RAMFB_STANDARD_MODE_COUNT;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
STATIC
|
|
189
|
+
EFI_STATUS
|
|
190
|
+
EFIAPI
|
|
191
|
+
QemuRamfbGraphicsOutputQueryMode (
|
|
192
|
+
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
|
|
193
|
+
IN UINT32 ModeNumber,
|
|
194
|
+
OUT UINTN *SizeOfInfo,
|
|
195
|
+
OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
|
|
196
|
+
)
|
|
197
|
+
{
|
|
198
|
+
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *ModeInfo;
|
|
199
|
+
|
|
200
|
+
if ((Info == NULL) || (SizeOfInfo == NULL) ||
|
|
201
|
+
(ModeNumber >= mQemuRamfbMode.MaxMode))
|
|
202
|
+
{
|
|
203
|
+
return EFI_INVALID_PARAMETER;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
ModeInfo = &mQemuRamfbModeInfo[ModeNumber];
|
|
207
|
+
|
|
208
|
+
*Info = AllocateCopyPool (
|
|
209
|
+
sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION),
|
|
210
|
+
ModeInfo
|
|
211
|
+
);
|
|
212
|
+
if (*Info == NULL) {
|
|
213
|
+
return EFI_OUT_OF_RESOURCES;
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
*SizeOfInfo = sizeof (EFI_GRAPHICS_OUTPUT_MODE_INFORMATION);
|
|
217
|
+
|
|
218
|
+
return EFI_SUCCESS;
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
STATIC
|
|
222
|
+
EFI_STATUS
|
|
223
|
+
EFIAPI
|
|
224
|
+
QemuRamfbGraphicsOutputSetMode (
|
|
225
|
+
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
|
|
226
|
+
IN UINT32 ModeNumber
|
|
227
|
+
)
|
|
228
|
+
{
|
|
229
|
+
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *ModeInfo;
|
|
230
|
+
RAMFB_CONFIG Config;
|
|
231
|
+
EFI_GRAPHICS_OUTPUT_BLT_PIXEL Black;
|
|
232
|
+
RETURN_STATUS Status;
|
|
233
|
+
|
|
234
|
+
if (ModeNumber >= mQemuRamfbMode.MaxMode) {
|
|
235
|
+
return EFI_UNSUPPORTED;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
ModeInfo = &mQemuRamfbModeInfo[ModeNumber];
|
|
239
|
+
|
|
240
|
+
DEBUG ((
|
|
241
|
+
DEBUG_INFO,
|
|
242
|
+
"Ramfb: SetMode %u (%ux%u)\n",
|
|
243
|
+
ModeNumber,
|
|
244
|
+
ModeInfo->HorizontalResolution,
|
|
245
|
+
ModeInfo->VerticalResolution
|
|
246
|
+
));
|
|
247
|
+
|
|
248
|
+
Config.Address = SwapBytes64 (mQemuRamfbMode.FrameBufferBase);
|
|
249
|
+
Config.FourCC = SwapBytes32 (RAMFB_FORMAT);
|
|
250
|
+
Config.Flags = SwapBytes32 (0);
|
|
251
|
+
Config.Width = SwapBytes32 (ModeInfo->HorizontalResolution);
|
|
252
|
+
Config.Height = SwapBytes32 (ModeInfo->VerticalResolution);
|
|
253
|
+
Config.Stride = SwapBytes32 (ModeInfo->HorizontalResolution * RAMFB_BPP);
|
|
254
|
+
|
|
255
|
+
Status = FrameBufferBltConfigure (
|
|
256
|
+
(VOID *)(UINTN)mQemuRamfbMode.FrameBufferBase,
|
|
257
|
+
ModeInfo,
|
|
258
|
+
mQemuRamfbFrameBufferBltConfigure,
|
|
259
|
+
&mQemuRamfbFrameBufferBltConfigureSize
|
|
260
|
+
);
|
|
261
|
+
|
|
262
|
+
if (Status == RETURN_BUFFER_TOO_SMALL) {
|
|
263
|
+
if (mQemuRamfbFrameBufferBltConfigure != NULL) {
|
|
264
|
+
FreePool (mQemuRamfbFrameBufferBltConfigure);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
mQemuRamfbFrameBufferBltConfigure =
|
|
268
|
+
AllocatePool (mQemuRamfbFrameBufferBltConfigureSize);
|
|
269
|
+
if (mQemuRamfbFrameBufferBltConfigure == NULL) {
|
|
270
|
+
mQemuRamfbFrameBufferBltConfigureSize = 0;
|
|
271
|
+
return EFI_OUT_OF_RESOURCES;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
Status = FrameBufferBltConfigure (
|
|
275
|
+
(VOID *)(UINTN)mQemuRamfbMode.FrameBufferBase,
|
|
276
|
+
ModeInfo,
|
|
277
|
+
mQemuRamfbFrameBufferBltConfigure,
|
|
278
|
+
&mQemuRamfbFrameBufferBltConfigureSize
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
if (RETURN_ERROR (Status)) {
|
|
283
|
+
ASSERT (Status == RETURN_UNSUPPORTED);
|
|
284
|
+
return Status;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
mQemuRamfbMode.Mode = ModeNumber;
|
|
288
|
+
mQemuRamfbMode.Info = ModeInfo;
|
|
289
|
+
|
|
290
|
+
QemuFwCfgSelectItem (mRamfbFwCfgItem);
|
|
291
|
+
QemuFwCfgWriteBytes (sizeof (Config), &Config);
|
|
292
|
+
|
|
293
|
+
//
|
|
294
|
+
// clear screen
|
|
295
|
+
//
|
|
296
|
+
ZeroMem (&Black, sizeof (Black));
|
|
297
|
+
Status = FrameBufferBlt (
|
|
298
|
+
mQemuRamfbFrameBufferBltConfigure,
|
|
299
|
+
&Black,
|
|
300
|
+
EfiBltVideoFill,
|
|
301
|
+
0, // SourceX -- ignored
|
|
302
|
+
0, // SourceY -- ignored
|
|
303
|
+
0, // DestinationX
|
|
304
|
+
0, // DestinationY
|
|
305
|
+
ModeInfo->HorizontalResolution, // Width
|
|
306
|
+
ModeInfo->VerticalResolution, // Height
|
|
307
|
+
0 // Delta -- ignored
|
|
308
|
+
);
|
|
309
|
+
if (RETURN_ERROR (Status)) {
|
|
310
|
+
DEBUG ((
|
|
311
|
+
DEBUG_WARN,
|
|
312
|
+
"%a: clearing the screen failed: %r\n",
|
|
313
|
+
__func__,
|
|
314
|
+
Status
|
|
315
|
+
));
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return EFI_SUCCESS;
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
STATIC
|
|
322
|
+
EFI_STATUS
|
|
323
|
+
EFIAPI
|
|
324
|
+
QemuRamfbGraphicsOutputBlt (
|
|
325
|
+
IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
|
|
326
|
+
IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer OPTIONAL,
|
|
327
|
+
IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
|
|
328
|
+
IN UINTN SourceX,
|
|
329
|
+
IN UINTN SourceY,
|
|
330
|
+
IN UINTN DestinationX,
|
|
331
|
+
IN UINTN DestinationY,
|
|
332
|
+
IN UINTN Width,
|
|
333
|
+
IN UINTN Height,
|
|
334
|
+
IN UINTN Delta
|
|
335
|
+
)
|
|
336
|
+
{
|
|
337
|
+
return FrameBufferBlt (
|
|
338
|
+
mQemuRamfbFrameBufferBltConfigure,
|
|
339
|
+
BltBuffer,
|
|
340
|
+
BltOperation,
|
|
341
|
+
SourceX,
|
|
342
|
+
SourceY,
|
|
343
|
+
DestinationX,
|
|
344
|
+
DestinationY,
|
|
345
|
+
Width,
|
|
346
|
+
Height,
|
|
347
|
+
Delta
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
STATIC EFI_GRAPHICS_OUTPUT_PROTOCOL mQemuRamfbGraphicsOutput = {
|
|
352
|
+
QemuRamfbGraphicsOutputQueryMode,
|
|
353
|
+
QemuRamfbGraphicsOutputSetMode,
|
|
354
|
+
QemuRamfbGraphicsOutputBlt,
|
|
355
|
+
&mQemuRamfbMode,
|
|
356
|
+
};
|
|
357
|
+
|
|
358
|
+
EFI_STATUS
|
|
359
|
+
EFIAPI
|
|
360
|
+
InitializeQemuRamfb (
|
|
361
|
+
IN EFI_HANDLE ImageHandle,
|
|
362
|
+
IN EFI_SYSTEM_TABLE *SystemTable
|
|
363
|
+
)
|
|
364
|
+
{
|
|
365
|
+
EFI_DEVICE_PATH_PROTOCOL *RamfbDevicePath;
|
|
366
|
+
EFI_DEVICE_PATH_PROTOCOL *GopDevicePath;
|
|
367
|
+
VOID *DevicePath;
|
|
368
|
+
VENDOR_DEVICE_PATH VendorDeviceNode;
|
|
369
|
+
ACPI_ADR_DEVICE_PATH AcpiDeviceNode;
|
|
370
|
+
EFI_STATUS Status;
|
|
371
|
+
EFI_PHYSICAL_ADDRESS FbBase;
|
|
372
|
+
UINTN FbSize, MaxFbSize, Pages;
|
|
373
|
+
UINTN FwCfgSize;
|
|
374
|
+
UINTN Index;
|
|
375
|
+
UINT32 PreferredMode;
|
|
376
|
+
|
|
377
|
+
if (!QemuFwCfgIsAvailable ()) {
|
|
378
|
+
DEBUG ((DEBUG_INFO, "Ramfb: no FwCfg\n"));
|
|
379
|
+
return EFI_NOT_FOUND;
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
Status = QemuFwCfgFindFile ("etc/ramfb", &mRamfbFwCfgItem, &FwCfgSize);
|
|
383
|
+
if (EFI_ERROR (Status)) {
|
|
384
|
+
return EFI_NOT_FOUND;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
if (FwCfgSize != sizeof (RAMFB_CONFIG)) {
|
|
388
|
+
DEBUG ((
|
|
389
|
+
DEBUG_ERROR,
|
|
390
|
+
"Ramfb: FwCfg size mismatch (expected %lu, got %lu)\n",
|
|
391
|
+
(UINT64)sizeof (RAMFB_CONFIG),
|
|
392
|
+
(UINT64)FwCfgSize
|
|
393
|
+
));
|
|
394
|
+
return EFI_PROTOCOL_ERROR;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
PreferredMode = QemuRamfbPreferredMode ();
|
|
398
|
+
|
|
399
|
+
MaxFbSize = 0;
|
|
400
|
+
for (Index = 0; Index < mQemuRamfbMode.MaxMode; Index++) {
|
|
401
|
+
mQemuRamfbModeInfo[Index].PixelsPerScanLine =
|
|
402
|
+
mQemuRamfbModeInfo[Index].HorizontalResolution;
|
|
403
|
+
mQemuRamfbModeInfo[Index].PixelFormat =
|
|
404
|
+
PixelBlueGreenRedReserved8BitPerColor;
|
|
405
|
+
FbSize = RAMFB_BPP *
|
|
406
|
+
mQemuRamfbModeInfo[Index].HorizontalResolution *
|
|
407
|
+
mQemuRamfbModeInfo[Index].VerticalResolution;
|
|
408
|
+
if (MaxFbSize < FbSize) {
|
|
409
|
+
MaxFbSize = FbSize;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
DEBUG ((
|
|
413
|
+
DEBUG_INFO,
|
|
414
|
+
"Ramfb: Mode %lu: %ux%u, %lu kB\n",
|
|
415
|
+
(UINT64)Index,
|
|
416
|
+
mQemuRamfbModeInfo[Index].HorizontalResolution,
|
|
417
|
+
mQemuRamfbModeInfo[Index].VerticalResolution,
|
|
418
|
+
(UINT64)(FbSize / 1024)
|
|
419
|
+
));
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
Pages = EFI_SIZE_TO_PAGES (MaxFbSize);
|
|
423
|
+
MaxFbSize = EFI_PAGES_TO_SIZE (Pages);
|
|
424
|
+
FbBase = (EFI_PHYSICAL_ADDRESS)(UINTN)AllocateReservedPages (Pages);
|
|
425
|
+
if (FbBase == 0) {
|
|
426
|
+
DEBUG ((DEBUG_ERROR, "Ramfb: memory allocation failed\n"));
|
|
427
|
+
return EFI_OUT_OF_RESOURCES;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
DEBUG ((
|
|
431
|
+
DEBUG_INFO,
|
|
432
|
+
"Ramfb: Framebuffer at 0x%lx, %lu kB, %lu pages\n",
|
|
433
|
+
(UINT64)FbBase,
|
|
434
|
+
(UINT64)(MaxFbSize / 1024),
|
|
435
|
+
(UINT64)Pages
|
|
436
|
+
));
|
|
437
|
+
mQemuRamfbMode.FrameBufferSize = MaxFbSize;
|
|
438
|
+
mQemuRamfbMode.FrameBufferBase = FbBase;
|
|
439
|
+
|
|
440
|
+
//
|
|
441
|
+
// Start in the resolution the host asked for (800 x 600 by default).
|
|
442
|
+
//
|
|
443
|
+
QemuRamfbGraphicsOutputSetMode (&mQemuRamfbGraphicsOutput, PreferredMode);
|
|
444
|
+
|
|
445
|
+
//
|
|
446
|
+
// ramfb vendor devpath
|
|
447
|
+
//
|
|
448
|
+
VendorDeviceNode.Header.Type = HARDWARE_DEVICE_PATH;
|
|
449
|
+
VendorDeviceNode.Header.SubType = HW_VENDOR_DP;
|
|
450
|
+
CopyGuid (&VendorDeviceNode.Guid, &gQemuRamfbGuid);
|
|
451
|
+
SetDevicePathNodeLength (
|
|
452
|
+
&VendorDeviceNode.Header,
|
|
453
|
+
sizeof (VENDOR_DEVICE_PATH)
|
|
454
|
+
);
|
|
455
|
+
|
|
456
|
+
RamfbDevicePath = AppendDevicePathNode (
|
|
457
|
+
NULL,
|
|
458
|
+
(EFI_DEVICE_PATH_PROTOCOL *)&VendorDeviceNode
|
|
459
|
+
);
|
|
460
|
+
if (RamfbDevicePath == NULL) {
|
|
461
|
+
Status = EFI_OUT_OF_RESOURCES;
|
|
462
|
+
goto FreeFramebuffer;
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
Status = gBS->InstallMultipleProtocolInterfaces (
|
|
466
|
+
&mRamfbHandle,
|
|
467
|
+
&gEfiDevicePathProtocolGuid,
|
|
468
|
+
RamfbDevicePath,
|
|
469
|
+
NULL
|
|
470
|
+
);
|
|
471
|
+
if (EFI_ERROR (Status)) {
|
|
472
|
+
DEBUG ((
|
|
473
|
+
DEBUG_ERROR,
|
|
474
|
+
"Ramfb: install Ramfb Vendor DevicePath failed: %r\n",
|
|
475
|
+
Status
|
|
476
|
+
));
|
|
477
|
+
goto FreeRamfbDevicePath;
|
|
478
|
+
}
|
|
479
|
+
|
|
480
|
+
//
|
|
481
|
+
// gop devpath + protocol
|
|
482
|
+
//
|
|
483
|
+
AcpiDeviceNode.Header.Type = ACPI_DEVICE_PATH;
|
|
484
|
+
AcpiDeviceNode.Header.SubType = ACPI_ADR_DP;
|
|
485
|
+
AcpiDeviceNode.ADR = ACPI_DISPLAY_ADR (
|
|
486
|
+
1, // DeviceIdScheme
|
|
487
|
+
0, // HeadId
|
|
488
|
+
0, // NonVgaOutput
|
|
489
|
+
1, // BiosCanDetect
|
|
490
|
+
0, // VendorInfo
|
|
491
|
+
ACPI_ADR_DISPLAY_TYPE_EXTERNAL_DIGITAL, // Type
|
|
492
|
+
0, // Port
|
|
493
|
+
0 // Index
|
|
494
|
+
);
|
|
495
|
+
SetDevicePathNodeLength (
|
|
496
|
+
&AcpiDeviceNode.Header,
|
|
497
|
+
sizeof (ACPI_ADR_DEVICE_PATH)
|
|
498
|
+
);
|
|
499
|
+
|
|
500
|
+
GopDevicePath = AppendDevicePathNode (
|
|
501
|
+
RamfbDevicePath,
|
|
502
|
+
(EFI_DEVICE_PATH_PROTOCOL *)&AcpiDeviceNode
|
|
503
|
+
);
|
|
504
|
+
if (GopDevicePath == NULL) {
|
|
505
|
+
Status = EFI_OUT_OF_RESOURCES;
|
|
506
|
+
goto FreeRamfbHandle;
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
Status = gBS->InstallMultipleProtocolInterfaces (
|
|
510
|
+
&mGopHandle,
|
|
511
|
+
&gEfiDevicePathProtocolGuid,
|
|
512
|
+
GopDevicePath,
|
|
513
|
+
&gEfiGraphicsOutputProtocolGuid,
|
|
514
|
+
&mQemuRamfbGraphicsOutput,
|
|
515
|
+
NULL
|
|
516
|
+
);
|
|
517
|
+
if (EFI_ERROR (Status)) {
|
|
518
|
+
DEBUG ((
|
|
519
|
+
DEBUG_ERROR,
|
|
520
|
+
"Ramfb: install GOP DevicePath failed: %r\n",
|
|
521
|
+
Status
|
|
522
|
+
));
|
|
523
|
+
goto FreeGopDevicePath;
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
Status = gBS->OpenProtocol (
|
|
527
|
+
mRamfbHandle,
|
|
528
|
+
&gEfiDevicePathProtocolGuid,
|
|
529
|
+
&DevicePath,
|
|
530
|
+
gImageHandle,
|
|
531
|
+
mGopHandle,
|
|
532
|
+
EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER
|
|
533
|
+
);
|
|
534
|
+
if (EFI_ERROR (Status)) {
|
|
535
|
+
DEBUG ((DEBUG_ERROR, "Ramfb: OpenProtocol failed: %r\n", Status));
|
|
536
|
+
goto FreeGopHandle;
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
return EFI_SUCCESS;
|
|
540
|
+
|
|
541
|
+
FreeGopHandle:
|
|
542
|
+
gBS->UninstallMultipleProtocolInterfaces (
|
|
543
|
+
mGopHandle,
|
|
544
|
+
&gEfiDevicePathProtocolGuid,
|
|
545
|
+
GopDevicePath,
|
|
546
|
+
&gEfiGraphicsOutputProtocolGuid,
|
|
547
|
+
&mQemuRamfbGraphicsOutput,
|
|
548
|
+
NULL
|
|
549
|
+
);
|
|
550
|
+
FreeGopDevicePath:
|
|
551
|
+
FreePool (GopDevicePath);
|
|
552
|
+
FreeRamfbHandle:
|
|
553
|
+
gBS->UninstallMultipleProtocolInterfaces (
|
|
554
|
+
mRamfbHandle,
|
|
555
|
+
&gEfiDevicePathProtocolGuid,
|
|
556
|
+
RamfbDevicePath,
|
|
557
|
+
NULL
|
|
558
|
+
);
|
|
559
|
+
FreeRamfbDevicePath:
|
|
560
|
+
FreePool (RamfbDevicePath);
|
|
561
|
+
FreeFramebuffer:
|
|
562
|
+
FreePages ((VOID *)(UINTN)mQemuRamfbMode.FrameBufferBase, Pages);
|
|
563
|
+
return Status;
|
|
564
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
## @file
|
|
2
|
+
# This driver is a implementation of the Graphics Output Protocol
|
|
3
|
+
# for the QEMU ramfb device.
|
|
4
|
+
#
|
|
5
|
+
# Copyright (c) 2018, Red Hat Inc.
|
|
6
|
+
#
|
|
7
|
+
# SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
8
|
+
#
|
|
9
|
+
##
|
|
10
|
+
|
|
11
|
+
[Defines]
|
|
12
|
+
INF_VERSION = 0x00010005
|
|
13
|
+
BASE_NAME = QemuRamfbDxe
|
|
14
|
+
FILE_GUID = dce1b094-7dc6-45d0-9fdd-d7fc3cc3e4ef
|
|
15
|
+
MODULE_TYPE = DXE_DRIVER
|
|
16
|
+
VERSION_STRING = 1.0
|
|
17
|
+
|
|
18
|
+
ENTRY_POINT = InitializeQemuRamfb
|
|
19
|
+
|
|
20
|
+
[Sources]
|
|
21
|
+
QemuRamfb.c
|
|
22
|
+
|
|
23
|
+
[Packages]
|
|
24
|
+
MdePkg/MdePkg.dec
|
|
25
|
+
MdeModulePkg/MdeModulePkg.dec
|
|
26
|
+
OvmfPkg/OvmfPkg.dec
|
|
27
|
+
|
|
28
|
+
[LibraryClasses]
|
|
29
|
+
BaseLib
|
|
30
|
+
BaseMemoryLib
|
|
31
|
+
DebugLib
|
|
32
|
+
DevicePathLib
|
|
33
|
+
FrameBufferBltLib
|
|
34
|
+
MemoryAllocationLib
|
|
35
|
+
PcdLib
|
|
36
|
+
UefiBootServicesTableLib
|
|
37
|
+
UefiDriverEntryPoint
|
|
38
|
+
QemuFwCfgLib
|
|
39
|
+
|
|
40
|
+
[Protocols]
|
|
41
|
+
gEfiGraphicsOutputProtocolGuid ## PRODUCES
|
|
42
|
+
|
|
43
|
+
[Pcd]
|
|
44
|
+
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoHorizontalResolution ## SOMETIMES_PRODUCES
|
|
45
|
+
gEfiMdeModulePkgTokenSpaceGuid.PcdVideoVerticalResolution ## SOMETIMES_PRODUCES
|
|
46
|
+
|
|
47
|
+
[Guids]
|
|
48
|
+
gQemuRamfbGuid
|
|
49
|
+
|
|
50
|
+
[Depex]
|
|
51
|
+
TRUE
|