source: rtems/c/src/lib/libbsp/i386/pc386/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 Apr 15, 1998 at 12:10:03 AM

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: 6.8 KB
Line 
1/*-------------------------------------------------------------------------+
2| bspstart.c v1.1 - PC386 BSP - 1997/08/07
3+--------------------------------------------------------------------------+
4| This file contains the PC386 BSP startup package. It includes application,
5| board, and monitor specific initialization and configuration. The generic CPU
6| dependent initialization has been performed before this routine is invoked.
7+--------------------------------------------------------------------------+
8| (C) Copyright 1997 -
9| - NavIST Group - Real-Time Distributed Systems and Industrial Automation
10|
11| http://pandora.ist.utl.pt
12|
13| Instituto Superior Tecnico * Lisboa * PORTUGAL
14+--------------------------------------------------------------------------+
15| Disclaimer:
16|
17| This file is provided "AS IS" without warranty of any kind, either
18| expressed or implied.
19+--------------------------------------------------------------------------+
20| This code is based on:
21|   bspstart.c,v 1.8 1996/05/28 13:12:40 joel Exp - go32 BSP
22| With the following copyright notice:
23| **************************************************************************
24| *  COPYRIGHT (c) 1989-1998.
25| *  On-Line Applications Research Corporation (OAR).
26| *  Copyright assigned to U.S. Government, 1994.
27| *
28| *  The license and distribution terms for this file may be
29| *  found in found in the file LICENSE in this distribution or at
30| *  http://www.OARcorp.com/rtems/license.html.
31| **************************************************************************
32|
33|  $Id$
34+--------------------------------------------------------------------------*/
35
36
37#include <bsp.h>
38#include <libcsupport.h>
39#include <rtems/libio.h>
40 
41/*-------------------------------------------------------------------------+
42| Global Variables
43+--------------------------------------------------------------------------*/
44#ifdef RTEMS_SMALL_MEMORY
45extern rtems_unsigned32 _end;           /* End of BSS. Defined in 'linkcmds'. */
46
47rtems_unsigned32 rtemsFreeMemStart = (rtems_unsigned32)&_end;
48                         /* Address of start of free memory - should be updated
49                            after creating new partitions or regions.         */
50#else
51rtems_unsigned32 rtemsFreeMemStart = RAM_START;
52                                             /* RAM_START defined in 'bsp.h'. */
53#endif /* RTEMS_SMALL_MEMORY */
54
55/* The original BSP configuration table from the application and our copy of it
56   with some changes. */
57
58extern rtems_configuration_table  Configuration;
59       rtems_configuration_table  BSP_Configuration;
60
61rtems_cpu_table Cpu_table;                     /* CPU configuration table.    */
62char            *rtems_progname;               /* Program name - from main(). */
63
64
65/*-------------------------------------------------------------------------+
66| External Prototypes
67+--------------------------------------------------------------------------*/
68extern void _exit(int);  /* define in exit.c */
69
70/*-------------------------------------------------------------------------+
71|         Function: bsp_libc_init
72|      Description: Initialize whatever libc we are using. Called from
73|                   pretasking hook.
74| Global Variables: rtemsFreeMemStart.
75|        Arguments: None.
76|          Returns: Nothing.
77+--------------------------------------------------------------------------*/
78static void
79bsp_libc_init(void)
80{
81  if (rtemsFreeMemStart & (CPU_ALIGNMENT - 1))  /* not aligned => align it */
82    rtemsFreeMemStart = (rtemsFreeMemStart+CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
83
84  RTEMS_Malloc_Initialize((void *)rtemsFreeMemStart, HEAP_SIZE << 10, 0);
85  rtemsFreeMemStart += HEAP_SIZE << 10;           /* HEAP_SIZE is in KBytes */
86
87  /* Init the RTEMS libio facility to provide UNIX-like system calls for use by
88     newlib (ie: provide __rtems_open, __rtems_close, etc). Uses malloc()
89     to get area for the iops, so must be after malloc initialization. */
90
91  rtems_libio_init();
92
93  /* Set up for the libc handling. */
94
95  if (BSP_Configuration.ticks_per_timeslice > 0)
96    libc_init(1); /* reentrant if possible */
97  else
98    libc_init(0); /* non-reentrant         */
99} /* bsp_libc_init */
100
101 
102/*-------------------------------------------------------------------------+
103|         Function: bsp_pretasking_hook
104|      Description: BSP pretasking hook.  Called just before drivers are
105|                   initialized. Used to setup libc and install any BSP
106|                   extensions. NOTE: Must not use libc (to do io) from here,
107|                   since drivers are not yet initialized.
108| Global Variables: None.
109|        Arguments: None.
110|          Returns: Nothing.
111+--------------------------------------------------------------------------*/
112void
113bsp_pretasking_hook(void)
114{
115  bsp_libc_init();
116
117#ifdef RTEMS_DEBUG
118
119  rtems_debug_enable(RTEMS_DEBUG_ALL_MASK);
120
121#endif /* RTEMS_DEBUG */
122} /* bsp_pretasking_hook */
123 
124
125/*
126 *  Use the shared bsp_postdriver_hook() implementation
127 */
128 
129void bsp_postdriver_hook(void);
130
131
132/*-------------------------------------------------------------------------+
133|         Function: bsp_start
134|      Description: Called before main is invoked.
135| Global Variables: None.
136|        Arguments: None.
137|          Returns: Nothing.
138+--------------------------------------------------------------------------*/
139void bsp_start( void )
140{
141  /* If we don't have command line arguments set default program name. */
142
143  Cpu_table.pretasking_hook         = bsp_pretasking_hook; /* init libc, etc. */
144  Cpu_table.predriver_hook          = NULL;                /* use system's    */
145  Cpu_table.postdriver_hook         = bsp_postdriver_hook;
146  Cpu_table.idle_task               = NULL;
147                                          /* do not override system IDLE task */
148  Cpu_table.do_zero_of_workspace    = TRUE;
149  Cpu_table.interrupt_table_segment = get_ds();
150  Cpu_table.interrupt_table_offset  = (void *)Interrupt_descriptor_table;
151  Cpu_table.interrupt_stack_size    = 4096;
152  Cpu_table.extra_mpci_receive_server_stack = 0;
153
154  /* Copy user's table and make necessary adjustments.              */
155
156  BSP_Configuration = Configuration;
157
158  /* Place RTEMS workspace at top of physical RAM (RAM_END defined in 'bsp.h' */
159
160  BSP_Configuration.work_space_start =
161                          (void *)(RAM_END - BSP_Configuration.work_space_size);
162
163  /* Tell libio how many fd's we want and allow it to tweak config. */
164
165  rtems_libio_config(&BSP_Configuration, BSP_LIBIO_MAX_FDS);
166
167#if 0
168  rtems_initialize_executive(&BSP_Configuration, &Cpu_table);
169  /* does not return */
170
171  /*-------------------------------------------------------------------------+
172  | We only return here if the executive has finished. This happens when the
173  | task has called exit(). We will then call _exit() which is part of the bsp.
174  +--------------------------------------------------------------------------*/
175
176  for (;;)
177    _exit(0);
178
179  /* no cleanup necessary for PC386 */
180
181  return 0;
182#endif
183} /* bsp_start */
Note: See TracBrowser for help on using the repository browser.