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

4.104.114.84.9
Last change on this file since c244a9ee was c244a9ee, checked in by Joel Sherrill <joel.sherrill@…>, on Apr 14, 1998 at 9:32:12 PM

Stack checker extension now accounted for in confdefs.h

  • Property mode set to 100644
File size: 5.3 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   * Tell libio how many fd's we want and allow it to tweak config
164   */
165
166  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
167
168  /*
169   *  Need to "allocate" the memory for the RTEMS Workspace and
170   *  tell the RTEMS configuration where it is.  This memory is
171   *  not malloc'ed.  It is just "pulled from the air".
172   */
173
174  BSP_Configuration.work_space_start = (void *)
175      RAM_END - BSP_Configuration.work_space_size;
176
177  /*
178   *  initialize the CPU table for this BSP
179   */
180
181  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
182
183  Cpu_table.predriver_hook = NULL;
184
185  Cpu_table.postdriver_hook = bsp_postdriver_hook;
186
187  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
188
189  Cpu_table.do_zero_of_workspace = TRUE;
190
191  Cpu_table.interrupt_stack_size = 4 * 1024;
192
193  Cpu_table.extra_mpci_receive_server_stack = 0;
194
195  /*
196   *  Don't forget the other CPU Table entries.
197   */
198
199  Cpu_table.clicks_per_usec = 10;
200
201  Cpu_table.serial_per_sec = 10000000;
202
203  Cpu_table.serial_external_clock = 1;
204
205  Cpu_table.serial_xon_xoff = 0;
206
207  Cpu_table.serial_cts_rts = 1;
208
209  Cpu_table.serial_rate = 9600;
210
211  Cpu_table.timer_average_overhead = 2;
212
213  Cpu_table.timer_least_valid = 3;
214}
Note: See TracBrowser for help on using the repository browser.