Changes between Version 3 and Version 4 of hba_driver


Ignore:
Timestamp:
Mar 25, 2015, 7:14:56 PM (10 years ago)
Author:
alain
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • hba_driver

    v3 v4  
    55The [source:soft/giet_vm/giet_drivers/hba_driver.c hba_driver.c] and [source:soft/giet_vm/giet_drivers/hba_driver.h hba_driver.h] files define the HBA driver.
    66
    7 The ''vci_multi_ahci'' component is a multi-channels, block oriented, external mass storage controller respecting the AHCI standard.
     7The ''vci_multi_ahci'' component is a multi-channels, block oriented, external mass storage controller respecting the AHCI standard. Each channel define an independant physical disk, but this driver supports only one channel, because the GIET-VM uses only one physical disk.
    88
    9 This driver is called by the generic IOC driver when the USE_IOC_HBA flag is set in the hard_config.h file.
     9The '''Command List''' is a software FIFO that can contain up to 32 independant commands, posted by different user tasks. These independant transfers are handled by the HBA device in the same order as they have been written in the command list. There is no global lock protecting the the HBA device, but the command list being a shared structure, the driver uses an atomic_increment() to get a slot in the command list, and increment the write pointer.
     10
     11This driver implements two operating mode:
     12 * In '''synchronous mode''', the calling task uses a polling strategy on the HBA_PXCI register to detect the command completion (busy waiting). It does not use interrupt. 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).
     13 * In '''descheduling mode''', the calling task is descheduled, and the calling task global index is saved in the ''_hba_gtid[32] array, indexed by the command index. The task must be reactivated  when the command is completed. This mode is used, to handle the user system calls.
     14
     15As several user tasks can concurrently register commands in the command list, and there is only one HBA interrupt per channel, this interrupt is not linked to a specific calling task: in descheduling mode, the HBA IRQ is a "global" IRQ that is statically routed to processor P[x_io,y_io,0] in cluster_io.  The associated global HBA_ISR send a WAKUP WTI to all tasks that have a completed command. This HBA_ISR uses a read pointer on the Command List to identify the expected command completion. The incrementation of this read pointer does not require atomic_increment as there is no concurrent access on this pointer.
    1016
    1117The SEG_IOC_BASE address must be defined in the hard_config.h file.
     
    1319The addressable registers map is defined [source:soft/giet_vm/giet_drivers/hba_driver.h here].
    1420
     21 == __HBA access functions__ ==
    1522
     23 === unsigned int '''_hba_init'' ( ) ===
     24This function checks the block size and desactivates interrupts. It initializes
     25the HBA hardware registers, and the Command List.
     26Return 0 for success, > 0 if error.
    1627
    17  === unsigned int '''_hba_init'' ( unsigned int channel ) ===
    18 This function initializes for a given channel
    19  *  the HBA hardware registers,
    20  *  the command list pointer,
    21  *  the command lists physical addresse,
    22  *  the command tables physical addresses array,
    23 
    24  === unsigned int '''_hba_write'''( unsigned int channel,   unsigned int mode,  unsigned int lba,  unsigned long long paddr,  unsigned int count ) ===   
    25 This function register a write command in Command List and Command Table for a single physical buffer, and updates the HBA_PXCI register.
    26  * channel : channel index
    27  * mode :   BOOT / KERNEL / USER
    28  * lba :  logic bloc address on device
    29  * paddr : memory buffer physical base address
    30  * count : number of blocs
     28 === unsigned int '''_hba_access'''( unsigned int use_irq  ,  unsigned int to_mem  ,  unsigned int lba ,  unsigned long long paddr,  unsigned int count ) ===   
     29This function register a command in the Command List (and associated Command Table) for a single physical buffer, and updates the HBA_PXCI register.
     30 * '''use_irq''': Boolean => request to use the descheduling mode if non zero
     31 * '''to_mem''' :  Boolean => to memory transfer if non zero
     32 * '''lba''' :  logic bloc address on device
     33 * '''paddr''' : memory buffer physical base address
     34 * '''count''' : number of blocs
    3135Returns 0 if success, > 0 if error.
    3236
    33  === unsigned int '''_hba_read'''( unsigned int channel,   unsigned int mode,  unsigned int lba,  unsigned long long paddr,  unsigned int count ) ===   
    34 This function register a read command in Command List and Command Table for a single physical buffer, and updates the HBA_PXCI register.
    35  * channel : channel index
    36  * mode :   BOOT / KERNEL / USER
    37  * lba :  logic bloc address on device
    38  * paddr : memory buffer physical base address
    39  * count : number of blocs
    40 Returns 0 if success, > 0 if error.
     37=== void '''_hba_isr'''( unsigned int irq_type , unsigned int irq_id , unsigned int channel ) ===
     38This Interrupt Service routine is only used in the descheduling mode. It analyses the HBA_PXCI register, and for all completed commands, it saves the status value in the ''_hba_status[32]'' array, indexed by the command index, and activates the task waiting completion of this command.
     39 * '''irq_type''' : HWI / PTI / WTI
     40 * '''irq-id'''     : index returned by XCU
     41 * '''channel'''  : unused (only one HBA channel is supported).
    4142
    42  === unsigned int '''_hba_get_block_size''' () ===
    43 This function returns the block_size of HBA controller
    44 
    45  === unsigned int '''_hba_get_status'''( unsigned int   channel ) ===
    46 This function returns the content of the HBA_PXIS register for a given channel,  and reset this register to acknoledge IRQ.
    47 Return 0 if success, > 0 if error
    48