]> git.ipfire.org Git - people/ms/u-boot.git/blob - include/iotrace.h
Convert CONFIG_BOOTCOUNT_ENV to Kconfig
[people/ms/u-boot.git] / include / iotrace.h
1 /*
2 * Copyright (c) 2014 Google, Inc.
3 *
4 * SPDX-License-Identifier: GPL-2.0+
5 */
6
7 #ifndef __IOTRACE_H
8 #define __IOTRACE_H
9
10 #include <linux/types.h>
11
12 /*
13 * This file is designed to be included in arch/<arch>/include/asm/io.h.
14 * It redirects all IO access through a tracing/checksumming feature for
15 * testing purposes.
16 */
17
18 #if defined(CONFIG_IO_TRACE) && !defined(IOTRACE_IMPL) && \
19 !defined(CONFIG_SPL_BUILD)
20
21 #undef readl
22 #define readl(addr) iotrace_readl((const void *)(addr))
23
24 #undef writel
25 #define writel(val, addr) iotrace_writel(val, (const void *)(addr))
26
27 #undef readw
28 #define readw(addr) iotrace_readw((const void *)(addr))
29
30 #undef writew
31 #define writew(val, addr) iotrace_writew(val, (const void *)(addr))
32
33 #undef readb
34 #define readb(addr) iotrace_readb((const void *)(uintptr_t)addr)
35
36 #undef writeb
37 #define writeb(val, addr) \
38 iotrace_writeb(val, (const void *)(uintptr_t)addr)
39
40 #endif
41
42 /* Tracing functions which mirror their io.h counterparts */
43 u32 iotrace_readl(const void *ptr);
44 void iotrace_writel(ulong value, const void *ptr);
45 u16 iotrace_readw(const void *ptr);
46 void iotrace_writew(ulong value, const void *ptr);
47 u8 iotrace_readb(const void *ptr);
48 void iotrace_writeb(ulong value, const void *ptr);
49
50 /**
51 * iotrace_reset_checksum() - Reset the iotrace checksum
52 */
53 void iotrace_reset_checksum(void);
54
55 /**
56 * iotrace_get_checksum() - Get the current checksum value
57 *
58 * @return currect checksum value
59 */
60 u32 iotrace_get_checksum(void);
61
62 /**
63 * iotrace_set_enabled() - Set whether iotracing is enabled or not
64 *
65 * This controls whether the checksum is updated and a trace record added
66 * for each I/O access.
67 *
68 * @enable: true to enable iotracing, false to disable
69 */
70 void iotrace_set_enabled(int enable);
71
72 /**
73 * iotrace_get_enabled() - Get whether iotracing is enabled or not
74 *
75 * @return true if enabled, false if disabled
76 */
77 int iotrace_get_enabled(void);
78
79 /**
80 * iotrace_set_buffer() - Set position and size of iotrace buffer
81 *
82 * Defines where the iotrace buffer goes, and resets the output pointer to
83 * the start of the buffer.
84 *
85 * The buffer can be 0 size in which case the checksum is updated but no
86 * trace records are writen. If the buffer is exhausted, the offset will
87 * continue to increase but not new data will be written.
88 *
89 * @start: Start address of buffer
90 * @size: Size of buffer in bytes
91 */
92 void iotrace_set_buffer(ulong start, ulong size);
93
94 /**
95 * iotrace_get_buffer() - Get buffer information
96 *
97 * @start: Returns start address of buffer
98 * @size: Returns size of buffer in bytes
99 * @offset: Returns the byte offset where the next output trace record will
100 * @count: Returns the number of trace records recorded
101 * be written (or would be if the buffer was large enough)
102 */
103 void iotrace_get_buffer(ulong *start, ulong *size, ulong *offset, ulong *count);
104
105 #endif /* __IOTRACE_H */