source: rtems/c/src/lib/libbsp/powerpc/papyrus/startup/bspstart.c @ ab97da95

4.104.114.84.95
Last change on this file since ab97da95 was 3b89891, checked in by Joel Sherrill <joel.sherrill@…>, on 04/14/98 at 20:54:26

Now accounts for region used by RTEMS malloc and extension used
by newlib.

  • Property mode set to 100644
File size: 5.4 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 *  Author:     Andrew Bray <andy@i-cubed.co.uk>
13 *
14 *  COPYRIGHT (c) 1995 by i-cubed ltd.
15 *
16 *  To anyone who acknowledges that this file is provided "AS IS"
17 *  without any express or implied warranty:
18 *      permission to use, copy, modify, and distribute this file
19 *      for any purpose is hereby granted without fee, provided that
20 *      the above copyright notice and this notice appears in all
21 *      copies, and that the name of i-cubed limited not be used in
22 *      advertising or publicity pertaining to distribution of the
23 *      software without specific, written prior permission.
24 *      i-cubed limited makes no representations about the suitability
25 *      of this software for any purpose.
26 *
27 *  Derived from c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c:
28 *
29 *  COPYRIGHT (c) 1989-1998.
30 *  On-Line Applications Research Corporation (OAR).
31 *  Copyright assigned to U.S. Government, 1994.
32 *
33 *  The license and distribution terms for this file may be
34 *  found in the file LICENSE in this distribution or at
35 *  http://www.OARcorp.com/rtems/license.html.
36 *
37 *  $Id$
38 */
39
40#include <bsp.h>
41#include <rtems/libio.h>
42 
43#include <libcsupport.h>
44 
45#include <string.h>
46 
47#ifdef STACK_CHECKER_ON
48#include <stackchk.h>
49#endif
50
51/*
52 *  The original table from the application and our copy of it with
53 *  some changes.
54 */
55
56extern rtems_configuration_table Configuration;
57
58rtems_configuration_table  BSP_Configuration;
59
60rtems_cpu_table Cpu_table;
61
62char *rtems_progname;
63
64/*      Initialize whatever libc we are using
65 *      called from postdriver hook
66 */
67
68void bsp_libc_init()
69{
70    extern int _end;
71    rtems_unsigned32        heap_start;
72
73    heap_start = (rtems_unsigned32) &_end;
74    if (heap_start & (CPU_ALIGNMENT-1))
75        heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
76
77    /*
78     *  The last parameter to RTEMS_Malloc_Initialize is the "chunk"
79     *  size which a multiple of will be requested on each sbrk()
80     *  call by malloc().  A value of 0 indicates that sbrk() should
81     *  not be called to extend the heap.
82     */
83
84    RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0);
85
86    /*
87     *  Init the RTEMS libio facility to provide UNIX-like system
88     *  calls for use by newlib (ie: provide __rtems_open, __rtems_close, etc)
89     *  Uses malloc() to get area for the iops, so must be after malloc init
90     */
91
92    rtems_libio_init();
93
94    /*
95     * Set up for the libc handling.
96     */
97
98    if (BSP_Configuration.ticks_per_timeslice > 0)
99        libc_init(1);                /* reentrant if possible */
100    else
101        libc_init(0);                /* non-reentrant */
102
103}
104
105/*
106 *  Function:   bsp_pretasking_hook
107 *  Created:    95/03/10
108 *
109 *  Description:
110 *      BSP pretasking hook.  Called just before drivers are initialized.
111 *      Used to setup libc and install any BSP extensions.
112 *
113 *  NOTES:
114 *      Must not use libc (to do io) from here, since drivers are
115 *      not yet initialized.
116 *
117 */
118 
119void
120bsp_pretasking_hook(void)
121{
122    bsp_libc_init();
123 
124#ifdef STACK_CHECKER_ON
125    /*
126     *  Initialize the stack bounds checker
127     *  We can either turn it on here or from the app.
128     */
129 
130    Stack_check_Initialize();
131#endif
132 
133#ifdef RTEMS_DEBUG
134    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
135#endif
136}
137 
138
139/*
140 *  Use the shared bsp_postdriver_hook() implementation
141 */
142 
143void bsp_postdriver_hook(void);
144
145
146void bsp_start( void )
147{
148  /*
149   *  Allocate the memory for the RTEMS Work Space.  This can come from
150   *  a variety of places: hard coded address, malloc'ed from outside
151   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
152   *  typically done by stock BSPs) by subtracting the required amount
153   *  of work space from the last physical address on the CPU board.
154   */
155
156  /*
157   *  Copy the Configuration Table .. so we can change it
158   */
159
160  BSP_Configuration = Configuration;
161
162  /*
163   * Add 1 extension for stack checker
164   */
165
166#ifdef STACK_CHECKER_ON
167    BSP_Configuration.maximum_extensions++;
168#endif
169
170  /*
171   * Tell libio how many fd's we want and allow it to tweak config
172   */
173
174  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
175
176  /*
177   *  Need to "allocate" the memory for the RTEMS Workspace and
178   *  tell the RTEMS configuration where it is.  This memory is
179   *  not malloc'ed.  It is just "pulled from the air".
180   */
181
182  BSP_Configuration.work_space_start = (void *)
183      RAM_END - BSP_Configuration.work_space_size;
184
185  /*
186   *  initialize the CPU table for this BSP
187   */
188
189  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
190
191  Cpu_table.predriver_hook = NULL;
192
193  Cpu_table.postdriver_hook = bsp_postdriver_hook;
194
195  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
196
197  Cpu_table.do_zero_of_workspace = TRUE;
198
199  Cpu_table.interrupt_stack_size = 4 * 1024;
200
201  Cpu_table.extra_mpci_receive_server_stack = 0;
202
203  /*
204   *  Don't forget the other CPU Table entries.
205   */
206
207  Cpu_table.clicks_per_usec = 10;
208
209  Cpu_table.serial_per_sec = 10000000;
210
211  Cpu_table.serial_external_clock = 1;
212
213  Cpu_table.serial_xon_xoff = 0;
214
215  Cpu_table.serial_cts_rts = 1;
216
217  Cpu_table.serial_rate = 9600;
218
219  Cpu_table.timer_average_overhead = 2;
220
221  Cpu_table.timer_least_valid = 3;
222}
Note: See TracBrowser for help on using the repository browser.