flbase.h
上传用户:luoyougen
上传日期:2008-05-12
资源大小:23136k
文件大小:7k
源码类别:

VxWorks

开发平台:

C/C++

  1. /*
  2.  * $Log:   P:/user/amir/lite/vcs/flbase.h_v  $
  3.    
  4.       Rev 1.15   06 Oct 1997 19:39:44   danig
  5.    Changed LEushortlong & Unaligned4 to arrays
  6.    
  7.       Rev 1.14   10 Sep 1997 16:11:40   danig
  8.    Got rid of generic names
  9.    
  10.       Rev 1.13   31 Aug 1997 14:27:32   danig
  11.    flTooManyComponents
  12.    
  13.       Rev 1.12   28 Aug 1997 16:46:00   danig
  14.    Moved SectorNo definition from fltl.h
  15.    
  16.       Rev 1.11   21 Aug 1997 14:06:42   unknown
  17.    Unaligned4
  18.    
  19.       Rev 1.10   31 Jul 1997 14:28:22   danig
  20.    UNALIGNED -> Unaligned
  21.    
  22.       Rev 1.9   28 Jul 1997 15:15:58   danig
  23.    Standard typedefs
  24.    
  25.       Rev 1.8   24 Jul 1997 18:05:40   amirban
  26.    New include file org
  27.    
  28.       Rev 1.7   07 Jul 1997 15:23:26   amirban
  29.    Ver 2.0
  30.    
  31.       Rev 1.5   18 May 1997 17:34:30   amirban
  32.    Defined dataError
  33.    
  34.       Rev 1.4   03 Oct 1996 11:56:16   amirban
  35.    New Big-Endian
  36.    
  37.       Rev 1.3   18 Aug 1996 13:47:34   amirban
  38.    Comments
  39.    
  40.       Rev 1.2   12 Aug 1996 15:46:58   amirban
  41.    Defined incomplete and timedOut codes
  42.    
  43.       Rev 1.1   16 Jun 1996 14:03:00   amirban
  44.    Added iFLite compatibility mode
  45.    
  46.       Rev 1.0   20 Mar 1996 13:33:20   amirban
  47.    Initial revision.
  48.  */
  49. /************************************************************************/
  50. /*                                                                      */
  51. /* FAT-FTL Lite Software Development Kit */
  52. /* Copyright (C) M-Systems Ltd. 1995-1996 */
  53. /* */
  54. /************************************************************************/
  55. #ifndef FLBASE_H
  56. #define FLBASE_H
  57. #ifdef __cplusplus
  58. extern "C" {
  59. #endif
  60. #include "flsystem.h"
  61. #include "flcustom.h"
  62. /* standard type definitions */
  63. typedef int  FLBoolean;
  64. /* Boolean constants */
  65. #ifndef FALSE
  66. #define FALSE 0
  67. #endif
  68. #ifndef TRUE
  69. #define TRUE 1
  70. #endif
  71. #ifndef TFFS_ON
  72. #define TFFS_ON 1
  73. #endif
  74. #ifndef TFFS_OFF
  75. #define TFFS_OFF 0
  76. #endif
  77. #define SECTOR_SIZE (1 << SECTOR_SIZE_BITS)
  78. /* define SectorNo range according to media maximum size */
  79. #if (MAX_VOLUME_MBYTES * 0x100000l) / SECTOR_SIZE > 0x10000l
  80. typedef unsigned long SectorNo;
  81. #define UNASSIGNED_SECTOR 0xffffffffl
  82. #else
  83. typedef unsigned short SectorNo;
  84. #define UNASSIGNED_SECTOR 0xffff
  85. #endif
  86. #if FAR_LEVEL > 0
  87.   #define FAR0 far
  88. #else
  89.   #define FAR0
  90. #endif
  91. #if FAR_LEVEL > 1
  92.   #define FAR1 far
  93. #else
  94.   #define FAR1
  95. #endif
  96. #if FAR_LEVEL > 2
  97.   #define FAR2 far
  98. #else
  99.   #define FAR2
  100. #endif
  101. #define vol (*pVol)
  102. #ifndef TFFS_BIG_ENDIAN
  103. typedef unsigned short LEushort;
  104. typedef unsigned long LEulong;
  105. #define LE2(arg) arg
  106. #define toLE2(to,arg) (to) = (arg)
  107. #define LE4(arg) arg
  108. #define toLE4(to,arg) (to) = (arg)
  109. #define COPY2(to,arg) (to) = (arg)
  110. #define COPY4(to,arg) (to) = (arg)
  111. typedef unsigned char Unaligned[2];
  112. typedef Unaligned Unaligned4[2];
  113. #define UNAL2(arg) fromUNAL(arg)
  114. #define toUNAL2(to,arg) toUNAL(to,arg)
  115. #define UNAL4(arg) fromUNALLONG(arg)
  116. #define toUNAL4(to,arg) toUNALLONG(to,arg)
  117. extern void toUNAL(unsigned char FAR0 *unal, unsigned n);
  118. extern unsigned short fromUNAL(unsigned char const FAR0 *unal);
  119. extern void toUNALLONG(Unaligned FAR0 *unal, unsigned long n);
  120. extern unsigned long fromUNALLONG(Unaligned const FAR0 *unal);
  121. #else
  122. typedef unsigned char LEushort[2];
  123. typedef unsigned char LEulong[4];
  124. #define LE2(arg) fromLEushort(arg)
  125. #define toLE2(to,arg) toLEushort(to,arg)
  126. #define LE4(arg) fromLEulong(arg)
  127. #define toLE4(to,arg) toLEulong(to,arg)
  128. #define COPY2(to,arg) copyShort(to,arg)
  129. #define COPY4(to,arg) copyLong(to,arg)
  130. #define Unaligned LEushort
  131. #define Unaligned4 LEulong
  132. extern void toLEushort(unsigned char FAR0 *le, unsigned n);
  133. extern unsigned short fromLEushort(unsigned char const FAR0 *le);
  134. extern void toLEulong(unsigned char FAR0 *le, unsigned long n);
  135. extern unsigned long fromLEulong(unsigned char const FAR0 *le);
  136. extern void copyShort(unsigned char FAR0 *to,
  137.       unsigned char const FAR0 *from);
  138. extern void copyLong(unsigned char FAR0 *to,
  139.      unsigned char const FAR0 *from);
  140. #define UNAL2 LE2
  141. #define toUNAL2 toLE2
  142. #define UNAL4 LE4
  143. #define toUNAL4 toLE4
  144. #endif /* TFFS_BIG_ENDIAN */
  145. #ifndef IFLITE_ERROR_CODES
  146. typedef enum {flOK  = 0, /* Status code for operation.
  147.    A zero value indicates success,
  148.    other codes are the extended
  149.    DOS codes. */
  150.      flBadFunction = 1,
  151.      flFileNotFound = 2,
  152.      flPathNotFound = 3,
  153.      flTooManyOpenFiles = 4,
  154.      flNoWriteAccess = 5,
  155.      flBadFileHandle = 6,
  156.      flDriveNotAvailable = 9,
  157.      flNonFATformat = 10,
  158.      flFormatNotSupported = 11,
  159.      flNoMoreFiles = 18,
  160.      flWriteProtect  = 19,
  161.      flBadDriveHandle = 20,
  162.      flDriveNotReady  = 21,
  163.      flUnknownCmd  = 22,
  164.      flBadFormat = 23,
  165.      flBadLength = 24,
  166.      flDataError = 25,
  167.      flUnknownMedia  = 26,
  168.      flSectorNotFound  = 27,
  169.      flOutOfPaper  = 28,
  170.      flWriteFault  = 29,
  171.      flReadFault = 30,
  172.      flGeneralFailure  = 31,
  173.      flDiskChange  = 34,
  174.      flVppFailure = 50,
  175.      flBadParameter = 51,
  176.      flNoSpaceInVolume = 52,
  177.      flInvalidFATchain = 53,
  178.      flRootDirectoryFull = 54,
  179.      flNotMounted = 55,
  180.      flPathIsRootDirectory = 56,
  181.      flNotADirectory = 57,
  182.      flDirectoryNotEmpty = 58,
  183.      flFileIsADirectory = 59,
  184.      flAdapterNotFound = 60,
  185.      flFormattingError = 62,
  186.      flNotEnoughMemory = 63,
  187.      flVolumeTooSmall = 64,
  188.      flBufferingError = 65,
  189.      flFileAlreadyExists = 80,
  190.      flIncomplete = 100,
  191.      flTimedOut = 101,
  192.      flTooManyComponents = 102
  193. #else
  194. #include "type.h"
  195. typedef enum {flOK  = ERR_NONE,
  196. /* Status code for operation.
  197.    A zero value indicates success,
  198.    other codes are the extended
  199.    DOS codes. */
  200.      flBadFunction = ERR_SW_HW,
  201.      flFileNotFound = ERR_NOTEXISTS,
  202.      flPathNotFound = ERR_NOTEXISTS,
  203.      flTooManyOpenFiles = ERR_MAX_FILES,
  204.      flNoWriteAccess = ERR_WRITE,
  205.      flBadFileHandle = ERR_NOTOPEN,
  206.      flDriveNotAvailable = ERR_SW_HW,
  207.      flNonFATformat = ERR_PARTITION,
  208.      flFormatNotSupported = ERR_PARTITION,
  209.      flNoMoreFiles = ERR_NOTEXISTS,
  210.      flWriteProtect  = ERR_WRITE,
  211.      flBadDriveHandle = ERR_SW_HW,
  212.      flDriveNotReady  = ERR_PARTITION,
  213.      flUnknownCmd  = ERR_PARAM,
  214.      flBadFormat = ERR_PARTITION,
  215.      flBadLength = ERR_SW_HW,
  216.      flDataError = ERR_READ,
  217.      flUnknownMedia  = ERR_PARTITION,
  218.      flSectorNotFound  = ERR_READ,
  219.      flOutOfPaper  = ERR_SW_HW,
  220.      flWriteFault  = ERR_WRITE,
  221.      flReadFault = ERR_READ,
  222.      flGeneralFailure  = ERR_SW_HW,
  223.      flDiskChange  = ERR_PARTITION,
  224.      flVppFailure = ERR_WRITE,
  225.      flBadParameter = ERR_PARAM,
  226.      flNoSpaceInVolume = ERR_SPACE,
  227.      flInvalidFATchain = ERR_PARTITION,
  228.      flRootDirectoryFull = ERR_DIRECTORY,
  229.      flNotMounted = ERR_PARTITION,
  230.      flPathIsRootDirectory = ERR_DIRECTORY,
  231.      flNotADirectory = ERR_DIRECTORY,
  232.      flDirectoryNotEmpty = ERR_NOT_EMPTY,
  233.      flFileIsADirectory = ERR_DIRECTORY,
  234.      flAdapterNotFound = ERR_DETECT,
  235.      flFormattingError = ERR_FORMAT,
  236.      flNotEnoughMemory = ERR_SW_HW,
  237.      flVolumeTooSmall = ERR_FORMAT,
  238.      flBufferingError = ERR_SW_HW,
  239.      flFileAlreadyExists = ERR_EXISTS,
  240.      flIncomplete = ERR_DETECT,
  241.      flTimedOut = ERR_SW_HW,
  242.      flTooManyComponents = ERR_PARAM
  243. #endif
  244.      } FLStatus;
  245. /* call a procedure returning status and fail if it fails. This works only in
  246.    routines that return Status */
  247. #define checkStatus(exp)      { FLStatus status = (exp); 
  248. if (status != flOK)  
  249.   return status; }
  250. #include "flsysfun.h"
  251. #ifdef __cplusplus
  252. }
  253. #endif
  254. #endif