Further explanation of writing a FileCore based filing system.
i) Single data transfer in foreground.
You, the filing system, will be given:
r2 = disc address
r3 = start of data in RAM
r4 = length of data
The start may be non-word aligned and the length may be not a whole number of sectors big.
You should transfer the data to/from the disc in foreground, returning to FileCore once the transfer has finished. Even if you discover an error before starting the transfer you should call FileCore's FIQ release code (if you needed FIQs).
ii) Scatter list data transfer in foreground.
You will be given:
r2 = disc address
r3 = pointer to scatter list
r4 = length of transfer
You can assume the scatter list is word-aligned and has entries which cover the full length of the transfer and are each a non-zero whole number of sectors long. This sort of scatter list doesn't wrap in the same way as the background variety. Once again if you discover an error before starting the transfer you should call FileCore's FIQ release code (if you needed FIQs). It may be possible that a non-whole sector transfer is requested - you should cope with this, but the boundaries between scatter-list entries will be on sector boundaries. The scatter list should be updated as each sector gets transfered successfully - this means the caller can retry with the scatter list in the state as returned by the filing system.
iii) Data transfer in background.
You will be given:
r2 = disc address
r3 = pointer to scatter list
r4 = length of transfer
The length of transfer will be the length that should be transfered before returning to FileCore. Having returned to FileCore your data transfer routine should still be actively transfering data. It should stop when it reaches a non-wrapping zero-length address-length pair. In the background it should perform retries as appropriate and, once the operation has finished (by completing the request or getting an error), the process error and process status should be filled out as follows:
Type of finish Filling
complete process status = 0 process error can have any value error process error = error as described P.1047 PRM process status = pointer to failed address,length pair
This short piece of code will find the beginning of a process block. On entry r1 points to any address,length pair in the process block
Loop LDR r2, [r1, #8]! TEQ r2, #0 BPL Loop ADD r1, r1, r2
On exit r1 points to the start of the process block such that this will work:
STMDB r1, {error, status}
Note the DB means error and status are at [r1, #-8] and [r1, #-4] respectively, and that error and status are aliases for two registers where error is a lower numbered register than status.
The background call after routine returned by FileCore should be called even if an error was detected before the operation was started. Also the FIQ release routine should be called as for the other ways of transfering data.