source: rtems/cpukit/libcsupport/src/consolesimple.c @ 337a186

5
Last change on this file since 337a186 was 337a186, checked in by Sebastian Huber <sebastian.huber@…>, on 02/21/18 at 11:40:18

Add a simple task console driver

Close #3320.

  • Property mode set to 100644
File size: 1.8 KB
RevLine 
[ac28f15]1/*
2 * Copyright (c) 2017 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 <rtems/console.h>
16#include <rtems/bspIo.h>
17#include <rtems/imfs.h>
18
[337a186]19#include "consolesimple.h"
[ac28f15]20
21static ssize_t _Console_simple_Write(
22  rtems_libio_t *iop,
23  const void    *buffer,
24  size_t         count
25)
26{
27  const char *buf;
28  ssize_t     i;
29  ssize_t     n;
30
31  buf = buffer;
32  n = (ssize_t) count;
33
34  for ( i = 0; i < n; ++i ) {
35    rtems_putc( buf[ i ] );
36  }
37
38  return n;
39}
40
41static const rtems_filesystem_file_handlers_r _Console_simple_Handlers = {
42  .open_h = rtems_filesystem_default_open,
43  .close_h = rtems_filesystem_default_close,
44  .read_h = _Console_simple_Read,
45  .write_h = _Console_simple_Write,
46  .ioctl_h = rtems_filesystem_default_ioctl,
47  .lseek_h = rtems_filesystem_default_lseek,
48  .fstat_h = IMFS_stat,
49  .ftruncate_h = rtems_filesystem_default_ftruncate,
50  .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
51  .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
52  .fcntl_h = rtems_filesystem_default_fcntl,
53  .readv_h = rtems_filesystem_default_readv,
54  .writev_h = rtems_filesystem_default_writev,
55  .mmap_h = rtems_filesystem_default_mmap
56};
57
58static const IMFS_node_control
59_Console_simple_Node_control = IMFS_GENERIC_INITIALIZER(
60  &_Console_simple_Handlers,
61  IMFS_node_initialize_default,
62  IMFS_node_destroy_default
63);
64
65void _Console_simple_Initialize( void )
66{
67  IMFS_make_generic_node(
68    CONSOLE_DEVICE_NAME,
69    S_IFCHR | S_IRWXU | S_IRWXG | S_IRWXO,
70    &_Console_simple_Node_control,
71    NULL
72  );
73}
Note: See TracBrowser for help on using the repository browser.