blob: 43093a6bb21668dce86d370fdb8da314c6a63a85 [file] [log] [blame]
Manish Pandey29495372020-04-09 15:19:26 +01001/*
2 * Copyright (c) 2020, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <drivers/arm/pl011.h>
8#include <drivers/console.h>
J-Alves5aecd982020-06-11 10:25:33 +01009#include <sp_helpers.h>
Manish Pandey29495372020-04-09 15:19:26 +010010
11#include "cactus.h"
Manish Pandey29495372020-04-09 15:19:26 +010012
13static int (*putc_impl)(int);
14
15static int putc_hypcall(int c)
16{
17 spm_debug_log((char)c);
18
19 return c;
20}
21
22static int putc_uart(int c)
23{
24 console_pl011_putc(c);
25
26 return c;
27}
28
29void set_putc_impl(enum stdout_route route)
30{
31 switch (route) {
32
33 case HVC_CALL_AS_STDOUT:
34 putc_impl = putc_hypcall;
35 return;
36
37 case PL011_AS_STDOUT:
38 default:
39 break;
40 }
41
42 putc_impl = putc_uart;
43}
44
45int console_putc(int c)
46{
47 if (!putc_impl) {
48 return -1;
49 }
50
51 return putc_impl(c);
52}