source: rtems/c/src/lib/libbsp/sh/gensh1/startup/bspstart.c @ c244a9ee

4.104.114.84.95
Last change on this file since c244a9ee was c244a9ee, checked in by Joel Sherrill <joel.sherrill@…>, on 04/14/98 at 21:32:12

Stack checker extension now accounted for in confdefs.h

  • Property mode set to 100644
File size: 5.0 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 *  Authors: Ralf Corsepius (corsepiu@faw.uni-ulm.de) and
13 *           Bernd Becker (becker@faw.uni-ulm.de)
14 *
15 *  COPYRIGHT (c) 1997-1998, FAW Ulm, Germany
16 *
17 *  This program is distributed in the hope that it will be useful,
18 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
19 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 *
22 *  COPYRIGHT (c) 1998.
23 *  On-Line Applications Research Corporation (OAR).
24 *  Copyright assigned to U.S. Government, 1994.
25 *
26 *  The license and distribution terms for this file may be
27 *  found in the file LICENSE in this distribution or at
28 *  http://www.OARcorp.com/rtems/license.html.
29 *
30 *  $Id$
31 */
32
33#include <bsp.h>
34#include <rtems/libio.h>
35 
36#include <libcsupport.h>
37 
38#include <string.h>
39 
40#ifdef STACK_CHECKER_ON
41#include <stackchk.h>
42#endif
43
44/*
45 *  The original table from the application and our copy of it with
46 *  some changes.
47 */
48
49extern rtems_configuration_table Configuration;
50
51rtems_configuration_table  BSP_Configuration;
52
53rtems_cpu_table Cpu_table;
54
55char *rtems_progname;
56
57/*      Initialize whatever libc we are using
58 *      called from postdriver hook
59 */
60
61
62void bsp_libc_init()
63{
64    /*
65     *  The last parameter to RTEMS_Malloc_Initialize is the "chunk"
66     *  size which a multiple of will be requested on each sbrk()
67     *  call by malloc().  A value of 0 indicates that sbrk() should
68     *  not be called to extend the heap.
69     */
70
71    RTEMS_Malloc_Initialize(&HeapStart, sizeof(unsigned32) * (&HeapEnd - &HeapStart), 0);
72
73    /*
74     *  Init the RTEMS libio facility to provide UNIX-like system
75     *  calls for use by newlib (ie: provide __rtems_open, __rtems_close, etc)
76     *  Uses malloc() to get area for the iops, so must be after malloc init
77     */
78
79    rtems_libio_init();
80
81    /*
82     * Set up for the libc handling.
83     */
84
85    if (BSP_Configuration.ticks_per_timeslice > 0)
86        libc_init(1);                /* reentrant if possible */
87    else
88        libc_init(0);                /* non-reentrant */
89}
90
91/*
92 *  Function:   bsp_pretasking_hook
93 *
94 *  Description:
95 *      BSP pretasking hook.  Called just before drivers are initialized.
96 *      Used to setup libc and install any BSP extensions.
97 *
98 *  NOTES:
99 *      Must not use libc (to do io) from here, since drivers are
100 *      not yet initialized.
101 *
102 */
103 
104void
105bsp_pretasking_hook(void)
106{
107    bsp_libc_init();
108 
109#ifdef STACK_CHECKER_ON
110    /*
111     *  Initialize the stack bounds checker
112     *  We can either turn it on here or from the app.
113     */
114 
115    Stack_check_Initialize();
116#endif
117 
118#ifdef RTEMS_DEBUG
119    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
120#endif
121}
122
123/*
124 *  Use the shared bsp_postdriver_hook() implementation
125 */
126 
127void bsp_postdriver_hook(void);
128
129
130void bsp_start(void)
131{
132  /*
133     For real boards you need to setup the hardware
134     and need to copy the vector table from rom to ram.
135
136     Depending on the board this can ether be done from inside the rom
137     startup code, rtems startup code or here.
138   */
139   
140  /*
141   *  Allocate the memory for the RTEMS Work Space.  This can come from
142   *  a variety of places: hard coded address, malloc'ed from outside
143   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
144   *  typically done by stock BSPs) by subtracting the required amount
145   *  of work space from the last physical address on the CPU board.
146   */
147
148  /*
149   *  Copy the Configuration Table .. so we can change it
150   */
151
152  BSP_Configuration = Configuration;
153
154  /*
155   *  Need to "allocate" the memory for the RTEMS Workspace and
156   *  tell the RTEMS configuration where it is.  This memory is
157   *  not malloc'ed.  It is just "pulled from the air".
158   */
159
160  BSP_Configuration.work_space_start = (void *) &WorkSpaceStart ;
161  BSP_Configuration.work_space_size  =
162    (unsigned32) &WorkSpaceEnd -
163    (unsigned32) &WorkSpaceStart ;
164 
165  /*
166   *  initialize the CPU table for this BSP
167   */
168
169#if ( CPU_ALLOCATE_INTERRUPT_STACK == FALSE )
170  _CPU_Interrupt_stack_low = &CPU_Interrupt_stack_low ;
171  _CPU_Interrupt_stack_high = &CPU_Interrupt_stack_high ;
172
173  /* This isn't used anywhere */
174  Cpu_table.interrupt_stack_size =
175    (unsigned32) (&CPU_Interrupt_stack_high) -
176    (unsigned32) (&CPU_Interrupt_stack_low) ;
177#endif
178
179
180  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
181
182  Cpu_table.predriver_hook = NULL;
183
184  Cpu_table.postdriver_hook = bsp_postdriver_hook;
185
186  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
187
188  Cpu_table.do_zero_of_workspace = TRUE;
189
190#if ( CPU_ALLOCATE_INTERRUPT_STACK == TRUE )
191  Cpu_table.interrupt_stack_size = 4096;
192#endif
193
194  Cpu_table.extra_mpci_receive_server_stack = 0;
195
196  /*
197   *  Don't forget the other CPU Table entries.
198   */
199
200  /*
201   * Tell libio how many fd's we want and allow it to tweak config
202   */
203
204  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
205}
Note: See TracBrowser for help on using the repository browser.