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

📄 fileinit.c

📁 nucleus file NUCLEUS的文件系统源代码
💻 C
📖 第 1 页 / 共 2 页
字号:
/*                                            partition.                  */
/*       NUF_FMTCSIZE                        Too many clusters for this   */
/*                                            partition.                  */
/*       NUF_FMTFSIZE                        File allocation table too    */
/*                                            small.                      */
/*       NUF_FMTRSIZE                        Numroot must be an even      */
/*                                            multiple of 16.             */
/*       NUF_INVNAME                         Volume lable includes        */
/*                                            invalid character.          */
/*       NUF_NO_MEMORY                       Can't allocate internal      */
/*                                            buffer.                     */
/*       NUF_NO_BLOCK                        No block buffer available.   */
/*       NUF_IO_ERROR                        Driver IO error.             */
/*       NUF_INTERNAL                        Nucleus FILE internal error. */
/*                                                                        */
/**************************************************************************/ 
STATUS setup_ramdisk(VOID)
{
STATUS          status;
FMTPARMS    fmt;


    /* Since the ramdisk is not yet formatted, this call will      */
	/* return an NUF_FORMAT error.  This is normal operation.      */
	/* After the ramdisk is formatted, other calls to NU_Open_Disk */
	/* will return an NU_SUCCES                                    */
    status = NU_Open_Disk(RAM_DISK); /* Open the ramdisk for use */


    /* Setup Format parameters */
    fmt.oemname[0] = 'N';
    fmt.oemname[1] = 'U';
    fmt.oemname[2] = 'F';
    fmt.oemname[3] = 'I';
    fmt.oemname[4] = 'L';
    fmt.oemname[5] = 'E';
    fmt.oemname[6] = ' ';
    fmt.oemname[7] = ' ';
    fmt.oemname[8] = '\0';
    fmt.secpalloc =      (UINT8)  2; 
	                                    /* must be a multiple of 2.  This
                                          number indicates the number of
                                          sectors (blocks) per cluster.
                                          This value is the minimum number
                                          of bytes that are written to or
                                          read from the disk at a time.  */
    fmt.secreserved =    (UINT16) 1;
    fmt.numfats     =    (UINT8)  1;
                                        /* since redundant fats aren't used
                                           only have one fat.  */
    fmt.numroot     =    (UINT16) 64;   /* number of files in root */
    fmt.bytepsec    =    (UINT16) 512;
    fmt.mediadesc   =    (UINT8)  0xFD;
    fmt.partdisk    =    (UINT8)0;
                                         /* No partition */
    fmt.secptrk     =    (UINT16) NRAMDISKBLOCKS/4;
    fmt.numhead     =    (UINT16) 2;
    fmt.numcyl      =    (UINT16) 2;
    fmt.physical_drive_no =   0;
    fmt.binary_volume_label = 0x12345678L;
    fmt.text_volume_label[0] = '\0';    /* 11 chars max */


    /* Format the Ram Disk */
	status = NU_Format(RAM_DRIVE, &fmt); 
	
    /* Return status from NU_Format() */
	return(status);

}
#endif

#if IDE_ATA
/**************************************************************************/
/*                                                                        */
/*  FUNCTION                           "setup_disk"                       */
/*                                                                        */
/*                                                                        */
/*  DESCRIPTION                                                           */
/*                                                                        */
/*      This task will set up the format parameters and then              */
/*      call NU_Format() to format the hard disk if necessary             */
/*                                                                        */
/*  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          */
/*                                            partition.                  */
/*       NUF_FMTCSIZE                        Too many clusters for this   */
/*                                            partition.                  */
/*       NUF_FMTFSIZE                        File allocation table too    */
/*                                            small.                      */
/*       NUF_FMTRSIZE                        Numroot must be an even      */
/*                                            multiple of 16.             */
/*       NUF_INVNAME                         Volume lable includes        */
/*                                            invalid character.          */
/*       NUF_NO_MEMORY                       Can't allocate internal      */
/*                                            buffer.                     */
/*       NUF_NO_BLOCK                        No block buffer available.   */
/*       NUF_IO_ERROR                        Driver IO error.             */
/*       NUF_INTERNAL                        Nucleus FILE internal error. */
/*                                                                        */
/**************************************************************************/ 
STATUS setup_disk(VOID)
{
STATUS          status;
FMTPARMS    fmt;


    /* If the disk not yet formatted, this call will               */
	/* return an NUF_FORMAT error.  This is normal operation.      */
	/* After the disk is formatted, other calls to NU_Open_Disk    */
	/* will return an NU_SUCCES                                    */
    status = NU_Open_Disk(HARD_DISK); /* Open the ramdisk for use  */

	/* If disk not formatted, then format */
	if(status == NUF_FORMAT)
	{
		/* Get the disk parameters */
        pc_get_ataparams( HARD_DRIVE, &fmt);

        /* Format the Ram Disk */
	    status = NU_Format(HARD_DRIVE, &fmt); 
	}

    /* Return status */
	return(status);

}
#endif



⌨️ 快捷键说明

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