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

4.104.115
Last change on this file since fe6cce1c was fe6cce1c, checked in by Joel Sherrill <joel.sherrill@…>, on 09/15/08 at 22:05:03

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

  • startup/bspstart.c, startup/bspstart.c.nocache: Add use of bsp_get_work_area() in its own file and rely on BSP Framework to perform more initialization.
  • Property mode set to 100644
File size: 4.9 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#warning The interrupt disable mask is now stored in SPRG0, please verify that this is compatible to this BSP (see also bootcard.c).
22
23#include <bsp.h>
24#include <bsp/irq.h>
25#include <rtems/libio.h>
26#include <rtems/bspIo.h>
27#include <libcpu/cpuIdent.h>
28#include <libcpu/spr.h>
29#include <rtems/powerpc/powerpc.h>
30
31SPR_RW(SPRG1)
32
33extern unsigned long intrStackPtr;
34
35/*
36 *  Driver configuration parameters
37 */
38uint32_t   bsp_clicks_per_usec;
39uint32_t   bsp_clock_speed;
40uint32_t   bsp_serial_per_sec;         /* Serial clocks per second */
41bool       bsp_serial_external_clock;
42bool       bsp_serial_xon_xoff;
43bool       bsp_serial_cts_rts;
44uint32_t   bsp_serial_rate;
45uint32_t   bsp_timer_average_overhead; /* Average overhead of timer in ticks */
46uint32_t   bsp_timer_least_valid;      /* Least valid number from timer      */
47bool       bsp_timer_internal_clock;   /* TRUE, when timer runs with CPU clk */
48
49void BSP_panic(char *s)
50{
51  printk("%s PANIC %s\n",_RTEMS_version, s);
52  __asm__ __volatile ("sc");
53}
54
55void _BSP_Fatal_error(unsigned int v)
56{
57  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
58  __asm__ __volatile ("sc");
59}
60
61/*
62 *  bsp_start()
63 *
64 *  Board-specific initialization code. Called from the generic boot_card()
65 *  function defined in rtems/c/src/lib/libbsp/shared/main.c. That function
66 *  does some of the board independent initialization. It is called from the
67 *  MBX8xx entry point _start() defined in
68 *  rtems/c/src/lib/libbsp/powerpc/mbx8xx/startup/start.S
69 *
70 *  _start() has set up a stack, has zeroed the .bss section, has turned off
71 *  interrupts, and placed the processor in the supervisor mode. boot_card()
72 *  has left the processor in that state when bsp_start() was called.
73 *
74 *  RUNS WITH ADDRESS TRANSLATION AND CACHING TURNED OFF!
75 *  ASSUMES THAT THE VIRTUAL ADDRESSES WILL BE IDENTICAL TO THE PHYSICAL
76 *  ADDRESSES. Software-controlled address translation would be required
77 *  otherwise.
78 *
79 *  Input parameters: NONE
80 *
81 *  Output parameters: NONE
82 *
83 *  Return values: NONE
84 */
85void bsp_start(void)
86{
87  ppc_cpu_id_t myCpu;
88  ppc_cpu_revision_t myCpuRevision;
89  register unsigned char* intrStack;
90
91  /*
92   * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function
93   * store the result in global variables so that it can be used latter...
94   */
95  myCpu         = get_ppc_cpu_type();
96  myCpuRevision = get_ppc_cpu_revision();
97
98  mmu_init();
99
100  /*
101   * Enable instruction and data caches. Do not force writethrough mode.
102   */
103#if NVRAM_CONFIGURE == 1
104  if ( nvram->cache_mode & 0x02 )
105    rtems_cache_enable_instruction();
106  if ( nvram->cache_mode & 0x01 )
107    rtems_cache_enable_data();
108#else
109#ifdef INSTRUCTION_CACHE_ENABLE
110  rtems_cache_enable_instruction();
111#endif
112#ifdef DATA_CACHE_ENABLE
113  rtems_cache_enable_data();
114#endif
115#endif
116  /*
117   * Initialize some SPRG registers related to irq handling
118   */
119
120  intrStack = (((unsigned char*)&intrStackPtr) - PPC_MINIMUM_STACK_FRAME_SIZE);
121  _write_SPRG1((unsigned int)intrStack);
122
123  /*
124   * Install our own set of exception vectors
125   */
126  initialize_exceptions();
127
128  /*
129   *  initialize the device driver parameters
130   */
131
132#if    ( defined(mbx860_001b) || \
133         defined(mbx860_002b) || \
134         defined(mbx860_003b) || \
135         defined(mbx860_003b) || \
136         defined(mbx860_004b) || \
137         defined(mbx860_005b) || \
138         defined(mbx860_006b) || \
139         defined(mbx821_001b) || \
140         defined(mbx821_002b) || \
141         defined(mbx821_003b) || \
142         defined(mbx821_004b) || \
143         defined(mbx821_005b) || \
144         defined(mbx821_006b))
145  bsp_clicks_per_usec = 0;  /* for 32768Hz extclk */
146#else
147  bsp_clicks_per_usec = 1;  /* for 4MHz extclk */
148#endif
149
150  bsp_serial_per_sec = 10000000;
151  bsp_serial_external_clock = true;
152  bsp_serial_xon_xoff = false;
153  bsp_serial_cts_rts = true;
154  bsp_serial_rate = 9600;
155#if ( defined(mbx821_001) || defined(mbx821_001b) || defined(mbx860_001b) )
156  bsp_clock_speed = 50000000;
157  bsp_timer_average_overhead = 3;
158  bsp_timer_least_valid = 3;
159#else
160  bsp_clock_speed = 40000000;
161  bsp_timer_average_overhead = 3;
162  bsp_timer_least_valid = 3;
163#endif
164
165  m8xx.scc2.sccm=0;
166  m8xx.scc2p.rbase=0;
167  m8xx.scc2p.tbase=0;
168  m8xx_cp_execute_cmd( M8xx_CR_OP_STOP_TX | M8xx_CR_CHAN_SCC2 );
169  /*
170   * Initalize RTEMS IRQ system
171   */
172  BSP_rtems_irq_mng_init(0);
173#ifdef SHOW_MORE_INIT_SETTINGS
174  printk("Exit from bspstart\n");
175#endif
176
177}
Note: See TracBrowser for help on using the repository browser.