a question about SD card rtems_blkdev_generic functions

André Marques andre.lousa.marques at gmail.com
Wed Aug 19 14:22:50 UTC 2015

Hello Chan,

On 19-08-2015 13:46, Chan Kim wrote:
> Hello, rtems folks,
> I managed to write an SD card driver on our platform (it was a month ago but I was doing other things lately) and am
> tryng to test file read and write. File read is done anyway and I can print the file contents.
> Couple of days ago I saw block write starting initiated by file write operation, but somehow I don't know how to make block write start.
> somewhere in the driver,  there are lines below.
> static const rtems_driver_address_table sd_card_disk_ops = {
>      .initialization_entry = sd_card_disk_init,
>      .open_entry = rtems_blkdev_generic_open,
>      .close_entry = rtems_blkdev_generic_close,
>      .read_entry = rtems_blkdev_generic_read,
>      .write_entry = rtems_blkdev_generic_write,
>      .control_entry = rtems_blkdev_generic_ioctl
> };
> sc = rtems_io_register_driver( 0, &sd_card_disk_ops, &major);
> but strangely, even when I read a file successfully(using fopen, fgets) and print it, only rtems_blkdev_generic_open and rtems_blkdev_generic_close function are called and rtems_blkdev_generic_read/write.functions are not called.
> Is this normal? Can someone direct me to a good document on how this works or explain it to me?
> Thanks!
> Chan

sd_card_disk_init should be creating the disk in the system through 
rtems_disk_create_phys, which takes an IO control handler for the block 
operations. This controller is the one that should be doing your reads 
and writes.

 From [1] :

These primitives (except initialize) can be implemented in a generic 
fashion based upon the supplied block device driver IO control handler. 
*Every block device driver should provide an initialize entry point, 
which registers the appropriate IO control handler.*

[1] - 

--André Marques

> _______________________________________________
> users mailing list
> users at rtems.org
> http://lists.rtems.org/mailman/listinfo/users

More information about the users mailing list