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

4.104.114.84.95
Last change on this file since 8a496e46 was 8a496e46, checked in by Joel Sherrill <joel.sherrill@…>, on 09/23/98 at 13:20:34

Patch from Aleksey (Quality Quorum <qqi@…>):

  1. Finally fixes raw interrupts for pc386
  2. Makes some minor cleanup in console and startup
  3. Makes rtems_termios_dequeue_characters() to return count of outstanding chars - it allows to simplify console isrs a little bit.
  4. pc386 uart modified to be friendlier to termios parameter changes, to have minor performance improvement and to take advantage of of above termios modification.
  • 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  _IBMPC_initVideo();
150
151  rtemsFreeMemStart = (rtems_unsigned32)&_end + _stack_size;
152                                    /* set the value of start of free memory. */
153
154  /* If we don't have command line arguments set default program name. */
155
156  Cpu_table.pretasking_hook         = bsp_pretasking_hook; /* init libc, etc. */
157  Cpu_table.predriver_hook          = NULL;                /* use system's    */
158  Cpu_table.postdriver_hook         = bsp_postdriver_hook;
159  Cpu_table.idle_task               = NULL;
160                                          /* do not override system IDLE task */
161  Cpu_table.do_zero_of_workspace    = TRUE;
162  Cpu_table.interrupt_table_segment = get_ds();
163  Cpu_table.interrupt_table_offset  = (void *)Interrupt_descriptor_table;
164  Cpu_table.interrupt_stack_size    = 4096;
165  Cpu_table.extra_mpci_receive_server_stack = 0;
166
167  /* Place RTEMS workspace at beginning of free memory. */
168
169  if (rtemsFreeMemStart & (CPU_ALIGNMENT - 1))  /* not aligned => align it */
170    rtemsFreeMemStart = (rtemsFreeMemStart+CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
171
172  BSP_Configuration.work_space_start = (void *)rtemsFreeMemStart;
173  rtemsFreeMemStart += BSP_Configuration.work_space_size;
174
175  console_reserve_resources(&BSP_Configuration);
176
177  /*
178   * Init rtems interrupt management
179   */
180  rtems_irq_mngt_init();
181  /*
182   * Init rtems exceptions management
183   */
184  rtems_exception_init_mngt();
185  /*
186   *  The following information is very useful when debugging.
187   */
188
189#if 0
190  printk( "work_space_size = 0x%x\n", BSP_Configuration.work_space_size );
191  printk( "maximum_extensions = 0x%x\n", BSP_Configuration.maximum_extensions );
192  printk( "microseconds_per_tick = 0x%x\n",
193     BSP_Configuration.microseconds_per_tick );
194  printk( "ticks_per_timeslice = 0x%x\n",
195     BSP_Configuration.ticks_per_timeslice );
196  printk( "maximum_devices = 0x%x\n", BSP_Configuration.maximum_devices );
197  printk( "number_of_device_drivers = 0x%x\n",
198     BSP_Configuration.number_of_device_drivers );
199  printk( "Device_driver_table = 0x%x\n",
200     BSP_Configuration.Device_driver_table );
201
202  printk( "_heap_size = 0x%x\n", _heap_size );
203  printk( "_stack_size = 0x%x\n", _stack_size );
204  printk( "rtemsFreeMemStart = 0x%x\n", rtemsFreeMemStart );
205  printk( "work_space_start = 0x%x\n", BSP_Configuration.work_space_start );
206  printk( "work_space_size = 0x%x\n", BSP_Configuration.work_space_size );
207#endif
208} /* bsp_start */
Note: See TracBrowser for help on using the repository browser.