From owner-freebsd-scsi Wed Aug 7 6:36:50 2002 Delivered-To: freebsd-scsi@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 96C7937B400 for ; Wed, 7 Aug 2002 06:36:44 -0700 (PDT) Received: from enserg.enserg.fr (enserg.enserg.fr [192.93.178.1]) by mx1.FreeBSD.org (Postfix) with ESMTP id C53DE43E4A for ; Wed, 7 Aug 2002 06:36:43 -0700 (PDT) (envelope-from jdalbosc@enserg.fr) Received: (from www@localhost) by enserg.enserg.fr (8.12.1/8.12.1) id g77DagTe031718; Wed, 7 Aug 2002 15:36:42 +0200 Date: Wed, 7 Aug 2002 15:36:42 +0200 Message-Id: <200208071336.g77DagTe031718@enserg.enserg.fr> X-Authentication-Warning: enserg.enserg.fr: www set sender to jdalbosc@enserg.fr using -f From: "Jean-françois Dalbosco" To: freebsd-scsi@FreeBSD.org Subject: CAM and the passthrough device X-Mailer: NeoMail 1.24 X-IPAddress: 194.206.211.65 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Sender: owner-freebsd-scsi@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org 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 #include #include #include #include #include #include #include #include #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