source: rtems/c/src/lib/libbsp/i386/i386ex/startup/bspstart.c @ 752cd8f

4.104.114.84.95
Last change on this file since 752cd8f was 752cd8f, checked in by Joel Sherrill <joel.sherrill@…>, on 10/15/96 at 20:57:04

initial version from Erik

  • Property mode set to 100644
File size: 3.4 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, 1990, 1991, 1992, 1993, 1994.
13 *  On-Line Applications Research Corporation (OAR).
14 *  All rights assigned to U.S. Government, 1994.
15 *
16 *  This material may be reproduced by or for the U.S. Government pursuant
17 *  to the copyright license under the clause at DFARS 252.227-7013.  This
18 *  notice must appear in all copies of this file and its derivatives.
19 *
20 *  $Id$
21 */
22
23#include <rtems.h>
24#include <bsp.h>
25#include <libcsupport.h>
26
27#include <stackchk.h>
28
29#include <stdio.h>
30extern void outbyte(char);
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
42/*      Initialize whatever libc we are using
43 *      called from postdriver hook
44 */
45
46void bsp_libc_init()
47{
48    extern int end;
49    rtems_unsigned32        heap_start;
50
51    heap_start = (rtems_unsigned32) &end;
52    if (heap_start & (CPU_ALIGNMENT-1))
53        heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
54
55    RTEMS_Malloc_Initialize((void *) heap_start, 64 * 1024, 0);
56
57    /*
58     * Set up for the libc handling.
59     */
60
61    if (BSP_Configuration.ticks_per_timeslice > 0)
62        libc_init(1);                /* reentrant if possible */
63    else
64        libc_init(0);                /* non-reentrant */
65
66    /*
67     *  Initialize the stack bounds checker
68     */
69
70#ifdef STACK_CHECKER_ON
71    Stack_check_Initialize();
72#endif
73
74}
75extern char inbyte(void);
76extern void outbyte(char);
77
78int bsp_start(
79  int argc,
80  char **argv,
81  char **environp
82)
83{
84#ifdef PRINTON   
85
86  outbyte('a');
87  outbyte('b');
88  outbyte('c');
89  outbyte ('S');
90
91#endif
92
93  /*
94   *  we do not use the pretasking_hook.
95   */
96
97  Cpu_table.pretasking_hook = NULL;
98
99  Cpu_table.predriver_hook = bsp_libc_init;  /* RTEMS resources available */
100
101  Cpu_table.postdriver_hook = NULL;   /* Call our main() for constructors */
102
103  Cpu_table.idle_task = NULL;  /* do not override system IDLE task */
104
105  Cpu_table.do_zero_of_workspace = TRUE;
106
107  Cpu_table.interrupt_table_segment = get_ds();
108
109  Cpu_table.interrupt_table_offset = (void *)Interrupt_descriptor_table;
110
111  Cpu_table.interrupt_stack_size = 4096;
112
113  Cpu_table.extra_system_initialization_stack = 0;
114
115  /*
116   *  Copy the table
117   */
118
119  BSP_Configuration = Configuration;
120
121  BSP_Configuration.work_space_start = (void *)
122     RAM_END - BSP_Configuration.work_space_size;
123
124 
125
126#ifdef SPRINTON
127  sprintf( x_buffer, "ram end : %u, work_space_size: %d\n",
128           RAM_END ,  BSP_Configuration.work_space_size );
129  do {
130    outbyte ( x_buffer[i] );
131  } while ( x_buffer[i++] != '\n');
132#endif
133
134  /*
135   * Add 1 region for Malloc in libc_low
136   */
137
138  BSP_Configuration.maximum_regions++;
139
140  /*
141   * Add 1 extension for newlib libc
142   */
143
144#ifdef RTEMS_NEWLIB
145    BSP_Configuration.maximum_extensions++;
146#endif
147
148  /*
149   * Add another extension if using the stack checker
150   */
151
152#ifdef STACK_CHECKER_ON
153    BSP_Configuration.maximum_extensions++;
154#endif
155
156  rtems_initialize_executive( &BSP_Configuration, &Cpu_table );
157  /* does not return */
158  /* no cleanup necessary for Force CPU-386 */
159  for (;;);  /* was return 0 to go to the debug monitor */
160}
Note: See TracBrowser for help on using the repository browser.