//----------------------------------------------------------- static int SingleIo( CamKey Key, BYTE A, BYTE F, BYTE *Data, BYTE Mem, TranslatedIosb *iosb, int dmode ) { char tmp[7]; int highwayType, status; if( MSGLVL(FUNCTION_NAME) ) printf( "\033[01;31mSingleIo(F=%d)-->\033[0m", F ); sprintf(tmp, "GK%c%d", Key.scsi_port, Key.scsi_address); if( (status = QueryHighwayType( tmp )) == SUCCESS ) { highwayType = NUMERIC(tmp[5]); // extract type switch( highwayType ) { // check highway type case JORWAY: case JORWAY_OLD: if( MSGLVL(DETAILS) ) printf( "-->>JorwayDoIo()\n" ); status = JorwayDoIo( Key, // module info A, // module sub address F, // module function 1, // implied count of 1 Data, // data Mem, // 16 or 24 bit data iosb, // status struct dmode, // mode 0 // non-enhanced ); break; case KINSYSCO: if( MSGLVL(DETAILS) ) printf( "-->>KsSingleIo()\n" ); status = KsSingleIo( Key, // module info A, // module sub-address F, // module function Data, // data Mem, // 16 or 24 bit data iosb, // status struct KSMODE(dmode) // mode ); break; case JORWAY_73A: if( MSGLVL(DETAILS) ) printf( "-->>JorwayDoIo()\n" ); status = Jorway73ADoIo( Key, // module info A, // module sub address F, // module function 1, // implied count of 1 Data, // data Mem, // 16 or 24 bit data iosb, // status struct dmode, // mode 0 // non-enhanced ); break; default: if( MSGLVL(IMPORTANT) ) fprintf( stderr, "highway type(%d) not supported\n", highwayType ); status = FAILURE; break; } // end of switch() if( MSGLVL(FUNCTION_NAME) ) // show data, if there is some if (Data) { if (Mem==16) printf( "\033[01;31mSingleIo(F=%d)-->>%d\033[0m\n", F, *(short *) Data ); else printf( "\033[01;31mSingleIo(F=%d)-->>%d\033[0m\n", F, *(int *) Data ); } } // end of if() //printf("SingleIo(iosb)::->> bytecount= %d\n", iosb->bytcnt); // [2002.12.13] return status; }
//----------------------------------------------------------- static int MultiIo( CamKey Key, BYTE A, BYTE F, int Count, BYTE *Data, BYTE Mem, TranslatedIosb *iosb, int dmode, int Enhanced ) { char tmp[7]; int highwayType, mode, status; if( MSGLVL(FUNCTION_NAME) ) printf( "\033[01;31mMultiIo(F=%d, count=%d)-->>\033[0m\n", F, Count ); sprintf(tmp, "GK%c%d", Key.scsi_port, Key.scsi_address); if( (status = QueryHighwayType( tmp )) == SUCCESS ) { highwayType = NUMERIC(tmp[5]); // extract type switch( highwayType ) { // check highway type case JORWAY: case JORWAY_OLD: if( MSGLVL(DETAILS) ) printf( "-->>JorwayDoIo()\n" ); mode = JORWAYMODE(dmode, (Enhanced && highwayType == JORWAY), Count > 1); if( mode != NO_MODE ) status = JorwayDoIo( Key, // module info A, // module sub address F, // module function Count, // data count int bytes Data, // data Mem, // 16 or 24 bit data iosb, // status struct dmode, // mode Enhanced // highway mode ); else status = NOT_SUPPORTED(); break; case KINSYSCO: if( MSGLVL(DETAILS) ) printf( "-->>KsMultiIo()\n" ); status = KsMultiIo( Key, // module info A, // module sub-address F, // module function Count, // data count in bytes Data, // data Mem, // 16 or 24 bit data iosb, // status struct KSMODE(dmode), // mode Enhanced // enhanced ); break; case JORWAY_73A: mode = JORWAYMODE(dmode, (Enhanced && highwayType == JORWAY), Count > 1); if( mode != NO_MODE ) status = Jorway73ADoIo( Key, // module info A, // module sub address F, // module function Count, // data count int bytes Data, // data Mem, // 16 or 24 bit data iosb, // status struct dmode, // mode Enhanced // highway mode ); else status = NOT_SUPPORTED(); break; default: if( MSGLVL(IMPORTANT) ) fprintf( stderr, "highway type(%d) not supported\n", highwayType ); status = FAILURE; break; } // end of switch() } // end of if() if( MSGLVL(DETAILS) ) { if (!iosb) printf("MultiIo null iosb ptr"); else printf("MultiIo(iosb)::->> bytecount= %d\n", iosb->bytcnt); // [2002.12.13] } return status; }
//------------------------------------------------------------------------- // Fri Mar 9 15:12:40 EST 2001 // Thu Mar 15 13:40:01 EST 2001 // Mon Mar 26 13:49:08 EST 2001 // Tue Apr 3 16:45:23 EDT 2001 // Mon Apr 30 16:37:43 EDT 2001 -- added support for highway type // Fri Jul 6 11:37:19 EDT 2001 -- 'tighten-up' search loop //------------------------------------------------------------------------- // lookup a CAMAC device (either a serial highway or a module) and // return o/s specific device number, eg '/dev/sg#' // puts value into crate.db; leaves unchanged if not found // NB! called by 'autoconfig()' in cts::verbs //------------------------------------------------------------------------- int map_scsi_device( char *highway_name ) { char line[80], *pline, tmp[7]; char dsf[3], hwytype; int adapter, i, numOfEntries, scsi_id, sg_number; int status = SUCCESS; // optimistic int found = FALSE; FILE *fp, *fopen(); extern struct CRATE *CRATEdb; // pointer to in-memory copy of data file if( MSGLVL(FUNCTION_NAME) ) printf( "map_scsi_device('%s')\n", highway_name ); // open '/proc' filesystem scsi info if( (fp = fopen(PROC_FILE, "r")) == NULL ) { if( MSGLVL(ALWAYS) ) fprintf( stderr, "failure to open '%s'\n", PROC_FILE ); status = FILE_ERROR; // serious error !!! no scsi devices to check goto MapScsiDevice_Exit; } // get current db file count if( (numOfEntries = get_file_count( CRATE_DB )) <= 0 ) { status = FILE_ERROR; goto MapScsiDevice_Exit; // we're done :< } if( MSGLVL(DETAILS) ) printf( "crate.db count= %d\n", numOfEntries ); // lookup highway name if( MSGLVL(DETAILS) ) printf("msd() looking up '%s'\n", highway_name); if( (i = lookup_entry( CRATE_DB, highway_name )) < 0 ) { status = NO_DEVICE; // no such device in db file goto MapScsiDevice_Exit; } if( MSGLVL(DETAILS) ) printf( "msd(): lookup index [%d]:%s\n", i, highway_name ); // point to actual memory pline = &line[0]; // scan all scsi devices sg_number = 0; // start at the beginning while( !found && (pline = fgets(line, sizeof(line), fp)) != NULL ) { if( strncmp(pline, "Host:", 5) == EQUAL ) { sscanf(line, "Host: scsi%d Channel: %*2c Id: %d %*s", &adapter, &scsi_id); sprintf(tmp, "GK%c%d", 'A' + adapter, scsi_id); if( strncmp(tmp, highway_name, 4) == EQUAL ) { // found it if( QueryHighwayType( tmp ) == SUCCESS ) // determine highway type hwytype = tmp[5]; // we're done, so exit found = TRUE; } else sg_number++; } // end of if() .... } // end of while() ... // 'lock' file with semaphore if( lock_file() != SUCCESS ) { status = FAILURE; // LOCK_ERROR; [2001.07.12] goto MapScsiDevice_Exit; } // update memory mapped version if( found ) { sprintf(dsf, "%03d", sg_number); // format conversion strncpy((CRATEdb+i)->DSFname, dsf, 3); // real device number (CRATEdb+i)->HwyType = hwytype; // highway type } else { strncpy((CRATEdb+i)->DSFname, "...", 3); // place-holder device number (CRATEdb+i)->HwyType = '.'; } // commit changes to file if( commit_entry( CRATE_DB ) != SUCCESS ) { status = FAILURE; // COMMIT_ERROR; [2001.07.12] goto MapScsiDevice_Exit; } if( MSGLVL(DETAILS) ) printf( "'%.4s+%.3s+%c'\n", highway_name, (CRATEdb+i)->DSFname, (CRATEdb+i)->HwyType ); // unlock file if( unlock_file() != SUCCESS ) { status = FAILURE; // UNLOCK_ERROR; [2001.07.12] goto MapScsiDevice_Exit; } MapScsiDevice_Exit: // cleanup if( fp ) fclose(fp); return status; }