Date: Wed, 7 Aug 2002 15:36:42 +0200 From: "Jean-françois Dalbosco" <jdalbosc@enserg.fr> To: freebsd-scsi@FreeBSD.org Subject: CAM and the passthrough device Message-ID: <200208071336.g77DagTe031718@enserg.enserg.fr>
next in thread | raw e-mail | index | archive | help
hi, i'm currently trying to port an Irix software to FreeBSD. Part of the software consist in a driver for a SCSI device which is a bit particular. However particular it may be on Irix it worked perfectly. But now with some specific CDB i don't manage to perform the same actions on the mbm. I'm using the passthrough driver and the CAM ccb to send my opcodes to the device. But it seems like it doesn't work ( the device doesn't fullfill the buffer i'm giving it for retrieving datas ) for some opcodes though it should insofar as it used to work on Irix. I join the code i'm using to test those opcodes and i've 2 questions: 1. is the way i'm using CAM correct?( i manage to get some good result for some opcodes but for other like Read A Page it sucks completly ...) 2. does the passthrough driver require something more for my code to work? And if no, where could the data be stored if not at the adress of dataptr? thanks by advance for your help! #include <stdio.h> #include <fcntl.h> #include <camlib.h> #include <sys/ioctl.h> #include <errno.h> #include <string.h> #include <stdlib.h> #include <cam/scsi/scsi_pass.h> #include <cam/scsi/scsi_message.h> #define AdrPage 0 int main(int argc,char *argv[]) { int status = 0 , i; struct cam_device *cam_dev = NULL; union ccb *ccb; u_int8_t *data_ptr; long int databytes; char Nom_Fichier[]="ENTETMBM"; /************************************************/ /* Opening of the device */ /************************************************/ cam_dev = cam_open_device("/dev/da2",O_RDWR); if ( cam_dev == NULL ) { printf("Error while opening the device %s\n%s\n",argv [1],cam_errbuf); status = -1; } else { printf("Device opening succeed\n"); } /************************************************/ /* Creation of the ccb that goes with */ /************************************************/ ccb = cam_getccb(cam_dev); /**************************************************/ /* Memory space reservation for */ /* the datas */ /**************************************************/ if (argv[1]!=NULL){ databytes = (long int)atoi(argv[2]); printf("Nb de databytes= %x\n",databytes); } else databytes = 1024; data_ptr = (u_int8_t *)malloc(databytes); if ( data_ptr == NULL ) { printf("malloc failure"); status=-1; } else { bzero(data_ptr,databytes); } /*************************************************/ /* fullfill the ccb a 1st time */ /*************************************************/ cam_fill_csio(&ccb->csio, /* retries */ 1, /* cbfcnp */ NULL, /* flags */ CAM_DIR_IN, /* tag_action */ MSG_SIMPLE_Q_TAG, /* data_ptr */ Nom_Fichier, /* data tfert len */ 8, /* sense lenght */ SSD_FULL_SIZE, /* cdb_len */ 10, /* timeout */ 35000 ); bzero( &ccb->csio.cdb_io.cdb_bytes,10); ccb->csio.cdb_io.cdb_bytes[0]=(u_int8_t)0xF8; ccb->csio.cdb_io.cdb_bytes[9]=(u_int8_t)0x80; if ( cam_send_ccb(cam_dev,ccb)<0 ) { printf("cam_send_ccb ERROR!\n%s\n%s\n",cam_errbuf,strerror (errno)); status = -1; } else { printf("1st send_ccb succeed!\n"); } /*************************************************/ /* fullfill the ccb a 2nd time for */ /* another opcode */ /*************************************************/ cam_fill_csio(&ccb->csio, /* retries */ 1, /* cbfcnp */ NULL, /* flags */ CAM_DIR_IN, /* tag_action */ MSG_SIMPLE_Q_TAG, /* data_ptr */ data_ptr, /* data tfert len */ databytes, /* sense lenght */ SSD_FULL_SIZE, /* cdb_len */ 10, /* timeout */ 35000 ); bzero( &ccb->csio.cdb_io.cdb_bytes,10); ccb->csio.cdb_io.cdb_bytes[0]=(u_int8_t)0xE0; // ccb->csio.cdb_io.cdb_bytes[9]=(u_int8_t)0x80; ccb->csio.cdb_io.cdb_bytes[2]=/* Adresse Page */(u_int8_t)AdrPage; ccb->csio.cdb_io.cdb_bytes[3]=/* Adresse Page & 0x00FF */AdrPage & 0x00FF; ccb->csio.cdb_io.cdb_bytes[7]=1 | 0x80; ccb->csio.cdb_io.cdb_bytes[8]=1 & 0x00FF; printf("Avant le Lecture_Directe_Page, data_ptr:%s\n",data_ptr); if ( cam_send_ccb(cam_dev,ccb)<0 ) { printf("cam_send_ccb ERROR!\n%s\n%s\n",cam_errbuf,strerror (errno)); status = -1; } else { printf("cam_send_ccb SUCCESS!\nApres le Lecture_Directe_Pages, data_ptr:\n"); for(i=0;i<databytes;i++) { printf("%c\n ",*(data_ptr+i)); } } return status; } -- NeoMail - Webmail that doesn't suck... as much. http://neomail.sourceforge.net To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-scsi" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200208071336.g77DagTe031718>