Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 20 Nov 2002 01:05:45 -0500
From:      Katsushi Kobayashi <ikob@koganei.wide.ad.jp>
To:        Buzz Slye <buzz@gaia.arc.nasa.gov>
Cc:        freebsd-firewire@FreeBSD.ORG
Subject:   Re: Kodak on firewire
Message-ID:  <1B5B5C1B-FC4E-11D6-B36D-000393D603A4@koganei.wide.ad.jp>
In-Reply-To: <Pine.GSO.4.44.0211191013040.1262-100000@mono.arc.nasa.gov>

next in thread | previous in thread | raw e-mail | index | archive | help
I cannot judge whether your code would work from the attached
information. I found the attached SBP-2 test code when I was
using earlier developing phase. I think this code is messy and
difficult to read. But, I hope it is your help.

On 2002.Nov.19, at 01:15  PM, Buzz Slye wrote:

> Hi,
>
> I am going to try this one again.  This time it really is a Kodak 
> camera,
> not an Oxford disk.  (The result fails the same way.)  The Kodak is not
> a SCSI device.  The Kodak camera is logged in and attached by SBP-II as
> follows:
>


#include <sys/param.h>
#include <sys/malloc.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/errno.h>
#include <sys/types.h>
#include <sys/stat.h>

#include <dev/firewire/firewire.h>

#include <netinet/in.h>
#include <fcntl.h>
#include <stdio.h>
#include <strings.h>

#define SBPRES_HI	0x000f
#define SBPRES_LO	0x30000000

usage()
{
	printf("TBD..");
	exit();
}
main(argc, argv)
         int argc;
         char *argv[];
{
	extern char *optarg;
	extern int optind;
	int d;
	int i, j, len;
	unsigned long *qld;
	unsigned long *buf;
	char ch, node;
	char devname[] = "/dev/fw0";
	struct fw_asyreq *asyreq;
	struct fw_asybindreq bindreq;
	struct fw_pkt *fp;
	struct stat sb;

	while ((ch = getopt(argc, argv, "I:")) != -1){
		switch(ch) {
			case 'I':
				strcpy(devname, optarg);
		     		break;
			case '?':
			default:
				usage();
				break;
		}
	}
	argc -= optind;
	argv += optind;
	if( argc < 1 ) {
		usage();
	}else {
		node = strtoul(argv[0], (char **)NULL, 10);
	}
	asyreq = (struct fw_asyreq *)malloc(sizeof(struct fw_asyreq_t) + 512);
	buf = (unsigned long *)malloc(512);
	fp = (struct fw_pkt *)buf;

	d = open(devname, O_RDWR);

	if(fstat(d, &sb)< 0){
        		err(1, "stat");
	}
	bindreq.start.hi = SBPRES_HI;
	bindreq.start.lo = SBPRES_LO;
	bindreq.len= 2048;
#if 1
	printf("step 1\n");

	if( ioctl(d, FW_SBINDADDR, &bindreq) < 0) {
        		err(1, "ioctl");
	}
/**/
	asyreq->req.sped = 0;
	asyreq->req.type = FWASREQNODE;
	asyreq->pkt.mode.wreqb.dst = htons(0xffc0 | node);
	asyreq->pkt.mode.wreqb.tlrt = 0;
	asyreq->pkt.mode.wreqb.tcode = 1;
	asyreq->pkt.mode.wreqb.len = htons(8);
	asyreq->req.len = 512;
	asyreq->pkt.mode.wreqb.extcode = 0;

	asyreq->pkt.mode.wreqb.dest_hi = htons(0xffff);
/**/
	asyreq->pkt.mode.wreqb.dest_lo = htonl(0xf0030000);
/**/
	asyreq->pkt.mode.wreqb.dest_lo = htonl(0xf0010000);

	asyreq->pkt.mode.wreqb.payload[0] = htonl(SBPRES_HI);
	asyreq->pkt.mode.wreqb.payload[1] = htonl(SBPRES_LO);
/**/
/*
	asyreq->req.sped = 0;
	asyreq->req.type = FWASREQNODE;
	asyreq->pkt.mode.wreqq.dst = 0xffc0 | node;
	asyreq->pkt.mode.wreqq.tlrt = 0;
	asyreq->pkt.mode.wreqq.tcode = 0;
	asyreq->pkt.mode.wreqq.data = 0;
	asyreq->req.len = 512;

	asyreq->pkt.mode.wreqq.dest_hi = 0xffff;
	asyreq->pkt.mode.wreqq.dest_lo = 0xf0010008;

	qld = (unsigned long *)&asyreq->pkt;
	for(i = 0 ; i < 24 ; i+= 4){
		printf("%08x ", qld[i/4]);
	}
	printf("\n");

	printf("step 2\n");

	if( ioctl(d, FW_ASYREQ, asyreq) < 0) {
        			err(1, "ioctl");
	}
	for(i = 0 ; i < asyreq->req.len ; i+= 4){
		printf("%08x ", qld[i/4]);
	}
	printf("\n");

	asyreq->req.sped = 0;
	asyreq->req.type = FWASREQNODE;
	asyreq->pkt.mode.wreqq.dst = 0xffc0 | node;
	asyreq->pkt.mode.wreqq.tlrt = 0;
	asyreq->pkt.mode.wreqq.tcode = 0;
	asyreq->pkt.mode.wreqq.data = 0x30000000;
	asyreq->req.len = 512;

	asyreq->pkt.mode.wreqq.dest_hi = 0xffff;
	asyreq->pkt.mode.wreqq.dest_lo = 0xf001000c;
*/
	qld = (unsigned long *)&asyreq->pkt;
	for(i = 0 ; i < 24 ; i+= 4){
		printf("%08x ", ntohl(qld[i/4]));
	}
	printf("\n");

	printf("step 3\n");
	if( ioctl(d, FW_ASYREQ, asyreq) < 0) {
        			err(1, "ioctl");
	}
	for(i = 0 ; i < asyreq->req.len ; i+= 4){
		printf("%08x ", ntohl(qld[i/4]));
	}
	printf("\n");
	len = read(d, buf, 512);
	if(len < 0){
        		err(1, "ioctl");
	}
/*
	printf("len = %d\n", len);
	for(i = 0 ; i < len; i+= 4){
		printf("%08x ", buf[i/4]);
		if(((i - 1 )% 64) == 0){
			printf("\n");
		}
	}
	if((i % 64) != 0){
		printf("\n");
	}
*/
	printf("code %08x ", fp->mode.rreqb.tcode);
	printf("tlrt %08x ", fp->mode.rreqb.tlrt);
	printf("addr %08x:", ntohs(fp->mode.rreqb.dest_hi));
	printf("%08x ", ntohl(fp->mode.rreqb.dest_lo));
	printf("len %08x\n", ntohs(fp->mode.rreqb.len));

	asyreq->pkt.mode.rresb.dst = ntohs(0xffc0 | node);
	asyreq->pkt.mode.rresb.tlrt = fp->mode.rreqb.tlrt;
	asyreq->pkt.mode.rresb.tcode = 7;
	asyreq->pkt.mode.rresb.rtcode = 0;
	asyreq->pkt.mode.rresb.len = fp->mode.rreqb.len;
	asyreq->req.len = 512;
	asyreq->pkt.mode.rresb.extcode = 0;

	printf("len %08x\n", ntohs(fp->mode.rreqb.len));

	asyreq->pkt.mode.rresb.payload[0] = 0;
	asyreq->pkt.mode.rresb.payload[1] = 0;
	asyreq->pkt.mode.rresb.payload[2] = 0;
	asyreq->pkt.mode.rresb.payload[3] = ntohl(0x30000200);
	asyreq->pkt.mode.rresb.payload[4] = ntohl(0x90100000);
	asyreq->pkt.mode.rresb.payload[5] = ntohl(0x00000200);
	asyreq->pkt.mode.rresb.payload[6] = ntohl(0x00000000);
	asyreq->pkt.mode.rresb.payload[7] = ntohl(0x30000400);
/**/
	for(i = 0 ; i < 40 ; i+= 4){
		printf("%08x ", ntohl(qld[i/4]));
	}
	printf("\n");
/**/

	printf("step 4\n");
	if( ioctl(d, FW_ASYREQ, asyreq) < 0) {
        			err(1, "ioctl");
	}
	for(i = 0 ; i < asyreq->req.len ; i+= 4){
		printf("%08x ", qld[i/4]);
	}
	printf("\n");

	len = read(d, buf, 512);
	if(len < 0){
        		err(1, "ioctl");
	}
	printf("len = %d\n", len);
	for(i = 0 ; i < len; i+= 4){
		printf("%08x ", buf[i/4]);
		if(((i - 1 )% 64) == 0){
			printf("\n");
		}
	}
	if((i % 64) != 0){
		printf("\n");
	}
/**/
	printf("code %08x ", fp->mode.wreqb.tcode);
	printf("tlrt %08x ", fp->mode.wreqb.tlrt);
	printf("addr %08x:", fp->mode.wreqb.dest_hi);
	printf("%08x ", fp->mode.wreqb.dest_lo);
	printf("len %08x\n", fp->mode.wreqb.len);
	printf("%08x %08x %08x\n", fp->mode.wreqb.payload[0],
		fp->mode.wreqb.payload[1], fp->mode.wreqb.payload[2]);

	asyreq->pkt.mode.wres.dst = 0xffc0 | node;
	asyreq->pkt.mode.wres.tlrt = fp->mode.rreqb.tlrt;
	asyreq->pkt.mode.wres.tcode = 2;
	asyreq->pkt.mode.wres.rtcode = 0;
	asyreq->req.len = 512;
	printf("step 5\n");
	if( ioctl(d, FW_ASYREQ, asyreq) < 0) {
        			err(1, "ioctl");
	}


	len = read(d, buf, 512);
	if(len < 0){
        		err(1, "ioctl");
	}
/*
	printf("len = %d\n", len);
	for(i = 0 ; i < len; i+= 4){
		printf("%08x ", buf[i/4]);
		if(((i - 1 )% 64) == 0){
			printf("\n");
		}
	}
	if((i % 64) != 0){
		printf("\n");
	}
*/
/**/
	printf("code %08x ", fp->mode.wreqb.tcode);
	printf("tlrt %08x ", fp->mode.wreqb.tlrt);
	printf("addr %08x:", fp->mode.wreqb.dest_hi);
	printf("%08x ", fp->mode.wreqb.dest_lo);
	printf("len %08x\n", fp->mode.wreqb.len);
	printf("%08x %08x %08x\n", fp->mode.wreqb.payload[0],
		fp->mode.wreqb.payload[1], fp->mode.wreqb.payload[2]);

	asyreq->pkt.mode.wres.dst = 0xffc0 | node;
	asyreq->pkt.mode.wres.tlrt = fp->mode.rreqb.tlrt;
	asyreq->pkt.mode.wres.tcode = 2;
	asyreq->pkt.mode.wres.rtcode = 0;
	asyreq->req.len = 512;
	printf("step 6\n");
	if( ioctl(d, FW_ASYREQ, asyreq) < 0) {
        			err(1, "ioctl");
	}
/**/
#endif
#if 0
	fp->mode.wres.dst = 0xffc0 | node;
	fp->mode.wres.rtcode = 0;
	fp->mode.wreqb.tcode = 2;
	for(i = 0 ; i < 12 ; i+= 4){
		printf("%08x ", buf[i/4]);
		if(((i - 1 )% 64) == 0){
			printf("\n");
		}
	}
	if((i % 64) != 0){
		printf("\n");
	}
	len = write(d, buf, 12);
	if(len < 0){
        		err(1, "write");
	}
#endif
}


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-firewire" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1B5B5C1B-FC4E-11D6-B36D-000393D603A4>