kernels/linux-2.4.0/drivers/scsi/ips.c
/****************************************************************************/
/*                                                                          */
/* Routine Name: ips_msense                                                 */
/*                                                                          */
/* Routine Description:                                                     */
/*                                                                          */
/*   Simulate a mode sense command to a logical drive                       */
/*                                                                          */
/****************************************************************************/


Routine Description.

Simulate a mode sense command to a logical drive
Routine Description . Simulate a mode sense command to a logical drive
static int
ips_msense(ips_ha_t *ha, ips_scb_t *scb) {
   u16          heads;
   u16          sectors;
   u32          cylinders;
   ips_mdata_t  mdata;
   METHOD_TRACE("ips_msense", 1);
   if (ha->enq->ulDriveSize[scb->target_id] > 0x400000 &&
       (ha->enq->ucMiscFlag & 0x8) == 0) {
      heads = IPS_NORM_HEADS;
      sectors = IPS_NORM_SECTORS;
   } else {
      heads = IPS_COMP_HEADS;
      sectors = IPS_COMP_SECTORS;
   }
   cylinders = ha->enq->ulDriveSize[scb->target_id] / (heads * sectors);
   mdata.plh.plh_type = 0;
   mdata.plh.plh_wp = 0;
   mdata.plh.plh_bdl = 8;
   switch (scb->scsi_cmd->cmnd[2] & 0x3f) {
   case 0x03: 
      mdata.pdata.pg3.pg_pc = 0x3;
      mdata.pdata.pg3.pg_res1 = 0;
      mdata.pdata.pg3.pg_len = sizeof(IPS_DADF);
      mdata.plh.plh_len = 3 + mdata.plh.plh_bdl + mdata.pdata.pg3.pg_len;
      mdata.pdata.pg3.pg_trk_z = 0;
      mdata.pdata.pg3.pg_asec_z = 0;
      mdata.pdata.pg3.pg_atrk_z = 0;
      mdata.pdata.pg3.pg_atrk_v = 0;
      mdata.pdata.pg3.pg_sec_t = htons(sectors);
      mdata.pdata.pg3.pg_bytes_s = htons(IPS_BLKSIZE);
      mdata.pdata.pg3.pg_intl = htons(1);
      mdata.pdata.pg3.pg_trkskew = 0;
      mdata.pdata.pg3.pg_cylskew = 0;
      mdata.pdata.pg3.pg_res2 = 0;
      mdata.pdata.pg3.pg_ins = 0;
      mdata.pdata.pg3.pg_surf = 0;
      mdata.pdata.pg3.pg_rmb = 0;
      mdata.pdata.pg3.pg_hsec = 0;
      mdata.pdata.pg3.pg_ssec = 1;
      break;
   case 0x4:
      mdata.pdata.pg4.pg_pc = 0x4;
      mdata.pdata.pg4.pg_res1 = 0;
      mdata.pdata.pg4.pg_len = sizeof(IPS_RDDG);
      mdata.plh.plh_len = 3 + mdata.plh.plh_bdl + mdata.pdata.pg4.pg_len;
      mdata.pdata.pg4.pg_cylu = (cylinders >> 8) & 0xffff;
      mdata.pdata.pg4.pg_cyll = cylinders & 0xff;
      mdata.pdata.pg4.pg_head = heads;
      mdata.pdata.pg4.pg_wrpcompu = 0;
      mdata.pdata.pg4.pg_wrpcompl = 0;
      mdata.pdata.pg4.pg_redwrcur = 0;
      mdata.pdata.pg4.pg_drstep = htons(1);
      mdata.pdata.pg4.pg_landu = 0;
      mdata.pdata.pg4.pg_landl = 0;
      mdata.pdata.pg4.pg_res2 = 0;
      break;
   default:
      return (0);
   } 
   memcpy(scb->scsi_cmd->request_buffer, &mdata, scb->scsi_cmd->request_bufflen);
   return (1);
}
static int ips_msense ( ips_ha_t * ha , ips_scb_t * scb ) { u16 heads ; u16 sectors ; u32 cylinders ; ips_mdata_t mdata ; METHOD_TRACE ( " " , 1 ) ; if ( ha -> enq -> ulDriveSize [ scb -> target_id ] > 0x400000 && ( ha -> enq -> ucMiscFlag & 0x8 ) == 0 ) { heads = IPS_NORM_HEADS ; sectors = IPS_NORM_SECTORS ; } else { heads = IPS_COMP_HEADS ; sectors = IPS_COMP_SECTORS ; } cylinders = ha -> enq -> ulDriveSize [ scb -> target_id ] / ( heads * sectors ) ; mdata . plh . plh_type = 0 ; mdata . plh . plh_wp = 0 ; mdata . plh . plh_bdl = 8 ; switch ( scb -> scsi_cmd -> cmnd [ 2 ] & 0x3f ) { case 0x03 : mdata . pdata . pg3 . pg_pc = 0x3 ; mdata . pdata . pg3 . pg_res1 = 0 ; mdata . pdata . pg3 . pg_len = sizeof ( IPS_DADF ) ; mdata . plh . plh_len = 3 + mdata . plh . plh_bdl + mdata . pdata . pg3 . pg_len ; mdata . pdata . pg3 . pg_trk_z = 0 ; mdata . pdata . pg3 . pg_asec_z = 0 ; mdata . pdata . pg3 . pg_atrk_z = 0 ; mdata . pdata . pg3 . pg_atrk_v = 0 ; mdata . pdata . pg3 . pg_sec_t = htons ( sectors ) ; mdata . pdata . pg3 . pg_bytes_s = htons ( IPS_BLKSIZE ) ; mdata . pdata . pg3 . pg_intl = htons ( 1 ) ; mdata . pdata . pg3 . pg_trkskew = 0 ; mdata . pdata . pg3 . pg_cylskew = 0 ; mdata . pdata . pg3 . pg_res2 = 0 ; mdata . pdata . pg3 . pg_ins = 0 ; mdata . pdata . pg3 . pg_surf = 0 ; mdata . pdata . pg3 . pg_rmb = 0 ; mdata . pdata . pg3 . pg_hsec = 0 ; mdata . pdata . pg3 . pg_ssec = 1 ; break ; case 0x4 : mdata . pdata . pg4 . pg_pc = 0x4 ; mdata . pdata . pg4 . pg_res1 = 0 ; mdata . pdata . pg4 . pg_len = sizeof ( IPS_RDDG ) ; mdata . plh . plh_len = 3 + mdata . plh . plh_bdl + mdata . pdata . pg4 . pg_len ; mdata . pdata . pg4 . pg_cylu = ( cylinders >> 8 ) & 0xffff ; mdata . pdata . pg4 . pg_cyll = cylinders & 0xff ; mdata . pdata . pg4 . pg_head = heads ; mdata . pdata . pg4 . pg_wrpcompu = 0 ; mdata . pdata . pg4 . pg_wrpcompl = 0 ; mdata . pdata . pg4 . pg_redwrcur = 0 ; mdata . pdata . pg4 . pg_drstep = htons ( 1 ) ; mdata . pdata . pg4 . pg_landu = 0 ; mdata . pdata . pg4 . pg_landl = 0 ; mdata . pdata . pg4 . pg_res2 = 0 ; break ; default : return ( 0 ) ; } memcpy ( scb -> scsi_cmd -> request_buffer , & mdata , scb -> scsi_cmd -> request_bufflen ) ; return ( 1 ) ; }
Routine Name: ips_msense
Routine Name : ips_msense
/* page 3 */ /* end switch */