9 | | This driver is called by the generic IOC driver when the USE_IOC_HBA flag is set in the hard_config.h file. |
| 9 | The '''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 | |
| 11 | This 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 | |
| 15 | As 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. |
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 ) === |
| 29 | This 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 |
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 ) === |
| 38 | This 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). |