source: rtems/c/src/lib/libbsp/powerpc/mbx8xx/startup/bspstart.c.nocache @ 310a2ec

4.104.114.84.95
Last change on this file since 310a2ec was 8ef3818, checked in by Joel Sherrill <joel.sherrill@…>, on 06/12/00 at 19:57:02

Patch from John Cotton <john.cotton@…>, Charles-Antoine Gauthier
<charles.gauthier@…>, and Darlene A. Stewart
<Darlene.Stewart@…> to add support for a number of very
significant things:

+ BSPs for many variations on the Motorola MBX8xx board series
+ Cache Manager including initial support for m68040

and PowerPC

+ Rework of mpc8xx libcpu code so all mpc8xx CPUs now use

same code base.

+ Rework of eth_comm BSP to utiltize above.

John reports this works on the 821 and 860

  • 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 *  Copyright assigned to U.S. Government, 1994.
11 *
12 *  The license and distribution terms for this file may be
13 *  found in the file LICENSE in this distribution or at
14 *  http://www.OARcorp.com/rtems/license.html.
15 *
16 *  Modifications for MBX860:
17 *  Copyright (c) 1999, National Research Council of Canada
18 *
19 *  $Id$
20 */
21
22#include <bsp.h>
23#include <rtems/libio.h>
24 
25#include <libcsupport.h>
26 
27#include <string.h>
28 
29#ifdef STACK_CHECKER_ON
30#include <stackchk.h>
31#endif
32
33/*
34 *  The original table from the application (in ROM) and our copy of it with
35 *  some changes. Configuration is defined in <confdefs.h>. Make sure that
36 *  our configuration tables are uninitialized so that they get allocated in
37 *  the .bss section (RAM).
38 */
39extern rtems_configuration_table Configuration;
40rtems_configuration_table  BSP_Configuration;
41
42rtems_cpu_table Cpu_table;
43
44char *rtems_progname;
45
46/*
47 *  Use the shared implementations of the following routines.
48 *  Look in rtems/c/src/lib/libbsp/shared/bsppost.c and
49 *  rtems/c/src/lib/libbsp/shared/bsplibc.c.
50 */
51void bsp_postdriver_hook(void);
52void bsp_libc_init( void *, unsigned32, int );
53
54/*
55 *  bsp_pretasking_hook
56 *
57 *  Called when RTEMS initialization is complete but before interrupts and
58 *  tasking are enabled. Used to setup libc and install any BSP extensions.
59 *
60 *  Must not use libc (to do io) from here, since drivers are not yet
61 *  initialized.
62 *
63 *  Installed in the rtems_cpu_table defined in
64 *  rtems/c/src/exec/score/cpu/m68k/cpu.h in main() below. Called from
65 *  rtems_initialize_executive() defined in rtems/c/src/exec/sapi/src/init.c
66 *
67 *  Input parameters: NONE
68 *
69 *  Output parameters: NONE
70 *
71 *  Return values: NONE
72 */
73void bsp_pretasking_hook(void)
74{
75  /*
76   *  These are assigned addresses in the linkcmds file for the BSP. This
77   *  approach is better than having these defined as manifest constants and
78   *  compiled into the kernel, but it is still not ideal when dealing with
79   *  multiprocessor configuration in which each board as a different memory
80   *  map. A better place for defining these symbols might be the makefiles.
81   *  Consideration should also be given to developing an approach in which
82   *  the kernel and the application can be linked and burned into ROM
83   *  independently of each other.
84   */
85    extern unsigned char _HeapStart;
86    extern unsigned char _HeapEnd;
87
88    bsp_libc_init( &_HeapStart, &_HeapEnd - &_HeapStart, 0 );
89 
90#ifdef STACK_CHECKER_ON
91  /*
92   *  Initialize the stack bounds checker
93   *  We can either turn it on here or from the app.
94   */
95 
96  Stack_check_Initialize();
97#endif /* STACK_CHECKER_ON */
98 
99#ifdef RTEMS_DEBUG
100  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
101#endif
102}
103
104
105/*
106 *  bsp_start()
107 *
108 *  Board-specific initialization code. Called from the generic boot_card()
109 *  function defined in rtems/c/src/lib/libbsp/shared/main.c. That function
110 *  does some of the board independent initialization. It is called from the
111 *  MBX8xx entry point _start() defined in
112 *  rtems/c/src/lib/libbsp/powerpc/mbx8xx/startup/start.S
113 *
114 *  _start() has set up a stack, has zeroed the .bss section, has turned off
115 *  interrupts, and placed the processor in the supervisor mode. boot_card()
116 *  has left the processor in that state when bsp_start() was called.
117 *
118 *  RUNS WITH ADDRESS TRANSLATION AND CACHING TURNED OFF!
119 *  ASSUMES THAT THE VIRTUAL ADDRESSES WILL BE IDENTICAL TO THE PHYSICAL
120 *  ADDRESSES. Software-controlled address translation would be required
121 *  otherwise.
122 *
123 *  Input parameters: NONE
124 *
125 *  Output parameters: NONE
126 *
127 *  Return values: NONE
128 */
129void bsp_start(void)
130{
131  extern void *_WorkspaceBase;
132  unsigned32 r1;
133
134  mmu_init();
135 
136  /*
137   * Enable instruction and data caches. Do not force writethrough mode.
138   */
139  #ifdef INSTRUCTION_CACHE_ENABLE
140  r1 = M8xx_CACHE_CMD_ENABLE;
141  _mtspr( M8xx_IC_CST, r1 );
142  _isync;
143  #endif
144
145  /*
146   * Warning: EPPCBug 1.1 chokes to death if the data cache is turned on.
147   * Set DATA_CACHE_ENABLE to zero in mbx8xx.cfg if EPPCBUG is used.
148   */
149  #ifdef DATA_CACHE_ENABLE
150  r1 = M8xx_CACHE_CMD_ENABLE;
151  _mtspr( M8xx_DC_CST, r1 );
152  _isync;
153  #endif
154   
155  /*
156   *  Allocate the memory for the RTEMS Work Space.  This can come from
157   *  a variety of places: hard coded address, malloc'ed from outside
158   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
159   *  typically done by stock BSPs) by subtracting the required amount
160   *  of work space from the last physical address on the CPU board.
161   *
162   *  In this case, the memory is not malloc'ed.  It is just
163   *  "pulled from the air".
164   */
165  BSP_Configuration.work_space_start = (void *)&_WorkspaceBase;
166
167  /*
168   *  initialize the CPU table for this BSP
169   */
170
171  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
172  Cpu_table.postdriver_hook = bsp_postdriver_hook;
173  if( Cpu_table.interrupt_stack_size < 4 * 1024 )
174      Cpu_table.interrupt_stack_size = 4 * 1024;
175
176  Cpu_table.clicks_per_usec = 1;  /* for 4MHz extclk */
177  Cpu_table.serial_per_sec = 10000000;
178  Cpu_table.serial_external_clock = 1;
179  Cpu_table.serial_xon_xoff = 0;
180  Cpu_table.serial_cts_rts = 1;
181  Cpu_table.serial_rate = 9600;
182#if ( defined(mbx821_001) || defined(mbx821_001b) || defined(mbx860_001b) )
183  Cpu_table.clock_speed = 50000000;
184  Cpu_table.timer_average_overhead = 3;
185  Cpu_table.timer_least_valid = 3;
186#else
187  Cpu_table.clock_speed = 40000000;
188  Cpu_table.timer_average_overhead = 3;
189  Cpu_table.timer_least_valid = 3;
190#endif
191
192  /*
193   * Call this in case we use TERMIOS for console I/O
194   */
195  m8xx_uart_reserve_resources( &BSP_Configuration );
196
197  m8xx.scc2.sccm=0;
198  m8xx.scc2p.rbase=0;
199  m8xx.scc2p.tbase=0;
200  m8xx_cp_execute_cmd( M8xx_CR_OP_STOP_TX | M8xx_CR_CHAN_SCC2 );
201}
202
Note: See TracBrowser for help on using the repository browser.