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

4.104.114.95
Last change on this file since 9cf283a was 4130d8e2, checked in by Joel Sherrill <joel.sherrill@…>, on 12/11/07 at 15:50:25

2007-12-11 Joel Sherrill <joel.sherrill@…>

  • include/bsp.h, startup/bspstart.c: Eliminate copies of the Configuration Table. Use the RTEMS provided accessor macros to obtain configuration fields.
  • Property mode set to 100644
File size: 6.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-2007.
9 *  On-Line Applications Research Corporation (OAR).
10 *
11 *  The license and distribution terms for this file may in
12 *  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
25/*
26 * PCI Bus Frequency
27 */
28unsigned int BSP_bus_frequency;  /* XXX - Set this based upon the Score board */
29
30/*
31 * processor clock frequency
32 */
33unsigned int BSP_processor_frequency; /* XXX - Set this based upon the Score board */
34
35/*
36 * Time base divisior (how many tick for 1 second).
37 */
38unsigned int BSP_time_base_divisor = 1000;  /* XXX - Just a guess */
39
40/*
41 *  Driver configuration parameters
42 */
43uint32_t   bsp_clicks_per_usec;
44
45void BSP_panic(char *s)
46{
47  printk("%s PANIC %s\n",_RTEMS_version, s);
48  __asm__ __volatile ("sc");
49}
50
51void _BSP_Fatal_error(unsigned int v)
52{
53  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
54  __asm__ __volatile ("sc");
55}
56
57/*
58 *  Use the shared implementations of the following routines
59 */
60
61void bsp_postdriver_hook(void);
62void bsp_libc_init( void *, uint32_t, int );
63
64/*PAGE
65 *
66 *  bsp_pretasking_hook
67 *
68 *  BSP pretasking hook.  Called just before drivers are initialized.
69 *  Used to setup libc and install any BSP extensions.
70 */
71
72void bsp_pretasking_hook(void)
73{
74  extern int end;
75  uint32_t         heap_start;
76  uint32_t         heap_size;
77
78  heap_start = (uint32_t) &end;
79  if (heap_start & (CPU_ALIGNMENT-1))
80    heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
81
82  heap_size = Configuration.work_space_start - (void *)&end;
83  heap_size &= 0xfffffff0;  /* keep it as a multiple of 16 bytes */
84
85  bsp_libc_init((void *) heap_start, heap_size, 0);
86
87#ifdef RTEMS_DEBUG
88  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
89#endif
90}
91
92/*PAGE
93 *
94 *  bsp_predriver_hook
95 *
96 *  Before drivers are setup initialize interupt vectors.
97 */
98
99void init_RTC();
100void initialize_PMC();
101
102void bsp_predriver_hook(void)
103{
104  init_RTC();
105/*   XXX - What Does this now ????
106  init_PCI();
107  initialize_universe();
108*/
109
110  initialize_PCI_bridge ();
111
112#if (HAS_PMC_PSC8)
113  initialize_PMC();
114#endif
115
116 /*
117  * Initialize Bsp General purpose vector table.
118  */
119 initialize_external_exception_vector();
120
121#if (0)
122  /*
123   * XXX - Modify this to write a 48000000 (loop to self) command
124   *       to each interrupt location.  This is better for debug.
125   */
126 bsp_spurious_initialize();
127#endif
128
129}
130
131/*PAGE
132 *
133 *  initialize_PMC
134 */
135
136void initialize_PMC() {
137  volatile uint32_t         *PMC_addr;
138  uint8_t          data;
139
140#if (0) /* First Values sent */
141  /*
142   * set PMC base address.
143   */
144  PMC_addr  = BSP_PCI_DEVICE_ADDRESS( 0x14 );
145  *PMC_addr = (BSP_PCI_REGISTER_BASE >> 24) & 0x3f;
146
147  /*
148   * Clear status, enable SERR and memory space only.
149   */
150  PMC_addr = BSP_PCI_DEVICE_ADDRESS( 0x4 );
151  *PMC_addr = 0x0201ff37;
152
153  /*
154   * Bit 0 and 1 HI cause Medium Loopback to occur.
155   */
156  PMC_addr = (volatile uint32_t*)
157        BSP_PMC_SERIAL_ADDRESS( 0x100000 );
158  data = *PMC_addr;
159  /*   *PMC_addr = data | 0x3;  */
160  *PMC_addr = data & 0xfc;
161
162#endif
163
164#if (1)
165
166  /*
167   * Clear status, enable SERR and memory space only.
168   */
169  PMC_addr = BSP_PCI_DEVICE_ADDRESS( 0x4 );
170  *PMC_addr = 0x020080cc;
171
172  /*
173   * set PMC base address.
174   */
175  PMC_addr  = BSP_PCI_DEVICE_ADDRESS( 0x14 );
176  *PMC_addr = (BSP_PCI_REGISTER_BASE >> 24) & 0x3f;
177
178  PMC_addr = (volatile uint32_t*)
179      BSP_PMC_SERIAL_ADDRESS( 0x100000 );
180  data = *PMC_addr;
181  *PMC_addr = data & 0xfc;
182
183#endif
184}
185
186/*PAGE
187 *
188 *  bsp_postdriver_hook
189 *
190 *  Standard post driver hook plus some BSP specific stuff.
191 */
192
193void bsp_postdriver_hook(void)
194{
195  extern void Init_EE_mask_init(void);
196  extern void open_dev_console(void);
197
198  open_dev_console();
199
200  Init_EE_mask_init();
201}
202
203void bsp_set_trap_vectors( void );
204
205/*PAGE
206 *
207 *  bsp_start
208 *
209 *  This routine does the bulk of the system initialization.
210 */
211
212void bsp_start( void )
213{
214  unsigned char *work_space_start;
215  unsigned int  msr_value = 0x0000;
216  volatile uint32_t         *ptr;
217
218  rtems_bsp_delay( 1000 );
219
220  /*
221   *  Zero out lots of memory
222   */
223
224  memset(
225    &end,
226    0,
227    (unsigned char *)&RAM_END - (unsigned char *) &end
228  );
229
230  BSP_processor_frequency = 266000000;
231  BSP_bus_frequency       =  66000000;
232
233  /*
234   *  There are multiple ROM monitors available for this board.
235   */
236#if (SCORE603E_USE_SDS)
237
238  /*
239   * Write instruction for Unconditional Branch to ROM vector.
240   */
241
242   Code = 0x4bf00002;
243   for (Address = 0x100; Address <= 0xe00; Address += 0x100) {
244     A_Vector = (uint32_t*)Address;
245     Code = 0x4bf00002 + Address;
246     *A_Vector = Code;
247   }
248
249   for (Address = 0x1000; Address <= 0x1400; Address += 0x100) {
250     A_Vector = (uint32_t*)Address;
251     Code = 0x4bf00002 + Address;
252     *A_Vector = Code;
253   }
254
255  msr_value = 0x2030;
256
257#elif (SCORE603E_USE_OPEN_FIRMWARE)
258  msr_value = 0x2030;
259
260#elif (SCORE603E_USE_NONE)
261  msr_value = 0x2030;
262  _CPU_MSR_SET( msr_value );
263  bsp_set_trap_vectors();
264
265#elif (SCORE603E_USE_DINK)
266  msr_value = 0x2030;
267  _CPU_MSR_SET( msr_value );
268
269  /*
270   * Override the DINK error on a Decrementor interrupt.
271   */
272  /* org    dec_vector  - rfi */
273  ptr = (uint32_t*)0x900;
274  *ptr = 0x4c000064;
275
276#else
277#error "SCORE603E BSPSTART.C -- what ROM monitor are you using"
278#endif
279
280  _CPU_MSR_SET( msr_value );
281
282  /*
283   *  Need to "allocate" the memory for the RTEMS Workspace and
284   *  tell the RTEMS configuration where it is.  This memory is
285   *  not malloc'ed.  It is just "pulled from the air".
286   */
287
288  work_space_start =
289    (unsigned char *)&RAM_END - rtems_configuration_get_work_space_size();
290
291  if ( work_space_start <= (unsigned char *)&end ) {
292    printk( "bspstart: Not enough RAM!!!\n" );
293    bsp_cleanup();
294  }
295
296  Configuration.work_space_start = work_space_start;
297
298  /*
299   *  initialize the device driver parameters
300   */
301  bsp_clicks_per_usec = 66 / 4;  /* XXX get from linkcmds */
302
303#if ( PPC_USE_DATA_CACHE )
304  instruction_cache_enable ();
305  data_cache_enable ();
306#endif
307}
Note: See TracBrowser for help on using the repository browser.