source: rtems/c/src/lib/libbsp/powerpc/gen5200/startup/bspstart.c @ 801b5d8

4.115
Last change on this file since 801b5d8 was 801b5d8, checked in by Sebastian Huber <sebastian.huber@…>, on 02/17/14 at 08:23:59

powerpc: Change interrupt disable implemetation

Instead of SPRG0 (= special purpose register 272) use the new global
symbol _PPC_INTERRUPT_DISABLE_MASK to store the interrupt disable mask.
The benefit is that it is now possible to disable interrupts without
further run-time initialization in boot_card().

At least on Freescale e500 cores this leads also to a faster execution
since the mfmsr and mfspr instruction require four cycles to complete.
The instructions to load the mask value can execute while the mfmsr is
in progress.

  • Property mode set to 100644
File size: 8.9 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 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#include <rtems.h>
98#include <rtems/counter.h>
99
100#include <libcpu/powerpc-utility.h>
101
102#include <bsp.h>
103#include <bsp/vectors.h>
104#include <bsp/bootcard.h>
105#include <bsp/irq.h>
106#include <bsp/irq-generic.h>
107#include <bsp/mpc5200.h>
108
109/* Configuration parameter for clock driver */
110uint32_t bsp_time_base_frequency;
111
112/* Legacy */
113uint32_t bsp_clicks_per_usec;
114
115void BSP_panic(char *s)
116{
117  printk("%s PANIC %s\n",_RTEMS_version, s);
118  __asm__ __volatile ("sc");
119}
120
121void _BSP_Fatal_error(unsigned int v)
122{
123  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
124  __asm__ __volatile ("sc");
125}
126
127void mpc5200_fatal(mpc5200_fatal_code code)
128{
129  rtems_fatal(RTEMS_FATAL_SOURCE_BSP_SPECIFIC, code);
130}
131
132void bsp_start(void)
133{
134  ppc_cpu_id_t myCpu;
135  ppc_cpu_revision_t myCpuRevision;
136
137  /*
138   * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
139   * function store the result in global variables so that it can be used
140   * later...
141   */
142  myCpu         = get_ppc_cpu_type();
143  myCpuRevision = get_ppc_cpu_revision();
144
145  #if defined(HAS_UBOOT) && defined(SHOW_MORE_INIT_SETTINGS)
146    {
147      void dumpUBootBDInfo( bd_t * );
148      dumpUBootBDInfo( &bsp_uboot_board_info );
149    }
150  #endif
151
152  cpu_init();
153
154  if(get_ppc_cpu_revision() >= 0x2014) {
155    /* Special settings for MPC5200B (B variant) */
156    uint32_t xlb_cfg = mpc5200.config;
157
158    /* XXX: The Freescale documentation for BSDIS seems to be wrong */
159    xlb_cfg |= XLB_CFG_BSDIS;
160
161    xlb_cfg &= ~XLB_CFG_PLDIS;
162
163    mpc5200.config = xlb_cfg;
164  }
165
166  bsp_time_base_frequency = XLB_CLOCK / 4;
167  bsp_clicks_per_usec    = (XLB_CLOCK/4000000);
168  rtems_counter_initialize_converter(bsp_time_base_frequency);
169
170  /* Initialize exception handler */
171  ppc_exc_cache_wb_check = 0;
172  ppc_exc_initialize(
173    (uintptr_t) bsp_interrupt_stack_start,
174    (uintptr_t) bsp_interrupt_stack_size
175  );
176  ppc_exc_set_handler(ASM_ALIGN_VECTOR, ppc_exc_alignment_handler);
177
178  /* Initalize interrupt support */
179  bsp_interrupt_initialize();
180
181  /*
182   *  If the BSP was built with IRQ benchmarking enabled,
183   *  then intialize it.
184   */
185  #if (BENCHMARK_IRQ_PROCESSING == 1)
186    BSP_IRQ_Benchmarking_Reset();
187  #endif
188
189  #ifdef SHOW_MORE_INIT_SETTINGS
190    printk("Exit from bspstart\n");
191  #endif
192}
Note: See TracBrowser for help on using the repository browser.