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

4.104.114.84.95
Last change on this file since fed03bc was fed03bc, checked in by Joel Sherrill <joel.sherrill@…>, on Nov 1, 2000 at 9:22:48 PM

2000-11-01 Joel Sherrill <joel@…>

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