OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [rtos/] [rtems/] [c/] [src/] [lib/] [libbsp/] [i386/] [pc386/] [startup/] [bspstart.c] - Blame information for rev 173

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 30 unneback
/*-------------------------------------------------------------------------+
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: bspstart.c,v 1.2 2001-09-27 11:59:48 chris Exp $
31
+--------------------------------------------------------------------------*/
32
 
33
 
34
#include <bsp.h>
35
#include <libcsupport.h>
36
#include <rtems/libio.h>
37
#include <libcpu/cpuModel.h>
38
 
39
/*-------------------------------------------------------------------------+
40
| Global Variables
41
+--------------------------------------------------------------------------*/
42
extern 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
 */
47
rtems_unsigned32 _heap_size = 0;
48
 
49
/* Size of stack used during initialization. Defined in 'start.s'.  */
50
extern rtems_unsigned32 _stack_size;
51
 
52
rtems_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
 
59
extern rtems_configuration_table  Configuration;
60
       rtems_configuration_table  BSP_Configuration;
61
 
62
rtems_cpu_table Cpu_table;                     /* CPU configuration table.    */
63
char            *rtems_progname;               /* Program name - from main(). */
64
 
65
/*-------------------------------------------------------------------------+
66
| External Prototypes
67
+--------------------------------------------------------------------------*/
68
extern void rtems_irq_mngt_init(void);
69
void bsp_libc_init( void *, unsigned32, int );
70
void 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
+--------------------------------------------------------------------------*/
82
void 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
+--------------------------------------------------------------------------*/
138
void 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
  /*
148
   * Initialize printk channel
149
   */
150
 
151
  _IBMPC_initVideo();
152
 
153
  rtemsFreeMemStart = (rtems_unsigned32)&_end + _stack_size;
154
                                    /* set the value of start of free memory. */
155
 
156
  /* If we don't have command line arguments set default program name. */
157
 
158
  Cpu_table.pretasking_hook         = bsp_pretasking_hook; /* init libc, etc. */
159
  Cpu_table.predriver_hook          = NULL;                /* use system's    */
160
  Cpu_table.postdriver_hook         = bsp_postdriver_hook;
161
  Cpu_table.idle_task               = NULL;
162
                                          /* do not override system IDLE task */
163
  Cpu_table.do_zero_of_workspace    = TRUE;
164
  Cpu_table.interrupt_table_segment = get_ds();
165
  Cpu_table.interrupt_table_offset  = (void *)Interrupt_descriptor_table;
166
  Cpu_table.interrupt_stack_size    = CONFIGURE_INTERRUPT_STACK_MEMORY;
167
  Cpu_table.extra_mpci_receive_server_stack = 0;
168
 
169
  /* Place RTEMS workspace at beginning of free memory. */
170
 
171
  if (rtemsFreeMemStart & (CPU_ALIGNMENT - 1))  /* not aligned => align it */
172
    rtemsFreeMemStart = (rtemsFreeMemStart+CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
173
 
174
  BSP_Configuration.work_space_start = (void *)rtemsFreeMemStart;
175
  rtemsFreeMemStart += BSP_Configuration.work_space_size;
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 */
209
 
210
/*
211
 *  By making this a weak alias for bsp_start_default, a brave soul
212
 *  can override the actual bsp_start routine used.
213
 */
214
 
215
void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default")));

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.