source: rtems/cpukit/rtems/src/taskinitusers.c @ fe100e16

5
Last change on this file since fe100e16 was fe100e16, checked in by Sebastian Huber <sebastian.huber@…>, on 12/22/15 at 08:13:08

score: Add fatal errors for NULL entry init tasks

This simplifies the global construction.

Update #2514.

  • Property mode set to 100644
File size: 2.7 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/rtems/rtemsapi.h>
27#include <rtems/score/assert.h>
28#include <rtems/score/stack.h>
29#include <rtems/rtems/tasksimpl.h>
30#include <rtems/score/thread.h>
31#include <rtems/score/wkspace.h>
32#include <rtems/score/apiext.h>
33
34/*
35 *  _RTEMS_tasks_Initialize_user_tasks_body
36 *
37 *  This routine creates and starts all configured user
38 *  initialization threads.
39 *
40 *  Input parameters: NONE
41 *
42 *  Output parameters:  NONE
43 */
44
45void _RTEMS_tasks_Initialize_user_tasks_body( void )
46{
47  uint32_t                          index;
48  uint32_t                          maximum;
49  rtems_id                          id;
50  rtems_status_code                 return_value;
51  rtems_initialization_tasks_table *user_tasks;
52  bool                              register_global_construction;
53  rtems_task_entry                  entry_point;
54
55  /*
56   *  Move information into local variables
57   */
58  user_tasks = Configuration_RTEMS_API.User_initialization_tasks_table;
59  maximum    = Configuration_RTEMS_API.number_of_initialization_tasks;
60
61  /*
62   *  Verify that we have a set of user tasks to iterate
63   */
64  if ( !user_tasks )
65    return;
66
67  register_global_construction = true;
68
69  /*
70   *  Now iterate over the initialization tasks and create/start them.
71   */
72  for ( index=0 ; index < maximum ; index++ ) {
73    return_value = rtems_task_create(
74      user_tasks[ index ].name,
75      user_tasks[ index ].initial_priority,
76      user_tasks[ index ].stack_size,
77      user_tasks[ index ].mode_set,
78      user_tasks[ index ].attribute_set,
79      &id
80    );
81    if ( !rtems_is_status_successful( return_value ) )
82      _Terminate( INTERNAL_ERROR_RTEMS_API, true, return_value );
83
84    entry_point = user_tasks[ index ].entry_point;
85    if ( entry_point == NULL ) {
86      _Terminate(
87        INTERNAL_ERROR_CORE,
88        false,
89        INTERNAL_ERROR_RTEMS_INIT_TASK_ENTRY_IS_NULL
90      );
91    }
92
93    if ( register_global_construction ) {
94      register_global_construction = false;
95      entry_point = (rtems_task_entry) _Thread_Global_construction;
96    }
97
98    return_value = rtems_task_start(
99      id,
100      entry_point,
101      user_tasks[ index ].argument
102    );
103    _Assert( rtems_is_status_successful( return_value ) );
104    (void) return_value;
105  }
106}
Note: See TracBrowser for help on using the repository browser.