#include "buffer.h"
#include "board.h"
Include dependency graph for filesys.h:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Classes | |
struct | fragmentEntry |
Fragment Table. More... | |
Defines | |
#define | IS_FAT_32 UDF |
Use PSW User Definable Flag to indicate FAT16/32. | |
#define | MAX_NUMBER_FRAGMENTS 10 |
Maximum allowable number of fragments in file. | |
Functions | |
unsigned char | InitFileSystem () |
Start the filing system and initialize all necessary subsystems. | |
unsigned char | OpenFile (unsigned int fileNumber) |
Open a file for reading. | |
unsigned char | FGetChar () |
Read a character from current file. | |
unsigned char | BuildFragmentTable (void) |
Build a fragment table starting from current sector. | |
unsigned char | ScanForFreeSector () |
Search for next free sector. | |
void | WriteClusterChain () |
Write a cluster chain to FAT for a fragment. | |
Variables | |
Public xdata unsigned long | fileSize |
Size of current file to play. | |
xdata struct fragmentEntry | fragment [MAX_NUMBER_FRAGMENTS] |
Fragment Table. | |
xdata char | currentFileName [12] |
8 first characters of current file name | |
xdata unsigned long | freeSector |
Next free cluster number. | |
data unsigned char | fatSectorsPerCluster |
FAT Global sectors per cluster. |
Definition in file filesys.h.
|
Use PSW User Definable Flag to indicate FAT16/32.
Definition at line 15 of file filesys.h. Referenced by BuildFragmentTable(), FatInitGlobals(), GetFatEntry(), GetNextSector(), and WriteClusterChain(). |
|
Maximum allowable number of fragments in file.
|
|
Build a fragment table starting from current sector. Returns number of fragments in song. This function is used to get fast access to the filesystem when playing so cluster chain needs not be followed when the song is playing, that would be too slow with MMC cards without extra buffer memory for the file allocation tables. Note: filesys.c module does not use the fragment table internally. it is written to be a service to the player routine, which uses storage.c module directly for disk access after using the filesys.c module for finding a file to play. I am listening to Darude's Sandstorm while coding this. In terms of memory allocation, this function is devilish. At one stage temp.l is used just to make compiler use memory at temp.l instead of spilling to another unnecessary temp variable... Definition at line 397 of file filesys.c. References Address::b, Address::B::b0, Address::B::b1, Address::B::b3, dataStart, diskSect, DiskBlock::Fat16Table, DiskBlock::Fat32Table, fatSectorsPerCluster, fatStart, fragment, IS_FAT_32, Temp::l, Address::l, fragmentEntry::length, MAX_NUMBER_FRAGMENTS, Public, ReadDiskSector(), sectorAddress, fragmentEntry::start, and temp. Referenced by PlayCurrentFile().
Here is the call graph for this function: |
|
Read a character from current file. This can be called after calling OpenFile. It is a slow method for reading character based file data. fileSize holds the number of characters still left in file to be read, check for fileSize=0 to detect end-of-file. If FGetChar is called after the end of file is reached, it does nothing and returns 0. Definition at line 549 of file filesys.c. References DiskBlock::Raw::buf, dataBufPtr, diskSect, fileSize, Address::l, LoadNextSector(), Public, DiskBlock::raw, ReadDiskSector(), and sectorAddress. Referenced by GetAVIBlock().
Here is the call graph for this function: |
|
Start the filing system and initialize all necessary subsystems. Init storage and file system. FAT16 and FAT32 are supported Definition at line 902 of file filesys.c. References Address::b, Address::B::b0, Address::B::b1, Address::B::b2, Address::B::b3, DiskBlock::Raw::buf, dataStart, diskSect, FatInitGlobals(), fatStart, freeSector, InitStorage(), Address::l, Public, DiskBlock::raw, ReadDiskSector(), rootStart, and sectorAddress. Referenced by main().
Here is the call graph for this function: |
|
Open a file for reading. Prepares the Filing System to read a data file from the storage. Files are referred to by their numbers, not file names. This makes the system generic, not necessarily needing a complex file system such as FAT. The way to assign numbers to files is implementation dependent. Returns 0 when ok, error code otherwise.
Additionally, if it's called with 0 as the fileNumber and it happens to see an empty directory record, it registers a new file with name RECnnnnn.WAV starting from cluster fragment[0].start with file size from fragment[0].length Definition at line 598 of file filesys.c. References DirRecordUnion::Entry::Attr, Temp::c, currentFileName, dataBufPtr, dataStart, DiskBlock::dir, dirLevel, dirStack, diskSect, displayText, DirRecordUnion::entry, directoryStack::entry, fatSectorsPerCluster, fileSize, DirRecordUnion::Entry::FileSize, fragment, DirRecordUnion::Entry::FstClusHi, DirRecordUnion::Entry::FstClusLo, GetNextSector(), InitMMC(), Address::l, fragmentEntry::length, MAX_NUMBER_SUBDIRECTORIES, DirRecordUnion::Entry::Name, Public, ReadDiskSector(), rootStart, directoryStack::sector, sectorAddress, fragmentEntry::start, temp, and WriteDiskSector(). Referenced by main(), and WriteClusterChain().
Here is the call graph for this function: |
|
Search for next free sector. If freeSector is zero, a new file should be allocated. Definition at line 244 of file filesys.c. References dataStart, fatSectorsPerCluster, freeSector, GetFatEntry(), PConvertClusterToSector(), and PConvertSectorToCluster(). Referenced by Record().
Here is the call graph for this function: |
|
Write a cluster chain to FAT for a fragment. This takes its input from the fragment[] table. It currently has the ability to register only single fragment from fragment[0]. fragment[1].start should contain the next cluster number after this fragment or 0x0fffffff if this is the last fragment. This function currently also registers a FAT directory entry for the file to first free entry slot in the directory structure. If no free directory entries are available, it will behave unpredictably. This could happen in FAT32. OpenFile(0) is a special call to register a directory entry for fragment[0].
Definition at line 125 of file filesys.c. References Temp::c, diskSect, DiskBlock::Fat16Table, DiskBlock::Fat32Table, fatSectorsPerCluster, fatStart, fragment, IS_FAT_32, Address::l, fragmentEntry::length, OpenFile(), PConvertSectorToCluster(), ReadDiskSector(), sectorAddress, fragmentEntry::start, temp, and WriteDiskSector(). Referenced by Record().
Here is the call graph for this function: |
|
8 first characters of current file name
Definition at line 31 of file filesys.h. Referenced by main(), and OpenFile(). |
|
FAT Global sectors per cluster.
Definition at line 84 of file filesys.h. Referenced by BuildFragmentTable(), FatInitGlobals(), GetNextSector(), OpenFile(), PConvertClusterToSector(), PConvertSectorToCluster(), Record(), ScanForFreeSector(), and WriteClusterChain(). |
|
Size of current file to play.
Definition at line 17 of file filesys.h. Referenced by FGetChar(), GetAVIBlock(), OpenFile(), and PlayAvi(). |
|
Fragment Table.
|
|
Next free cluster number.
Definition at line 82 of file filesys.h. Referenced by InitFileSystem(), Record(), and ScanForFreeSector(). |