source: rtems/c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c @ 7f6a24ab

4.104.114.84.95
Last change on this file since 7f6a24ab was ac7d5ef0, checked in by Joel Sherrill <joel.sherrill@…>, on 05/11/95 at 17:39:37

Initial revision

  • Property mode set to 100644
File size: 3.7 KB
Line 
1/*  bsp_start()
2 *
3 *  This routine starts the application.  It includes application,
4 *  board, and monitor specific initialization and configuration.
5 *  The generic CPU dependent initialization has been performed
6 *  before this routine is invoked.
7 *
8 *  INPUT:  NONE
9 *
10 *  OUTPUT: NONE
11 *
12 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
13 *  On-Line Applications Research Corporation (OAR).
14 *  All rights assigned to U.S. Government, 1994.
15 *
16 *  This material may be reproduced by or for the U.S. Government pursuant
17 *  to the copyright license under the clause at DFARS 252.227-7013.  This
18 *  notice must appear in all copies of this file and its derivatives.
19 *
20 *  $Id$
21 */
22
23#include <rtems.h>
24#include <bsp.h>
25#include <shm.h>
26#include <libcsupport.h>
27
28/*
29 *  The original table from the application and our copy of it with
30 *  some changes.
31 */
32
33extern rtems_configuration_table Configuration;
34
35rtems_configuration_table  BSP_Configuration;
36
37rtems_cpu_table Cpu_table;
38
39/*      Initialize whatever libc we are using
40 *      called from postdriver hook
41 */
42
43void bsp_libc_init()
44{
45    extern int end;
46    rtems_unsigned32        heap_start;
47
48    heap_start = (rtems_unsigned32) &end;
49    if (heap_start & (CPU_ALIGNMENT-1))
50        heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
51
52    /*
53     *  The last parameter to RTEMS_Malloc_Initialize is the "chunk"
54     *  size which a multiple of will be requested on each sbrk()
55     *  call by malloc().  A value of 0 indicates that sbrk() should
56     *  not be called to extend the heap.
57     */
58
59    RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0);
60
61    /*
62     * Set up for the libc handling.
63     */
64
65    if (BSP_Configuration.ticks_per_timeslice > 0)
66        libc_init(1);                /* reentrant if possible */
67    else
68        libc_init(0);                /* non-reentrant */
69
70    /*
71     *  Initialize the stack bounds checker
72     */
73
74#ifdef STACK_CHECKER_ON
75    Stack_check_Initialize();
76#endif
77}
78
79int bsp_start(
80  int argc,
81  char **argv,
82  char **environp
83)
84{
85  /*
86   *  Allocate the memory for the RTEMS Work Space.  This can come from
87   *  a variety of places: hard coded address, malloc'ed from outside
88   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
89   *  typically done by stock BSPs) by subtracting the required amount
90   *  of work space from the last physical address on the CPU board.
91   */
92
93  /*
94   *  Copy the Configuration Table .. so we can change it
95   */
96
97  BSP_Configuration = Configuration;
98
99  /*
100   * Add 1 region for the RTEMS Malloc
101   */
102
103  BSP_Configuration.maximum_regions++;
104
105  /*
106   * Add 1 extension for newlib libc
107   */
108
109#ifdef RTEMS_NEWLIB
110    BSP_Configuration.maximum_extensions++;
111#endif
112
113  /*
114   * Add 1 extension for newlib libc
115   */
116
117#ifdef RTEMS_NEWLIB
118    BSP_Configuration.maximum_extensions++;
119#endif
120
121  /*
122   *  Need to "allocate" the memory for the RTEMS Workspace and
123   *  tell the RTEMS configuration where it is.  This memory is
124   *  not malloc'ed.  It is just "pulled from the air".
125   */
126
127  BSP_Configuration.work_space_start = (void *) 0;
128
129  /*
130   *  initialize the CPU table for this BSP
131   */
132
133  /*
134   *  we do not use the pretasking_hook
135   */
136
137  Cpu_table.pretasking_hook = NULL;
138
139  Cpu_table.predriver_hook = bsp_libc_init;    /* RTEMS resources available */
140
141  Cpu_table.postdriver_hook = NULL;
142
143  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
144
145  Cpu_table.do_zero_of_workspace = TRUE;
146
147  Cpu_table.interrupt_stack_size = 4096;
148
149  Cpu_table.extra_system_initialization_stack = 0;
150
151  /*
152   *  Don't forget the other CPU Table entries.
153   */
154
155  /*
156   *  Start RTEMS
157   */
158
159  rtems_initialize_executive( &BSP_Configuration, &Cpu_table );
160
161  bsp_cleanup();
162
163  return 0;
164}
Note: See TracBrowser for help on using the repository browser.