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

5
Last change on this file since 37030e3 was 37030e3, checked in by Sebastian Huber <sebastian.huber@…>, on 12/09/15 at 07:05:57

bsps: Call bsp_work_area_initialize() early

Call bsp_work_area_initialize() before bsp_start(). This allows
bsp_start() to use malloc() etc. which is beneficial for systems with a
plug-and-play hardware enumeration.

Update #2408.

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