1 /* SPDX-License-Identifier: GPL-2.0+ */
2 /*
3  * Copyright 2020 Google LLC
4  * Written by Simon Glass <sjg@chromium.org>
5  */
6 
7 #ifndef __asm_serial_h
8 #define __asm_serial_h
9 
10 #include <dt-structs.h>
11 
12 struct sandbox_serial_plat {
13 #if CONFIG_IS_ENABLED(OF_PLATDATA)
14 	struct dtd_sandbox_serial dtplat;
15 #endif
16 	int colour;	/* Text colour to use for output, -1 for none */
17 };
18 
19 /**
20  * sandbox_serial_written() - Get the total number of characters written
21  *
22  * This returns the number of characters written by the sandbox serial
23  * device. It is intended for performing tests of the serial subsystem
24  * where a console buffer cannot be used. The absolute number should not be
25  * relied upon; call this function twice and compare the difference.
26  *
27  * Return: The number of characters written
28  */
29 size_t sandbox_serial_written(void);
30 
31 /**
32  * sandbox_serial_endisable() - Enable or disable serial output
33  * @enabled: Whether serial output should be enabled or not
34  *
35  * This allows tests to enable or disable the sandbox serial output. All
36  * processes relating to writing output (except the actual writing) will be
37  * performed.
38  */
39 void sandbox_serial_endisable(bool enabled);
40 
41 /**
42  * struct sandbox_serial_priv - Private data for this driver
43  *
44  * @buf: holds input characters available to be read by this driver
45  */
46 struct sandbox_serial_priv {
47 	struct membuff buf;
48 	char serial_buf[16];
49 	bool start_of_line;
50 };
51 
52 #endif /* __asm_serial_h */
53