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

4.104.114.84.95
Last change on this file since e084576 was 5edbffe, checked in by Joel Sherrill <joel.sherrill@…>, on 10/22/01 at 14:46:02

01-10-22 Andy Dachs <a.dachs@…>

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