source: rtems/c/src/lib/libbsp/powerpc/mbx8xx/startup/bspstart.c @ 1899fe4

4.104.114.84.95
Last change on this file since 1899fe4 was 1899fe4, checked in by Ralf Corsepius <ralf.corsepius@…>, on 02/17/05 at 04:29:15

2005-02-17 Ralf Corsepius <ralf.corsepius@…>

  • startup/bspstart.c: include <rtems/powerpc/powerpc.h>. Use PPC_MINIMUM_STACK_FRAME_SIZE instead of CPU_MINIMUM_STACK_FRAME_SIZE.
  • Property mode set to 100644
File size: 6.8 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 *  Modifications for MBX860:
16 *  Copyright (c) 1999, National Research Council of Canada
17 *
18 *  $Id$
19 */
20
21#include <string.h>
22
23#include <bsp.h>
24#include <bsp/irq.h>
25#include <rtems/libio.h>
26#include <rtems/libcsupport.h>
27#include <rtems/bspIo.h>
28#include <libcpu/cpuIdent.h>
29#include <libcpu/spr.h>
30#include <rtems/powerpc/powerpc.h>
31
32SPR_RW(SPRG0)
33SPR_RW(SPRG1)
34
35/*
36 *  The original table from the application (in ROM) and our copy of it with
37 *  some changes. Configuration is defined in <confdefs.h>. Make sure that
38 *  our configuration tables are uninitialized so that they get allocated in
39 *  the .bss section (RAM).
40 */
41extern rtems_configuration_table Configuration;
42extern unsigned long intrStackPtr;
43rtems_configuration_table  BSP_Configuration;
44
45rtems_cpu_table Cpu_table;
46
47char *rtems_progname;
48
49/*
50 *  Use the shared implementations of the following routines.
51 *  Look in rtems/c/src/lib/libbsp/shared/bsppost.c and
52 *  rtems/c/src/lib/libbsp/shared/bsplibc.c.
53 */
54void bsp_postdriver_hook(void);
55void bsp_libc_init( void *, uint32_t, int );
56
57void BSP_panic(char *s)
58{
59  printk("%s PANIC %s\n",_RTEMS_version, s);
60  __asm__ __volatile ("sc");
61}
62
63void _BSP_Fatal_error(unsigned int v)
64{
65  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
66  __asm__ __volatile ("sc");
67}
68
69/*
70 *  bsp_pretasking_hook
71 *
72 *  Called when RTEMS initialization is complete but before interrupts and
73 *  tasking are enabled. Used to setup libc and install any BSP extensions.
74 *
75 *  Must not use libc (to do io) from here, since drivers are not yet
76 *  initialized.
77 *
78 *  Installed in the rtems_cpu_table defined in
79 *  rtems/c/src/exec/score/cpu/m68k/cpu.h in main() below. Called from
80 *  rtems_initialize_executive() defined in rtems/c/src/exec/sapi/src/init.c
81 *
82 *  Input parameters: NONE
83 *
84 *  Output parameters: NONE
85 *
86 *  Return values: NONE
87 */
88void bsp_pretasking_hook(void)
89{
90  /*
91   *  These are assigned addresses in the linkcmds file for the BSP. This
92   *  approach is better than having these defined as manifest constants and
93   *  compiled into the kernel, but it is still not ideal when dealing with
94   *  multiprocessor configuration in which each board as a different memory
95   *  map. A better place for defining these symbols might be the makefiles.
96   *  Consideration should also be given to developing an approach in which
97   *  the kernel and the application can be linked and burned into ROM
98   *  independently of each other.
99   */
100    extern unsigned char _HeapStart;
101    extern unsigned char _HeapEnd;
102
103    bsp_libc_init( &_HeapStart, &_HeapEnd - &_HeapStart, 0 );
104
105#ifdef RTEMS_DEBUG
106  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
107#endif
108}
109
110/*
111 *  bsp_start()
112 *
113 *  Board-specific initialization code. Called from the generic boot_card()
114 *  function defined in rtems/c/src/lib/libbsp/shared/main.c. That function
115 *  does some of the board independent initialization. It is called from the
116 *  MBX8xx entry point _start() defined in
117 *  rtems/c/src/lib/libbsp/powerpc/mbx8xx/startup/start.S
118 *
119 *  _start() has set up a stack, has zeroed the .bss section, has turned off
120 *  interrupts, and placed the processor in the supervisor mode. boot_card()
121 *  has left the processor in that state when bsp_start() was called.
122 *
123 *  RUNS WITH ADDRESS TRANSLATION AND CACHING TURNED OFF!
124 *  ASSUMES THAT THE VIRTUAL ADDRESSES WILL BE IDENTICAL TO THE PHYSICAL
125 *  ADDRESSES. Software-controlled address translation would be required
126 *  otherwise.
127 *
128 *  Input parameters: NONE
129 *
130 *  Output parameters: NONE
131 *
132 *  Return values: NONE
133 */
134void bsp_start(void)
135{
136  extern void *_WorkspaceBase;
137
138  ppc_cpu_id_t myCpu;
139  ppc_cpu_revision_t myCpuRevision;
140  register unsigned char* intrStack;
141
142  /*
143   * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
144   * store the result in global variables so that it can be used latter...
145   */
146  myCpu         = get_ppc_cpu_type();
147  myCpuRevision = get_ppc_cpu_revision();
148
149  mmu_init();
150
151  /*
152   * Enable instruction and data caches. Do not force writethrough mode.
153   */
154#if NVRAM_CONFIGURE == 1
155  if ( nvram->cache_mode & 0x02 )
156    rtems_cache_enable_instruction();
157  if ( nvram->cache_mode & 0x01 )
158    rtems_cache_enable_data();
159#else
160#ifdef INSTRUCTION_CACHE_ENABLE
161  rtems_cache_enable_instruction();
162#endif
163#ifdef DATA_CACHE_ENABLE
164  rtems_cache_enable_data();
165#endif
166#endif
167  /*
168   * Initialize some SPRG registers related to irq handling
169   */
170
171  intrStack = (((unsigned char*)&intrStackPtr) - PPC_MINIMUM_STACK_FRAME_SIZE);
172  _write_SPRG1((unsigned int)intrStack);
173  /* signal them that we have fixed PR288 - eventually, this should go away */
174  _write_SPRG0(PPC_BSP_HAS_FIXED_PR288);
175
176  /*
177   * Install our own set of exception vectors
178   */
179  initialize_exceptions();
180
181  /*
182   *  Allocate the memory for the RTEMS Work Space.  This can come from
183   *  a variety of places: hard coded address, malloc'ed from outside
184   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
185   *  typically done by stock BSPs) by subtracting the required amount
186   *  of work space from the last physical address on the CPU board.
187   *
188   *  In this case, the memory is not malloc'ed.  It is just
189   *  "pulled from the air".
190   */
191  BSP_Configuration.work_space_start = (void *)&_WorkspaceBase;
192
193  /*
194   *  initialize the CPU table for this BSP
195   */
196
197  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
198  Cpu_table.postdriver_hook = bsp_postdriver_hook;
199  if( Cpu_table.interrupt_stack_size < 4 * 1024 )
200      Cpu_table.interrupt_stack_size = 4 * 1024;
201
202  Cpu_table.clicks_per_usec = 1;  /* for 4MHz extclk */
203  Cpu_table.serial_per_sec = 10000000;
204  Cpu_table.serial_external_clock = 1;
205  Cpu_table.serial_xon_xoff = 0;
206  Cpu_table.serial_cts_rts = 1;
207  Cpu_table.serial_rate = 9600;
208#if ( defined(mbx821_001) || defined(mbx821_001b) || defined(mbx860_001b) )
209  Cpu_table.clock_speed = 50000000;
210  Cpu_table.timer_average_overhead = 3;
211  Cpu_table.timer_least_valid = 3;
212#else
213  Cpu_table.clock_speed = 40000000;
214  Cpu_table.timer_average_overhead = 3;
215  Cpu_table.timer_least_valid = 3;
216#endif
217
218  /*
219   * Call this in case we use TERMIOS for console I/O
220   */
221  m8xx_uart_reserve_resources( &BSP_Configuration );
222
223  m8xx.scc2.sccm=0;
224  m8xx.scc2p.rbase=0;
225  m8xx.scc2p.tbase=0;
226  m8xx_cp_execute_cmd( M8xx_CR_OP_STOP_TX | M8xx_CR_CHAN_SCC2 );
227  /*
228   * Initalize RTEMS IRQ system
229   */
230  BSP_rtems_irq_mng_init(0);
231#ifdef SHOW_MORE_INIT_SETTINGS
232  printk("Exit from bspstart\n");
233#endif
234
235}
Note: See TracBrowser for help on using the repository browser.