source: rtems/c/src/lib/libbsp/mips/p4000/startup/bspstart.c @ 9b64c2d5

4.104.114.84.95
Last change on this file since 9b64c2d5 was 9b64c2d5, checked in by Joel Sherrill <joel.sherrill@…>, on 04/15/98 at 00:10:03

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.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 *  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/*
39 *  The original table from the application and our copy of it with
40 *  some changes.
41 */
42
43extern rtems_configuration_table Configuration;
44
45rtems_configuration_table  BSP_Configuration;
46
47rtems_cpu_table Cpu_table;
48
49char *rtems_progname;
50
51/*      Initialize whatever libc we are using
52 *      called from postdriver hook
53 */
54
55#define LIBC_HEAP_SIZE (64 * 1024)
56
57void bsp_libc_init()
58{
59    extern int end;
60    rtems_unsigned32        heap_start;
61
62    heap_start = (rtems_unsigned32) &end;
63    if (heap_start & (CPU_ALIGNMENT-1))
64        heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
65
66    /*
67     *  The last parameter to RTEMS_Malloc_Initialize is the "chunk"
68     *  size which a multiple of will be requested on each sbrk()
69     *  call by malloc().  A value of 0 indicates that sbrk() should
70     *  not be called to extend the heap.
71     */
72
73    RTEMS_Malloc_Initialize((void *) heap_start, LIBC_HEAP_SIZE, 0);
74
75    /*
76     *  Init the RTEMS libio facility to provide UNIX-like system
77     *  calls for use by newlib (ie: provide __rtems_open, __rtems_close, etc)
78     *  Uses malloc() to get area for the iops, so must be after malloc init
79     */
80
81    rtems_libio_init();
82
83    /*
84     * Set up for the libc handling.
85     */
86
87    if (BSP_Configuration.ticks_per_timeslice > 0)
88        libc_init(1);                /* reentrant if possible */
89    else
90        libc_init(0);                /* non-reentrant */
91}
92
93/*
94 *  Function:   bsp_pretasking_hook
95 *  Created:    95/03/10
96 *
97 *  Description:
98 *      BSP pretasking hook.  Called just before drivers are initialized.
99 *      Used to setup libc and install any BSP extensions.
100 *
101 *  NOTES:
102 *      Must not use libc (to do io) from here, since drivers are
103 *      not yet initialized.
104 *
105 */
106 
107void
108bsp_pretasking_hook(void)
109{
110    bsp_libc_init();
111 
112#ifdef RTEMS_DEBUG
113    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
114#endif
115}
116 
117/*
118 *  Use the shared bsp_postdriver_hook() implementation
119 */
120 
121void bsp_postdriver_hook(void);
122
123extern int end; /* defined by linker */
124
125void bsp_start( void )
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   * Tell libio how many fd's we want and allow it to tweak config
143   */
144
145  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
146
147  /*
148   *  Need to "allocate" the memory for the RTEMS Workspace and
149   *  tell the RTEMS configuration where it is.  This memory is
150   *  not malloc'ed.  It is just "pulled from the air".
151   */
152
153  BSP_Configuration.work_space_start = (void *)((unsigned64)((&end) + LIBC_HEAP_SIZE + 0x2000) & ~0x7);
154
155  /*
156   *  initialize the CPU table for this BSP
157   */
158
159  /*
160   *  we do not use the pretasking_hook
161   */
162
163  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
164
165  Cpu_table.predriver_hook = NULL;
166
167  Cpu_table.postdriver_hook = bsp_postdriver_hook;
168
169  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
170
171  Cpu_table.do_zero_of_workspace = TRUE;
172
173  Cpu_table.interrupt_stack_size = 4096;
174
175  Cpu_table.extra_mpci_receive_server_stack = 0;
176
177  /*
178   *  Don't forget the other CPU Table entries.
179   */
180
181}
Note: See TracBrowser for help on using the repository browser.