Register an IO driver

Joel Sherrill joel.sherrill at oarcorp.com
Fri Jan 4 16:50:23 UTC 2008


Gatti André wrote:
> We are making a BSP and want to register an IO driver but we are not 
> sure where tu put the call to the function rtems_io_register_driver. 
> We think that the correct place should be inside rtems_io_initialize, 
> but the problem is that the call to rtems_io_initialize already 
> includes the major and minor number as parameters.
>
> rtems_status_code rtems_io_initialize(rtems_device_major_number major, 
> rtems_device_minor_number minor, void * argument);
>
> So should be a place before rtems_io_initialize, it would be great if 
> someone can tell us how to do it.
>
It is called automatically during RTEMS initialization.
> Apart from that when we call the function rtems_io_register_driver(0, 
> &driver_table, &registered_major) we get the error RTEMS_TOO_MANY. 
> This is because there is not enought space in the device driver table, 
> but we don't want to modified the constant CONFIGURE_MAXIMUM_DRIVERS 
> in confdefs.h, is it automatically incremented?
>
In 4.7 and older, you had to do your own driver table with the same name.
confdefs.h should pick up the name and size automatically.

4.8 and newer have CONFIGURE_APPLICATION_EXTRA_DRIVERS which lets you
add to the table generated by confdefs.h easily.

CONFIGURE_NUMBER_OF_DRIVERS is the number of statically configured
drivers. 

CONFIGURE_MAXIMUM_DRIVERS is the maximum number of driver and
includes those dynamically registered.
>
> Please, can anyone tell us which is wrong here:
>
> Example of our driver:
>
>
> static rtems_status_code rtems_io_initialize(rtems_device_major_number 
> major, rtems_device_minor_number minor, void * argument);
> static rtems_status_code rtems_io_open(rtems_device_major_number 
> major, rtems_device_minor_number minor, void * argument);
> static rtems_status_code rtems_io_close(rtems_device_major_number 
> major, rtems_device_minor_number minor, void * argument);
> static rtems_status_code rtems_io_read(rtems_device_major_number 
> major, rtems_device_minor_number minor, void * argument);
> static rtems_status_code rtems_io_write(rtems_device_major_number 
> major, rtems_device_minor_number minor, void * argument);
> static rtems_status_code rtems_io_control(rtems_device_major_number 
> major, rtems_device_minor_number minor, void * argument);
>
> rtems_driver_address_table driver_table = {
>     rtems_io_initialize,
>     rtems_io_open,
>     rtems_io_close,
>     rtems_io_read,
>     rtems_io_write,
>     rtems_io_control,
> };
>
> rtems_status_code rtems_io_initialize(rtems_device_major_number major, 
> rtems_device_minor_number minor, void * argument){
>     rtems_device_major_number registered_major;
>
>     if(rtems_io_register_driver(0, driver_table, &registered_major) == 
> RTEMS_SUCCESSFUL){
>
>         rtems_io_register_name("iodriver", registered_major, 0);
>
>         return RTEMS_SUCCESSFUL;
>     }
>
>     return RTEMS_INVALID_NUMBER;
> }
>
> rtems_status_code rtems_io_open(rtems_device_major_number major, 
> rtems_device_minor_number minor, void * argument){
>     printk("Open.\n");
>     return RTEMS_SUCCESSFUL;
> }
>
>
> rtems_status_code rtems_io_close(rtems_device_major_number major, 
> rtems_device_minor_number minor, void * argument){
>     printk("Close.\n");
>     return RTEMS_SUCCESSFUL;
> }
>
>
> rtems_status_code rtems_io_read(rtems_device_major_number major, 
> rtems_device_minor_number minor, void * argument){
>     printk("Read.\n");
>     return RTEMS_SUCCESSFUL;
> }
>
>
> rtems_status_code rtems_io_write(rtems_device_major_number major, 
> rtems_device_minor_number minor, void * argument){
>     printk("Write.\n");
>     return RTEMS_SUCCESSFUL;
> }
>
>
> rtems_status_code rtems_io_control(rtems_device_major_number major, 
> rtems_device_minor_number minor, void * argument){
>     printk("Control.\n");
>     return RTEMS_SUCCESSFUL;
> }
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.com
> http://rtems.rtems.org/mailman/listinfo/rtems-users
>   




More information about the users mailing list