source: rtems/c/src/lib/libbsp/i386/i386ex/startup/bspstart.c @ 92e15e0

4.104.114.84.95
Last change on this file since 92e15e0 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: 4.1 KB
Line 
1/*
2 *  This routine starts the application.  It includes application,
3 *  board, and monitor specific initialization and configuration.
4 *  The generic CPU dependent initialization has been performed
5 *  before this routine is invoked.
6 *
7 *  COPYRIGHT (c) 1989-1998.
8 *  On-Line Applications Research Corporation (OAR).
9 *  Copyright assigned to U.S. Government, 1994.
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.OARcorp.com/rtems/license.html.
14 *
15 *  Ported to the i386ex and submitted by:
16 *
17 *    Erik Ivanenko
18 *    University of Toronto
19 *    erik.ivanenko@utoronto.ca
20 * 
21 *  $Id$
22 */
23
24#include <bsp.h>
25#include <rtems/libio.h>
26 
27#include <libcsupport.h>
28
29#ifdef STACK_CHECKER_ON
30#include <stackchk.h>
31#endif
32
33/*
34 *  The original table from the application and our copy of it with
35 *  some changes.
36 */
37
38extern rtems_configuration_table  Configuration;
39rtems_configuration_table  BSP_Configuration;
40
41rtems_cpu_table Cpu_table;
42
43/*
44 *  Tells us where to put the workspace in case remote debugger is present.
45 */
46
47extern rtems_unsigned32  rdb_start;
48
49/*
50 *  bsp_libc_init
51 *
52 *  Initialize whatever libc we are using called from bsp_postdriver_hook.
53 */
54
55 
56void bsp_libc_init()
57{
58    extern int heap_bottom;
59    rtems_unsigned32 heap_start;
60    rtems_unsigned32 heap_size;
61
62    heap_start = (rtems_unsigned32) &heap_bottom;
63    if (heap_start & (CPU_ALIGNMENT-1))
64      heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
65
66    heap_size = BSP_Configuration.work_space_start -(void *) heap_start ;
67    heap_size &= 0xfffffff0;  /* keep it as a multiple of 16 bytes */
68
69    heap_size &= 0xfffffff0;  /* keep it as a multiple of 16 bytes */
70    RTEMS_Malloc_Initialize((void *) heap_start, heap_size, 0);
71
72    /*
73     *  Init the RTEMS libio facility to provide UNIX-like system
74     *  calls for use by newlib (ie: provide __rtems_open, __rtems_close, etc)
75     *  Uses malloc() to get area for the iops, so must be after malloc init
76     */
77 
78    rtems_libio_init();
79 
80    /*
81     * Set up for the libc handling.
82     */
83 
84    if (BSP_Configuration.ticks_per_timeslice > 0)
85        libc_init(1);                /* reentrant if possible */
86    else
87        libc_init(0);                /* non-reentrant */
88}
89
90/*
91 *  Function:   bsp_pretasking_hook
92 *  Created:    95/03/10
93 *
94 *  Description:
95 *      BSP pretasking hook.  Called just before drivers are initialized.
96 *      Used to setup libc and install any BSP extensions.
97 *
98 *  NOTES:
99 *      Must not use libc (to do io) from here, since drivers are
100 *      not yet initialized.
101 *
102 */
103 
104void
105bsp_pretasking_hook(void)
106{
107    bsp_libc_init();
108 
109#ifdef STACK_CHECKER_ON
110    /*
111     *  Initialize the stack bounds checker
112     *  We can either turn it on here or from the app.
113     */
114 
115    Stack_check_Initialize();
116#endif
117
118#ifdef RTEMS_DEBUG
119    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
120#endif
121}
122
123
124/*
125 *  Use the shared bsp_postdriver_hook() implementation
126 */
127 
128void bsp_postdriver_hook(void);
129
130void bsp_start( void )
131{
132  /*
133   *  we do not use the pretasking_hook.
134   */
135
136  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
137 
138  Cpu_table.predriver_hook = NULL;
139 
140  Cpu_table.postdriver_hook = bsp_postdriver_hook;
141 
142  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
143 
144  Cpu_table.do_zero_of_workspace = TRUE;
145 
146  Cpu_table.interrupt_table_segment = get_ds();
147 
148  Cpu_table.interrupt_table_offset = (void *)Interrupt_descriptor_table;
149 
150  Cpu_table.interrupt_stack_size = 4096;  /* STACK_MINIMUM_SIZE */
151 
152  Cpu_table.extra_mpci_receive_server_stack = 0;
153
154  /*
155   *  Copy the table
156   */
157
158  BSP_Configuration = Configuration;
159
160#if defined(RTEMS_POSIX_API)
161  BSP_Configuration.work_space_size *= 3;
162#endif
163
164  BSP_Configuration.work_space_start = (void *)
165     RAM_END - BSP_Configuration.work_space_size;
166
167  /*
168   *  Account for the console's resources
169   */
170
171  /*   console_reserve_resources( &BSP_Configuration ); */
172
173
174  /*
175   * Tell libio how many fd's we want and allow it to tweak config
176   */
177
178  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
179
180}
Note: See TracBrowser for help on using the repository browser.