Changes between Version 1 and Version 2 of kernel_fat32


Ignore:
Timestamp:
Mar 23, 2015, 10:42:45 PM (10 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • kernel_fat32

    v1 v2  
    11= GIET-VM  / FAT32 Handler =
    22
    3 This section define the kernel data structure 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).
    43
    54[[PageOutline]]
    65
    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.
     6The [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
     8All 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
     10The 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
     11polling mode, and the GIET-VM kernel uses the descheduling + IRQ mode to handle the user system calls.
    1112
    1213All these functions are prefixed by ''_'' to remind that they can only be executed by a processor in kernel mode.
    1314
    14 The [source:soft/giet_vm/giet_kernel/sys_handler.c _syscall_vector] array contains the 64 kernel functions (syscal handlers) defined by the GIET-VM to handle system calls.
     15==  Kernel-level  FAT32 access functions  ==
    1516
    16 == Common FAT32 access functions  ==
     17=== 1) int '''_fat_init'''( unsigned int  use_irq ) ===
     18This function initialises the kernel ''_fat'' structure describing the FAT32 file system, including the set of open files,
     19and the FAT cache (only one single 512 bytes block at the moment).
     20The '''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.
     21Return 0 in case of success, exit if error.
    1722
    18 == Polling based FAT32 access functions  ==
     23=== 2) int '''_fat_open'''( unsigned int use_irq  ,  char* pathname  ,  unsigned int create ) ===
     24This 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).
     28Returns fd_id if success, returns -1 if file not found).
    1929
    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 ) ===
     31This function transfer an integer number of blocks from an open file (identified by the fd_id) to a memory buffer, after checking the arguments.
     32If 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.
    2734 * '''fd_id''' : file descriptor index
    2835 * '''buffer''' : memory buffer virtual base address
     
    3138Returns number of sectors transfered if success, returns -1 if error.
    3239
    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 ) ===
     41This 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
     47Returns number of sectors written if success, returns -1 if error.
     48
     49=== 5) int '''_fat_fstat'''( unsigned int fd_id ) ===
     50Return the file size (bytes) for a file identified by the fd_id.
     51
     52=== 6) int '''fat_close'''( unsigned int  fd_id ) ===
     53This 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 ) ===
     56All 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.
    3659 * '''lba''' : first block index on the block device.
    3760 * '''buf_vaddr''' : memory buffer virtual base address
     
    3962Returns 0 if success, returns -1 if error.
    4063
    41 == Interrupt based FAT32 access functions  ==
     64== User level FAT32 access functions  ==
    4265
     66These functions are used by the kernel to handle the user system calls.
     67They should be modified to respect the UNIX specification.
    4368
     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