1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2014 Google, Inc.
9 #include <linux/types.h>
12 * This file is designed to be included in arch/<arch>/include/asm/io.h.
13 * It redirects all IO access through a tracing/checksumming feature for
17 #if defined(CONFIG_IO_TRACE) && !defined(IOTRACE_IMPL) && \
18 !defined(CONFIG_SPL_BUILD)
21 #define readl(addr) iotrace_readl((const void *)(addr))
24 #define writel(val, addr) iotrace_writel(val, (const void *)(addr))
27 #define readw(addr) iotrace_readw((const void *)(addr))
30 #define writew(val, addr) iotrace_writew(val, (const void *)(addr))
33 #define readb(addr) iotrace_readb((const void *)(uintptr_t)addr)
36 #define writeb(val, addr) \
37 iotrace_writeb(val, (const void *)(uintptr_t)addr)
41 /* Tracing functions which mirror their io.h counterparts */
42 u32 iotrace_readl(const void *ptr);
43 void iotrace_writel(ulong value, const void *ptr);
44 u16 iotrace_readw(const void *ptr);
45 void iotrace_writew(ulong value, const void *ptr);
46 u8 iotrace_readb(const void *ptr);
47 void iotrace_writeb(ulong value, const void *ptr);
50 * iotrace_reset_checksum() - Reset the iotrace checksum
52 void iotrace_reset_checksum(void);
55 * iotrace_get_checksum() - Get the current checksum value
57 * @return currect checksum value
59 u32 iotrace_get_checksum(void);
62 * iotrace_set_region() - Set whether iotrace is limited to a specific
65 * Defines the address and size of the limited region.
67 * @start: address of the beginning of the region
68 * @size: size of the region in bytes.
70 void iotrace_set_region(ulong start, ulong size);
73 * iotrace_reset_region() - Reset the region limit
75 void iotrace_reset_region(void);
78 * iotrace_get_region() - Get region information
80 * @start: Returns start address of region
81 * @size: Returns size of region in bytes
83 void iotrace_get_region(ulong *start, ulong *size);
86 * iotrace_set_enabled() - Set whether iotracing is enabled or not
88 * This controls whether the checksum is updated and a trace record added
89 * for each I/O access.
91 * @enable: true to enable iotracing, false to disable
93 void iotrace_set_enabled(int enable);
96 * iotrace_get_enabled() - Get whether iotracing is enabled or not
98 * @return true if enabled, false if disabled
100 int iotrace_get_enabled(void);
103 * iotrace_set_buffer() - Set position and size of iotrace buffer
105 * Defines where the iotrace buffer goes, and resets the output pointer to
106 * the start of the buffer.
108 * The buffer can be 0 size in which case the checksum is updated but no
109 * trace records are writen. If the buffer is exhausted, the offset will
110 * continue to increase but not new data will be written.
112 * @start: Start address of buffer
113 * @size: Size of buffer in bytes
115 void iotrace_set_buffer(ulong start, ulong size);
118 * iotrace_get_buffer() - Get buffer information
120 * @start: Returns start address of buffer
121 * @size: Returns size of buffer in bytes
122 * @offset: Returns the byte offset where the next output trace record will
123 * @count: Returns the number of trace records recorded
124 * be written (or would be if the buffer was large enough)
126 void iotrace_get_buffer(ulong *start, ulong *size, ulong *offset, ulong *count);
128 #endif /* __IOTRACE_H */