| @@ -1,14 +1,14 @@ | | | @@ -1,14 +1,14 @@ |
1 | /* $NetBSD: empb_bsm.c,v 1.4 2012/06/04 19:45:50 rkujawa Exp $ */ | | 1 | /* $NetBSD: empb_bsm.c,v 1.5 2012/06/27 18:53:03 rkujawa Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2012 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2012 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * This code is derived from software contributed to The NetBSD Foundation | | 7 | * This code is derived from software contributed to The NetBSD Foundation |
8 | * by Radoslaw Kujawa. | | 8 | * by Radoslaw Kujawa. |
9 | * | | 9 | * |
10 | * Redistribution and use in source and binary forms, with or without | | 10 | * Redistribution and use in source and binary forms, with or without |
11 | * modification, are permitted provided that the following conditions | | 11 | * modification, are permitted provided that the following conditions |
12 | * are met: | | 12 | * are met: |
13 | * 1. Redistributions of source code must retain the above copyright | | 13 | * 1. Redistributions of source code must retain the above copyright |
14 | * notice, this list of conditions and the following disclaimer. | | 14 | * notice, this list of conditions and the following disclaimer. |
| @@ -132,31 +132,28 @@ empb_bsm_init(void) | | | @@ -132,31 +132,28 @@ empb_bsm_init(void) |
132 | /* === common bus space methods === */ | | 132 | /* === common bus space methods === */ |
133 | | | 133 | |
134 | static int | | 134 | static int |
135 | empb_bsm(bus_space_tag_t space, bus_addr_t address, bus_size_t size, | | 135 | empb_bsm(bus_space_tag_t space, bus_addr_t address, bus_size_t size, |
136 | int flags, bus_space_handle_t *handlep) | | 136 | int flags, bus_space_handle_t *handlep) |
137 | { | | 137 | { |
138 | | | 138 | |
139 | /* Check for bridge driver softc. */ | | 139 | /* Check for bridge driver softc. */ |
140 | if (empb_sc==NULL) | | 140 | if (empb_sc==NULL) |
141 | if(empb_bsm_init() == false) | | 141 | if(empb_bsm_init() == false) |
142 | return -1; | | 142 | return -1; |
143 | | | 143 | |
144 | /* Fail miserably if the driver wants linear space. */ | | 144 | /* Fail miserably if the driver wants linear space. */ |
145 | if (flags & BUS_SPACE_MAP_LINEAR) | | 145 | if ( (flags & BUS_SPACE_MAP_LINEAR) && (size > 8*1024*1024)) |
146 | { | | 146 | aprint_error("empb: linear space mapping might not work\n"); |
147 | aprint_error("empb: linear space mapping not possible\n"); | | | |
148 | return -1; | | | |
149 | } | | | |
150 | | | 147 | |
151 | /* | | 148 | /* |
152 | * Just store the desired PCI bus address as handlep. Don't make things | | 149 | * Just store the desired PCI bus address as handlep. Don't make things |
153 | * more complicated than they need to be. | | 150 | * more complicated than they need to be. |
154 | */ | | 151 | */ |
155 | *handlep = address; | | 152 | *handlep = address; |
156 | | | 153 | |
157 | return 0; | | 154 | return 0; |
158 | } | | 155 | } |
159 | | | 156 | |
160 | static int | | 157 | static int |
161 | empb_bsms(bus_space_handle_t handle, | | 158 | empb_bsms(bus_space_handle_t handle, |
162 | bus_size_t offset, bus_size_t size, bus_space_handle_t *nhandlep) | | 159 | bus_size_t offset, bus_size_t size, bus_space_handle_t *nhandlep) |
| @@ -173,122 +170,127 @@ empb_bsu(bus_space_handle_t handle, bus_ | | | @@ -173,122 +170,127 @@ empb_bsu(bus_space_handle_t handle, bus_ |
173 | | | 170 | |
174 | /* === 8-bit methods === */ | | 171 | /* === 8-bit methods === */ |
175 | | | 172 | |
176 | static uint8_t | | 173 | static uint8_t |
177 | empb_bsr1(bus_space_handle_t handle, bus_size_t offset) | | 174 | empb_bsr1(bus_space_handle_t handle, bus_size_t offset) |
178 | { | | 175 | { |
179 | uint8_t *p; | | 176 | uint8_t *p; |
180 | uint8_t x; | | 177 | uint8_t x; |
181 | bus_addr_t wp; /* window position */ | | 178 | bus_addr_t wp; /* window position */ |
182 | | | 179 | |
183 | wp = empb_switch_window(empb_sc, handle); | | 180 | wp = empb_switch_window(empb_sc, handle); |
184 | | | 181 | |
185 | /* window address + (PCI mem address - window position) */ | | 182 | /* window address + (PCI mem address - window position) */ |
186 | p = (uint8_t*)((empb_sc->pci_mem_win_t->base) + (handle - wp)); | | 183 | p = (uint8_t*)((empb_sc->pci_mem_win_t->base) + (handle - wp) + offset); |
187 | x = *p; | | 184 | x = *p; |
188 | | | 185 | |
189 | return x; | | 186 | return x; |
190 | } | | 187 | } |
191 | | | 188 | |
192 | static void | | 189 | static void |
193 | empb_bsw1(bus_space_handle_t handle, bus_size_t offset, unsigned value) | | 190 | empb_bsw1(bus_space_handle_t handle, bus_size_t offset, unsigned value) |
194 | { | | 191 | { |
195 | uint8_t *p; | | 192 | uint8_t *p; |
196 | bus_addr_t wp; | | 193 | bus_addr_t wp; |
197 | | | 194 | |
198 | wp = empb_switch_window(empb_sc, handle); | | 195 | wp = empb_switch_window(empb_sc, handle); |
199 | p = (uint8_t*)((empb_sc->pci_mem_win_t->base) + (handle - wp)); | | 196 | p = (uint8_t*)((empb_sc->pci_mem_win_t->base) + (handle - wp) + offset); |
200 | *p = value; | | 197 | *p = value; |
201 | } | | 198 | } |
202 | | | 199 | |
203 | static void | | 200 | static void |
204 | empb_bsrm1(bus_space_handle_t handle, bus_size_t offset, u_int8_t *pointer, | | 201 | empb_bsrm1(bus_space_handle_t handle, bus_size_t offset, u_int8_t *pointer, |
205 | bus_size_t count) | | 202 | bus_size_t count) |
206 | { | | 203 | { |
207 | volatile uint8_t *p; | | 204 | volatile uint8_t *p; |
208 | bus_addr_t wp; | | 205 | bus_addr_t wp; |
209 | | | 206 | |
210 | wp = empb_switch_window(empb_sc, handle); | | 207 | wp = empb_switch_window(empb_sc, handle); |
211 | p = (volatile u_int8_t *)((empb_sc->pci_mem_win_t->base)+(handle - wp)); | | 208 | p = (volatile u_int8_t *) ((empb_sc->pci_mem_win_t->base) + |
| | | 209 | (handle - wp) + offset); |
212 | | | 210 | |
213 | while (count > 0) { | | 211 | while (count > 0) { |
214 | *pointer++ = *p; | | 212 | *pointer++ = *p; |
215 | amiga_bus_reorder_protect(); | | 213 | amiga_bus_reorder_protect(); |
216 | --count; | | 214 | --count; |
217 | } | | 215 | } |
218 | } | | 216 | } |
219 | | | 217 | |
220 | static void | | 218 | static void |
221 | empb_bswm1(bus_space_handle_t handle, bus_size_t offset, | | 219 | empb_bswm1(bus_space_handle_t handle, bus_size_t offset, |
222 | const u_int8_t *pointer, bus_size_t count) | | 220 | const u_int8_t *pointer, bus_size_t count) |
223 | { | | 221 | { |
224 | volatile uint8_t *p; | | 222 | volatile uint8_t *p; |
225 | bus_addr_t wp; | | 223 | bus_addr_t wp; |
226 | | | 224 | |
227 | wp = empb_switch_window(empb_sc, handle); | | 225 | wp = empb_switch_window(empb_sc, handle); |
228 | p = (volatile u_int8_t *)((empb_sc->pci_mem_win_t->base)+(handle - wp)); | | 226 | p = (volatile u_int8_t *) ((empb_sc->pci_mem_win_t->base) + |
| | | 227 | (handle - wp) + offset); |
229 | | | 228 | |
230 | while (count > 0) { | | 229 | while (count > 0) { |
231 | *p = *pointer++; | | 230 | *p = *pointer++; |
232 | amiga_bus_reorder_protect(); | | 231 | amiga_bus_reorder_protect(); |
233 | --count; | | 232 | --count; |
234 | } | | 233 | } |
235 | } | | 234 | } |
236 | | | 235 | |
237 | static void | | 236 | static void |
238 | empb_bsrr1(bus_space_handle_t handle, bus_size_t offset, u_int8_t *pointer, | | 237 | empb_bsrr1(bus_space_handle_t handle, bus_size_t offset, u_int8_t *pointer, |
239 | bus_size_t count) | | 238 | bus_size_t count) |
240 | { | | 239 | { |
241 | volatile uint8_t *p; | | 240 | volatile uint8_t *p; |
242 | bus_addr_t wp; | | 241 | bus_addr_t wp; |
243 | | | 242 | |
244 | wp = empb_switch_window(empb_sc, handle); | | 243 | wp = empb_switch_window(empb_sc, handle); |
245 | p = (volatile u_int8_t *)((empb_sc->pci_mem_win_t->base)+(handle - wp)); | | 244 | p = (volatile u_int8_t *) ((empb_sc->pci_mem_win_t->base) + |
| | | 245 | (handle - wp) + offset); |
246 | | | 246 | |
247 | while (count > 0) { | | 247 | while (count > 0) { |
248 | *pointer++ = *p; | | 248 | *pointer++ = *p; |
249 | amiga_bus_reorder_protect(); | | 249 | amiga_bus_reorder_protect(); |
250 | p++; | | 250 | p++; |
251 | --count; | | 251 | --count; |
252 | } | | 252 | } |
253 | } | | 253 | } |
254 | | | 254 | |
255 | static void | | 255 | static void |
256 | empb_bswr1(bus_space_handle_t handle, bus_size_t offset, | | 256 | empb_bswr1(bus_space_handle_t handle, bus_size_t offset, |
257 | const u_int8_t *pointer, bus_size_t count) | | 257 | const u_int8_t *pointer, bus_size_t count) |
258 | { | | 258 | { |
259 | volatile uint8_t *p; | | 259 | volatile uint8_t *p; |
260 | bus_addr_t wp; | | 260 | bus_addr_t wp; |
261 | | | 261 | |
262 | wp = empb_switch_window(empb_sc, handle); | | 262 | wp = empb_switch_window(empb_sc, handle); |
263 | p = (volatile u_int8_t *)((empb_sc->pci_mem_win_t->base)+(handle - wp)); | | 263 | p = (volatile u_int8_t *) ((empb_sc->pci_mem_win_t->base) + |
| | | 264 | (handle - wp) + offset); |
264 | | | 265 | |
265 | while (count > 0) { | | 266 | while (count > 0) { |
266 | *p = *pointer++; | | 267 | *p = *pointer++; |
267 | amiga_bus_reorder_protect(); | | 268 | amiga_bus_reorder_protect(); |
268 | p++; | | 269 | p++; |
269 | --count; | | 270 | --count; |
270 | } | | 271 | } |
271 | } | | 272 | } |
272 | | | 273 | |
273 | static void | | 274 | static void |
274 | empb_bssr1(bus_space_handle_t handle, bus_size_t offset, unsigned value, | | 275 | empb_bssr1(bus_space_handle_t handle, bus_size_t offset, unsigned value, |
275 | bus_size_t count) | | 276 | bus_size_t count) |
276 | { | | 277 | { |
277 | volatile uint8_t *p; | | 278 | volatile uint8_t *p; |
278 | bus_addr_t wp; | | 279 | bus_addr_t wp; |
279 | | | 280 | |
280 | wp = empb_switch_window(empb_sc, handle); | | 281 | wp = empb_switch_window(empb_sc, handle); |
281 | p = (volatile u_int8_t *)((empb_sc->pci_mem_win_t->base)+(handle - wp)); | | 282 | p = (volatile u_int8_t *) ((empb_sc->pci_mem_win_t->base) + |
| | | 283 | (handle - wp) + offset); |
282 | | | 284 | |
283 | while (count > 0) { | | 285 | while (count > 0) { |
284 | *p = value; | | 286 | *p = value; |
285 | amiga_bus_reorder_protect(); | | 287 | amiga_bus_reorder_protect(); |
286 | p++; | | 288 | p++; |
287 | --count; | | 289 | --count; |
288 | } | | 290 | } |
289 | } | | 291 | } |
290 | | | 292 | |
291 | /* XXX: this is broken, rewrite */ | | 293 | /* XXX: this is broken, rewrite */ |
292 | static void | | 294 | static void |
293 | empb_bscr1(bus_space_handle_t handlefrom, bus_size_t from, | | 295 | empb_bscr1(bus_space_handle_t handlefrom, bus_size_t from, |
294 | bus_space_handle_t handleto, bus_size_t to, bus_size_t count) | | 296 | bus_space_handle_t handleto, bus_size_t to, bus_size_t count) |
| @@ -312,224 +314,232 @@ empb_bscr1(bus_space_handle_t handlefrom | | | @@ -312,224 +314,232 @@ empb_bscr1(bus_space_handle_t handlefrom |
312 | } | | 314 | } |
313 | | | 315 | |
314 | /* === 16-bit methods === */ | | 316 | /* === 16-bit methods === */ |
315 | | | 317 | |
316 | static uint16_t | | 318 | static uint16_t |
317 | empb_bsr2(bus_space_handle_t handle, bus_size_t offset) | | 319 | empb_bsr2(bus_space_handle_t handle, bus_size_t offset) |
318 | { | | 320 | { |
319 | uint16_t *p; | | 321 | uint16_t *p; |
320 | uint16_t x; | | 322 | uint16_t x; |
321 | bus_addr_t wp; | | 323 | bus_addr_t wp; |
322 | | | 324 | |
323 | wp = empb_switch_window(empb_sc, handle); | | 325 | wp = empb_switch_window(empb_sc, handle); |
324 | | | 326 | |
325 | p = (uint16_t*)((empb_sc->pci_mem_win_t->base) + (handle - wp)); | | 327 | p = (uint16_t*) ((empb_sc->pci_mem_win_t->base) + (handle - wp) |
| | | 328 | + offset); |
326 | x = *p; | | 329 | x = *p; |
327 | | | 330 | |
328 | return x; | | 331 | return x; |
329 | } | | 332 | } |
330 | | | 333 | |
331 | static uint16_t | | 334 | static uint16_t |
332 | empb_bsr2_swap(bus_space_handle_t handle, bus_size_t offset) | | 335 | empb_bsr2_swap(bus_space_handle_t handle, bus_size_t offset) |
333 | { | | 336 | { |
334 | uint16_t *p; | | 337 | uint16_t *p; |
335 | uint16_t x; | | 338 | uint16_t x; |
336 | bus_addr_t wp; | | 339 | bus_addr_t wp; |
337 | | | 340 | |
338 | wp = empb_switch_window(empb_sc, handle); | | 341 | wp = empb_switch_window(empb_sc, handle); |
339 | | | 342 | |
340 | p = (uint16_t*)((empb_sc->pci_mem_win_t->base) + (handle - wp)); | | 343 | p = (uint16_t*) ((empb_sc->pci_mem_win_t->base) + (handle - wp) |
| | | 344 | + offset); |
341 | x = *p; | | 345 | x = *p; |
342 | | | 346 | |
343 | return bswap16(x); | | 347 | return bswap16(x); |
344 | } | | 348 | } |
345 | | | 349 | |
346 | | | 350 | |
347 | static void | | 351 | static void |
348 | empb_bsw2(bus_space_handle_t handle, bus_size_t offset, unsigned value) | | 352 | empb_bsw2(bus_space_handle_t handle, bus_size_t offset, unsigned value) |
349 | { | | 353 | { |
350 | uint16_t *p; | | 354 | uint16_t *p; |
351 | bus_addr_t wp; | | 355 | bus_addr_t wp; |
352 | | | 356 | |
353 | wp = empb_switch_window(empb_sc, handle); | | 357 | wp = empb_switch_window(empb_sc, handle); |
354 | p = (uint16_t*)((empb_sc->pci_mem_win_t->base) + (handle - wp)); | | 358 | p = (uint16_t*)((empb_sc->pci_mem_win_t->base) + (handle - wp) |
| | | 359 | + offset); |
355 | *p = value; | | 360 | *p = value; |
356 | } | | 361 | } |
357 | | | 362 | |
358 | static void | | 363 | static void |
359 | empb_bsw2_swap(bus_space_handle_t handle, bus_size_t offset, unsigned value) | | 364 | empb_bsw2_swap(bus_space_handle_t handle, bus_size_t offset, unsigned value) |
360 | { | | 365 | { |
361 | uint16_t *p; | | 366 | uint16_t *p; |
362 | bus_addr_t wp; | | 367 | bus_addr_t wp; |
363 | | | 368 | |
364 | wp = empb_switch_window(empb_sc, handle); | | 369 | wp = empb_switch_window(empb_sc, handle); |
365 | p = (uint16_t*)((empb_sc->pci_mem_win_t->base) + (handle - wp)); | | 370 | p = (uint16_t*)((empb_sc->pci_mem_win_t->base) + (handle - wp) |
| | | 371 | + offset); |
366 | *p = bswap16(value); | | 372 | *p = bswap16(value); |
367 | } | | 373 | } |
368 | | | 374 | |
369 | static void | | 375 | static void |
370 | empb_bsrm2(bus_space_handle_t handle, bus_size_t offset, u_int16_t *pointer, | | 376 | empb_bsrm2(bus_space_handle_t handle, bus_size_t offset, u_int16_t *pointer, |
371 | bus_size_t count) | | 377 | bus_size_t count) |
372 | { | | 378 | { |
373 | volatile uint16_t *p; | | 379 | volatile uint16_t *p; |
374 | bus_addr_t wp; | | 380 | bus_addr_t wp; |
375 | | | 381 | |
376 | wp = empb_switch_window(empb_sc, handle); | | 382 | wp = empb_switch_window(empb_sc, handle); |
377 | p = (volatile uint16_t *) ((empb_sc->pci_mem_win_t->base) + | | 383 | p = (volatile uint16_t *) ((empb_sc->pci_mem_win_t->base) + |
378 | (handle - wp)); | | 384 | (handle - wp) + offset); |
379 | | | 385 | |
380 | while (count > 0) { | | 386 | while (count > 0) { |
381 | *pointer++ = *p; | | 387 | *pointer++ = *p; |
382 | amiga_bus_reorder_protect(); | | 388 | amiga_bus_reorder_protect(); |
383 | --count; | | 389 | --count; |
384 | } | | 390 | } |
385 | } | | 391 | } |
386 | | | 392 | |
387 | static void | | 393 | static void |
388 | empb_bsrm2_swap(bus_space_handle_t handle, bus_size_t offset, | | 394 | empb_bsrm2_swap(bus_space_handle_t handle, bus_size_t offset, |
389 | u_int16_t *pointer, bus_size_t count) | | 395 | u_int16_t *pointer, bus_size_t count) |
390 | { | | 396 | { |
391 | volatile uint16_t *p; | | 397 | volatile uint16_t *p; |
392 | bus_addr_t wp; | | 398 | bus_addr_t wp; |
393 | | | 399 | |
394 | wp = empb_switch_window(empb_sc, handle); | | 400 | wp = empb_switch_window(empb_sc, handle); |
395 | p = (volatile uint16_t *) ((empb_sc->pci_mem_win_t->base) + | | 401 | p = (volatile uint16_t *) ((empb_sc->pci_mem_win_t->base) + |
396 | (handle - wp)); | | 402 | (handle - wp) + offset); |
397 | | | 403 | |
398 | while (count > 0) { | | 404 | while (count > 0) { |
399 | *pointer++ = bswap16(*p); | | 405 | *pointer++ = bswap16(*p); |
400 | amiga_bus_reorder_protect(); | | 406 | amiga_bus_reorder_protect(); |
401 | --count; | | 407 | --count; |
402 | } | | 408 | } |
403 | } | | 409 | } |
404 | | | 410 | |
405 | static void | | 411 | static void |
406 | empb_bswm2(bus_space_handle_t handle, bus_size_t offset, | | 412 | empb_bswm2(bus_space_handle_t handle, bus_size_t offset, |
407 | const u_int16_t *pointer, bus_size_t count) | | 413 | const u_int16_t *pointer, bus_size_t count) |
408 | { | | 414 | { |
409 | volatile uint16_t *p; | | 415 | volatile uint16_t *p; |
410 | bus_addr_t wp; | | 416 | bus_addr_t wp; |
411 | | | 417 | |
412 | wp = empb_switch_window(empb_sc, handle); | | 418 | wp = empb_switch_window(empb_sc, handle); |
413 | p = (volatile uint16_t *) ((empb_sc->pci_mem_win_t->base) + | | 419 | p = (volatile uint16_t *) ((empb_sc->pci_mem_win_t->base) + |
414 | (handle - wp)); | | 420 | (handle - wp) + offset); |
415 | | | 421 | |
416 | while (count > 0) { | | 422 | while (count > 0) { |
417 | *p = *pointer++; | | 423 | *p = *pointer++; |
418 | amiga_bus_reorder_protect(); | | 424 | amiga_bus_reorder_protect(); |
419 | --count; | | 425 | --count; |
420 | } | | 426 | } |
421 | } | | 427 | } |
422 | | | 428 | |
423 | static void | | 429 | static void |
424 | empb_bswm2_swap(bus_space_handle_t handle, bus_size_t offset, | | 430 | empb_bswm2_swap(bus_space_handle_t handle, bus_size_t offset, |
425 | const u_int16_t *pointer, bus_size_t count) | | 431 | const u_int16_t *pointer, bus_size_t count) |
426 | { | | 432 | { |
427 | volatile uint16_t *p; | | 433 | volatile uint16_t *p; |
428 | bus_addr_t wp; | | 434 | bus_addr_t wp; |
429 | | | 435 | |
430 | wp = empb_switch_window(empb_sc, handle); | | 436 | wp = empb_switch_window(empb_sc, handle); |
431 | p = (volatile uint16_t *) ((empb_sc->pci_mem_win_t->base) + | | 437 | p = (volatile uint16_t *) ((empb_sc->pci_mem_win_t->base) + |
432 | (handle - wp)); | | 438 | (handle - wp) + offset); |
433 | | | 439 | |
434 | while (count > 0) { | | 440 | while (count > 0) { |
435 | *p = bswap16(*pointer++); | | 441 | *p = bswap16(*pointer++); |
436 | amiga_bus_reorder_protect(); | | 442 | amiga_bus_reorder_protect(); |
437 | --count; | | 443 | --count; |
438 | } | | 444 | } |
439 | } | | 445 | } |
440 | | | 446 | |
441 | static void | | 447 | static void |
442 | empb_bsrr2(bus_space_handle_t handle, bus_size_t offset, u_int16_t *pointer, | | 448 | empb_bsrr2(bus_space_handle_t handle, bus_size_t offset, u_int16_t *pointer, |
443 | bus_size_t count) | | 449 | bus_size_t count) |
444 | { | | 450 | { |
445 | volatile uint16_t *p; | | 451 | volatile uint16_t *p; |
446 | bus_addr_t wp; | | 452 | bus_addr_t wp; |
447 | | | 453 | |
448 | wp = empb_switch_window(empb_sc, handle); | | 454 | wp = empb_switch_window(empb_sc, handle); |
449 | p = (volatile uint16_t *)((empb_sc->pci_mem_win_t->base)+(handle - wp)); | | 455 | p = (volatile uint16_t *) ((empb_sc->pci_mem_win_t->base) + |
| | | 456 | (handle - wp) + offset); |
450 | | | 457 | |
451 | while (count > 0) { | | 458 | while (count > 0) { |
452 | *pointer++ = *p; | | 459 | *pointer++ = *p; |
453 | amiga_bus_reorder_protect(); | | 460 | amiga_bus_reorder_protect(); |
454 | p++; | | 461 | p++; |
455 | --count; | | 462 | --count; |
456 | } | | 463 | } |
457 | } | | 464 | } |
458 | | | 465 | |
459 | static void | | 466 | static void |
460 | empb_bsrr2_swap(bus_space_handle_t handle, bus_size_t offset, | | 467 | empb_bsrr2_swap(bus_space_handle_t handle, bus_size_t offset, |
461 | u_int16_t *pointer, bus_size_t count) | | 468 | u_int16_t *pointer, bus_size_t count) |
462 | { | | 469 | { |
463 | volatile uint16_t *p; | | 470 | volatile uint16_t *p; |
464 | bus_addr_t wp; | | 471 | bus_addr_t wp; |
465 | | | 472 | |
466 | wp = empb_switch_window(empb_sc, handle); | | 473 | wp = empb_switch_window(empb_sc, handle); |
467 | p = (volatile uint16_t *)((empb_sc->pci_mem_win_t->base)+(handle - wp)); | | 474 | p = (volatile uint16_t *) ((empb_sc->pci_mem_win_t->base) + |
| | | 475 | (handle - wp) + offset); |
468 | | | 476 | |
469 | while (count > 0) { | | 477 | while (count > 0) { |
470 | *pointer++ = bswap16(*p); | | 478 | *pointer++ = bswap16(*p); |
471 | amiga_bus_reorder_protect(); | | 479 | amiga_bus_reorder_protect(); |
472 | p++; | | 480 | p++; |
473 | --count; | | 481 | --count; |
474 | } | | 482 | } |
475 | } | | 483 | } |
476 | | | 484 | |
477 | static void | | 485 | static void |
478 | empb_bssr2_swap(bus_space_handle_t handle, bus_size_t offset, unsigned value, | | 486 | empb_bssr2_swap(bus_space_handle_t handle, bus_size_t offset, unsigned value, |
479 | bus_size_t count) | | 487 | bus_size_t count) |
480 | { | | 488 | { |
481 | volatile uint16_t *p; | | 489 | volatile uint16_t *p; |
482 | bus_addr_t wp; | | 490 | bus_addr_t wp; |
483 | | | 491 | |
484 | wp = empb_switch_window(empb_sc, handle); | | 492 | wp = empb_switch_window(empb_sc, handle); |
485 | p = (volatile uint16_t *) ((empb_sc->pci_mem_win_t->base) + | | 493 | p = (volatile uint16_t *) ((empb_sc->pci_mem_win_t->base) + |
486 | (handle - wp)); | | 494 | (handle - wp) + offset); |
487 | | | 495 | |
488 | while (count > 0) { | | 496 | while (count > 0) { |
489 | *p = bswap16(value); | | 497 | *p = bswap16(value); |
490 | amiga_bus_reorder_protect(); | | 498 | amiga_bus_reorder_protect(); |
491 | p++; | | 499 | p++; |
492 | --count; | | 500 | --count; |
493 | } | | 501 | } |
494 | } | | 502 | } |
495 | | | 503 | |
496 | static void | | 504 | static void |
497 | empb_bswr2(bus_space_handle_t handle, bus_size_t offset, | | 505 | empb_bswr2(bus_space_handle_t handle, bus_size_t offset, |
498 | const u_int16_t *pointer, bus_size_t count) | | 506 | const u_int16_t *pointer, bus_size_t count) |
499 | { | | 507 | { |
500 | volatile uint16_t *p; | | 508 | volatile uint16_t *p; |
501 | bus_addr_t wp; | | 509 | bus_addr_t wp; |
502 | | | 510 | |
503 | wp = empb_switch_window(empb_sc, handle); | | 511 | wp = empb_switch_window(empb_sc, handle); |
504 | p = (volatile u_int16_t *)((empb_sc->pci_mem_win_t->base)+(handle - wp)); | | 512 | p = (volatile u_int16_t *) ((empb_sc->pci_mem_win_t->base) + |
| | | 513 | (handle - wp) + offset); |
505 | | | 514 | |
506 | while (count > 0) { | | 515 | while (count > 0) { |
507 | *p = *pointer++; | | 516 | *p = *pointer++; |
508 | amiga_bus_reorder_protect(); | | 517 | amiga_bus_reorder_protect(); |
509 | p++; | | 518 | p++; |
510 | --count; | | 519 | --count; |
511 | } | | 520 | } |
512 | } | | 521 | } |
513 | | | 522 | |
514 | static void | | 523 | static void |
515 | empb_bswr2_swap(bus_space_handle_t handle, bus_size_t offset, | | 524 | empb_bswr2_swap(bus_space_handle_t handle, bus_size_t offset, |
516 | const u_int16_t *pointer, bus_size_t count) | | 525 | const u_int16_t *pointer, bus_size_t count) |
517 | { | | 526 | { |
518 | volatile uint16_t *p; | | 527 | volatile uint16_t *p; |
519 | bus_addr_t wp; | | 528 | bus_addr_t wp; |
520 | | | 529 | |
521 | wp = empb_switch_window(empb_sc, handle); | | 530 | wp = empb_switch_window(empb_sc, handle); |
522 | p = (volatile u_int16_t *)((empb_sc->pci_mem_win_t->base)+(handle - wp)); | | 531 | p = (volatile u_int16_t *) ((empb_sc->pci_mem_win_t->base) |
| | | 532 | + (handle - wp) + offset); |
523 | | | 533 | |
524 | while (count > 0) { | | 534 | while (count > 0) { |
525 | *p = bswap16(*pointer++); | | 535 | *p = bswap16(*pointer++); |
526 | amiga_bus_reorder_protect(); | | 536 | amiga_bus_reorder_protect(); |
527 | p++; | | 537 | p++; |
528 | --count; | | 538 | --count; |
529 | } | | 539 | } |
530 | } | | 540 | } |
531 | | | 541 | |
532 | /* XXX: this is broken, rewrite, XXX 2: should we swap here? */ | | 542 | /* XXX: this is broken, rewrite, XXX 2: should we swap here? */ |
533 | static void | | 543 | static void |
534 | empb_bscr2(bus_space_handle_t handlefrom, bus_size_t from, | | 544 | empb_bscr2(bus_space_handle_t handlefrom, bus_size_t from, |
535 | bus_space_handle_t handleto, bus_size_t to, bus_size_t count) | | 545 | bus_space_handle_t handleto, bus_size_t to, bus_size_t count) |
| @@ -553,224 +563,232 @@ empb_bscr2(bus_space_handle_t handlefrom | | | @@ -553,224 +563,232 @@ empb_bscr2(bus_space_handle_t handlefrom |
553 | } | | 563 | } |
554 | | | 564 | |
555 | /* === 32-bit methods === */ | | 565 | /* === 32-bit methods === */ |
556 | | | 566 | |
557 | static uint32_t | | 567 | static uint32_t |
558 | empb_bsr4(bus_space_handle_t handle, bus_size_t offset) | | 568 | empb_bsr4(bus_space_handle_t handle, bus_size_t offset) |
559 | { | | 569 | { |
560 | uint32_t *p; | | 570 | uint32_t *p; |
561 | uint32_t x; | | 571 | uint32_t x; |
562 | bus_addr_t wp; | | 572 | bus_addr_t wp; |
563 | | | 573 | |
564 | wp = empb_switch_window(empb_sc, handle); | | 574 | wp = empb_switch_window(empb_sc, handle); |
565 | | | 575 | |
566 | p = (uint32_t*)((empb_sc->pci_mem_win_t->base) + (handle - wp)); | | 576 | p = (uint32_t*) ((empb_sc->pci_mem_win_t->base) |
| | | 577 | + (handle - wp) + offset); |
567 | x = *p; | | 578 | x = *p; |
568 | | | 579 | |
569 | return x; | | 580 | return x; |
570 | } | | 581 | } |
571 | | | 582 | |
572 | static uint32_t | | 583 | static uint32_t |
573 | empb_bsr4_swap(bus_space_handle_t handle, bus_size_t offset) | | 584 | empb_bsr4_swap(bus_space_handle_t handle, bus_size_t offset) |
574 | { | | 585 | { |
575 | uint32_t *p; | | 586 | uint32_t *p; |
576 | uint32_t x; | | 587 | uint32_t x; |
577 | bus_addr_t wp; | | 588 | bus_addr_t wp; |
578 | | | 589 | |
579 | wp = empb_switch_window(empb_sc, handle); | | 590 | wp = empb_switch_window(empb_sc, handle); |
580 | | | 591 | |
581 | p = (uint32_t*)((empb_sc->pci_mem_win_t->base) + (handle - wp)); | | 592 | p = (uint32_t*) ((empb_sc->pci_mem_win_t->base) + (handle - wp) |
| | | 593 | + offset); |
582 | x = *p; | | 594 | x = *p; |
583 | | | 595 | |
584 | return bswap32(x); | | 596 | return bswap32(x); |
585 | } | | 597 | } |
586 | | | 598 | |
587 | | | 599 | |
588 | static void | | 600 | static void |
589 | empb_bsw4(bus_space_handle_t handle, bus_size_t offset, unsigned value) | | 601 | empb_bsw4(bus_space_handle_t handle, bus_size_t offset, unsigned value) |
590 | { | | 602 | { |
591 | uint32_t *p; | | 603 | uint32_t *p; |
592 | bus_addr_t wp; | | 604 | bus_addr_t wp; |
593 | | | 605 | |
594 | wp = empb_switch_window(empb_sc, handle); | | 606 | wp = empb_switch_window(empb_sc, handle); |
595 | p = (uint32_t*)((empb_sc->pci_mem_win_t->base) + (handle - wp)); | | 607 | p = (uint32_t*)((empb_sc->pci_mem_win_t->base) + (handle - wp) |
| | | 608 | + offset); |
596 | *p = value; | | 609 | *p = value; |
597 | } | | 610 | } |
598 | | | 611 | |
599 | static void | | 612 | static void |
600 | empb_bsw4_swap(bus_space_handle_t handle, bus_size_t offset, unsigned value) | | 613 | empb_bsw4_swap(bus_space_handle_t handle, bus_size_t offset, unsigned value) |
601 | { | | 614 | { |
602 | uint32_t *p; | | 615 | uint32_t *p; |
603 | bus_addr_t wp; | | 616 | bus_addr_t wp; |
604 | | | 617 | |
605 | wp = empb_switch_window(empb_sc, handle); | | 618 | wp = empb_switch_window(empb_sc, handle); |
606 | p = (uint32_t*)((empb_sc->pci_mem_win_t->base) + (handle - wp)); | | 619 | p = (uint32_t*)((empb_sc->pci_mem_win_t->base) + (handle - wp) |
| | | 620 | + offset); |
607 | *p = bswap32(value); | | 621 | *p = bswap32(value); |
608 | } | | 622 | } |
609 | | | 623 | |
610 | static void | | 624 | static void |
611 | empb_bsrm4(bus_space_handle_t handle, bus_size_t offset, u_int32_t *pointer, | | 625 | empb_bsrm4(bus_space_handle_t handle, bus_size_t offset, u_int32_t *pointer, |
612 | bus_size_t count) | | 626 | bus_size_t count) |
613 | { | | 627 | { |
614 | volatile uint32_t *p; | | 628 | volatile uint32_t *p; |
615 | bus_addr_t wp; | | 629 | bus_addr_t wp; |
616 | | | 630 | |
617 | wp = empb_switch_window(empb_sc, handle); | | 631 | wp = empb_switch_window(empb_sc, handle); |
618 | p = (volatile uint32_t *) ((empb_sc->pci_mem_win_t->base) + | | 632 | p = (volatile uint32_t *) ((empb_sc->pci_mem_win_t->base) + |
619 | (handle - wp)); | | 633 | (handle - wp) + offset); |
620 | | | 634 | |
621 | while (count > 0) { | | 635 | while (count > 0) { |
622 | *pointer++ = *p; | | 636 | *pointer++ = *p; |
623 | amiga_bus_reorder_protect(); | | 637 | amiga_bus_reorder_protect(); |
624 | --count; | | 638 | --count; |
625 | } | | 639 | } |
626 | } | | 640 | } |
627 | | | 641 | |
628 | static void | | 642 | static void |
629 | empb_bsrm4_swap(bus_space_handle_t handle, bus_size_t offset, | | 643 | empb_bsrm4_swap(bus_space_handle_t handle, bus_size_t offset, |
630 | u_int32_t *pointer, bus_size_t count) | | 644 | u_int32_t *pointer, bus_size_t count) |
631 | { | | 645 | { |
632 | volatile uint32_t *p; | | 646 | volatile uint32_t *p; |
633 | bus_addr_t wp; | | 647 | bus_addr_t wp; |
634 | | | 648 | |
635 | wp = empb_switch_window(empb_sc, handle); | | 649 | wp = empb_switch_window(empb_sc, handle); |
636 | p = (volatile uint32_t *) ((empb_sc->pci_mem_win_t->base) + | | 650 | p = (volatile uint32_t *) ((empb_sc->pci_mem_win_t->base) + |
637 | (handle - wp)); | | 651 | (handle - wp) + offset); |
638 | | | 652 | |
639 | while (count > 0) { | | 653 | while (count > 0) { |
640 | *pointer++ = bswap32(*p); | | 654 | *pointer++ = bswap32(*p); |
641 | amiga_bus_reorder_protect(); | | 655 | amiga_bus_reorder_protect(); |
642 | --count; | | 656 | --count; |
643 | } | | 657 | } |
644 | } | | 658 | } |
645 | | | 659 | |
646 | static void | | 660 | static void |
647 | empb_bswm4(bus_space_handle_t handle, bus_size_t offset, | | 661 | empb_bswm4(bus_space_handle_t handle, bus_size_t offset, |
648 | const u_int32_t *pointer, bus_size_t count) | | 662 | const u_int32_t *pointer, bus_size_t count) |
649 | { | | 663 | { |
650 | volatile uint32_t *p; | | 664 | volatile uint32_t *p; |
651 | bus_addr_t wp; | | 665 | bus_addr_t wp; |
652 | | | 666 | |
653 | wp = empb_switch_window(empb_sc, handle); | | 667 | wp = empb_switch_window(empb_sc, handle); |
654 | p = (volatile uint32_t *) ((empb_sc->pci_mem_win_t->base) + | | 668 | p = (volatile uint32_t *) ((empb_sc->pci_mem_win_t->base) + |
655 | (handle - wp)); | | 669 | (handle - wp) + offset); |
656 | | | 670 | |
657 | while (count > 0) { | | 671 | while (count > 0) { |
658 | *p = *pointer++; | | 672 | *p = *pointer++; |
659 | amiga_bus_reorder_protect(); | | 673 | amiga_bus_reorder_protect(); |
660 | --count; | | 674 | --count; |
661 | } | | 675 | } |
662 | } | | 676 | } |
663 | | | 677 | |
664 | static void | | 678 | static void |
665 | empb_bswm4_swap(bus_space_handle_t handle, bus_size_t offset, | | 679 | empb_bswm4_swap(bus_space_handle_t handle, bus_size_t offset, |
666 | const u_int32_t *pointer, bus_size_t count) | | 680 | const u_int32_t *pointer, bus_size_t count) |
667 | { | | 681 | { |
668 | volatile uint32_t *p; | | 682 | volatile uint32_t *p; |
669 | bus_addr_t wp; | | 683 | bus_addr_t wp; |
670 | | | 684 | |
671 | wp = empb_switch_window(empb_sc, handle); | | 685 | wp = empb_switch_window(empb_sc, handle); |
672 | p = (volatile uint32_t *) ((empb_sc->pci_mem_win_t->base) + | | 686 | p = (volatile uint32_t *) ((empb_sc->pci_mem_win_t->base) + |
673 | (handle - wp)); | | 687 | (handle - wp) + offset); |
674 | | | 688 | |
675 | while (count > 0) { | | 689 | while (count > 0) { |
676 | *p = bswap32(*pointer++); | | 690 | *p = bswap32(*pointer++); |
677 | amiga_bus_reorder_protect(); | | 691 | amiga_bus_reorder_protect(); |
678 | --count; | | 692 | --count; |
679 | } | | 693 | } |
680 | } | | 694 | } |
681 | | | 695 | |
682 | static void | | 696 | static void |
683 | empb_bsrr4(bus_space_handle_t handle, bus_size_t offset, u_int32_t *pointer, | | 697 | empb_bsrr4(bus_space_handle_t handle, bus_size_t offset, u_int32_t *pointer, |
684 | bus_size_t count) | | 698 | bus_size_t count) |
685 | { | | 699 | { |
686 | volatile uint32_t *p; | | 700 | volatile uint32_t *p; |
687 | bus_addr_t wp; | | 701 | bus_addr_t wp; |
688 | | | 702 | |
689 | wp = empb_switch_window(empb_sc, handle); | | 703 | wp = empb_switch_window(empb_sc, handle); |
690 | p = (volatile uint32_t *)((empb_sc->pci_mem_win_t->base)+(handle - wp)); | | 704 | p = (volatile uint32_t *) ((empb_sc->pci_mem_win_t->base) + |
| | | 705 | (handle - wp) + offset); |
691 | | | 706 | |
692 | while (count > 0) { | | 707 | while (count > 0) { |
693 | *pointer++ = *p; | | 708 | *pointer++ = *p; |
694 | amiga_bus_reorder_protect(); | | 709 | amiga_bus_reorder_protect(); |
695 | p++; | | 710 | p++; |
696 | --count; | | 711 | --count; |
697 | } | | 712 | } |
698 | } | | 713 | } |
699 | | | 714 | |
700 | static void | | 715 | static void |
701 | empb_bsrr4_swap(bus_space_handle_t handle, bus_size_t offset, | | 716 | empb_bsrr4_swap(bus_space_handle_t handle, bus_size_t offset, |
702 | u_int32_t *pointer, bus_size_t count) | | 717 | u_int32_t *pointer, bus_size_t count) |
703 | { | | 718 | { |
704 | volatile uint32_t *p; | | 719 | volatile uint32_t *p; |
705 | bus_addr_t wp; | | 720 | bus_addr_t wp; |
706 | | | 721 | |
707 | wp = empb_switch_window(empb_sc, handle); | | 722 | wp = empb_switch_window(empb_sc, handle); |
708 | p = (volatile uint32_t *)((empb_sc->pci_mem_win_t->base)+(handle - wp)); | | 723 | p = (volatile uint32_t *) ((empb_sc->pci_mem_win_t->base) |
| | | 724 | + (handle - wp) + offset); |
709 | | | 725 | |
710 | while (count > 0) { | | 726 | while (count > 0) { |
711 | *pointer++ = bswap32(*p); | | 727 | *pointer++ = bswap32(*p); |
712 | amiga_bus_reorder_protect(); | | 728 | amiga_bus_reorder_protect(); |
713 | p++; | | 729 | p++; |
714 | --count; | | 730 | --count; |
715 | } | | 731 | } |
716 | } | | 732 | } |
717 | | | 733 | |
718 | static void | | 734 | static void |
719 | empb_bssr4_swap(bus_space_handle_t handle, bus_size_t offset, unsigned value, | | 735 | empb_bssr4_swap(bus_space_handle_t handle, bus_size_t offset, unsigned value, |
720 | bus_size_t count) | | 736 | bus_size_t count) |
721 | { | | 737 | { |
722 | volatile uint32_t *p; | | 738 | volatile uint32_t *p; |
723 | bus_addr_t wp; | | 739 | bus_addr_t wp; |
724 | | | 740 | |
725 | wp = empb_switch_window(empb_sc, handle); | | 741 | wp = empb_switch_window(empb_sc, handle); |
726 | p = (volatile uint32_t *) ((empb_sc->pci_mem_win_t->base) + | | 742 | p = (volatile uint32_t *) ((empb_sc->pci_mem_win_t->base) + |
727 | (handle - wp)); | | 743 | (handle - wp) + offset); |
728 | | | 744 | |
729 | while (count > 0) { | | 745 | while (count > 0) { |
730 | *p = bswap32(value); | | 746 | *p = bswap32(value); |
731 | amiga_bus_reorder_protect(); | | 747 | amiga_bus_reorder_protect(); |
732 | p++; | | 748 | p++; |
733 | --count; | | 749 | --count; |
734 | } | | 750 | } |
735 | } | | 751 | } |
736 | | | 752 | |
737 | static void | | 753 | static void |
738 | empb_bswr4(bus_space_handle_t handle, bus_size_t offset, | | 754 | empb_bswr4(bus_space_handle_t handle, bus_size_t offset, |
739 | const u_int32_t *pointer, bus_size_t count) | | 755 | const u_int32_t *pointer, bus_size_t count) |
740 | { | | 756 | { |
741 | volatile uint32_t *p; | | 757 | volatile uint32_t *p; |
742 | bus_addr_t wp; | | 758 | bus_addr_t wp; |
743 | | | 759 | |
744 | wp = empb_switch_window(empb_sc, handle); | | 760 | wp = empb_switch_window(empb_sc, handle); |
745 | p = (volatile uint32_t *)((empb_sc->pci_mem_win_t->base)+(handle - wp)); | | 761 | p = (volatile uint32_t *) ((empb_sc->pci_mem_win_t->base) |
| | | 762 | + (handle - wp) + offset); |
746 | | | 763 | |
747 | while (count > 0) { | | 764 | while (count > 0) { |
748 | *p = *pointer++; | | 765 | *p = *pointer++; |
749 | amiga_bus_reorder_protect(); | | 766 | amiga_bus_reorder_protect(); |
750 | p++; | | 767 | p++; |
751 | --count; | | 768 | --count; |
752 | } | | 769 | } |
753 | } | | 770 | } |
754 | | | 771 | |
755 | static void | | 772 | static void |
756 | empb_bswr4_swap(bus_space_handle_t handle, bus_size_t offset, | | 773 | empb_bswr4_swap(bus_space_handle_t handle, bus_size_t offset, |
757 | const u_int32_t *pointer, bus_size_t count) | | 774 | const u_int32_t *pointer, bus_size_t count) |
758 | { | | 775 | { |
759 | volatile uint32_t *p; | | 776 | volatile uint32_t *p; |
760 | bus_addr_t wp; | | 777 | bus_addr_t wp; |
761 | | | 778 | |
762 | wp = empb_switch_window(empb_sc, handle); | | 779 | wp = empb_switch_window(empb_sc, handle); |
763 | p = (volatile uint32_t *)((empb_sc->pci_mem_win_t->base)+(handle - wp)); | | 780 | p = (volatile uint32_t *) ((empb_sc->pci_mem_win_t->base) |
| | | 781 | + (handle - wp) + offset); |
764 | | | 782 | |
765 | while (count > 0) { | | 783 | while (count > 0) { |
766 | *p = bswap32(*pointer++); | | 784 | *p = bswap32(*pointer++); |
767 | amiga_bus_reorder_protect(); | | 785 | amiga_bus_reorder_protect(); |
768 | p++; | | 786 | p++; |
769 | --count; | | 787 | --count; |
770 | } | | 788 | } |
771 | } | | 789 | } |
772 | | | 790 | |
773 | /* XXX: this is broken, rewrite, XXX 2: should we swap here? */ | | 791 | /* XXX: this is broken, rewrite, XXX 2: should we swap here? */ |
774 | void | | 792 | void |
775 | empb_bscr4(bus_space_handle_t handlefrom, bus_size_t from, | | 793 | empb_bscr4(bus_space_handle_t handlefrom, bus_size_t from, |
776 | bus_space_handle_t handleto, bus_size_t to, bus_size_t count) | | 794 | bus_space_handle_t handleto, bus_size_t to, bus_size_t count) |
| @@ -832,17 +850,18 @@ const struct amiga_bus_space_methods emp | | | @@ -832,17 +850,18 @@ const struct amiga_bus_space_methods emp |
832 | .bsr4 = empb_bsr4_swap, | | 850 | .bsr4 = empb_bsr4_swap, |
833 | .bsw4 = empb_bsw4_swap, | | 851 | .bsw4 = empb_bsw4_swap, |
834 | .bsrs4 = empb_bsr4, | | 852 | .bsrs4 = empb_bsr4, |
835 | .bsws4 = empb_bsw4, | | 853 | .bsws4 = empb_bsw4, |
836 | .bsrm4 = empb_bsrm4_swap, | | 854 | .bsrm4 = empb_bsrm4_swap, |
837 | .bswm4 = empb_bswm4_swap, | | 855 | .bswm4 = empb_bswm4_swap, |
838 | .bsrms4 = empb_bsrm4, | | 856 | .bsrms4 = empb_bsrm4, |
839 | .bswms4 = empb_bswm4, | | 857 | .bswms4 = empb_bswm4, |
840 | .bsrr4 = empb_bsrr4_swap, | | 858 | .bsrr4 = empb_bsrr4_swap, |
841 | .bswr4 = empb_bswr4_swap, | | 859 | .bswr4 = empb_bswr4_swap, |
842 | .bsrrs4 = empb_bsrr4, | | 860 | .bsrrs4 = empb_bsrr4, |
843 | .bswrs4 = empb_bswr4, | | 861 | .bswrs4 = empb_bswr4, |
844 | .bssr4 = empb_bssr4_swap, | | 862 | .bssr4 = empb_bssr4_swap, |
845 | .bscr4 = empb_bscr4 /* swap? */ | | 863 | .bscr4 = empb_bscr4 /* swap? */ |
| | | 864 | |
846 | }; | | 865 | }; |
847 | | | 866 | |
848 | | | 867 | |