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

📄 bootconfig.c

📁 s3c2410 vxworks 的bsp
💻 C
📖 第 1 页 / 共 5 页
字号:
	}    return (NULL);    }#endif    /* INCLUDE_END *//********************************************************************************* RETURNS: OK or ERROR*/LOCAL STATUS netLoad     (    char *hostName,    char *fileName,    char *usr,    char *passwd,    FUNCPTR *pEntry    )    {    int fd;    int errFd;		/* for receiving standard error messages from Unix */    char command [BOOT_FILE_LEN + BOOT_HOST_LEN];    BOOL bootFtp = (passwd[0] != EOS);    BOOL bootRsh = FALSE;    printf ("Loading... ");          return (OK);    }#endif  /* INCLUDE_NETWORK */#if     (defined (INCLUDE_SCSI_BOOT) || defined (INCLUDE_FD) || \	 defined (INCLUDE_IDE) || defined (INCLUDE_ATA) || \	 defined (INCLUDE_TFFS))#define	SPIN_UP_TIMEOUT	45	/* max # of seconds to wait for spinup *//******************************************************************************** devSplit - split the device name from a full path name** This routine returns the device name from a valid UNIX-style path name* by copying until two slashes ("/") are detected.  The device name is* copied into <devName>.** RETURNS: N/A** NOMANUAL*/void devSplit     (    FAST char *fullFileName,	/* full file name being parsed */    FAST char *devName		/* result device name */    )    {    FAST int nChars = 0;    if (fullFileName != NULL)	{	char *p0 = fullFileName;	char *p1 = devName;	while ((nChars < 2) && (*p0 != EOS))	    {	    if (*p0 == '/')		nChars++;	    *p1++ = *p0++;	    }	*p1 = EOS;	}    else	{	(void) strcpy (devName, "");	}    }#endif  /* (defined (INCLUDE_SCSI_BOOT) || (INCLUDE_FD) || (INCLUDE_IDE)) */#ifdef  INCLUDE_SCSI_BOOT/******************************************************************************** scsiLoad - load a vxWorks image from a local SCSI disk** RETURNS: OK, or ERROR if file can not be loaded.*/LOCAL STATUS scsiLoad     (    int     bootDevId,    int     bootDevLUN,    char    *fileName,    FUNCPTR *pEntry    )    {    int fd;    SCSI_PHYS_DEV *pScsiPhysBootDev;    BLK_DEV       *pScsiBlkBootDev;    char bootDir  [BOOT_FILE_LEN];    int           ix;#ifdef INCLUDE_SCSI2    SCSI_OPTIONS  options;    UINT          which;#endif /* INCLUDE_SCSI2 */    CBIO_DEV_ID pCbio;    if (!scsiInitialized)		/* skip if this is a retry */	{	if (sysScsiInit () == ERROR)	    {	    printErr ("Could not initialize SCSI.\n");	    return (ERROR);	    }	scsiInitialized = TRUE;	}    taskDelay (sysClkRateGet ());	/* delay 1 second after reset */    if ((bootDevId  < SCSI_MIN_BUS_ID) ||	(bootDevId  > SCSI_MAX_BUS_ID) ||	(bootDevLUN < SCSI_MIN_LUN)    ||	(bootDevLUN > SCSI_MAX_LUN))	{	printErr ("SCSI device parameters < busId = %d, lun = %d > ",		  bootDevId, bootDevLUN);	printErr ("are out of range (0-7).\n");	printErr ("Check boot device format:\n");	printErr ("    scsi=<busId>,<lun>  e.g.  scsi=2,0\n");	return (ERROR);	}#ifdef INCLUDE_SCSI2    /* Set all devices to asynchronous data transfer */    which = SCSI_SET_OPT_XFER_PARAMS;    options.maxOffset = 0;    options.minPeriod = SCSI_SYNC_XFER_MIN_PERIOD;    scsiTargetOptionsSet (pSysScsiCtrl, bootDevId, &options, which);#endif /* INCLUDE_SCSI2 */    /* create device handle for TEST UNIT READY commands */    if ((pScsiPhysBootDev = scsiPhysDevCreate (pSysScsiCtrl, bootDevId,					       bootDevLUN, 128, 0, 0,					       0xffff, 512))	== NULL)	{	printErr ("scsiPhysDevCreate failed.\n");	return (ERROR);	}    /* issue a couple fo TEST UNIT READY commands to clear reset execption */    scsiTestUnitRdy (pScsiPhysBootDev);    scsiTestUnitRdy (pScsiPhysBootDev);    /* issue a TEST UNIT READY every second for SPIN_UP_TIMEOUT seconds,     * or until device returns OK status.     */    if (scsiTestUnitRdy (pScsiPhysBootDev) != OK)        {        printf ("Waiting for disk to spin up...");        for (ix = 0; ix < SPIN_UP_TIMEOUT; ix++)            {            if (scsiTestUnitRdy (pScsiPhysBootDev) == OK)                {                printf (" done.\n");                break;		}            else		{                if (ix != (SPIN_UP_TIMEOUT - 1))                    printf (".");                else                    {                    printf (" timed out.\n");                    return (ERROR);		    }                taskDelay (sysClkRateGet ());		}	    }	}    /* delete temporary device handle */    scsiPhysDevDelete (pScsiPhysBootDev);    printf ("Attaching to scsi device... ");    /* recreate a device handle, with polling for actual device parameters */    taskDelay (sysClkRateGet ());    if ((pScsiPhysBootDev = scsiPhysDevCreate (pSysScsiCtrl, bootDevId,                                               bootDevLUN, 0, -1, 0, 0, 0))         == NULL)	{        printErr ("scsiPhysDevCreate failed.\n");        return (ERROR);        }    /*-------------------------------------------------------------------------     *     * Configuration of an OMTI3500     *     *-----------------------------------------------------------------------*/    if ((strncmp (pScsiPhysBootDev->devVendorID, "SMS", 3) == 0) &&	(strncmp (pScsiPhysBootDev->devProductID, "OMTI3500", 8) == 0))	{	char modeData [4];	/* array for floppy MODE SELECT data */	/* zero modeData array, then set byte 1 to "medium code" (0x1b).	 * NOTE: MODE SELECT data is highly device-specific.  If your device	 * requires configuration via MODE SELECT, please consult the device's	 * Programmer's Reference for the relevant data format.	 */	bzero (modeData, sizeof (modeData));	modeData [1] = 0x1b;	/* issue a MODE SELECT cmd to correctly configure floppy controller */	scsiModeSelect (pScsiPhysBootDev, 1, 0, modeData, sizeof (modeData));	/* delete and re-create the SCSI_PHYS_DEV so that INQUIRY will return	 * the new device parameters, i.e., correct number of blocks	 */	scsiPhysDevDelete (pScsiPhysBootDev);	/* recreate a device handle, polling for actual device parameters */	if ((pScsiPhysBootDev = scsiPhysDevCreate (pSysScsiCtrl, bootDevId,						   bootDevLUN, 0, -1, 0, 0, 0))	    == NULL)	    {	    printErr ("scsiPhysDevCreate failed.\n");	    return (ERROR);	    }	}    /*-------------------------------------------------------------------------     *     * END of OMTI3500 configuration     *     *-----------------------------------------------------------------------*/    /* create a block device spanning entire disk (non-distructive!) */    if ((pScsiBlkBootDev = scsiBlkDevCreate (pScsiPhysBootDev, 0, 0)) == NULL)	{        printErr ("scsiLoad: scsiBlkDevCreate failed.\n");        return (ERROR);	}    dosFsInit (NUM_DOSFS_FILES);        /* initialize DOS-FS */    /* split off boot device from boot file */    devSplit (fileName, bootDir);    /* now support booting from partitions on SCSI devices */    pCbio = dpartDevCreate((CBIO_DEV_ID) pScsiBlkBootDev,                           NUM_PARTITIONS_DISK_BOOT,                           usrFdiskPartRead);    if (NULL == pCbio)        {        printErr ("scsiLoad: dpartDevCreate returned NULL.\n");        return (ERROR);	}    /* initialize the boot block device as a dosFs device named <bootDir> */    if (ERROR == dosFsDevCreate(bootDir,                                dpartPartGet(pCbio,PARTITION_DISK_BOOT),                                20, NONE))        {        printErr ("scsiLoad: dosFsDevCreate returned ERROR.\n");        return (ERROR);	}	    printErr ("done.\n");    /* load the boot file */    printErr ("Loading %s...", fileName);    fd = open (fileName, O_RDONLY, 0);    if (fd == ERROR)	{        printErr ("\nCannot open \"%s\".\n", fileName);        return (ERROR);	}    if (bootLoadModule (fd, pEntry) != OK)        goto readErr;    close (fd);    return (OK);readErr:    close (fd);    return (ERROR);    }#endif	/* INCLUDE_SCSI_BOOT */#ifdef	INCLUDE_FD#include "usrFd.c"/******************************************************************************** fdLoad - load a vxWorks image from a local floppy disk** RETURNS: OK, or ERROR if file can not be loaded.*/LOCAL STATUS fdLoad     (    int     drive,    int     type,    char    *fileName,    FUNCPTR *pEntry    )    {    int fd;    if (fdDrv (FD_INT_VEC, FD_INT_LVL) != OK)	{	printErr ("Could not initialize.\n");	return (ERROR);	}    printf ("Attaching to floppy disk device... ");    dosFsInit (NUM_DOSFS_FILES);        /* initialize DOS-FS */    if (usrFdConfig (drive, type, fileName) == ERROR)	{        printErr ("usrFdConfig failed.\n");        return (ERROR);	}    printErr ("done.\n");    /* load the boot file */    printErr ("Loading %s...", fileName);    if ((fd = open (fileName, O_RDONLY, 0)) == ERROR)	{        printErr ("\nCannot open \"%s\".\n", fileName);        return (ERROR);	}    if (bootLoadModule (fd, pEntry) != OK)        goto fdLoadErr;    close (fd);    return (OK);fdLoadErr:    close (fd);    return (ERROR);    }#endif	/* INCLUDE_FD */#ifdef	INCLUDE_IDE#define	IDE_MEM_DOSFS	0x200000#include "usrIde.c"/******************************************************************************** ideLoad - load a vxWorks image from a local IDE disk** RETURNS: OK, or ERROR if file can not be loaded.*/LOCAL STATUS ideLoad     (    int     drive,    int     type,    char    *fileName,    FUNCPTR *pEntry    )    {    int fd;    if (ideDrv (IDE_INT_VEC, IDE_INT_LVL, type) == ERROR)	{	printErr ("Could not initialize.\n");	return (ERROR);	}    printf ("Attaching to IDE disk device... ");    dosFsInit (NUM_DOSFS_FILES);        /* initialize DOS-FS */    if (usrIdeConfig (drive, fileName) == ERROR)	{        printErr ("usrIdeConfig failed.\n");        return (ERROR);	}    printErr ("done.\n");    /* load the boot file */    printErr ("Loading %s...", fileName);    if ((fd = open (fileName, O_RDONLY, 0)) == ERROR)	{        printErr ("\nCannot open \"%s\".\n", fileName);        return (ERROR);	}    if (bootLoadModule (fd, pEntry) != OK)        goto ideLoadErr;    close (fd);    return (OK);ideLoadErr:    close (fd);    return (ERROR);    }#endif	/* INCLUDE_IDE */#ifdef	INCLUDE_ATA#define	ATA_MEM_DOSFS	0x200000#include "usrAta.c"/******************************************************************************** ataLoad - load a vxWorks image from a local ATA disk** RETURNS: OK, or ERROR if file can not be loaded.*/LOCAL STATUS ataLoad     (    int     ctrl,    int     drive,    char    *fileName,    FUNCPTR *pEntry    )    {    IMPORT ATA_RESOURCE ataResources[];    ATA_RESOURCE *pAtaResource	= &ataResources[ctrl];    int fd;    char tmp[BOOT_FILE_LEN];    if (ataDrv (ctrl, pAtaResource->drives, pAtaResource->intVector,		pAtaResource->intLevel, pAtaResource->configType,		pAtaResource->semTimeout, pAtaResource->wdgTimeout) == ERROR)	{	printErr ("Could not initialize.\n");	return (ERROR);	}    printf ("Attaching to ATA disk device... ");    dosFsInit (NUM_DOSFS_FILES);        /* initialize DOS-FS */    devSplit (fileName, tmp);    if (usrAtaConfig (ctrl, drive, tmp) == ERROR)	{        printErr ("usrAtaConfig failed.\n");        return (ERROR);	}    printErr ("done.\n");    /* load the boot file */    printErr ("Loading %s...", fileName);    if ((fd = open (fileName, O_RDONLY, 0)) == ERROR)	{        printErr ("\nCannot open \"%s\".\n", fileName);        return (ERROR);	}    if (bootLoadModule (fd, pEntry) != OK)        goto ataLoadErr;    close (fd);    return (OK);ataLoadErr:    close (fd);    return (ERROR);    }#endif	/* INCLUDE_ATA */#ifdef	INCLUDE_PCMCIA#define	PCMCIA_MEM_DOSFS	0x200000#include "usrPcmcia.c"/******************************************************************************** pcmciaLoad - load a vxWorks image from a PCMCIA disk device** RETURNS: OK, or ERROR if file can not be loaded.*/LOCAL STATUS pcmciaLoad     (    int     sock,    char    *fileName,    FUNCPTR *pEntry    )    {    int fd;    printf ("Attaching to PCMCIA block device... ");    dosFsInit (NUM_DOSFS_FILES);        /* initialize DOS-FS */    if (usrPcmciaConfig (sock, fileName) != OK)        return (ERROR);    printErr ("done.\n");    /* load the boot file */    printErr ("Loading %s...", fileName);    if ((fd = open (fileName, O_RDONLY, 0)) == ERROR)

⌨️ 快捷键说明

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