source: rtems/c/src/lib/libbsp/powerpc/ss555/startup/bspstart.c @ 07e9642c

4.104.114.9
Last change on this file since 07e9642c was 07e9642c, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 28, 2007 at 9:44:46 PM

2007-11-28 Joel Sherrill <joel.sherrill@…>

  • startup/bspstart.c: Eliminate PowerPC specific elements from the CPU Table. They have been replaced with variables named bsp_XXX as needed.
  • Property mode set to 100644
File size: 6.2 KB
Line 
1/*  bspstart.c
2 *
3 *  This set of routines 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 *  COPYRIGHT (c) 1989-2007.
9 *  On-Line Applications Research Corporation (OAR).
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.com/license/LICENSE.
14 *
15 *  SS555 port sponsored by Defence Research and Development Canada - Suffield
16 *  Copyright (C) 2004, Real-Time Systems Inc. (querbach@realtime.bc.ca)
17 *
18 *  Derived from c/src/lib/libbsp/powerpc/mbx8xx/startup/bspstart.c:
19 *
20 *  Modifications for MBX860:
21 *  Copyright (c) 1999, National Research Council of Canada
22 *
23 *  $Id$
24 */
25
26#include <string.h>
27
28#include <rtems/libio.h>
29#include <rtems/libcsupport.h>
30#include <rtems/bspIo.h>
31#include <rtems/powerpc/powerpc.h>
32
33#include <libcpu/cpuIdent.h>
34#include <libcpu/spr.h>
35
36#include <bsp/irq.h>
37#include <bsp.h>
38
39SPR_RW(SPRG0)
40SPR_RW(SPRG1)
41
42/*
43 *  The original table from the application (in ROM) and our copy of it with
44 *  some changes. Configuration is defined in <confdefs.h>. Make sure that
45 *  our configuration tables are uninitialized so that they get allocated in
46 *  the .bss section (RAM).
47 */
48extern rtems_configuration_table Configuration;
49extern unsigned long intrStackPtr;
50rtems_configuration_table  BSP_Configuration;
51
52rtems_cpu_table Cpu_table;
53
54char *rtems_progname;
55
56/*
57 *  Driver configuration parameters
58 */
59uint32_t   bsp_clicks_per_usec;
60uint32_t   bsp_clock_speed;            /* Serial clocks per second */
61
62/*
63 *  Use the shared implementations of the following routines.
64 *  Look in rtems/c/src/lib/libbsp/shared/bsppost.c and
65 *  rtems/c/src/lib/libbsp/shared/bsplibc.c.
66 */
67void bsp_postdriver_hook(void);
68void bsp_libc_init( void *, uint32_t, int );
69
70void BSP_panic(char *s)
71{
72  printk("%s PANIC %s\n",_RTEMS_version, s);
73  __asm__ __volatile ("sc");
74}
75
76void _BSP_Fatal_error(unsigned int v)
77{
78  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
79  __asm__ __volatile ("sc");
80}
81
82/*
83 *  bsp_pretasking_hook
84 *
85 *  Called when RTEMS initialization is complete but before interrupts and
86 *  tasking are enabled. Used to setup libc and install any BSP extensions.
87 *
88 *  Must not use libc (to do io) from here, since drivers are not yet
89 *  initialized.
90 *
91 *  Installed in the rtems_cpu_table defined in
92 *  rtems/c/src/exec/score/cpu/powerpc/rtems/new-exceptions/cpu.h by main()
93 *  below.  Called from rtems_initialize_executive() defined in
94 *  rtems/c/src/exec/sapi/src/init.c
95 *
96 *  Input parameters: NONE
97 *
98 *  Output parameters: NONE
99 *
100 *  Return values: NONE
101 */
102void bsp_pretasking_hook(void)
103{
104  /*
105   *  These are assigned addresses in the linkcmds file for the BSP. This
106   *  approach is better than having these defined as manifest constants and
107   *  compiled into the kernel, but it is still not ideal when dealing with
108   *  multiprocessor configuration in which each board as a different memory
109   *  map. A better place for defining these symbols might be the makefiles.
110   *  Consideration should also be given to developing an approach in which
111   *  the kernel and the application can be linked and burned into ROM
112   *  independently of each other.
113   */
114    uint8_t *_HeapStart =
115      (uint8_t *)BSP_Configuration.work_space_start
116           + BSP_Configuration.work_space_size;
117    extern uint8_t _HeapEnd[];
118
119    bsp_libc_init( _HeapStart, _HeapEnd - _HeapStart, 0 );
120
121#ifdef RTEMS_DEBUG
122  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
123#endif
124}
125
126/*
127 *  bsp_start()
128 *
129 *  Board-specific initialization code. Called from the generic boot_card()
130 *  function defined in rtems/c/src/lib/libbsp/shared/main.c. That function
131 *  does some of the board independent initialization. It is called from the
132 *  SS555 entry point _start() defined in
133 *  rtems/c/src/lib/libbsp/powerpc/ss555/startup/start.S
134 *
135 *  _start() has set up a stack, has zeroed the .bss section, has set up the
136 *  .data section from contents stored in ROM, has turned off interrupts,
137 *  and placed the processor in the supervisor mode.  boot_card() has left
138 *  the processor in that state when bsp_start() was called.
139 *
140 *  Input parameters: NONE
141 *
142 *  Output parameters: NONE
143 *
144 *  Return values: NONE
145 */
146void bsp_start(void)
147{
148  extern char _WorkspaceBase[];
149
150  ppc_cpu_id_t myCpu;
151  ppc_cpu_revision_t myCpuRevision;
152  register unsigned char* intrStack;
153
154  /*
155   * Get CPU identification dynamically.  Note that the get_ppc_cpu_type()
156   * function stores the result in global variables so that it can be used
157   * later.
158   */
159  myCpu         = get_ppc_cpu_type();
160  myCpuRevision = get_ppc_cpu_revision();
161
162  /*
163   * Initialize some SPRG registers related to irq handling
164   */
165  intrStack = (((unsigned char*)&intrStackPtr) - PPC_MINIMUM_STACK_FRAME_SIZE);
166  _write_SPRG1((unsigned int)intrStack);
167  /* signal them that we have fixed PR288 - eventually, this should go away */
168  _write_SPRG0(PPC_BSP_HAS_FIXED_PR288);
169
170  /*
171   * Install our own set of exception vectors
172   */
173  initialize_exceptions();
174
175  /*
176   *  Allocate the memory for the RTEMS Work Space.  This can come from
177   *  a variety of places: hard coded address, malloc'ed from outside
178   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
179   *  typically done by stock BSPs) by subtracting the required amount
180   *  of work space from the last physical address on the CPU board.
181   *
182   *  In this case, the memory is not malloc'ed.  It is just
183   *  "pulled from the air".
184   */
185  BSP_Configuration.work_space_start = _WorkspaceBase;
186
187  /*
188   *  initialize the CPU table for this BSP
189   */
190  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
191  Cpu_table.postdriver_hook = bsp_postdriver_hook;
192  if( Cpu_table.interrupt_stack_size < 4 * 1024 )
193      Cpu_table.interrupt_stack_size = 4 * 1024;
194
195  bsp_clicks_per_usec = BSP_CRYSTAL_HZ / 4 / 1000000;
196  bsp_clock_speed     = BSP_CLOCK_HZ;   /* for SCI baud rate generator */
197
198  /*
199   * Call this in case we use TERMIOS for console I/O
200   */
201  m5xx_uart_reserve_resources( &BSP_Configuration );
202
203  /*
204   * Initalize RTEMS IRQ system
205   */
206  BSP_rtems_irq_mng_init(0);
207}
Note: See TracBrowser for help on using the repository browser.