Deleted Added
full compact
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__
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
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
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
68#include <dev/firewire/firewire.h>
69#include <dev/firewire/firewirereg.h>
70#include <dev/firewire/fwmem.h>
71#endif
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);
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);
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);
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);
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
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}