1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (c) 2014 Google, Inc.
9 #include <linux/types.h>
11 /* Support up to the machine word length for now */
12 typedef ulong iovalue_t;
24 * struct iotrace_record - Holds a single I/O trace record
26 * @flags: I/O access type
27 * @timestamp: Timestamp of access
28 * @addr: Address of access
29 * @value: Value written or read
31 struct iotrace_record {
32 enum iotrace_flags flags;
39 * This file is designed to be included in arch/<arch>/include/asm/io.h.
40 * It redirects all IO access through a tracing/checksumming feature for
44 #if defined(CONFIG_IO_TRACE) && !defined(IOTRACE_IMPL) && \
45 !defined(CONFIG_SPL_BUILD)
48 #define readl(addr) iotrace_readl((const void *)(addr))
51 #define writel(val, addr) iotrace_writel(val, (void *)(addr))
54 #define readw(addr) iotrace_readw((const void *)(addr))
57 #define writew(val, addr) iotrace_writew(val, (void *)(addr))
60 #define readb(addr) iotrace_readb((const void *)(uintptr_t)addr)
63 #define writeb(val, addr) iotrace_writeb(val, (void *)(uintptr_t)addr)
67 /* Tracing functions which mirror their io.h counterparts */
68 u32 iotrace_readl(const void *ptr);
69 void iotrace_writel(ulong value, void *ptr);
70 u16 iotrace_readw(const void *ptr);
71 void iotrace_writew(ulong value, void *ptr);
72 u8 iotrace_readb(const void *ptr);
73 void iotrace_writeb(ulong value, void *ptr);
76 * iotrace_reset_checksum() - Reset the iotrace checksum
78 void iotrace_reset_checksum(void);
81 * iotrace_get_checksum() - Get the current checksum value
83 * Return: currect checksum value
85 u32 iotrace_get_checksum(void);
88 * iotrace_set_region() - Set whether iotrace is limited to a specific
91 * Defines the address and size of the limited region.
93 * @start: address of the beginning of the region
94 * @size: size of the region in bytes.
96 void iotrace_set_region(ulong start, ulong size);
99 * iotrace_reset_region() - Reset the region limit
101 void iotrace_reset_region(void);
104 * iotrace_get_region() - Get region information
106 * @start: Returns start address of region
107 * @size: Returns size of region in bytes
109 void iotrace_get_region(ulong *start, ulong *size);
112 * iotrace_set_enabled() - Set whether iotracing is enabled or not
114 * This controls whether the checksum is updated and a trace record added
115 * for each I/O access.
117 * @enable: true to enable iotracing, false to disable
119 void iotrace_set_enabled(int enable);
122 * iotrace_get_enabled() - Get whether iotracing is enabled or not
124 * Return: true if enabled, false if disabled
126 int iotrace_get_enabled(void);
129 * iotrace_set_buffer() - Set position and size of iotrace buffer
131 * Defines where the iotrace buffer goes, and resets the output pointer to
132 * the start of the buffer.
134 * The buffer can be 0 size in which case the checksum is updated but no
135 * trace records are writen. If the buffer is exhausted, the offset will
136 * continue to increase but not new data will be written.
138 * @start: Start address of buffer
139 * @size: Size of buffer in bytes
141 void iotrace_set_buffer(ulong start, ulong size);
144 * iotrace_get_buffer() - Get buffer information
146 * @start: Returns start address of buffer
147 * @size: Returns actual size of buffer in bytes
148 * @needed_size: Returns needed size of buffer in bytes
149 * @offset: Returns the byte offset where the next output trace record will
150 * @count: Returns the number of trace records recorded
151 * be written (or would be if the buffer was large enough)
153 void iotrace_get_buffer(ulong *start, ulong *size, ulong *needed_size, ulong *offset, ulong *count);
155 #endif /* __IOTRACE_H */