Changes between Version 8 and Version 9 of bdv_driver


Ignore:
Timestamp:
Mar 23, 2015, 11:10:27 PM (9 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • bdv_driver

    v8 v9  
    77This component is a single channel, block oriented, external mass storage peripheral, available in the SoCLib components library.
    88
    9 This driver is called by the generic IOC driver when the USE_IOC_BDV flag is set in the hard_config.h file.
     9This driver is called by the generic FAT handler when the USE_IOC_BDV flag is set in the hard_config.h file.
    1010
    1111The SEG_IOC_BASE address must be defined in the hard_config.h file.
    1212
    13 The _bdv_read() and _bdv_write() functions are always blocking. They can be called in 3 modes:
    14  * In '''BOOT''' mode, these functions use a polling policy on the BDV STATUS register to detect transfer completion, as interrupts are not activated. This mode is used by the boot code to load the map.bin file into memory (before MMU activation), or to load the .elf files (after MMU activation).
    15  * In '''KERNEL''' mode, these functions use a descheduling strategy: The ISR executed when transfer completes should restart the calling task. There is no checking of user access right to the memory buffer. This mode must be used, for an ''open'' system call.
    16  * In '''USER''' mode, these functions use a descheduling strategy: The ISR executed when transfer completes should restart the calling task. The user access right to the memory buffer must be checked. This mode must be used for a ''read'' or ''write'' system call.
     13The _bdv_read() and _bdv_write() functions are always blocking. They can be called in 2 modes:
     14 * In '''synchronous''' mode, these functions use a polling policy on the BDV STATUS register to detect transfer completion, as interrupts are not activated. This mode is used by the boot code to load the map.bin file into memory (before MMU activation), or to load the .elf files (after MMU activation).
     15 * In '''descheduling''' mode, these functions use a descheduling plus IRQ strategy: The ISR executed when transfer completes should restart the calling task. This mode must be used, to handle the user system calls. The ''_bdv_gtid'' global variable register the calling task global index.
    1716
    18 The BDV component is single channel, but can be used by several programs running in parallel, as the _bdv_lock variable guaranties exclusive access to the device.  The _bdv_read() and _bdv_write() functions use atomic LL/SC to get the lock.
    19 
    20 Finally, the memory buffer must fulfill the following conditions:
    21  * The buffer must be word aligned,
    22  * The buffer must be mapped in user space for an user access,
    23  * The buffer must be writable in case of (to_mem) access,
    24  * All physical pages occupied by the user buffer must be contiguous.
    25 An error code is returned if these conditions are not verified.
     17The BDV component is single channel, but can be used by several programs running in parallel, as the ''_bdv_lock'' global variable guaranties exclusive access to the device.  The _bdv_read() and _bdv_write() functions use atomic LL/SC to get the lock.
    2618
    2719The addressable registers map, the operation codes, and the status values are defined [source:soft/giet_vm/giet_drivers/bdv_driver.h here].
    28 
    2920
    3021 
     
    3324Return 0 for success, > 0 if error
    3425
    35  === unsigned int '''_bdv_read'''(  unsigned int mode,  unsigned int lba, unsigned long long buffer,  unsigned int count ) ===
     26 === unsigned int '''_bdv_access'''(  unsigned int use_irq  ,  unsigned int to_mem  ,  unsigned int lba  ,  unsigned long long buffer  ,  unsigned int count ) ===
    3627This function transfer data from the block device to a memory buffer.
    37  * mode     : BOOT / KERNEL / USER
    38  * lba       : first block index on the block device
    39  * buffer   : physical base address of the memory buffer (word aligned)
    40  * count    : number of blocks to be transfered.
     28 * '''use_irq''' : Boolean => descheduling mode when non zero.
     29 * '''to_mem''' : Boolean => to memory transfer when non zero.
     30 * '''lba''' : first block index on the block device
     31 * '''buffer''' : physical base address of the memory buffer (word aligned)
     32 * '''count''' : number of blocks to be transfered.
    4133Returns 0 if success, > 0 if error.
    4234
    43  === unsigned int '''_bdv_write'''( unsigned int mode,  unsigned int lba,  unsigned long long buffer,  unsigned int count ) ===
    44 This function transfer data from a memory buffer to the block device.
    45  * mode     : BOOT / KERNEL / USER
    46  * lba       : first block index on the block device
    47  * buffer   : physical base address of the memory buffer (word aligned)
    48  * count    : number of blocks to be transfered.
    49 Returns 0 if success, > 0 if error.
    50 
    51  === unsigned int '''_bdv_get_status'''() ===
    52 This function returns device status. Status values are defined in  the [source:soft/giet_vm/giet_drivers/bdv_driver.h bdv_driver.h] file.
    53 
    54  ===  unsigned int '''_bdv_get_block_size'''() ===
    55 This function returns the block size (bytes).
    56 
    5735 === void '''_bdv_isr'''( unsigned irq_type,  unsigned irq_id,  unsigned channel ) ===
    58 This Interrupt Service Routine save the status, acknowledge the IRQ, and activates the task waiting on IO transfer. It can be an HWI or a SWI.
     36This Interrupt Service Routine save the status register value in the ''_bdv_status'' global variable, acknowledge the IRQ, and activates the task waiting on IO transfer. It can be an HWI or a SWI.
    5937 * irq_type : HWI / PTI / WTI
    6038 * irq-id     : index returned by ICU/XCU