source: rtems/c/src/lib/libbsp/i386/force386/startup/bspstart.c @ 3b89891

4.104.114.84.95
Last change on this file since 3b89891 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: 3.8 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#include <bsp.h>
24#include <rtems/libio.h>
25
26#include <libcsupport.h>
27
28#ifdef STACK_CHECKER_ON
29#include <stackchk.h>
30#endif
31
32/*
33 *  The original table from the application and our copy of it with
34 *  some changes.
35 */
36
37extern rtems_configuration_table  Configuration;
38rtems_configuration_table  BSP_Configuration;
39
40rtems_cpu_table Cpu_table;
41
42char *rtems_progname;
43
44/*      Initialize whatever libc we are using
45 *      called from postdriver hook
46 */
47
48void bsp_libc_init()
49{
50    extern int end;
51    rtems_unsigned32        heap_start;
52
53    heap_start = (rtems_unsigned32) &end;
54    if (heap_start & (CPU_ALIGNMENT-1))
55        heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
56
57    RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0);
58
59    /*
60     *  Init the RTEMS libio facility to provide UNIX-like system
61     *  calls for use by newlib (ie: provide __rtems_open, __rtems_close, etc)
62     *  Uses malloc() to get area for the iops, so must be after malloc init
63     */
64
65    rtems_libio_init();
66
67    /*
68     * Set up for the libc handling.
69     */
70
71    if (BSP_Configuration.ticks_per_timeslice > 0)
72        libc_init(1);                /* reentrant if possible */
73    else
74        libc_init(0);                /* non-reentrant */
75}
76
77/*
78 *  Function:   bsp_pretasking_hook
79 *  Created:    95/03/10
80 *
81 *  Description:
82 *      BSP pretasking hook.  Called just before drivers are initialized.
83 *      Used to setup libc and install any BSP extensions.
84 *
85 *  NOTES:
86 *      Must not use libc (to do io) from here, since drivers are
87 *      not yet initialized.
88 *
89 */
90 
91void
92bsp_pretasking_hook(void)
93{
94    bsp_libc_init();
95 
96#ifdef STACK_CHECKER_ON
97    /*
98     *  Initialize the stack bounds checker
99     *  We can either turn it on here or from the app.
100     */
101 
102    Stack_check_Initialize();
103#endif
104 
105#ifdef RTEMS_DEBUG
106    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
107#endif
108}
109 
110
111/*
112 *  Use the shared bsp_postdriver_hook() implementation
113 */
114 
115void bsp_postdriver_hook(void);
116
117void bsp_start( void )
118{
119 
120  /*
121   *  FORCE documentation incorrectly states that the bus request
122   *  level is initialized to 3.  It is actually initialized by
123   *  FORCEbug to 0.
124   */
125
126  outport_byte( 0x00, 0x3f );      /* resets VMEbus request level */
127
128  /*
129   *  we do not use the pretasking_hook.
130   */
131
132  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
133
134  Cpu_table.predriver_hook = NULL;
135
136  Cpu_table.postdriver_hook = bsp_postdriver_hook;
137
138  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
139
140  Cpu_table.do_zero_of_workspace = TRUE;
141
142  Cpu_table.interrupt_table_segment = get_ds();
143
144  Cpu_table.interrupt_table_offset = (void *)Interrupt_descriptor_table;
145
146  Cpu_table.interrupt_stack_size = 4096;
147
148  Cpu_table.extra_mpci_receive_server_stack = 0;
149
150  /*
151   *  Copy the table
152   */
153
154  BSP_Configuration = Configuration;
155
156  BSP_Configuration.work_space_start = (void *)
157     RAM_END - BSP_Configuration.work_space_size;
158
159  /*
160   * Add another extension if using the stack checker
161   */
162
163#ifdef STACK_CHECKER_ON
164    BSP_Configuration.maximum_extensions++;
165#endif
166
167  /*
168   * Tell libio how many fd's we want and allow it to tweak config
169   */
170
171  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
172}
Note: See TracBrowser for help on using the repository browser.