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

📄 i2o_proc.c

📁 内核linux2.4.20,可跟rtlinux3.2打补丁 组成实时linux系统,编译内核
💻 C
📖 第 1 页 / 共 5 页
字号:
	len = 0;		result = kmalloc(sizeof(i2o_driver_result_table), GFP_KERNEL);	if(result == NULL)		return -ENOMEM;	spin_lock(&i2o_proc_lock);	token = i2o_query_table(I2O_PARAMS_TABLE_GET,				c, ADAPTER_TID, 0x0005, -1, NULL, 0, 				result, sizeof(*result));	if (token < 0) {		len += i2o_report_query_status(buf+len, token,"0x0005 DRIVER STORE TABLE");		spin_unlock(&i2o_proc_lock);		kfree(result);		return len;	}	len += sprintf(buf+len, "#  Module_type     Vendor Mod_id  Module_name             Vrs"  				"Date     Mod_size Par_size Flags\n");	for(i=0, dst=&result->dst[0]; i < result->row_count; dst=&result->dst[++i])	{		len += sprintf(buf+len, "%-3d", dst->stored_ddm_index);		switch(dst->module_type)		{		case 0x01:			len += sprintf(buf+len, "Downloaded DDM  ");			break;					case 0x22:			len += sprintf(buf+len, "Embedded DDM    ");			break;		default:			len += sprintf(buf+len, "                ");		}#if 0		if(c->i2oversion == 0x02)			len += sprintf(buf+len, "%-d", dst->module_state);#endif		len += sprintf(buf+len, "%-#7x", dst->i2o_vendor_id);		len += sprintf(buf+len, "%-#8x", dst->module_id);		len += sprintf(buf+len, "%-29s", chtostr(dst->module_name_version,28));		len += sprintf(buf+len, "%-9s", chtostr(dst->date,8));		len += sprintf(buf+len, "%8d ", dst->module_size);		len += sprintf(buf+len, "%8d ", dst->mpb_size);		len += sprintf(buf+len, "0x%04x", dst->module_flags);#if 0		if(c->i2oversion == 0x02)			len += sprintf(buf+len, "%d",				       dst->notification_level);#endif		len += sprintf(buf+len, "\n");	}	spin_unlock(&i2o_proc_lock);	kfree(result);	return len;}/* Generic group F000h - Params Descriptor (table) */int i2o_proc_read_groups(char *buf, char **start, off_t offset, int len, 			 int *eof, void *data){	struct i2o_device *d = (struct i2o_device*)data;	int token;	int i;	u8 properties;	typedef struct _i2o_group_info	{		u16 group_number;		u16 field_count;		u16 row_count;		u8  properties;		u8  reserved;	} i2o_group_info;	struct	{		u16 result_count;		u16 pad;		u16 block_size;		u8  block_status;		u8  error_info_size;		u16 row_count;		u16 more_flag;		i2o_group_info group[256];	} result;	spin_lock(&i2o_proc_lock);	len = 0;	token = i2o_query_table(I2O_PARAMS_TABLE_GET,				d->controller, d->lct_data.tid, 0xF000, -1, NULL, 0,				&result, sizeof(result));	if (token < 0) {		len = i2o_report_query_status(buf+len, token, "0xF000 Params Descriptor");		spin_unlock(&i2o_proc_lock);		return len;	}	len += sprintf(buf+len, "#  Group   FieldCount RowCount Type   Add Del Clear\n");	for (i=0; i < result.row_count; i++)	{		len += sprintf(buf+len, "%-3d", i);		len += sprintf(buf+len, "0x%04X ", result.group[i].group_number);		len += sprintf(buf+len, "%10d ", result.group[i].field_count);		len += sprintf(buf+len, "%8d ",  result.group[i].row_count);		properties = result.group[i].properties;		if (properties & 0x1)	len += sprintf(buf+len, "Table  ");				else	len += sprintf(buf+len, "Scalar ");		if (properties & 0x2)	len += sprintf(buf+len, " + ");				else	len += sprintf(buf+len, " - ");		if (properties & 0x4)	len += sprintf(buf+len, "  + ");				else	len += sprintf(buf+len, "  - ");		if (properties & 0x8)	len += sprintf(buf+len, "  + ");				else	len += sprintf(buf+len, "  - ");		len += sprintf(buf+len, "\n");	}	if (result.more_flag)		len += sprintf(buf+len, "There is more...\n");	spin_unlock(&i2o_proc_lock);	return len;}/* Generic group F001h - Physical Device Table (table) */int i2o_proc_read_phys_device(char *buf, char **start, off_t offset, int len,			      int *eof, void *data){	struct i2o_device *d = (struct i2o_device*)data;	int token;	int i;	struct	{		u16 result_count;		u16 pad;		u16 block_size;		u8  block_status;		u8  error_info_size;		u16 row_count;		u16 more_flag;		u32 adapter_id[64];	} result;	spin_lock(&i2o_proc_lock);	len = 0;	token = i2o_query_table(I2O_PARAMS_TABLE_GET,				d->controller, d->lct_data.tid,				0xF001, -1, NULL, 0,				&result, sizeof(result));	if (token < 0) {		len += i2o_report_query_status(buf+len, token,"0xF001 Physical Device Table");		spin_unlock(&i2o_proc_lock);		return len;	}	if (result.row_count)		len += sprintf(buf+len, "#  AdapterId\n");	for (i=0; i < result.row_count; i++)	{		len += sprintf(buf+len, "%-2d", i);		len += sprintf(buf+len, "%#7x\n", result.adapter_id[i]);	}	if (result.more_flag)		len += sprintf(buf+len, "There is more...\n");	spin_unlock(&i2o_proc_lock);	return len;}/* Generic group F002h - Claimed Table (table) */int i2o_proc_read_claimed(char *buf, char **start, off_t offset, int len,			  int *eof, void *data){	struct i2o_device *d = (struct i2o_device*)data;	int token;	int i;	struct {		u16 result_count;		u16 pad;		u16 block_size;		u8  block_status;		u8  error_info_size;		u16 row_count;		u16 more_flag;		u16 claimed_tid[64];	} result;	spin_lock(&i2o_proc_lock);	len = 0;	token = i2o_query_table(I2O_PARAMS_TABLE_GET,				d->controller, d->lct_data.tid,				0xF002, -1, NULL, 0,				&result, sizeof(result));	if (token < 0) {		len += i2o_report_query_status(buf+len, token,"0xF002 Claimed Table");		spin_unlock(&i2o_proc_lock);		return len;	}	if (result.row_count)		len += sprintf(buf+len, "#  ClaimedTid\n");	for (i=0; i < result.row_count; i++)	{		len += sprintf(buf+len, "%-2d", i);		len += sprintf(buf+len, "%#7x\n", result.claimed_tid[i]);	}	if (result.more_flag)		len += sprintf(buf+len, "There is more...\n");	spin_unlock(&i2o_proc_lock);	return len;}/* Generic group F003h - User Table (table) */int i2o_proc_read_users(char *buf, char **start, off_t offset, int len,			int *eof, void *data){	struct i2o_device *d = (struct i2o_device*)data;	int token;	int i;	typedef struct _i2o_user_table	{		u16 instance;		u16 user_tid;		u8 claim_type;		u8  reserved1;		u16  reserved2;	} i2o_user_table;	struct	{		u16 result_count;		u16 pad;		u16 block_size;		u8  block_status;		u8  error_info_size;		u16 row_count;		u16 more_flag;		i2o_user_table user[64];	} result;	spin_lock(&i2o_proc_lock);	len = 0;	token = i2o_query_table(I2O_PARAMS_TABLE_GET,				d->controller, d->lct_data.tid,				0xF003, -1, NULL, 0,				&result, sizeof(result));	if (token < 0) {		len += i2o_report_query_status(buf+len, token,"0xF003 User Table");		spin_unlock(&i2o_proc_lock);		return len;	}	len += sprintf(buf+len, "#  Instance UserTid ClaimType\n");	for(i=0; i < result.row_count; i++)	{		len += sprintf(buf+len, "%-3d", i);		len += sprintf(buf+len, "%#8x ", result.user[i].instance);		len += sprintf(buf+len, "%#7x ", result.user[i].user_tid);		len += sprintf(buf+len, "%#9x\n", result.user[i].claim_type);	}	if (result.more_flag)		len += sprintf(buf+len, "There is more...\n");	spin_unlock(&i2o_proc_lock);	return len;}/* Generic group F005h - Private message extensions (table) (optional) */int i2o_proc_read_priv_msgs(char *buf, char **start, off_t offset, int len, 			    int *eof, void *data){	struct i2o_device *d = (struct i2o_device*)data;	int token;	int i;	typedef struct _i2o_private	{		u16 ext_instance;		u16 organization_id;		u16 x_function_code;	} i2o_private;	struct	{		u16 result_count;		u16 pad;		u16 block_size;		u8  block_status;		u8  error_info_size;		u16 row_count;		u16 more_flag;		i2o_private extension[64];	} result;	spin_lock(&i2o_proc_lock);	len = 0;	token = i2o_query_table(I2O_PARAMS_TABLE_GET,				d->controller, d->lct_data.tid,				0xF000, -1,				NULL, 0,				&result, sizeof(result));	if (token < 0) {		len += i2o_report_query_status(buf+len, token,"0xF005 Private Message Extensions (optional)");		spin_unlock(&i2o_proc_lock);		return len;	}		len += sprintf(buf+len, "Instance#  OrgId  FunctionCode\n");	for(i=0; i < result.row_count; i++)	{		len += sprintf(buf+len, "%0#9x ", result.extension[i].ext_instance);		len += sprintf(buf+len, "%0#6x ", result.extension[i].organization_id);		len += sprintf(buf+len, "%0#6x",  result.extension[i].x_function_code);		len += sprintf(buf+len, "\n");	}	if(result.more_flag)		len += sprintf(buf+len, "There is more...\n");	spin_unlock(&i2o_proc_lock);	return len;}/* Generic group F006h - Authorized User Table (table) */int i2o_proc_read_authorized_users(char *buf, char **start, off_t offset, int len,				   int *eof, void *data){	struct i2o_device *d = (struct i2o_device*)data;	int token;	int i;	struct	{		u16 result_count;		u16 pad;		u16 block_size;		u8  block_status;		u8  error_info_size;		u16 row_count;		u16 more_flag;		u32 alternate_tid[64];	} result;	spin_lock(&i2o_proc_lock);	len = 0;	token = i2o_query_table(I2O_PARAMS_TABLE_GET,				d->controller, d->lct_data.tid,				0xF006, -1,				NULL, 0,				&result, sizeof(result));	if (token < 0) {		len += i2o_report_query_status(buf+len, token,"0xF006 Autohorized User Table");		spin_unlock(&i2o_proc_lock);		return len;	}	if (result.row_count)		len += sprintf(buf+len, "#  AlternateTid\n");	for(i=0; i < result.row_count; i++)	{		len += sprintf(buf+len, "%-2d", i);		len += sprintf(buf+len, "%#7x ", result.alternate_tid[i]);	}	if (result.more_flag)		len += sprintf(buf+len, "There is more...\n");	spin_unlock(&i2o_proc_lock);	return len;}/* Generic group F100h - Device Identity (scalar) */int i2o_proc_read_dev_identity(char *buf, char **start, off_t offset, int len, 			       int *eof, void *data){	struct i2o_device *d = (struct i2o_device*)data;	static u32 work32[128];		// allow for "stuff" + up to 256 byte (max) serial number					// == (allow) 512d bytes (max)	static u16 *work16 = (u16*)work32;	int token;	spin_lock(&i2o_proc_lock);		len = 0;	token = i2o_query_scalar(d->controller, d->lct_data.tid,				0xF100,	-1,				&work32, sizeof(work32));	if (token < 0) {		len += i2o_report_query_status(buf+len, token ,"0xF100 Device Identity");		spin_unlock(&i2o_proc_lock);		return len;	}		len += sprintf(buf,     "Device Class  : %s\n", i2o_get_class_name(work16[0]));	len += sprintf(buf+len, "Owner TID     : %0#5x\n", work16[2]);	len += sprintf(buf+len, "Parent TID    : %0#5x\n", work16[3]);	len += sprintf(buf+len, "Vendor info   : %s\n", chtostr((u8 *)(work32+2), 16));	len += sprintf(buf+len, "Product info  : %s\n", chtostr((u8 *)(work32+6), 16));	len += sprintf(buf+len, "Description   : %s\n", chtostr((u8 *)(work32+10), 16));	len += sprintf(buf+len, "Product rev.  : %s\n", chtostr((u8 *)(work32+14), 8));	len += sprintf(buf+len, "Serial number : ");	len = print_serial_number(buf, len,			(u8*)(work32+16),						/* allow for SNLen plus						 * possible trailing '\0'						 */			sizeof(work32)-(16*sizeof(u32))-2				);	len +=  sprintf(buf+len, "\n");	spin_unlock(&i2o_proc_lock);	return len;}int i2o_proc_read_dev_name(char *buf, char **start, off_t offset, int len,	int *eof, void *data){	struct i2o_device *d = (struct i2o_device*)data;	if ( d->dev_name[0] == '\0' )		return 0;	len = sprintf(buf, "%s\n", d->dev_name);	return len;}/* Generic group F101h - DDM Identity (scalar) */int i2o_proc_read_ddm_identity(char *buf, char **start, off_t offset, int len, 			      int *eof, void *data)

⌨️ 快捷键说明

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