source: rtems/c/src/lib/libbsp/powerpc/gen5200/startup/bspstart.c @ 5e8726d0

4.104.115
Last change on this file since 5e8726d0 was 82bd8d9d, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 09/03/08 at 15:39:03

Converted to use shared

exception and interrupt code.

  • Property mode set to 100644
File size: 10.5 KB
Line 
1/*===============================================================*\
2| Project: RTEMS generic MPC5200 BSP                              |
3+-----------------------------------------------------------------+
4| Partially based on the code references which are named below.   |
5| Adaptions, modifications, enhancements and any recent parts of  |
6| the code are:                                                   |
7|                    Copyright (c) 2005                           |
8|                    Embedded Brains GmbH                         |
9|                    Obere Lagerstr. 30                           |
10|                    D-82178 Puchheim                             |
11|                    Germany                                      |
12|                    rtems@embedded-brains.de                     |
13+-----------------------------------------------------------------+
14| The license and distribution terms for this file may be         |
15| found in the file LICENSE in this distribution or at            |
16|                                                                 |
17| http://www.rtems.com/license/LICENSE.                           |
18|                                                                 |
19+-----------------------------------------------------------------+
20| this file contains the BSP initialization code                  |
21\*===============================================================*/
22/***********************************************************************/
23/*                                                                     */
24/*   Module:       bspstart.c                                          */
25/*   Date:         07/17/2003                                          */
26/*   Purpose:      RTEMS MPC5x00 C level startup code                  */
27/*                                                                     */
28/*---------------------------------------------------------------------*/
29/*                                                                     */
30/*   Description:  This routine starts the application. It includes    */
31/*                 application, board, and monitor specific            */
32/*                 initialization and configuration. The generic CPU   */
33/*                 dependent initialization has been performed before  */
34/*                 this routine is invoked.                            */
35/*                                                                     */
36/*---------------------------------------------------------------------*/
37/*                                                                     */
38/*   Code                                                              */
39/*   References:   MPC8260ads C level startup code                     */
40/*   Module:       bspstart.c                                          */
41/*   Project:      RTEMS 4.6.0pre1 / MCF8260ads BSP                    */
42/*   Version       1.2                                                 */
43/*   Date:         04/17/2002                                          */
44/*                                                                     */
45/*   Author(s) / Copyright(s):                                         */
46/*                                                                     */
47/*   The MPC860 specific stuff was written by Jay Monkman              */
48/*   (jmonkman@frasca.com)                                             */
49/*                                                                     */
50/*   Modified for the MPC8260ADS board by Andy Dachs                   */
51/*   <a.dachs@sstl.co.uk>                                              */
52/*   Surrey Satellite Technology Limited, 2001                         */
53/*   A 40MHz system clock is assumed.                                  */
54/*   The PON. RST.CONF. Dip switches (DS1) are                         */
55/*   1 - Off                                                           */
56/*   2 - On                                                            */
57/*   3 - Off                                                           */
58/*   4 - On                                                            */
59/*   5 - Off                                                           */
60/*   6 - Off                                                           */
61/*   7 - Off                                                           */
62/*   8 - Off                                                           */
63/*   Dip switches on DS2 and DS3 are all set to ON                     */
64/*   The LEDs on the board are used to signal panic and fatal_error    */
65/*   conditions.                                                       */
66/*   The mmu is unused at this time.                                   */
67/*                                                                     */
68/*   COPYRIGHT (c) 1989-2007.                                          */
69/*   On-Line Applications Research Corporation (OAR).                  */
70/*                                                                     */
71/*   The license and distribution terms for this file may be           */
72/*   found in found in the file LICENSE in this distribution or at     */
73/*   http://www.rtems.com/license/LICENSE.                             */
74/*                                                                     */
75/*---------------------------------------------------------------------*/
76/*                                                                     */
77/*   Partially based on the code references which are named above.     */
78/*   Adaptions, modifications, enhancements and any recent parts of    */
79/*   the code are under the right of                                   */
80/*                                                                     */
81/*         IPR Engineering, Dachauer Straße 38, D-80335 MÃŒnchen        */
82/*                        Copyright(C) 2003                            */
83/*                                                                     */
84/*---------------------------------------------------------------------*/
85/*                                                                     */
86/*   IPR Engineering makes no representation or warranties with        */
87/*   respect to the performance of this computer program, and          */
88/*   specifically disclaims any responsibility for any damages,        */
89/*   special or consequential, connected with the use of this program. */
90/*                                                                     */
91/*---------------------------------------------------------------------*/
92/*                                                                     */
93/*   Version history:  1.0                                             */
94/*                                                                     */
95/***********************************************************************/
96
97#warning The interrupt disable mask is now stored in SPRG0, please verify that this is compatible to this BSP (see also bootcard.c).
98
99#include <string.h>
100
101#include <rtems/libio.h>
102#include <rtems/libcsupport.h>
103#include <rtems/score/thread.h>
104
105#include <libcpu/powerpc-utility.h>
106#include <libcpu/raw_exception.h>
107
108#include <bsp.h>
109#include <bsp/bootcard.h>
110#include <bsp/ppc_exc_bspsupp.h>
111
112#include <bsp/irq.h>
113
114#if defined(HAS_UBOOT)
115bd_t *uboot_bdinfo_ptr = (bd_t *)1; /* will be overwritten from startup code */
116bd_t uboot_bdinfo_copy;             /* will be overwritten with copy of bdinfo */
117#endif
118
119/*
120 *  Driver configuration parameters
121 */
122uint32_t   bsp_clicks_per_usec;
123
124void BSP_panic(char *s)
125  {
126  printk("%s PANIC %s\n",_RTEMS_version, s);
127  __asm__ __volatile ("sc");
128  }
129
130void _BSP_Fatal_error(unsigned int v)
131  {
132  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
133  __asm__ __volatile ("sc");
134  }
135
136void bsp_get_work_area(
137  void   **work_area_start,
138  size_t  *work_area_size,
139  void   **heap_start,
140  size_t  *heap_size)
141{
142#ifdef HAS_UBOOT
143  char *ram_end = (char *) uboot_bdinfo_ptr->bi_memstart +
144                                 uboot_bdinfo_ptr->bi_memsize;
145#else /* HAS_UBOOT */
146  char *ram_end = bsp_ram_end;
147#endif /* HAS_UBOOT */
148
149  *work_area_start = bsp_work_area_start;
150  *work_area_size = ram_end - bsp_work_area_start;
151  *heap_start = BSP_BOOTCARD_HEAP_USES_WORK_AREA;
152  *heap_size = BSP_BOOTCARD_HEAP_SIZE_DEFAULT;
153}
154
155void bsp_predriver_hook(void)
156  {
157#if 0
158  init_RTC();
159
160  init_PCI();
161  initialize_universe();
162  initialize_PCI_bridge ();
163
164#if (HAS_PMC_PSC8)
165  initialize_PMC();
166#endif
167
168 /*
169  * Initialize Bsp General purpose vector table.
170  */
171 initialize_external_exception_vector();
172
173#if (0)
174  /*
175   * XXX - Modify this to write a 48000000 (loop to self) command
176   *       to each interrupt location.  This is better for debug.
177   */
178 bsp_spurious_initialize();
179#endif
180
181#endif
182}
183
184void bsp_start(void)
185{
186  ppc_cpu_id_t myCpu;
187  ppc_cpu_revision_t myCpuRevision;
188
189  /*
190   * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
191   * function store the result in global variables so that it can be used
192   * later...
193   */
194  myCpu         = get_ppc_cpu_type();
195  myCpuRevision = get_ppc_cpu_revision();
196
197  #if defined(HAS_UBOOT)
198    uboot_bdinfo_copy = *uboot_bdinfo_ptr;
199    uboot_bdinfo_ptr = &uboot_bdinfo_copy;
200  #endif 
201
202  #if defined(HAS_UBOOT) && defined(SHOW_MORE_INIT_SETTINGS)
203    {
204      void dumpUBootBDInfo( bd_t * );
205      dumpUBootBDInfo( uboot_bdinfo_ptr );
206    }
207  #endif
208
209  cpu_init();
210
211 bsp_clicks_per_usec    = (IPB_CLOCK/1000000);
212
213  /*
214   * Enable instruction and data caches. Do not force writethrough mode.
215   */
216  #if INSTRUCTION_CACHE_ENABLE
217    rtems_cache_enable_instruction();
218  #endif
219  #if DATA_CACHE_ENABLE
220    rtems_cache_enable_data();
221  #endif
222
223  /* Initialize exception handler */
224  ppc_exc_cache_wb_check = 0;
225  ppc_exc_initialize(
226    PPC_INTERRUPT_DISABLE_MASK_DEFAULT,
227    (uint32_t) bsp_interrupt_stack_start,
228    (uint32_t) bsp_interrupt_stack_size
229  );
230
231  /* Initalize interrupt support */
232  if (bsp_interrupt_initialize() != RTEMS_SUCCESSFUL) {
233    BSP_panic( "Cannot intitialize interrupt support\n");
234  }
235
236  /*
237   *  If the BSP was built with IRQ benchmarking enabled,
238   *  then intialize it.
239   */
240  #if (BENCHMARK_IRQ_PROCESSING == 1)
241    BSP_IRQ_Benchmarking_Reset();
242  #endif
243
244  #ifdef SHOW_MORE_INIT_SETTINGS
245    printk("Exit from bspstart\n");
246  #endif
247
248}
249
250/*
251 *
252 *  _Thread_Idle_body
253 *
254 *  Replaces the one in c/src/exec/score/src/threadidlebody.c
255 *  The MSR[POW] bit is set to put the CPU into the low power mode
256 *  defined in HID0.  HID0 is set during starup in start.S.
257 *
258 */
259Thread _Thread_Idle_body(uint32_t ignored)
260{
261  for(;;) {
262    asm volatile(
263      "mfmsr 3; oris 3,3,4; sync; mtmsr 3; isync; ori 3,3,0; ori 3,3,0"
264     );
265  }
266  return 0;
267}
268
Note: See TracBrowser for help on using the repository browser.