00001 /* 00002 fat.h 00003 Simple functionality for startup, mounting and unmounting of FAT-based devices. 00004 00005 Copyright (c) 2006 Michael "Chishm" Chisholm 00006 00007 Redistribution and use in source and binary forms, with or without modification, 00008 are permitted provided that the following conditions are met: 00009 00010 1. Redistributions of source code must retain the above copyright notice, 00011 this list of conditions and the following disclaimer. 00012 2. Redistributions in binary form must reproduce the above copyright notice, 00013 this list of conditions and the following disclaimer in the documentation and/or 00014 other materials provided with the distribution. 00015 3. The name of the author may not be used to endorse or promote products derived 00016 from this software without specific prior written permission. 00017 00018 THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 00019 WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY 00020 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE 00021 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 00022 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00023 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 00024 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00025 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, 00026 EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00027 */ 00028 00029 00030 #ifndef _LIBFAT_H 00031 #define _LIBFAT_H 00032 00033 #ifdef __cplusplus 00034 extern "C" { 00035 #endif 00036 00037 // When compiling for NDS, make sure NDS is defined 00038 #ifndef NDS 00039 #define NDS 00040 #endif 00041 00042 #include <stdint.h> 00043 #include "nds/disc_io.h" 00044 00045 /* 00046 Initialise any inserted block-devices. 00047 Add the fat device driver to the devoptab, making it available for standard file functions. 00048 cacheSize: The number of pages to allocate for each inserted block-device 00049 setAsDefaultDevice: if true, make this the default device driver for file operations 00050 */ 00051 extern bool fatInit (uint32_t cacheSize, bool setAsDefaultDevice); 00052 00053 /* 00054 Calls fatInit with setAsDefaultDevice = true and cacheSize optimised for the host system. 00055 */ 00056 extern bool fatInitDefault (void); 00057 00058 /* 00059 Mount the device pointed to by interface, and set up a devoptab entry for it as "name:". 00060 You can then access the filesystem using "name:/". 00061 This will mount the active partition or the first valid partition on the disc, 00062 and will use a cache size optimized for the host system. 00063 */ 00064 extern bool fatMountSimple (const char* name, const DISC_INTERFACE* interface); 00065 00066 /* 00067 Mount the device pointed to by interface, and set up a devoptab entry for it as "name:". 00068 You can then access the filesystem using "name:/". 00069 If startSector = 0, it will mount the active partition of the first valid partition on 00070 the disc. Otherwise it will try to mount the partition starting at startSector. 00071 cacheSize specifies the number of pages to allocate for the cache. 00072 This will not startup the disc, so you need to call interface->startup(); first. 00073 */ 00074 extern bool fatMount (const char* name, const DISC_INTERFACE* interface, sec_t startSector, uint32_t cacheSize, uint32_t SectorsPerPage); 00075 00076 /* 00077 Unmount the partition specified by name. 00078 If there are open files, it will attempt to synchronise them to disc. 00079 */ 00080 extern void fatUnmount (const char* name); 00081 00082 #ifdef __cplusplus 00083 } 00084 #endif 00085 00086 #endif // _LIBFAT_H