source: rtems/cpukit/libcsupport/src/libio_init.c @ cefc9aea

4.115
Last change on this file since cefc9aea was cefc9aea, checked in by Alex Ivanov <alexivanov97@…>, on 12/15/12 at 12:23:36

libcsupport: Doxygen Enhancement Task #8

http://www.google-melange.com/gci/task/view/google/gci2012/7996208

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/**
2 *  @file
3 *
4 *  @brief RTEMS LibIO Initialization
5 *  @ingroup LibIO
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2010.
10 *  On-Line Applications Research Corporation (OAR).
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.rtems.com/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/libio_.h>               /* libio_.h pulls in rtems */
22#include <rtems.h>
23#include <rtems/assoc.h>                /* assoc.h not included by rtems.h */
24
25#include <stdio.h>                      /* O_RDONLY, et.al. */
26#include <fcntl.h>                      /* O_RDONLY, et.al. */
27#include <errno.h>
28
29#include <errno.h>
30#include <string.h>                     /* strcmp */
31#include <unistd.h>
32#include <stdlib.h>                     /* calloc() */
33
34#include <rtems/libio.h>                /* libio.h not pulled in by rtems */
35
36/*
37 *  File descriptor Table Information
38 */
39
40rtems_id           rtems_libio_semaphore;
41rtems_libio_t     *rtems_libio_iops;
42rtems_libio_t     *rtems_libio_iop_freelist;
43
44void rtems_libio_init( void )
45{
46    rtems_status_code rc;
47    uint32_t i;
48    rtems_libio_t *iop;
49
50    if (rtems_libio_number_iops > 0)
51    {
52        rtems_libio_iops = (rtems_libio_t *) calloc(rtems_libio_number_iops,
53                                                    sizeof(rtems_libio_t));
54        if (rtems_libio_iops == NULL)
55            rtems_fatal_error_occurred(RTEMS_NO_MEMORY);
56
57        iop = rtems_libio_iop_freelist = rtems_libio_iops;
58        for (i = 0 ; (i + 1) < rtems_libio_number_iops ; i++, iop++)
59          iop->data1 = iop + 1;
60        iop->data1 = NULL;
61    }
62
63  /*
64   *  Create the binary semaphore used to provide mutual exclusion
65   *  on the IOP Table.
66   */
67
68  rc = rtems_semaphore_create(
69    RTEMS_LIBIO_SEM,
70    1,
71    RTEMS_BINARY_SEMAPHORE | RTEMS_INHERIT_PRIORITY | RTEMS_PRIORITY,
72    RTEMS_NO_PRIORITY,
73    &rtems_libio_semaphore
74  );
75  if ( rc != RTEMS_SUCCESSFUL )
76    rtems_fatal_error_occurred( rc );
77
78  /*
79   *  Initialize the base file system infrastructure.
80   */
81
82  if (rtems_fs_init_helper)
83     (* rtems_fs_init_helper)();
84}
Note: See TracBrowser for help on using the repository browser.