blob: d777db8a3ed13cb888eccae5fb2182ae42bd6e65 [file] [log] [blame]
Tom Rini70df9d62018-05-07 17:02:21 -04001// SPDX-License-Identifier: GPL-2.0+
Alexander Graf4aacacc2016-03-04 01:10:00 +01002/*
3 * EFI application console interface
4 *
5 * Copyright (c) 2016 Alexander Graf
Alexander Graf4aacacc2016-03-04 01:10:00 +01006 */
7
8#include <common.h>
Rob Clark0d138cf2017-09-09 06:47:40 -04009#include <charset.h>
Rob Clark3863b712017-09-13 18:05:43 -040010#include <dm/device.h>
Alexander Graf4aacacc2016-03-04 01:10:00 +010011#include <efi_loader.h>
Rob Clark3863b712017-09-13 18:05:43 -040012#include <stdio_dev.h>
13#include <video_console.h>
Alexander Graf4aacacc2016-03-04 01:10:00 +010014
Alexander Graf4aacacc2016-03-04 01:10:00 +010015static bool console_size_queried;
16
Emmanuel Vadota074d5d2016-11-08 06:03:29 +010017#define EFI_COUT_MODE_2 2
18#define EFI_MAX_COUT_MODE 3
19
20struct cout_mode {
21 unsigned long columns;
22 unsigned long rows;
23 int present;
24};
25
26static struct cout_mode efi_cout_modes[] = {
27 /* EFI Mode 0 is 80x25 and always present */
28 {
29 .columns = 80,
30 .rows = 25,
31 .present = 1,
32 },
33 /* EFI Mode 1 is always 80x50 */
34 {
35 .columns = 80,
36 .rows = 50,
37 .present = 0,
38 },
39 /* Value are unknown until we query the console */
40 {
41 .columns = 0,
42 .rows = 0,
43 .present = 0,
44 },
45};
46
Heinrich Schuchardt580c13b2017-10-26 19:25:59 +020047const efi_guid_t efi_guid_text_output_protocol =
48 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID;
49const efi_guid_t efi_guid_text_input_protocol =
50 EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID;
Alexander Graf4aacacc2016-03-04 01:10:00 +010051
52#define cESC '\x1b'
53#define ESC "\x1b"
54
Emmanuel Vadota074d5d2016-11-08 06:03:29 +010055/* Default to mode 0 */
Alexander Graf4aacacc2016-03-04 01:10:00 +010056static struct simple_text_output_mode efi_con_mode = {
Emmanuel Vadota074d5d2016-11-08 06:03:29 +010057 .max_mode = 1,
Alexander Graf4aacacc2016-03-04 01:10:00 +010058 .mode = 0,
59 .attribute = 0,
60 .cursor_column = 0,
61 .cursor_row = 0,
62 .cursor_visible = 1,
63};
64
65static int term_read_reply(int *n, int maxnum, char end_char)
66{
67 char c;
68 int i = 0;
69
70 c = getc();
71 if (c != cESC)
72 return -1;
73 c = getc();
74 if (c != '[')
75 return -1;
76
77 n[0] = 0;
78 while (1) {
79 c = getc();
80 if (c == ';') {
81 i++;
82 if (i >= maxnum)
83 return -1;
84 n[i] = 0;
85 continue;
86 } else if (c == end_char) {
87 break;
88 } else if (c > '9' || c < '0') {
89 return -1;
90 }
91
92 /* Read one more decimal position */
93 n[i] *= 10;
94 n[i] += c - '0';
95 }
96
97 return 0;
98}
99
100static efi_status_t EFIAPI efi_cout_reset(
101 struct efi_simple_text_output_protocol *this,
102 char extended_verification)
103{
104 EFI_ENTRY("%p, %d", this, extended_verification);
105 return EFI_EXIT(EFI_UNSUPPORTED);
106}
107
Alexander Graf4aacacc2016-03-04 01:10:00 +0100108static efi_status_t EFIAPI efi_cout_output_string(
109 struct efi_simple_text_output_protocol *this,
Rob Clark1ef185d2017-09-13 18:05:44 -0400110 const efi_string_t string)
Alexander Graf4aacacc2016-03-04 01:10:00 +0100111{
Rob Clark1ef185d2017-09-13 18:05:44 -0400112 struct simple_text_output_mode *con = &efi_con_mode;
113 struct cout_mode *mode = &efi_cout_modes[con->mode];
Alexander Graf4aacacc2016-03-04 01:10:00 +0100114
115 EFI_ENTRY("%p, %p", this, string);
Rob Clark1ef185d2017-09-13 18:05:44 -0400116
117 unsigned int n16 = utf16_strlen(string);
118 char buf[MAX_UTF8_PER_UTF16 * n16 + 1];
119 char *p;
120
121 *utf16_to_utf8((u8 *)buf, string, n16) = '\0';
122
123 fputs(stdout, buf);
124
125 for (p = buf; *p; p++) {
126 switch (*p) {
127 case '\r': /* carriage-return */
128 con->cursor_column = 0;
129 break;
130 case '\n': /* newline */
131 con->cursor_column = 0;
132 con->cursor_row++;
133 break;
134 case '\t': /* tab, assume 8 char align */
135 break;
136 case '\b': /* backspace */
137 con->cursor_column = max(0, con->cursor_column - 1);
138 break;
139 default:
140 con->cursor_column++;
141 break;
142 }
143 if (con->cursor_column >= mode->columns) {
144 con->cursor_column = 0;
145 con->cursor_row++;
Alexander Graf4aacacc2016-03-04 01:10:00 +0100146 }
Rob Clark1ef185d2017-09-13 18:05:44 -0400147 con->cursor_row = min(con->cursor_row, (s32)mode->rows - 1);
Alexander Graf4aacacc2016-03-04 01:10:00 +0100148 }
149
150 return EFI_EXIT(EFI_SUCCESS);
151}
152
153static efi_status_t EFIAPI efi_cout_test_string(
154 struct efi_simple_text_output_protocol *this,
Rob Clark1ef185d2017-09-13 18:05:44 -0400155 const efi_string_t string)
Alexander Graf4aacacc2016-03-04 01:10:00 +0100156{
157 EFI_ENTRY("%p, %p", this, string);
158 return EFI_EXIT(EFI_SUCCESS);
159}
160
Emmanuel Vadota074d5d2016-11-08 06:03:29 +0100161static bool cout_mode_matches(struct cout_mode *mode, int rows, int cols)
162{
163 if (!mode->present)
164 return false;
165
166 return (mode->rows == rows) && (mode->columns == cols);
167}
168
Rob Clark1e948922017-09-13 18:05:42 -0400169static int query_console_serial(int *rows, int *cols)
170{
171 /* Ask the terminal about its size */
172 int n[3];
173 u64 timeout;
174
175 /* Empty input buffer */
176 while (tstc())
177 getc();
178
179 printf(ESC"[18t");
180
181 /* Check if we have a terminal that understands */
182 timeout = timer_get_us() + 1000000;
183 while (!tstc())
184 if (timer_get_us() > timeout)
185 return -1;
186
187 /* Read {depth,rows,cols} */
188 if (term_read_reply(n, 3, 't'))
189 return -1;
190
191 *cols = n[2];
192 *rows = n[1];
193
194 return 0;
195}
196
Alexander Graf4aacacc2016-03-04 01:10:00 +0100197static efi_status_t EFIAPI efi_cout_query_mode(
198 struct efi_simple_text_output_protocol *this,
199 unsigned long mode_number, unsigned long *columns,
200 unsigned long *rows)
201{
202 EFI_ENTRY("%p, %ld, %p, %p", this, mode_number, columns, rows);
203
204 if (!console_size_queried) {
Rob Clark3863b712017-09-13 18:05:43 -0400205 const char *stdout_name = env_get("stdout");
Rob Clark1e948922017-09-13 18:05:42 -0400206 int rows, cols;
Alexander Graf4aacacc2016-03-04 01:10:00 +0100207
208 console_size_queried = true;
209
Rob Clark3863b712017-09-13 18:05:43 -0400210 if (stdout_name && !strcmp(stdout_name, "vidconsole") &&
211 IS_ENABLED(CONFIG_DM_VIDEO)) {
212 struct stdio_dev *stdout_dev =
213 stdio_get_by_name("vidconsole");
214 struct udevice *dev = stdout_dev->priv;
215 struct vidconsole_priv *priv =
216 dev_get_uclass_priv(dev);
217 rows = priv->rows;
218 cols = priv->cols;
219 } else if (query_console_serial(&rows, &cols)) {
Alexander Graf4aacacc2016-03-04 01:10:00 +0100220 goto out;
Rob Clark3863b712017-09-13 18:05:43 -0400221 }
Emmanuel Vadota074d5d2016-11-08 06:03:29 +0100222
223 /* Test if we can have Mode 1 */
224 if (cols >= 80 && rows >= 50) {
225 efi_cout_modes[1].present = 1;
226 efi_con_mode.max_mode = 2;
227 }
228
229 /*
230 * Install our mode as mode 2 if it is different
231 * than mode 0 or 1 and set it as the currently selected mode
232 */
233 if (!cout_mode_matches(&efi_cout_modes[0], rows, cols) &&
234 !cout_mode_matches(&efi_cout_modes[1], rows, cols)) {
235 efi_cout_modes[EFI_COUT_MODE_2].columns = cols;
236 efi_cout_modes[EFI_COUT_MODE_2].rows = rows;
237 efi_cout_modes[EFI_COUT_MODE_2].present = 1;
238 efi_con_mode.max_mode = EFI_MAX_COUT_MODE;
239 efi_con_mode.mode = EFI_COUT_MODE_2;
240 }
Alexander Graf4aacacc2016-03-04 01:10:00 +0100241 }
242
Emmanuel Vadota074d5d2016-11-08 06:03:29 +0100243 if (mode_number >= efi_con_mode.max_mode)
244 return EFI_EXIT(EFI_UNSUPPORTED);
245
246 if (efi_cout_modes[mode_number].present != 1)
247 return EFI_EXIT(EFI_UNSUPPORTED);
248
Alexander Graf4aacacc2016-03-04 01:10:00 +0100249out:
250 if (columns)
Emmanuel Vadota074d5d2016-11-08 06:03:29 +0100251 *columns = efi_cout_modes[mode_number].columns;
Alexander Graf4aacacc2016-03-04 01:10:00 +0100252 if (rows)
Emmanuel Vadota074d5d2016-11-08 06:03:29 +0100253 *rows = efi_cout_modes[mode_number].rows;
Alexander Graf4aacacc2016-03-04 01:10:00 +0100254
255 return EFI_EXIT(EFI_SUCCESS);
256}
257
258static efi_status_t EFIAPI efi_cout_set_mode(
259 struct efi_simple_text_output_protocol *this,
260 unsigned long mode_number)
261{
262 EFI_ENTRY("%p, %ld", this, mode_number);
263
Alexander Graf4aacacc2016-03-04 01:10:00 +0100264
Emmanuel Vadota074d5d2016-11-08 06:03:29 +0100265 if (mode_number > efi_con_mode.max_mode)
266 return EFI_EXIT(EFI_UNSUPPORTED);
267
268 efi_con_mode.mode = mode_number;
269 efi_con_mode.cursor_column = 0;
270 efi_con_mode.cursor_row = 0;
271
272 return EFI_EXIT(EFI_SUCCESS);
Alexander Graf4aacacc2016-03-04 01:10:00 +0100273}
274
Rob Clark87ef0012017-10-10 08:23:01 -0400275static const struct {
276 unsigned int fg;
277 unsigned int bg;
278} color[] = {
279 { 30, 40 }, /* 0: black */
280 { 34, 44 }, /* 1: blue */
281 { 32, 42 }, /* 2: green */
282 { 36, 46 }, /* 3: cyan */
283 { 31, 41 }, /* 4: red */
284 { 35, 45 }, /* 5: magenta */
285 { 33, 43 }, /* 6: brown, map to yellow as edk2 does*/
286 { 37, 47 }, /* 7: light grey, map to white */
287};
288
289/* See EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute(). */
Alexander Graf4aacacc2016-03-04 01:10:00 +0100290static efi_status_t EFIAPI efi_cout_set_attribute(
291 struct efi_simple_text_output_protocol *this,
292 unsigned long attribute)
293{
Rob Clark87ef0012017-10-10 08:23:01 -0400294 unsigned int bold = EFI_ATTR_BOLD(attribute);
295 unsigned int fg = EFI_ATTR_FG(attribute);
296 unsigned int bg = EFI_ATTR_BG(attribute);
297
Alexander Graf4aacacc2016-03-04 01:10:00 +0100298 EFI_ENTRY("%p, %lx", this, attribute);
299
Rob Clark87ef0012017-10-10 08:23:01 -0400300 if (attribute)
301 printf(ESC"[%u;%u;%um", bold, color[fg].fg, color[bg].bg);
302 else
303 printf(ESC"[0;37;40m");
304
305 return EFI_EXIT(EFI_SUCCESS);
Alexander Graf4aacacc2016-03-04 01:10:00 +0100306}
307
308static efi_status_t EFIAPI efi_cout_clear_screen(
309 struct efi_simple_text_output_protocol *this)
310{
311 EFI_ENTRY("%p", this);
312
313 printf(ESC"[2J");
314
315 return EFI_EXIT(EFI_SUCCESS);
316}
317
318static efi_status_t EFIAPI efi_cout_set_cursor_position(
319 struct efi_simple_text_output_protocol *this,
320 unsigned long column, unsigned long row)
321{
322 EFI_ENTRY("%p, %ld, %ld", this, column, row);
323
324 printf(ESC"[%d;%df", (int)row, (int)column);
325 efi_con_mode.cursor_column = column;
326 efi_con_mode.cursor_row = row;
327
328 return EFI_EXIT(EFI_SUCCESS);
329}
330
331static efi_status_t EFIAPI efi_cout_enable_cursor(
332 struct efi_simple_text_output_protocol *this,
333 bool enable)
334{
335 EFI_ENTRY("%p, %d", this, enable);
336
337 printf(ESC"[?25%c", enable ? 'h' : 'l');
338
339 return EFI_EXIT(EFI_SUCCESS);
340}
341
Heinrich Schuchardt580c13b2017-10-26 19:25:59 +0200342struct efi_simple_text_output_protocol efi_con_out = {
Alexander Graf4aacacc2016-03-04 01:10:00 +0100343 .reset = efi_cout_reset,
344 .output_string = efi_cout_output_string,
345 .test_string = efi_cout_test_string,
346 .query_mode = efi_cout_query_mode,
347 .set_mode = efi_cout_set_mode,
348 .set_attribute = efi_cout_set_attribute,
349 .clear_screen = efi_cout_clear_screen,
350 .set_cursor_position = efi_cout_set_cursor_position,
351 .enable_cursor = efi_cout_enable_cursor,
352 .mode = (void*)&efi_con_mode,
353};
354
355static efi_status_t EFIAPI efi_cin_reset(
356 struct efi_simple_input_interface *this,
357 bool extended_verification)
358{
359 EFI_ENTRY("%p, %d", this, extended_verification);
360 return EFI_EXIT(EFI_UNSUPPORTED);
361}
362
Heinrich Schuchardtaa503da2018-02-19 18:53:29 +0100363/*
364 * Analyze modifiers (shift, alt, ctrl) for function keys.
365 * This gets called when we have already parsed CSI.
366 *
367 * @modifiers: bitmask (shift, alt, ctrl)
368 * @return: the unmodified code
369 */
370static char skip_modifiers(int *modifiers)
371{
372 char c, mod = 0, ret = 0;
373
374 c = getc();
375
376 if (c != ';') {
377 ret = c;
378 if (c == '~')
379 goto out;
380 c = getc();
381 }
382 for (;;) {
383 switch (c) {
384 case '0'...'9':
385 mod *= 10;
386 mod += c - '0';
387 /* fall through */
388 case ';':
389 c = getc();
390 break;
391 default:
392 goto out;
393 }
394 }
395out:
396 if (mod)
397 --mod;
398 if (modifiers)
399 *modifiers = mod;
400 if (!ret)
401 ret = c;
402 return ret;
403}
404
Alexander Graf4aacacc2016-03-04 01:10:00 +0100405static efi_status_t EFIAPI efi_cin_read_key_stroke(
406 struct efi_simple_input_interface *this,
407 struct efi_input_key *key)
408{
409 struct efi_input_key pressed_key = {
410 .scan_code = 0,
411 .unicode_char = 0,
412 };
413 char ch;
414
415 EFI_ENTRY("%p, %p", this, key);
416
417 /* We don't do interrupts, so check for timers cooperatively */
418 efi_timer_check();
419
420 if (!tstc()) {
421 /* No key pressed */
422 return EFI_EXIT(EFI_NOT_READY);
423 }
424
425 ch = getc();
426 if (ch == cESC) {
Heinrich Schuchardtaa503da2018-02-19 18:53:29 +0100427 /*
428 * Xterm Control Sequences
429 * https://www.xfree86.org/4.8.0/ctlseqs.html
430 */
Alexander Graf4aacacc2016-03-04 01:10:00 +0100431 ch = getc();
432 switch (ch) {
433 case cESC: /* ESC */
434 pressed_key.scan_code = 23;
435 break;
436 case 'O': /* F1 - F4 */
Heinrich Schuchardtaa503da2018-02-19 18:53:29 +0100437 ch = getc();
438 /* skip modifiers */
439 if (ch <= '9')
440 ch = getc();
441 pressed_key.scan_code = ch - 'P' + 11;
Alexander Graf4aacacc2016-03-04 01:10:00 +0100442 break;
443 case 'a'...'z':
444 ch = ch - 'a';
445 break;
446 case '[':
447 ch = getc();
448 switch (ch) {
449 case 'A'...'D': /* up, down right, left */
450 pressed_key.scan_code = ch - 'A' + 1;
451 break;
452 case 'F': /* End */
453 pressed_key.scan_code = 6;
454 break;
455 case 'H': /* Home */
456 pressed_key.scan_code = 5;
457 break;
Heinrich Schuchardtaa503da2018-02-19 18:53:29 +0100458 case '1':
459 ch = skip_modifiers(NULL);
460 switch (ch) {
461 case '1'...'5': /* F1 - F5 */
462 pressed_key.scan_code = ch - '1' + 11;
463 break;
464 case '7'...'9': /* F6 - F8 */
465 pressed_key.scan_code = ch - '7' + 16;
466 break;
467 case 'A'...'D': /* up, down right, left */
468 pressed_key.scan_code = ch - 'A' + 1;
469 break;
470 case 'F':
471 pressed_key.scan_code = 6; /* End */
472 break;
473 case 'H':
474 pressed_key.scan_code = 5; /* Home */
475 break;
476 }
Alexander Graf4aacacc2016-03-04 01:10:00 +0100477 break;
Heinrich Schuchardtaa503da2018-02-19 18:53:29 +0100478 case '2':
479 ch = skip_modifiers(NULL);
480 switch (ch) {
481 case '0'...'1': /* F9 - F10 */
482 pressed_key.scan_code = ch - '0' + 19;
483 break;
484 case '3'...'4': /* F11 - F12 */
485 pressed_key.scan_code = ch - '3' + 21;
486 break;
487 case '~': /* INS */
488 pressed_key.scan_code = 7;
489 break;
490 }
Alexander Graf4aacacc2016-03-04 01:10:00 +0100491 break;
492 case '3': /* DEL */
493 pressed_key.scan_code = 8;
Heinrich Schuchardtaa503da2018-02-19 18:53:29 +0100494 skip_modifiers(NULL);
495 break;
496 case '5': /* PG UP */
497 pressed_key.scan_code = 9;
498 skip_modifiers(NULL);
499 break;
500 case '6': /* PG DOWN */
501 pressed_key.scan_code = 10;
502 skip_modifiers(NULL);
Alexander Graf4aacacc2016-03-04 01:10:00 +0100503 break;
504 }
505 break;
506 }
507 } else if (ch == 0x7f) {
508 /* Backspace */
509 ch = 0x08;
510 }
Heinrich Schuchardtaa503da2018-02-19 18:53:29 +0100511 if (!pressed_key.scan_code)
512 pressed_key.unicode_char = ch;
Alexander Graf4aacacc2016-03-04 01:10:00 +0100513 *key = pressed_key;
514
515 return EFI_EXIT(EFI_SUCCESS);
516}
517
xypron.glpk@gmx.de54c7a8e2017-07-18 20:17:22 +0200518struct efi_simple_input_interface efi_con_in = {
Alexander Graf4aacacc2016-03-04 01:10:00 +0100519 .reset = efi_cin_reset,
520 .read_key_stroke = efi_cin_read_key_stroke,
521 .wait_for_key = NULL,
522};
xypron.glpk@gmx.de54c7a8e2017-07-18 20:17:22 +0200523
524static struct efi_event *console_timer_event;
525
xypron.glpk@gmx.de0ce42dc2017-07-20 05:26:07 +0200526static void EFIAPI efi_key_notify(struct efi_event *event, void *context)
xypron.glpk@gmx.de54c7a8e2017-07-18 20:17:22 +0200527{
528}
529
Heinrich Schuchardtd8b878a2018-01-19 20:24:51 +0100530/*
531 * Notification function of the console timer event.
532 *
533 * event: console timer event
534 * context: not used
535 */
xypron.glpk@gmx.de0ce42dc2017-07-20 05:26:07 +0200536static void EFIAPI efi_console_timer_notify(struct efi_event *event,
537 void *context)
xypron.glpk@gmx.de54c7a8e2017-07-18 20:17:22 +0200538{
539 EFI_ENTRY("%p, %p", event, context);
Heinrich Schuchardtd8b878a2018-01-19 20:24:51 +0100540
541 /* Check if input is available */
Heinrich Schuchardt8b11a8a2017-09-15 10:06:13 +0200542 if (tstc()) {
Heinrich Schuchardtd8b878a2018-01-19 20:24:51 +0100543 /* Queue the wait for key event */
Heinrich Schuchardt1bbee392017-10-04 15:03:24 +0200544 efi_con_in.wait_for_key->is_signaled = true;
Heinrich Schuchardtd8b878a2018-01-19 20:24:51 +0100545 efi_signal_event(efi_con_in.wait_for_key, true);
546 }
xypron.glpk@gmx.de54c7a8e2017-07-18 20:17:22 +0200547 EFI_EXIT(EFI_SUCCESS);
548}
549
550/* This gets called from do_bootefi_exec(). */
551int efi_console_register(void)
552{
553 efi_status_t r;
Heinrich Schuchardt580c13b2017-10-26 19:25:59 +0200554 struct efi_object *efi_console_output_obj;
555 struct efi_object *efi_console_input_obj;
Rob Clark49f7b4b2017-07-24 10:39:01 -0400556
Heinrich Schuchardt580c13b2017-10-26 19:25:59 +0200557 /* Create handles */
Heinrich Schuchardtb7cb8b42018-01-11 08:16:09 +0100558 r = efi_create_handle((efi_handle_t *)&efi_console_output_obj);
Heinrich Schuchardt580c13b2017-10-26 19:25:59 +0200559 if (r != EFI_SUCCESS)
560 goto out_of_memory;
561 r = efi_add_protocol(efi_console_output_obj->handle,
562 &efi_guid_text_output_protocol, &efi_con_out);
563 if (r != EFI_SUCCESS)
564 goto out_of_memory;
Heinrich Schuchardtb7cb8b42018-01-11 08:16:09 +0100565 r = efi_create_handle((efi_handle_t *)&efi_console_input_obj);
Heinrich Schuchardt580c13b2017-10-26 19:25:59 +0200566 if (r != EFI_SUCCESS)
567 goto out_of_memory;
568 r = efi_add_protocol(efi_console_input_obj->handle,
569 &efi_guid_text_input_protocol, &efi_con_in);
570 if (r != EFI_SUCCESS)
571 goto out_of_memory;
Rob Clark49f7b4b2017-07-24 10:39:01 -0400572
Heinrich Schuchardt580c13b2017-10-26 19:25:59 +0200573 /* Create console events */
Heinrich Schuchardtbf7f1692018-02-18 15:17:52 +0100574 r = efi_create_event(EVT_NOTIFY_WAIT, TPL_CALLBACK, efi_key_notify,
575 NULL, NULL, &efi_con_in.wait_for_key);
xypron.glpk@gmx.de54c7a8e2017-07-18 20:17:22 +0200576 if (r != EFI_SUCCESS) {
577 printf("ERROR: Failed to register WaitForKey event\n");
578 return r;
579 }
580 r = efi_create_event(EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
Heinrich Schuchardtbf7f1692018-02-18 15:17:52 +0100581 efi_console_timer_notify, NULL, NULL,
xypron.glpk@gmx.de54c7a8e2017-07-18 20:17:22 +0200582 &console_timer_event);
583 if (r != EFI_SUCCESS) {
584 printf("ERROR: Failed to register console event\n");
585 return r;
586 }
587 /* 5000 ns cycle is sufficient for 2 MBaud */
588 r = efi_set_timer(console_timer_event, EFI_TIMER_PERIODIC, 50);
589 if (r != EFI_SUCCESS)
590 printf("ERROR: Failed to set console timer\n");
591 return r;
Heinrich Schuchardt580c13b2017-10-26 19:25:59 +0200592out_of_memory:
593 printf("ERROR: Out of meemory\n");
594 return r;
xypron.glpk@gmx.de54c7a8e2017-07-18 20:17:22 +0200595}