source: rtems/c/src/lib/libbsp/powerpc/score603e/startup/bspstart.c @ 8e230e6

4.9
Last change on this file since 8e230e6 was 31a5ec8, checked in by Jennifer Averett <Jennifer.Averett@…>, on 05/05/09 at 16:18:06

2009-05-05 Jennifer Averett <jennifer.averett@…>

  • Makefile.am, README, configure.ac, preinstall.am, PCI_bus/PCI.c, PCI_bus/PCI.h, PCI_bus/flash.c, PCI_bus/universe.c, console/85c30.c, console/85c30.h, console/console.c, console/consolebsp.h, console/tbl85c30.c, include/bsp.h, include/coverhd.h, include/gen2.h, include/irq-config.h, include/tm27.h, irq/FPGA.c, irq/irq.h, irq/irq_init.c, start/start.S, startup/Hwr_init.c, startup/bspstart.c, timer/timer.c, tod/tod.c: Updated and tested with the latest powerpc isr source
  • irq/no_pic.c: New file.
  • irq/irq.c, startup/genpvec.c, startup/setvec.c, startup/vmeintr.c: Removed.
  • Property mode set to 100644
File size: 6.9 KB
Line 
1/*  bspstart.c
2 *
3 *  This set of routines starts the application.  It includes application,
4 *  board, and monitor specific initialization and configuration.
5 *  The generic CPU dependent initialization has been performed
6 *  before any of these are invoked.
7 *
8 *  COPYRIGHT (c) 1989-2009.
9 *  On-Line Applications Research Corporation (OAR).
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.com/license/LICENSE.
14 *
15 *  $Id$
16 */
17
18#include <string.h>
19
20#include <bsp.h>
21#include <rtems/libio.h>
22#include <rtems/libcsupport.h>
23#include <rtems/bspIo.h>
24#include <libcpu/cpuIdent.h>
25
26#define DEBUG 0
27
28/*
29 * Where the heap starts; is used by bsp_pretasking_hook;
30 */
31unsigned int BSP_heap_start;
32
33/*
34 * PCI Bus Frequency
35 */
36unsigned int BSP_bus_frequency; 
37
38/*
39 * processor clock frequency
40 */
41unsigned int BSP_processor_frequency;
42
43/*
44 * Time base divisior (how many tick for 1 second).
45 */
46unsigned int BSP_time_base_divisor = 4000;
47
48/*
49 * system init stack
50 */
51#define INIT_STACK_SIZE 0x1000
52
53extern unsigned long __rtems_end[];
54
55
56/*
57 *  Driver configuration parameters
58 */
59uint32_t   bsp_clicks_per_usec;
60
61void BSP_panic(char *s)
62{
63  printk("%s PANIC %s\n",_RTEMS_version, s);
64  __asm__ __volatile ("sc");
65}
66
67void _BSP_Fatal_error(unsigned int v)
68{
69  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
70  __asm__ __volatile ("sc");
71}
72
73/*
74 *  Use the shared implementations of the following routines
75 */
76
77void bsp_postdriver_hook(void);
78void bsp_libc_init( void *, uint32_t, int );
79
80/*PAGE
81 *
82 *  bsp_pretasking_hook
83 *
84 *  BSP pretasking hook.  Called just before drivers are initialized.
85 *  Used to setup libc and install any BSP extensions.
86 */
87
88void bsp_pretasking_hook(void)
89{
90  extern int end;
91  uint32_t         heap_start;
92  uint32_t         heap_size;
93
94  heap_start = (BSP_heap_start + CPU_ALIGNMENT - 1) & ~(CPU_ALIGNMENT-1);
95  heap_size = (uint32_t) &RAM_END;
96  heap_size = heap_size - heap_start - Configuration.work_space_size;
97  heap_size &= 0xfffffff0;  /* keep it as a multiple of 16 bytes */
98 
99
100  #if DEBUG
101    printk("bsp_pretasking_hook: Set Heap start 0x%x size 0x%x\n", heap_start, heap_size);
102  #endif
103
104  #if DEBUG
105    printk("bsp_pretasking_hook: bsp_libc_init\n");
106  #endif
107  bsp_libc_init((void *) heap_start, heap_size, 0);
108  #if DEBUG
109    printk("bsp_pretasking_hook: End of routine\n");
110  #endif
111}
112
113/*PAGE
114 *
115 *  bsp_predriver_hook
116 *
117 *  Before drivers are setup initialize interupt vectors.
118 */
119
120void init_RTC();
121void initialize_PMC();
122
123void bsp_predriver_hook(void)
124{
125  init_PCI();
126  initialize_universe();
127
128  #if DEBUG
129    printk("bsp_predriver_hook: initialize_PCI_bridge\n");
130  #endif
131  initialize_PCI_bridge ();
132
133#if (HAS_PMC_PSC8)
134  #if DEBUG
135    printk("bsp_predriver_hook: initialize_PMC\n");
136  #endif
137  initialize_PMC();
138#endif
139
140  #if DEBUG
141    printk("bsp_predriver_hook: End of routine\n");
142  #endif
143
144}
145
146/*PAGE
147 *
148 *  initialize_PMC
149 */
150
151void initialize_PMC() {
152  volatile uint32_t     *PMC_addr;
153  uint32_t               data;
154
155  /*
156   * Clear status, enable SERR and memory space only.
157   */
158  PMC_addr = BSP_PCI_DEVICE_ADDRESS( 0x4 );
159  *PMC_addr = 0x020080cc;
160  #if DEBUG
161    printk("initialize_PMC: 0x%x = 0x%x\n", PMC_addr, 0x020080cc);
162  #endif
163
164  /*
165   * set PMC base address.
166   */
167  PMC_addr  = BSP_PCI_DEVICE_ADDRESS( 0x14 );
168  *PMC_addr = (BSP_PCI_REGISTER_BASE >> 24) & 0x3f;
169  #if DEBUG
170    printk("initialize_PMC: 0x%x = 0x%x\n", PMC_addr, ((BSP_PCI_REGISTER_BASE >> 24) & 0x3f));
171  #endif
172
173   PMC_addr = (volatile uint32_t*)
174      BSP_PMC_SERIAL_ADDRESS( 0x100000 );
175  data = *PMC_addr;
176  #if DEBUG
177    printk("initialize_PMC: Read 0x%x (0x%x)\n", PMC_addr, data );
178    printk("initialize_PMC: Read 0x%x (0x%x)\n", PMC_addr, data & 0xfc );
179  #endif
180  *PMC_addr = data & 0xfc;
181}
182
183/*PAGE
184 *
185 *  bsp_postdriver_hook
186 *
187 *  Standard post driver hook plus some BSP specific stuff.
188 */
189
190void bsp_postdriver_hook(void)
191{
192  extern void open_dev_console(void);
193  #if DEBUG
194    printk("bsp_postdriver_hook: open_dev_console\n");
195  #endif
196  open_dev_console();
197  #if DEBUG
198    printk("bsp_postdriver_hook: Finished procedure\n");
199  #endif
200}
201
202void bsp_set_trap_vectors( void );
203
204/*PAGE
205 *
206 *  bsp_start
207 *
208 *  This routine does the bulk of the system initialization.
209 */
210
211void bsp_start( void )
212{
213  unsigned char *work_space_start;
214  unsigned int  msr_value = 0x0000;
215  uint32_t      intrStackStart;
216  uint32_t      intrStackSize;
217  volatile uint32_t         *ptr;
218  ppc_cpu_id_t myCpu;
219  ppc_cpu_revision_t myCpuRevision;
220
221  rtems_bsp_delay( 1000 );
222
223  /*
224   *  Zero out lots of memory
225   */
226  #if DEBUG
227    printk("bsp_start: Zero out lots of memory\n");
228  #endif
229
230  memset(
231    &end,
232    0,
233    (unsigned char *)&RAM_END - (unsigned char *) &end
234  );
235
236  BSP_processor_frequency = 266000000;
237  BSP_bus_frequency       =  66000000;
238
239  /*
240   * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
241   * function store the result in global variables so that it can be used
242   * later...
243   */
244  myCpu         = get_ppc_cpu_type();
245  myCpuRevision = get_ppc_cpu_revision();
246  printk("Cpu: 0x%x  Revision: %d\n", myCpu, myCpuRevision);
247  printk("Cpu %s\n", get_ppc_cpu_type_name(myCpu) );
248
249  /*
250   * Initialize the interrupt related settings.
251   */
252  intrStackStart = (uint32_t) __rtems_end + INIT_STACK_SIZE;
253  intrStackSize = rtems_configuration_get_interrupt_stack_size();
254  BSP_heap_start = intrStackStart + intrStackSize;
255  printk("Interrupt Stack Start: 0x%x Size: 0x%x  Heap Start: 0x%x\n",
256    intrStackStart, intrStackSize, BSP_heap_start
257  );
258
259  /*
260   * Initialize default raw exception handlers.
261   */
262  ppc_exc_initialize(
263    PPC_INTERRUPT_DISABLE_MASK_DEFAULT,
264    intrStackStart,
265    intrStackSize
266  );
267
268  msr_value = 0x2030;
269  _CPU_MSR_SET( msr_value );
270
271  _CPU_MSR_SET( msr_value );
272
273  /*
274   *  Need to "allocate" the memory for the RTEMS Workspace and
275   *  tell the RTEMS configuration where it is.  This memory is
276   *  not malloc'ed.  It is just "pulled from the air".
277   */
278  work_space_start =
279    (unsigned char *)&RAM_END - rtems_configuration_get_work_space_size();
280  printk("Work Space Start: 0x%x\n", work_space_start );
281
282  if ( work_space_start <= (unsigned char *)&end ) {
283    printk( "bspstart: Not enough RAM!!!\n" );
284    bsp_cleanup();
285  }
286
287  Configuration.work_space_start = work_space_start;
288
289  /*
290   *  initialize the device driver parameters
291   */
292  #if DEBUG
293    printk("bsp_start: set clicks poer usec\n");
294  #endif
295  bsp_clicks_per_usec = 66 / 4;  /* XXX get from linkcmds */
296
297  #if ( PPC_USE_DATA_CACHE )
298    #if DEBUG
299      printk("bsp_start: cache_enable\n");
300    #endif
301    instruction_cache_enable ();
302    data_cache_enable ();
303    #if DEBUG
304      printk("bsp_start: END PPC_USE_DATA_CACHE\n");
305    #endif
306  #endif
307
308  /*
309   * Initalize RTEMS IRQ system
310   */
311  #if DEBUG 
312    printk("bspstart: Call BSP_rtems_irq_mng_init\n");
313  #endif
314  BSP_rtems_irq_mng_init(0);
315 
316  #if DEBUG
317    printk("bsp_start: end BSPSTART\n");
318    ShowBATS();
319  #endif
320}
Note: See TracBrowser for help on using the repository browser.