= GIET-VM / BDV Driver = [[PageOutline]] The [source:soft/giet_vm/giet_drivers/bdv_driver.c bdv_driver.c] and [source:soft/giet_vm/giet_drivers/bdv_driver.h bdv_driver.h] files define the BDV driver. This component is a single channel, block oriented, external mass storage peripheral, available in the SoCLib components library. This driver is called by the generic FAT handler when the USE_IOC_BDV flag is set in the hard_config.h file. The SEG_IOC_BASE address must be defined in the hard_config.h file. The _bdv_access() function is always blocking, and can be called in 2 modes: * In '''synchronous''' mode, these functions use a polling policy on the BDV STATUS register to detect transfer 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). * In '''descheduling''' mode, these functions use a descheduling plus IRQ policy: The ''_bdv_gtid'' global variable register the calling task global index, and the ISR executed when transfer completes restart the calling task. This mode is used, to handle the user system calls. The 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 addressable registers map, the operation codes, and the status values are defined [source:soft/giet_vm/giet_drivers/bdv_driver.h here]. == __Access Functions__ == === unsigned int '''_bdv_init'''() === This function cheks block size == 512, and desactivates the interrupts. Return 0 for success, > 0 if error === unsigned int '''_bdv_access'''( unsigned int use_irq , unsigned int to_mem , unsigned int lba , unsigned long long buffer , unsigned int count ) === This function transfer data from the block device to a memory buffer. * '''use_irq''' : Boolean => descheduling mode when non zero. * '''to_mem''' : Boolean => to memory transfer when non zero. * '''lba''' : first block index on the block device * '''buffer''' : physical base address of the memory buffer (word aligned) * '''count''' : number of blocks to be transfered. Returns 0 if success, > 0 if error. === void '''_bdv_isr'''( unsigned irq_type, unsigned irq_id, unsigned channel ) === This Interrupt Service Routine is only used in descheduling mode. It 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. * '''irq_type''' : HWI / PTI / WTI * '''irq-id''' : index returned by XCU * '''channel''' : unused (BDV device is single channel).