source: rtems/c/src/lib/libbsp/shared/bootcard.c @ ab49921

4.115
Last change on this file since ab49921 was ab49921, checked in by Sebastian Huber <sebastian.huber@…>, on 04/08/13 at 14:13:02

bsps: Fix warnings

  • Property mode set to 100644
File size: 5.0 KB
Line 
1/**
2 * @file
3 *
4 * @ingroup bsp_bootcard
5 *
6 * @brief Standard system startup.
7 */
8
9/*
10 *  This is the C entry point for ALL RTEMS BSPs.  It is invoked
11 *  from the assembly language initialization file usually called
12 *  start.S.  It provides the framework for the BSP initialization
13 *  sequence.  The basic flow of initialization is:
14 *
15 *  + start.S: basic CPU setup (stack, zero BSS)
16 *    + boot_card
17 *      + bspstart.c: bsp_start - more advanced initialization
18 *      + obtain information on BSP memory and allocate RTEMS Workspace
19 *      + rtems_initialize_data_structures
20 *      + allocate memory to C Program Heap
21 *      + initialize C Library and C Program Heap
22 *      + bsp_pretasking_hook
23 *      + if defined( RTEMS_DEBUG )
24 *        - rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
25 *      + rtems_initialize_before_drivers
26 *      + bsp_predriver_hook
27 *      + rtems_initialize_device_drivers
28 *        - all device drivers
29 *      + bsp_postdriver_hook
30 *      + rtems_initialize_start_multitasking
31 *        - 1st task executes C++ global constructors
32 *          .... appplication runs ...
33 *          - exit
34 *      + will not return to here
35 *
36 *  This style of initialization ensures that the C++ global
37 *  constructors are executed after RTEMS is initialized.
38 *  Thanks to Chris Johns <cjohns@plessey.com.au> for the idea
39 *  to move C++ global constructors into the first task.
40 *
41 *  COPYRIGHT (c) 1989-2011.
42 *  On-Line Applications Research Corporation (OAR).
43 *
44 *  The license and distribution terms for this file may be
45 *  found in the file LICENSE in this distribution or at
46 *  http://www.rtems.com/license/LICENSE.
47 */
48
49#include <rtems.h>
50
51#include <bsp/bootcard.h>
52#include <rtems/bspIo.h>
53#include <rtems/malloc.h>
54
55#ifdef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
56#include <unistd.h> /* for sbrk() */
57#endif
58
59/*
60 *  At most a single pointer to the cmdline for those target
61 *  short on memory and not supporting a command line.
62 */
63const char *bsp_boot_cmdline;
64
65/*
66 *  This is the initialization framework routine that weaves together
67 *  calls to RTEMS and the BSP in the proper sequence to initialize
68 *  the system while maximizing shared code and keeping BSP code in C
69 *  as much as possible.
70 */
71void boot_card(
72  const char *cmdline
73)
74{
75  rtems_interrupt_level  bsp_isr_level;
76
77  /*
78   * Special case for PowerPC: The interrupt disable mask is stored in SPRG0.
79   * It must be valid before we can use rtems_interrupt_disable().
80   */
81  #ifdef PPC_INTERRUPT_DISABLE_MASK_DEFAULT
82    ppc_interrupt_set_disable_mask( PPC_INTERRUPT_DISABLE_MASK_DEFAULT );
83  #endif /* PPC_INTERRUPT_DISABLE_MASK_DEFAULT */
84
85  /*
86   *  Make sure interrupts are disabled.
87   */
88  (void) bsp_isr_level;
89  rtems_interrupt_disable( bsp_isr_level );
90
91  bsp_boot_cmdline = cmdline;
92
93  /*
94   * Invoke Board Support Package initialization routine written in C.
95   */
96  bsp_start();
97
98  /*
99   *  Initialize the RTEMS Workspace and the C Program Heap.
100   */
101  bsp_work_area_initialize();
102
103  /*
104   *  Initialize RTEMS data structures
105   */
106  rtems_initialize_data_structures();
107
108  /*
109   *  Initialize the C library for those BSPs using the shared
110   *  framework.
111   */
112  bsp_libc_init();
113
114  /*
115   *  Let the BSP do any required initialization now that RTEMS
116   *  data structures are initialized.  In older BSPs or those
117   *  which do not use the shared framework, this is the typical
118   *  time when the C Library is initialized so malloc()
119   *  can be called by device drivers.  For BSPs using the shared
120   *  framework, this routine can be empty.
121   */
122  bsp_pretasking_hook();
123
124  /*
125   *  If debug is enabled, then enable all dynamic RTEMS debug
126   *  capabilities.
127   *
128   *  NOTE: Most debug features are conditionally compiled in
129   *        or enabled via configure time plugins.
130   */
131  #ifdef RTEMS_DEBUG
132    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
133  #endif
134
135  /*
136   *  Let RTEMS perform initialization it requires before drivers
137   *  are allowed to be initialized.
138   */
139  rtems_initialize_before_drivers();
140
141  /*
142   *  Execute BSP specific pre-driver hook. Drivers haven't gotten
143   *  to initialize yet so this is a good chance to initialize
144   *  buses, spurious interrupt handlers, etc..
145   *
146   *  NOTE: Many BSPs do not require this handler and use the
147   *        shared stub.
148   */
149  bsp_predriver_hook();
150
151  /*
152   *  Initialize all device drivers.
153   */
154  rtems_initialize_device_drivers();
155
156  /*
157   *  Invoke the postdriver hook.  This normally opens /dev/console
158   *  for use as stdin, stdout, and stderr.
159   */
160  bsp_postdriver_hook();
161
162  /*
163   *  Complete initialization of RTEMS and switch to the first task.
164   *  Global C++ constructors will be executed in the context of that task.
165   */
166  rtems_initialize_start_multitasking();
167
168  /***************************************************************
169   ***************************************************************
170   *  APPLICATION RUNS NOW!!!  We will not return to here!!!     *
171   ***************************************************************
172   ***************************************************************/
173}
Note: See TracBrowser for help on using the repository browser.