source: rtems/c/src/lib/libbsp/powerpc/papyrus/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.3 KB
RevLine 
[3235ad9]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 *
[5c491aef]12 *  Author:     Andrew Bray <andy@i-cubed.co.uk>
[3235ad9]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 *
[60b791ad]29 *  COPYRIGHT (c) 1989-1998.
[3235ad9]30 *  On-Line Applications Research Corporation (OAR).
[03f2154e]31 *  Copyright assigned to U.S. Government, 1994.
[3235ad9]32 *
[98e4ebf5]33 *  The license and distribution terms for this file may be
34 *  found in the file LICENSE in this distribution or at
[03f2154e]35 *  http://www.OARcorp.com/rtems/license.html.
[3235ad9]36 *
[eb5a7e07]37 *  $Id$
[3235ad9]38 */
39
40#include <bsp.h>
[3a4ae6c]41#include <rtems/libio.h>
42 
[3235ad9]43#include <libcsupport.h>
[3a4ae6c]44 
45#include <string.h>
46 
47#ifdef STACK_CHECKER_ON
48#include <stackchk.h>
49#endif
[3235ad9]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
[3a4ae6c]62char *rtems_progname;
63
[3235ad9]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
[3a4ae6c]86    /*
87     *  Init the RTEMS libio facility to provide UNIX-like system
[634e746]88     *  calls for use by newlib (ie: provide __rtems_open, __rtems_close, etc)
[3a4ae6c]89     *  Uses malloc() to get area for the iops, so must be after malloc init
90     */
91
92    rtems_libio_init();
93
[3235ad9]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
[3652ad35]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
[3235ad9]125    /*
126     *  Initialize the stack bounds checker
[3652ad35]127     *  We can either turn it on here or from the app.
[3235ad9]128     */
[3652ad35]129 
[3235ad9]130    Stack_check_Initialize();
131#endif
[3652ad35]132 
133#ifdef RTEMS_DEBUG
134    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
135#endif
[3235ad9]136}
[3652ad35]137 
[3235ad9]138
[3a4ae6c]139/*
[8f95b5f]140 *  Use the shared bsp_postdriver_hook() implementation
[3a4ae6c]141 */
142 
[8f95b5f]143void bsp_postdriver_hook(void);
144
[3a4ae6c]145
[e2a2ec60]146void bsp_start( void )
[3235ad9]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
[3a4ae6c]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
[3235ad9]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
[3652ad35]181  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
[3235ad9]182
[3652ad35]183  Cpu_table.predriver_hook = NULL;
[3235ad9]184
[3a4ae6c]185  Cpu_table.postdriver_hook = bsp_postdriver_hook;
[3235ad9]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
[8cbbe312]193  Cpu_table.extra_mpci_receive_server_stack = 0;
[3235ad9]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.