blob: 91fbfda97f0f1971fa2f36a538343baa62f6a380 [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>
9
10#include "cactus.h"
J-Alves7581c382020-05-07 18:34:20 +010011#include "ffa_helpers.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}