Configuring the file system





The file <FileSys>\FSconfig.fth contains the default configuration for the file system. To set your own configuration, copy <FileSys>\FSconfig.fth and rename it. You can put it where you like, so placing it in your main application source folder is sensible. Then compile your file before FileSys.bld, which will ignore the default file if it finds a previously loaded configuration.




Diagnostics

1 equ FSdiags?  \ -- n
Set non-zero to compile diagnostic and test code.




Sector/Block size

The file system operates on fixed-size blocks on the disk. The size of each block is normally 512 bytes. It can be changed as required. If the block size is changed, you will need to redefine the compiler macros in this section. These macros use shift and logical operations on the assumption that these are faster than division operations. You can change these macros to suit your CPU architecture, or replace them by words if the block size is not a power of two.

#512 equ BLOCK_SIZE     \ -- u
Block size in bytes on disk.

: BSdiv         \ size -- #blocks
Given a length, return the number of complete blocks required. Equivalent to:

  BLOCK_SIZE /

: BSmod         \ size -- rem
Given a length, return the number of bytes in the last block. Equivalent to:

  BLOCK_SIZE mod

: BS/mod        \ size -- rem #blocks
Given a length, return the number of bytes in the last block and the number of complete blocks. Equivalent to:

  BLOCK_SIZE /mod

: BSblks        \ size -- #blocks
Given a size in bytes, return the number of blocks required to contain them. Unlike BSdiv, this allows for a partly used last block.




Disk information

These equates affect the proportion of the disk used for management and how much RAM is required.




Filing system

BLOCK_SIZE equ MIN_FILE_SIZE    \ -- u
Defines how much space is initially allocated when a file is created.

#32 equ MAX_FILES       \ -- u
Maximum number of files on the drive.

3 equ PATH-LIMIT        \ -- u
Maximum nesting of directory levels.

char / equ DIR-DELIMIT  \ -- char
Defines the character used as a directory name delimiter.

char . equ THIS-DIR     \ -- char
Defines the character used to mean "this directory".

#11 equ PATH-LENGTH     \ -- u
Maximum length of a file name.




Disk Cache

The disk can operate with a choice of caching modes, which provide trade-offs between disk performance, RAM usage, determinism and interrupt latency.

0 equ NoDiskCache       \ -- 0
No Disk Cache. All disk activity is to the drive. Lowest RAM usage and lowest performance. This may be the best solution for systems with limited RAM and drives with their own cache.

1 equ CloseDiskFlush    \ -- 1
The disk cache is only written back on demand by the word SYNC-VOL, or when a file is closed, or when a directory is created.

2 equ TaskDiskFlush     \ -- 3
A separate task DiskTask executes SYNC-VOL when required. When data is written out depends on SyncMs and SyncOnIdle below.

CloseDiskFlush equ DiskCacheMode        \ -- n
Define the required disk cache mode.

#4 equ #CACHE_BLOCKS    \ -- n
Number of disk blocks that are cached in RAM.

#250 equ SyncMs \ -- ms
Time in milliseconds after a write after which the disk cache will be flushed.

0 equ SyncOnIdle        \ -- n
If non-zero SYNC-VOL is executed SyncMs milliseconds after the last disk write, otherwise it is executed SyncMs milliseconds after the first disk write.

#15000 equ VOL_TIMEOUT  \ -- ms
Number of milliseconds after a write before the cache is flushed.




Disk information block

The file system was originally written to use CompactFlash cards or ATAPI drives. These return a disk identification block in little endian format. See Specs\cfspec1_4.pdf Table 40 for the gory details. This format is retained for all hardware, regardless of host CPU and attached hardware. At present, the only required data is the number of sectors on the disk.

#57 2* equ ID.#SECTORS  \ -- offset
Offset of the 32 bit number of sectors on the disk.




End of configuration

This must be the last section of the configuration file.

1 equ FSconfigured?     \ -- n
Must be defined non-zero after all configuration information has been defined.