2 * COPYRIGHT: See COPYING.ARM in the top level directory
3 * PROJECT: ReactOS UEFI Boot Library
4 * FILE: boot/environ/lib/platform/display.c
5 * PURPOSE: Boot Library Display Management Routines
6 * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
9 /* INCLUDES ******************************************************************/
14 /* DATA VARIABLES ************************************************************/
16 PVOID BfiCachedStrikeData
;
17 LIST_ENTRY BfiDeferredListHead
;
18 LIST_ENTRY BfiFontFileListHead
;
19 PVOID BfiGraphicsRectangle
;
21 ULONG ConsoleGraphicalResolutionListFlags
;
22 BL_DISPLAY_MODE ConsoleGraphicalResolutionList
[3] =
28 ULONG ConsoleGraphicalResolutionListSize
= RTL_NUMBER_OF(ConsoleGraphicalResolutionList
);
30 BL_DISPLAY_MODE ConsoleTextResolutionList
[1] =
35 PVOID DspRemoteInputConsole
;
37 PVOID DspGraphicalConsole
;
39 /* FUNCTIONS *****************************************************************/
42 DsppGraphicsDisabledByBcd (
46 //EarlyPrint(L"Disabling graphics\n");
55 BL_LIBRARY_PARAMETERS LibraryParameters
= BlpLibraryParameters
;
56 BOOLEAN NoGraphics
;// , HighestMode;
58 PBL_DISPLAY_MODE DisplayMode
;
59 //ULONG GraphicsResolution;
60 PBL_GRAPHICS_CONSOLE GraphicsConsole
;
61 PBL_TEXT_CONSOLE TextConsole
, RemoteConsole
;
63 /* Initialize font data */
64 BfiCachedStrikeData
= 0;
65 InitializeListHead(&BfiDeferredListHead
);
66 InitializeListHead(&BfiFontFileListHead
);
68 /* Allocate the font rectangle */
69 BfiGraphicsRectangle
= BlMmAllocateHeap(0x5A);
70 if (!BfiGraphicsRectangle
)
72 return STATUS_NO_MEMORY
;
75 /* Display re-initialization not yet handled */
76 if (LibraryParameters
.LibraryFlags
& BL_LIBRARY_FLAG_REINITIALIZE_ALL
)
78 EarlyPrint(L
"Display path not handled\n");
79 return STATUS_NOT_SUPPORTED
;
82 /* Check if no graphics console is needed */
83 if ((Flags
& BL_LIBRARY_FLAG_NO_GRAPHICS_CONSOLE
) ||
84 (DsppGraphicsDisabledByBcd()))
91 /* No graphics -- remember this */
95 /* On first load, we always initialize a graphics display */
96 GraphicsConsole
= NULL
;
97 if (!(Flags
& BL_LIBRARY_FLAG_REINITIALIZE_ALL
) || !(NoGraphics
))
99 /* Default to mode 0 (1024x768) */
100 DisplayMode
= &ConsoleGraphicalResolutionList
[0];
102 /* Check what resolution to use*/
104 Status
= BlGetBootOptionInteger(BlpApplicationEntry
.BcdData
,
105 BcdLibraryInteger_GraphicsResolution
,
106 &GraphicsResolution
);
108 //GraphicsResolution = 0;
109 Status
= STATUS_NOT_FOUND
;
111 if (NT_SUCCESS(Status
))
113 ConsoleGraphicalResolutionListFlags
|= BL_DISPLAY_GRAPHICS_FORCED_VIDEO_MODE_FLAG
;
114 EarlyPrint(L
"Display selection not yet handled\n");
115 return STATUS_NOT_IMPLEMENTED
;
118 /* Check if the highest mode should be forced */
120 Status
= BlGetBootOptionBoolean(BlpApplicationEntry
.BcdData
,
121 BcdLibraryBoolean_GraphicsForceHighestMode
,
125 Status
= STATUS_NOT_FOUND
;
127 if (NT_SUCCESS(Status
))
129 ConsoleGraphicalResolutionListFlags
|= BL_DISPLAY_GRAPHICS_FORCED_HIGH_RES_MODE_FLAG
;
130 EarlyPrint(L
"High res mode not yet handled\n");
131 return STATUS_NOT_IMPLEMENTED
;
134 /* Do we need graphics mode after all? */
137 /* Yep -- go allocate it */
138 GraphicsConsole
= BlMmAllocateHeap(sizeof(*GraphicsConsole
));
142 Status
= ConsoleGraphicalConstruct(GraphicsConsole
);
143 if (!NT_SUCCESS(Status
))
145 EarlyPrint(L
"GFX FAILED: %lx\n", Status
);
146 BlMmFreeHeap(GraphicsConsole
);
147 GraphicsConsole
= NULL
;
152 RtlFillMemory(GraphicsConsole
->FrameBuffer
, GraphicsConsole
->FrameBufferSize
, 0x55);
157 /* Are we using something else than the default mode? */
158 if (DisplayMode
!= &ConsoleGraphicalResolutionList
[0])
160 EarlyPrint(L
"Display path not handled\n");
161 return STATUS_NOT_SUPPORTED
;
164 /* Mask out all the flags now */
165 ConsoleGraphicalResolutionListFlags
&= ~(BL_DISPLAY_GRAPHICS_FORCED_VIDEO_MODE_FLAG
|
166 BL_DISPLAY_GRAPHICS_FORCED_HIGH_RES_MODE_FLAG
);
169 /* Do we have a graphics console? */
171 if (!GraphicsConsole
)
173 /* Nope -- go allocate a text console */
174 TextConsole
= BlMmAllocateHeap(sizeof(*TextConsole
));
178 Status
= ConsoleTextLocalConstruct(TextConsole
, TRUE
);
179 if (!NT_SUCCESS(Status
))
181 BlMmFreeHeap(TextConsole
);
187 /* Initialize all globals to NULL */
188 DspRemoteInputConsole
= NULL
;
189 DspTextConsole
= NULL
;
190 DspGraphicalConsole
= NULL
;
192 /* If we don't have a text console, go get a remote console */
193 RemoteConsole
= NULL
;
196 ConsoleCreateRemoteConsole(&RemoteConsole
);
199 /* Do we have a remote console? */
202 /* Nope -- what about a graphical one? */
205 /* Yes, use it for both graphics and text */
206 DspGraphicalConsole
= GraphicsConsole
;
207 DspTextConsole
= GraphicsConsole
;
209 else if (TextConsole
)
211 /* Nope, but we have a text console */
212 DspTextConsole
= TextConsole
;
215 /* Console has been setup */
216 return STATUS_SUCCESS
;
219 /* We have a remote console -- have to figure out how to use it*/
220 EarlyPrint(L
"Display path not handled\n");
221 return STATUS_NOT_SUPPORTED
;
225 BlpDisplayInitialize (
231 /* Are we resetting or initializing? */
232 if (Flags
& BL_LIBRARY_FLAG_REINITIALIZE
)
234 /* This is a reset */
235 Status
= STATUS_NOT_IMPLEMENTED
;
237 Status
= DsppReinitialize(Flags
);
238 if (NT_SUCCESS(Status
))
240 Status
= BlpDisplayReinitialize();
246 /* Initialize the display */
247 Status
= DsppInitialize(Flags
);
250 /* Return display initailziation state */
255 BlDisplayGetTextCellResolution (
256 _Out_ PULONG TextWidth
,
257 _Out_ PULONG TextHeight
262 /* If the caller doesn't want anything, bail out */
263 if (!(TextWidth
) || !(TextHeight
))
268 /* Do we have a text console? */
269 Status
= STATUS_UNSUCCESSFUL
;
272 /* Do we have a graphics console? */
273 if (DspGraphicalConsole
)
275 /* Yep -- query it */
276 EarlyPrint(L
"Not supported\n");
277 Status
= STATUS_NOT_IMPLEMENTED
;
281 /* Check if we failed to get it from the graphics console */
282 if (!NT_SUCCESS(Status
))
284 /* Set default text size */