2 * Copyright (c) 2014 Andrew Turner
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 #include "opt_platform.h"
32 #include <sys/param.h>
33 __FBSDID("$FreeBSD$");
38 #include <machine/bus.h>
40 uint8_t generic_bs_r_1(void *, bus_space_handle_t, bus_size_t);
41 uint16_t generic_bs_r_2(void *, bus_space_handle_t, bus_size_t);
42 uint32_t generic_bs_r_4(void *, bus_space_handle_t, bus_size_t);
43 uint64_t generic_bs_r_8(void *, bus_space_handle_t, bus_size_t);
45 void generic_bs_rm_1(void *, bus_space_handle_t, bus_size_t, uint8_t *,
47 void generic_bs_rm_2(void *, bus_space_handle_t, bus_size_t, uint16_t *,
49 void generic_bs_rm_4(void *, bus_space_handle_t, bus_size_t, uint32_t *,
51 void generic_bs_rm_8(void *, bus_space_handle_t, bus_size_t, uint64_t *,
54 void generic_bs_rr_1(void *, bus_space_handle_t, bus_size_t, uint8_t *,
56 void generic_bs_rr_2(void *, bus_space_handle_t, bus_size_t, uint16_t *,
58 void generic_bs_rr_4(void *, bus_space_handle_t, bus_size_t, uint32_t *,
60 void generic_bs_rr_8(void *, bus_space_handle_t, bus_size_t, uint64_t *,
63 void generic_bs_w_1(void *, bus_space_handle_t, bus_size_t, uint8_t);
64 void generic_bs_w_2(void *, bus_space_handle_t, bus_size_t, uint16_t);
65 void generic_bs_w_4(void *, bus_space_handle_t, bus_size_t, uint32_t);
66 void generic_bs_w_8(void *, bus_space_handle_t, bus_size_t, uint64_t);
68 void generic_bs_wm_1(void *, bus_space_handle_t, bus_size_t, const uint8_t *,
70 void generic_bs_wm_2(void *, bus_space_handle_t, bus_size_t, const uint16_t *,
72 void generic_bs_wm_4(void *, bus_space_handle_t, bus_size_t, const uint32_t *,
74 void generic_bs_wm_8(void *, bus_space_handle_t, bus_size_t, const uint64_t *,
77 void generic_bs_wr_1(void *, bus_space_handle_t, bus_size_t, const uint8_t *,
79 void generic_bs_wr_2(void *, bus_space_handle_t, bus_size_t, const uint16_t *,
81 void generic_bs_wr_4(void *, bus_space_handle_t, bus_size_t, const uint32_t *,
83 void generic_bs_wr_8(void *, bus_space_handle_t, bus_size_t, const uint64_t *,
86 int generic_bs_peek_1(void *, bus_space_handle_t, bus_size_t , uint8_t *);
87 int generic_bs_peek_2(void *, bus_space_handle_t, bus_size_t , uint16_t *);
88 int generic_bs_peek_4(void *, bus_space_handle_t, bus_size_t , uint32_t *);
89 int generic_bs_peek_8(void *, bus_space_handle_t, bus_size_t , uint64_t *);
91 int generic_bs_poke_1(void *, bus_space_handle_t, bus_size_t, uint8_t);
92 int generic_bs_poke_2(void *, bus_space_handle_t, bus_size_t, uint16_t);
93 int generic_bs_poke_4(void *, bus_space_handle_t, bus_size_t, uint32_t);
94 int generic_bs_poke_8(void *, bus_space_handle_t, bus_size_t, uint64_t);
97 generic_bs_map(void *t, bus_addr_t bpa, bus_size_t size, int flags,
98 bus_space_handle_t *bshp)
102 va = pmap_mapdev(bpa, size);
105 *bshp = (bus_space_handle_t)va;
110 generic_bs_unmap(void *t, bus_space_handle_t bsh, bus_size_t size)
113 pmap_unmapdev(bsh, size);
117 generic_bs_barrier(void *t, bus_space_handle_t bsh, bus_size_t offset,
118 bus_size_t size, int flags)
123 generic_bs_subregion(void *t, bus_space_handle_t bsh, bus_size_t offset,
124 bus_size_t size, bus_space_handle_t *nbshp)
127 *nbshp = bsh + offset;
131 struct bus_space memmap_bus = {
135 /* mapping/unmapping */
136 .bs_map = generic_bs_map,
137 .bs_unmap = generic_bs_unmap,
138 .bs_subregion = generic_bs_subregion,
140 /* allocation/deallocation */
145 .bs_barrier = generic_bs_barrier,
148 .bs_r_1 = generic_bs_r_1,
149 .bs_r_2 = generic_bs_r_2,
150 .bs_r_4 = generic_bs_r_4,
151 .bs_r_8 = generic_bs_r_8,
154 .bs_rm_1 = generic_bs_rm_1,
155 .bs_rm_2 = generic_bs_rm_2,
156 .bs_rm_4 = generic_bs_rm_4,
157 .bs_rm_8 = generic_bs_rm_8,
160 .bs_rr_1 = generic_bs_rr_1,
161 .bs_rr_2 = generic_bs_rr_2,
162 .bs_rr_4 = generic_bs_rr_4,
163 .bs_rr_8 = generic_bs_rr_8,
166 .bs_w_1 = generic_bs_w_1,
167 .bs_w_2 = generic_bs_w_2,
168 .bs_w_4 = generic_bs_w_4,
169 .bs_w_8 = generic_bs_w_8,
172 .bs_wm_1 = generic_bs_wm_1,
173 .bs_wm_2 = generic_bs_wm_2,
174 .bs_wm_4 = generic_bs_wm_4,
175 .bs_wm_8 = generic_bs_wm_8,
178 .bs_wr_1 = generic_bs_wr_1,
179 .bs_wr_2 = generic_bs_wr_2,
180 .bs_wr_4 = generic_bs_wr_4,
181 .bs_wr_8 = generic_bs_wr_8,
201 /* read single stream */
207 /* read multiple stream */
208 .bs_rm_1_s = generic_bs_rm_1,
209 .bs_rm_2_s = generic_bs_rm_2,
210 .bs_rm_4_s = generic_bs_rm_4,
211 .bs_rm_8_s = generic_bs_rm_8,
213 /* read region stream */
219 /* write single stream */
225 /* write multiple stream */
226 .bs_wm_1_s = generic_bs_wm_1,
227 .bs_wm_2_s = generic_bs_wm_2,
228 .bs_wm_4_s = generic_bs_wm_4,
229 .bs_wm_8_s = generic_bs_wm_8,
231 /* write region stream */
238 .bs_peek_1 = generic_bs_peek_1,
239 .bs_peek_2 = generic_bs_peek_2,
240 .bs_peek_4 = generic_bs_peek_4,
241 .bs_peek_8 = generic_bs_peek_8,
244 .bs_poke_1 = generic_bs_poke_1,
245 .bs_poke_2 = generic_bs_poke_2,
246 .bs_poke_4 = generic_bs_poke_4,
247 .bs_poke_8 = generic_bs_poke_8,
251 bus_space_tag_t fdtbus_bs_tag = &memmap_bus;