blob: 5d1a9a8081eeab0681caf546977c15e76e80e3a8 [file] [log] [blame]
Alexander Grafc1311ad2016-03-04 01:10:00 +01001/*
2 * EFI application console interface
3 *
4 * Copyright (c) 2016 Alexander Graf
5 *
6 * SPDX-License-Identifier: GPL-2.0+
7 */
8
9#include <common.h>
Rob Clark78178bb2017-09-09 06:47:40 -040010#include <charset.h>
Rob Clarka18c5a82017-09-13 18:05:43 -040011#include <dm/device.h>
Alexander Grafc1311ad2016-03-04 01:10:00 +010012#include <efi_loader.h>
Rob Clarka18c5a82017-09-13 18:05:43 -040013#include <stdio_dev.h>
14#include <video_console.h>
Alexander Grafc1311ad2016-03-04 01:10:00 +010015
Alexander Grafc1311ad2016-03-04 01:10:00 +010016static bool console_size_queried;
17
Emmanuel Vadot5be8b0a2016-11-08 06:03:29 +010018#define EFI_COUT_MODE_2 2
19#define EFI_MAX_COUT_MODE 3
20
21struct cout_mode {
22 unsigned long columns;
23 unsigned long rows;
24 int present;
25};
26
27static struct cout_mode efi_cout_modes[] = {
28 /* EFI Mode 0 is 80x25 and always present */
29 {
30 .columns = 80,
31 .rows = 25,
32 .present = 1,
33 },
34 /* EFI Mode 1 is always 80x50 */
35 {
36 .columns = 80,
37 .rows = 50,
38 .present = 0,
39 },
40 /* Value are unknown until we query the console */
41 {
42 .columns = 0,
43 .rows = 0,
44 .present = 0,
45 },
46};
47
Heinrich Schuchardtebb4dd52017-10-26 19:25:59 +020048const efi_guid_t efi_guid_text_output_protocol =
49 EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL_GUID;
50const efi_guid_t efi_guid_text_input_protocol =
51 EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID;
Alexander Grafc1311ad2016-03-04 01:10:00 +010052
53#define cESC '\x1b'
54#define ESC "\x1b"
55
Emmanuel Vadot5be8b0a2016-11-08 06:03:29 +010056/* Default to mode 0 */
Alexander Grafc1311ad2016-03-04 01:10:00 +010057static struct simple_text_output_mode efi_con_mode = {
Emmanuel Vadot5be8b0a2016-11-08 06:03:29 +010058 .max_mode = 1,
Alexander Grafc1311ad2016-03-04 01:10:00 +010059 .mode = 0,
60 .attribute = 0,
61 .cursor_column = 0,
62 .cursor_row = 0,
63 .cursor_visible = 1,
64};
65
66static int term_read_reply(int *n, int maxnum, char end_char)
67{
68 char c;
69 int i = 0;
70
71 c = getc();
72 if (c != cESC)
73 return -1;
74 c = getc();
75 if (c != '[')
76 return -1;
77
78 n[0] = 0;
79 while (1) {
80 c = getc();
81 if (c == ';') {
82 i++;
83 if (i >= maxnum)
84 return -1;
85 n[i] = 0;
86 continue;
87 } else if (c == end_char) {
88 break;
89 } else if (c > '9' || c < '0') {
90 return -1;
91 }
92
93 /* Read one more decimal position */
94 n[i] *= 10;
95 n[i] += c - '0';
96 }
97
98 return 0;
99}
100
101static efi_status_t EFIAPI efi_cout_reset(
102 struct efi_simple_text_output_protocol *this,
103 char extended_verification)
104{
105 EFI_ENTRY("%p, %d", this, extended_verification);
106 return EFI_EXIT(EFI_UNSUPPORTED);
107}
108
Alexander Grafc1311ad2016-03-04 01:10:00 +0100109static efi_status_t EFIAPI efi_cout_output_string(
110 struct efi_simple_text_output_protocol *this,
Rob Clark3a45bc72017-09-13 18:05:44 -0400111 const efi_string_t string)
Alexander Grafc1311ad2016-03-04 01:10:00 +0100112{
Rob Clark3a45bc72017-09-13 18:05:44 -0400113 struct simple_text_output_mode *con = &efi_con_mode;
114 struct cout_mode *mode = &efi_cout_modes[con->mode];
Alexander Grafc1311ad2016-03-04 01:10:00 +0100115
116 EFI_ENTRY("%p, %p", this, string);
Rob Clark3a45bc72017-09-13 18:05:44 -0400117
118 unsigned int n16 = utf16_strlen(string);
119 char buf[MAX_UTF8_PER_UTF16 * n16 + 1];
120 char *p;
121
122 *utf16_to_utf8((u8 *)buf, string, n16) = '\0';
123
124 fputs(stdout, buf);
125
126 for (p = buf; *p; p++) {
127 switch (*p) {
128 case '\r': /* carriage-return */
129 con->cursor_column = 0;
130 break;
131 case '\n': /* newline */
132 con->cursor_column = 0;
133 con->cursor_row++;
134 break;
135 case '\t': /* tab, assume 8 char align */
136 break;
137 case '\b': /* backspace */
138 con->cursor_column = max(0, con->cursor_column - 1);
139 break;
140 default:
141 con->cursor_column++;
142 break;
Alexander Grafc1311ad2016-03-04 01:10:00 +0100143 }
Rob Clark3a45bc72017-09-13 18:05:44 -0400144 if (con->cursor_column >= mode->columns) {
145 con->cursor_column = 0;
146 con->cursor_row++;
147 }
148 con->cursor_row = min(con->cursor_row, (s32)mode->rows - 1);
Alexander Grafc1311ad2016-03-04 01:10:00 +0100149 }
150
151 return EFI_EXIT(EFI_SUCCESS);
152}
153
154static efi_status_t EFIAPI efi_cout_test_string(
155 struct efi_simple_text_output_protocol *this,
Rob Clark3a45bc72017-09-13 18:05:44 -0400156 const efi_string_t string)
Alexander Grafc1311ad2016-03-04 01:10:00 +0100157{
158 EFI_ENTRY("%p, %p", this, string);
159 return EFI_EXIT(EFI_SUCCESS);
160}
161
Emmanuel Vadot5be8b0a2016-11-08 06:03:29 +0100162static bool cout_mode_matches(struct cout_mode *mode, int rows, int cols)
163{
164 if (!mode->present)
165 return false;
166
167 return (mode->rows == rows) && (mode->columns == cols);
168}
169
Rob Clark71cc25c2017-09-13 18:05:42 -0400170static int query_console_serial(int *rows, int *cols)
171{
172 /* Ask the terminal about its size */
173 int n[3];
174 u64 timeout;
175
176 /* Empty input buffer */
177 while (tstc())
178 getc();
179
180 printf(ESC"[18t");
181
182 /* Check if we have a terminal that understands */
183 timeout = timer_get_us() + 1000000;
184 while (!tstc())
185 if (timer_get_us() > timeout)
186 return -1;
187
188 /* Read {depth,rows,cols} */
189 if (term_read_reply(n, 3, 't'))
190 return -1;
191
192 *cols = n[2];
193 *rows = n[1];
194
195 return 0;
196}
197
Alexander Grafc1311ad2016-03-04 01:10:00 +0100198static efi_status_t EFIAPI efi_cout_query_mode(
199 struct efi_simple_text_output_protocol *this,
200 unsigned long mode_number, unsigned long *columns,
201 unsigned long *rows)
202{
203 EFI_ENTRY("%p, %ld, %p, %p", this, mode_number, columns, rows);
204
205 if (!console_size_queried) {
Rob Clarka18c5a82017-09-13 18:05:43 -0400206 const char *stdout_name = env_get("stdout");
Rob Clark71cc25c2017-09-13 18:05:42 -0400207 int rows, cols;
Alexander Grafc1311ad2016-03-04 01:10:00 +0100208
209 console_size_queried = true;
210
Rob Clarka18c5a82017-09-13 18:05:43 -0400211 if (stdout_name && !strcmp(stdout_name, "vidconsole") &&
212 IS_ENABLED(CONFIG_DM_VIDEO)) {
213 struct stdio_dev *stdout_dev =
214 stdio_get_by_name("vidconsole");
215 struct udevice *dev = stdout_dev->priv;
216 struct vidconsole_priv *priv =
217 dev_get_uclass_priv(dev);
218 rows = priv->rows;
219 cols = priv->cols;
220 } else if (query_console_serial(&rows, &cols)) {
Alexander Grafc1311ad2016-03-04 01:10:00 +0100221 goto out;
Rob Clarka18c5a82017-09-13 18:05:43 -0400222 }
Emmanuel Vadot5be8b0a2016-11-08 06:03:29 +0100223
224 /* Test if we can have Mode 1 */
225 if (cols >= 80 && rows >= 50) {
226 efi_cout_modes[1].present = 1;
227 efi_con_mode.max_mode = 2;
228 }
229
230 /*
231 * Install our mode as mode 2 if it is different
232 * than mode 0 or 1 and set it as the currently selected mode
233 */
234 if (!cout_mode_matches(&efi_cout_modes[0], rows, cols) &&
235 !cout_mode_matches(&efi_cout_modes[1], rows, cols)) {
236 efi_cout_modes[EFI_COUT_MODE_2].columns = cols;
237 efi_cout_modes[EFI_COUT_MODE_2].rows = rows;
238 efi_cout_modes[EFI_COUT_MODE_2].present = 1;
239 efi_con_mode.max_mode = EFI_MAX_COUT_MODE;
240 efi_con_mode.mode = EFI_COUT_MODE_2;
241 }
Alexander Grafc1311ad2016-03-04 01:10:00 +0100242 }
243
Emmanuel Vadot5be8b0a2016-11-08 06:03:29 +0100244 if (mode_number >= efi_con_mode.max_mode)
245 return EFI_EXIT(EFI_UNSUPPORTED);
246
247 if (efi_cout_modes[mode_number].present != 1)
248 return EFI_EXIT(EFI_UNSUPPORTED);
249
Alexander Grafc1311ad2016-03-04 01:10:00 +0100250out:
251 if (columns)
Emmanuel Vadot5be8b0a2016-11-08 06:03:29 +0100252 *columns = efi_cout_modes[mode_number].columns;
Alexander Grafc1311ad2016-03-04 01:10:00 +0100253 if (rows)
Emmanuel Vadot5be8b0a2016-11-08 06:03:29 +0100254 *rows = efi_cout_modes[mode_number].rows;
Alexander Grafc1311ad2016-03-04 01:10:00 +0100255
256 return EFI_EXIT(EFI_SUCCESS);
257}
258
259static efi_status_t EFIAPI efi_cout_set_mode(
260 struct efi_simple_text_output_protocol *this,
261 unsigned long mode_number)
262{
263 EFI_ENTRY("%p, %ld", this, mode_number);
264
Alexander Grafc1311ad2016-03-04 01:10:00 +0100265
Emmanuel Vadot5be8b0a2016-11-08 06:03:29 +0100266 if (mode_number > efi_con_mode.max_mode)
267 return EFI_EXIT(EFI_UNSUPPORTED);
268
269 efi_con_mode.mode = mode_number;
270 efi_con_mode.cursor_column = 0;
271 efi_con_mode.cursor_row = 0;
272
273 return EFI_EXIT(EFI_SUCCESS);
Alexander Grafc1311ad2016-03-04 01:10:00 +0100274}
275
Rob Clark2d5dc2a2017-10-10 08:23:01 -0400276static const struct {
277 unsigned int fg;
278 unsigned int bg;
279} color[] = {
280 { 30, 40 }, /* 0: black */
281 { 34, 44 }, /* 1: blue */
282 { 32, 42 }, /* 2: green */
283 { 36, 46 }, /* 3: cyan */
284 { 31, 41 }, /* 4: red */
285 { 35, 45 }, /* 5: magenta */
286 { 33, 43 }, /* 6: brown, map to yellow as edk2 does*/
287 { 37, 47 }, /* 7: light grey, map to white */
288};
289
290/* See EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL.SetAttribute(). */
Alexander Grafc1311ad2016-03-04 01:10:00 +0100291static efi_status_t EFIAPI efi_cout_set_attribute(
292 struct efi_simple_text_output_protocol *this,
293 unsigned long attribute)
294{
Rob Clark2d5dc2a2017-10-10 08:23:01 -0400295 unsigned int bold = EFI_ATTR_BOLD(attribute);
296 unsigned int fg = EFI_ATTR_FG(attribute);
297 unsigned int bg = EFI_ATTR_BG(attribute);
298
Alexander Grafc1311ad2016-03-04 01:10:00 +0100299 EFI_ENTRY("%p, %lx", this, attribute);
300
Rob Clark2d5dc2a2017-10-10 08:23:01 -0400301 if (attribute)
302 printf(ESC"[%u;%u;%um", bold, color[fg].fg, color[bg].bg);
303 else
304 printf(ESC"[0;37;40m");
305
306 return EFI_EXIT(EFI_SUCCESS);
Alexander Grafc1311ad2016-03-04 01:10:00 +0100307}
308
309static efi_status_t EFIAPI efi_cout_clear_screen(
310 struct efi_simple_text_output_protocol *this)
311{
312 EFI_ENTRY("%p", this);
313
314 printf(ESC"[2J");
315
316 return EFI_EXIT(EFI_SUCCESS);
317}
318
319static efi_status_t EFIAPI efi_cout_set_cursor_position(
320 struct efi_simple_text_output_protocol *this,
321 unsigned long column, unsigned long row)
322{
323 EFI_ENTRY("%p, %ld, %ld", this, column, row);
324
325 printf(ESC"[%d;%df", (int)row, (int)column);
326 efi_con_mode.cursor_column = column;
327 efi_con_mode.cursor_row = row;
328
329 return EFI_EXIT(EFI_SUCCESS);
330}
331
332static efi_status_t EFIAPI efi_cout_enable_cursor(
333 struct efi_simple_text_output_protocol *this,
334 bool enable)
335{
336 EFI_ENTRY("%p, %d", this, enable);
337
338 printf(ESC"[?25%c", enable ? 'h' : 'l');
339
340 return EFI_EXIT(EFI_SUCCESS);
341}
342
Heinrich Schuchardtebb4dd52017-10-26 19:25:59 +0200343struct efi_simple_text_output_protocol efi_con_out = {
Alexander Grafc1311ad2016-03-04 01:10:00 +0100344 .reset = efi_cout_reset,
345 .output_string = efi_cout_output_string,
346 .test_string = efi_cout_test_string,
347 .query_mode = efi_cout_query_mode,
348 .set_mode = efi_cout_set_mode,
349 .set_attribute = efi_cout_set_attribute,
350 .clear_screen = efi_cout_clear_screen,
351 .set_cursor_position = efi_cout_set_cursor_position,
352 .enable_cursor = efi_cout_enable_cursor,
353 .mode = (void*)&efi_con_mode,
354};
355
356static efi_status_t EFIAPI efi_cin_reset(
357 struct efi_simple_input_interface *this,
358 bool extended_verification)
359{
360 EFI_ENTRY("%p, %d", this, extended_verification);
361 return EFI_EXIT(EFI_UNSUPPORTED);
362}
363
Heinrich Schuchardt0fb41692018-02-19 18:53:29 +0100364/*
365 * Analyze modifiers (shift, alt, ctrl) for function keys.
366 * This gets called when we have already parsed CSI.
367 *
368 * @modifiers: bitmask (shift, alt, ctrl)
369 * @return: the unmodified code
370 */
371static char skip_modifiers(int *modifiers)
372{
373 char c, mod = 0, ret = 0;
374
375 c = getc();
376
377 if (c != ';') {
378 ret = c;
379 if (c == '~')
380 goto out;
381 c = getc();
382 }
383 for (;;) {
384 switch (c) {
385 case '0'...'9':
386 mod *= 10;
387 mod += c - '0';
388 /* fall through */
389 case ';':
390 c = getc();
391 break;
392 default:
393 goto out;
394 }
395 }
396out:
397 if (mod)
398 --mod;
399 if (modifiers)
400 *modifiers = mod;
401 if (!ret)
402 ret = c;
403 return ret;
404}
405
Alexander Grafc1311ad2016-03-04 01:10:00 +0100406static efi_status_t EFIAPI efi_cin_read_key_stroke(
407 struct efi_simple_input_interface *this,
408 struct efi_input_key *key)
409{
410 struct efi_input_key pressed_key = {
411 .scan_code = 0,
412 .unicode_char = 0,
413 };
414 char ch;
415
416 EFI_ENTRY("%p, %p", this, key);
417
418 /* We don't do interrupts, so check for timers cooperatively */
419 efi_timer_check();
420
421 if (!tstc()) {
422 /* No key pressed */
423 return EFI_EXIT(EFI_NOT_READY);
424 }
425
426 ch = getc();
427 if (ch == cESC) {
Heinrich Schuchardt0fb41692018-02-19 18:53:29 +0100428 /*
429 * Xterm Control Sequences
430 * https://www.xfree86.org/4.8.0/ctlseqs.html
431 */
Alexander Grafc1311ad2016-03-04 01:10:00 +0100432 ch = getc();
433 switch (ch) {
434 case cESC: /* ESC */
435 pressed_key.scan_code = 23;
436 break;
437 case 'O': /* F1 - F4 */
Heinrich Schuchardt0fb41692018-02-19 18:53:29 +0100438 ch = getc();
439 /* skip modifiers */
440 if (ch <= '9')
441 ch = getc();
442 pressed_key.scan_code = ch - 'P' + 11;
Alexander Grafc1311ad2016-03-04 01:10:00 +0100443 break;
444 case 'a'...'z':
445 ch = ch - 'a';
446 break;
447 case '[':
448 ch = getc();
449 switch (ch) {
450 case 'A'...'D': /* up, down right, left */
451 pressed_key.scan_code = ch - 'A' + 1;
452 break;
453 case 'F': /* End */
454 pressed_key.scan_code = 6;
455 break;
456 case 'H': /* Home */
457 pressed_key.scan_code = 5;
458 break;
Heinrich Schuchardt0fb41692018-02-19 18:53:29 +0100459 case '1':
460 ch = skip_modifiers(NULL);
461 switch (ch) {
462 case '1'...'5': /* F1 - F5 */
463 pressed_key.scan_code = ch - '1' + 11;
464 break;
465 case '7'...'9': /* F6 - F8 */
466 pressed_key.scan_code = ch - '7' + 16;
467 break;
468 case 'A'...'D': /* up, down right, left */
469 pressed_key.scan_code = ch - 'A' + 1;
470 break;
471 case 'F':
472 pressed_key.scan_code = 6; /* End */
473 break;
474 case 'H':
475 pressed_key.scan_code = 5; /* Home */
476 break;
477 }
Alexander Grafc1311ad2016-03-04 01:10:00 +0100478 break;
Heinrich Schuchardt0fb41692018-02-19 18:53:29 +0100479 case '2':
480 ch = skip_modifiers(NULL);
481 switch (ch) {
482 case '0'...'1': /* F9 - F10 */
483 pressed_key.scan_code = ch - '0' + 19;
484 break;
485 case '3'...'4': /* F11 - F12 */
486 pressed_key.scan_code = ch - '3' + 21;
487 break;
488 case '~': /* INS */
489 pressed_key.scan_code = 7;
490 break;
491 }
Alexander Grafc1311ad2016-03-04 01:10:00 +0100492 break;
493 case '3': /* DEL */
494 pressed_key.scan_code = 8;
Heinrich Schuchardt0fb41692018-02-19 18:53:29 +0100495 skip_modifiers(NULL);
496 break;
497 case '5': /* PG UP */
498 pressed_key.scan_code = 9;
499 skip_modifiers(NULL);
500 break;
501 case '6': /* PG DOWN */
502 pressed_key.scan_code = 10;
503 skip_modifiers(NULL);
Alexander Grafc1311ad2016-03-04 01:10:00 +0100504 break;
505 }
506 break;
507 }
508 } else if (ch == 0x7f) {
509 /* Backspace */
510 ch = 0x08;
511 }
Heinrich Schuchardt0fb41692018-02-19 18:53:29 +0100512 if (!pressed_key.scan_code)
513 pressed_key.unicode_char = ch;
Alexander Grafc1311ad2016-03-04 01:10:00 +0100514 *key = pressed_key;
515
516 return EFI_EXIT(EFI_SUCCESS);
517}
518
xypron.glpk@gmx.de91be9a72017-07-18 20:17:22 +0200519struct efi_simple_input_interface efi_con_in = {
Alexander Grafc1311ad2016-03-04 01:10:00 +0100520 .reset = efi_cin_reset,
521 .read_key_stroke = efi_cin_read_key_stroke,
522 .wait_for_key = NULL,
523};
xypron.glpk@gmx.de91be9a72017-07-18 20:17:22 +0200524
525static struct efi_event *console_timer_event;
526
xypron.glpk@gmx.deff925932017-07-20 05:26:07 +0200527static void EFIAPI efi_key_notify(struct efi_event *event, void *context)
xypron.glpk@gmx.de91be9a72017-07-18 20:17:22 +0200528{
529}
530
Heinrich Schuchardt9bc96642018-01-19 20:24:51 +0100531/*
532 * Notification function of the console timer event.
533 *
534 * event: console timer event
535 * context: not used
536 */
xypron.glpk@gmx.deff925932017-07-20 05:26:07 +0200537static void EFIAPI efi_console_timer_notify(struct efi_event *event,
538 void *context)
xypron.glpk@gmx.de91be9a72017-07-18 20:17:22 +0200539{
540 EFI_ENTRY("%p, %p", event, context);
Heinrich Schuchardt9bc96642018-01-19 20:24:51 +0100541
542 /* Check if input is available */
Heinrich Schuchardtca62a4f2017-09-15 10:06:13 +0200543 if (tstc()) {
Heinrich Schuchardt9bc96642018-01-19 20:24:51 +0100544 /* Queue the wait for key event */
Heinrich Schuchardte190e892017-10-04 15:03:24 +0200545 efi_con_in.wait_for_key->is_signaled = true;
Heinrich Schuchardt9bc96642018-01-19 20:24:51 +0100546 efi_signal_event(efi_con_in.wait_for_key, true);
547 }
xypron.glpk@gmx.de91be9a72017-07-18 20:17:22 +0200548 EFI_EXIT(EFI_SUCCESS);
549}
550
551/* This gets called from do_bootefi_exec(). */
552int efi_console_register(void)
553{
554 efi_status_t r;
Heinrich Schuchardtebb4dd52017-10-26 19:25:59 +0200555 struct efi_object *efi_console_output_obj;
556 struct efi_object *efi_console_input_obj;
Rob Clarka17e62c2017-07-24 10:39:01 -0400557
Heinrich Schuchardtebb4dd52017-10-26 19:25:59 +0200558 /* Create handles */
Heinrich Schuchardt2074f702018-01-11 08:16:09 +0100559 r = efi_create_handle((efi_handle_t *)&efi_console_output_obj);
Heinrich Schuchardtebb4dd52017-10-26 19:25:59 +0200560 if (r != EFI_SUCCESS)
561 goto out_of_memory;
562 r = efi_add_protocol(efi_console_output_obj->handle,
563 &efi_guid_text_output_protocol, &efi_con_out);
564 if (r != EFI_SUCCESS)
565 goto out_of_memory;
Heinrich Schuchardt2074f702018-01-11 08:16:09 +0100566 r = efi_create_handle((efi_handle_t *)&efi_console_input_obj);
Heinrich Schuchardtebb4dd52017-10-26 19:25:59 +0200567 if (r != EFI_SUCCESS)
568 goto out_of_memory;
569 r = efi_add_protocol(efi_console_input_obj->handle,
570 &efi_guid_text_input_protocol, &efi_con_in);
571 if (r != EFI_SUCCESS)
572 goto out_of_memory;
Rob Clarka17e62c2017-07-24 10:39:01 -0400573
Heinrich Schuchardtebb4dd52017-10-26 19:25:59 +0200574 /* Create console events */
Heinrich Schuchardtb095f3c2018-02-18 15:17:52 +0100575 r = efi_create_event(EVT_NOTIFY_WAIT, TPL_CALLBACK, efi_key_notify,
576 NULL, NULL, &efi_con_in.wait_for_key);
xypron.glpk@gmx.de91be9a72017-07-18 20:17:22 +0200577 if (r != EFI_SUCCESS) {
578 printf("ERROR: Failed to register WaitForKey event\n");
579 return r;
580 }
581 r = efi_create_event(EVT_TIMER | EVT_NOTIFY_SIGNAL, TPL_CALLBACK,
Heinrich Schuchardtb095f3c2018-02-18 15:17:52 +0100582 efi_console_timer_notify, NULL, NULL,
xypron.glpk@gmx.de91be9a72017-07-18 20:17:22 +0200583 &console_timer_event);
584 if (r != EFI_SUCCESS) {
585 printf("ERROR: Failed to register console event\n");
586 return r;
587 }
588 /* 5000 ns cycle is sufficient for 2 MBaud */
589 r = efi_set_timer(console_timer_event, EFI_TIMER_PERIODIC, 50);
590 if (r != EFI_SUCCESS)
591 printf("ERROR: Failed to set console timer\n");
592 return r;
Heinrich Schuchardtebb4dd52017-10-26 19:25:59 +0200593out_of_memory:
594 printf("ERROR: Out of meemory\n");
595 return r;
xypron.glpk@gmx.de91be9a72017-07-18 20:17:22 +0200596}