wiki:bdv_driver

Version 3 (modified by alain, 10 years ago) (diff)

--

GIET-VM / BDV Driver

The bdv_driver.c and bdv_driver.h files define the blockdevice driver. This component is a single channel, block oriented, external mass storage peripheral, available in the SoCLib components library.

The _bdv_read() and _bdv_write() functions are always blocking. They can be called in 3 modes:

  • 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).
  • 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.
  • 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.

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.

Finally, the memory buffer must fulfill the following conditions:

  • The buffer must be word aligned,
  • The buffer must be mapped in user space for an user access,
  • The buffer must be writable in case of (to_mem) access,
  • All physical pages occupied by the user buffer must be contiguous.

An error code is returned if these conditions are not verified.

The SEG_IOC_BASE address must be defined in the hard_config.h file.