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. |
| 13 | The _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. |
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. |
| 17 | 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 _bdv_read() and _bdv_write() functions use atomic LL/SC to get the lock. |
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. |
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 | | |