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

📄 readme

📁 电子硬盘驱动
💻
📖 第 1 页 / 共 5 页
字号:

        #ifdef __cplusplus
        extern "C" {
        #endif

        #ifndef _ASMLANGUAGE

        #include "blkIo.h"

	/* TrueFFS driver's configuration variables. See Chapter 4
           for details */

        extern unsigned char flUse8bit;
        extern unsigned char flUseNFTLCache;
        extern int fl_useDebug;

        #if defined(__STDC__) || defined(__cplusplus)

	extern void      tffsSetup (int diskonchips, long *addressRange);
        extern STATUS	 tffsDrv (void);
        extern BLK_DEV * tffsDevCreate (int tffsDriveNo, int removableMediaFlag);

        #else	/* __STDC__ */

	extern void      tffsSetup ();
        extern STATUS	 tffsDrv ();
        extern BLK_DEV * tffsDevCreate ();

        #endif	/* __STDC__ */

        #endif  /* _ASMLANGUAGE */

        #ifdef __cplusplus
        }
        #endif

        /* forward declarations */

        #ifdef	__STDC__
        void	devSplit (char *fullFileName, char *devName);
        #else
        void	devSplit ();
        #endif	/* __STDC__ */

        extern unsigned	 noOfDrives;

        STATUS usrTffsConfig
            (
            int     drive,	/* drive number of TFFS */
            int     removable,	/* 0 - nonremovable flash media */
            char *  fileName	/* mount point */
            )
            {
            BLK_DEV * pBootDev;
            char bootDir [BOOT_FILE_LEN];

            if ((UINT)drive >= noOfDrives)
        	{
        	printErr ("drive is out of range (0-%d).\n", noOfDrives - 1);
        	return (ERROR);
        	}

            /* create a block device spanning entire disk (non-destructive!) */

            if ((pBootDev = tffsDevCreate (drive, 0)) == NULL)
        	{
                printErr ("tffsDevCreate failed.\n");
                return (ERROR);
        	}

            /* split off boot device from boot file */

            devSplit (fileName, bootDir);

            /* initialize the boot block device as a dosFs device named <bootDir> */

            if (dosFsDevInit (bootDir, pBootDev, NULL) == NULL)
        	{
                printErr ("dosFsDevInit failed.\n");
                return (ERROR);
        	}

            return (OK);
            }

        LOCAL STATUS tffsLoad
            (
            int     drive,		/* TFFS drive number (0 - (noOfDrives-1)) */
            int     removable,		/* 0 - nonremovable flash media */
            char    * fileName,		/* file name to download */
            FUNCPTR * pEntry
            )
            {
            int fd;

            /*
             * Call tffsSetup() as appropriate for your application. See
             * Section 2.6 above for details.
             */

            /*
             * If you want to change the settings of the driver's configuration
             * variables flUse8bit, flUseNFTLCache and fl_useDebug, do it here.
             * See Chapter 4 for details.
             */

            if (tffsDrv () != OK)
        	{
        	printErr ("Could not initialize.\n");
        	return (ERROR);
        	}

            printf ("Attaching to TFFS... ");

            dosFsInit (NUM_DOSFS_FILES);        /* initialize DOS-FS */

            if (usrTffsConfig (drive, 0, fileName) == ERROR)
        	{
                printErr ("usrTffsConfig 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 tffsLoadErr;

            close (fd);
            return (OK);

        tffsLoadErr:

            printErr ("\nerror loading file: status = 0x%x.\n", errnoGet ());
            close (fd);
            return (ERROR);
            }

        #endif	/* INCLUDE_DISKONCHIP */


     ===> NOTE.  Please note that the 2nd arguement passed to the routine 
                 tffsDevCreate() above, is always zero. This is correct regardless
                 of the fact whether dosFs's long filename support is disabled 
                 or enabled, because the bootloader code above is looking for
                 access to the primary partition (where VxWorks application is
                 stored). After application has been loaded from the primary 
                 partition and started, it issues another call to tffsDevCreate(). 
                 This call is described in Sections 2.9 and 2.24 respectively for 
                 cases when dosFs's long filenames support is disabled or enabled. 

3.12. Modify the file Tornado/target/config/all/bootConfig.c and add the
      following code fragment under #define INCLUDE_DISKONCHIP to the
      helpMsg[] in the routine bootHelp():

        #ifdef	INCLUDE_ATA
        	"boot device: ata=ctrl,drive           file name: /ata0/vxWorks","",
        #endif	/* INCLUDE_ATA */

        #ifdef	INCLUDE_DISKONCHIP
       	        "boot device: tffs=drive,removable     file name: /tffs0/vxWorks","",
        #endif	/* INCLUDE_DISKONCHIP */

        #ifdef	INCLUDE_PCMCIA
        	"boot device: pcmcia=sock              file name: /pcmcia0/vxWorks","",
        #endif	/* INCLUDE_PCMCIA */

3.13. Modify the file Tornado/target/config/all/bootConfig.c and add the
      following code fragment under #define INCLUDE_DISKONCHIP to
      the routine bootHelp():


        #ifdef  INCLUDE_ATA
            printf (" ata");
        #endif  /* INCLUDE_ATA */

        #ifdef  INCLUDE_DISKONCHIP
            printf (" tffs");
        #endif  /* INCLUDE_DISKONCHIP */

        #ifdef  INCLUDE_TFFS
            printf (" tffs");
        #endif  /* INCLUDE_TFFS */

            printf ("\n");
            }

3.14. IModify the file Tornado/target/config/all/bootConfig.c and add the
      following code fragment under #define INCLUDE_DISKONCHIP to the
      routine bootLoad():

        #ifdef	INCLUDE_ATA

            if (strncmp (params.bootDev, "ata", 3) == 0)
        	{
        	int ctrl  = 0;
        	int drive = 0;

        	if (strlen (params.bootDev) == 3)
        	    return (ERROR);
        	else
        	    sscanf (params.bootDev, "%*3s%*c%d%*c%d", &ctrl, &drive);

        	if (ataLoad (ctrl, drive, params.bootFile, pEntry) != OK)
        	    {
        	    printErr ("\nError loading file: errno = 0x%x.\n", errno);
        	    return (ERROR);
        	    }

        	return (OK);
        	}

        #endif	/* INCLUDE_ATA */

        #ifdef	INCLUDE_DISKONCHIP

            if (strncmp (params.bootDev, "tffs", 4) == 0)
                {
                int drive = 0;
                int removable = 0;

                if (strlen (params.bootDev) == 4)
        	    return (ERROR);
                else
        	    sscanf (params.bootDev, "%*4s%*c%d%*c%d", &drive, &removable);

                if (tffsLoad (drive, 0, params.bootFile, pEntry) != OK)
        	    {
        	    printErr ("\nError loading file: errno = 0x%x.\n", errno);
        	    return (ERROR);
        	    }

                return (OK);
            }

        #endif  /* INCLUDE_DISKONCHIP */

        #ifdef	INCLUDE_PCMCIA

            pcmciaInit ();			/* init PCMCIA Lib */

            if (strncmp (params.bootDev, "pcmcia", 6) == 0)
        	{
        	int sock	= NONE;

        	if (strlen (params.bootDev) == 6)
        	    return (ERROR);
        	else
        	    sscanf (params.bootDev, "%*6s%*c%d", &sock);

        	if (pcmciaLoad (sock, params.bootFile, pEntry) == OK)
        	    return (OK);

        	/* fall through if the PC card is not a block device.
        	 * let's try to boot it from an ethernet device.
        	 */
        	}

        #endif	/* INCLUDE_PCMCIA */

3.15. Modify the file Tornado/target/config/all/bootConfig.c and add the
      following code fragment to #define INCLUDE_DISKONCHIP
      as shown below:

        #if     (defined (INCLUDE_SCSI_BOOT) || defined (INCLUDE_FD) || \
        	 defined (INCLUDE_IDE) || defined (INCLUDE_ATA) || \
        	 defined (INCLUDE_DISKONCHIP) || defined (INCLUDE_TFFS))

        #define	SPIN_UP_TIMEOUT	45	/* max # of seconds to wait for spinup */

3.16. Modify the file Tornado/target/config/all/usrConfig.c and add the
      following code fragment under #define INCLUDE_DISKONCHIP, just
      before the routine usrRoot():

        #ifdef	INCLUDE_DISKONCHIP

        #ifdef __cplusplus
        extern "C" {
        #endif

        #ifndef _ASMLANGUAGE

	/* DiskOnChip driver's configuration variables. */
        /* See Chapter 4 for details.                   */

        extern unsigned char flUse8bit;
        extern unsigned char flUseNFTLCache;
        extern int fl_useDebug;

        #if defined(__STDC__) || defined(__cplusplus)

	extern void      tffsSetup (int diskonchips, long *addressRange);
        extern STATUS	 tffsDrv (void);

        #else	/* __STDC__ */

	extern void      tffsSetup ();
        extern STATUS	 tffsDrv ();

        #endif	/* __STDC__ */

        #endif  /* _ASMLANGUAGE */

        #ifdef __cplusplus
        }
        #endif

        #endif	/* INCLUDE_DISKONCHIP */

3.17. Modify the file Tornado/target/config/all/usrConfig.c and add the
      following code fragment under #define INCLUDE_DISKONCHIP to
      the routine usrRoot():

        #ifdef  INCLUDE_ATA
            {                                   /* initialize hard disk driver */
            IMPORT ATA_RESOURCE ataResources[];
            ATA_RESOURCE *pAtaResource;

            for (ix = 0; ix < ATA_MAX_CTRLS; ix++)
                {
                pAtaResource = &ataResources[ix];
                if (pAtaResource->ctrlType == IDE_LOCAL)
                    ataDrv (ix, pAtaResource->drives, pAtaResource->intVector,
                            pAtaResource->intLevel, pAtaResource->configType,
                            pAtaResource->semTimeout, pAtaResource->wdgTimeout);
                }
            }
        #ifdef  INCLUDE_SHOW_ROUTINES
            ataShowInit ();                     /* install ATA/IDE show routine */
        #endif  /* INCLUDE_SHOW_ROUTINES */
        #endif  /* INCLUDE_ATA */

        #ifdef  INCLUDE_LPT
            {
            IMPORT LPT_RESOURCE lptResources[];
            lptDrv (LPT_CHANNELS, &lptResources[0]); /* init LPT parallel driver */
            }
        #endif  /* INCLUDE_LPT */

⌨️ 快捷键说明

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