summaryrefslogtreecommitdiff
path: root/arch/sandbox/include/asm/serial.h
blob: 16589a1b219eb2be0491828749b6b0b560f169e4 (plain)
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
/* SPDX-License-Identifier: GPL-2.0+ */
/*
 * Copyright 2020 Google LLC
 * Written by Simon Glass <sjg@chromium.org>
 */

#ifndef __asm_serial_h
#define __asm_serial_h

#include <dt-structs.h>

struct sandbox_serial_plat {
#if CONFIG_IS_ENABLED(OF_PLATDATA)
	struct dtd_sandbox_serial dtplat;
#endif
	int colour;	/* Text colour to use for output, -1 for none */
};

/**
 * sandbox_serial_written() - Get the total number of characters written
 *
 * This returns the number of characters written by the sandbox serial
 * device. It is intended for performing tests of the serial subsystem
 * where a console buffer cannot be used. The absolute number should not be
 * relied upon; call this function twice and compare the difference.
 *
 * Return: The number of characters written
 */
size_t sandbox_serial_written(void);

/**
 * sandbox_serial_endisable() - Enable or disable serial output
 * @enabled: Whether serial output should be enabled or not
 *
 * This allows tests to enable or disable the sandbox serial output. All
 * processes relating to writing output (except the actual writing) will be
 * performed.
 */
void sandbox_serial_endisable(bool enabled);

/**
 * struct sandbox_serial_priv - Private data for this driver
 *
 * @buf: holds input characters available to be read by this driver
 */
struct sandbox_serial_priv {
	struct membuff buf;
	char serial_buf[16];
	bool start_of_line;
};

#endif /* __asm_serial_h */