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

4.104.115
Last change on this file since 9f6aaf7 was 9f6aaf7, checked in by Joel Sherrill <joel.sherrill@…>, on 10/16/09 at 16:22:46

2009-10-16 Jennifer Averett <jennifer@…>

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