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

📄 bootconfig_mod.c

📁 flash驱动代码
💻 C
字号:
#include "flash.c"
#define BOOT_FROM_FLASH

LOCAL char autoboot 
    (
    int timeout		/* timeout time in seconds */
    )
    {
    ULONG	autoBootTime;
    int		timeLeft;
    UINT	timeMarker;
    int		bytesRead = 0;
    FUNCPTR	entry;
    char	key;
#ifdef  BOOT_FROM_FLASH	
	char tmpt[4];
	int vxWorksLen = 0x100000;
#endif

    if (timeout > 0)
	{
		printf ("\nPress any key to stop auto-boot...\n");

		/* Loop looking for a char, or timeout after specified seconds */

		autoBootTime = tickGet () + sysClkRateGet () * timeout;
		timeMarker = tickGet () + sysClkRateGet ();
		timeLeft = timeout;

		printf ("%2d\r", timeLeft);

		 while ((tickGet () < autoBootTime) && (bytesRead == 0))
		 {
		    (void) ioctl (consoleFd, FIONREAD, (int) &bytesRead);

		    if (tickGet () == timeMarker)
			{
				timeMarker = tickGet () + sysClkRateGet ();
				printf ("%2d\r", --timeLeft);
			}
	    }
	}

    if (bytesRead == 0)    /* nothing typed so auto-boot */
	{
	/* put the console back in line mode so it echoes (so's you can bang
	 * on it to see if it's still alive) */

	(void) ioctl (consoleFd, FIOSETOPTIONS, OPT_TERMINAL);

	printf ("\nauto-booting...\n");

/*blueyna -- 2003.6.11,flash启动*/
#ifdef BOOT_FROM_FLASH	
	if(FlashInit()==STATUS_NORMAL)	/*初始化FLASH*/
	{
		/*首先读取vxWorks的长度,存储在FLASH_DATA_CPU开始的头4个字节*/
		if(FlashDataGet(FLASH_DATA_CPU,tmpt,4)!=STATUS_NORMAL)
			printf("error in getting vxWorks length\n");
		else
		{
			vxWorksLen = tmpt[0]*0x01000000+tmpt[1]*0x00010000+tmpt[2]*0x00000100+tmpt[3];
			/*从flash中的第FLASH_DATA_CPU块开始读取vxWorks本身长度再加上头4个字节长度的字节*/
			printf("\nloading vxWorks for %d bytes from flash\n",vxWorksLen); 
			if(FlashDataGet(FLASH_DATA_CPU,(char *)(0x0010000-4),vxWorksLen+4)!=STATUS_NORMAL)
				printf("error in getting vxWorks.bin from flash\n");
			else
			{
				/*开始运行*/
				printf("now running...\n");
				go((FUNCPTR)0x0010000);
			}
		}
	}
#endif
	if (bootLoad (BOOT_LINE_ADRS, &entry) == OK)
	    go (entry);				/* ... and never return */

	else
	    {
	    printf ("Can't load boot file!!\n");
	    taskDelay (sysClkRateGet ());	/* pause a second */
	    reboot (BOOT_NO_AUTOBOOT);		/* something is awry */
	    }
	}
    else
	{
	/* read the key that stopped autoboot */

	read (consoleFd, &key, 1);
	return (key & 0x7f);		/* mask off parity in raw mode */
	}

    return (ERROR);			/* for lint - can't really get here */
}

⌨️ 快捷键说明

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