RTEMS_INVALID_NUMBER in rtems_io_register_driver

Joel Sherrill joel.sherrill at oarcorp.com
Mon Jan 14 19:01:19 UTC 2008


Gatti André wrote:
> If I have to add it to the static driver table I guess I have to edit
> the confdefs.h file inside the RTEMS tree. But because of confdefs is
> one for all the BSPs, in that case all the BSPs are modified. Is that
> correct? Is there a way to only modified the BSP involved?
>
>   
First.. what driver are you trying to add?  What functionality
is it supposed to provide?  Is it really required in all applications
that use your BSP?

Second.. I added CONFIGURE_APPLICATION_EXTRA_DRIVERS
in 4.8 and the CVS head for a simple situation.  You can follow
that in "confdefs.h" and add a "BSP_PREREQUISITE_DRIVERS"
along the same pattern -- but as the first thing in the generated
table in confdefs.  Then bsp.h can define that and it will
be in just those BSPs -- but automatically.

I would have posted a suggested patch but am teaching a class
this week.   If you get a patch, post it.  It is a generally desirable
feature.

--joel
> Thanks,
>
>
> Joel Sherrill escribió:
>   
>> Gatti André wrote:
>>     
>>> Actually, the initDriver() call is inside bsp_start(), so, as you
>>> said, RTEMS is not initialized. If this is the wrong place, where
>>> should this function call would be?
>>>
>>>       
>> The point of dynamic registration is to do it after the system is
>> fully initialized
>> and to do it from a task.
>>
>> In this case, I would either add it to the static driver table or add
>> it from
>> the first task.  Or you could add it in the BSP in either the pre-driver
>> or post-driver hook.
>>     
>>> I also tried declaring CONFIGURE_MAXIMUM_DRIVERS with a high number
>>> in my application, but with the same result (RTEMS_INVALID_NUMBER).
>>> But is this necessary if we are using dynamic registration
>>> (rtems_io_register_driver)?
>>>
>>>       
>> No it is because RTEMS wasn't initialized yet and this had no effect yet.
>> The variable in question was zeroed out by the start.S zeroBSS loop and
>> hasn't been set to the configured number yet.
>>     
>>> Thanks,
>>>
>>>
>>>
>>> Joel Sherrill escribió:
>>>       
>>>> 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()).
>>>>>
>>>>>           
>>>> Has RTEMS even been initialized yet?   Are you in the function
>>>> bsp_start?  If so, then it hasn't.
>>>>
>>>> _IO_Number_of_drivers could be 0 if RTEMS isn't initialized.
>>>>
>>>>         
>>>>> 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 users mailing list