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

4.104.114.84.95
Last change on this file since 468c6f00 was f05b2ac, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/21/04 at 16:01:48

Remove duplicate white lines.

  • Property mode set to 100644
File size: 3.5 KB
Line 
1/*
2 *  A simple main which can be used on any embedded target.
3 *
4 *  This style of initialization insures that the C++ global
5 *  constructors are executed after RTEMS is initialized.
6 *
7 *  Thanks to Chris Johns <cjohns@plessey.com.au> for this idea.
8 *
9 *  COPYRIGHT (c) 1989-1999.
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.com/license/LICENSE.
15 *
16 *  $Id$
17 */
18
19#include <bsp.h>
20
21#if defined(__USE_INIT_FINI__)
22#include <stdlib.h> /* for atexit() */
23#endif
24
25extern void bsp_start( void );
26extern void bsp_cleanup( void );
27
28extern rtems_configuration_table  Configuration;
29extern rtems_configuration_table  BSP_Configuration;
30extern rtems_cpu_table            Cpu_table;
31
32rtems_api_configuration_table BSP_RTEMS_Configuration;
33
34#ifdef RTEMS_POSIX_API
35posix_api_configuration_table BSP_POSIX_Configuration;
36#endif
37
38/* Initialize C++ global Ctor/Dtor and initializes exception handling. */
39#if defined(__USE_INIT_FINI__)
40extern void _fini( void );
41#endif
42
43rtems_interrupt_level bsp_isr_level;
44
45/*
46 *  Since there is a forward reference
47 */
48
49int c_rtems_main(int argc, char **argv, char **envp);
50
51int boot_card(int argc, char **argv, char **envp)
52{
53  int    status;
54  static char  *argv_pointer = NULL;
55  static char  *envp_pointer = NULL;
56  char **argv_p = &argv_pointer;
57  char **envp_p = &envp_pointer;
58
59  /*
60   *  Set things up so c_rtems_main() is called with real pointers for
61   *  argv and envp.  If the BSP has passed us something useful, then
62   *  pass it on.  Somehow we need to eventually make this available to
63   *  a real main() in user land. :)
64   */
65
66  if ( argv )
67    argv_p = argv;
68
69  if ( envp )
70    envp_p = envp;
71
72  /*
73   *  Set default values for the CPU Table fields all ports must have.
74   *  These values can be overridden in bsp_start() but they are
75   *  right most of the time.
76   */
77
78  Cpu_table.pretasking_hook                 = NULL;
79  Cpu_table.predriver_hook                  = NULL;
80  Cpu_table.postdriver_hook                 = NULL;
81  Cpu_table.idle_task                       = NULL;
82  Cpu_table.do_zero_of_workspace            = TRUE;
83  Cpu_table.interrupt_stack_size            = RTEMS_MINIMUM_STACK_SIZE;
84  Cpu_table.extra_mpci_receive_server_stack = 0;
85  Cpu_table.stack_allocate_hook             = NULL;
86  Cpu_table.stack_free_hook                 = NULL;
87
88  /*
89   *  Copy the configuration table so we and the BSP wants to change it.
90   */
91
92  BSP_Configuration       = Configuration;
93
94  BSP_RTEMS_Configuration = *Configuration.RTEMS_api_configuration;
95  BSP_Configuration.RTEMS_api_configuration = &BSP_RTEMS_Configuration;
96
97#ifdef RTEMS_POSIX_API
98  BSP_POSIX_Configuration = *Configuration.POSIX_api_configuration;
99  BSP_Configuration.POSIX_api_configuration = &BSP_POSIX_Configuration;
100#endif
101
102  /*
103   *  The atexit hook will be before the static destructor list's entry
104   *  point.
105   */
106
107  bsp_start();
108
109  /*
110   *  Initialize RTEMS but do NOT start multitasking.
111   */
112
113  bsp_isr_level =
114    rtems_initialize_executive_early( &BSP_Configuration, &Cpu_table );
115
116  /*
117   *  Call c_rtems_main() and eventually let the first task or the real
118   *  main() invoke the global constructors if there are any.
119   */
120
121#if defined(__USE_INIT_FINI__)
122   atexit( _fini );
123#endif
124
125  status = c_rtems_main( argc, argv_p, envp_p );
126
127  /*
128   *  Perform any BSP specific shutdown actions.
129   */
130
131  bsp_cleanup();
132
133  /*
134   *  Now return to the start code.
135   */
136
137  return status;
138}
Note: See TracBrowser for help on using the repository browser.