RTEMS_INVALID_NUMBER in rtems_io_register_driver

Joel Sherrill joel.sherrill at oarcorp.com
Fri Jan 11 11:03:31 CST 2008



Gatti André wrote:
> We get the error RTEMS_INVALID_NUMBER when trying to register an IO 
> driver with the call to rtems_io_register_driver (in the function 
> initDriver()).
>
How did you configure the system?  You should have specified
CONFIGURE_MAXIMUM_DRIVERS to be greater than  the
number of statically specified drivers.


> The function initDriver() is call in the bspStart.c file.
>
> The condition that cause the problem inside rtems_io_register_driver() is
>     if ( major >= _IO_Number_of_drivers )
>         return RTEMS_INVALID_NUMBER;
>
>
>
> Example:
>
> 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,
> };
>
> void init(){
>     rtems_status_code r;
>     rtems_device_major_number registered_major;
>
>    if ((r = rtems_io_register_driver(0, &driver_table, 
> &registered_major)) == RTEMS_SUCCESSFUL) {
>         printk("Driver successfully registered, major: %d\n", 
> registered_major);
>     } else {
>         switch(r) {
>         case RTEMS_TOO_MANY:
>             printk("rtems_io_register_driver failed: RTEMS_TOO_MANY 
> (%d)\n", registered_major); break;
>         case RTEMS_INVALID_NUMBER:
>             printk("rtems_io_register_driver failed: 
> RTEMS_INVALID_NUMBER (%d)\n", registered_major); break;
>         case RTEMS_RESOURCE_IN_USE:
>             printk("rtems_io_register_driver failed: 
> RTEMS_RESOURCE_IN_USE (%d)\n", registered_major); break;
>         default:
>            printk("rtems_io_register_driver failed (%d)\n", 
> registered_major);
>         }
>     }
>     return;
> }
>
> 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_name("/dev/iodriver", registered_major, 0) == 
> RTEMS_SUCCESSFUL){
>        
>         return RTEMS_SUCCESSFUL;
>     }
>
>     return RTEMS_INTERNAL_ERROR;
> }
>
> 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 rtems-users mailing list