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

4.11
Last change on this file since f7513a0 was f7513a0, checked in by Sebastian Huber <sebastian.huber@…>, on Aug 9, 2012 at 2:45:12 PM

bsps: Remove unused bsp_libc_init() prototype

  • Property mode set to 100644
File size: 5.1 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  rtems_status_code sc = RTEMS_SUCCESSFUL;
154  unsigned int         msr_value = 0x0000;
155  uintptr_t            intrStackStart;
156  uintptr_t            intrStackSize;
157  ppc_cpu_id_t         myCpu;
158  ppc_cpu_revision_t   myCpuRevision;
159
160  rtems_bsp_delay( 1000 );
161
162  /*
163   *  Zero out lots of memory
164   */
165  #if DEBUG
166    printk("bsp_start: Zero out lots of memory\n");
167  #endif
168
169  BSP_processor_frequency = 266000000;
170  BSP_bus_frequency       =  66000000;
171
172  /*
173   * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
174   * function store the result in global variables so that it can be used
175   * later...
176   */
177  myCpu         = get_ppc_cpu_type();
178  myCpuRevision = get_ppc_cpu_revision();
179  printk("Cpu: 0x%x  Revision: %d\n", myCpu, myCpuRevision);
180  printk("Cpu %s\n", get_ppc_cpu_type_name(myCpu) );
181
182  /*
183   * Initialize the interrupt related settings.
184   */
185  intrStackStart = (uintptr_t) __rtems_end;
186  intrStackSize = rtems_configuration_get_interrupt_stack_size();
187  printk("Interrupt Stack Start: 0x%x Size: 0x%x  Heap Start: 0x%x\n",
188    intrStackStart, intrStackSize, BSP_heap_start
189  );
190
191  BSP_mem_size = (uint32_t) RamSize;
192  printk("BSP_mem_size: %p\n", RamSize );
193
194  /*
195   * Initialize default raw exception handlers.
196   */
197  sc = ppc_exc_initialize(
198    PPC_INTERRUPT_DISABLE_MASK_DEFAULT,
199    intrStackStart,
200    intrStackSize
201  );
202  if (sc != RTEMS_SUCCESSFUL) {
203    BSP_panic("cannot initialize exceptions");
204  }
205
206  msr_value = 0x2030;
207  _CPU_MSR_SET( msr_value );
208  __asm__ volatile("sync; isync");
209
210  /*
211   *  initialize the device driver parameters
212   */
213  #if DEBUG
214    printk("bsp_start: set clicks poer usec\n");
215  #endif
216  bsp_clicks_per_usec = 66 / 4;
217
218  #if BSP_DATA_CACHE_ENABLED
219    #if DEBUG
220      printk("bsp_start: cache_enable\n");
221    #endif
222    instruction_cache_enable ();
223    data_cache_enable ();
224    #if DEBUG
225      printk("bsp_start: END BSP_DATA_CACHE_ENABLED\n");
226    #endif
227  #endif
228
229  /*
230   * Initalize RTEMS IRQ system
231   */
232  #if DEBUG
233    printk("bspstart: Call BSP_rtems_irq_mng_init\n");
234  #endif
235  BSP_rtems_irq_mng_init(0);
236
237  #if DEBUG
238    printk("bsp_start: end BSPSTART\n");
239    ShowBATS();
240  #endif
241}
Note: See TracBrowser for help on using the repository browser.