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

4.104.114.95
Last change on this file since a86f3aac was a86f3aac, checked in by Thomas Doerfler <Thomas.Doerfler@…>, on 07/11/08 at 10:01:37

adapted powerpc BSPs to new exception code

  • Property mode set to 100644
File size: 7.7 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#warning The interrupt disable mask is now stored in SPRG0, please verify that this is compatible to this BSP (see also bootcard.c).
39
40#include <bsp.h>
41
42/*
43#include <mmu.h>
44*/
45
46#include <mpc8260.h>
47#include <rtems/libio.h>
48#include <rtems/libcsupport.h>
49#include <rtems/score/thread.h>
50#include <rtems/powerpc/powerpc.h>
51
52#include <rtems/bspIo.h>
53#include <libcpu/cpuIdent.h>
54#include <libcpu/spr.h>
55
56#include <string.h>
57
58SPR_RW(SPRG1)
59
60extern unsigned long intrStackPtr;
61
62/*
63 *  Driver configuration parameters
64 */
65uint32_t   bsp_clock_speed;
66uint32_t   bsp_clicks_per_usec;
67uint32_t   bsp_serial_per_sec;         /* Serial clocks per second */
68boolean    bsp_serial_external_clock;
69boolean    bsp_serial_xon_xoff;
70boolean    bsp_serial_cts_rts;
71uint32_t   bsp_serial_rate;
72uint32_t   bsp_timer_average_overhead; /* Average overhead of timer in ticks */
73uint32_t   bsp_timer_least_valid;      /* Least valid number from timer      */
74boolean    bsp_timer_internal_clock;   /* TRUE, when timer runs with CPU clk */
75
76/*
77 *  Use the shared implementations of the following routines.
78 *  Look in rtems/c/src/lib/libbsp/shared/bsppost.c and
79 *  rtems/c/src/lib/libbsp/shared/bsplibc.c.
80 */
81void bsp_libc_init( void *, uint32_t, int );
82
83void  _BSP_GPLED1_on(void);
84void  _BSP_GPLED0_on(void);
85void  cpu_init(void);
86void  initialize_exceptions(void);
87
88void BSP_panic(char *s)
89{
90  _BSP_GPLED1_on();
91  printk("%s PANIC %s\n",_RTEMS_version, s);
92  __asm__ __volatile ("sc");
93}
94
95void _BSP_Fatal_error(unsigned int v)
96{
97  _BSP_GPLED0_on();
98  _BSP_GPLED1_on();
99  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
100  __asm__ __volatile ("sc");
101}
102
103void _BSP_GPLED0_on()
104{
105  BCSR *csr;
106  csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000);
107  csr->bcsr0 &=  ~GP0_LED;              /* Turn on GP0 LED */
108}
109
110void _BSP_GPLED0_off()
111{
112  BCSR *csr;
113  csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000);
114  csr->bcsr0 |=  GP0_LED;               /* Turn off GP0 LED */
115}
116
117void _BSP_GPLED1_on()
118{
119  BCSR *csr;
120  csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000);
121  csr->bcsr0 &=  ~GP1_LED;              /* Turn on GP1 LED */
122}
123
124void _BSP_GPLED1_off()
125{
126  BCSR *csr;
127  csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000);
128  csr->bcsr0 |=  GP1_LED;               /* Turn off GP1 LED */
129}
130
131void _BSP_Uart1_enable()
132{
133  BCSR *csr;
134  csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000);
135  csr->bcsr1 &= ~UART1_E;               /* Enable Uart1 */
136}
137
138void _BSP_Uart1_disable()
139{
140  BCSR *csr;
141  csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000);
142  csr->bcsr1 |=  UART1_E;               /* Disable Uart1 */
143}
144
145void _BSP_Uart2_enable()
146{
147  BCSR *csr;
148  csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000);
149  csr->bcsr1 &= ~UART2_E;               /* Enable Uart2 */
150}
151
152void _BSP_Uart2_disable()
153{
154  BCSR *csr;
155  csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000);
156  csr->bcsr1 |=  UART2_E;               /* Disable Uart2 */
157
158}
159
160/*
161 *  Function:   bsp_pretasking_hook
162 *  Created:    95/03/10
163 *
164 *  Description:
165 *      BSP pretasking hook.  Called just before drivers are initialized.
166 *      Used to setup libc and install any BSP extensions.
167 *
168 *  NOTES:
169 *      Must not use libc (to do io) from here, since drivers are
170 *      not yet initialized.
171 *
172 */
173
174void
175bsp_pretasking_hook(void)
176{
177  /*
178   *  These are assigned addresses in the linkcmds file for the BSP. This
179   *  approach is better than having these defined as manifest constants and
180   *  compiled into the kernel, but it is still not ideal when dealing with
181   *  multiprocessor configuration in which each board as a different memory
182   *  map. A better place for defining these symbols might be the makefiles.
183   *  Consideration should also be given to developing an approach in which
184   *  the kernel and the application can be linked and burned into ROM
185   *  independently of each other.
186   */
187  extern unsigned char _HeapStart;
188  extern unsigned char _HeapEnd;
189
190  bsp_libc_init( &_HeapStart, &_HeapEnd - &_HeapStart, 0 );
191}
192
193void bsp_start(void)
194{
195  extern void *_WorkspaceBase;
196  ppc_cpu_id_t myCpu;
197  ppc_cpu_revision_t myCpuRevision;
198  register unsigned char* intrStack;
199
200  /* Set MPC8260ADS board LEDS and Uart enable lines */
201  _BSP_GPLED0_off();
202  _BSP_GPLED1_off();
203  _BSP_Uart1_enable();
204  _BSP_Uart2_enable();
205
206  /*
207   * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
208   * store the result in global variables so that it can be used latter...
209   */
210  myCpu         = get_ppc_cpu_type();
211  myCpuRevision = get_ppc_cpu_revision();
212
213  cpu_init();
214
215/*
216  mmu_init();
217*/
218  /*
219   * Initialize some SPRG registers related to irq handling
220   */
221
222  intrStack = (((unsigned char*)&intrStackPtr) - PPC_MINIMUM_STACK_FRAME_SIZE);
223  _write_SPRG1((unsigned int)intrStack);
224
225/*
226  printk( "About to call initialize_exceptions\n" );
227*/
228   /*
229    * Install our own set of exception vectors
230    */
231
232   initialize_exceptions();
233
234/*
235  mmu_init();
236*/
237
238  /*
239   * Enable instruction and data caches. Do not force writethrough mode.
240   */
241#if INSTRUCTION_CACHE_ENABLE
242  rtems_cache_enable_instruction();
243#endif
244#if DATA_CACHE_ENABLE
245  rtems_cache_enable_data();
246#endif
247
248  /*
249   *  Allocate the memory for the RTEMS Work Space.  This can come from
250   *  a variety of places: hard coded address, malloc'ed from outside
251   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
252   *  typically done by stock BSPs) by subtracting the required amount
253   *  of work space from the last physical address on the CPU board.
254   */
255
256  /*
257   *  Need to "allocate" the memory for the RTEMS Workspace and
258   *  tell the RTEMS configuration where it is.  This memory is
259   *  not malloc'ed.  It is just "pulled from the air".
260   */
261
262  Configuration.work_space_start = (void *)&_WorkspaceBase;
263
264  /*
265   *  initialize the device driver parameters
266   */
267  bsp_clicks_per_usec      = 10;  /* for 40MHz extclk */
268  bsp_serial_per_sec       = 40000000;
269  bsp_serial_external_clock  = 0;
270  bsp_serial_xon_xoff      = 0;
271  bsp_serial_cts_rts       = 0;
272  bsp_serial_rate          = 9600;
273  bsp_timer_average_overhead = 3;
274  bsp_timer_least_valid            = 3;
275  bsp_clock_speed          = 40000000;
276
277#ifdef REV_0_2
278  /* set up some board specific registers */
279  m8260.siumcr &= 0xF3FFFFFF;           /* set TBEN ** BUG FIX ** */
280  m8260.siumcr |= 0x08000000;
281#endif
282
283  /* use BRG1 to generate 32kHz timebase */
284/*
285  m8260.brgc1 = M8260_BRG_EN + (uint32_t)(((uint16_t)((40016384)/(32768)) - 1) << 1) + 0;
286*/
287
288  /*
289   * Initalize RTEMS IRQ system
290   */
291  BSP_rtems_irq_mng_init(0);
292
293#ifdef SHOW_MORE_INIT_SETTINGS
294  printk("Exit from bspstart\n");
295#endif
296
297}
298
299/*
300 *
301 *  _Thread_Idle_body
302 *
303 *  Replaces the one in c/src/exec/score/src/threadidlebody.c
304 *  The MSR[POW] bit is set to put the CPU into the low power mode
305 *  defined in HID0.  HID0 is set during starup in start.S.
306 *
307 */
308Thread _Thread_Idle_body(
309  uint32_t   ignored )
310{
311
312  for( ; ; )
313  {
314    asm volatile(
315      "mfmsr 3; oris 3,3,4; sync; mtmsr 3; isync; ori 3,3,0; ori 3,3,0"
316    );
317  }
318
319  return 0; /* to remove warning */
320}
Note: See TracBrowser for help on using the repository browser.