source: rtems/c/src/lib/libbsp/mips/p4000/startup/bspstart.c @ 8f95b5f

4.104.114.84.95
Last change on this file since 8f95b5f was 8f95b5f, checked in by Joel Sherrill <joel.sherrill@…>, on 03/30/98 at 14:01:19

Moved bsp_postdriver_hook() to a shared file and made it a common
component.

  • 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 *  COPYRIGHT (c) 1989-1998.
13 *  On-Line Applications Research Corporation (OAR).
14 *  Copyright assigned to U.S. Government, 1994.
15 *
16 *  The license and distribution terms for this file may be
17 *  found in the file LICENSE in this distribution or at
18 *  http://www.OARcorp.com/rtems/license.html.
19 *
20 *  $Id$
21 */
22
23/*
24 *  Rather than deleting this, it is commented out to (hopefully) help
25 *  the submitter send updates.
26 *
27 *  static char _sccsid[] = "@(#)bspstart.c 06/11/96     1.2\n";
28 */
29
30
31#include <bsp.h>
32#include <rtems/libio.h>
33 
34#include <libcsupport.h>
35 
36#include <string.h>
37 
38#ifdef STACK_CHECKER_ON
39#include <stackchk.h>
40#endif
41
42/*
43 *  The original table from the application and our copy of it with
44 *  some changes.
45 */
46
47extern rtems_configuration_table Configuration;
48
49rtems_configuration_table  BSP_Configuration;
50
51rtems_cpu_table Cpu_table;
52
53char *rtems_progname;
54
55/*      Initialize whatever libc we are using
56 *      called from postdriver hook
57 */
58
59#define LIBC_HEAP_SIZE (64 * 1024)
60
61void bsp_libc_init()
62{
63    extern int end;
64    rtems_unsigned32        heap_start;
65
66    heap_start = (rtems_unsigned32) &end;
67    if (heap_start & (CPU_ALIGNMENT-1))
68        heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
69
70    /*
71     *  The last parameter to RTEMS_Malloc_Initialize is the "chunk"
72     *  size which a multiple of will be requested on each sbrk()
73     *  call by malloc().  A value of 0 indicates that sbrk() should
74     *  not be called to extend the heap.
75     */
76
77    RTEMS_Malloc_Initialize((void *) heap_start, LIBC_HEAP_SIZE, 0);
78
79    /*
80     *  Init the RTEMS libio facility to provide UNIX-like system
81     *  calls for use by newlib (ie: provide __rtems_open, __rtems_close, etc)
82     *  Uses malloc() to get area for the iops, so must be after malloc init
83     */
84
85    rtems_libio_init();
86
87    /*
88     * Set up for the libc handling.
89     */
90
91    if (BSP_Configuration.ticks_per_timeslice > 0)
92        libc_init(1);                /* reentrant if possible */
93    else
94        libc_init(0);                /* non-reentrant */
95}
96
97/*
98 *  Function:   bsp_pretasking_hook
99 *  Created:    95/03/10
100 *
101 *  Description:
102 *      BSP pretasking hook.  Called just before drivers are initialized.
103 *      Used to setup libc and install any BSP extensions.
104 *
105 *  NOTES:
106 *      Must not use libc (to do io) from here, since drivers are
107 *      not yet initialized.
108 *
109 */
110 
111void
112bsp_pretasking_hook(void)
113{
114    bsp_libc_init();
115 
116#ifdef STACK_CHECKER_ON
117    /*
118     *  Initialize the stack bounds checker
119     *  We can either turn it on here or from the app.
120     */
121 
122    Stack_check_Initialize();
123#endif
124 
125#ifdef RTEMS_DEBUG
126    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
127#endif
128}
129 
130/*
131 *  Use the shared bsp_postdriver_hook() implementation
132 */
133 
134void bsp_postdriver_hook(void);
135
136extern int end; /* defined by linker */
137
138void bsp_start( void )
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   * Add 1 region for the RTEMS Malloc
156   */
157
158  BSP_Configuration.RTEMS_api_configuration->maximum_regions++;
159
160  /*
161   * Add 1 extension for newlib libc
162   */
163
164#ifdef RTEMS_NEWLIB
165    BSP_Configuration.maximum_extensions++;
166#endif
167
168  /*
169   * Add 1 extension for newlib libc
170   */
171
172#ifdef RTEMS_NEWLIB
173    BSP_Configuration.maximum_extensions++;
174#endif
175
176#ifdef STACK_CHECKER_ON
177    /*
178     * Add 1 extension for stack checker
179     */
180 
181    BSP_Configuration.maximum_extensions++;
182#endif
183
184  /*
185   * Tell libio how many fd's we want and allow it to tweak config
186   */
187
188  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
189
190  /*
191   *  Need to "allocate" the memory for the RTEMS Workspace and
192   *  tell the RTEMS configuration where it is.  This memory is
193   *  not malloc'ed.  It is just "pulled from the air".
194   */
195
196  BSP_Configuration.work_space_start = (void *)((unsigned64)((&end) + LIBC_HEAP_SIZE + 0x2000) & ~0x7);
197
198  /*
199   *  initialize the CPU table for this BSP
200   */
201
202  /*
203   *  we do not use the pretasking_hook
204   */
205
206  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
207
208  Cpu_table.predriver_hook = NULL;
209
210  Cpu_table.postdriver_hook = bsp_postdriver_hook;
211
212  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
213
214  Cpu_table.do_zero_of_workspace = TRUE;
215
216  Cpu_table.interrupt_stack_size = 4096;
217
218  Cpu_table.extra_mpci_receive_server_stack = 0;
219
220  /*
221   *  Don't forget the other CPU Table entries.
222   */
223
224}
Note: See TracBrowser for help on using the repository browser.