source: rtems/cpukit/rtems/src/taskinitusers.c @ 66cb142

5
Last change on this file since 66cb142 was a7dcef97, checked in by Sebastian Huber <sebastian.huber@…>, on 11/17/17 at 05:36:54

score: Simplify global construction

Update #3243.

  • Property mode set to 100644
File size: 2.4 KB
Line 
1/**
2 * @file
3 *
4 * @brief _RTEMS_tasks_Initialize_user_tasks_body
5 * @ingroup ClassicTasks Tasks
6 */
7
8/*
9 *  COPYRIGHT (c) 1989-2008.
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.org/license/LICENSE.
15 */
16
17#if HAVE_CONFIG_H
18#include "config.h"
19#endif
20
21#include <rtems/system.h>
22#include <rtems/config.h>
23#include <rtems/rtems/status.h>
24#include <rtems/rtems/support.h>
25#include <rtems/rtems/modes.h>
26#include <rtems/score/assert.h>
27#include <rtems/score/stack.h>
28#include <rtems/rtems/tasksimpl.h>
29#include <rtems/score/thread.h>
30#include <rtems/score/wkspace.h>
31
32/*
33 *  _RTEMS_tasks_Initialize_user_tasks_body
34 *
35 *  This routine creates and starts all configured user
36 *  initialization threads.
37 *
38 *  Input parameters: NONE
39 *
40 *  Output parameters:  NONE
41 */
42
43void _RTEMS_tasks_Initialize_user_tasks_body( void )
44{
45  uint32_t                          index;
46  uint32_t                          maximum;
47  rtems_id                          id;
48  rtems_status_code                 return_value;
49  rtems_initialization_tasks_table *user_tasks;
50  rtems_task_entry                  entry_point;
51
52  /*
53   *  Move information into local variables
54   */
55  user_tasks = Configuration_RTEMS_API.User_initialization_tasks_table;
56  maximum    = Configuration_RTEMS_API.number_of_initialization_tasks;
57
58  /*
59   *  Verify that we have a set of user tasks to iterate
60   */
61  if ( !user_tasks )
62    return;
63
64  /*
65   *  Now iterate over the initialization tasks and create/start them.
66   */
67  for ( index=0 ; index < maximum ; index++ ) {
68    return_value = rtems_task_create(
69      user_tasks[ index ].name,
70      user_tasks[ index ].initial_priority,
71      user_tasks[ index ].stack_size,
72      user_tasks[ index ].mode_set,
73      user_tasks[ index ].attribute_set,
74      &id
75    );
76    if ( !rtems_is_status_successful( return_value ) ) {
77      _Internal_error( INTERNAL_ERROR_RTEMS_INIT_TASK_CREATE_FAILED );
78    }
79
80    entry_point = user_tasks[ index ].entry_point;
81    if ( entry_point == NULL ) {
82      _Internal_error( INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL );
83    }
84
85    return_value = rtems_task_start(
86      id,
87      entry_point,
88      user_tasks[ index ].argument
89    );
90    _Assert( rtems_is_status_successful( return_value ) );
91    (void) return_value;
92
93    if ( _Thread_Global_constructor == 0 ) {
94      _Thread_Global_constructor = id;
95    }
96  }
97}
Note: See TracBrowser for help on using the repository browser.