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

📄 bootconfig.c

📁 cpc-1631的BSP包for VxWorks操作系统
💻 C
📖 第 1 页 / 共 5 页
字号:

    /* install driver for on-board serial ports and make devices */

#ifdef  INCLUDE_TYCODRV_5_2
#ifdef  INCLUDE_TTY_DEV
    if (NUM_TTY > 0)
        {
        tyCoDrv ();                             /* install console driver */

        for (ix = 0; ix < NUM_TTY; ix++)        /* create serial devices */
            {
            sprintf (tyName, "%s%d", "/tyCo/", ix);

            (void) tyCoDevCreate (tyName, ix, 512, 512);

            if (ix == CONSOLE_TTY)
                strcpy (consoleName, tyName);   /* store console name */
            }

        consoleFd = open (consoleName, O_RDWR, 0);

        /* set baud rate */

        (void) ioctl (consoleFd, FIOBAUDRATE, CONSOLE_BAUD_RATE);
        (void) ioctl (consoleFd, FIOSETOPTIONS,
			OPT_ECHO | OPT_CRMOD | OPT_TANDEM | OPT_7_BIT);
        }
#endif  /* INCLUDE_TTY_DEV */

#else   /* !INCLUDE_TYCODRV_5_2 */
#ifdef  INCLUDE_TTY_DEV
    if (NUM_TTY > 0)
        {
        ttyDrv();                               /* install console driver */

        for (ix = 0; ix < NUM_TTY; ix++)        /* create serial devices */
            {
#if (defined(INCLUDE_WDB) && (WDB_COMM_TYPE == WDB_COMM_SERIAL))
	    if (ix == WDB_TTY_CHANNEL)          /* don't use WDBs channel */
	    	continue;
#endif

            sprintf (tyName, "%s%d", "/tyCo/", ix);
            (void) ttyDevCreate (tyName, sysSerialChanGet(ix), 512, 512);

            if (ix == CONSOLE_TTY)              /* init the tty console */
                {
                strcpy (consoleName, tyName);
                consoleFd = open (consoleName, O_RDWR, 0);

                (void) ioctl (consoleFd, FIOBAUDRATE, CONSOLE_BAUD_RATE);

                (void) ioctl (consoleFd, FIOSETOPTIONS,
			OPT_ECHO | OPT_CRMOD | OPT_TANDEM | OPT_7_BIT);

                }
            }
        }
#endif  /* INCLUDE_TTY_DEV */

#ifdef INCLUDE_PC_CONSOLE
    pcConDrv ();
    for (ix = 0; ix < N_VIRTUAL_CONSOLES; ix++)
        {
        sprintf (tyName, "%s%d", "/pcConsole/", ix);
        (void) pcConDevCreate (tyName,ix, 512, 512);
        if (ix == PC_CONSOLE)           /* init the console device */
            {
            strcpy (consoleName, tyName);
            consoleFd = open (consoleName, O_RDWR, 0);
            (void) ioctl (consoleFd, FIOBAUDRATE, CONSOLE_BAUD_RATE);
            (void) ioctl (consoleFd, FIOSETOPTIONS,
			OPT_ECHO | OPT_CRMOD | OPT_TANDEM | OPT_7_BIT);
            }
        }
#endif  /* INCLUDE_PC_CONSOLE */

#endif  /* !INCLUDE_TYCODRV_5_2 */

#ifdef INCLUDE_WDB
    wdbConfig();		/* configure and initialize the WDB agent */
    vxBootFile[0] = NULL;	/* clear boot line set by wdbConfig() */

#if defined(INCLUDE_TSFS_BOOT) && defined(INCLUDE_TSFS_BOOT_VIO_CONSOLE)
    consoleFd = open ("/vio/0", O_RDWR, 0);	/* for Target Server Console */
#endif
#endif	/* INCLUDE_WDB */

    ioGlobalStdSet (STD_IN,  consoleFd);
    ioGlobalStdSet (STD_OUT, consoleFd);
    ioGlobalStdSet (STD_ERR, consoleFd);

    pipeDrv ();					/* install pipe driver */

#if     defined(INCLUDE_EXC_HANDLING) && defined(INCLUDE_EXC_TASK)
#ifdef  INCLUDE_EXC_SHOW
    excShowInit ();			/* init exception show routines */
#endif
    excInit ();				/* initialize exception handling */
#endif  /* defined(INCLUDE_EXC_HANDLING) && defined(INCLUDE_EXC_TASK) */

    excHookAdd ((FUNCPTR) bootExcHandler);	/* install exc handler */
    logInit (consoleFd, 5);			/* initialize logging */

#ifdef	INCLUDE_DOSFS
    hashLibInit ();				/* hashLib used by dosFS */
#endif

    /* initialize object module loader */

#if	defined(INCLUDE_AOUT)
    bootAoutInit ();				/* use a.out format */
#else	/* coff or ecoff */
#if	defined(INCLUDE_ECOFF)
    bootEcoffInit ();				/* use ecoff format */
#else	/* coff */
#if	defined(INCLUDE_COFF)
    bootCoffInit ();				/* use coff format */
#else   /* coff */
#if	defined(INCLUDE_ELF)
    bootElfInit ();				/* use elf format */
#endif
#endif 						/* mips cpp no elif */
#endif
#endif

#ifdef  INCLUDE_PCMCIA                                       
                                                             
    pcmciaInit ();                      /* init PCMCIA Lib */

#endif /* INCLUDE_PCMCIA */


#ifdef INCLUDE_TFFS_1208

	nand_init();

	if (tffsDrv () != OK)
	{
		printf("Could not initialize tffsDrv.\n");
	}
	else
	{
		(void)dosFsInit (NUM_DOSFS_FILES);        /* initialize DOS-FS */
		printf ("Attaching to TFFS... ");

		/*if ( usrTffsConfig ( TFFS_DRIVE_NUMBER, TFFS_REMOVABLE, TFFS_MOUNT_POINT ) == ERROR)*/
		if (usrTffsConfig (0, 0, "/tffs0") == ERROR)
		{
			printf ("usrTffsConfig failed.format tffs now\n");

			/*if ( tffsDevFormat( 0, (int)&quickFormatParams) == ERROR )*/
			if ( tffsDevFormat( 0,(int)&params) == ERROR )
			{
				printf( "tffsDevFormat ERROR!\n" );
			}
			else
			{
				(void)dosFsInit (NUM_DOSFS_FILES);        /* initialize DOS-FS */

				printf ("Attaching to TFFS... ");
				(void)usrTffsConfig ( 0, 0, "/tffs0" );

				printf ("done.\n");

			}
		}
		else
		{	    
			printf ("done.\n");
		}
	}
#endif

#ifdef INCLUDE_ATA_686
initIDE();
#if 0
	sysPicInit();/*初始化8259中断控制器(vt82c686)*/
	vt82c686Init();/*初始化vt82c686南桥*/
	sysPciIbcIntrInit(VT_IRQ);/*使能南桥中断(8259),VT_IRQ=0X02*/
	sysAtaInit(0);	/* device zero used first time through */
#endif

    for (ix = 0; ix < ATA_MAX_CTRLS; ix++)
    {
        pAtaResource = &ataResources[ix];
        if (pAtaResource->ctrlType == IDE_LOCAL)
            if ((ataDrv (ix, pAtaResource->drives, pAtaResource->intVector,
		   pAtaResource->intLevel, pAtaResource->configType,
                   pAtaResource->semTimeout, pAtaResource->wdgTimeout))
		== ERROR)
		{
        printf("Could not initialize ataDrv %d.\n",ix);
		}
    }
		
      (void)dosFsInit (NUM_DOSFS_FILES);        /* initialize DOS-FS */

		for(i=0;i<ATA_MAX_CTRLS;i++)
		{
			for(j=0;j<ATA_MAX_DRIVES;j++)
			{
				if(OK==devPresent(i,j))
				{
					sprintf(devName,"%s%d%s%d","/ata",i,"/ide",j);
					
					printf("Attach %s ...",devName);
					
					if(OK == usrAtaConfig (i, j, devName))
					{
						printf("OK.\n");
					}
					else
					{
						printf("Error.\n");
					}
				}
			}
		}

#endif /*INCLUDE_ATA_686*/

#ifdef TFFS_BOOT		/*Flash作为启动盘*/
	if(ioDefPathSet("/tffs0") !=OK)
	{
		printf( "Flash ERROR, please check!\n" ) ;
	}	
#else/*IDE硬盘作为启动盘*/
	if(ioDefPathSet("/ata1/ide0") !=OK)
	{
		printf( "CF card ERROR, please check!\n" ) ;
	}
#endif

#ifdef INCLUDE_END
    /* initialize the MUX */

    muxMaxBinds = MUX_MAX_BINDS;
    if (muxLibInit() == ERROR)
	return;                              /* can't return ERROR */

    /* Initialize all the available devices. */
    for (count = 0, pDevTbl = endDevTbl; pDevTbl->endLoadFunc != END_TBL_END;
         pDevTbl++, count++)
        {
        cookieTbl[count].pCookie = muxDevLoad (pDevTbl->unit, pDevTbl->endLoadFunc,
                                       pDevTbl->endLoadString,
                                       pDevTbl->endLoan, pDevTbl->pBSP);
        if (cookieTbl[count].pCookie == NULL)
            {
            printf ("muxLoad failed!\n");
            }

        cookieTbl[count].unitNo=pDevTbl->unit;
	bzero((void *)cookieTbl[count].devName,END_NAME_MAX);
	pDevTbl->endLoadFunc((char*)cookieTbl[count].devName, NULL);

        }
#endif /* INCLUDE_END */

    taskSpawn ("tBoot", bootCmdTaskPriority, bootCmdTaskOptions,
		bootCmdTaskStackSize, (FUNCPTR) bootCmdLoop,
		0,0,0,0,0,0,0,0,0,0);

    }
/*******************************************************************************
*
* usrClock - user defined system clock interrupt routine
*
* This routine is called at interrupt level on each clock interrupt.  It is
* installed a call to sysClkConnect().  It calls any other facilities that
* need to know about clock ticks, including the kernel itself.
*
* If the application needs anything to happen at clock interrupt level,
* it should be added to this routine.
*
* NOMANUAL
*/

void usrClock (void)

    {
    tickAnnounce ();	/* announce system tick to kernel */
    }
/*******************************************************************************
*
* bootCmdLoop - read and execute user commands forever (until boot)
*/

LOCAL void bootCmdLoop (void)

    {
    BOOT_PARAMS params;
    char line [BOOT_CMD_MAX_LINE];
    char *pLine;
    int nwords;
    int nbytes;
    int value;
    int adr;
    int adr2;
    FUNCPTR entry;
    char key = 0;
	
#ifdef INCLUDE_TFFS_1208						
	tffsDevFormatParams quickFormatParams =
	    {
	        {
	            0x000000, 99, 1, 0x10000, NULL, {0,0,0,0}, NULL, 2, 0, NULL
	        },
	        FTL_FORMAT_IF_NEEDED
	    };

	tffsDevFormatParams completeFormatParams =
	    {
	        {
	            0x000000, 99, 1, 0x10000, NULL, {0,0,0,0}, NULL, 2, 0, NULL
	        },
	        FTL_FORMAT
	    };
#endif
    /* flush standard input to get rid of any garbage;
     * E.g. the Heurikon HKV2F gets junk in USART if no terminal connected.
     */

    (void) ioctl (STD_IN, FIOFLUSH, 0 /*XXX*/);
		
    if (sysStartType & BOOT_CLEAR)
	printBootLogo ();

    usrBootLineInit (sysStartType);

	/*初始化调试网口*/
    loadDebugNet((char *)(BOOT_LINE_ADRS));
	
    ftpdInit ((FUNCPTR)NULL, 0);        /* File Transfer Protocol Server Library and Task */

#ifdef CPCI_PCI_6150
	/*CPCI桥芯片(PCI 6150)初始化*/
	pci6150Init();
#endif

    /* print out any new exception message -
     * the first byte is zeroed after printing so that we won't print
     * it again automatically.  However, 'e' command will still print out
     * the remainder. */

    printExcMsg (sysExcMsg);
    *sysExcMsg = EOS;		/* indicate exception message is old */


    /* start autoboot, unless no-autoboot specified */

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

#if defined(INCLUDE_TSFS_BOOT) && defined(INCLUDE_TSFS_BOOT_VIO_CONSOLE)

    /* Wait for Target Server connection */

    while (!wdbTargetIsConnected())
    	taskDelay (sysClkRateGet());

    /*
     * disable the auto-boot mechanism, because the Target Server may not have
     * time to start its VIO Console before the end of the auto-boot coutdown.
     */

    sysStartType |= BOOT_NO_AUTOBOOT;
#endif

    if (!(sysStartType & BOOT_NO_AUTOBOOT) &&
	!(sysFlags & SYSFLG_NO_AUTOBOOT))
	{
	int timeout = TIMEOUT;

	if ((sysStartType & BOOT_QUICK_AUTOBOOT) ||
	    (sysFlags & SYSFLG_QUICK_AUTOBOOT))
	    {
	    timeout = 1;
	    }

	key = autoboot (timeout);	/* doesn't return if successful */
	}


    /* If we're here, either we aren't auto-booting, or we got an error
     * auto-booting, or the auto-booting was stopped. */

    /* put console in line mode */

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

    /* read and execute the ROM commands */

    printf ("\n");

    FOREVER

⌨️ 快捷键说明

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