7 | | * The [source:soft/giet_vm/giet_fat32/fat_sync.c fat_sync.c] and [source:soft/giet_vm/giet_fat32/fat_sync.h fat_sync.h] files define the functions to access the block device with a polling policy on the peripheral status. |
8 | | * The [source:soft/giet_vm/giet_fat32/fat_irq.c fat_irq.c] and [source:soft/giet_vm/giet_fat32/fat_irq.h fat_irq.h] files define the functions to access the block device with a a descheduling / completion IRQ policy. |
9 | | * The [source:soft/giet_vm/giet_fat32/fat_common.c fat_common.c] and [source:soft/giet_vm/fat_common.h fat_common.h] files define the functions that are independant on the |
10 | | blockdevice access mode. |
| 6 | The [source:soft/giet_vm/giet_fat32/fat32.c fat32.c] and [source:soft/giet_vm/giet_fat32/fat32.h fat32.h] files define the data structures and functions that are used to access a FAT32 file system stored on a mass storage block device (such as BDV, HBA, SDC, or RDK peripherals). |
| 7 | |
| 8 | All the block device peripherals support a polling mode on the peripheral status register to detect the completion of a read or write access to the device, but some peripheral (BDV and HBA) support a descheduling mode for the calling task, with an interrupt to signal transfer completion. |
| 9 | |
| 10 | The GIET-VM handler supports the 4 peripheral types (only one type in a given platform), and most of the FAT access functions support a specific argument to activate the descheduling/IRQ mode when it is supported by the hardware. As a general rule the GIET-VM boot-loader uses only the |
| 11 | polling mode, and the GIET-VM kernel uses the descheduling + IRQ mode to handle the user system calls. |
16 | | == Common FAT32 access functions == |
| 17 | === 1) int '''_fat_init'''( unsigned int use_irq ) === |
| 18 | This function initialises the kernel ''_fat'' structure describing the FAT32 file system, including the set of open files, |
| 19 | and the FAT cache (only one single 512 bytes block at the moment). |
| 20 | The '''use_irq''' argument define the requested access mode (polling / descheduling), but both the GIET-VM boot-loader and the GIET-VM kernel use the polling mode for FAT initialisation. |
| 21 | Return 0 in case of success, exit if error. |
18 | | == Polling based FAT32 access functions == |
| 23 | === 2) int '''_fat_open'''( unsigned int use_irq , char* pathname , unsigned int create ) === |
| 24 | This function open a file, register it in the set of open files, and return a file descriptor index (fd_id) that must be used by all other access functions. |
| 25 | * '''use_irq''' : Boolean => request to use the descheduling mode when non zero. |
| 26 | * '''pathname''' : file absolute path name from the root directory. |
| 27 | * ''' create''' : Boolean => request to create the file if it does not exist (Not supported yet). |
| 28 | Returns fd_id if success, returns -1 if file not found). |
20 | | The following functions are intended to be used by the GIET_VM boot-loader, when the interrupts are not yet enabled. They use a polling strategy on the block device status to detect completion. |
21 | | |
22 | | === 1) int '''_fat_sync_open'''( ) === |
23 | | |
24 | | === 2) int '''_fat_sync_read'''( unsigned int fd_id , unsigned int buffer , unsigned int count , unsigned int offset ) === |
25 | | This function transfer an integer number of blocks from an open file on the block device to a memory buffer, after checking the arguments. |
26 | | If the number of requested sectors exceeds the file size, this number of sectors is reduced. |
| 30 | === 3) int '''_fat_read'''( unsigned int use_irq , unsigned int fd_id , void* buffer , unsigned int count , unsigned int offset ) === |
| 31 | This function transfer an integer number of blocks from an open file (identified by the fd_id) to a memory buffer, after checking the arguments. |
| 32 | If the number of requested sectors exceeds the file size, this number of loaded sectors is reduced. |
| 33 | * '''use_irq''' : Boolean => request to use the descheduling mode when non zero. |
33 | | === 3) int '''_fat_sync_ioc_access( unsigned int to_memory , unsigned int lba , unsigned int buf_vaddr , unsigned int count ) === |
34 | | This function computes the buffer physical address, and call the proper block device driver, as specified in the mapping. |
35 | | * '''to_memory''' : to memory transfer if non zero. |
| 40 | === 4) int '''_fat_write( unsigned int use_irq , unsigned int fd_id , void* buffer , unsigned int count , unsigned int offset ) === |
| 41 | This function transfer an integer number of blocks from a memory buffer to an open file (identified by the fd_id), after checking the arguments. It allocates new clusters on the block device if (offset + count) is larger than the current file size. |
| 42 | * '''use_irq''' : Boolean => request to use the descheduling mode when non zero. |
| 43 | * '''fd_id''' : file descriptor index |
| 44 | * '''buffer''' : memory buffer virtual base address |
| 45 | * '''count''' : number of blocks to transfer |
| 46 | * '''offset''' : number of blocks to skip in file |
| 47 | Returns number of sectors written if success, returns -1 if error. |
| 48 | |
| 49 | === 5) int '''_fat_fstat'''( unsigned int fd_id ) === |
| 50 | Return the file size (bytes) for a file identified by the fd_id. |
| 51 | |
| 52 | === 6) int '''fat_close'''( unsigned int fd_id ) === |
| 53 | This function removes a file identified by the fd_id from the set of open files. |
| 54 | |
| 55 | === 7) int '''_fat_ioc_access'''( unsigned int use_irq , unsigned int to_mem , unsigned int lba , unsigned int buf_vaddr , unsigned int count ) === |
| 56 | All the previous functions uses this function to access the block device. It computes the buffer physical address, and call the proper block device driver, as specified in the mapping. |
| 57 | * '''use_irq''' : Boolean => request to use the descheduling mode when non zero. |
| 58 | * '''to_mem''' : Boolean => to memory transfer when non zero. |
| 69 | === 1) int '''_fat_user_open'''( char* pathname , unsigned int flags ) === |
| 70 | |
| 71 | === 2) int '''_fat_user_read'''( unsigned int fd , void* buffer , unsigned int count , unsigned int offset ) === |
| 72 | |
| 73 | === 3) int '''_fat_user_write'''( unsigned int fd , void* buffer , unsigned int count , unsigned int offset ) === |
| 74 | |
| 75 | === 4) int '''_fat_user_lseek( unsigned int fd , unsigned int offset , unsigned int whence ) === |
| 76 | |