1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
|
/* SPDX-License-Identifier: GPL-2.0+ */
/*
* (C) Copyright 2000-2009
* Wolfgang Denk, DENX Software Engineering, wd@denx.de.
*/
#ifndef __CONSOLE_H
#define __CONSOLE_H
#include <stdbool.h>
#include <stdio_dev.h>
#include <linux/errno.h>
extern char console_buffer[];
/* common/console.c */
int console_init_f(void); /* Before relocation; uses the serial stuff */
int console_init_r(void); /* After relocation; uses the console stuff */
int console_start(int file, struct stdio_dev *sdev); /* Start a console device */
void console_stop(int file, struct stdio_dev *sdev); /* Stop a console device */
int console_assign(int file, const char *devname); /* Assign the console */
int ctrlc(void);
int had_ctrlc(void); /* have we had a Control-C since last clear? */
void clear_ctrlc(void); /* clear the Control-C condition */
int disable_ctrlc(int); /* 1 to disable, 0 to enable Control-C detect */
int confirm_yesno(void); /* 1 if input is "y", "Y", "yes" or "YES" */
/**
* console_search_dev() - search for stdio device with given flags and name
* @flags: device flags as per input/output/system
* @name: device name
*
* Iterates over registered STDIO devices and match them with given @flags
* and @name.
*
* Return: pointer to the &struct stdio_dev if found, or NULL otherwise
*/
struct stdio_dev *console_search_dev(int flags, const char *name);
#ifdef CONFIG_CONSOLE_RECORD
/**
* console_record_init() - set up the console recording buffers
*
* This should be called as soon as malloc() is available so that the maximum
* amount of console output can be recorded.
*
* Return: 0 if OK, -ENOMEM if out of memory
*/
int console_record_init(void);
/**
* console_record_reset() - reset the console recording buffers
*
* Removes any data in the buffers
*/
void console_record_reset(void);
/**
* console_record_reset_enable() - reset and enable the console buffers
*
* This should be called to enable the console buffer.
*
* Return: 0 (always)
*/
int console_record_reset_enable(void);
/**
* console_record_readline() - Read a line from the console output
*
* This reads the next available line from the console output previously
* recorded.
*
* @str: Place to put string
* @maxlen: Maximum length of @str including nul terminator
* Return: length of string returned, or -ENOSPC if the console buffer was
* overflowed by the output, or -ENOENT if there was nothing to read
*/
int console_record_readline(char *str, int maxlen);
/**
* console_record_avail() - Get the number of available bytes in console output
*
* Return: available bytes (0 if empty)
*/
int console_record_avail(void);
/**
* console_record_isempty() - Returns if console output is empty
*
* Return: true if empty
*/
bool console_record_isempty(void);
/**
* console_in_puts() - Write a string to the console input buffer
*
* This writes the given string to the console_in buffer which will then be
* returned if a function calls e.g. `getc()`
*
* @str: the string to write
* Return: the number of bytes added
*/
int console_in_puts(const char *str);
#else
static inline int console_record_init(void)
{
/* Always succeed, since it is not enabled */
return 0;
}
static inline void console_record_reset(void)
{
/* Nothing to do here */
}
static inline int console_record_reset_enable(void)
{
/* Cannot enable it as it is not supported */
return -ENOSYS;
}
static inline int console_record_readline(char *str, int maxlen)
{
/* Nothing to read */
return 0;
}
static inline int console_record_avail(void)
{
/* There is never anything available */
return 0;
}
static inline int console_in_puts(const char *str)
{
/* There is never anything written */
return 0;
}
static inline bool console_record_isempty(void)
{
/* Always empty */
return true;
}
#endif /* !CONFIG_CONSOLE_RECORD */
/**
* console_announce_r() - print a U-Boot console on non-serial consoles
*
* When U-Boot starts up with a display it generally does not announce itself
* on the display. The banner is instead emitted on the UART before relocation.
* This function prints a banner on devices which (we assume) did not receive
* it before relocation.
*
* Return: 0 (meaning no errors)
*/
int console_announce_r(void);
/**
* console_puts_select_stderr() - Output a string to selected console devices
*
* This writes to stderr only. It is useful for outputting errors
*
* @serial_only: true to output only to serial, false to output to everything
* else
* @s: String to output
*/
void console_puts_select_stderr(bool serial_only, const char *s);
/**
* console_clear() - Clear the console
*
* Uses an ANSI sequence to clear the display, failing back to clearing the
* video display directly if !CONFIG_VIDEO_ANSI
*
* Return: 0 if OK, -ve on error
*/
int console_clear(void);
/**
* console_remove_by_name() - Remove a console by its stdio name
*
* This must only be used in tests. It removes any use of the named stdio device
* from the console tables.
*/
int console_remove_by_name(const char *name);
/*
* CONSOLE multiplexing.
*/
#ifdef CONFIG_CONSOLE_MUX
#include <iomux.h>
#endif
#endif
|