2 * COPYRIGHT: See COPYING.ARM in the top level directory
3 * PROJECT: ReactOS UEFI Boot Library
4 * FILE: boot/environ/lib/io/display/textcons.c
5 * PURPOSE: Boot Library Text Console Routines
6 * PROGRAMMER: Alex Ionescu (alex.ionescu@reactos.org)
9 /* INCLUDES ******************************************************************/
13 /* DATA VARIABLES ************************************************************/
15 BL_TEXT_CONSOLE_VTABLE ConsoleTextLocalVtbl
=
17 ConsoleTextLocalDestruct
,
18 ConsoleTextLocalReinitialize
,
19 ConsoleTextBaseGetTextState
,
20 ConsoleTextLocalSetTextState
,
21 ConsoleTextBaseGetTextResolution
,
22 ConsoleTextLocalSetTextResolution
,
23 ConsoleTextLocalClearText
,
24 ConsoleTextLocalWriteText
27 /* FUNCTIONS *****************************************************************/
30 ConsoleTextLocalDestruct (
31 _In_
struct _BL_TEXT_CONSOLE
* Console
38 ConsoleTextLocalReinitialize (
39 _In_
struct _BL_TEXT_CONSOLE
* Console
42 EfiPrintf(L
"Not active yet!\r\n");
43 return STATUS_NOT_IMPLEMENTED
;
47 ConsoleTextBaseGetTextState (
48 _In_
struct _BL_TEXT_CONSOLE
* Console
,
49 _Out_ PBL_DISPLAY_STATE TextState
52 return STATUS_NOT_IMPLEMENTED
;
56 ConsoleTextLocalSetTextState (
57 _In_
struct _BL_TEXT_CONSOLE
* Console
,
59 _In_ PBL_DISPLAY_STATE TextState
62 return ConsoleFirmwareTextSetState(Console
, Mask
, TextState
);
66 ConsoleTextBaseGetTextResolution (
67 _In_
struct _BL_TEXT_CONSOLE
* Console
,
68 _Out_ PULONG TextResolution
71 return STATUS_NOT_IMPLEMENTED
;
75 ConsoleTextLocalSetTextResolution (
76 _In_
struct _BL_TEXT_CONSOLE
* Console
,
77 _In_ ULONG NewTextResolution
,
78 _Out_ PULONG OldTextResolution
81 return STATUS_NOT_IMPLEMENTED
;
85 ConsoleTextLocalClearText (
86 _In_
struct _BL_TEXT_CONSOLE
* Console
,
90 return ConsoleFirmwareTextClear(Console
, LineOnly
);
94 ConsoleTextLocalWriteText (
95 _In_
struct _BL_TEXT_CONSOLE
* Console
,
100 return STATUS_NOT_IMPLEMENTED
;
104 ConsoleTextLocalConstruct (
105 _In_ PBL_TEXT_CONSOLE TextConsole
,
106 _In_ BOOLEAN Activate
110 BL_DISPLAY_STATE TextState
;
112 /* Set our callbacks */
113 TextConsole
->Callbacks
= &ConsoleTextLocalVtbl
;
115 /* Are we activating this console? */
118 /* Call firmware to activate it */
119 Status
= ConsoleFirmwareTextOpen(TextConsole
);
120 if (!NT_SUCCESS(Status
))
122 EfiPrintf(L
"Failed to activate console: %lx\r\n", Status
);
127 /* Set default text state */
128 TextState
.BgColor
= 0;
131 TextState
.CursorVisible
= FALSE
;
132 TextState
.FgColor
= White
;
134 /* Are we activating? */
137 /* Call firmware to set it */
138 Status
= ConsoleFirmwareTextSetState(TextConsole
, 0xF, &TextState
);
139 if (!NT_SUCCESS(Status
))
141 /* We failed, back down */
142 EfiPrintf(L
"Failed to set console state: %lx\r\n", Status
);
143 ConsoleFirmwareTextClose(TextConsole
);
149 /* Just save the state for now, someone else can activate later */
150 TextConsole
->State
= TextState
;
153 /* Remember if we activated it */
154 TextConsole
->Active
= Activate
;
155 return STATUS_SUCCESS
;
159 ConsolepFindResolution (
160 _In_ PBL_DISPLAY_MODE Mode
,
161 _In_ PBL_DISPLAY_MODE List
,
165 PBL_DISPLAY_MODE ListEnd
;
167 /* Loop until we hit the maximum supported list index */
168 ListEnd
= &List
[MaxIndex
];
169 while (List
!= ListEnd
)
171 /* Does this resolution match? */
172 if ((Mode
->HRes
== List
->HRes
) && (Mode
->VRes
== List
->VRes
))
174 /* Yep -- we got a match */
183 /* No matches were found */
187 BL_INPUT_CONSOLE_VTABLE ConsoleInputLocalVtbl
=
189 (PCONSOLE_DESTRUCT
)ConsoleInputLocalDestruct
,
190 (PCONSOLE_REINITIALIZE
)ConsoleInputBaseReinitialize
,
194 ConsoleInputLocalDestruct (
195 _In_ PBL_INPUT_CONSOLE Console
198 /* Erase the current input buffer, and tear down the console */
199 ConsoleInputLocalEraseBuffer(Console
, NULL
);
200 BlMmFreeHeap(Console
->Buffer
);
204 ConsoleInputBaseConstruct (
205 _In_ PBL_INPUT_CONSOLE Console
210 /* Allocate a new 512 byte buffer */
211 Buffer
= BlMmAllocateHeap(512);
212 Console
->Buffer
= Buffer
;
215 return STATUS_INSUFFICIENT_RESOURCES
;
218 /* Set the current buffer pointers to it */
219 Console
->DataStart
= Buffer
;
220 Console
->DataEnd
= Buffer
;
222 /* Set the end 128 data entries into the buffer */
223 Console
->EndBuffer
= Buffer
+ 128;
224 return STATUS_SUCCESS
;
228 ConsoleInputBaseReinitialize (
229 _In_ PBL_INPUT_CONSOLE Console
234 /* Reset all the buffer pointers to the current buffer */
235 Buffer
= Console
->Buffer
;
236 Console
->DataStart
= Buffer
;
237 Console
->DataEnd
= Buffer
;
238 Console
->EndBuffer
= Buffer
+ 128;
239 return STATUS_SUCCESS
;
243 ConsoleCreateLocalInputConsole (
247 PBL_INPUT_CONSOLE InputConsole
;
250 /* Allocate the input console */
251 InputConsole
= BlMmAllocateHeap(sizeof(*InputConsole
));
254 return STATUS_INSUFFICIENT_RESOURCES
;
258 Status
= ConsoleInputBaseConstruct(InputConsole
);
259 if (!NT_SUCCESS(Status
));
261 /* Tear down on failure */
262 BlMmFreeHeap(InputConsole
);
266 /* Set the callback table, and set us as the local input console */
267 InputConsole
->Callbacks
= &ConsoleInputLocalVtbl
;
268 DspLocalInputConsole
= InputConsole
;
269 return STATUS_SUCCESS
;