iotrace.c (83d290c56fab2d38cd1ab4c4cc7099559c1d5046) iotrace.c (a74440b27b3f12d2cce54d7910953af19f1ac051)
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (c) 2014 Google, Inc.
4 */
5
6#define IOTRACE_IMPL
7
8#include <common.h>

--- 28 unchanged lines hidden (view full) ---

37};
38
39/**
40 * struct iotrace - current trace status and checksum
41 *
42 * @start: Start address of iotrace buffer
43 * @size: Size of iotrace buffer in bytes
44 * @offset: Current write offset into iotrace buffer
1// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (c) 2014 Google, Inc.
4 */
5
6#define IOTRACE_IMPL
7
8#include <common.h>

--- 28 unchanged lines hidden (view full) ---

37};
38
39/**
40 * struct iotrace - current trace status and checksum
41 *
42 * @start: Start address of iotrace buffer
43 * @size: Size of iotrace buffer in bytes
44 * @offset: Current write offset into iotrace buffer
45 * @region_start: Address of IO region to trace
46 * @region_size: Size of region to trace. if 0 will trace all address space
45 * @crc32: Current value of CRC chceksum of trace records
46 * @enabled: true if enabled, false if disabled
47 */
48static struct iotrace {
49 ulong start;
50 ulong size;
51 ulong offset;
47 * @crc32: Current value of CRC chceksum of trace records
48 * @enabled: true if enabled, false if disabled
49 */
50static struct iotrace {
51 ulong start;
52 ulong size;
53 ulong offset;
54 ulong region_start;
55 ulong region_size;
52 u32 crc32;
53 bool enabled;
54} iotrace;
55
56static void add_record(int flags, const void *ptr, ulong value)
57{
58 struct iotrace_record srec, *rec = &srec;
59
60 /*
61 * We don't support iotrace before relocation. Since the trace buffer
62 * is set up by a command, it can't be enabled at present. To change
63 * this we would need to set the iotrace buffer at build-time. See
64 * lib/trace.c for how this might be done if you are interested.
65 */
66 if (!(gd->flags & GD_FLG_RELOC) || !iotrace.enabled)
67 return;
68
56 u32 crc32;
57 bool enabled;
58} iotrace;
59
60static void add_record(int flags, const void *ptr, ulong value)
61{
62 struct iotrace_record srec, *rec = &srec;
63
64 /*
65 * We don't support iotrace before relocation. Since the trace buffer
66 * is set up by a command, it can't be enabled at present. To change
67 * this we would need to set the iotrace buffer at build-time. See
68 * lib/trace.c for how this might be done if you are interested.
69 */
70 if (!(gd->flags & GD_FLG_RELOC) || !iotrace.enabled)
71 return;
72
73 if (iotrace.region_size)
74 if ((ulong)ptr < iotrace.region_start ||
75 (ulong)ptr > iotrace.region_start + iotrace.region_size)
76 return;
77
69 /* Store it if there is room */
70 if (iotrace.offset + sizeof(*rec) < iotrace.size) {
71 rec = (struct iotrace_record *)map_sysmem(
72 iotrace.start + iotrace.offset,
73 sizeof(value));
74 }
75
76 rec->flags = flags;

--- 60 unchanged lines hidden (view full) ---

137 iotrace.crc32 = 0;
138}
139
140u32 iotrace_get_checksum(void)
141{
142 return iotrace.crc32;
143}
144
78 /* Store it if there is room */
79 if (iotrace.offset + sizeof(*rec) < iotrace.size) {
80 rec = (struct iotrace_record *)map_sysmem(
81 iotrace.start + iotrace.offset,
82 sizeof(value));
83 }
84
85 rec->flags = flags;

--- 60 unchanged lines hidden (view full) ---

146 iotrace.crc32 = 0;
147}
148
149u32 iotrace_get_checksum(void)
150{
151 return iotrace.crc32;
152}
153
154void iotrace_set_region(ulong start, ulong size)
155{
156 iotrace.region_start = start;
157 iotrace.region_size = size;
158}
159
160void iotrace_reset_region(void)
161{
162 iotrace.region_start = 0;
163 iotrace.region_size = 0;
164}
165
166void iotrace_get_region(ulong *start, ulong *size)
167{
168 *start = iotrace.region_start;
169 *size = iotrace.region_size;
170}
171
145void iotrace_set_enabled(int enable)
146{
147 iotrace.enabled = enable;
148}
149
150int iotrace_get_enabled(void)
151{
152 return iotrace.enabled;

--- 17 unchanged lines hidden ---
172void iotrace_set_enabled(int enable)
173{
174 iotrace.enabled = enable;
175}
176
177int iotrace_get_enabled(void)
178{
179 return iotrace.enabled;

--- 17 unchanged lines hidden ---