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

📄 fileinit.c

📁 基于nucleus操作系统的GPRS无线数据传输终端全套源文件。包括支持ARM7的BSP,操作系统
💻 C
📖 第 1 页 / 共 2 页
字号:
/*******************************************************************/
/*                                                                 */
/* File Initialization Module                                      */
/*                                                                 */
/*                                                                 */
/* This module contains functions used to initialize the hardware  */
/* in your system.  It must be modified for your individual setup. */
/* The function file_init() must be called from a task to setup    */
/* the file system before any other tasks attempt to use it.       */
/* The task that calls file_init() will automatically be setup     */
/* as a File User.                                                 */
/*                                                                 */
/* NOTE: This module is linked in with File.lib.  After you make   */
/*       changes, you must rebuild File.lib.                       */
/*                                                                 */
/*******************************************************************/

/* Include necessary Nucleus PLUS files.  */
#include  "plus\nucleus.h"
#include  "file\pcdisk.h"


/* These #defines are used for initialization */
#define         RAM_DRIVE    0       /* 0  */
#define         RAM_DISK     "A:"    /* A: */  
#define         HARD_DRIVE    2       /* 2  */
#define         HARD_DISK     "C:"    /* C: */  

/* Function prototypes */
#if RAMDISK           /* Defined in pcdisk.h */
STATUS setup_ramdisk(VOID);
#endif
#if IDE_ATA           /* Defined in pcdisk.h */
STATUS setup_disk(VOID);
extern INT   pc_get_ataparams(INT16 driveno, FMTPARMS *pfmt);
#endif

/************************************************************************/
/*                                                                      */
/*  FUNCTION                           "file_init"                      */
/*                                                                      */
/*                                                                      */
/*  DESCRIPTION                                                         */
/*                                                                      */
/*      This function is responsible for initializing the file system   */
/*      This module needs to be modified to reflect the actual          */
/*      hardware present in your system.                                */
/*                                                                      */
/*  ROUTINES CALLED                                                     */
/*                                                                      */
/*      NU_Become_File_User                 Registers this task as a    */
/*                                          user of the file system.    */
/*      setup_ramdisk                       Sets up the ramdisk         */
/*      setup_disk                          Sets up a hard disk.        */
/*                                          on the disk.                */
/*                                                                      */
/*  INPUTS                                                              */
/*       NONE.                                                          */
/*                                                                      */
/*  OUTPUTS                                                             */
/*       status                             Status from NU_Open_Disk or */
/*                                          Status from NU_Format       */
/*                                                                      */
/************************************************************************/
STATUS   file_init(VOID)
{
OPTION      preempt_status;
STATUS  status;                 /* Return value from funtion calls */


    /* Disable time slice until ramdisk is set up */
    preempt_status = NU_Change_Preemption(NU_NO_PREEMPT);

    /* Initialize memory. This only needs to be done once system wide */
    if (!pc_memory_init())
    {
        return(NUF_INTERNAL);
    }
    
    status = NU_Become_File_User();

    /* Each task must register as a File User user */
    if (status != YES)
    {
        
        return (NUF_BAD_USER);
    }

#if RAMDISK
    /* Set up the ramdisk for use */
	status = setup_ramdisk();

	if(status == NU_SUCCESS)
	    status = NU_Set_Default_Drive(RAM_DRIVE);

	if(status == NU_SUCCESS)
  	    status = NU_Set_Current_Dir(RAM_DISK);
#endif
    
#if IDE_ATA
    /* Set up the hard disk for use */
	status = setup_disk();

	if(status == NU_SUCCESS)
	    status = NU_Set_Default_Drive(HARD_DRIVE);

	if(status == NU_SUCCESS)
	    status = NU_Set_Current_Dir(HARD_DISK);
#endif
    
	/* Enable time slice */
    NU_Change_Preemption(preempt_status);

	return(status);



}


#if RAMDISK
/**************************************************************************/
/*                                                                        */
/*  FUNCTION                           "setup_ramdisk"                    */
/*                                                                        */
/*                                                                        */
/*  DESCRIPTION                                                           */
/*                                                                        */
/*      This task will set up the format parameters and then              */
/*      call NU_Format() to format the ramdisk.                           */
/*                                                                        */
/*  AUTHOR                                                                */
/*                      Accelerated Technology                            */
/*  CALLED FROM                                                           */
/*                                                                        */
/*      file_init                                                         */
/*                                                                        */
/*  ROUTINES CALLED                                                       */
/*                                                                        */
/*      NU_Format                           Formats the disk              */
/*                                          user of the file system.      */
/*                                          on the disk.                  */
/*                                                                        */
/*  INPUTS                                                                */
/*       driveno                            The number of the             */
/*                                          drive to format               */
/*  OUTPUTS                                                               */
/*       NU_SUCCESS                          If the filesystem disk was   */
/*                                            successfully initialized.   */
/*       NUF_BAD_USER                        Not a file user.             */
/*       NUF_BADDRIVE                        Invalid drive specified.     */
/*       NUF_NOT_OPENED                      The disk is not opened yet.  */
/*       NUF_FATCORE                         Fat cache table too small.   */
/*       NUF_BADPARM                         Invalid parameter specified. */
/*       NUF_BADDISK                         Bad Disk.                    */
/*       NUF_NO_PARTITION                    No partition in disk.        */
/*       NUF_NOFAT                           No FAT type in this          */

⌨️ 快捷键说明

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