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

4.115
Last change on this file since 80207b8 was 80207b8, checked in by Joel Sherrill <joel.sherrill@…>, on Oct 7, 2014 at 10:38:54 PM

powerpc/score603e/startup/bspstart.c: Add include of <bsp/bootcard.h> to fix warning and clean up

  • Property mode set to 100644
File size: 4.9 KB
Line 
1/*
2 *  This routine does the bulk of the system initialization.
3 */
4
5/*
6 *  COPYRIGHT (c) 1989-2010.
7 *  On-Line Applications Research Corporation (OAR).
8 *
9 *  The license and distribution terms for this file may be
10 *  found in the file LICENSE in this distribution or at
11 *  http://www.rtems.org/license/LICENSE.
12 */
13
14#include <string.h>
15
16#include <bsp.h>
17#include <bsp/bootcard.h>
18#include <rtems/libio.h>
19#include <rtems/libcsupport.h>
20#include <rtems/bspIo.h>
21#include <rtems/counter.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(intrStackStart, intrStackSize);
197
198  msr_value = 0x2030;
199  _CPU_MSR_SET( msr_value );
200  __asm__ volatile("sync; isync");
201
202  /*
203   *  initialize the device driver parameters
204   */
205  #if DEBUG
206    printk("bsp_start: set clicks poer usec\n");
207  #endif
208  bsp_clicks_per_usec = 66 / 4;
209  rtems_counter_initialize_converter(bsp_clicks_per_usec * 1000000);
210
211  #if BSP_DATA_CACHE_ENABLED
212    #if DEBUG
213      printk("bsp_start: cache_enable\n");
214    #endif
215    instruction_cache_enable ();
216    data_cache_enable ();
217    #if DEBUG
218      printk("bsp_start: END BSP_DATA_CACHE_ENABLED\n");
219    #endif
220  #endif
221
222  /*
223   * Initalize RTEMS IRQ system
224   */
225  #if DEBUG
226    printk("bspstart: Call BSP_rtems_irq_mng_init\n");
227  #endif
228  BSP_rtems_irq_mng_init(0);
229
230  #if DEBUG
231    printk("bsp_start: end BSPSTART\n");
232    ShowBATS();
233  #endif
234}
Note: See TracBrowser for help on using the repository browser.