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

4.104.114.84.9
Last change on this file since 9b64c2d5 was 9b64c2d5, checked in by Joel Sherrill <joel.sherrill@…>, on Apr 15, 1998 at 12:10:03 AM

Per suggestion from Eric Norum, went from one initial extension set
to multiple. This lets the stack check extension be installed
at system initialization time and avoids the BSP having to
even know about its existence.

  • Property mode set to 100644
File size: 4.8 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/*
41 *  The original table from the application and our copy of it with
42 *  some changes.
43 */
44
45extern rtems_configuration_table Configuration;
46
47rtems_configuration_table  BSP_Configuration;
48
49rtems_cpu_table Cpu_table;
50
51char *rtems_progname;
52
53/*      Initialize whatever libc we are using
54 *      called from postdriver hook
55 */
56
57
58void bsp_libc_init()
59{
60    /*
61     *  The last parameter to RTEMS_Malloc_Initialize is the "chunk"
62     *  size which a multiple of will be requested on each sbrk()
63     *  call by malloc().  A value of 0 indicates that sbrk() should
64     *  not be called to extend the heap.
65     */
66
67    RTEMS_Malloc_Initialize(&HeapStart, sizeof(unsigned32) * (&HeapEnd - &HeapStart), 0);
68
69    /*
70     *  Init the RTEMS libio facility to provide UNIX-like system
71     *  calls for use by newlib (ie: provide __rtems_open, __rtems_close, etc)
72     *  Uses malloc() to get area for the iops, so must be after malloc init
73     */
74
75    rtems_libio_init();
76
77    /*
78     * Set up for the libc handling.
79     */
80
81    if (BSP_Configuration.ticks_per_timeslice > 0)
82        libc_init(1);                /* reentrant if possible */
83    else
84        libc_init(0);                /* non-reentrant */
85}
86
87/*
88 *  Function:   bsp_pretasking_hook
89 *
90 *  Description:
91 *      BSP pretasking hook.  Called just before drivers are initialized.
92 *      Used to setup libc and install any BSP extensions.
93 *
94 *  NOTES:
95 *      Must not use libc (to do io) from here, since drivers are
96 *      not yet initialized.
97 *
98 */
99 
100void
101bsp_pretasking_hook(void)
102{
103    bsp_libc_init();
104 
105#ifdef RTEMS_DEBUG
106    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
107#endif
108}
109
110/*
111 *  Use the shared bsp_postdriver_hook() implementation
112 */
113 
114void bsp_postdriver_hook(void);
115
116
117void bsp_start(void)
118{
119  /*
120     For real boards you need to setup the hardware
121     and need to copy the vector table from rom to ram.
122
123     Depending on the board this can ether be done from inside the rom
124     startup code, rtems startup code or here.
125   */
126   
127  /*
128   *  Allocate the memory for the RTEMS Work Space.  This can come from
129   *  a variety of places: hard coded address, malloc'ed from outside
130   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
131   *  typically done by stock BSPs) by subtracting the required amount
132   *  of work space from the last physical address on the CPU board.
133   */
134
135  /*
136   *  Copy the Configuration Table .. so we can change it
137   */
138
139  BSP_Configuration = Configuration;
140
141  /*
142   *  Need to "allocate" the memory for the RTEMS Workspace and
143   *  tell the RTEMS configuration where it is.  This memory is
144   *  not malloc'ed.  It is just "pulled from the air".
145   */
146
147  BSP_Configuration.work_space_start = (void *) &WorkSpaceStart ;
148  BSP_Configuration.work_space_size  = 
149    (unsigned32) &WorkSpaceEnd - 
150    (unsigned32) &WorkSpaceStart ;
151 
152  /*
153   *  initialize the CPU table for this BSP
154   */
155
156#if ( CPU_ALLOCATE_INTERRUPT_STACK == FALSE )
157  _CPU_Interrupt_stack_low = &CPU_Interrupt_stack_low ;
158  _CPU_Interrupt_stack_high = &CPU_Interrupt_stack_high ;
159
160  /* This isn't used anywhere */
161  Cpu_table.interrupt_stack_size = 
162    (unsigned32) (&CPU_Interrupt_stack_high) -
163    (unsigned32) (&CPU_Interrupt_stack_low) ;
164#endif
165
166
167  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
168
169  Cpu_table.predriver_hook = NULL;
170
171  Cpu_table.postdriver_hook = bsp_postdriver_hook;
172
173  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
174
175  Cpu_table.do_zero_of_workspace = TRUE;
176
177#if ( CPU_ALLOCATE_INTERRUPT_STACK == TRUE )
178  Cpu_table.interrupt_stack_size = 4096;
179#endif
180
181  Cpu_table.extra_mpci_receive_server_stack = 0;
182
183  /*
184   *  Don't forget the other CPU Table entries.
185   */
186
187  /*
188   * Tell libio how many fd's we want and allow it to tweak config
189   */
190
191  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
192}
Note: See TracBrowser for help on using the repository browser.