Deleted Added
full compact
fwmem.c (124145) fwmem.c (127468)
1/*
2 * Copyright (c) 2002-2003
3 * Hidetoshi Shimokawa. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 */
35
1/*
2 * Copyright (c) 2002-2003
3 * Hidetoshi Shimokawa. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
33 *
34 */
35
36#ifdef __FreeBSD__
36#include <sys/cdefs.h>
37#include <sys/cdefs.h>
37__FBSDID("$FreeBSD: head/sys/dev/firewire/fwmem.c 124145 2004-01-05 14:21:18Z simokawa $");
38__FBSDID("$FreeBSD: head/sys/dev/firewire/fwmem.c 127468 2004-03-26 23:17:10Z simokawa $");
39#endif
38
39#include <sys/param.h>
40#include <sys/systm.h>
41#include <sys/types.h>
42
43#include <sys/kernel.h>
44#include <sys/malloc.h>
45#include <sys/conf.h>
46#include <sys/sysctl.h>
40
41#include <sys/param.h>
42#include <sys/systm.h>
43#include <sys/types.h>
44
45#include <sys/kernel.h>
46#include <sys/malloc.h>
47#include <sys/conf.h>
48#include <sys/sysctl.h>
47#if __FreeBSD_version < 500000
49#if defined(__DragonFly__) || __FreeBSD_version < 500000
48#include <sys/buf.h>
49#else
50#include <sys/bio.h>
51#endif
52
53#include <sys/bus.h>
54#include <machine/bus.h>
55
56#include <sys/signal.h>
57#include <sys/mman.h>
58#include <sys/ioccom.h>
59#include <sys/fcntl.h>
60
50#include <sys/buf.h>
51#else
52#include <sys/bio.h>
53#endif
54
55#include <sys/bus.h>
56#include <machine/bus.h>
57
58#include <sys/signal.h>
59#include <sys/mman.h>
60#include <sys/ioccom.h>
61#include <sys/fcntl.h>
62
63#ifdef __DragonFly__
64#include "firewire.h"
65#include "firewirereg.h"
66#include "fwmem.h"
67#else
61#include <dev/firewire/firewire.h>
62#include <dev/firewire/firewirereg.h>
63#include <dev/firewire/fwmem.h>
68#include <dev/firewire/firewire.h>
69#include <dev/firewire/firewirereg.h>
70#include <dev/firewire/fwmem.h>
71#endif
64
65static int fwmem_speed=2, fwmem_debug=0;
66static struct fw_eui64 fwmem_eui64;
67SYSCTL_DECL(_hw_firewire);
68SYSCTL_NODE(_hw_firewire, OID_AUTO, fwmem, CTLFLAG_RD, 0,
69 "FireWire Memory Access");
70SYSCTL_UINT(_hw_firewire_fwmem, OID_AUTO, eui64_hi, CTLFLAG_RW,
71 &fwmem_eui64.hi, 0, "Fwmem target EUI64 high");

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

281 if (fms == NULL)
282 return ENOMEM;
283 bcopy(&fwmem_eui64, &fms->eui, sizeof(struct fw_eui64));
284 dev->si_drv1 = (void *)fms;
285 dev->si_iosize_max = DFLTPHYS;
286 fms->refcount = 1;
287 }
288 if (fwmem_debug)
72
73static int fwmem_speed=2, fwmem_debug=0;
74static struct fw_eui64 fwmem_eui64;
75SYSCTL_DECL(_hw_firewire);
76SYSCTL_NODE(_hw_firewire, OID_AUTO, fwmem, CTLFLAG_RD, 0,
77 "FireWire Memory Access");
78SYSCTL_UINT(_hw_firewire_fwmem, OID_AUTO, eui64_hi, CTLFLAG_RW,
79 &fwmem_eui64.hi, 0, "Fwmem target EUI64 high");

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

289 if (fms == NULL)
290 return ENOMEM;
291 bcopy(&fwmem_eui64, &fms->eui, sizeof(struct fw_eui64));
292 dev->si_drv1 = (void *)fms;
293 dev->si_iosize_max = DFLTPHYS;
294 fms->refcount = 1;
295 }
296 if (fwmem_debug)
289 printf("%s: refcount=%d\n", __FUNCTION__, fms->refcount);
297 printf("%s: refcount=%d\n", __func__, fms->refcount);
290
291 return (0);
292}
293
294int
295fwmem_close (dev_t dev, int flags, int fmt, fw_proc *td)
296{
297 struct fwmem_softc *fms;
298
299 fms = (struct fwmem_softc *)dev->si_drv1;
300 fms->refcount --;
301 if (fwmem_debug)
298
299 return (0);
300}
301
302int
303fwmem_close (dev_t dev, int flags, int fmt, fw_proc *td)
304{
305 struct fwmem_softc *fms;
306
307 fms = (struct fwmem_softc *)dev->si_drv1;
308 fms->refcount --;
309 if (fwmem_debug)
302 printf("%s: refcount=%d\n", __FUNCTION__, fms->refcount);
310 printf("%s: refcount=%d\n", __func__, fms->refcount);
303 if (fms->refcount < 1) {
304 free(dev->si_drv1, M_FW);
305 dev->si_drv1 = NULL;
306 }
307
308 return (0);
309}
310
311
312static void
313fwmem_biodone(struct fw_xfer *xfer)
314{
315 struct bio *bp;
316
317 bp = (struct bio *)xfer->sc;
318 bp->bio_error = xfer->resp;
319
320 if (bp->bio_error != 0) {
321 if (fwmem_debug)
311 if (fms->refcount < 1) {
312 free(dev->si_drv1, M_FW);
313 dev->si_drv1 = NULL;
314 }
315
316 return (0);
317}
318
319
320static void
321fwmem_biodone(struct fw_xfer *xfer)
322{
323 struct bio *bp;
324
325 bp = (struct bio *)xfer->sc;
326 bp->bio_error = xfer->resp;
327
328 if (bp->bio_error != 0) {
329 if (fwmem_debug)
322 printf("%s: err=%d\n", __FUNCTION__, bp->bio_error);
330 printf("%s: err=%d\n", __func__, bp->bio_error);
323 bp->bio_flags |= BIO_ERROR;
324 bp->bio_resid = bp->bio_bcount;
325 }
326
327 fw_xfer_free(xfer);
328 biodone(bp);
329}
330

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

384 goto error;
385 }
386 /* XXX */
387 bp->bio_resid = bp->bio_bcount - iolen;
388error:
389 splx(s);
390 if (err != 0) {
391 if (fwmem_debug)
331 bp->bio_flags |= BIO_ERROR;
332 bp->bio_resid = bp->bio_bcount;
333 }
334
335 fw_xfer_free(xfer);
336 biodone(bp);
337}
338

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

392 goto error;
393 }
394 /* XXX */
395 bp->bio_resid = bp->bio_bcount - iolen;
396error:
397 splx(s);
398 if (err != 0) {
399 if (fwmem_debug)
392 printf("%s: err=%d\n", __FUNCTION__, err);
400 printf("%s: err=%d\n", __func__, err);
393 bp->bio_error = err;
394 bp->bio_flags |= BIO_ERROR;
395 bp->bio_resid = bp->bio_bcount;
396 biodone(bp);
397 }
398}
399
400int

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

417 return(err);
418}
419int
420fwmem_poll (dev_t dev, int events, fw_proc *td)
421{
422 return EINVAL;
423}
424int
401 bp->bio_error = err;
402 bp->bio_flags |= BIO_ERROR;
403 bp->bio_resid = bp->bio_bcount;
404 biodone(bp);
405 }
406}
407
408int

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

425 return(err);
426}
427int
428fwmem_poll (dev_t dev, int events, fw_proc *td)
429{
430 return EINVAL;
431}
432int
425#if __FreeBSD_version < 500102
433#if defined(__DragonFly__) || __FreeBSD_version < 500102
426fwmem_mmap (dev_t dev, vm_offset_t offset, int nproto)
427#else
428fwmem_mmap (dev_t dev, vm_offset_t offset, vm_paddr_t *paddr, int nproto)
429#endif
430{
431 return EINVAL;
432}
434fwmem_mmap (dev_t dev, vm_offset_t offset, int nproto)
435#else
436fwmem_mmap (dev_t dev, vm_offset_t offset, vm_paddr_t *paddr, int nproto)
437#endif
438{
439 return EINVAL;
440}