xref: /optee_os/core/include/console.h (revision 770b2afacf3342b462629198ad26675b9fb41687)
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>
10*770b2afaSEtienne Carriere #include <tee_api_types.h>
11*770b2afaSEtienne 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
21*770b2afaSEtienne Carriere /*
22*770b2afaSEtienne Carriere  * Get console info from a reacheable DTB. Check the embedded DTB and fall
23*770b2afaSEtienne Carriere  * back to the external DTB.
24*770b2afaSEtienne Carriere  *
25*770b2afaSEtienne Carriere  * If the DTB does not specify a chosen (or secure-chosen) node, we assume
26*770b2afaSEtienne Carriere  * DTB does not provide specific console directive. Early console may remain.
27*770b2afaSEtienne Carriere  * If the DTB does not specify any console in the chosen (or secure-chosen)
28*770b2afaSEtienne Carriere  * node, we assume there is no console. Early console would be disabled.
29*770b2afaSEtienne Carriere  *
30*770b2afaSEtienne Carriere  * @fdt_out: Output DTB address where console directive is found
31*770b2afaSEtienne Carriere  * @offs_out: Output offset in the DTB where console directive is found
32*770b2afaSEtienne Carriere  * @path_out: Output string configuration of the console from in the DTB
33*770b2afaSEtienne Carriere  * @params_out: Output console parameters found from the DTB
34*770b2afaSEtienne Carriere  *
35*770b2afaSEtienne Carriere  * Return a TEE_Result compliant return value
36*770b2afaSEtienne Carriere  *
37*770b2afaSEtienne Carriere  */
38*770b2afaSEtienne Carriere TEE_Result get_console_node_from_dt(void **fdt_out, int *offs_out,
39*770b2afaSEtienne Carriere 				    const char **path_out,
40*770b2afaSEtienne Carriere 				    const char **params_out);
41*770b2afaSEtienne Carriere 
42*770b2afaSEtienne Carriere /*
43*770b2afaSEtienne Carriere  * Check if the /secure-chosen or /chosen node in the DT contains an
44*770b2afaSEtienne Carriere  * stdout-path value for which we have a compatible driver. If so, switch
45*770b2afaSEtienne Carriere  * the console to this device.
46*770b2afaSEtienne Carriere  */
472f82082fSEdison Ai void configure_console_from_dt(void);
484dc31c52SJerome Forissier #else
492f82082fSEdison Ai static inline void configure_console_from_dt(void)
504dc31c52SJerome Forissier {}
514dc31c52SJerome Forissier #endif /* !CFG_DT */
524dc31c52SJerome Forissier 
534de4bebcSJens Wiklander #endif /* CONSOLE_H */
544de4bebcSJens Wiklander 
55