⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 scsi_all.c

📁 基于组件方式开发操作系统的OSKIT源代码
💻 C
📖 第 1 页 / 共 5 页
字号:
			"Unload tape failure") },/* DT  WR OM    */{SST(0x53, 0x02, SS_DEF,			"Medium removal prevented") },/*    P         */{SST(0x54, 0x00, SS_DEF,			"Scsi to host system interface failure") },/*    P         */{SST(0x55, 0x00, SS_DEF,			"System resource failure") },/* D      O     */{SST(0x55, 0x01, SS_NEDEF|ENOSPC,			"System buffer full") },/*      R       */{SST(0x57, 0x00, SS_DEF,			"Unable to recover table-of-contents") },/*        O     */{SST(0x58, 0x00, SS_DEF,			"Generation does not exist") },/*        O     */{SST(0x59, 0x00, SS_DEF,			"Updated block read") },/* DTLPWRSOM    */{SST(0x5A, 0x00, SS_DEF,			"Operator request or state change input") },/* DT  WR OM    */{SST(0x5A, 0x01, SS_DEF,			"Operator medium removal request") },/* DT  W  O     */{SST(0x5A, 0x02, SS_DEF,			"Operator selected write protect") },/* DT  W  O     */{SST(0x5A, 0x03, SS_DEF,			"Operator selected write permit") },/* DTLPWRSOM    */{SST(0x5B, 0x00, SS_DEF,			"Log exception") },/* DTLPWRSOM    */{SST(0x5B, 0x01, SS_DEF,			"Threshold condition met") },/* DTLPWRSOM    */{SST(0x5B, 0x02, SS_DEF,			"Log counter at maximum") },/* DTLPWRSOM    */{SST(0x5B, 0x03, SS_DEF,			"Log list codes exhausted") },/* D      O     */{SST(0x5C, 0x00, SS_DEF,			"RPL status change") },/* D      O     */{SST(0x5C, 0x01, SS_NEDEF,			"Spindles synchronized") },/* D      O     */{SST(0x5C, 0x02, SS_DEF,			"Spindles not synchronized") },/* DTLPWRSOMCAE */{SST(0x5D, 0x00, SS_DEF,			"Failure prediction threshold exceeded") },/* DTLPWRSOMCAE */{SST(0x5D, 0xFF, SS_DEF,			"Failure prediction threshold exceeded (false)") },/* DTLPWRSO CA  */{SST(0x5E, 0x00, SS_DEF,			"Low power condition on") },/* DTLPWRSO CA  */{SST(0x5E, 0x01, SS_DEF,			"Idle condition activated by timer") },/* DTLPWRSO CA  */{SST(0x5E, 0x02, SS_DEF,			"Standby condition activated by timer") },/* DTLPWRSO CA  */{SST(0x5E, 0x03, SS_DEF,			"Idle condition activated by command") },/* DTLPWRSO CA  */{SST(0x5E, 0x04, SS_DEF,			"Standby condition activated by command") },/*       S      */{SST(0x60, 0x00, SS_DEF,			"Lamp failure") },/*       S      */{SST(0x61, 0x00, SS_DEF,			"Video acquisition error") },/*       S      */{SST(0x61, 0x01, SS_DEF,			"Unable to acquire video") },/*       S      */{SST(0x61, 0x02, SS_DEF,			"Out of focus") },/*       S      */{SST(0x62, 0x00, SS_DEF,			"Scan head positioning error") },/*      R       */{SST(0x63, 0x00, SS_DEF,			"End of user area encountered on this track") },/*      R       */{SST(0x63, 0x01, SS_NEDEF|ENOSPC,			"Packet does not fit in available space") },/*      R       */{SST(0x64, 0x00, SS_DEF,			"Illegal mode for this track") },/*      R       */{SST(0x64, 0x01, SS_DEF,			"Invalid packet size") },/* DTLPWRSOMCAE */{SST(0x65, 0x00, SS_DEF,			"Voltage fault") },/*       S      */{SST(0x66, 0x00, SS_DEF,			"Automatic document feeder cover up") },/*       S      */{SST(0x66, 0x01, SS_DEF,			"Automatic document feeder lift up") },/*       S      */{SST(0x66, 0x02, SS_DEF,			"Document jam in automatic document feeder") },/*       S      */{SST(0x66, 0x03, SS_DEF,			"Document miss feed automatic in document feeder") },/*           A  */{SST(0x67, 0x00, SS_DEF,			"Configuration failure") },/*           A  */{SST(0x67, 0x01, SS_DEF,			"Configuration of incapable logical units failed") },/*           A  */{SST(0x67, 0x02, SS_DEF,			"Add logical unit failed") },/*           A  */{SST(0x67, 0x03, SS_DEF,			"Modification of logical unit failed") },/*           A  */{SST(0x67, 0x04, SS_DEF,			"Exchange of logical unit failed") },/*           A  */{SST(0x67, 0x05, SS_DEF,			"Remove of logical unit failed") },/*           A  */{SST(0x67, 0x06, SS_DEF,			"Attachment of logical unit failed") },/*           A  */{SST(0x67, 0x07, SS_DEF,			"Creation of logical unit failed") },/*           A  */{SST(0x68, 0x00, SS_DEF,			"Logical unit not configured") },/*           A  */{SST(0x69, 0x00, SS_DEF,			"Data loss on logical unit") },/*           A  */{SST(0x69, 0x01, SS_DEF,			"Multiple logical unit failures") },/*           A  */{SST(0x69, 0x02, SS_DEF,			"Parity/data mismatch") },/*           A  */{SST(0x6A, 0x00, SS_DEF,			"Informational, refer to log") },/*           A  */{SST(0x6B, 0x00, SS_DEF,			"State change has occurred") },/*           A  */{SST(0x6B, 0x01, SS_DEF,			"Redundancy level got better") },/*           A  */{SST(0x6B, 0x02, SS_DEF,			"Redundancy level got worse") },/*           A  */{SST(0x6C, 0x00, SS_DEF,			"Rebuild failure occurred") },/*           A  */{SST(0x6D, 0x00, SS_DEF,			"Recalculate failure occurred") },/*           A  */{SST(0x6E, 0x00, SS_DEF,			"Command to logical unit failed") },/*  T           */{SST(0x70, 0x00, SS_DEF,			"Decompression exception short: ASCQ = Algorithm ID") },/*  T           */{SST(0x70, 0xFF, SS_DEF|SSQ_RANGE,			NULL) }, /* Range 0x00 -> 0xFF *//*  T           */{SST(0x71, 0x00, SS_DEF,			"Decompression exception long: ASCQ = Algorithm ID") },/*  T           */{SST(0x71, 0xFF, SS_DEF|SSQ_RANGE,			NULL) }, /* Range 0x00 -> 0xFF */	/*      R       */{SST(0x72, 0x00, SS_DEF,			"Session fixation error") },/*      R       */{SST(0x72, 0x01, SS_DEF,			"Session fixation error writing lead-in") },/*      R       */{SST(0x72, 0x02, SS_DEF,			"Session fixation error writing lead-out") },/*      R       */{SST(0x72, 0x03, SS_DEF,			"Session fixation error - incomplete track in session") },/*      R       */{SST(0x72, 0x04, SS_DEF,			"Empty or partially written reserved track") },/*      R       */{SST(0x73, 0x00, SS_DEF,			"CD control error") },/*      R       */{SST(0x73, 0x01, SS_DEF,			"Power calibration area almost full") },/*      R       */{SST(0x73, 0x02, SS_NEDEF|ENOSPC,			"Power calibration area is full") },/*      R       */{SST(0x73, 0x03, SS_DEF,			"Power calibration area error") },/*      R       */{SST(0x73, 0x04, SS_DEF,			"Program memory area update failure") },/*      R       */{SST(0x73, 0x05, SS_DEF,			"program memory area is full") }};#if !defined(SCSI_NO_SENSE_STRINGS)const char *scsi_sense_desc(int asc, int ascq, struct scsi_inquiry_data *inq_data){	int i, j;	caddr_t match;	struct asc_table_entry *table[2];	int table_size[2];	int num_tables;	if (inq_data == NULL)		return(NULL);	match = cam_quirkmatch((caddr_t)inq_data,			       (caddr_t)asc_quirk_table,			       sizeof(asc_quirk_table)/sizeof(*asc_quirk_table),			       sizeof(*asc_quirk_table), scsi_inquiry_match);	if (match != NULL) {		table[0] = ((struct scsi_sense_quirk_entry *)match)->asc_info;		table_size[0] = 			((struct scsi_sense_quirk_entry *)match)->num_ascs;		table[1] = asc_text;		table_size[1] = sizeof(asc_text)/sizeof(asc_text[0]);		num_tables = 2;	} else {		table[0] = asc_text;		table_size[0] = sizeof(asc_text)/sizeof(asc_text[0]);		num_tables = 1;	}	for (j = 0; j < num_tables; j++) {		for (i = 0; i < table_size[j]; i++) {			if (table[j][i].asc == asc) {				/* Check for ranges */				if ((table[j][i].action & SSQ_RANGE) != 0) {									if (table[j][i].ascq >= ascq					 && table[j][i-1].ascq <= ascq)						return table[j][i-1].desc;					continue;				}							if (table[j][i].ascq == ascq)					return table[j][i].desc;			} 		}	}	if (asc >= 0x80 && asc <= 0xff)		return "Vendor Specific ASC";	if (ascq >= 0x80 && ascq <= 0xff)		return "Vendor Specific ASCQ";	return "Reserved ASC/ASCQ pair";}#else /* SCSI_NO_SENSE_STRINGS */const char *scsi_sense_desc(int asc, int ascq, struct scsi_inquiry_data *inq_data){	return ("");}#endif/* * Given a particular failed CCB and its device type information, return * the appropriate action from either the sense code quirk table or the * sense code table. */scsi_sense_actionscsi_error_action(int asc, int ascq, struct scsi_inquiry_data *inq_data){	caddr_t match;	struct asc_table_entry *table[2];	int table_size[2];	int num_tables;	int i, j;	/*	 * If we don't have inquiry data, we can't match against any quirk	 * entries.	 */	if (inq_data != NULL) {		match = cam_quirkmatch((caddr_t)inq_data,				       (caddr_t)asc_quirk_table,				       sizeof(asc_quirk_table) /					 sizeof(*asc_quirk_table),				       sizeof(*asc_quirk_table),				       scsi_inquiry_match);	} else		match = NULL;	if (match != NULL) {		table[0] = ((struct scsi_sense_quirk_entry *)match)->asc_info;		table_size[0] = 			((struct scsi_sense_quirk_entry *)match)->num_ascs;		table[1] = asc_text;		table_size[1] = sizeof(asc_text)/sizeof(asc_text[0]);		num_tables = 2;	} else {		table[0] = asc_text;		table_size[0] = sizeof(asc_text)/sizeof(asc_text[0]);		num_tables = 1;	}	for (j = 0; j < num_tables; j++) {		for (i = 0; i < table_size[j]; i++) {			if (table[j][i].asc == asc) {				/* Check for ranges */				if ((table[j][i].action & SSQ_RANGE) != 0){									if (table[j][i].ascq >= ascq					 && table[j][i-1].ascq <= ascq)						return table[j][i].action;					continue;				}				/*				 * Check to see if we have a match.  If the				 * current ascq in the table is greater				 * than our ascq, and there aren't any more				 * tables to search, just return the				 * default action.				 */				if (table[j][i].ascq == ascq)					return(table[j][i].action);				else if ((j == (num_tables - 1)) &&					(table[j][i].ascq > ascq))					return(SS_DEF);			}		}	}	/* 	 * If we get to this point, it's most likely a vendor specific	 * ASC and we don't have a quirk entry for it.  Oh well, we just	 * tell the error handling code to take the default action.	 */	return(SS_DEF);}char *scsi_cdb_string(u_int8_t *cdb_ptr, char *cdb_string, size_t len){	u_int8_t cdb_len;	int i;	if (cdb_ptr == NULL)		return("");	/* Silence warnings */	cdb_len = 0;	/*	 * This is taken from the SCSI-3 draft spec.	 * (T10/1157D revision 0.3)	 * The top 3 bits of an opcode are the group code.  The next 5 bits	 * are the command code.	 * Group 0:  six byte commands	 * Group 1:  ten byte commands	 * Group 2:  ten byte commands	 * Group 3:  reserved	 * Group 4:  sixteen byte commands	 * Group 5:  twelve byte commands	 * Group 6:  vendor specific	 * Group 7:  vendor specific	 */	switch((*cdb_ptr >> 5) & 0x7) {		case 0:			cdb_len = 6;			break;		case 1:		case 2:			cdb_len = 10;			break;		case 3:		case 6:		case 7:			/* in this case, just print out the opcode */			cdb_len = 1;			break;		case 4:			cdb_len = 16;			break;		case 5:			cdb_len = 12;			break;	}	*cdb_string = '\0';	for (i = 0; i < cdb_len; i++)		snprintf(cdb_string + strlen(cdb_string),		    len - strlen(cdb_string), "%x ", cdb_ptr[i]);	return(cdb_string);}/* * scsi_sense_print will decode the sense data into human * readable form.  Sense handlers can use this to generate * a report. *//* * Because scsi_sense_print() utilizes transport layer functions, it will * only work in the kernel. */#ifdef KERNELvoid scsi_sense_print(struct ccb_scsiio *csio){	struct	  scsi_sense_data *sense;	u_int32_t info;	int	  error_code;	int	  sense_key;	int	  asc, ascq;	struct ccb_getdev cgd;	u_int8_t  command_print;	sense = &csio->sense_data;		/*	 * If the CDB is a physical address, we can't deal with it..	 */	if ((csio->ccb_h.flags & CAM_CDB_PHYS) != 0)		command_print = 0;	else		command_print = 1;	/*	 * Get the device information.	 */	xpt_setup_ccb(&cgd.ccb_h,		      csio->ccb_h.path,		      /*priority*/ 1);	cgd.ccb_h.func_code = XPT_GDEV_TYPE;	xpt_action((union ccb *)&cgd);	/*	 * If the device is unconfigured, just pretend that it is a hard	 * drive.  scsi_op_desc() needs this.	 */	if (cgd.ccb_h.status == CAM_DEV_NOT_THERE)		cgd.inq_data.device = T_DIRECT;	if (command_print != 0) {		char cdb_str[(SCSI_MAX_CDBLEN * 3) + 1];		xpt_print_path(csio->ccb_h.path);		if ((csio->ccb_h.flags & CAM_CDB_POINTER) != 0) {			printf("%s. CDB: %s\n", 				scsi_op_desc(csio->cdb_io.cdb_ptr[0],				&cgd.inq_data),				scsi_cdb_string(csio->cdb_io.cdb_ptr, cdb_str,						sizeof(cdb_str)));		} else {			printf("%s. CDB: %s\n",				scsi_op_desc(csio->cdb_io.cdb_bytes[0], 				&cgd.inq_data), scsi_cdb_string(				csio->cdb_io.cdb_bytes, cdb_str,				sizeof(cdb_str)));		}	}	/*	 * If the sense data is a physical pointer, forget it.	 */	if (csio->ccb_h.flags & CAM_SENSE_PTR) {		if (csio->ccb_h.flags & CAM_SENSE_PHYS)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -