ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

ff_ioman.h
Go to the documentation of this file.
00001 /*****************************************************************************
00002  *  FullFAT - High Performance, Thread-Safe Embedded FAT File-System         *
00003  *  Copyright (C) 2009  James Walmsley (james@worm.me.uk)                    *
00004  *                                                                           *
00005  *  This program is free software: you can redistribute it and/or modify     *
00006  *  it under the terms of the GNU General Public License as published by     *
00007  *  the Free Software Foundation, either version 3 of the License, or        *
00008  *  (at your option) any later version.                                      *
00009  *                                                                           *
00010  *  This program is distributed in the hope that it will be useful,          *
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00013  *  GNU General Public License for more details.                             *
00014  *                                                                           *
00015  *  You should have received a copy of the GNU General Public License        *
00016  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.    *
00017  *                                                                           *
00018  *  IMPORTANT NOTICE:                                                        *
00019  *  =================                                                        *
00020  *  Alternative Licensing is available directly from the Copyright holder,   *
00021  *  (James Walmsley). For more information consult LICENSING.TXT to obtain   *
00022  *  a Commercial license.                                                    *
00023  *                                                                           *
00024  *  See RESTRICTIONS.TXT for extra restrictions on the use of FullFAT.       *
00025  *                                                                           *
00026  *  Removing the above notice is illegal and will invalidate this license.   *
00027  *****************************************************************************
00028  *  See http://worm.me.uk/fullfat for more information.                      *
00029  *  Or  http://fullfat.googlecode.com/ for latest releases and the wiki.     *
00030  *****************************************************************************/
00031 
00038 #ifndef _FF_IOMAN_H_
00039 #define _FF_IOMAN_H_
00040 
00041 #include <stdlib.h>                         // Use of malloc()
00042 #include "ff_error.h"
00043 #include "ff_config.h"
00044 #include "ff_types.h"
00045 #include "ff_safety.h"                      // Provide thread-safety via semaphores.
00046 #include "ff_memory.h"                      // Memory access routines for ENDIAN independence.
00047 #include "ff_hash.h"
00048 
00049 //#define   FF_MAX_PARTITION_NAME   5       ///< Partition name length.
00050 
00051 #define FF_T_FAT12              0x0A
00052 #define FF_T_FAT16              0x0B
00053 #define FF_T_FAT32              0x0C
00054 
00055 #define FF_MODE_READ            0x01        ///< Buffer / FILE Mode for Read Access.
00056 #define FF_MODE_WRITE           0x02        ///< Buffer / FILE Mode for Write Access.
00057 #define FF_MODE_APPEND          0x04        ///< FILE Mode Append Access.
00058 #define FF_MODE_CREATE          0x08        ///< FILE Mode Create file if not existing.
00059 #define FF_MODE_TRUNCATE        0x10        ///< FILE Mode Truncate an Existing file.
00060 #define FF_MODE_DIR             0x80        ///< Special Mode to open a Dir. (Internal use ONLY!)
00061 
00062 #define FF_BUF_MAX_HANDLES      0xFFFF      ///< Maximum number handles sharing a buffer. (16 bit integer, we don't want to overflow it!)
00063 
00074 typedef struct {
00075     FF_T_UINT16 BlkSize;
00076     FF_T_UINT32 TotalBlocks;
00077 } FF_DEVICE_INFO;
00078 
00079 typedef FF_T_SINT32 (*FF_WRITE_BLOCKS)  (FF_T_UINT8 *pBuffer, FF_T_UINT32 SectorAddress, FF_T_UINT32 Count, void *pParam);
00080 typedef FF_T_SINT32 (*FF_READ_BLOCKS)   (FF_T_UINT8 *pBuffer, FF_T_UINT32 SectorAddress, FF_T_UINT32 Count, void *pParam);
00081 
00082 #define FF_ERR_DRIVER_BUSY          -10
00083 #define FF_ERR_DRIVER_FATAL_ERROR   -11
00084 
00089 typedef struct {
00090     FF_WRITE_BLOCKS fnpWriteBlocks; 
00091     FF_READ_BLOCKS  fnpReadBlocks;  
00092     FF_T_UINT16     devBlkSize;     
00093     void            *pParam;        
00094 } FF_BLK_DEVICE;
00095 
00101 typedef struct {
00102     FF_T_UINT32     Sector;         
00103     FF_T_UINT32     LRU;            
00104     FF_T_UINT16     NumHandles;     
00105     FF_T_UINT16     Persistance;    
00106     FF_T_UINT8      Mode;           
00107     FF_T_BOOL       Modified;       
00108     FF_T_BOOL       Valid;          
00109     FF_T_UINT8      *pBuffer;       
00110 } FF_BUFFER;
00111 
00112 typedef struct {
00113 #ifdef FF_UNICODE_SUPPORT
00114     FF_T_WCHAR  Path[FF_MAX_PATH];
00115 #else
00116     FF_T_INT8   Path[FF_MAX_PATH];
00117 #endif
00118     FF_T_UINT32 DirCluster;
00119 } FF_PATHCACHE;
00120 
00121 #ifdef FF_HASH_CACHE
00122 typedef struct {
00123     FF_T_UINT32     ulDirCluster;   
00124     FF_HASH_TABLE   pHashTable;     
00125     FF_T_UINT32     ulNumHandles;   
00126     FF_T_UINT32     ulMisses;       
00127 } FF_HASHCACHE;
00128 #endif
00129 
00135 typedef struct {
00136     //FF_T_UINT8        ID;                 ///< Partition Incremental ID number.
00137     FF_T_UINT8      Type;               
00138     FF_T_UINT16     BlkSize;            
00139     FF_T_UINT8      BlkFactor;          
00140     //FF_T_INT8     Name[FF_MAX_PARTITION_NAME];    ///< Partition Identifier e.g. c: sd0: etc.
00141     FF_T_INT8       VolLabel[12];       
00142     FF_T_UINT32     BeginLBA;           
00143     FF_T_UINT32     PartSize;           
00144     FF_T_UINT32     FatBeginLBA;        
00145     FF_T_UINT8      NumFATS;            
00146     FF_T_UINT32     SectorsPerFAT;      
00147     FF_T_UINT8      SectorsPerCluster;  
00148     FF_T_UINT32     TotalSectors;
00149     FF_T_UINT32     DataSectors;
00150     FF_T_UINT32     RootDirSectors;
00151     FF_T_UINT32     FirstDataSector;
00152     FF_T_UINT16     ReservedSectors;
00153     FF_T_UINT32     ClusterBeginLBA;    
00154     FF_T_UINT32     NumClusters;        
00155     FF_T_UINT32     RootDirCluster;     
00156     FF_T_UINT32     LastFreeCluster;
00157     FF_T_UINT32     FreeClusterCount;   
00158     FF_T_BOOL       PartitionMounted;   
00159 #ifdef FF_PATH_CACHE
00160     FF_PATHCACHE    PathCache[FF_PATH_CACHE_DEPTH];
00161     FF_T_UINT32     PCIndex;
00162 #endif
00163 } FF_PARTITION;
00164 
00165 
00166 
00173 #define FF_FAT_LOCK         0x01    ///< Lock bit mask for FAT table locking.
00174 #define FF_DIR_LOCK         0x02    ///< Lock bit mask for DIR modification locking.
00175 //#define FF_PATHCACHE_LOCK 0x04
00176 
00190 typedef struct {
00191     FF_BLK_DEVICE   *pBlkDevice;        
00192     FF_PARTITION    *pPartition;        
00193     FF_BUFFER       *pBuffers;          
00194     void            *pSemaphore;        
00195 #ifdef FF_BLKDEV_USES_SEM
00196     void            *pBlkDevSemaphore;  
00197 #endif
00198     void            *FirstFile;         
00199     FF_T_UINT8      *pCacheMem;         
00200     FF_T_UINT32     LastReplaced;       
00201     FF_T_UINT16     BlkSize;            
00202     FF_T_UINT16     CacheSize;          
00203     FF_T_UINT8      PreventFlush;       
00204     FF_T_UINT8      MemAllocation;      
00205     FF_T_UINT8      Locks;              
00206 #ifdef FF_HASH_CACHE
00207     FF_HASHCACHE    HashCache[FF_HASH_CACHE_DEPTH];
00208 #endif
00209 } FF_IOMAN;
00210 
00211 // Bit-Masks for Memory Allocation testing.
00212 #define FF_IOMAN_ALLOC_BLKDEV   0x01    ///< Flags the pBlkDevice pointer is allocated.
00213 #define FF_IOMAN_ALLOC_PART     0x02    ///< Flags the pPartition pointer is allocated.
00214 #define FF_IOMAN_ALLOC_BUFDESCR 0x04    ///< Flags the pBuffers pointer is allocated.
00215 #define FF_IOMAN_ALLOC_BUFFERS  0x08    ///< Flags the pCacheMem pointer is allocated.
00216 #define FF_IOMAN_ALLOC_RESERVED 0xF0    ///< Reserved Section.
00217 
00218 
00219 //---------- PROTOTYPES (in order of appearance)
00220 
00221 // PUBLIC (Interfaces):
00222 FF_IOMAN    *FF_CreateIOMAN         (FF_T_UINT8 *pCacheMem, FF_T_UINT32 Size, FF_T_UINT16 BlkSize, FF_ERROR *pError);
00223 FF_ERROR    FF_DestroyIOMAN         (FF_IOMAN *pIoman);
00224 FF_ERROR    FF_RegisterBlkDevice    (FF_IOMAN *pIoman, FF_T_UINT16 BlkSize, FF_WRITE_BLOCKS fnWriteBlocks, FF_READ_BLOCKS fnReadBlocks, void *pParam);
00225 FF_ERROR    FF_UnregisterBlkDevice  (FF_IOMAN *pIoman);
00226 FF_ERROR    FF_MountPartition       (FF_IOMAN *pIoman, FF_T_UINT8 PartitionNumber);
00227 FF_ERROR    FF_UnmountPartition     (FF_IOMAN *pIoman);
00228 FF_ERROR    FF_FlushCache           (FF_IOMAN *pIoman);
00229 FF_T_SINT32 FF_GetPartitionBlockSize(FF_IOMAN *pIoman);
00230 
00231 #ifdef FF_64_NUM_SUPPORT
00232 FF_T_UINT64 FF_GetVolumeSize(FF_IOMAN *pIoman);
00233 #else
00234 FF_T_UINT32 FF_GetVolumeSize(FF_IOMAN *pIoman);
00235 #endif
00236 
00237 // PUBLIC  (To FullFAT Only):
00238 FF_T_SINT32 FF_BlockRead            (FF_IOMAN *pIoman, FF_T_UINT32 ulSectorLBA, FF_T_UINT32 ulNumSectors, void *pBuffer);
00239 FF_T_SINT32 FF_BlockWrite           (FF_IOMAN *pIoman, FF_T_UINT32 ulSectorLBA, FF_T_UINT32 ulNumSectors, void *pBuffer);
00240 FF_ERROR    FF_IncreaseFreeClusters (FF_IOMAN *pIoman, FF_T_UINT32 Count);
00241 FF_ERROR    FF_DecreaseFreeClusters (FF_IOMAN *pIoman, FF_T_UINT32 Count);
00242 FF_BUFFER   *FF_GetBuffer           (FF_IOMAN *pIoman, FF_T_UINT32 Sector, FF_T_UINT8 Mode);
00243 void        FF_ReleaseBuffer        (FF_IOMAN *pIoman, FF_BUFFER *pBuffer);
00244 
00245 // PRIVATE (For this module only!):
00246 
00247 
00248 #endif
00249 
00250 

Generated on Sat May 26 2012 04:31:57 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.