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

4.104.114.84.95
Last change on this file since a800d09c was a800d09c, checked in by Joel Sherrill <joel.sherrill@…>, on Apr 12, 2004 at 9:52:13 PM

2004-04-12 David Querbach <querbach@…>

  • .cvsignore, ChangeLog?, Makefile.am, README, bsp_specs, configure.ac, times, clock/p_clock.c, console/console.c, include/.cvsignore, include/bsp.h, include/coverhd.h, irq/irq.h, startup/bspstart.c, startup/iss555.c, startup/linkcmds, startup/start.S, wrapup/.cvsignore, wrapup/Makefile.am: New files.
  • Property mode set to 100644
File size: 6.0 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-1998.
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
32#include <libcpu/cpuIdent.h>
33#include <libcpu/spr.h>
34
35#include <bsp/irq.h>
36#include <bsp.h>
37
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 *  Use the shared implementations of the following routines.
58 *  Look in rtems/c/src/lib/libbsp/shared/bsppost.c and
59 *  rtems/c/src/lib/libbsp/shared/bsplibc.c.
60 */
61void bsp_postdriver_hook(void);
62void bsp_libc_init( void *, unsigned32, int );
63
64void BSP_panic(char *s)
65{
66  printk("%s PANIC %s\n",_RTEMS_version, s);
67  __asm__ __volatile ("sc"); 
68}
69
70void _BSP_Fatal_error(unsigned int v)
71{
72  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
73  __asm__ __volatile ("sc"); 
74}
75
76/*
77 *  bsp_pretasking_hook
78 *
79 *  Called when RTEMS initialization is complete but before interrupts and
80 *  tasking are enabled. Used to setup libc and install any BSP extensions.
81 *
82 *  Must not use libc (to do io) from here, since drivers are not yet
83 *  initialized.
84 *
85 *  Installed in the rtems_cpu_table defined in
86 *  rtems/c/src/exec/score/cpu/powerpc/rtems/new-exceptions/cpu.h by main()
87 *  below.  Called from rtems_initialize_executive() defined in
88 *  rtems/c/src/exec/sapi/src/init.c
89 *
90 *  Input parameters: NONE
91 *
92 *  Output parameters: NONE
93 *
94 *  Return values: NONE
95 */
96void bsp_pretasking_hook(void)
97{
98  /*
99   *  These are assigned addresses in the linkcmds file for the BSP. This
100   *  approach is better than having these defined as manifest constants and
101   *  compiled into the kernel, but it is still not ideal when dealing with
102   *  multiprocessor configuration in which each board as a different memory
103   *  map. A better place for defining these symbols might be the makefiles.
104   *  Consideration should also be given to developing an approach in which
105   *  the kernel and the application can be linked and burned into ROM
106   *  independently of each other.
107   */
108    unsigned char *_HeapStart = 
109      (char*)BSP_Configuration.work_space_start
110           + BSP_Configuration.work_space_size;
111    extern unsigned char _HeapEnd[];
112
113    bsp_libc_init( _HeapStart, _HeapEnd - _HeapStart, 0 );
114 
115#ifdef RTEMS_DEBUG
116  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
117#endif
118}
119
120
121/*
122 *  bsp_start()
123 *
124 *  Board-specific initialization code. Called from the generic boot_card()
125 *  function defined in rtems/c/src/lib/libbsp/shared/main.c. That function
126 *  does some of the board independent initialization. It is called from the
127 *  SS555 entry point _start() defined in
128 *  rtems/c/src/lib/libbsp/powerpc/ss555/startup/start.S
129 *
130 *  _start() has set up a stack, has zeroed the .bss section, has set up the
131 *  .data section from contents stored in ROM, has turned off interrupts,
132 *  and placed the processor in the supervisor mode.  boot_card() has left
133 *  the processor in that state when bsp_start() was called.
134 *
135 *  Input parameters: NONE
136 *
137 *  Output parameters: NONE
138 *
139 *  Return values: NONE
140 */
141void bsp_start(void)
142{
143  extern char _WorkspaceBase[];
144 
145  ppc_cpu_id_t myCpu;
146  ppc_cpu_revision_t myCpuRevision;
147  register unsigned char* intrStack;
148 
149  /*
150   * Get CPU identification dynamically.  Note that the get_ppc_cpu_type()
151   * function stores the result in global variables so that it can be used
152   * later.
153   */
154  myCpu         = get_ppc_cpu_type();
155  myCpuRevision = get_ppc_cpu_revision();
156
157  /*
158   * Initialize some SPRG registers related to irq handling
159   */
160  intrStack = (((unsigned char*)&intrStackPtr) - CPU_MINIMUM_STACK_FRAME_SIZE);
161  _write_SPRG1((unsigned int)intrStack);
162  /* signal them that we have fixed PR288 - eventually, this should go away */
163  _write_SPRG0(PPC_BSP_HAS_FIXED_PR288);
164
165  /*
166   * Install our own set of exception vectors
167   */
168  initialize_exceptions();
169
170  /*
171   *  Allocate the memory for the RTEMS Work Space.  This can come from
172   *  a variety of places: hard coded address, malloc'ed from outside
173   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
174   *  typically done by stock BSPs) by subtracting the required amount
175   *  of work space from the last physical address on the CPU board.
176   *
177   *  In this case, the memory is not malloc'ed.  It is just
178   *  "pulled from the air".
179   */
180  BSP_Configuration.work_space_start = _WorkspaceBase;
181
182  /*
183   *  initialize the CPU table for this BSP
184   */
185  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
186  Cpu_table.postdriver_hook = bsp_postdriver_hook;
187  if( Cpu_table.interrupt_stack_size < 4 * 1024 )
188      Cpu_table.interrupt_stack_size = 4 * 1024;
189
190  Cpu_table.clicks_per_usec = BSP_CRYSTAL_HZ / 4 / 1000000;
191  Cpu_table.clock_speed = BSP_CLOCK_HZ; /* for SCI baud rate generator */
192
193  /*
194   * Call this in case we use TERMIOS for console I/O
195   */
196  m5xx_uart_reserve_resources( &BSP_Configuration );
197
198  /*
199   * Initalize RTEMS IRQ system
200   */
201  BSP_rtems_irq_mng_init(0);
202}
203
Note: See TracBrowser for help on using the repository browser.