source: rtems/c/src/lib/libbsp/shared/console_select.c @ ba692232

4.115
Last change on this file since ba692232 was ba692232, checked in by Jennifer Averett <Jennifer.Averett@…>, on Oct 18, 2011 at 6:23:51 PM

2011-10-18 Jennifer Averett <Jennifer.Averett@…>

PR 1917/bsps

  • console.c: Modifications to add dynamic tables for libchip serial drivers.
  • console_control.c, console_private.h, console_read.c, console_select.c, console_write.c: New files.
  • Property mode set to 100644
File size: 2.4 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup Console
5 *
6 * @brief Generic libchip console select
7 */
8
9/*
10 *  This file contains a routine to select the
11 *  console based upon a number of criteria.
12 *
13 *  COPYRIGHT (c) 2011.
14 *  On-Line Applications Research Corporation (OAR).
15 *
16 *  The license and distribution terms for this file may be
17 *  found in the file LICENSE in this distribution or at
18 *  http://www.rtems.com/license/LICENSE.
19 *
20 *  $Id$
21 */
22
23#include <bsp.h>
24#include <rtems/libio.h>
25#include <stdlib.h>
26#include <assert.h>
27#include <termios.h>
28
29#include <rtems/termiostypes.h>
30#include <libchip/serial.h>
31#include "console_private.h"
32
33/*
34 * Method to return true if the device associated with the
35 * minor number probs available.
36 */
37static bool bsp_Is_Available( rtems_device_minor_number minor )
38{
39  console_tbl  *cptr = Console_Port_Tbl[minor];
40
41  /*
42   * First perform the configuration dependent probe, then the
43   * device dependent probe
44   */
45  if ((!cptr->deviceProbe || cptr->deviceProbe(minor)) &&
46       cptr->pDeviceFns->deviceProbe(minor)) {
47    return true; 
48  }
49  return false;
50}
51
52/*
53 * Method to return the first available device.
54 */
55static rtems_device_minor_number bsp_First_Available_Device( void )
56{
57  rtems_device_minor_number minor;
58
59  for (minor=0; minor < Console_Port_Count ; minor++) {
60    console_tbl  *cptr = Console_Port_Tbl[minor];
61
62    /*
63     * First perform the configuration dependent probe, then the
64     * device dependent probe
65     */
66
67    if ((!cptr->deviceProbe || cptr->deviceProbe(minor)) &&
68         cptr->pDeviceFns->deviceProbe(minor)) {
69      return minor;
70    }
71  }
72
73  /*
74   *  Error No devices were found.  We will want to bail here.
75   */
76  rtems_fatal_error_occurred(RTEMS_IO_ERROR);
77}
78
79void bsp_console_select(void)
80{
81
82  /*
83   *  Reset Console_Port_Minor and
84   *  BSPPrintkPort here if desired.
85   * 
86   *  This default version allows the bsp to set these
87   *  values at creation and will not touch them again
88   *  unless the selected port number is not available.
89   */
90
91  /*
92   * If the device that was selected isn't available then
93   * let the user know and select the first available device.
94   */
95  if ( !bsp_Is_Available( Console_Port_Minor ) ) {
96    printk(
97      "Error finding %s setting console to first available\n",
98      Console_Port_Tbl[Console_Port_Minor]->sDeviceName
99    );
100    Console_Port_Minor = bsp_First_Available_Device();
101  }
102}
Note: See TracBrowser for help on using the repository browser.