xref: /optee_os/core/include/console.h (revision d2c717b23e63e07a3c05dbbdd6af62117480920d)
11bb92983SJerome Forissier /* SPDX-License-Identifier: BSD-2-Clause */
24de4bebcSJens Wiklander /*
34de4bebcSJens Wiklander  * Copyright (c) 2014, Linaro Limited
44de4bebcSJens Wiklander  */
54de4bebcSJens Wiklander 
64de4bebcSJens Wiklander #ifndef CONSOLE_H
74de4bebcSJens Wiklander #define CONSOLE_H
84de4bebcSJens Wiklander 
94dc31c52SJerome Forissier #include <compiler.h>
10770b2afaSEtienne Carriere #include <tee_api_types.h>
11770b2afaSEtienne Carriere 
124dc31c52SJerome Forissier 
136ef34537SSY Chiu void console_init(void);
144de4bebcSJens Wiklander void console_putc(int ch);
15db886a7fSJerome Forissier void console_flush(void);
164de4bebcSJens Wiklander 
17756aea59SJerome Forissier struct serial_chip;
18756aea59SJerome Forissier void register_serial_console(struct serial_chip *chip);
19756aea59SJerome Forissier 
204dc31c52SJerome Forissier #ifdef CFG_DT
21770b2afaSEtienne Carriere /*
22770b2afaSEtienne Carriere  * Get console info from a reacheable DTB. Check the embedded DTB and fall
23770b2afaSEtienne Carriere  * back to the external DTB.
24770b2afaSEtienne Carriere  *
25770b2afaSEtienne Carriere  * If the DTB does not specify a chosen (or secure-chosen) node, we assume
26770b2afaSEtienne Carriere  * DTB does not provide specific console directive. Early console may remain.
27770b2afaSEtienne Carriere  * If the DTB does not specify any console in the chosen (or secure-chosen)
28770b2afaSEtienne Carriere  * node, we assume there is no console. Early console would be disabled.
29770b2afaSEtienne Carriere  *
30770b2afaSEtienne Carriere  * @fdt_out: Output DTB address where console directive is found
31770b2afaSEtienne Carriere  * @offs_out: Output offset in the DTB where console directive is found
32*d2c717b2SJerome Forissier  * @path_out: Output string configuration of the console from the DTB.
33*d2c717b2SJerome Forissier  * (*path_out) shall be freed using nex_free().
34*d2c717b2SJerome Forissier  * @params_out: Output console parameters found from the DTB.
35*d2c717b2SJerome Forissier  * (*params_out) shall be freed using nex_free().
36770b2afaSEtienne Carriere  *
37770b2afaSEtienne Carriere  * Return a TEE_Result compliant return value
38770b2afaSEtienne Carriere  *
39770b2afaSEtienne Carriere  */
40286c31d4SEtienne Carriere TEE_Result get_console_node_from_dt(void *fdt, int *offs_out,
41*d2c717b2SJerome Forissier 				    char **path_out, char **params_out);
42770b2afaSEtienne Carriere 
43770b2afaSEtienne Carriere /*
44770b2afaSEtienne Carriere  * Check if the /secure-chosen or /chosen node in the DT contains an
45770b2afaSEtienne Carriere  * stdout-path value for which we have a compatible driver. If so, switch
46770b2afaSEtienne Carriere  * the console to this device.
47770b2afaSEtienne Carriere  */
482f82082fSEdison Ai void configure_console_from_dt(void);
494dc31c52SJerome Forissier #else
502f82082fSEdison Ai static inline void configure_console_from_dt(void)
514dc31c52SJerome Forissier {}
524dc31c52SJerome Forissier #endif /* !CFG_DT */
534dc31c52SJerome Forissier 
544de4bebcSJens Wiklander #endif /* CONSOLE_H */
554de4bebcSJens Wiklander 
56