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

📄 sym53c8xx_comm.h

📁 讲述linux的初始化过程
💻 H
📖 第 1 页 / 共 5 页
字号:
	gpcntl &= 0xfe;	OUTB (nc_gpcntl, gpcntl);	S24C16_stop(np, &gpreg);	retv = 0;out:	/* return GPIO0/1 to original states after having accessed NVRAM */	OUTB (nc_gpcntl, old_gpcntl);	OUTB (nc_gpreg,  old_gpreg);	return retv;}#undef SET_BIT #undef CLR_BIT #undef SET_CLK #undef CLR_CLK /* *  Try reading Symbios NVRAM. *  Return 0 if OK. */static int __init sym_read_Symbios_nvram (ncr_slot *np, Symbios_nvram *nvram){	static u_char Symbios_trailer[6] = {0xfe, 0xfe, 0, 0, 0, 0};	u_char *data = (u_char *) nvram;	int len  = sizeof(*nvram);	u_short	csum;	int x;	/* probe the 24c16 and read the SYMBIOS 24c16 area */	if (sym_read_S24C16_nvram (np, SYMBIOS_NVRAM_ADDRESS, data, len))		return 1;	/* check valid NVRAM signature, verify byte count and checksum */	if (nvram->type != 0 ||	    memcmp(nvram->trailer, Symbios_trailer, 6) ||	    nvram->byte_count != len - 12)		return 1;	/* verify checksum */	for (x = 6, csum = 0; x < len - 6; x++)		csum += data[x];	if (csum != nvram->checksum)		return 1;	return 0;}/* *  93C46 EEPROM reading. * *  GPOI0 - data in *  GPIO1 - data out *  GPIO2 - clock *  GPIO4 - chip select * *  Used by Tekram. *//* *  Pulse clock bit in GPIO0 */static void __init T93C46_Clk(ncr_slot *np, u_char *gpreg){	OUTB (nc_gpreg, *gpreg | 0x04);	UDELAY (2);	OUTB (nc_gpreg, *gpreg);}/*  *  Read bit from NVRAM */static void __init T93C46_Read_Bit(ncr_slot *np, u_char *read_bit, u_char *gpreg){	UDELAY (2);	T93C46_Clk(np, gpreg);	*read_bit = INB (nc_gpreg);}/* *  Write bit to GPIO0 */static void __init T93C46_Write_Bit(ncr_slot *np, u_char write_bit, u_char *gpreg){	if (write_bit & 0x01)		*gpreg |= 0x02;	else		*gpreg &= 0xfd;			*gpreg |= 0x10;			OUTB (nc_gpreg, *gpreg);	UDELAY (2);	T93C46_Clk(np, gpreg);}/* *  Send STOP condition to NVRAM - puts NVRAM to sleep... ZZZzzz!! */static void __init T93C46_Stop(ncr_slot *np, u_char *gpreg){	*gpreg &= 0xef;	OUTB (nc_gpreg, *gpreg);	UDELAY (2);	T93C46_Clk(np, gpreg);}/* *  Send read command and address to NVRAM */static void __init T93C46_Send_Command(ncr_slot *np, u_short write_data, 		    u_char *read_bit, u_char *gpreg){	int x;	/* send 9 bits, start bit (1), command (2), address (6)  */	for (x = 0; x < 9; x++)		T93C46_Write_Bit(np, (u_char) (write_data >> (8 - x)), gpreg);	*read_bit = INB (nc_gpreg);}/* *  READ 2 bytes from the NVRAM */static void __init T93C46_Read_Word(ncr_slot *np, u_short *nvram_data, u_char *gpreg){	int x;	u_char read_bit;	*nvram_data = 0;	for (x = 0; x < 16; x++) {		T93C46_Read_Bit(np, &read_bit, gpreg);		if (read_bit & 0x01)			*nvram_data |=  (0x01 << (15 - x));		else			*nvram_data &= ~(0x01 << (15 - x));	}}/* *  Read Tekram NvRAM data. */static int __init T93C46_Read_Data(ncr_slot *np, u_short *data,int len,u_char *gpreg){	u_char	read_bit;	int	x;	for (x = 0; x < len; x++)  {		/* output read command and address */		T93C46_Send_Command(np, 0x180 | x, &read_bit, gpreg);		if (read_bit & 0x01)			return 1; /* Bad */		T93C46_Read_Word(np, &data[x], gpreg);		T93C46_Stop(np, gpreg);	}	return 0;}/* *  Try reading 93C46 Tekram NVRAM. */static int __init sym_read_T93C46_nvram (ncr_slot *np, Tekram_nvram *nvram){	u_char gpcntl, gpreg;	u_char old_gpcntl, old_gpreg;	int retv = 1;	/* save current state of GPCNTL and GPREG */	old_gpreg	= INB (nc_gpreg);	old_gpcntl	= INB (nc_gpcntl);	/* set up GPREG & GPCNTL to set GPIO0/1/2/4 in to known state, 0 in,	   1/2/4 out */	gpreg = old_gpreg & 0xe9;	OUTB (nc_gpreg, gpreg);	gpcntl = (old_gpcntl & 0xe9) | 0x09;	OUTB (nc_gpcntl, gpcntl);	/* input all of NVRAM, 64 words */	retv = T93C46_Read_Data(np, (u_short *) nvram,				sizeof(*nvram) / sizeof(short), &gpreg);		/* return GPIO0/1/2/4 to original states after having accessed NVRAM */	OUTB (nc_gpcntl, old_gpcntl);	OUTB (nc_gpreg,  old_gpreg);	return retv;}/* *  Try reading Tekram NVRAM. *  Return 0 if OK. */static int __init sym_read_Tekram_nvram (ncr_slot *np, u_short device_id, Tekram_nvram *nvram){	u_char *data = (u_char *) nvram;	int len = sizeof(*nvram);	u_short	csum;	int x;	switch (device_id) {	case PCI_DEVICE_ID_NCR_53C885:	case PCI_DEVICE_ID_NCR_53C895:	case PCI_DEVICE_ID_NCR_53C896:		x = sym_read_S24C16_nvram(np, TEKRAM_24C16_NVRAM_ADDRESS,					  data, len);		break;	case PCI_DEVICE_ID_NCR_53C875:		x = sym_read_S24C16_nvram(np, TEKRAM_24C16_NVRAM_ADDRESS,					  data, len);		if (!x)			break;	default:		x = sym_read_T93C46_nvram(np, nvram);		break;	}	if (x)		return 1;	/* verify checksum */	for (x = 0, csum = 0; x < len - 1; x += 2)		csum += data[x] + (data[x+1] << 8);	if (csum != 0x1234)		return 1;	return 0;}#endif	/* SCSI_NCR_NVRAM_SUPPORT *//*===================================================================****    Detect and try to read SYMBIOS and TEKRAM NVRAM.****    Data can be used to order booting of boards.****    Data is saved in ncr_device structure if NVRAM found. This**    is then used to find drive boot order for ncr_attach().****    NVRAM data is passed to Scsi_Host_Template later during **    ncr_attach() for any device set up.****===================================================================*/#ifdef SCSI_NCR_NVRAM_SUPPORTstatic void __init ncr_get_nvram(ncr_device *devp, ncr_nvram *nvp){	devp->nvram = nvp;	if (!nvp)		return;	/*	**    Get access to chip IO registers	*/#ifdef NCR_IOMAPPED	request_region(devp->slot.io_port, 128, NAME53C8XX);	devp->slot.base_io = devp->slot.io_port;#else	devp->slot.reg = (struct ncr_reg *) remap_pci_mem(devp->slot.base, 128);	if (!devp->slot.reg)		return;#endif	/*	**    Try to read SYMBIOS nvram.	**    Try to read TEKRAM nvram if Symbios nvram not found.	*/	if	(!sym_read_Symbios_nvram(&devp->slot, &nvp->data.Symbios))		nvp->type = SCSI_NCR_SYMBIOS_NVRAM;	else if	(!sym_read_Tekram_nvram(&devp->slot, devp->chip.device_id,					&nvp->data.Tekram))		nvp->type = SCSI_NCR_TEKRAM_NVRAM;	else {		nvp->type = 0;		devp->nvram = 0;	}	/*	** Release access to chip IO registers	*/#ifdef NCR_IOMAPPED	release_region(devp->slot.base_io, 128);#else	unmap_pci_mem((u_long) devp->slot.reg, 128ul);#endif}/*===================================================================****	Display the content of NVRAM for debugging purpose.****===================================================================*/#ifdef	SCSI_NCR_DEBUG_NVRAMstatic void __init ncr_display_Symbios_nvram(Symbios_nvram *nvram){	int i;	/* display Symbios nvram host data */	printk(KERN_DEBUG NAME53C8XX ": HOST ID=%d%s%s%s%s%s\n",		nvram->host_id & 0x0f,		(nvram->flags  & SYMBIOS_SCAM_ENABLE)	? " SCAM"	:"",		(nvram->flags  & SYMBIOS_PARITY_ENABLE)	? " PARITY"	:"",		(nvram->flags  & SYMBIOS_VERBOSE_MSGS)	? " VERBOSE"	:"", 		(nvram->flags  & SYMBIOS_CHS_MAPPING)	? " CHS_ALT"	:"", 		(nvram->flags1 & SYMBIOS_SCAN_HI_LO)	? " HI_LO"	:"");	/* display Symbios nvram drive data */	for (i = 0 ; i < 15 ; i++) {		struct Symbios_target *tn = &nvram->target[i];		printk(KERN_DEBUG NAME53C8XX 		"-%d:%s%s%s%s WIDTH=%d SYNC=%d TMO=%d\n",		i,		(tn->flags & SYMBIOS_DISCONNECT_ENABLE)	? " DISC"	: "",		(tn->flags & SYMBIOS_SCAN_AT_BOOT_TIME)	? " SCAN_BOOT"	: "",		(tn->flags & SYMBIOS_SCAN_LUNS)		? " SCAN_LUNS"	: "",		(tn->flags & SYMBIOS_QUEUE_TAGS_ENABLED)? " TCQ"	: "",		tn->bus_width,		tn->sync_period / 4,		tn->timeout);	}}static u_char Tekram_boot_delay[7] __initdata = {3, 5, 10, 20, 30, 60, 120};static void __init ncr_display_Tekram_nvram(Tekram_nvram *nvram){	int i, tags, boot_delay;	char *rem;	/* display Tekram nvram host data */	tags = 2 << nvram->max_tags_index;	boot_delay = 0;	if (nvram->boot_delay_index < 6)		boot_delay = Tekram_boot_delay[nvram->boot_delay_index];	switch((nvram->flags & TEKRAM_REMOVABLE_FLAGS) >> 6) {	default:	case 0:	rem = "";			break;	case 1: rem = " REMOVABLE=boot device";	break;	case 2: rem = " REMOVABLE=all";		break;	}	printk(KERN_DEBUG NAME53C8XX		": HOST ID=%d%s%s%s%s%s%s%s%s%s BOOT DELAY=%d tags=%d\n",		nvram->host_id & 0x0f,		(nvram->flags1 & SYMBIOS_SCAM_ENABLE)	? " SCAM"	:"",		(nvram->flags & TEKRAM_MORE_THAN_2_DRIVES) ? " >2DRIVES":"",		(nvram->flags & TEKRAM_DRIVES_SUP_1GB)	? " >1GB"	:"",		(nvram->flags & TEKRAM_RESET_ON_POWER_ON) ? " RESET"	:"",		(nvram->flags & TEKRAM_ACTIVE_NEGATION)	? " ACT_NEG"	:"",		(nvram->flags & TEKRAM_IMMEDIATE_SEEK)	? " IMM_SEEK"	:"",		(nvram->flags & TEKRAM_SCAN_LUNS)	? " SCAN_LUNS"	:"",		(nvram->flags1 & TEKRAM_F2_F6_ENABLED)	? " F2_F6"	:"",		rem, boot_delay, tags);	/* display Tekram nvram drive data */	for (i = 0; i <= 15; i++) {		int sync, j;		struct Tekram_target *tn = &nvram->target[i];		j = tn->sync_index & 0xf;		sync = Tekram_sync[j];		printk(KERN_DEBUG NAME53C8XX "-%d:%s%s%s%s%s%s PERIOD=%d\n",		i,		(tn->flags & TEKRAM_PARITY_CHECK)	? " PARITY"	: "",		(tn->flags & TEKRAM_SYNC_NEGO)		? " SYNC"	: "",		(tn->flags & TEKRAM_DISCONNECT_ENABLE)	? " DISC"	: "",		(tn->flags & TEKRAM_START_CMD)		? " START"	: "",		(tn->flags & TEKRAM_TAGGED_COMMANDS)	? " TCQ"	: "",		(tn->flags & TEKRAM_WIDE_NEGO)		? " WIDE"	: "",		sync);	}}#endif /* SCSI_NCR_DEBUG_NVRAM */#endif	/* SCSI_NCR_NVRAM_SUPPORT *//*===================================================================****	Utility routines that protperly return data through /proc FS.****===================================================================*/#ifdef SCSI_NCR_USER_INFO_SUPPORTstruct info_str{	char *buffer;	int length;	int offset;	int pos;};static void copy_mem_info(struct info_str *info, char *data, int len){	if (info->pos + len > info->length)		len = info->length - info->pos;	if (info->pos + len < info->offset) {		info->pos += len;		return;	}	if (info->pos < info->offset) {		data += (info->offset - info->pos);		len  -= (info->offset - info->pos);	}	if (len > 0) {		memcpy(info->buffer + info->pos, data, len);		info->pos += len;	}}static int copy_info(struct info_str *info, char *fmt, ...){	va_list args;	char buf[81];	int len;	va_start(args, fmt);	len = vsprintf(buf, fmt, args);	va_end(args);	copy_mem_info(info, buf, len);	return len;}#endif/*===================================================================****	Driver setup from the boot command line****===================================================================*/#ifdef MODULE#define	ARG_SEP	' '#else#define	ARG_SEP	','#endif#define OPT_TAGS		1#define OPT_MASTER_PARITY	2#define OPT_SCSI_PARITY		3#define OPT_DISCONNECTION	4#define OPT_SPECIAL_FEATURES	5#define OPT_ULTRA_SCSI		6#define OPT_FORCE_SYNC_NEGO	7#define OPT_REVERSE_PROBE	8#define OPT_DEFAULT_SYNC	9#define OPT_VERBOSE		10#define OPT_DEBUG		11#define OPT_BURST_MAX		12#define OPT_LED_PIN		13#define OPT_MAX_WIDE		14#define OPT_SETTLE_DELAY	15#define OPT_DIFF_SUPPORT	16#define OPT_IRQM		17#define OPT_PCI_FIX_UP		18#define OPT_BUS_CHECK		19#define OPT_OPTIMIZE		20#define OPT_RECOVERY		21#define OPT_SAFE_SETUP		22#define OPT_USE_NVRAM		23#define OPT_EXCLUDE		24#define OPT_HOST_ID		25#ifdef SCSI_NCR_IARB_SUPPORT#define OPT_IARB		26#endifstatic char setup_token[] __initdata = 	"tags:"   "mpar:"	"spar:"   "disc:"	"specf:"  "ultra:"	"fsn:"    "revprob:"	"sync:"   "verb:"	"debug:"  "burst:"	"led:"    "wide:"	"settle:" "diff:"	"irqm:"   "pcifix:"	"buschk:" "optim:"	"recovery:"	"safe:"   "nvram:"	"excl:"   "hostid:"#ifdef SCSI_NCR_IARB_SUPPORT	"iarb:"#endif	;	/* DONNOT REMOVE THIS ';' */#ifdef MODULE#define	ARG_SEP	' '#else#define	ARG_SEP	','#endifstatic int __init get_setup_token(char *p){	char *cur = setup_token;	char *pc;	int i = 0;

⌨️ 快捷键说明

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