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

4.104.114.84.95
Last change on this file since 0ebbf66 was 0ebbf66, checked in by Joel Sherrill <joel.sherrill@…>, on 10/05/98 at 22:36:06

Large patch from Erik Ivanenko <erik.ivanenko@…> which
moves pieces of the pc386 bsp up to a shared level for all i386 BSPs
and modifies the i386ex BSP to use those shared pieces. Serial remote
debugging is included for both targets. Erik's notes:

There are several workarounds in it:

1) #define NEXT_GAS is hardcoded in pc386/start/start.s
2) #define NEXT_GAS is hardcoded in i386ex/start/start.s
3) #define NEW_GAS is hardcoded in pc386/start16.s
4) #undef assert and redeclare _assert hardcoded in console.c for

both pc386 and i386ex due to my egcs1.1b ~ newlib problem. Should have
modified t-rtems.cfg ( no time )

I've tested pc386 with both video and serial consoles and GDB remote.
All work fine, except that GDB acts weird. ( re: other posting)

I hope this will work for you. It took quite some time to locate the
autoconf error. The remainder was just grunt work.
Unfortunately, I think I've unwound the removal of the IBMPCInitVideo
stuff. Sorry. I REALLY can't spend more time... I've been at this
conversion to 4.0 locally and updating the release since Sept. 8th, and
have yet to compile my network driver.... This is as much as I can do
right now.

I look forward to the next patch to really test i368ex. I did make sure
that the sample tests worked for pc386.

  • Property mode set to 100644
File size: 7.3 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-1998.
23| *  On-Line Applications Research Corporation (OAR).
24| *  Copyright assigned to U.S. Government, 1994.
25| *
26| *  The license and distribution terms for this file may be
27| *  found in found in the file LICENSE in this distribution or at
28| *  http://www.OARcorp.com/rtems/license.html.
29| **************************************************************************
30|
31|  $Id$
32+--------------------------------------------------------------------------*/
33
34
35#include <bsp.h>
36#include <libcsupport.h>
37#include <rtems/libio.h>
38#include <libcpu/cpuModel.h>
39
40/*-------------------------------------------------------------------------+
41| Global Variables
42+--------------------------------------------------------------------------*/
43extern rtems_unsigned32 _end;         /* End of BSS. Defined in 'linkcmds'. */
44/*
45 * Size of heap if it is 0 it will be dynamically defined by memory size,
46 * otherwise the value should be changed by binary patch
47 */
48rtems_unsigned32 _heap_size = 0;
49
50/* Size of stack used during initialization. Defined in 'start.s'.  */
51extern rtems_unsigned32 _stack_size;
52
53rtems_unsigned32 rtemsFreeMemStart;
54                         /* Address of start of free memory - should be updated
55                            after creating new partitions or regions.         */
56
57/* The original BSP configuration table from the application and our copy of it
58   with some changes. */
59
60extern rtems_configuration_table  Configuration;
61       rtems_configuration_table  BSP_Configuration;
62
63rtems_cpu_table Cpu_table;                     /* CPU configuration table.    */
64char            *rtems_progname;               /* Program name - from main(). */
65
66/*-------------------------------------------------------------------------+
67| External Prototypes
68+--------------------------------------------------------------------------*/
69extern void rtems_irq_mngt_init(void);
70void bsp_libc_init( void *, unsigned32, int );
71void bsp_postdriver_hook(void);
72
73/*-------------------------------------------------------------------------+
74|         Function: bsp_pretasking_hook
75|      Description: BSP pretasking hook.  Called just before drivers are
76|                   initialized. Used to setup libc and install any BSP
77|                   extensions. NOTE: Must not use libc (to do io) from here,
78|                   since drivers are not yet initialized.
79| Global Variables: None.
80|        Arguments: None.
81|          Returns: Nothing.
82+--------------------------------------------------------------------------*/
83void bsp_pretasking_hook(void)
84{
85  rtems_unsigned32 topAddr, val;
86  int i;
87 
88 
89  if (rtemsFreeMemStart & (CPU_ALIGNMENT - 1))  /* not aligned => align it */
90    rtemsFreeMemStart = (rtemsFreeMemStart+CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
91
92  if(_heap_size == 0)
93    {
94      /*
95       * We have to dynamically size memory. Memory size can be anything
96       * between 2M and 2048M.
97       * let us first write
98       */
99      for(i=2048; i>=2; i--)
100        {
101          topAddr = i*1024*1024 - 4;
102          *(volatile rtems_unsigned32 *)topAddr = topAddr;
103        }
104
105      for(i=2; i<=2048; i++)
106        {
107          topAddr = i*1024*1024 - 4;
108          val =  *(rtems_unsigned32 *)topAddr;
109          if(val != topAddr)
110            {
111              break;
112            }
113        }
114     
115      topAddr = (i-1)*1024*1024 - 4;
116
117      _heap_size = topAddr - rtemsFreeMemStart;
118    }
119     
120  bsp_libc_init((void *)rtemsFreeMemStart, _heap_size, 0);
121  rtemsFreeMemStart += _heap_size;           /* HEAP_SIZE  in KBytes */
122
123
124#ifdef RTEMS_DEBUG
125
126  rtems_debug_enable(RTEMS_DEBUG_ALL_MASK);
127
128#endif /* RTEMS_DEBUG */
129} /* bsp_pretasking_hook */
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  /*
142   * Calibrate variable for 1ms-loop (see timer.c)
143   */
144  Calibrate_loop_1ms();
145
146  /*
147   * Initialize printk channel
148   */
149 
150  _IBMPC_initVideo();
151
152  rtemsFreeMemStart = (rtems_unsigned32)&_end + _stack_size;
153                                    /* set the value of start of free memory. */
154
155  /* If we don't have command line arguments set default program name. */
156
157  Cpu_table.pretasking_hook         = bsp_pretasking_hook; /* init libc, etc. */
158  Cpu_table.predriver_hook          = NULL;                /* use system's    */
159  Cpu_table.postdriver_hook         = bsp_postdriver_hook;
160  Cpu_table.idle_task               = NULL;
161                                          /* do not override system IDLE task */
162  Cpu_table.do_zero_of_workspace    = TRUE;
163  Cpu_table.interrupt_table_segment = get_ds();
164  Cpu_table.interrupt_table_offset  = (void *)Interrupt_descriptor_table;
165  Cpu_table.interrupt_stack_size    = 4096;
166  Cpu_table.extra_mpci_receive_server_stack = 0;
167
168  /* Place RTEMS workspace at beginning of free memory. */
169
170  if (rtemsFreeMemStart & (CPU_ALIGNMENT - 1))  /* not aligned => align it */
171    rtemsFreeMemStart = (rtemsFreeMemStart+CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
172
173  BSP_Configuration.work_space_start = (void *)rtemsFreeMemStart;
174  rtemsFreeMemStart += BSP_Configuration.work_space_size;
175
176  console_reserve_resources(&BSP_Configuration);
177
178  /*
179   * Init rtems interrupt management
180   */
181  rtems_irq_mngt_init();
182  /*
183   * Init rtems exceptions management
184   */
185  rtems_exception_init_mngt();
186  /*
187   *  The following information is very useful when debugging.
188   */
189
190#if 0
191  printk( "work_space_size = 0x%x\n", BSP_Configuration.work_space_size );
192  printk( "maximum_extensions = 0x%x\n", BSP_Configuration.maximum_extensions );
193  printk( "microseconds_per_tick = 0x%x\n",
194     BSP_Configuration.microseconds_per_tick );
195  printk( "ticks_per_timeslice = 0x%x\n",
196     BSP_Configuration.ticks_per_timeslice );
197  printk( "maximum_devices = 0x%x\n", BSP_Configuration.maximum_devices );
198  printk( "number_of_device_drivers = 0x%x\n",
199     BSP_Configuration.number_of_device_drivers );
200  printk( "Device_driver_table = 0x%x\n",
201     BSP_Configuration.Device_driver_table );
202
203  printk( "_heap_size = 0x%x\n", _heap_size );
204  printk( "_stack_size = 0x%x\n", _stack_size );
205  printk( "rtemsFreeMemStart = 0x%x\n", rtemsFreeMemStart );
206  printk( "work_space_start = 0x%x\n", BSP_Configuration.work_space_start );
207  printk( "work_space_size = 0x%x\n", BSP_Configuration.work_space_size );
208#endif
209} /* bsp_start */
Note: See TracBrowser for help on using the repository browser.