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

📄 micro.c

📁 改写的U-boot for s3c4510 (注意此源码是在windows下压缩了)。 1、支持串口下载
💻 C
📖 第 1 页 / 共 5 页
字号:
	"DREXIT1",      /* 0x05 */	"DRPAUSE",      /* 0x06 */	"DREXIT2",      /* 0x07 */	"DRUPDATE",     /* 0x08 */	"IRSELECT",     /* 0x09 */	"IRCAPTURE",    /* 0x0A */	"IRSHIFT",      /* 0x0B */	"IREXIT1",      /* 0x0C */	"IRPAUSE",      /* 0x0D */	"IREXIT2",      /* 0x0E */	"IRUPDATE"      /* 0x0F */};#endif  /* DEBUG_MODE *//*#ifdef DEBUG_MODE	*//*    FILE* in;   /XXX* Legacy DEBUG_MODE file pointer */int xsvf_iDebugLevel;/*#endif /XXX* DEBUG_MODE *//*============================================================================ * Utility Functions ============================================================================*//***************************************************************************** * Function:     xsvfPrintLenVal * Description:  Print the lenval value in hex. * Parameters:   plv     - ptr to lenval. * Returns:      void. *****************************************************************************/#ifdef  DEBUG_MODEvoid xsvfPrintLenVal( lenVal *plv ){	int i;	if ( plv )	{		printf( "0x" );		for ( i = 0; i < plv->len; ++i )		{			printf( "%02x", ((unsigned int)(plv->val[ i ])) );		}	}}#endif  /* DEBUG_MODE *//***************************************************************************** * Function:     xsvfInfoInit * Description:  Initialize the xsvfInfo data. * Parameters:   pXsvfInfo   - ptr to the XSVF info structure. * Returns:      int         - 0 = success; otherwise error. *****************************************************************************/int xsvfInfoInit( SXsvfInfo* pXsvfInfo ){	XSVFDBG_PRINTF1( 4, "    sizeof( SXsvfInfo ) = %d bytes\n",			 sizeof( SXsvfInfo ) );	pXsvfInfo->ucComplete       = 0;	pXsvfInfo->ucCommand        = XCOMPLETE;	pXsvfInfo->lCommandCount    = 0;	pXsvfInfo->iErrorCode       = XSVF_ERROR_NONE;	pXsvfInfo->ucMaxRepeat      = 0;	pXsvfInfo->ucTapState       = XTAPSTATE_RESET;	pXsvfInfo->ucEndIR          = XTAPSTATE_RUNTEST;	pXsvfInfo->ucEndDR          = XTAPSTATE_RUNTEST;	pXsvfInfo->lShiftLengthBits = 0L;	pXsvfInfo->sShiftLengthBytes= 0;	pXsvfInfo->lRunTestTime     = 0L;	return( 0 );}/***************************************************************************** * Function:     xsvfInfoCleanup * Description:  Cleanup the xsvfInfo data. * Parameters:   pXsvfInfo   - ptr to the XSVF info structure. * Returns:      void. *****************************************************************************/void xsvfInfoCleanup( SXsvfInfo* pXsvfInfo ){}/***************************************************************************** * Function:     xsvfGetAsNumBytes * Description:  Calculate the number of bytes the given number of bits *               consumes. * Parameters:   lNumBits    - the number of bits. * Returns:      short       - the number of bytes to store the number of bits. *****************************************************************************/short xsvfGetAsNumBytes( long lNumBits ){	return( (short)( ( lNumBits + 7L ) / 8L ) );}/***************************************************************************** * Function:     xsvfTmsTransition * Description:  Apply TMS and transition TAP controller by applying one TCK *               cycle. * Parameters:   sTms    - new TMS value. * Returns:      void. *****************************************************************************/void xsvfTmsTransition( short sTms ){	setPort( TMS, sTms );	setPort( TCK, 0 );	setPort( TCK, 1 );}/***************************************************************************** * Function:     xsvfGotoTapState * Description:  From the current TAP state, go to the named TAP state. *               A target state of RESET ALWAYS causes TMS reset sequence. *               All SVF standard stable state paths are supported. *               All state transitions are supported except for the following *               which cause an XSVF_ERROR_ILLEGALSTATE: *                   - Target==DREXIT2;  Start!=DRPAUSE *                   - Target==IREXIT2;  Start!=IRPAUSE * Parameters:   pucTapState     - Current TAP state; returns final TAP state. *               ucTargetState   - New target TAP state. * Returns:      int             - 0 = success; otherwise error. *****************************************************************************/int xsvfGotoTapState( unsigned char*   pucTapState,		      unsigned char    ucTargetState ){	int i;	int iErrorCode;	iErrorCode  = XSVF_ERROR_NONE;	if ( ucTargetState == XTAPSTATE_RESET )	{		/* If RESET, always perform TMS reset sequence to reset/sync TAPs */		xsvfTmsTransition( 1 );		for ( i = 0; i < 5; ++i )		{			setPort( TCK, 0 );			setPort( TCK, 1 );		}		*pucTapState    = XTAPSTATE_RESET;		XSVFDBG_PRINTF( 3, "   TMS Reset Sequence -> Test-Logic-Reset\n" );		XSVFDBG_PRINTF1( 3, "   TAP State = %s\n",				 xsvf_pzTapState[ *pucTapState ] );	} else if ( ( ucTargetState != *pucTapState ) &&		  ( ( ( ucTargetState == XTAPSTATE_EXIT2DR ) && ( *pucTapState != XTAPSTATE_PAUSEDR ) ) ||		    ( ( ucTargetState == XTAPSTATE_EXIT2IR ) && ( *pucTapState != XTAPSTATE_PAUSEIR ) ) ) )	{		/* Trap illegal TAP state path specification */		iErrorCode      = XSVF_ERROR_ILLEGALSTATE;	} else {		if ( ucTargetState == *pucTapState )		{			/* Already in target state.  Do nothing except when in DRPAUSE			   or in IRPAUSE to comply with SVF standard */			if ( ucTargetState == XTAPSTATE_PAUSEDR )			{				xsvfTmsTransition( 1 );				*pucTapState    = XTAPSTATE_EXIT2DR;				XSVFDBG_PRINTF1( 3, "   TAP State = %s\n",						 xsvf_pzTapState[ *pucTapState ] );			}			else if ( ucTargetState == XTAPSTATE_PAUSEIR )			{				xsvfTmsTransition( 1 );				*pucTapState    = XTAPSTATE_EXIT2IR;				XSVFDBG_PRINTF1( 3, "   TAP State = %s\n",						 xsvf_pzTapState[ *pucTapState ] );			}		}		/* Perform TAP state transitions to get to the target state */		while ( ucTargetState != *pucTapState )		{			switch ( *pucTapState )			{			case XTAPSTATE_RESET:				xsvfTmsTransition( 0 );				*pucTapState    = XTAPSTATE_RUNTEST;				break;			case XTAPSTATE_RUNTEST:				xsvfTmsTransition( 1 );				*pucTapState    = XTAPSTATE_SELECTDR;				break;			case XTAPSTATE_SELECTDR:				if ( ucTargetState >= XTAPSTATE_IRSTATES )				{					xsvfTmsTransition( 1 );					*pucTapState    = XTAPSTATE_SELECTIR;				}				else				{					xsvfTmsTransition( 0 );					*pucTapState    = XTAPSTATE_CAPTUREDR;				}				break;			case XTAPSTATE_CAPTUREDR:				if ( ucTargetState == XTAPSTATE_SHIFTDR )				{					xsvfTmsTransition( 0 );					*pucTapState    = XTAPSTATE_SHIFTDR;				}				else				{					xsvfTmsTransition( 1 );					*pucTapState    = XTAPSTATE_EXIT1DR;				}				break;			case XTAPSTATE_SHIFTDR:				xsvfTmsTransition( 1 );				*pucTapState    = XTAPSTATE_EXIT1DR;				break;			case XTAPSTATE_EXIT1DR:				if ( ucTargetState == XTAPSTATE_PAUSEDR )				{					xsvfTmsTransition( 0 );					*pucTapState    = XTAPSTATE_PAUSEDR;				}				else				{					xsvfTmsTransition( 1 );					*pucTapState    = XTAPSTATE_UPDATEDR;				}				break;			case XTAPSTATE_PAUSEDR:				xsvfTmsTransition( 1 );				*pucTapState    = XTAPSTATE_EXIT2DR;				break;			case XTAPSTATE_EXIT2DR:				if ( ucTargetState == XTAPSTATE_SHIFTDR )				{					xsvfTmsTransition( 0 );					*pucTapState    = XTAPSTATE_SHIFTDR;				}				else				{					xsvfTmsTransition( 1 );					*pucTapState    = XTAPSTATE_UPDATEDR;				}				break;			case XTAPSTATE_UPDATEDR:				if ( ucTargetState == XTAPSTATE_RUNTEST )				{					xsvfTmsTransition( 0 );					*pucTapState    = XTAPSTATE_RUNTEST;				}				else				{					xsvfTmsTransition( 1 );					*pucTapState    = XTAPSTATE_SELECTDR;				}				break;			case XTAPSTATE_SELECTIR:				xsvfTmsTransition( 0 );				*pucTapState    = XTAPSTATE_CAPTUREIR;				break;			case XTAPSTATE_CAPTUREIR:				if ( ucTargetState == XTAPSTATE_SHIFTIR )				{					xsvfTmsTransition( 0 );					*pucTapState    = XTAPSTATE_SHIFTIR;				}				else				{					xsvfTmsTransition( 1 );					*pucTapState    = XTAPSTATE_EXIT1IR;				}				break;			case XTAPSTATE_SHIFTIR:				xsvfTmsTransition( 1 );				*pucTapState    = XTAPSTATE_EXIT1IR;				break;			case XTAPSTATE_EXIT1IR:				if ( ucTargetState == XTAPSTATE_PAUSEIR )				{					xsvfTmsTransition( 0 );					*pucTapState    = XTAPSTATE_PAUSEIR;				}				else				{					xsvfTmsTransition( 1 );					*pucTapState    = XTAPSTATE_UPDATEIR;				}				break;			case XTAPSTATE_PAUSEIR:				xsvfTmsTransition( 1 );				*pucTapState    = XTAPSTATE_EXIT2IR;				break;			case XTAPSTATE_EXIT2IR:				if ( ucTargetState == XTAPSTATE_SHIFTIR )				{					xsvfTmsTransition( 0 );					*pucTapState    = XTAPSTATE_SHIFTIR;				}				else				{					xsvfTmsTransition( 1 );					*pucTapState    = XTAPSTATE_UPDATEIR;				}				break;			case XTAPSTATE_UPDATEIR:				if ( ucTargetState == XTAPSTATE_RUNTEST )				{					xsvfTmsTransition( 0 );					*pucTapState    = XTAPSTATE_RUNTEST;				}				else				{					xsvfTmsTransition( 1 );					*pucTapState    = XTAPSTATE_SELECTDR;				}				break;			default:				iErrorCode      = XSVF_ERROR_ILLEGALSTATE;				*pucTapState    = ucTargetState;    /* Exit while loop */				break;			}			XSVFDBG_PRINTF1( 3, "   TAP State = %s\n",					 xsvf_pzTapState[ *pucTapState ] );		}	}	return( iErrorCode );}/***************************************************************************** * Function:     xsvfShiftOnly * Description:  Assumes that starting TAP state is SHIFT-DR or SHIFT-IR. *               Shift the given TDI data into the JTAG scan chain. *               Optionally, save the TDO data shifted out of the scan chain. *               Last shift cycle is special:  capture last TDO, set last TDI, *               but does not pulse TCK.  Caller must pulse TCK and optionally *               set TMS=1 to exit shift state. * Parameters:   lNumBits        - number of bits to shift. *               plvTdi          - ptr to lenval for TDI data. *               plvTdoCaptured  - ptr to lenval for storing captured TDO data. *               iExitShift      - 1=exit at end of shift; 0=stay in Shift-DR. * Returns:      void. *****************************************************************************/void xsvfShiftOnly( long    lNumBits,		    lenVal* plvTdi,		    lenVal* plvTdoCaptured,		    int     iExitShift ){	unsigned char*  pucTdi;	unsigned char*  pucTdo;	unsigned char   ucTdiByte;	unsigned char   ucTdoByte;	unsigned char   ucTdoBit;	int             i;	/* assert( ( ( lNumBits + 7 ) / 8 ) == plvTdi->len ); */	/* Initialize TDO storage len == TDI len */	pucTdo  = 0;	if ( plvTdoCaptured )	{		plvTdoCaptured->len = plvTdi->len;		pucTdo              = plvTdoCaptured->val + plvTdi->len;	}	/* Shift LSB first.  val[N-1] == LSB.  val[0] == MSB. */	pucTdi  = plvTdi->val + plvTdi->len;	while ( lNumBits )	{		/* Process on a byte-basis */		ucTdiByte   = (*(--pucTdi));		ucTdoByte   = 0;		for ( i = 0; ( lNumBits && ( i < 8 ) ); ++i )		{			--lNumBits;			if ( iExitShift && !lNumBits )			{				/* Exit Shift-DR state */				setPort( TMS, 1 );			}

⌨️ 快捷键说明

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