source: rtems/c/src/lib/libbsp/powerpc/mbx8xx/startup/bspstart.c.nocache @ 1e7cbc5

4.104.114.84.95
Last change on this file since 1e7cbc5 was 1e7cbc5, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 18:52:26

2003-09-04 Joel Sherrill <joel@…>

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