summaryrefslogtreecommitdiffstats
path: root/c
diff options
context:
space:
mode:
authorSebastian Huber <sebastian.huber@embedded-brains.de>2011-02-28 15:11:48 +0000
committerSebastian Huber <sebastian.huber@embedded-brains.de>2011-02-28 15:11:48 +0000
commit8f8e9038bdb2db3ffe07c646c92ab9cef5fd5c2e (patch)
tree2526bb7d6eb109bc6fb22497742705d8f4002545 /c
parentAdd freebsd8.2 (diff)
downloadrtems-8f8e9038bdb2db3ffe07c646c92ab9cef5fd5c2e.tar.bz2
2011-02-28 Sebastian Huber <sebastian.huber@embedded-brains.de>
* console.c: Register also normal device file of the console device. Call initialization before the device file registration.
Diffstat (limited to 'c')
-rw-r--r--c/src/lib/libbsp/shared/ChangeLog5
-rw-r--r--c/src/lib/libbsp/shared/console.c84
2 files changed, 31 insertions, 58 deletions
diff --git a/c/src/lib/libbsp/shared/ChangeLog b/c/src/lib/libbsp/shared/ChangeLog
index 92a8f69de5..c76d55ca99 100644
--- a/c/src/lib/libbsp/shared/ChangeLog
+++ b/c/src/lib/libbsp/shared/ChangeLog
@@ -1,3 +1,8 @@
+2011-02-28 Sebastian Huber <sebastian.huber@embedded-brains.de>
+
+ * console.c: Register also normal device file of the console device.
+ Call initialization before the device file registration.
+
2011-02-09 Ralf Corsépius <ralf.corsepius@rtems.org>
* timerstub.c: Include <rtems/btimer.h>.
diff --git a/c/src/lib/libbsp/shared/console.c b/c/src/lib/libbsp/shared/console.c
index 31cc1704da..94b627daa6 100644
--- a/c/src/lib/libbsp/shared/console.c
+++ b/c/src/lib/libbsp/shared/console.c
@@ -16,6 +16,7 @@
#include <bsp.h>
#include <rtems/libio.h>
+#include <rtems/console.h>
#include <stdlib.h>
#include <assert.h>
#include <termios.h>
@@ -216,77 +217,44 @@ rtems_device_driver console_control(
rtems_device_driver console_initialize(
rtems_device_major_number major,
- rtems_device_minor_number minor_arg,
+ rtems_device_minor_number minor,
void *arg
)
{
- rtems_status_code status;
- rtems_device_minor_number minor;
-
- /*
- * initialize the termio interface.
- */
+ rtems_status_code sc = RTEMS_SUCCESSFUL;
+ bool first = true;
rtems_termios_initialize();
- for (minor=0; minor < Console_Port_Count ; minor++) {
- /*
- * First perform the configuration dependent probe, then the
- * device dependent probe
- */
-
- if ((!Console_Port_Tbl[minor].deviceProbe ||
- Console_Port_Tbl[minor].deviceProbe(minor)) &&
- Console_Port_Tbl[minor].pDeviceFns->deviceProbe(minor)) {
- /*
- * Use this device for the console
- */
- break;
+ for (minor = 0; minor < Console_Port_Count; ++minor) {
+ const console_tbl *device = &Console_Port_Tbl [minor];
+
+ if (
+ (device->deviceProbe == NULL || device->deviceProbe(minor))
+ && device->pDeviceFns->deviceProbe(minor)
+ ) {
+ device->pDeviceFns->deviceInitialize(minor);
+ if (first) {
+ first = false;
+ Console_Port_Minor = minor;
+ sc = rtems_io_register_name(CONSOLE_DEVICE_NAME, major, minor);
+ if (sc != RTEMS_SUCCESSFUL) {
+ rtems_fatal_error_occurred(sc);
+ }
+ }
+ sc = rtems_io_register_name(device->sDeviceName, major, minor);
+ if (sc != RTEMS_SUCCESSFUL) {
+ rtems_fatal_error_occurred(sc);
+ }
}
}
- if ( minor == Console_Port_Count ) {
+
+ if (first) {
/*
* Failed to find a working device
*/
rtems_fatal_error_occurred(RTEMS_IO_ERROR);
}
- Console_Port_Minor=minor;
-
- /*
- * Register Device Names
- */
- status = rtems_io_register_name("/dev/console", major, Console_Port_Minor );
- if (status != RTEMS_SUCCESSFUL) {
- rtems_fatal_error_occurred(status);
- }
- Console_Port_Tbl[minor].pDeviceFns->deviceInitialize(Console_Port_Minor);
-
- for (minor++;minor<Console_Port_Count;minor++) {
- /*
- * First perform the configuration dependent probe, then the
- * device dependent probe
- */
-
- if ( (!Console_Port_Tbl[minor].deviceProbe ||
- Console_Port_Tbl[minor].deviceProbe(minor)) &&
- Console_Port_Tbl[minor].pDeviceFns->deviceProbe(minor)) {
- status = rtems_io_register_name(
- Console_Port_Tbl[minor].sDeviceName,
- major,
- minor );
- if (status != RTEMS_SUCCESSFUL) {
- rtems_fatal_error_occurred(status);
- }
-
- /*
- * Initialize the hardware device.
- */
-
- Console_Port_Tbl[minor].pDeviceFns->deviceInitialize(minor);
-
- }
- }
-
return RTEMS_SUCCESSFUL;
}