source: rtems/c/src/lib/libbsp/powerpc/mpc8260ads/startup/bspstart.c @ 2d2de4eb

4.104.115
Last change on this file since 2d2de4eb was 2d2de4eb, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 10/23/09 at 07:32:46

Update for exception support changes.

  • Property mode set to 100644
File size: 5.3 KB
Line 
1/*  bsp_start()
2 *
3 *  This routine 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 this routine is invoked.
7 *
8 *  The MPC860 specific stuff was written by Jay Monkman (jmonkman@frasca.com)
9 *
10 *  Modified for the MPC8260ADS board by Andy Dachs <a.dachs@sstl.co.uk>
11 *  Surrey Satellite Technology Limited, 2001
12 *  A 40MHz system clock is assumed.
13 *  The PON. RST.CONF. Dip switches (DS1) are
14 *  1 - Off
15 *  2 - On
16 *  3 - Off
17 *  4 - On
18 *  5 - Off
19 *  6 - Off
20 *  7 - Off
21 *  8 - Off
22 *  Dip switches on DS2 and DS3 are all set to ON
23 *  The LEDs on the board are used to signal panic and fatal_error
24 *  conditions.
25 *  The mmu is unused at this time.
26 *
27 *
28 *  COPYRIGHT (c) 1989-2007.
29 *  On-Line Applications Research Corporation (OAR).
30 *
31 *  The license and distribution terms for this file may be
32 *  found in the file LICENSE in this distribution or at
33 *  http://www.rtems.com/license/LICENSE.
34 *
35 *  $Id$
36 */
37
38#include <bsp.h>
39
40/*
41#include <mmu.h>
42*/
43
44#include <mpc8260.h>
45#include <rtems/score/thread.h>
46#include <rtems/powerpc/powerpc.h>
47
48#include <rtems/bspIo.h>
49#include <libcpu/cpuIdent.h>
50#include <libcpu/spr.h>
51
52#include <string.h>
53
54SPR_RW(SPRG1)
55
56/*
57 *  Driver configuration parameters
58 */
59uint32_t   bsp_clock_speed;
60uint32_t   bsp_clicks_per_usec;
61uint32_t   bsp_serial_per_sec;         /* Serial clocks per second */
62bool       bsp_serial_external_clock;
63bool       bsp_serial_xon_xoff;
64bool       bsp_serial_cts_rts;
65uint32_t   bsp_serial_rate;
66uint32_t   bsp_timer_average_overhead; /* Average overhead of timer in ticks */
67uint32_t   bsp_timer_least_valid;      /* Least valid number from timer      */
68bool       bsp_timer_internal_clock;   /* TRUE, when timer runs with CPU clk */
69
70void  _BSP_GPLED1_on(void);
71void  _BSP_GPLED0_on(void);
72void  cpu_init(void);
73
74extern char IntrStack_start [];
75extern char intrStack [];
76
77void BSP_panic(char *s)
78{
79  _BSP_GPLED1_on();
80  printk("%s PANIC %s\n",_RTEMS_version, s);
81  __asm__ __volatile ("sc");
82}
83
84void _BSP_Fatal_error(unsigned int v)
85{
86  _BSP_GPLED0_on();
87  _BSP_GPLED1_on();
88  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
89  __asm__ __volatile ("sc");
90}
91
92void _BSP_GPLED0_on()
93{
94  BCSR *csr;
95  csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000);
96  csr->bcsr0 &=  ~GP0_LED;              /* Turn on GP0 LED */
97}
98
99void _BSP_GPLED0_off()
100{
101  BCSR *csr;
102  csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000);
103  csr->bcsr0 |=  GP0_LED;               /* Turn off GP0 LED */
104}
105
106void _BSP_GPLED1_on()
107{
108  BCSR *csr;
109  csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000);
110  csr->bcsr0 &=  ~GP1_LED;              /* Turn on GP1 LED */
111}
112
113void _BSP_GPLED1_off()
114{
115  BCSR *csr;
116  csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000);
117  csr->bcsr0 |=  GP1_LED;               /* Turn off GP1 LED */
118}
119
120void _BSP_Uart1_enable()
121{
122  BCSR *csr;
123  csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000);
124  csr->bcsr1 &= ~UART1_E;               /* Enable Uart1 */
125}
126
127void _BSP_Uart1_disable()
128{
129  BCSR *csr;
130  csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000);
131  csr->bcsr1 |=  UART1_E;               /* Disable Uart1 */
132}
133
134void _BSP_Uart2_enable()
135{
136  BCSR *csr;
137  csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000);
138  csr->bcsr1 &= ~UART2_E;               /* Enable Uart2 */
139}
140
141void _BSP_Uart2_disable()
142{
143  BCSR *csr;
144  csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000);
145  csr->bcsr1 |=  UART2_E;               /* Disable Uart2 */
146
147}
148
149void bsp_start(void)
150{
151  rtems_status_code sc = RTEMS_SUCCESSFUL;
152  extern void *_WorkspaceBase;
153  ppc_cpu_id_t myCpu;
154  ppc_cpu_revision_t myCpuRevision;
155
156  /* Set MPC8260ADS board LEDS and Uart enable lines */
157  _BSP_GPLED0_off();
158  _BSP_GPLED1_off();
159  _BSP_Uart1_enable();
160  _BSP_Uart2_enable();
161
162  /*
163   * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
164   * store the result in global variables so that it can be used latter...
165   */
166  myCpu         = get_ppc_cpu_type();
167  myCpuRevision = get_ppc_cpu_revision();
168
169  cpu_init();
170
171/*
172  mmu_init();
173*/
174
175  /* Initialize exception handler */
176  /* FIXME: Interrupt stack begin and size */
177  sc = ppc_exc_initialize(
178    PPC_INTERRUPT_DISABLE_MASK_DEFAULT,
179    (uintptr_t) IntrStack_start,
180    (uintptr_t) intrStack - (uintptr_t) IntrStack_start
181  );
182  if (sc != RTEMS_SUCCESSFUL) {
183    BSP_panic("cannot intitialize exceptions");
184  }
185
186  /* Initalize interrupt support */
187  sc = bsp_interrupt_initialize();
188  if (sc != RTEMS_SUCCESSFUL) {
189    BSP_panic("cannot intitialize interrupts");
190  }
191
192
193/*
194  mmu_init();
195*/
196
197  /*
198   * Enable instruction and data caches. Do not force writethrough mode.
199   */
200#if INSTRUCTION_CACHE_ENABLE
201  rtems_cache_enable_instruction();
202#endif
203#if DATA_CACHE_ENABLE
204  rtems_cache_enable_data();
205#endif
206
207  /*
208   *  initialize the device driver parameters
209   */
210  bsp_clicks_per_usec      = 10;  /* for 40MHz extclk */
211  bsp_serial_per_sec       = 40000000;
212  bsp_serial_external_clock  = 0;
213  bsp_serial_xon_xoff      = 0;
214  bsp_serial_cts_rts       = 0;
215  bsp_serial_rate          = 9600;
216  bsp_timer_average_overhead = 3;
217  bsp_timer_least_valid            = 3;
218  bsp_clock_speed          = 40000000;
219
220#ifdef REV_0_2
221  /* set up some board specific registers */
222  m8260.siumcr &= 0xF3FFFFFF;           /* set TBEN ** BUG FIX ** */
223  m8260.siumcr |= 0x08000000;
224#endif
225
226  /* use BRG1 to generate 32kHz timebase */
227/*
228  m8260.brgc1 = M8260_BRG_EN + (uint32_t)(((uint16_t)((40016384)/(32768)) - 1) << 1) + 0;
229*/
230
231#ifdef SHOW_MORE_INIT_SETTINGS
232  printk("Exit from bspstart\n");
233#endif
234
235}
Note: See TracBrowser for help on using the repository browser.