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

📄 pc_error.c

📁 NUcleus plus 支持的文件系统。 是学习文件系统的很好参考资料。
💻 C
字号:
/************************************************************************
*                                                                       
*       Copyright (c) 2001 by Accelerated Technology, Inc.              
*                                                                       
*  PROPRIETARY RIGHTS of Accelerated Technology are  involved in        
*  the subject matter of this material.  All manufacturing,             
*  reproduction, use, and sales rights pertaining to this subject       
*  matter are  governed by the license agreement.  The recipient of     
*     this software implicitly accepts the terms of the license.        
*                                                                       
*                                                                       
*************************************************************************

*************************************************************************
* FILE NAME                                     VERSION                 
*                                                                       
*       PC_ERROR.C                              FILE  2.3             
*                                                                       
* COMPONENT                                                             
*                                                                       
*       Nucleus File                                                    
*                                                                       
* DESCRIPTION                                                           
*                                                                       
*       Report internal error function.                                 
*                                                                       
*                                                                       
* AUTHOR                                                                
*                                                                       
*       Takahiro Takahashi
*                                                                       
* DATA STRUCTURES                                                       
*                                                                       
*       pc_error_strings                    Error strings list.         
*                                                                       
* FUNCTIONS                                                             
*                                                                       
*       va_error_print                      Error code print.           
*       pc_report_error                     Error report.               
*                                                                       
* DEPENDENCIES                                                          
*                                                                       
*       pcdisk.h                            File common definitions     
*                                                                       
*************************************************************************/

#include        "file\pcdisk.h"
#include        <stdarg.h>


static UINT8 *pc_error_strings[] =
{
    /* PCERR_FAT_FLUSH      0 */    (UINT8 *)"Cant flush FAT\n",
    /* PCERR_FAT_NULLP      1 */    (UINT8 *)"flushfat called with null pointer",
    /* PCERR_NOFAT          2 */    (UINT8 *)"No FAT type in this partition., Can't Format",
    /* PCERR_FMTCSIZE       3 */    (UINT8 *)"Too many cluster for this partition., Can't Format",
    /* PCERR_FMTFSIZE       4 */    (UINT8 *)"File allocation Table Too Small, Can't Format",
    /* PCERR_FMTRSIZE       5 */    (UINT8 *)"Numroot must be an even multiple of INOPBLOCK",
    /* PCERR_FMTWBZERO      6 */    (UINT8 *)"Failed writing block 0",
    /* PCERR_FMTWFAT        7 */    (UINT8 *)"Failed writing FAT block",
    /* PCERR_FMTWROOT       8 */    (UINT8 *)"Failed writing root block",
    /* PCERR_FMT2BIG        9 */    (UINT8 *)"Total sectors may not exceed 64k.",
    /* PCERR_FSTOPEN        10 */    (UINT8 *)"pc_free_all freeing a file",
    /* PCERR_INITMEDI       11 */   (UINT8 *)"Not a DOS disk:pc_dskinit",
    /* PCERR_INITDRNO       12 */   (UINT8 *)"Invalid driveno to pc_dskinit",
    /* PCERR_INITCORE       13 */   (UINT8 *)"Out of core:pc_dskinit",
    /* PCERR_INITDEV        14 */   (UINT8 *)"Can't initialize device:pc_dskinit",
    /* PCERR_INITREAD       15 */   (UINT8 *)"Can't read block 0:pc_dskinit",
    /* PCERR_BLOCKCLAIM     16 */   (UINT8 *)"There is no block buffer",
    /* PCERR_INITALLOC      17 */   (UINT8 *)"Fatal error: Not enough core at startup",
    /* PCERR_BLOCKLOCK      18 */   (UINT8 *)"Warning: freeing a locked buffer",
    /* PCERR_FREEINODE      19 */   (UINT8 *)"Bad free call to freei",
    /* PCERR_FREEDROBJ      20 */   (UINT8 *)"Bad free call to freeobj",
    /* PCERR_FATCORE        22 */   (UINT8 *)"Not Enough Core To Load FAT",
    /* PCERR_FATREAD        23 */   (UINT8 *)"IO Error While Failed Reading FAT",
    /* PCERR_BLOCKALLOC     24 */   (UINT8 *)"Block Alloc Failure Memory Not Initialized",
    /* PCERR_DROBJALLOC     25 */   (UINT8 *)"Memory Failure: Out of DROBJ Structures",
    /* PCERR_FINODEALLOC    26 */   (UINT8 *)"Memory Failure: Out of FINODE Structures",
    /* PCERR_USERS          27 */   (UINT8 *)"Out of User Structures",
    /* PCERR_BAD_USER       28 */   (UINT8 *)"Unregistered User",
    /* PCERR_NO_DISK        29 */   (UINT8 *)"No disk",
    /* PCERR_DISK_CHANGED   30 */   (UINT8 *)"Disk changed",
    /* PCERR_DRVALLOC       31 */   (UINT8 *)"Memory Failure: Out of DDRIVE Structures",
    /* PCERR_PATHL          32 */   (UINT8 *)"Path too long."
    };


/************************************************************************
* FUNCTION                                                              
*                                                                       
*       va_error_print                                                  
*                                                                       
* DESCRIPTION                                                           
*                                                                       
*       Error print function.                                           
*                                                                       
* AUTHOR                                                                
*                                                                       
*       Takahiro Takahashi
*                                                                       
* INPUTS                                                                
*                                                                       
*       INT8 *format, ...                                               
*                                                                       
* OUTPUTS                                                               
*                                                                       
*       None.                                                           
*                                                                       
*************************************************************************/
VOID va_error_print(INT8 *format, ...)
{
#ifdef DEBUG
    va_list argptr;

    char msg[512];

    va_start(argptr, format);
    vsprintf(msg, (char *)format, argptr);
    va_end(argptr);

    PRINT_STRING(msg);
#endif

}


/************************************************************************
* FUNCTION                                                              
*                                                                       
*       pc_report_error                                                 
*                                                                       
* DESCRIPTION                                                           
*                                                                       
*       When the system detects an error needs it calls this routine    
*       with PCERR_????? as an argument. In the reference port we call  
*       printf to report the error. You may do anything you like with   
*       these errors.                                                   
*                                                                       
* AUTHOR                                                                
*                                                                       
*       Takahiro Takahashi
*                                                                       
* INPUTS                                                                
*                                                                       
*       error_number                        Error number                
*                                                                       
* OUTPUTS                                                               
*                                                                       
*       None.                                                           
*                                                                       
*************************************************************************/
VOID pc_report_error(INT error_number)
{
    va_error_print("Error %d: %s\r\n", error_number, pc_error_strings[error_number]);
}

⌨️ 快捷键说明

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