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

📄 sym_fw.c

📁 内核linux2.4.20,可跟rtlinux3.2打补丁 组成实时linux系统,编译内核
💻 C
📖 第 1 页 / 共 2 页
字号:
		*out++ = offsetof (struct sym_dsb, data[i]);	}}/* *  Setup useful script bus addresses. *  To be done for all firmwares. */static void sym_fw_setup_bus_addresses(hcb_p np, struct sym_fw *fw){	u32 *pa;	u_short *po;	int i;	/*	 *  Build the bus address table for script A 	 *  from the script A offset table.	 */	po = (u_short *) fw->a_ofs;	pa = (u32 *) &np->fwa_bas;	for (i = 0 ; i < sizeof(np->fwa_bas)/sizeof(u32) ; i++)		pa[i] = np->scripta_ba + po[i];	/*	 *  Same for script B.	 */	po = (u_short *) fw->b_ofs;	pa = (u32 *) &np->fwb_bas;	for (i = 0 ; i < sizeof(np->fwb_bas)/sizeof(u32) ; i++)		pa[i] = np->scriptb_ba + po[i];	/*	 *  Same for script Z.	 */	po = (u_short *) fw->z_ofs;	pa = (u32 *) &np->fwz_bas;	for (i = 0 ; i < sizeof(np->fwz_bas)/sizeof(u32) ; i++)		pa[i] = np->scriptz_ba + po[i];}#if	SYM_CONF_GENERIC_SUPPORT/* *  Setup routine for firmware #1. */static void sym_fw1_setup(hcb_p np, struct sym_fw *fw){	struct sym_fw1a_scr *scripta0;	struct sym_fw1b_scr *scriptb0;	scripta0 = (struct sym_fw1a_scr *) np->scripta0;	scriptb0 = (struct sym_fw1b_scr *) np->scriptb0;	/*	 *  Fill variable parts in scripts.	 */	sym_fw_fill_data(scripta0->data_in, scripta0->data_out);	/*	 *  Setup bus addresses used from the C code..	 */	sym_fw_setup_bus_addresses(np, fw);}#endif	/* SYM_CONF_GENERIC_SUPPORT *//* *  Setup routine for firmware #2. */static void sym_fw2_setup(hcb_p np, struct sym_fw *fw){	struct sym_fw2a_scr *scripta0;	struct sym_fw2b_scr *scriptb0;	scripta0 = (struct sym_fw2a_scr *) np->scripta0;	scriptb0 = (struct sym_fw2b_scr *) np->scriptb0;	/*	 *  Fill variable parts in scripts.	 */	sym_fw_fill_data(scripta0->data_in, scripta0->data_out);	/*	 *  Setup bus addresses used from the C code..	 */	sym_fw_setup_bus_addresses(np, fw);}/* *  Allocate firmware descriptors. */#if	SYM_CONF_GENERIC_SUPPORTstatic struct sym_fw sym_fw1 = SYM_FW_ENTRY(sym_fw1, "NCR-generic");#endif	/* SYM_CONF_GENERIC_SUPPORT */static struct sym_fw sym_fw2 = SYM_FW_ENTRY(sym_fw2, "LOAD/STORE-based");/* *  Find the most appropriate firmware for a chip. */struct sym_fw * sym_find_firmware(struct sym_pci_chip *chip){	if (chip->features & FE_LDSTR)		return &sym_fw2;#if	SYM_CONF_GENERIC_SUPPORT	else if (!(chip->features & (FE_PFEN|FE_NOPM|FE_DAC)))		return &sym_fw1;#endif	else		return 0;}/* *  Bind a script to physical addresses. */void sym_fw_bind_script (hcb_p np, u32 *start, int len){	u32 opcode, new, old, tmp1, tmp2;	u32 *end, *cur;	int relocs;	cur = start;	end = start + len/4;	while (cur < end) {		opcode = *cur;		/*		 *  If we forget to change the length		 *  in scripts, a field will be		 *  padded with 0. This is an illegal		 *  command.		 */		if (opcode == 0) {			printf ("%s: ERROR0 IN SCRIPT at %d.\n",				sym_name(np), (int) (cur-start));			MDELAY (10000);			++cur;			continue;		};		/*		 *  We use the bogus value 0xf00ff00f ;-)		 *  to reserve data area in SCRIPTS.		 */		if (opcode == SCR_DATA_ZERO) {			*cur++ = 0;			continue;		}		if (DEBUG_FLAGS & DEBUG_SCRIPT)			printf ("%d:  <%x>\n", (int) (cur-start),				(unsigned)opcode);		/*		 *  We don't have to decode ALL commands		 */		switch (opcode >> 28) {		case 0xf:			/*			 *  LOAD / STORE DSA relative, don't relocate.			 */			relocs = 0;			break;		case 0xe:			/*			 *  LOAD / STORE absolute.			 */			relocs = 1;			break;		case 0xc:			/*			 *  COPY has TWO arguments.			 */			relocs = 2;			tmp1 = cur[1];			tmp2 = cur[2];			if ((tmp1 ^ tmp2) & 3) {				printf ("%s: ERROR1 IN SCRIPT at %d.\n",					sym_name(np), (int) (cur-start));				MDELAY (10000);			}			/*			 *  If PREFETCH feature not enabled, remove 			 *  the NO FLUSH bit if present.			 */			if ((opcode & SCR_NO_FLUSH) &&			    !(np->features & FE_PFEN)) {				opcode = (opcode & ~SCR_NO_FLUSH);			}			break;		case 0x0:			/*			 *  MOVE/CHMOV (absolute address)			 */			if (!(np->features & FE_WIDE))				opcode = (opcode | OPC_MOVE);			relocs = 1;			break;		case 0x1:			/*			 *  MOVE/CHMOV (table indirect)			 */			if (!(np->features & FE_WIDE))				opcode = (opcode | OPC_MOVE);			relocs = 0;			break;#ifdef SYM_CONF_TARGET_ROLE_SUPPORT		case 0x2:			/*			 *  MOVE/CHMOV in target role (absolute address)			 */			opcode &= ~0x20000000;			if (!(np->features & FE_WIDE))				opcode = (opcode & ~OPC_TCHMOVE);			relocs = 1;			break;		case 0x3:			/*			 *  MOVE/CHMOV in target role (table indirect)			 */			opcode &= ~0x20000000;			if (!(np->features & FE_WIDE))				opcode = (opcode & ~OPC_TCHMOVE);			relocs = 0;			break;#endif		case 0x8:			/*			 *  JUMP / CALL			 *  dont't relocate if relative :-)			 */			if (opcode & 0x00800000)				relocs = 0;			else if ((opcode & 0xf8400000) == 0x80400000)/*JUMP64*/				relocs = 2;			else				relocs = 1;			break;		case 0x4:		case 0x5:		case 0x6:		case 0x7:			relocs = 1;			break;		default:			relocs = 0;			break;		};		/*		 *  Scriptify:) the opcode.		 */		*cur++ = cpu_to_scr(opcode);		/*		 *  If no relocation, assume 1 argument 		 *  and just scriptize:) it.		 */		if (!relocs) {			*cur = cpu_to_scr(*cur);			++cur;			continue;		}		/*		 *  Otherwise performs all needed relocations.		 */		while (relocs--) {			old = *cur;			switch (old & RELOC_MASK) {			case RELOC_REGISTER:				new = (old & ~RELOC_MASK) + np->mmio_ba;				break;			case RELOC_LABEL_A:				new = (old & ~RELOC_MASK) + np->scripta_ba;				break;			case RELOC_LABEL_B:				new = (old & ~RELOC_MASK) + np->scriptb_ba;				break;			case RELOC_SOFTC:				new = (old & ~RELOC_MASK) + np->hcb_ba;				break;			case 0:				/*				 *  Don't relocate a 0 address.				 *  They are mostly used for patched or 				 *  script self-modified areas.				 */				if (old == 0) {					new = old;					break;				}				/* fall through */			default:				new = 0;				panic("sym_fw_bind_script: "				      "weird relocation %x\n", old);				break;			}			*cur++ = cpu_to_scr(new);		}	};}

⌨️ 快捷键说明

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