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

4.104.114.84.95
Last change on this file since 6ff7e2c was d57c04e, checked in by Joel Sherrill <joel.sherrill@…>, on 12/05/00 at 16:49:23

2000-12-05 Eric Valette <valette@…>

  • console/inch.c, console/keyboard.c, console/pc_keyb.c, console/vt.c, include/bsp.h: Correct incorrect interrupt level handling in new keyboard management code. Correct BSP_poll_char initialization routine.
  • start/start.S, startup/bspstart.c: Correct when the video is initialized.
  • timer/timer.c (Calibrate_1ms_loop): Address problem where this did not work correctly on all PC speeds. The new calibrate routine has been tested on Pentium 166, pentium II 200, pentium III 300 Mhz and does work as expected.
  • Property mode set to 100644
File size: 7.4 KB
Line 
1/*-------------------------------------------------------------------------+
2| This file contains the PC386 BSP startup package. It includes application,
3| board, and monitor specific initialization and configuration. The generic CPU
4| dependent initialization has been performed before this routine is invoked.
5+--------------------------------------------------------------------------+
6| (C) Copyright 1997 -
7| - NavIST Group - Real-Time Distributed Systems and Industrial Automation
8|
9| http://pandora.ist.utl.pt
10|
11| Instituto Superior Tecnico * Lisboa * PORTUGAL
12+--------------------------------------------------------------------------+
13| Disclaimer:
14|
15| This file is provided "AS IS" without warranty of any kind, either
16| expressed or implied.
17+--------------------------------------------------------------------------+
18| This code is based on:
19|   bspstart.c,v 1.8 1996/05/28 13:12:40 joel Exp - go32 BSP
20| With the following copyright notice:
21| **************************************************************************
22| *  COPYRIGHT (c) 1989-1999.
23| *  On-Line Applications Research Corporation (OAR).
24| *
25| *  The license and distribution terms for this file may be
26| *  found in found in the file LICENSE in this distribution or at
27| *  http://www.OARcorp.com/rtems/license.html.
28| **************************************************************************
29|
30|  $Id$
31+--------------------------------------------------------------------------*/
32
33
34#include <bsp.h>
35#include <rtems/libio.h>
36#include <rtems/libcsupport.h>
37#include <libcpu/cpuModel.h>
38
39/*-------------------------------------------------------------------------+
40| Global Variables
41+--------------------------------------------------------------------------*/
42extern rtems_unsigned32 _end;         /* End of BSS. Defined in 'linkcmds'. */
43/*
44 * Size of heap if it is 0 it will be dynamically defined by memory size,
45 * otherwise the value should be changed by binary patch
46 */
47rtems_unsigned32 _heap_size = 0;
48
49/* Size of stack used during initialization. Defined in 'start.s'.  */
50extern rtems_unsigned32 _stack_size;
51
52rtems_unsigned32 rtemsFreeMemStart;
53                         /* Address of start of free memory - should be updated
54                            after creating new partitions or regions.         */
55
56/* The original BSP configuration table from the application and our copy of it
57   with some changes. */
58
59extern rtems_configuration_table  Configuration;
60       rtems_configuration_table  BSP_Configuration;
61
62rtems_cpu_table Cpu_table;                     /* CPU configuration table.    */
63char            *rtems_progname;               /* Program name - from main(). */
64
65/*-------------------------------------------------------------------------+
66| External Prototypes
67+--------------------------------------------------------------------------*/
68extern void rtems_irq_mngt_init(void);
69void bsp_libc_init( void *, unsigned32, int );
70void bsp_postdriver_hook(void);
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  rtems_unsigned32 topAddr, val;
85  int i;
86 
87 
88  if (rtemsFreeMemStart & (CPU_ALIGNMENT - 1))  /* not aligned => align it */
89    rtemsFreeMemStart = (rtemsFreeMemStart+CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
90
91  if(_heap_size == 0)
92    {
93      /*
94       * We have to dynamically size memory. Memory size can be anything
95       * between 2M and 2048M.
96       * let us first write
97       */
98      for(i=2048; i>=2; i--)
99        {
100          topAddr = i*1024*1024 - 4;
101          *(volatile rtems_unsigned32 *)topAddr = topAddr;
102        }
103
104      for(i=2; i<=2048; i++)
105        {
106          topAddr = i*1024*1024 - 4;
107          val =  *(rtems_unsigned32 *)topAddr;
108          if(val != topAddr)
109            {
110              break;
111            }
112        }
113     
114      topAddr = (i-1)*1024*1024 - 4;
115
116      _heap_size = topAddr - rtemsFreeMemStart;
117    }
118     
119  bsp_libc_init((void *)rtemsFreeMemStart, _heap_size, 0);
120  rtemsFreeMemStart += _heap_size;           /* HEAP_SIZE  in KBytes */
121
122
123#ifdef RTEMS_DEBUG
124
125  rtems_debug_enable(RTEMS_DEBUG_ALL_MASK);
126
127#endif /* RTEMS_DEBUG */
128} /* bsp_pretasking_hook */
129 
130
131/*-------------------------------------------------------------------------+
132|         Function: bsp_start
133|      Description: Called before main is invoked.
134| Global Variables: None.
135|        Arguments: None.
136|          Returns: Nothing.
137+--------------------------------------------------------------------------*/
138void bsp_start_default( void )
139{
140  void Calibrate_loop_1ms(void);
141 
142  /*
143   * Calibrate variable for 1ms-loop (see timer.c)
144   */
145  Calibrate_loop_1ms();
146
147  rtemsFreeMemStart = (rtems_unsigned32)&_end + _stack_size;
148                                    /* set the value of start of free memory. */
149
150  /* If we don't have command line arguments set default program name. */
151
152  Cpu_table.pretasking_hook         = bsp_pretasking_hook; /* init libc, etc. */
153  Cpu_table.predriver_hook          = NULL;                /* use system's    */
154  Cpu_table.postdriver_hook         = bsp_postdriver_hook;
155  Cpu_table.idle_task               = NULL;
156                                          /* do not override system IDLE task */
157  Cpu_table.do_zero_of_workspace    = TRUE;
158  Cpu_table.interrupt_table_segment = get_ds();
159  Cpu_table.interrupt_table_offset  = (void *)Interrupt_descriptor_table;
160  Cpu_table.interrupt_stack_size    = CONFIGURE_INTERRUPT_STACK_MEMORY;
161  Cpu_table.extra_mpci_receive_server_stack = 0;
162
163  /* Place RTEMS workspace at beginning of free memory. */
164
165  if (rtemsFreeMemStart & (CPU_ALIGNMENT - 1))  /* not aligned => align it */
166    rtemsFreeMemStart = (rtemsFreeMemStart+CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
167
168  BSP_Configuration.work_space_start = (void *)rtemsFreeMemStart;
169  rtemsFreeMemStart += BSP_Configuration.work_space_size;
170
171  /*
172   * Init rtems interrupt management
173   */
174  rtems_irq_mngt_init();
175  /*
176   * Init rtems exceptions management
177   */
178  rtems_exception_init_mngt();
179  /*
180   *  The following information is very useful when debugging.
181   */
182
183#if 0
184  printk( "work_space_size = 0x%x\n", BSP_Configuration.work_space_size );
185  printk( "maximum_extensions = 0x%x\n", BSP_Configuration.maximum_extensions );
186  printk( "microseconds_per_tick = 0x%x\n",
187     BSP_Configuration.microseconds_per_tick );
188  printk( "ticks_per_timeslice = 0x%x\n",
189     BSP_Configuration.ticks_per_timeslice );
190  printk( "maximum_devices = 0x%x\n", BSP_Configuration.maximum_devices );
191  printk( "number_of_device_drivers = 0x%x\n",
192     BSP_Configuration.number_of_device_drivers );
193  printk( "Device_driver_table = 0x%x\n",
194     BSP_Configuration.Device_driver_table );
195
196  printk( "_heap_size = 0x%x\n", _heap_size );
197  printk( "_stack_size = 0x%x\n", _stack_size );
198  printk( "rtemsFreeMemStart = 0x%x\n", rtemsFreeMemStart );
199  printk( "work_space_start = 0x%x\n", BSP_Configuration.work_space_start );
200  printk( "work_space_size = 0x%x\n", BSP_Configuration.work_space_size );
201#endif
202} /* bsp_start */
203
204/*
205 *  By making this a weak alias for bsp_start_default, a brave soul
206 *  can override the actual bsp_start routine used.
207 */
208
209void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default")));
Note: See TracBrowser for help on using the repository browser.