source: rtems/c/src/lib/libbsp/i386/pc386/startup/bspstart.c @ ab0df696

4.104.114.84.95
Last change on this file since ab0df696 was ab0df696, checked in by Joel Sherrill <joel.sherrill@…>, on 08/05/98 at 15:15:46

Automatic CPU type detection code from Eric Valette <valette@…>.
Enabled on the pc386.

  • Property mode set to 100644
File size: 6.6 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#include <libcpu/cpuModel.h>
41
42/*-------------------------------------------------------------------------+
43| Global Variables
44+--------------------------------------------------------------------------*/
45extern rtems_unsigned32 _end;           /* End of BSS. Defined in 'linkcmds'. */
46extern rtems_unsigned32 _heap_size;   /* Size of stack. Defined in 'start.s'. */
47extern rtems_unsigned32 _stack_size;  /* Size of heap. Defined in 'start.s'.  */
48
49rtems_unsigned32 rtemsFreeMemStart;
50                         /* Address of start of free memory - should be updated
51                            after creating new partitions or regions.         */
52
53/* The original BSP configuration table from the application and our copy of it
54   with some changes. */
55
56extern rtems_configuration_table  Configuration;
57       rtems_configuration_table  BSP_Configuration;
58
59rtems_cpu_table Cpu_table;                     /* CPU configuration table.    */
60char            *rtems_progname;               /* Program name - from main(). */
61
62extern void debugPollingGetChar();
63
64/*-------------------------------------------------------------------------+
65| External Prototypes
66+--------------------------------------------------------------------------*/
67extern void _exit(int);  /* define in exit.c */
68void bsp_libc_init( void *, unsigned32, int );
69void bsp_postdriver_hook(void);
70extern void rtems_irq_mngt_init();
71
72/*-------------------------------------------------------------------------+
73|         Function: bsp_pretasking_hook
74|      Description: BSP pretasking hook.  Called just before drivers are
75|                   initialized. Used to setup libc and install any BSP
76|                   extensions. NOTE: Must not use libc (to do io) from here,
77|                   since drivers are not yet initialized.
78| Global Variables: None.
79|        Arguments: None.
80|          Returns: Nothing.
81+--------------------------------------------------------------------------*/
82void bsp_pretasking_hook(void)
83{
84  if (rtemsFreeMemStart & (CPU_ALIGNMENT - 1))  /* not aligned => align it */
85    rtemsFreeMemStart = (rtemsFreeMemStart+CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
86
87  bsp_libc_init((void *)rtemsFreeMemStart, _heap_size, 0);
88  rtemsFreeMemStart += _heap_size;           /* HEAP_SIZE  in KBytes */
89
90
91#ifdef RTEMS_DEBUG
92
93  rtems_debug_enable(RTEMS_DEBUG_ALL_MASK);
94
95#endif /* RTEMS_DEBUG */
96} /* bsp_pretasking_hook */
97 
98
99/*-------------------------------------------------------------------------+
100|         Function: bsp_start
101|      Description: Called before main is invoked.
102| Global Variables: None.
103|        Arguments: None.
104|          Returns: Nothing.
105+--------------------------------------------------------------------------*/
106void bsp_start( void )
107{
108  rtemsFreeMemStart = (rtems_unsigned32)&_end + _heap_size + _stack_size;
109                                    /* set the value of start of free memory. */
110
111  /* If we don't have command line arguments set default program name. */
112
113  Cpu_table.pretasking_hook         = bsp_pretasking_hook; /* init libc, etc. */
114  Cpu_table.predriver_hook          = NULL;                /* use system's    */
115  Cpu_table.postdriver_hook         = bsp_postdriver_hook;
116  Cpu_table.idle_task               = NULL;
117                                          /* do not override system IDLE task */
118  Cpu_table.do_zero_of_workspace    = TRUE;
119  Cpu_table.interrupt_table_segment = get_ds();
120  Cpu_table.interrupt_table_offset  = (void *)Interrupt_descriptor_table;
121  Cpu_table.interrupt_stack_size    = 4096;
122  Cpu_table.extra_mpci_receive_server_stack = 0;
123
124  /* Place RTEMS workspace at beginning of free memory. */
125
126  if (rtemsFreeMemStart & (CPU_ALIGNMENT - 1))  /* not aligned => align it */
127    rtemsFreeMemStart = (rtemsFreeMemStart+CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
128
129  BSP_Configuration.work_space_start = (void *)rtemsFreeMemStart;
130  rtemsFreeMemStart += BSP_Configuration.work_space_size;
131
132  console_reserve_resources(&BSP_Configuration);
133
134  /*
135   * Init rtems_interrupt_management
136   */
137  rtems_irq_mngt_init();
138 
139  /*
140   *  The following information is very useful when debugging.
141   */
142
143#if 0
144  printk( "work_space_size = 0x%x\n", BSP_Configuration.work_space_size );
145  printk( "maximum_extensions = 0x%x\n", BSP_Configuration.maximum_extensions );
146  printk( "microseconds_per_tick = 0x%x\n",
147     BSP_Configuration.microseconds_per_tick );
148  printk( "ticks_per_timeslice = 0x%x\n",
149     BSP_Configuration.ticks_per_timeslice );
150  printk( "maximum_devices = 0x%x\n", BSP_Configuration.maximum_devices );
151  printk( "number_of_device_drivers = 0x%x\n",
152     BSP_Configuration.number_of_device_drivers );
153  printk( "Device_driver_table = 0x%x\n",
154     BSP_Configuration.Device_driver_table );
155
156  printk( "_heap_size = 0x%x\n", _heap_size );
157  printk( "_stack_size = 0x%x\n", _stack_size );
158  printk( "rtemsFreeMemStart = 0x%x\n", rtemsFreeMemStart );
159  printk( "work_space_start = 0x%x\n", BSP_Configuration.work_space_start );
160  printk( "work_space_size = 0x%x\n", BSP_Configuration.work_space_size );
161#endif
162} /* bsp_start */
Note: See TracBrowser for help on using the repository browser.