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

4.104.114.84.95
Last change on this file since 5e77d129 was 5e77d129, checked in by Joel Sherrill <joel.sherrill@…>, on 06/14/00 at 20:32:44

Patch from John Cotton <john.cotton@…> to correct cache
routine naming to follow RTEMS package/object.method rule.
This patch also eliminated calls to the obsolete routine
m68k_enable_caching.

  • Property mode set to 100644
File size: 5.7 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 
133  mmu_init();
134 
135  /*
136   * Enable instruction and data caches. Do not force writethrough mode.
137   */
138  #ifdef INSTRUCTION_CACHE_ENABLE
139        rtems_cache_enable_instruction();
140  #endif
141
142  #ifdef DATA_CACHE_ENABLE
143        rtems_cache_enable_data();
144  #endif
145   
146  /*
147   *  Allocate the memory for the RTEMS Work Space.  This can come from
148   *  a variety of places: hard coded address, malloc'ed from outside
149   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
150   *  typically done by stock BSPs) by subtracting the required amount
151   *  of work space from the last physical address on the CPU board.
152   *
153   *  In this case, the memory is not malloc'ed.  It is just
154   *  "pulled from the air".
155   */
156  BSP_Configuration.work_space_start = (void *)&_WorkspaceBase;
157
158  /*
159   *  initialize the CPU table for this BSP
160   */
161
162  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
163  Cpu_table.postdriver_hook = bsp_postdriver_hook;
164  if( Cpu_table.interrupt_stack_size < 4 * 1024 )
165      Cpu_table.interrupt_stack_size = 4 * 1024;
166
167  Cpu_table.clicks_per_usec = 1;  /* for 4MHz extclk */
168  Cpu_table.serial_per_sec = 10000000;
169  Cpu_table.serial_external_clock = 1;
170  Cpu_table.serial_xon_xoff = 0;
171  Cpu_table.serial_cts_rts = 1;
172  Cpu_table.serial_rate = 9600;
173#if ( defined(mbx821_001) || defined(mbx821_001b) || defined(mbx860_001b) )
174  Cpu_table.clock_speed = 50000000;
175  Cpu_table.timer_average_overhead = 3;
176  Cpu_table.timer_least_valid = 3;
177#else
178  Cpu_table.clock_speed = 40000000;
179  Cpu_table.timer_average_overhead = 3;
180  Cpu_table.timer_least_valid = 3;
181#endif
182
183  /*
184   * Call this in case we use TERMIOS for console I/O
185   */
186  m8xx_uart_reserve_resources( &BSP_Configuration );
187
188  m8xx.scc2.sccm=0;
189  m8xx.scc2p.rbase=0;
190  m8xx.scc2p.tbase=0;
191  m8xx_cp_execute_cmd( M8xx_CR_OP_STOP_TX | M8xx_CR_CHAN_SCC2 );
192}
193
Note: See TracBrowser for help on using the repository browser.