<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
</head>
<body bgcolor="#ffffff" text="#000000">
<font face="Verdana">We get the error RTEMS_INVALID_NUMBER when trying
to register an IO driver with the call to </font>rtems_io_register_driver<font
face="Verdana"> (in the function initDriver()).<br>
<br>
The function initDriver() is call in the bspStart.c file.<br>
<br>
The condition that cause the problem inside </font>rtems_io_register_driver()
<font face="Verdana">is <br>
</font>
<pre> if ( major >= _IO_Number_of_drivers )
return RTEMS_INVALID_NUMBER;</pre>
<br>
<br>
<font face="Verdana"><br>
E</font><font face="Verdana">xample:<br>
<br>
</font><font face="Verdana">static rtems_status_code
rtems_io_initialize(rtems_device_major_number major, </font><font
face="Verdana">rtems_device_minor_number minor, void * argument);<br>
</font><font face="Verdana">static rtems_status_code
rtems_io_open(rtems_device_major_number major, </font><font
face="Verdana">rtems_device_minor_number minor, void * argument);<br>
</font><font face="Verdana">static rtems_status_code
rtems_io_close(rtems_device_major_number major, </font><font
face="Verdana">rtems_device_minor_number minor, void * argument);<br>
</font><font face="Verdana">static rtems_status_code
rtems_io_read(rtems_device_major_number major, </font><font
face="Verdana">rtems_device_minor_number minor, void * argument);<br>
</font><font face="Verdana">static rtems_status_code
rtems_io_write(rtems_device_major_number major, </font><font
face="Verdana">rtems_device_minor_number minor, void * argument);<br>
</font><font face="Verdana">static rtems_status_code
rtems_io_control(rtems_device_major_number major, </font><font
face="Verdana">rtems_device_minor_number minor, void * argument);<br>
</font><font face="Verdana"><br>
</font><font face="Verdana">rtems_driver_address_table driver_table =</font><font
face="Verdana"> { <br>
</font><font face="Verdana"> rtems_io_initialize, <br>
</font><font face="Verdana">rtems_io_open, </font><font
face="Verdana"><br>
rtems_io_close,<br>
</font><font face="Verdana"> rtems_io_read,<br>
</font><font face="Verdana"> rtems_io_write,<br>
</font><font face="Verdana"> rtems_io_control,</font><br>
<font face="Verdana">};<br>
</font><font face="Verdana"><br>
</font><font face="Verdana">void init(){<br>
</font> rtems_status_code r;<br>
rtems_device_major_number registered_major;<br>
<br>
if ((r = rtems_io_register_driver(0, &driver_table,
®istered_major)) == RTEMS_SUCCESSFUL) {<br>
printk("Driver successfully registered, major: %d\n",
registered_major);<br>
} else {<br>
switch(r) {<br>
case RTEMS_TOO_MANY:<br>
printk("rtems_io_register_driver failed: RTEMS_TOO_MANY
(%d)\n", registered_major); break;<br>
case RTEMS_INVALID_NUMBER:<br>
printk("rtems_io_register_driver failed:
RTEMS_INVALID_NUMBER (%d)\n", registered_major); break;<br>
case RTEMS_RESOURCE_IN_USE:<br>
printk("rtems_io_register_driver failed:
RTEMS_RESOURCE_IN_USE (%d)\n", registered_major); break;<br>
default:<br>
printk("rtems_io_register_driver failed (%d)\n",
registered_major);<br>
}<br>
}<br>
return;<font face="Verdana"><br>
</font><font face="Verdana">}<br>
</font><br>
<font face="Verdana">rtems_status_code
rtems_io_initialize(rtems_device_major_number major, </font><font
face="Verdana">rtems_device_minor_number minor, void * argument){<br>
</font><font face="Verdana"> </font><font face="Verdana">rtems_device_major_number
</font><font face="Verdana">registered_major;<br>
<br>
</font><font face="Verdana"> if(</font><font face="Verdana">rtems_io_register_name("/dev/iodriver",
</font><font face="Verdana">registered_major</font><font face="Verdana">,
0)</font><font face="Verdana"></font><font face="Verdana"> == </font><font
face="Verdana">RTEMS_SUCCESSFUL){</font><font face="Verdana"><br>
</font><font face="Verdana"> </font><font face="Verdana"><br>
</font><font face="Verdana"> return RTEMS_SUCCESSFUL;</font><br>
<font face="Verdana"> }<br>
<br>
return RTEMS_INTERNAL_ERROR;</font><font face="Verdana"></font><br>
<font face="Verdana">}<br>
<br>
</font><font face="Verdana">rtems_status_code
rtems_io_open(rtems_device_major_number major, </font><font
face="Verdana">rtems_device_minor_number minor, void * argument){<br>
printk("Open.\n");<br>
return RTEMS_SUCCESSFUL;<br>
}<br>
</font><font face="Verdana"><br>
<br>
</font><font face="Verdana">rtems_status_code
rtems_io_close(rtems_device_major_number major, </font><font
face="Verdana">rtems_device_minor_number minor, void * argument){<br>
printk("Close.\n");<br>
return RTEMS_SUCCESSFUL;<br>
}<br>
</font><font face="Verdana"><br>
<br>
</font><font face="Verdana">rtems_status_code
rtems_io_read(rtems_device_major_number major, </font><font
face="Verdana">rtems_device_minor_number minor, void * argument){<br>
printk("Read.\n");<br>
return RTEMS_SUCCESSFUL;<br>
}<br>
</font><font face="Verdana"><br>
<br>
</font><font face="Verdana">rtems_status_code
rtems_io_write(rtems_device_major_number major, </font><font
face="Verdana">rtems_device_minor_number minor, void * argument){<br>
printk("Write.\n");<br>
return RTEMS_SUCCESSFUL;<br>
}<br>
</font><font face="Verdana"><br>
<br>
</font><font face="Verdana">rtems_status_code
rtems_io_control(rtems_device_major_number major, </font><font
face="Verdana">rtems_device_minor_number minor, void * argument){<br>
printk("Control.\n");<br>
return RTEMS_SUCCESSFUL;<br>
}<br>
</font><font face="Verdana"><br>
</font>
</body>
</html>