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

4.104.114.95
Last change on this file since cafa2c5 was cafa2c5, checked in by Joel Sherrill <joel.sherrill@…>, on 12/04/07 at 22:22:03

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

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