MPFS2.h

Go to the documentation of this file.
00001 
00002 
00003 
00030 /*********************************************************************
00031  * Software License Agreement
00032  *
00033  * Copyright (C) 2002-2008 Microchip Technology Inc.  All rights 
00034  * reserved.
00035  *
00036  * Microchip licenses to you the right to use, modify, copy, and 
00037  * distribute: 
00038  * (i)  the Software when embedded on a Microchip microcontroller or 
00039  *      digital signal controller product ("Device") which is 
00040  *      integrated into Licensee's product; or
00041  * (ii) ONLY the Software driver source files ENC28J60.c and 
00042  *      ENC28J60.h ported to a non-Microchip device used in 
00043  *      conjunction with a Microchip ethernet controller for the 
00044  *      sole purpose of interfacing with the ethernet controller. 
00045  *
00046  * You should refer to the license agreement accompanying this 
00047  * Software for additional information regarding your rights and 
00048  * obligations.
00049  *
00050  * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED "AS IS" WITHOUT 
00051  * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT 
00052  * LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A 
00053  * PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL 
00054  * MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR 
00055  * CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF 
00056  * PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS 
00057  * BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE 
00058  * THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER 
00059  * SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT 
00060  * (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE.
00061  *
00062  *
00063  * Author               Date        Comment
00064  *~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
00065  * Elliott Wood         07/2007     Complete rewrite as MPFS2
00066  * E. Wood              04/2008     Updated as MPFS2.1
00067  ********************************************************************/
00068 
00069 #ifndef __MPFS2_H
00070 #define __MPFS2_H
00071 
00072 
00073 /****************************************************************************
00074   Section:
00075     Storage Type Configurations
00076   ***************************************************************************/
00077     #if defined(STACK_USE_MPFS) && defined(STACK_USE_MPFS2)
00078         #error Both MPFS and MPFS2 are included
00079     #endif
00080 
00081     #if defined(MPFS_USE_EEPROM)
00082         #if defined(USE_EEPROM_25LC1024)
00083             #define MPFS_WRITE_PAGE_SIZE        (256u)  // Defines the size of a page in EEPROM
00084         #else
00085             #define MPFS_WRITE_PAGE_SIZE        (64u)   // Defines the size of a page in EEPROM
00086         #endif
00087     #endif
00088 
00089 /****************************************************************************
00090   Section:
00091     Type Definitions
00092   ***************************************************************************/
00093     #define MPFS2_FLAG_ISZIPPED     ((WORD)0x0001)  // Indicates a file is compressed with GZIP compression
00094     #define MPFS2_FLAG_HASINDEX     ((WORD)0x0002)  // Indicates a file has an associated index of dynamic variables
00095     // MODIFIX: Added the following macro:
00096     #define MPFS2_FLAG_ISCOMPRESSED ((WORD)0x0004)  // Indicates a file is compressed with huffman compression
00097     #define MPFS_INVALID            (0xffffffffu)   // Indicates a position pointer is invalid
00098     #define MPFS_INVALID_FAT        (0xffffu)       // Indicates an invalid FAT cache
00099     #define MPFS_INVALID_HANDLE     (0xffu)         // Indicates that a handle is not valid
00100     typedef DWORD MPFS_PTR;                         // MPFS Pointers are currently DWORDs
00101     typedef BYTE MPFS_HANDLE;                       // MPFS Handles are currently stored as BYTEs
00102 
00103 
00104     // Stores each file handle's information
00105     // Handles are free when addr = MPFS_INVALID
00106     typedef struct
00107     {
00108         MPFS_PTR addr;      // Current address in the file system
00109         DWORD bytesRem;     // How many bytes remain in this file
00110         WORD fatID;         // ID of which file in the FAT was accessed
00111         BYTE offset;        // MODIFIX: Added this field for bit position in huffman encoded files.
00112     } MPFS_STUB;
00113     
00114     // Indicates the method for MPFSSeek
00115     typedef enum
00116     {
00117         MPFS_SEEK_START     = 0u,   // Seek forwards from the front of the file
00118         MPFS_SEEK_END,              // Seek backwards from the end of the file
00119         MPFS_SEEK_FORWARD,          // Seek forward from the current position
00120         MPFS_SEEK_REWIND            // See backwards from the current position
00121     } MPFS_SEEK_MODE;
00122     
00123     // Stores the data for an MPFS2 FAT record
00124     typedef struct
00125     {
00126         DWORD string;       // Pointer to the file name
00127         DWORD data;         // Address of the file data
00128         DWORD len;          // Length of file data
00129         DWORD timestamp;    // Timestamp of file
00130         DWORD microtime;    // Microtime stamp of file
00131         WORD flags;         // Flags for this file
00132     } MPFS_FAT_RECORD;
00133 
00134 /****************************************************************************
00135   Section:
00136     Function Definitions
00137   ***************************************************************************/
00138 
00139 void MPFSInit(void);
00140 
00141 MPFS_HANDLE MPFSOpen(BYTE* cFile);
00142 #if defined(__18CXX)
00143     MPFS_HANDLE MPFSOpenROM(ROM BYTE* cFile);
00144 #else
00145     // Non-ROM variant for C30 / C32
00146     #define MPFSOpenROM(a)  MPFSOpen((BYTE*) a);
00147 #endif
00148 MPFS_HANDLE MPFSOpenID(WORD hFatID);
00149 void MPFSClose(MPFS_HANDLE hMPFS);
00150 
00151 BOOL MPFSGet(MPFS_HANDLE hMPFS, BYTE* c);
00152 WORD MPFSGetArray(MPFS_HANDLE hMPFS, BYTE* cData, WORD wLen);
00153 BOOL MPFSGetLong(MPFS_HANDLE hMPFS, DWORD* ul);
00154 BOOL MPFSSeek(MPFS_HANDLE hMPFS, DWORD dwOffset, MPFS_SEEK_MODE tMode);
00155 #if defined(__C30__)
00156     // Assembly function to read all three bytes of program memory for 16-bit parts
00157     extern DWORD ReadProgramMemory(DWORD address);
00158 #endif
00159 
00160 MPFS_HANDLE MPFSFormat(void);
00161 void MPFSPutEnd(BOOL final);
00162 WORD MPFSPutArray(MPFS_HANDLE hMPFS, BYTE* cData, WORD wLen);
00163 
00164 DWORD MPFSGetTimestamp(MPFS_HANDLE hMPFS);
00165 DWORD MPFSGetMicrotime(MPFS_HANDLE hMPFS);
00166 WORD MPFSGetFlags(MPFS_HANDLE hMPFS);
00167 DWORD MPFSGetSize(MPFS_HANDLE hMPFS);
00168 DWORD MPFSGetBytesRem(MPFS_HANDLE hMPFS);
00169 MPFS_PTR MPFSGetStartAddr(MPFS_HANDLE hMPFS);
00170 MPFS_PTR MPFSGetEndAddr(MPFS_HANDLE hMPFS);
00171 BOOL MPFSGetFilename(MPFS_HANDLE hMPFS, BYTE* cName, WORD wLen);
00172 DWORD MPFSGetPosition(MPFS_HANDLE hMPFS);
00173 WORD MPFSGetID(MPFS_HANDLE hMPFS);
00174 
00175 // Alias of MPFSGetPosition
00176 #define MPFSTell(a) MPFSGetPosition(a)
00177 
00178 #endif

Generated on Sun Nov 27 20:02:38 2011 for eWicht by  doxygen 1.5.5