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

📄 bootconfig.c

📁 这是一款amd公司的128Mbitflash芯片。 该代码实现了vxworks下对FLASH的访问操作
💻 C
📖 第 1 页 / 共 5 页
字号:
	}

    bootStringToStruct (netInitParam, &params);
    sysFlags = params.flags;

    /* Initialize the net for load the image from the remote host */
   if(ERROR == myNetInit(netInitParam, INIT_NET | INIT_IDE))
	printf("Error in net Initializtion\n");
   
    /* put console in line mode */

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

    /* read and execute the ROM commands */

    printf ("\n");

    FOREVER
    {
        if ((key == '!') || (key == '@'))
        {
            line [0] = key;
            line [1] = EOS;
            key = 0;
        }
        else
        {
            printf ("[VxWorks Boot]: ");
            fioRdString (STD_IN, line, sizeof (line));
        }

        adr = adr2 = 0;
        nwords = 0;

        /* take blanks off end of line */

        pLine = line + strlen (line) - 1;		/* point at last char */
        while ((pLine >= line) && (*pLine == ' '))
        {
            *pLine = EOS;
            pLine--;
        }

        pLine = line;
        skipSpace (&pLine);
        switch (*(pLine++))
        {
            case EOS:		/* blank line */
                break;

            case 'c':		/* change boot params */
                bootParamsPrompt (BOOT_LINE_ADRS);

                /* no NvRam */
                /*
                (void) sysNvRamSet (BOOT_LINE_ADRS,
                strlen (BOOT_LINE_ADRS) + 1, 0);
                */
                break;

            case 'd':		/* display */
                tmp = *(pLine++);
                if((tmp == 'b'))
                {
                    if ((getArg (&pLine, &adr, HEX, OPT) == OK) &&
                        (getArg (&pLine, &nwords, DEC, OPT) == OK))
                        d ((char *) adr, nwords);
                }
                else if(tmp == 'w')
                {
                    if ((getArg (&pLine, &adr, HEX, OPT) == OK) &&
                        (getArg (&pLine, &nwords, DEC, OPT) == OK))
                        dw ((UINT16 *) adr, nwords);
                }
                else if(tmp == 'd')
                {
                    if ((getArg (&pLine, &adr, HEX, OPT) == OK) &&
                        (getArg (&pLine, &nwords, DEC, OPT) == OK))		
                        dd ((unsigned long *) adr, nwords);
                }
                else if(tmp == 'g')
                {
                    if ((getArg (&pLine, &adr, HEX, OPT) == OK) &&
                        (getArg (&pLine, &nwords, DEC, OPT) == OK))		
                        dg ((long *) adr, nwords);
                }
                break;

            case 'e':		/* exception */
                printExcMsg (sysExcMsg + 1);
                break;

            case 'f':		/* fill */

                if ((getArg (&pLine, &adr, HEX, !OPT) == OK) &&
                    (getArg (&pLine, &nbytes, DEC, !OPT) == OK) &&
                    (getArg (&pLine, &value, DEC, !OPT) == OK))
                {
                    bfillBytes ((char *) adr, nbytes, value);
                }

                break;

            case 'g':		/* go */

                if (getArg (&pLine, (int *) &entry, HEX, !OPT) == OK)
                    go (entry);
                break;

            case '?':			/* help */
            case 'h':			/* help */
                bootHelp ();
                break;

            case 'l':			/* load with internal params */
                if (netLoad (params.had, params.bootFile, params.usr,
                    params.passwd, &entry) == OK)
                {
                    printf ("entry = 0x%lx\n",  (unsigned long)entry);
                }
                else
                {
                    taskDelay (sysClkRateGet ());	/* pause a second */
                    reboot (BOOT_NO_AUTOBOOT);		/* something is awry */
                }
                break;

            case 'm':		/* modify */
                if (getArg (&pLine, &adr, HEX, !OPT) == OK)
                    m ((char *) adr);
                break;

#ifdef  INCLUDE_NETWORK
            case 'n':
                netifAdrsPrint (pLine);
                break;
                
#ifdef ETHERNET_ADR_SET
            case 'N':
                mEnet (pLine);
                break;
#endif  /* ETHERNET_ADR_SET */
#endif  /* INCLUDE_NETWORK */

            case 'o':
                if (getArg (&pLine, &adr, HEX, !OPT) == OK)
                mb ((char *) adr);
                break;		
                
            case 'O':
                if ((getArg (&pLine, &adr, HEX, OPT) == OK) &&
                    (getArg (&pLine, &nwords, HEX, OPT) == OK))
                    wb ((char *) adr, nwords);
                break;
            case 'p':		/* print boot params */
                bootParamsShow (BOOT_LINE_ADRS);printf("\n");
                pciDeviceShow (0);printf("\n");
                pciDeviceShow (1);printf("\n");
                pciDeviceShow (2);printf("\n");
                pciDeviceShow (3);printf("\n");
                break;

#ifdef INCLUDE_updateImageOnline
            case 'q':
            {
                if(*pLine == 'f')/*update Flash Image*/
                {
                    pLine++;
                    if(OK == myGetFileName(pLine, myFileName))
                        sysUpdateImage(myFileName,params.had,params.usr,params.passwd);
                    else
                        printf("Type '?' for help.\n");
                }
                else if(*pLine == 'c')/*update CF Image*/
                {
                    pLine++;
                    if(OK == myGetFileName(pLine, myFileName))
                        sysUpdateFile(myFileName,params.had,params.usr,params.passwd);
                    else
                        printf("Type '?' for help.\n");
                }
                else
                    printf("Type '?' for help.\n");
            }
            break;
#endif /* INCLUDE_updateImageOnline */

#ifdef INCLUDE_DS12887
            case 'r':
                sysRtcGet(tim);
                printf("%04d,%02d,%02d %02d:%02d:%02d  week:%d\n",tim->tm_year,tim->tm_mon,tim->tm_mday,tim->tm_hour,
                    tim->tm_min,tim->tm_sec, tim->tm_wday);
                break;
#endif

            case 'R':
                myCheckAMDFlash((char *)0xfff00000);
                break;

#ifdef	TARGET_HK_V2F
            case 's':		/* system controller */
            {
                extern ULONG sysBCLSet ();
                if (getArg (&pLine, &value, DEC, !OPT) == OK)
                {
                    if (value != 0)
                    {
                        (void) sysBCLSet ((ULONG)HK_BCL_SYS_CONTROLLER,
                        		  (ULONG)HK_BCL_SYS_CONTROLLER);
                        printf ("System controller on.\n");
                    }
                    else
                    {
                        (void) sysBCLSet ((ULONG)HK_BCL_SYS_CONTROLLER,
                        		  (ULONG)0);
                        printf ("System controller off.\n");
                    }
                }
                break;
            }
#endif	/* TARGET_HK_V2F */

#if defined(TARGET_FRC_30) || defined(TARGET_FRC_31) || defined(TARGET_FRC_33)
            case 's':		/* system controller */
            if (getArg (&pLine, &value, DEC, !OPT) == OK)
            {
                if (value != 0)
                {
                    *FGA_CTL1 |= FGA_CTL1_SCON;
                    printf ("System controller on.\n");
                }
                else
                {
                    *FGA_CTL1 &= ~FGA_CTL1_SCON;
                    printf ("System controller off.\n");
                }
            }
            break;
#endif	/* TARGET_FRC_30 || TARGET_FRC_31 || TARGET_FRC_33 */

            case 'S':
                if (getArg (&pLine, &adr, HEX, !OPT) == OK)
                    S ((long) adr);		   	
                break;
            case 't':		/* transpose(?) (running out of letters!) */
                if ((getArg (&pLine, &adr, HEX, !OPT) == OK) &&
                    (getArg (&pLine, &adr2, HEX, !OPT) == OK) &&
                    (getArg (&pLine, &nbytes, HEX, !OPT) == OK))
                {
                    bcopy ((char *) adr, (char *) adr2, nbytes);
                }
                break;

#ifdef INCLUDE_DS12887
            case 'T':
            if ((getArg (&pLine, &tyear, DEC, !OPT) == OK) &&
                (getArg (&pLine, &tmon, DEC, !OPT) == OK) &&
                (getArg (&pLine, &tday, DEC, !OPT) == OK) &&
                (getArg (&pLine, &thour, DEC, !OPT) == OK) &&
                (getArg (&pLine, &tmin, DEC, !OPT) == OK) &&
                (getArg (&pLine, &tsec, DEC, !OPT) == OK) &&
                (getArg (&pLine, &twday, DEC, !OPT) == OK))
            {
                tim->tm_year = tyear;
                tim->tm_mon = tmon;
                tim->tm_mday = tday;
                tim->tm_hour = thour;
                tim->tm_min = tmin;
                tim->tm_sec = tsec;
                tim->tm_wday = twday;
                sysRtcInit();
                sysRtcSet(tim);
            }
            break;
#endif

#ifdef INCLUDE_UPDATEROM
            case 'u': 	
                if(OK == myGetFileName(pLine, myFileName))
                {
                    myUpdateRom(myFileName,params.had,params.usr,params.passwd);
                }
                else
                {
                    printf("Type '?' for help.\n");
                }
                break;
#endif /* INCLUDE_UPDATEROM */

            case '@':			/* load and go with internal params */
            case '$':			/* load and go with internal params */
                if (netLoad (params.had, params.bootFile, params.usr,
                    params.passwd, &entry) == OK)
                {
                    go (entry);
                }
                else
                {
                    taskDelay (sysClkRateGet ());	/* pause a second */
                    reboot (BOOT_NO_AUTOBOOT);		/* something is awry */
                }
                break;

            default:
                printf ("Unrecognized command. Type '?' for help.\n");
                break;
        } /* switch */
    } /* FOREVER */
}

/******************************************************************************
*
* autoboot - do automatic boot sequence
*
* RETURNS: Doesn't return if successful (starts execution of booted system).
*/

LOCAL char autoboot 
    (
    int timeout		/* timeout time in seconds */
    )
 {
    ULONG	autoBootTime;
    int		timeLeft;
    UINT	timeMarker;
    int		bytesRead = 0;
    FUNCPTR	entry;
    char	key;

    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\n");

#ifdef INCLUDE_FLASH_DOWNLOAD
        if (sysAutoFlashBoot (BOOT_LINE_ADRS, &entry) == OK)
#else
        if (bootLoad (BOOT_LINE_ADRS, &entry) == OK)
#endif /* INCLUDE_FLASH_DOWNLOAD 

⌨️ 快捷键说明

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