firewire.c (106790) | firewire.c (106810) |
---|---|
1/* 2 * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa 3 * 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 --- 16 unchanged lines hidden (view full) --- 25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 * | 1/* 2 * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa 3 * 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 --- 16 unchanged lines hidden (view full) --- 25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 * |
33 * $FreeBSD: head/sys/dev/firewire/firewire.c 106790 2002-11-12 05:52:01Z simokawa $ | 33 * $FreeBSD: head/sys/dev/firewire/firewire.c 106810 2002-11-12 13:49:17Z simokawa $ |
34 * 35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/types.h> 40#include <sys/mbuf.h> 41#include <sys/socket.h> --- 59 unchanged lines hidden (view full) --- 101static int firewire_detach __P((device_t)); 102#if 0 103static int firewire_shutdown __P((device_t)); 104#endif 105static device_t firewire_add_child __P((device_t, int, const char *, int)); 106static struct fw_bind *fw_bindlookup __P((struct firewire_comm *, u_int32_t, u_int32_t)); 107static void fw_try_bmr __P((void *)); 108static void fw_try_bmr_callback __P((struct fw_xfer *)); | 34 * 35 */ 36 37#include <sys/param.h> 38#include <sys/systm.h> 39#include <sys/types.h> 40#include <sys/mbuf.h> 41#include <sys/socket.h> --- 59 unchanged lines hidden (view full) --- 101static int firewire_detach __P((device_t)); 102#if 0 103static int firewire_shutdown __P((device_t)); 104#endif 105static device_t firewire_add_child __P((device_t, int, const char *, int)); 106static struct fw_bind *fw_bindlookup __P((struct firewire_comm *, u_int32_t, u_int32_t)); 107static void fw_try_bmr __P((void *)); 108static void fw_try_bmr_callback __P((struct fw_xfer *)); |
109static u_int16_t fw_noderesolve __P((struct firewire_comm *, struct fw_eui64)); | |
110static void fw_asystart __P((struct fw_xfer *)); 111static int fw_get_tlabel __P((struct firewire_comm *, struct fw_xfer *)); 112static void fw_bus_probe __P((struct firewire_comm *)); 113static void fw_bus_explore __P((struct firewire_comm *)); 114static void fw_bus_explore_callback __P((struct fw_xfer *)); 115static void fw_attach_dev __P((struct firewire_comm *)); 116#ifdef FW_VMACCESS 117static void fw_vmaccess __P((struct fw_xfer *)); --- 854 unchanged lines hidden (view full) --- 972 return err; 973 } 974 fp = &asyreq->pkt; 975 switch (asyreq->req.type) { 976 case FWASREQNODE: 977 xfer->dst = ntohs(fp->mode.hdr.dst); 978 break; 979 case FWASREQEUI: | 109static void fw_asystart __P((struct fw_xfer *)); 110static int fw_get_tlabel __P((struct firewire_comm *, struct fw_xfer *)); 111static void fw_bus_probe __P((struct firewire_comm *)); 112static void fw_bus_explore __P((struct firewire_comm *)); 113static void fw_bus_explore_callback __P((struct fw_xfer *)); 114static void fw_attach_dev __P((struct firewire_comm *)); 115#ifdef FW_VMACCESS 116static void fw_vmaccess __P((struct fw_xfer *)); --- 854 unchanged lines hidden (view full) --- 971 return err; 972 } 973 fp = &asyreq->pkt; 974 switch (asyreq->req.type) { 975 case FWASREQNODE: 976 xfer->dst = ntohs(fp->mode.hdr.dst); 977 break; 978 case FWASREQEUI: |
980 xfer->dst = fw_noderesolve(sc->fc, asyreq->req.dst.eui); 981 if(xfer->dst == FWNODE_INVAL ){ | 979 fwdev = fw_noderesolve(sc->fc, asyreq->req.dst.eui); 980 if (fwdev == NULL) { |
982 printf("%s:cannot found node\n", 983 device_get_nameunit(sc->fc->dev)); 984 err = EINVAL; 985 goto error; 986 } | 981 printf("%s:cannot found node\n", 982 device_get_nameunit(sc->fc->dev)); 983 err = EINVAL; 984 goto error; 985 } |
986 xfer->dst = fwdev->dst; |
|
987 fp->mode.hdr.dst = htons(FWLOCALBUS | xfer->dst); 988 break; 989 case FWASRESTL: 990 /* XXX what's this? */ 991 break; 992 case FWASREQSTREAM: 993 /* nothing to do */ 994 break; --- 154 unchanged lines hidden (view full) --- 1149 } 1150 1151 return revents; 1152} 1153 1154/* 1155 * To lookup node id. from EUI64. 1156 */ | 987 fp->mode.hdr.dst = htons(FWLOCALBUS | xfer->dst); 988 break; 989 case FWASRESTL: 990 /* XXX what's this? */ 991 break; 992 case FWASREQSTREAM: 993 /* nothing to do */ 994 break; --- 154 unchanged lines hidden (view full) --- 1149 } 1150 1151 return revents; 1152} 1153 1154/* 1155 * To lookup node id. from EUI64. 1156 */ |
1157u_int16_t | 1157struct fw_device * |
1158fw_noderesolve(struct firewire_comm *fc, struct fw_eui64 eui) 1159{ 1160 struct fw_device *fwdev; 1161 for(fwdev = TAILQ_FIRST(&fc->devices); fwdev != NULL; 1162 fwdev = TAILQ_NEXT(fwdev, link)){ 1163 if(fwdev->eui.hi == eui.hi && fwdev->eui.lo == eui.lo){ 1164 break; 1165 } 1166 } | 1158fw_noderesolve(struct firewire_comm *fc, struct fw_eui64 eui) 1159{ 1160 struct fw_device *fwdev; 1161 for(fwdev = TAILQ_FIRST(&fc->devices); fwdev != NULL; 1162 fwdev = TAILQ_NEXT(fwdev, link)){ 1163 if(fwdev->eui.hi == eui.hi && fwdev->eui.lo == eui.lo){ 1164 break; 1165 } 1166 } |
1167 if(fwdev == NULL) return FWNODE_INVAL; 1168 if(fwdev->status != FWDEVATTACHED) return FWNODE_INVAL; 1169 return fwdev->dst; | 1167 if(fwdev == NULL) return NULL; 1168 if(fwdev->status == FWDEVINVAL) return NULL; 1169 return fwdev; |
1170} 1171/* 1172 * Async. request procedure for userland application. 1173 */ 1174int 1175fw_asyreq(struct firewire_comm *fc, int sub, struct fw_xfer *xfer) 1176{ 1177 int err = 0; --- 999 unchanged lines hidden (view full) --- 2177 fc->ongoaddr = CSRROMOFF; 2178 fc->ongodev = NULL; 2179 fc->ongoeui.hi = 0xffffffff; fc->ongoeui.lo = 0xffffffff; 2180 goto loop; 2181 } 2182 fwdev = malloc(sizeof(struct fw_device), M_DEVBUF, M_DONTWAIT); 2183 if(fwdev == NULL) 2184 return; | 1170} 1171/* 1172 * Async. request procedure for userland application. 1173 */ 1174int 1175fw_asyreq(struct firewire_comm *fc, int sub, struct fw_xfer *xfer) 1176{ 1177 int err = 0; --- 999 unchanged lines hidden (view full) --- 2177 fc->ongoaddr = CSRROMOFF; 2178 fc->ongodev = NULL; 2179 fc->ongoeui.hi = 0xffffffff; fc->ongoeui.lo = 0xffffffff; 2180 goto loop; 2181 } 2182 fwdev = malloc(sizeof(struct fw_device), M_DEVBUF, M_DONTWAIT); 2183 if(fwdev == NULL) 2184 return; |
2185 fwdev->fc = fc; |
|
2185 fwdev->rommax = 0; 2186 fwdev->dst = fc->ongonode; 2187 fwdev->eui.hi = fc->ongoeui.hi; fwdev->eui.lo = fc->ongoeui.lo; 2188 fwdev->status = FWDEVINIT; 2189#if 0 2190 fwdev->speed = CSRARC(fc, SPED_MAP + 8 + fc->ongonode / 4) 2191 >> ((3 - (fc->ongonode % 4)) * 8); 2192#else --- 1006 unchanged lines hidden --- | 2186 fwdev->rommax = 0; 2187 fwdev->dst = fc->ongonode; 2188 fwdev->eui.hi = fc->ongoeui.hi; fwdev->eui.lo = fc->ongoeui.lo; 2189 fwdev->status = FWDEVINIT; 2190#if 0 2191 fwdev->speed = CSRARC(fc, SPED_MAP + 8 + fc->ongonode / 4) 2192 >> ((3 - (fc->ongonode % 4)) * 8); 2193#else --- 1006 unchanged lines hidden --- |