OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [shared/] [bootcard.c] - Blame information for rev 773

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*
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.OARcorp.com/rtems/license.html.
15
 *
16
 *  $Id: bootcard.c,v 1.2 2001-09-27 12:01:12 chris Exp $
17
 */
18
 
19
#include <bsp.h>
20
 
21
#ifdef USE_INIT_FINI 
22
#include <stdlib.h> /* for atexit() */
23
#endif
24
 
25
extern void bsp_start( void );
26
extern void bsp_cleanup( void );
27
 
28
extern rtems_configuration_table  Configuration;
29
extern rtems_configuration_table  BSP_Configuration;
30
extern rtems_cpu_table            Cpu_table;
31
 
32
rtems_api_configuration_table BSP_RTEMS_Configuration;
33
 
34
#ifdef RTEMS_POSIX_API
35
posix_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)
40
extern void _fini( void );
41
extern void _init( void );
42
#endif
43
 
44
rtems_interrupt_level bsp_isr_level;
45
 
46
/*
47
 *  Since there is a forward reference
48
 */
49
 
50
int main(int argc, char **argv, char **envp);
51
 
52
int boot_card(int argc, char **argv, char **envp)
53
{
54
  int    status;
55
  static char  *argv_pointer = NULL;
56
  static char  *envp_pointer = NULL;
57
  char **argv_p = &argv_pointer;
58
  char **envp_p = &envp_pointer;
59
 
60
  /*
61
   *  Set things up so main is called with real pointers for argv and envp.
62
   *  If the BSP has passed us something useful, then pass it on.
63
   */
64
 
65
  if ( argv )
66
    argv_p = argv;
67
 
68
  if ( envp )
69
    envp_p = envp;
70
 
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
  /*
90
   *  Copy the configuration table so we and the BSP wants to change it.
91
   */
92
 
93
  BSP_Configuration       = Configuration;
94
 
95
  BSP_RTEMS_Configuration = *Configuration.RTEMS_api_configuration;
96
  BSP_Configuration.RTEMS_api_configuration = &BSP_RTEMS_Configuration;
97
 
98
#ifdef RTEMS_POSIX_API
99
  BSP_POSIX_Configuration = *Configuration.POSIX_api_configuration;
100
  BSP_Configuration.POSIX_api_configuration = &BSP_POSIX_Configuration;
101
#endif
102
 
103
  /*
104
   *  The atexit hook will be before the static destructor list's entry
105
   *  point.
106
   */
107
 
108
  bsp_start();
109
 
110
  /*
111
   *  Initialize RTEMS but do NOT start multitasking.
112
   */
113
 
114
  bsp_isr_level =
115
    rtems_initialize_executive_early( &BSP_Configuration, &Cpu_table );
116
 
117
  /*
118
   *  Call main() and get the global constructors invoked if there
119
   *  are any.
120
   */
121
#ifdef USE_INIT_FINI 
122
   atexit( _fini );
123
   _init();
124
#endif
125
 
126
  status = main( argc, argv_p, envp_p );
127
 
128
  /*
129
   *  Perform any BSP specific shutdown actions.
130
   */
131
 
132
  bsp_cleanup();
133
 
134
  /*
135
   *  Now return to the start code.
136
   */
137
 
138
  return status;
139
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.