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

4.104.114.95
Last change on this file since b67a822 was b67a822, checked in by Joel Sherrill <joel.sherrill@…>, on 05/15/08 at 15:54:11

2008-05-15 Joel Sherrill <joel.sherrill@…>

  • startup/bspstart.c, startup/bspstart.c.nocache: Add capability for bootcard.c BSP Initialization Framework to ask the BSP where it has memory for the RTEMS Workspace and C Program Heap. These collectively are referred to as work area. If the BSP supports this, then it does not have to include code to split the available memory between the two areas. This reduces the amount of code in the BSP specific bspstart.c file. Additionally, the shared framework can initialize the C Library, call rtems_debug_enable(), and dirty the work area memory. Until most/all BSPs support this new capability, if the BSP supports this, it should call RTEMS_BSP_BOOTCARD_HANDLES_RAM_ALLOCATION from its configure.ac. When the transition is complete, this autoconf macro can be removed.
  • Property mode set to 100644
File size: 5.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-2007.
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 *  Driver configuration parameters
29 */
30uint32_t   bsp_clicks_per_usec;
31uint32_t   bsp_serial_per_sec;         /* Serial clocks per second */
32boolean    bsp_serial_external_clock;
33boolean    bsp_serial_xon_xoff;
34boolean    bsp_serial_cts_rts;
35uint32_t   bsp_serial_rate;
36uint32_t   bsp_timer_average_overhead; /* Average overhead of timer in ticks */
37uint32_t   bsp_timer_least_valid;      /* Least valid number from timer      */
38boolean    bsp_timer_internal_clock;   /* TRUE, when timer runs with CPU clk */
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_libc_init( void *, uint32_t, int );
46
47/*
48 *  bsp_pretasking_hook
49 *
50 *  Called when RTEMS initialization is complete but before interrupts and
51 *  tasking are enabled. Used to setup libc and install any BSP extensions.
52 *
53 *  Must not use libc (to do io) from here, since drivers are not yet
54 *  initialized.
55 *
56 *  Input parameters: NONE
57 *
58 *  Output parameters: NONE
59 *
60 *  Return values: NONE
61 */
62void bsp_pretasking_hook(void)
63{
64  /*
65   *  These are assigned addresses in the linkcmds file for the BSP. This
66   *  approach is better than having these defined as manifest constants and
67   *  compiled into the kernel, but it is still not ideal when dealing with
68   *  multiprocessor configuration in which each board as a different memory
69   *  map. A better place for defining these symbols might be the makefiles.
70   *  Consideration should also be given to developing an approach in which
71   *  the kernel and the application can be linked and burned into ROM
72   *  independently of each other.
73   */
74  extern unsigned char _HeapStart;
75  extern unsigned char _HeapEnd;
76
77  bsp_libc_init( &_HeapStart, &_HeapEnd - &_HeapStart, 0 );
78}
79
80
81/*
82 *  bsp_start()
83 *
84 *  Board-specific initialization code. Called from the generic boot_card()
85 *  function defined in rtems/c/src/lib/libbsp/shared/main.c. That function
86 *  does some of the board independent initialization. It is called from the
87 *  MBX8xx entry point _start() defined in
88 *  rtems/c/src/lib/libbsp/powerpc/mbx8xx/startup/start.S
89 *
90 *  _start() has set up a stack, has zeroed the .bss section, has turned off
91 *  interrupts, and placed the processor in the supervisor mode. boot_card()
92 *  has left the processor in that state when bsp_start() was called.
93 *
94 *  RUNS WITH ADDRESS TRANSLATION AND CACHING TURNED OFF!
95 *  ASSUMES THAT THE VIRTUAL ADDRESSES WILL BE IDENTICAL TO THE PHYSICAL
96 *  ADDRESSES. Software-controlled address translation would be required
97 *  otherwise.
98 *
99 *  Input parameters: NONE
100 *
101 *  Output parameters: NONE
102 *
103 *  Return values: NONE
104 */
105void bsp_start(void)
106{
107  extern void *_WorkspaceBase;
108  uint32_t   r1;
109
110  mmu_init();
111 
112  /*
113   * Enable instruction and data caches. Do not force writethrough mode.
114   */
115  #ifdef INSTRUCTION_CACHE_ENABLE
116  r1 = M8xx_CACHE_CMD_ENABLE;
117  _mtspr( M8xx_IC_CST, r1 );
118  _isync;
119  #endif
120
121  /*
122   * Warning: EPPCBug 1.1 chokes to death if the data cache is turned on.
123   * Set DATA_CACHE_ENABLE to zero in mbx8xx.cfg if EPPCBUG is used.
124   */
125  #ifdef DATA_CACHE_ENABLE
126  r1 = M8xx_CACHE_CMD_ENABLE;
127  _mtspr( M8xx_DC_CST, r1 );
128  _isync;
129  #endif
130   
131  /*
132   *  Allocate the memory for the RTEMS Work Space.  This can come from
133   *  a variety of places: hard coded address, malloc'ed from outside
134   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
135   *  typically done by stock BSPs) by subtracting the required amount
136   *  of work space from the last physical address on the CPU board.
137   *
138   *  In this case, the memory is not malloc'ed.  It is just
139   *  "pulled from the air".
140   */
141  Configuration.work_space_start = (void *)&_WorkspaceBase;
142
143  /*
144   *  initialize the device driver parameters
145   */
146  bsp_clicks_per_usec = 1;  /* for 4MHz extclk */
147  bsp_serial_per_sec = 10000000;
148  bsp_serial_external_clock = 1;
149  bsp_serial_xon_xoff = 0;
150  bsp_serial_cts_rts = 1;
151  bsp_serial_rate = 9600;
152#if ( defined(mbx821_001) || defined(mbx821_001b) || defined(mbx860_001b) )
153  bsp_clock_speed = 50000000;
154  bsp_timer_average_overhead = 3;
155  bsp_timer_least_valid = 3;
156#else
157  bsp_clock_speed = 40000000;
158  bsp_timer_average_overhead = 3;
159  bsp_timer_least_valid = 3;
160#endif
161
162  m8xx.scc2.sccm=0;
163  m8xx.scc2p.rbase=0;
164  m8xx.scc2p.tbase=0;
165  m8xx_cp_execute_cmd( M8xx_CR_OP_STOP_TX | M8xx_CR_CHAN_SCC2 );
166}
167
Note: See TracBrowser for help on using the repository browser.