RTEMS_INVALID_NUMBER in rtems_io_register_driver
Gatti André
agatti at invap.com.ar
Mon Jan 14 12:39:48 UTC 2008
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?
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,
>>>> ®istered_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