aboutsummaryrefslogtreecommitdiff
path: root/sys/sys/_cscan_bus.h
blob: b1fd4135261e0471946db79cf09ea8c4f317024a (plain) (blame)
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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/*-
 * SPDX-License-Identifier: BSD-2-Clause
 *
 * Copyright (c) 2019 Andrew Turner
 *
 * This software was developed by SRI International and the University of
 * Cambridge Computer Laboratory (Department of Computer Science and
 * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the
 * DARPA SSITH research programme.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 * SUCH DAMAGE.
 *
 * $FreeBSD$
 */

#ifndef _SYS__CSAN_BUS_H_
#define	_SYS__CSAN_BUS_H_

#define	KCSAN_BS_MULTI(rw, width, type)					\
	void kcsan_bus_space_##rw##_multi_##width(bus_space_tag_t, 	\
	    bus_space_handle_t, bus_size_t, type *, bus_size_t);	\
	void kcsan_bus_space_##rw##_multi_stream_##width(bus_space_tag_t, \
	    bus_space_handle_t, bus_size_t, type *, bus_size_t);	\
	void kcsan_bus_space_##rw##_region_##width(bus_space_tag_t,	\
	    bus_space_handle_t, bus_size_t, type *, bus_size_t);	\
	void kcsan_bus_space_##rw##_region_stream_##width(bus_space_tag_t, \
	    bus_space_handle_t, bus_size_t, type *, bus_size_t)

#define	KCSAN_BS_READ(width, type)					\
	type kcsan_bus_space_read_##width(bus_space_tag_t, 		\
	    bus_space_handle_t, bus_size_t);				\
	type kcsan_bus_space_read_stream_##width(bus_space_tag_t,	\
	    bus_space_handle_t, bus_size_t);				\
	KCSAN_BS_MULTI(read, width, type)

#define	KCSAN_BS_WRITE(width, type)					\
	void kcsan_bus_space_write_##width(bus_space_tag_t, 		\
	    bus_space_handle_t, bus_size_t, type);			\
	void kcsan_bus_space_write_stream_##width(bus_space_tag_t,	\
	    bus_space_handle_t, bus_size_t, type);			\
	KCSAN_BS_MULTI(write, width, const type)

#define	KCSAN_BS_SET(width, type)					\
	void kcsan_bus_space_set_multi_##width(bus_space_tag_t, 	\
	    bus_space_handle_t, bus_size_t, type, bus_size_t);		\
	void kcsan_bus_space_set_multi_stream_##width(bus_space_tag_t, \
	    bus_space_handle_t, bus_size_t, type, bus_size_t);		\
	void kcsan_bus_space_set_region_##width(bus_space_tag_t,	\
	    bus_space_handle_t, bus_size_t, type, bus_size_t);		\
	void kcsan_bus_space_set_region_stream_##width(bus_space_tag_t, \
	    bus_space_handle_t, bus_size_t, type, bus_size_t)

#define	KCSAN_BS_COPY(width, type)					\
	void kcsan_bus_space_copy_region_##width(bus_space_tag_t,	\
	    bus_space_handle_t,	bus_size_t, bus_space_handle_t,		\
	    bus_size_t, bus_size_t);					\
	void kcsan_bus_space_copy_region_stream_##width(bus_space_tag_t, \
	    bus_space_handle_t,	bus_size_t, bus_space_handle_t,		\
	    bus_size_t, bus_size_t);

#define	KCSAN_BS_PEEK(width, type)					\
	int kcsan_bus_space_peek_##width(bus_space_tag_t, 		\
	    bus_space_handle_t, bus_size_t, type *);

#define	KCSAN_BS_POKE(width, type)					\
	int kcsan_bus_space_poke_##width(bus_space_tag_t, 		\
	    bus_space_handle_t, bus_size_t, type);

#define	KCSAN_BS(width, type)						\
	KCSAN_BS_READ(width, type);					\
	KCSAN_BS_WRITE(width, type);					\
	KCSAN_BS_SET(width, type);					\
	KCSAN_BS_COPY(width, type)					\
	KCSAN_BS_PEEK(width, type);					\
	KCSAN_BS_POKE(width, type);

KCSAN_BS(1, uint8_t);
KCSAN_BS(2, uint16_t);
KCSAN_BS(4, uint32_t);
KCSAN_BS(8, uint64_t);

int kcsan_bus_space_map(bus_space_tag_t, bus_addr_t, bus_size_t, int,
    bus_space_handle_t *);
void kcsan_bus_space_unmap(bus_space_tag_t, bus_space_handle_t, bus_size_t);
int kcsan_bus_space_subregion(bus_space_tag_t, bus_space_handle_t, bus_size_t,
    bus_size_t, bus_space_handle_t *);
int kcsan_bus_space_alloc(bus_space_tag_t, bus_addr_t, bus_addr_t,
    bus_size_t, bus_size_t, bus_size_t, int, bus_addr_t *,
    bus_space_handle_t *);
void kcsan_bus_space_free(bus_space_tag_t, bus_space_handle_t, bus_size_t);
void kcsan_bus_space_barrier(bus_space_tag_t, bus_space_handle_t, bus_size_t,
    bus_size_t, int);

#ifndef KCSAN_RUNTIME

#define	bus_space_map			kcsan_bus_space_map
#define	bus_space_unmap			kcsan_bus_space_unmap
#define	bus_space_subregion		kcsan_bus_space_subregion
#define	bus_space_alloc			kcsan_bus_space_alloc
#define	bus_space_free			kcsan_bus_space_free
#define	bus_space_barrier		kcsan_bus_space_barrier

#define	bus_space_read_1		kcsan_bus_space_read_1
#define	bus_space_read_stream_1		kcsan_bus_space_read_stream_1
#define	bus_space_read_multi_1		kcsan_bus_space_read_multi_1
#define	bus_space_read_multi_stream_1	kcsan_bus_space_read_multi_stream_1
#define	bus_space_read_region_1		kcsan_bus_space_read_region_1
#define	bus_space_read_region_stream_1	kcsan_bus_space_read_region_stream_1
#define	bus_space_write_1		kcsan_bus_space_write_1
#define	bus_space_write_stream_1	kcsan_bus_space_write_stream_1
#define	bus_space_write_multi_1		kcsan_bus_space_write_multi_1
#define	bus_space_write_multi_stream_1	kcsan_bus_space_write_multi_stream_1
#define	bus_space_write_region_1	kcsan_bus_space_write_region_1
#define	bus_space_write_region_stream_1	kcsan_bus_space_write_region_stream_1
#define	bus_space_set_multi_1		kcsan_bus_space_set_multi_1
#define	bus_space_set_multi_stream_1	kcsan_bus_space_set_multi_stream_1
#define	bus_space_set_region_1		kcsan_bus_space_set_region_1
#define	bus_space_set_region_stream_1	kcsan_bus_space_set_region_stream_1
#define	bus_space_copy_multi_1		kcsan_bus_space_copy_multi_1
#define	bus_space_copy_multi_stream_1	kcsan_bus_space_copy_multi_stream_1
#define	bus_space_poke_1		kcsan_bus_space_poke_1
#define	bus_space_peek_1		kcsan_bus_space_peek_1

#define	bus_space_read_2		kcsan_bus_space_read_2
#define	bus_space_read_stream_2		kcsan_bus_space_read_stream_2
#define	bus_space_read_multi_2		kcsan_bus_space_read_multi_2
#define	bus_space_read_multi_stream_2	kcsan_bus_space_read_multi_stream_2
#define	bus_space_read_region_2		kcsan_bus_space_read_region_2
#define	bus_space_read_region_stream_2	kcsan_bus_space_read_region_stream_2
#define	bus_space_write_2		kcsan_bus_space_write_2
#define	bus_space_write_stream_2	kcsan_bus_space_write_stream_2
#define	bus_space_write_multi_2		kcsan_bus_space_write_multi_2
#define	bus_space_write_multi_stream_2	kcsan_bus_space_write_multi_stream_2
#define	bus_space_write_region_2	kcsan_bus_space_write_region_2
#define	bus_space_write_region_stream_2	kcsan_bus_space_write_region_stream_2
#define	bus_space_set_multi_2		kcsan_bus_space_set_multi_2
#define	bus_space_set_multi_stream_2	kcsan_bus_space_set_multi_stream_2
#define	bus_space_set_region_2		kcsan_bus_space_set_region_2
#define	bus_space_set_region_stream_2	kcsan_bus_space_set_region_stream_2
#define	bus_space_copy_multi_2		kcsan_bus_space_copy_multi_2
#define	bus_space_copy_multi_stream_2	kcsan_bus_space_copy_multi_stream_2
#define	bus_space_poke_2		kcsan_bus_space_poke_2
#define	bus_space_peek_2		kcsan_bus_space_peek_2

#define	bus_space_read_4		kcsan_bus_space_read_4
#define	bus_space_read_stream_4		kcsan_bus_space_read_stream_4
#define	bus_space_read_multi_4		kcsan_bus_space_read_multi_4
#define	bus_space_read_multi_stream_4	kcsan_bus_space_read_multi_stream_4
#define	bus_space_read_region_4		kcsan_bus_space_read_region_4
#define	bus_space_read_region_stream_4	kcsan_bus_space_read_region_stream_4
#define	bus_space_write_4		kcsan_bus_space_write_4
#define	bus_space_write_stream_4	kcsan_bus_space_write_stream_4
#define	bus_space_write_multi_4		kcsan_bus_space_write_multi_4
#define	bus_space_write_multi_stream_4	kcsan_bus_space_write_multi_stream_4
#define	bus_space_write_region_4	kcsan_bus_space_write_region_4
#define	bus_space_write_region_stream_4	kcsan_bus_space_write_region_stream_4
#define	bus_space_set_multi_4		kcsan_bus_space_set_multi_4
#define	bus_space_set_multi_stream_4	kcsan_bus_space_set_multi_stream_4
#define	bus_space_set_region_4		kcsan_bus_space_set_region_4
#define	bus_space_set_region_stream_4	kcsan_bus_space_set_region_stream_4
#define	bus_space_copy_multi_4		kcsan_bus_space_copy_multi_4
#define	bus_space_copy_multi_stream_4	kcsan_bus_space_copy_multi_stream_4
#define	bus_space_poke_4		kcsan_bus_space_poke_4
#define	bus_space_peek_4		kcsan_bus_space_peek_4

#define	bus_space_read_8		kcsan_bus_space_read_8
#define	bus_space_read_stream_8		kcsan_bus_space_read_stream_8
#define	bus_space_read_multi_8		kcsan_bus_space_read_multi_8
#define	bus_space_read_multi_stream_8	kcsan_bus_space_read_multi_stream_8
#define	bus_space_read_region_8		kcsan_bus_space_read_region_8
#define	bus_space_read_region_stream_8	kcsan_bus_space_read_region_stream_8
#define	bus_space_write_8		kcsan_bus_space_write_8
#define	bus_space_write_stream_8	kcsan_bus_space_write_stream_8
#define	bus_space_write_multi_8		kcsan_bus_space_write_multi_8
#define	bus_space_write_multi_stream_8	kcsan_bus_space_write_multi_stream_8
#define	bus_space_write_region_8	kcsan_bus_space_write_region_8
#define	bus_space_write_region_stream_8	kcsan_bus_space_write_region_stream_8
#define	bus_space_set_multi_8		kcsan_bus_space_set_multi_8
#define	bus_space_set_multi_stream_8	kcsan_bus_space_set_multi_stream_8
#define	bus_space_set_region_8		kcsan_bus_space_set_region_8
#define	bus_space_set_region_stream_8	kcsan_bus_space_set_region_stream_8
#define	bus_space_copy_multi_8		kcsan_bus_space_copy_multi_8
#define	bus_space_copy_multi_stream_8	kcsan_bus_space_copy_multi_stream_8
#define	bus_space_poke_8		kcsan_bus_space_poke_8
#define	bus_space_peek_8		kcsan_bus_space_peek_8


#endif /* !KCSAN_RUNTIME */

#endif /* !_SYS__CSAN_BUS_H_ */