source: rtems/c/src/lib/libbsp/powerpc/virtex/startup/bspstart.c @ 69effbb4

4.104.114.9
Last change on this file since 69effbb4 was dde1fedb, checked in by Joel Sherrill <joel.sherrill@…>, on May 15, 2008 at 3:55:28 PM

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

  • startup/bspstart.c: 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: 6.9 KB
Line 
1/*  bsp_start()
2 *
3 *  This routine 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 *  INPUT:  NONE
9 *
10 *  OUTPUT: NONE
11 *
12 *  Author:     Thomas Doerfler <td@imd.m.isar.de>
13 *              IMD Ingenieurbuero fuer Microcomputertechnik
14 *
15 *  COPYRIGHT (c) 1998 by IMD
16 *
17 *  Changes from IMD are covered by the original distributions terms.
18 *  This file has been derived from the papyrus BSP:
19 *
20 *  Author:     Andrew Bray <andy@i-cubed.co.uk>
21 *
22 *  COPYRIGHT (c) 1995 by i-cubed ltd.
23 *
24 *  To anyone who acknowledges that this file is provided "AS IS"
25 *  without any express or implied warranty:
26 *      permission to use, copy, modify, and distribute this file
27 *      for any purpose is hereby granted without fee, provided that
28 *      the above copyright notice and this notice appears in all
29 *      copies, and that the name of i-cubed limited not be used in
30 *      advertising or publicity pertaining to distribution of the
31 *      software without specific, written prior permission.
32 *      i-cubed limited makes no representations about the suitability
33 *      of this software for any purpose.
34 *
35 *  Modifications for spooling console driver and control of memory layout
36 *  with linker command file by
37 *              Thomas Doerfler <td@imd.m.isar.de>
38 *  for these modifications:
39 *  COPYRIGHT (c) 1997 by IMD, Puchheim, Germany.
40 *
41 *  To anyone who acknowledges that this file is provided "AS IS"
42 *  without any express or implied warranty:
43 *      permission to use, copy, modify, and distribute this file
44 *      for any purpose is hereby granted without fee, provided that
45 *      the above copyright notice and this notice appears in all
46 *      copies. IMD makes no representations about the suitability
47 *      of this software for any purpose.
48 *
49 *  Derived from c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c:
50 *
51 *  COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994.
52 *  On-Line Applications Research Corporation (OAR).
53 *
54 *  Modifications for PPC405GP by Dennis Ehlin
55 *
56 *  $Id$
57 */
58#include <string.h>
59#include <fcntl.h>
60
61#include <bsp.h>
62#include <rtems/libio.h>
63#include <rtems/libcsupport.h>
64#include <bsp/irq.h>
65#include <rtems/bspIo.h>
66#include <libcpu/cpuIdent.h>
67#include <libcpu/spr.h>
68#include <rtems/powerpc/powerpc.h>
69
70SPR_RW(SPRG0)
71SPR_RW(SPRG1)
72
73#include RTEMS_XPARAMETERS_H
74#include <stdio.h>
75
76uint32_t _heap_start;
77uint32_t _heap_end;
78uint32_t _top_of_ram;
79
80/*
81 *  Driver configuration parameters
82 */
83uint32_t   bsp_clicks_per_usec;
84uint32_t   bsp_serial_per_sec;         /* Serial clocks per second */
85boolean    bsp_serial_external_clock;
86boolean    bsp_serial_xon_xoff;
87boolean    bsp_serial_cts_rts;
88uint32_t   bsp_serial_rate;
89uint32_t   bsp_timer_average_overhead; /* Average overhead of timer in ticks */
90uint32_t   bsp_timer_least_valid;      /* Least valid number from timer      */
91boolean    bsp_timer_internal_clock;   /* TRUE, when timer runs with CPU clk */
92
93
94/*      Initialize whatever libc we are using
95 *      called from postdriver hook
96 */
97
98void bsp_XAssertHandler(const char* file, int line);
99void bsp_libc_init( void *, uint32_t, int );
100
101
102void bsp_XAssertHandler(const char* file, int line) {
103  printf("\n***\n*** XAssert Failed!  File: %s, Line: %d\n***\n", file, line);
104}
105
106/*
107 *  Function:   bsp_pretasking_hook
108 *  Created:    95/03/10
109 *
110 *  Description:
111 *      BSP pretasking hook.  Called just before drivers are initialized.
112 *      Used to setup libc and install any BSP extensions.
113 *
114 *  NOTES:
115 *      Must not use libc (to do io) from here, since drivers are
116 *      not yet initialized.
117 *
118 */
119
120void bsp_pretasking_hook(void)
121{
122
123
124    uint32_t        heap_start;
125    uint32_t        heap_size;
126    uint32_t        heap_end;
127
128    /* round up from the top of workspace to next 64k boundary, get
129     * default heapsize from linker script  */
130    heap_start = (((uint32_t)Configuration.work_space_start +
131                   rtems_configuration_get_work_space_size()) + 0x18000) & 0xffff0000;
132
133    heap_end = _heap_start + (uint32_t)&_HeapSize;
134
135    heap_size = (heap_end - heap_start);
136
137    _heap_start = heap_start;
138    _heap_end = heap_end;
139
140    _top_of_ram = heap_end;
141
142    bsp_libc_init((void *) heap_start, heap_size, 0); /* 64 * 1024 */
143
144}
145
146/*
147 *  bsp_start
148 *
149 *  This routine does the bulk of the system initialization.
150 */
151
152
153void bsp_start( void )
154{
155  extern unsigned long *intrStackPtr;
156  register unsigned char* intrStack;
157  ppc_cpu_id_t myCpu;
158  ppc_cpu_revision_t myCpuRevision;
159
160  /*
161   * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
162   * function store the result in global variables
163   * so that it can be used latter...
164   */
165  myCpu             = get_ppc_cpu_type();
166  myCpuRevision = get_ppc_cpu_revision();
167
168  /*
169   *  initialize the device driver parameters
170   */
171
172  /* timebase register ticks/microsecond */
173  bsp_clicks_per_usec = (250000000 / 1000000);
174  bsp_serial_per_sec = 14625000;
175  bsp_serial_external_clock = 0;
176  bsp_timer_internal_clock  = 1;
177  bsp_serial_xon_xoff = 0;
178  bsp_serial_cts_rts = 0;
179  bsp_serial_rate = 115200;
180  bsp_timer_average_overhead = 2;
181  bsp_timer_least_valid = 3;
182
183  /*
184   * Initialize some SPRG registers related to irq handling
185   */
186
187  intrStack = (((unsigned char*)&intrStackPtr) - PPC_MINIMUM_STACK_FRAME_SIZE);
188  _write_SPRG1((unsigned int)intrStack);
189  /* signal them that we have fixed PR288 - eventually, this should go away */
190  _write_SPRG0(PPC_BSP_HAS_FIXED_PR288);
191
192
193  /*
194   * Initialize default raw exception handlers.
195   * See shared/vectors/vectors_init.c
196   */
197  initialize_exceptions();
198
199  /*
200   * Install our own set of exception vectors
201   */
202  BSP_rtems_irq_mng_init(0);
203
204  /*
205   *  Allocate the memory for the RTEMS Work Space.  This can come from
206   *  a variety of places: hard coded address, malloc'ed from outside
207   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
208   *  typically done by stock BSPs) by subtracting the required amount
209   *  of work space from the last physical address on the CPU board.
210   */
211
212  /*
213   *  Need to "allocate" the memory for the RTEMS Workspace and
214   *  tell the RTEMS configuration where it is.  This memory is
215   *  not malloc'ed.  It is just "pulled from the air".
216   */
217  /* FIME: plan usage of RAM better:
218     - make top of ram dynamic,
219     - make rest of ram to heap...
220     -remove RAM_END from bsp.h, this cannot be valid...
221      or must be a function call
222   */
223  {
224    extern int _end;
225
226    /* round _end up to next 64k boundary for start of workspace */
227    Configuration.work_space_start = (void *)((((uint32_t)&_end) + 0x18000) & 0xffff0000);
228  }
229
230}
231
232void BSP_ask_for_reset(void)
233{
234  printk("system stopped, press RESET");
235  while(1) {};
236}
237
238void BSP_panic(char *s)
239{
240  printk("%s PANIC %s\n",_RTEMS_version, s);
241  BSP_ask_for_reset();
242}
243
244void _BSP_Fatal_error(unsigned int v)
245{
246  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
247  BSP_ask_for_reset();
248}
249 
Note: See TracBrowser for help on using the repository browser.