58 | | == 4) Block Device Drivers == |
59 | | |
60 | | To support various block device peripheral, this FAT32 implementation defines a generic _fat_ioc_access() function to access the physical block device. This function transfer one or several blocks between the block device and the file_cache by calling the relevant driver. |
61 | | |
62 | | === int '''_fat_ioc_access'''( unsigned int use_irq , unsigned int to_mem , unsigned int lba , unsigned int buf_vaddr , unsigned int count ) === |
63 | | * '''use_irq''' : boolean (use descheduling mode if supported by the IOC driver) |
64 | | * '''to_mem''' : boolean (from block device to memory if non zero) |
65 | | * '''lba''' : logical block address on block device |
66 | | * '''buf_vaddr''' : memory buffer virtual address |
67 | | * ''' count''' : number of blocks to be transferred |
68 | | |
69 | | == 5) Access Functions == |
| 60 | == 4) Access Functions == |
| 92 | === int '''_fat_file_info( unsigned int fd_id , unsigned int* size , unsigned int* offset ) === |
| 93 | This function implements the giet_fat_file_info() system call. |
| 94 | It returns the size and the current offset value for a file identified by the "fd_id" argument. |
| 95 | * '''fd_id''' : file descriptor index |
| 96 | * '''size''' : pointer on the size (return buffer) |
| 97 | * '''offset''' : pointer on the offset (return buffer) |
| 98 | It returns 0 if success / It returns -1 if failure. |
| 100 | === int '''_fat_read'''( unsigned int fd_id , void* buffer , unsigned int count ) === |
| 101 | The following function implements the "giet_fat_read()" system call, that has the same semantic as the UNIX "read()" function. |
| 102 | It access the File-Cache associated to the file identified by the file descriptor, and transfers "count" bytes from the cache to the user buffer, starting from the current file offset. |
| 103 | In case of miss in the File_Cache, it loads all involved clusters into the cache. |
| 104 | * '''fd_id''' : file descriptor index |
| 105 | * '''buffer''' : pointer on the memory buffer |
| 106 | * '''count''' : number of bytes |
| 107 | It returns the number of bytes actually transfered if success / It returns 0 if (offset + count > file_size) / It returns -1 if failure. |
| 108 | |
| 109 | === int '''_fat_write'''( unsigned int fd_id , void* buffer , unsigned int count ) === |
| 110 | The following function implements the "giet_fat_write()" system call, that has the same semantic as the UNIX "write()" function. |
| 111 | It access the File-Cache associated to the file identified by the file descriptor, and transfers count bytes from the user buffer, |
| 112 | to the cache, starting from the current file offset. It loads all involved clusters into cache if required. If (offset + count) is larger than the current file size, it increases the file size. It allocates new clusters if required, and updates the Fat-Cache and the FAT region on block device. As it implements a Write-Back policy, the DATA region on block device is not updated, but the modified clusters are marked dirty. |
| 113 | * '''fd_id''' : file descriptor index |
| 114 | * '''buffer''' : pointer on the memory buffer |
| 115 | * '''count''' : number of bytes |
| 116 | It returns the number of bytes actually transfered if success / It returns -1 if failure. |
| 117 | |
| 118 | === int '''_fat_ioc_access'''( unsigned int use_irq , unsigned int to_mem , unsigned int lba , unsigned int buf_vaddr , unsigned int count ) === |
| 119 | This function transfer one or several blocks between the block device and a memory buffer by calling the relevant driver. |
| 120 | * '''use_irq''' : boolean (use descheduling mode if supported by the IOC driver) |
| 121 | * '''to_mem''' : boolean (from block device to memory if non zero) |
| 122 | * '''lba''' : logical block address on block device |
| 123 | * '''buf_vaddr''' : memory buffer virtual address |
| 124 | * ''' count''' : number of blocks to be transferred |
| 125 | It returns 0 if success / It returns -1 if failure. |
| 126 | |