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

4.11
Last change on this file since b1e8a58 was b1e8a58, checked in by Sebastian Huber <sebastian.huber@…>, on Nov 14, 2012 at 8:57:55 AM

bsps/powerpc: Exception initialization error is fatal

  • Property mode set to 100644
File size: 5.0 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-2010.
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
16#include <string.h>
17
18#include <bsp.h>
19#include <rtems/libio.h>
20#include <rtems/libcsupport.h>
21#include <rtems/bspIo.h>
22#include <libcpu/cpuIdent.h>
23#include <bsp/irq.h>
24
25#define DEBUG 0
26
27/*
28 * Where the heap starts; is used by bsp_pretasking_hook;
29 */
30unsigned int BSP_heap_start;
31
32/*
33 * PCI Bus Frequency
34 */
35unsigned int BSP_bus_frequency;
36
37/*
38 * processor clock frequency
39 */
40unsigned int BSP_processor_frequency;
41
42/*
43 * Time base divisior (how many tick for 1 second).
44 * Note: Calibrated with an application using a 20ms timer and
45 * a scope.
46 */
47unsigned int BSP_time_base_divisor = 3960;
48
49/*
50 *  Driver configuration parameters
51 */
52uint32_t   bsp_clicks_per_usec;
53
54/*
55 * Memory on this board.
56 */
57extern char RamSize[];
58uint32_t BSP_mem_size;
59
60extern unsigned long __rtems_end[];
61
62void BSP_panic(char *s)
63{
64  printk("%s PANIC %s\n",_RTEMS_version, s);
65  __asm__ __volatile ("sc");
66}
67
68void _BSP_Fatal_error(unsigned int v)
69{
70  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
71  __asm__ __volatile ("sc");
72}
73
74/*PAGE
75 *
76 *  bsp_predriver_hook
77 *
78 *  Before drivers are setup initialize interupt vectors.
79 */
80
81void init_RTC(void);
82void initialize_PMC(void);
83
84void bsp_predriver_hook(void)
85{
86  init_PCI();
87  initialize_universe();
88
89  #if DEBUG
90    printk("bsp_predriver_hook: initialize_PCI_bridge\n");
91  #endif
92  initialize_PCI_bridge ();
93
94#if (HAS_PMC_PSC8)
95  #if DEBUG
96    printk("bsp_predriver_hook: initialize_PMC\n");
97  #endif
98  initialize_PMC();
99#endif
100
101  #if DEBUG
102    printk("bsp_predriver_hook: End of routine\n");
103  #endif
104
105}
106
107/*PAGE
108 *
109 *  initialize_PMC
110 */
111
112void initialize_PMC(void) {
113  volatile uint32_t     *PMC_addr;
114  uint32_t               data;
115
116  /*
117   * Clear status, enable SERR and memory space only.
118   */
119  PMC_addr = BSP_PCI_DEVICE_ADDRESS( 0x4 );
120  *PMC_addr = 0x020080cc;
121  #if DEBUG
122    printk("initialize_PMC: 0x%x = 0x%x\n", PMC_addr, 0x020080cc);
123  #endif
124
125  /*
126   * set PMC base address.
127   */
128  PMC_addr  = BSP_PCI_DEVICE_ADDRESS( 0x14 );
129  *PMC_addr = (BSP_PCI_REGISTER_BASE >> 24) & 0x3f;
130  #if DEBUG
131    printk("initialize_PMC: 0x%x = 0x%x\n", PMC_addr, ((BSP_PCI_REGISTER_BASE >> 24) & 0x3f));
132  #endif
133
134   PMC_addr = (volatile uint32_t*)
135      BSP_PMC_SERIAL_ADDRESS( 0x100000 );
136  data = *PMC_addr;
137  #if DEBUG
138    printk("initialize_PMC: Read 0x%x (0x%x)\n", PMC_addr, data );
139    printk("initialize_PMC: Read 0x%x (0x%x)\n", PMC_addr, data & 0xfc );
140  #endif
141  *PMC_addr = data & 0xfc;
142}
143
144/*PAGE
145 *
146 *  bsp_start
147 *
148 *  This routine does the bulk of the system initialization.
149 */
150
151void bsp_start( void )
152{
153  unsigned int         msr_value = 0x0000;
154  uintptr_t            intrStackStart;
155  uintptr_t            intrStackSize;
156  ppc_cpu_id_t         myCpu;
157  ppc_cpu_revision_t   myCpuRevision;
158
159  rtems_bsp_delay( 1000 );
160
161  /*
162   *  Zero out lots of memory
163   */
164  #if DEBUG
165    printk("bsp_start: Zero out lots of memory\n");
166  #endif
167
168  BSP_processor_frequency = 266000000;
169  BSP_bus_frequency       =  66000000;
170
171  /*
172   * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
173   * function store the result in global variables so that it can be used
174   * later...
175   */
176  myCpu         = get_ppc_cpu_type();
177  myCpuRevision = get_ppc_cpu_revision();
178  printk("Cpu: 0x%x  Revision: %d\n", myCpu, myCpuRevision);
179  printk("Cpu %s\n", get_ppc_cpu_type_name(myCpu) );
180
181  /*
182   * Initialize the interrupt related settings.
183   */
184  intrStackStart = (uintptr_t) __rtems_end;
185  intrStackSize = rtems_configuration_get_interrupt_stack_size();
186  printk("Interrupt Stack Start: 0x%x Size: 0x%x  Heap Start: 0x%x\n",
187    intrStackStart, intrStackSize, BSP_heap_start
188  );
189
190  BSP_mem_size = (uint32_t) RamSize;
191  printk("BSP_mem_size: %p\n", RamSize );
192
193  /*
194   * Initialize default raw exception handlers.
195   */
196  ppc_exc_initialize(
197    PPC_INTERRUPT_DISABLE_MASK_DEFAULT,
198    intrStackStart,
199    intrStackSize
200  );
201
202  msr_value = 0x2030;
203  _CPU_MSR_SET( msr_value );
204  __asm__ volatile("sync; isync");
205
206  /*
207   *  initialize the device driver parameters
208   */
209  #if DEBUG
210    printk("bsp_start: set clicks poer usec\n");
211  #endif
212  bsp_clicks_per_usec = 66 / 4;
213
214  #if BSP_DATA_CACHE_ENABLED
215    #if DEBUG
216      printk("bsp_start: cache_enable\n");
217    #endif
218    instruction_cache_enable ();
219    data_cache_enable ();
220    #if DEBUG
221      printk("bsp_start: END BSP_DATA_CACHE_ENABLED\n");
222    #endif
223  #endif
224
225  /*
226   * Initalize RTEMS IRQ system
227   */
228  #if DEBUG
229    printk("bspstart: Call BSP_rtems_irq_mng_init\n");
230  #endif
231  BSP_rtems_irq_mng_init(0);
232
233  #if DEBUG
234    printk("bsp_start: end BSPSTART\n");
235    ShowBATS();
236  #endif
237}
Note: See TracBrowser for help on using the repository browser.