source: rtems/c/src/lib/libbsp/powerpc/ss555/startup/bspstart.c @ c053657

4.104.114.95
Last change on this file since c053657 was c053657, checked in by Joel Sherrill <joel.sherrill@…>, on 04/23/08 at 21:50:55

2008-04-23 Joel Sherrill <joel.sherrill@…>

  • startup/bspstart.c: Remove all references to console_reserve_resources and termios_reserve_resources.
  • Property mode set to 100644
File size: 5.3 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 *  SS555 port sponsored by Defence Research and Development Canada - Suffield
16 *  Copyright (C) 2004, Real-Time Systems Inc. (querbach@realtime.bc.ca)
17 *
18 *  Derived from c/src/lib/libbsp/powerpc/mbx8xx/startup/bspstart.c:
19 *
20 *  Modifications for MBX860:
21 *  Copyright (c) 1999, National Research Council of Canada
22 *
23 *  $Id$
24 */
25
26#include <string.h>
27
28#include <rtems/libio.h>
29#include <rtems/libcsupport.h>
30#include <rtems/bspIo.h>
31#include <rtems/powerpc/powerpc.h>
32
33#include <libcpu/cpuIdent.h>
34#include <libcpu/spr.h>
35
36#include <bsp/irq.h>
37#include <bsp.h>
38
39SPR_RW(SPRG0)
40SPR_RW(SPRG1)
41
42extern unsigned long intrStackPtr;
43
44/*
45 *  Driver configuration parameters
46 */
47uint32_t   bsp_clicks_per_usec;
48uint32_t   bsp_clock_speed;            /* Serial clocks per second */
49uint32_t   bsp_timer_least_valid;
50uint32_t   bsp_timer_average_overhead;
51
52/*
53 *  Use the shared implementations of the following routines.
54 *  Look in rtems/c/src/lib/libbsp/shared/bsppost.c and
55 *  rtems/c/src/lib/libbsp/shared/bsplibc.c.
56 */
57void bsp_postdriver_hook(void);
58void bsp_libc_init( void *, uint32_t, int );
59
60void BSP_panic(char *s)
61{
62  printk("%s PANIC %s\n",_RTEMS_version, s);
63  __asm__ __volatile ("sc");
64}
65
66void _BSP_Fatal_error(unsigned int v)
67{
68  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
69  __asm__ __volatile ("sc");
70}
71
72/*
73 *  bsp_pretasking_hook
74 *
75 *  Called when RTEMS initialization is complete but before interrupts and
76 *  tasking are enabled. Used to setup libc and install any BSP extensions.
77 *
78 *  Must not use libc (to do io) from here, since drivers are not yet
79 *  initialized.
80 *
81 *  Input parameters: NONE
82 *
83 *  Output parameters: NONE
84 *
85 *  Return values: NONE
86 */
87void bsp_pretasking_hook(void)
88{
89  /*
90   *  These are assigned addresses in the linkcmds file for the BSP. This
91   *  approach is better than having these defined as manifest constants and
92   *  compiled into the kernel, but it is still not ideal when dealing with
93   *  multiprocessor configuration in which each board as a different memory
94   *  map. A better place for defining these symbols might be the makefiles.
95   *  Consideration should also be given to developing an approach in which
96   *  the kernel and the application can be linked and burned into ROM
97   *  independently of each other.
98   */
99    uint8_t *_HeapStart =
100      (uint8_t *)Configuration.work_space_start
101           + rtems_configuration_get_work_space_size();
102    extern uint8_t _HeapEnd[];
103
104    bsp_libc_init( _HeapStart, _HeapEnd - _HeapStart, 0 );
105
106#ifdef RTEMS_DEBUG
107  rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
108#endif
109}
110
111/*
112 *  bsp_start()
113 *
114 *  Board-specific initialization code. Called from the generic boot_card()
115 *  function defined in rtems/c/src/lib/libbsp/shared/main.c. That function
116 *  does some of the board independent initialization. It is called from the
117 *  SS555 entry point _start() defined in
118 *  rtems/c/src/lib/libbsp/powerpc/ss555/startup/start.S
119 *
120 *  _start() has set up a stack, has zeroed the .bss section, has set up the
121 *  .data section from contents stored in ROM, has turned off interrupts,
122 *  and placed the processor in the supervisor mode.  boot_card() has left
123 *  the processor in that state when bsp_start() was called.
124 *
125 *  Input parameters: NONE
126 *
127 *  Output parameters: NONE
128 *
129 *  Return values: NONE
130 */
131void bsp_start(void)
132{
133  extern char _WorkspaceBase[];
134
135  ppc_cpu_id_t myCpu;
136  ppc_cpu_revision_t myCpuRevision;
137  register unsigned char* intrStack;
138
139  /*
140   * Get CPU identification dynamically.  Note that the get_ppc_cpu_type()
141   * function stores the result in global variables so that it can be used
142   * later.
143   */
144  myCpu         = get_ppc_cpu_type();
145  myCpuRevision = get_ppc_cpu_revision();
146
147  /*
148   * Initialize some SPRG registers related to irq handling
149   */
150  intrStack = (((unsigned char*)&intrStackPtr) - PPC_MINIMUM_STACK_FRAME_SIZE);
151  _write_SPRG1((unsigned int)intrStack);
152  /* signal them that we have fixed PR288 - eventually, this should go away */
153  _write_SPRG0(PPC_BSP_HAS_FIXED_PR288);
154
155  /*
156   * Install our own set of exception vectors
157   */
158  initialize_exceptions();
159
160  /*
161   *  Allocate the memory for the RTEMS Work Space.  This can come from
162   *  a variety of places: hard coded address, malloc'ed from outside
163   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
164   *  typically done by stock BSPs) by subtracting the required amount
165   *  of work space from the last physical address on the CPU board.
166   *
167   *  In this case, the memory is not malloc'ed.  It is just
168   *  "pulled from the air".
169   */
170  Configuration.work_space_start = _WorkspaceBase;
171
172  /*
173   *  initialize the device driver parameters
174   */
175  bsp_clicks_per_usec = BSP_CRYSTAL_HZ / 4 / 1000000;
176  bsp_clock_speed     = BSP_CLOCK_HZ;   /* for SCI baud rate generator */
177  bsp_timer_least_valid      = 0;
178  bsp_timer_average_overhead = 0;
179
180  /*
181   * Initalize RTEMS IRQ system
182   */
183  BSP_rtems_irq_mng_init(0);
184}
Note: See TracBrowser for help on using the repository browser.