RTEMS Logo

RTEMS 4.9.4 On-Line Library


Console Driver Initialization

PREV UP NEXT Bookshelf BSP and Device Driver Development Guide

8.4.4: Initialization

The driver initialization is called once during the RTEMS initialization process.

The console_initialize function may look like this:

rtems_device_driver console_initialize(
    rtems_device_major_number major,
    rtems_device_minor_number minor,
    void *arg
)
{
    rtems_status_code sc = RTEMS_SUCCESSFUL;
    rtems_device_minor_number i = 0;

    /*
     * Initialize the Termios infrastructure.  If Termios has already
     * been initialized by another device driver, then this call will
     * have no effect.
     */
    rtems_termios_initialize();

    /* Initialize each device */
    for (i = 0; i < MY_DRIVER_DEVICE_NUMBER; ++i) {
        my_driver_entry *e = &my_driver_table [i];

        /*
         * Register this device in the file system.  In order to use the
         * console (i.e. being able to do printf, scanf etc. on stdin,
         * stdout and stderr), some device must be registered
         * as "/dev/console" (CONSOLE_DEVICE_NAME).
         */
        sc = rtems_io_register_name (e->device_name, major, i);
        RTEMS_CHECK_SC(sc, "Register IO device");

        /*
         * Initialize this device and install the interrupt handler if
         * necessary.  You may also initialize the device in the first
         * open call.
         */
    }

    return RTEMS_SUCCESSFUL;
}


PREV UP NEXT Bookshelf BSP and Device Driver Development Guide

Copyright © 1988-2008 OAR Corporation