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

4.8
Last change on this file since 325a4df0 was 325a4df0, checked in by Joel Sherrill <joel.sherrill@…>, on 11/26/07 at 22:09:45

2007-11-26 Joel Sherrill <joel.sherrill@…>

  • bootcard.c: Add comment.
  • Property mode set to 100644
File size: 4.2 KB
Line 
1/*
2 *  This is the C entry point for ALL RTEMS BSPs.  It is invoked
3 *  from the assembly language initialization file usually called
4 *  start.S.  It provides the framework for the BSP initialization
5 *  sequence.  The basic flow of initialization is:
6 *
7 *  + start.S: basic CPU setup (stack, zero BSS)
8 *    + boot_card
9 *      + bspstart.c: bsp_start - more advanced initialization
10 *      + rtems_initialize_executive_early
11 *        + all device drivers
12 *      + rtems_initialize_executive_late
13 *        + 1st task executes C++ global constructors
14 *        .... appplication runs ...
15 *        + exit
16 *     + back to here eventually
17 *     + bspclean.c: bsp_cleanup
18 *
19 *  This style of initialization insures that the C++ global
20 *  constructors are executed after RTEMS is initialized.
21 *
22 *  Thanks to Chris Johns <cjohns@plessey.com.au> for this idea.
23 *
24 *  COPYRIGHT (c) 1989-2006.
25 *  On-Line Applications Research Corporation (OAR).
26 *
27 *  The license and distribution terms for this file may be
28 *  found in the file LICENSE in this distribution or at
29 *  http://www.rtems.com/license/LICENSE.
30 *
31 *  $Id$
32 */
33
34#include <bsp.h>
35
36extern void bsp_start( void );
37extern void bsp_cleanup( void );
38
39extern rtems_configuration_table  Configuration;
40extern rtems_configuration_table  BSP_Configuration;
41extern rtems_cpu_table            Cpu_table;
42
43rtems_api_configuration_table BSP_RTEMS_Configuration;
44
45#ifdef RTEMS_POSIX_API
46posix_api_configuration_table BSP_POSIX_Configuration;
47#endif
48
49rtems_interrupt_level bsp_isr_level;
50
51/*
52 *  Since there is a forward reference
53 */
54
55char *rtems_progname;
56
57int boot_card(int argc, char **argv, char **envp)
58{
59  static char  *argv_pointer = NULL;
60  static char  *envp_pointer = NULL;
61  char **argv_p = &argv_pointer;
62  char **envp_p = &envp_pointer;
63
64  /*
65   *  Set things up so c_rtems_main() is called with real pointers for
66   *  argv and envp.  If the BSP has passed us something useful, then
67   *  pass it on.  Somehow we need to eventually make this available to
68   *  a real main() in user land. :)
69   */
70
71  if ( argv )
72    argv_p = argv;
73
74  if ( envp )
75    envp_p = envp;
76
77  /*
78   *  Set default values for the CPU Table fields all ports must have.
79   *  These values can be overridden in bsp_start() but they are
80   *  right most of the time.
81   */
82
83  Cpu_table.pretasking_hook                 = NULL;
84  Cpu_table.predriver_hook                  = NULL;
85  Cpu_table.postdriver_hook                 = NULL;
86  Cpu_table.idle_task                       = NULL;
87  Cpu_table.do_zero_of_workspace            = FALSE;
88  Cpu_table.interrupt_stack_size            = RTEMS_MINIMUM_STACK_SIZE;
89  Cpu_table.extra_mpci_receive_server_stack = 0;
90  Cpu_table.stack_allocate_hook             = NULL;
91  Cpu_table.stack_free_hook                 = NULL;
92
93  /*
94   *  Copy the configuration table so we and the BSP wants to change it.
95   */
96
97  BSP_Configuration       = Configuration;
98
99  BSP_RTEMS_Configuration = *Configuration.RTEMS_api_configuration;
100  BSP_Configuration.RTEMS_api_configuration = &BSP_RTEMS_Configuration;
101
102#ifdef RTEMS_POSIX_API
103  BSP_POSIX_Configuration = *Configuration.POSIX_api_configuration;
104  BSP_Configuration.POSIX_api_configuration = &BSP_POSIX_Configuration;
105#endif
106
107  /*
108   * Invoke Board Support Package initialization routine written in C.
109   */
110
111  bsp_start();
112
113  /*
114   *  Initialize RTEMS but do NOT start multitasking.
115   */
116
117  bsp_isr_level =
118    rtems_initialize_executive_early( &BSP_Configuration, &Cpu_table );
119
120  /*
121   *  Call c_rtems_main() and eventually let the first task or the real
122   *  main() invoke the global constructors if there are any.
123   */
124
125  if ((argc > 0) && argv && argv[0])
126    rtems_progname = argv[0];
127  else
128    rtems_progname = "RTEMS";
129
130  rtems_initialize_executive_late( bsp_isr_level );
131
132  /***************************************************************
133   ***************************************************************
134   *  APPLICATION RUNS HERE!!!  When it shuts down, we return!!! *
135   ***************************************************************
136   ***************************************************************
137   */
138
139  /*
140   *  Perform any BSP specific shutdown actions.
141   */
142
143  bsp_cleanup();
144
145  /*
146   *  Now return to the start code.
147   */
148
149  return 0;
150}
Note: See TracBrowser for help on using the repository browser.