source: rtems/c/src/lib/libbsp/shared/console-termios-init.c @ 90d8567

5
Last change on this file since 90d8567 was b4fa5a52, checked in by Sebastian Huber <sebastian.huber@…>, on 03/05/15 at 09:04:37

bsps: Fix warning

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/*
2 * Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
3 *
4 *  embedded brains GmbH
5 *  Dornierstr. 4
6 *  82178 Puchheim
7 *  Germany
8 *  <rtems@embedded-brains.de>
9 *
10 * The license and distribution terms for this file may be
11 * found in the file LICENSE in this distribution or at
12 * http://www.rtems.org/license/LICENSE.
13 */
14
15#include <bsp/console-termios.h>
16#include <bsp/fatal.h>
17
18#include <rtems/console.h>
19
20RTEMS_INTERRUPT_LOCK_DEFINE( static, console_lock, "console" )
21
22static rtems_device_major_number console_major = UINT32_MAX;
23
24static rtems_device_minor_number console_minor;
25
26rtems_status_code console_device_install(
27  const char                         *device_file,
28  const rtems_termios_device_handler *handler,
29  const rtems_termios_device_flow    *flow,
30  rtems_termios_device_context       *context
31)
32{
33  rtems_interrupt_lock_context lock_context;
34  rtems_device_minor_number    minor;
35
36  rtems_interrupt_lock_acquire( &console_lock, &lock_context );
37  minor = console_minor;
38  ++console_minor;
39  rtems_interrupt_lock_release( &console_lock, &lock_context );
40
41  return rtems_termios_device_install(
42    device_file,
43    console_major,
44    minor,
45    handler,
46    flow,
47    context
48  );
49}
50
51bool console_device_probe_default(rtems_termios_device_context *context)
52{
53  (void) context;
54
55  return true;
56}
57
58rtems_device_driver console_initialize(
59  rtems_device_major_number  major,
60  rtems_device_minor_number  minor,
61  void                      *arg
62)
63{
64  bool console_device_done = false;
65
66  rtems_termios_initialize();
67
68  for ( minor = 0; minor < console_device_count; ++minor ) {
69    const console_device *ctx = &console_device_table[ minor ];
70    rtems_status_code     sc;
71
72    if ( ( *ctx->probe )( ctx->context ) ) {
73      sc = rtems_termios_device_install(
74        ctx->device_file,
75        major,
76        minor,
77        ctx->handler,
78        ctx->flow,
79        ctx->context
80      );
81      if ( sc != RTEMS_SUCCESSFUL ) {
82        bsp_fatal( BSP_FATAL_CONSOLE_INSTALL_0 );
83      }
84
85      if ( !console_device_done ) {
86        console_device_done = true;
87
88        sc = rtems_io_register_name( CONSOLE_DEVICE_NAME, major, minor );
89        if ( sc != RTEMS_SUCCESSFUL ) {
90          bsp_fatal( BSP_FATAL_CONSOLE_INSTALL_1 );
91        }
92      }
93    }
94  }
95
96  console_major = major;
97  console_minor = minor;
98
99  return RTEMS_SUCCESSFUL;
100}
Note: See TracBrowser for help on using the repository browser.