blob: 98826fa6ea0f3d4b7eaf1f7fe9c52e09dbd07366 [file] [log] [blame]
/*
* Copyright (c) 2018-2019, Arm Limited. All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef __CONSOLE_H__
#define __CONSOLE_H__
/* Returned by getc callbacks when receive FIFO is empty. */
#define ERROR_NO_PENDING_CHAR -1
/* Returned by console_xxx() if the registered console doesn't implement xxx. */
#define ERROR_NO_VALID_CONSOLE (-128)
#ifndef __ASSEMBLY__
#include <stdint.h>
#ifdef SMC_FUZZ_VARIABLE_COVERAGE
#define CONSOLE_FLAG_PLAT_UART 0
#define CONSOLE_FLAG_SMC_FUZZER 1
#endif
/*
* Function to initialize the console without a C Runtime to print debug
* information. It saves the console base to the data section. Returns 1 on
* success, 0 on error.
*/
int console_init(uintptr_t base_addr,
unsigned int uart_clk, unsigned int baud_rate);
#ifdef SMC_FUZZ_VARIABLE_COVERAGE
/*
* Function to initialize the console without a C Runtime to print debug
* information. It saves the console base to the data section. Returns 1 on
* success, 0 on error.
*/
int console_init_fuzzer(uintptr_t base_addr,
unsigned int uart_clk, unsigned int baud_rate);
void tftf_switch_console_state(int state);
int tftf_get_console_state(void);
#endif
/*
* Function to output a character over the console. It returns the character
* printed on success or an error code.
*/
int console_putc(int c);
#ifdef SMC_FUZZ_VARIABLE_COVERAGE
/*
* Function to output a character over the console. It returns the character
* printed on success or an error code.
*/
int console_putc_fuzzer(int c);
#endif
/*
* Function to get a character from the console. It returns the character
* grabbed on success or an error code on error. This function is blocking, it
* waits until there is an available character to return. Returns a character or
* error code.
*/
int console_getc(void);
/*
* Function to get a character from the console. It returns the character
* grabbed on success or an error code on error. This function is non-blocking,
* it returns immediately.
*/
int console_try_getc(void);
/*
* Function to force a write of all buffered data that hasn't been output. It
* returns 0 upon successful completion, otherwise it returns an error code.
*/
int console_flush(void);
#endif /* __ASSEMBLY__ */
#endif /* __CONSOLE_H__ */