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

4.104.114.95
Last change on this file since d34d8692 was d34d8692, checked in by Joel Sherrill <joel.sherrill@…>, on 12/04/07 at 22:22:26

2007-12-04 Joel Sherrill <joel.sherrill@…>

  • include/bsp.h, startup/bspstart.c: Move interrupt_stack_size field from CPU Table to Configuration Table. Eliminate CPU Table from all ports. Delete references to CPU Table in all forms.
  • Property mode set to 100644
File size: 7.4 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
76/*
77 *  The original table from the application and our copy of it with
78 *  some changes.
79 */
80
81extern rtems_configuration_table Configuration;
82rtems_configuration_table  BSP_Configuration;
83
84char *rtems_progname;
85
86uint32_t _heap_start;
87uint32_t _heap_end;
88uint32_t _top_of_ram;
89
90/*
91 *  Driver configuration parameters
92 */
93uint32_t   bsp_clicks_per_usec;
94uint32_t   bsp_serial_per_sec;         /* Serial clocks per second */
95boolean    bsp_serial_external_clock;
96boolean    bsp_serial_xon_xoff;
97boolean    bsp_serial_cts_rts;
98uint32_t   bsp_serial_rate;
99uint32_t   bsp_timer_average_overhead; /* Average overhead of timer in ticks */
100uint32_t   bsp_timer_least_valid;      /* Least valid number from timer      */
101boolean    bsp_timer_internal_clock;   /* TRUE, when timer runs with CPU clk */
102
103
104/*      Initialize whatever libc we are using
105 *      called from postdriver hook
106 */
107
108void bsp_XAssertHandler(const char* file, int line);
109void bsp_postdriver_hook(void);
110void bsp_libc_init( void *, uint32_t, int );
111
112
113void bsp_XAssertHandler(const char* file, int line) {
114  printf("\n***\n*** XAssert Failed!  File: %s, Line: %d\n***\n", file, line);
115}
116
117/*
118 *
119 *  bsp_predriver_hook
120 *
121 *  Before drivers are setup.
122 */
123
124void bsp_predriver_hook(void)
125{
126 
127}
128
129/*
130 *  Function:   bsp_pretasking_hook
131 *  Created:    95/03/10
132 *
133 *  Description:
134 *      BSP pretasking hook.  Called just before drivers are initialized.
135 *      Used to setup libc and install any BSP extensions.
136 *
137 *  NOTES:
138 *      Must not use libc (to do io) from here, since drivers are
139 *      not yet initialized.
140 *
141 */
142
143void bsp_pretasking_hook(void)
144{
145
146
147    uint32_t        heap_start;
148    uint32_t        heap_size;
149    uint32_t        heap_end;
150
151    /* round up from the top of workspace to next 64k boundary, get
152     * default heapsize from linker script  */
153    heap_start = (((uint32_t)BSP_Configuration.work_space_start +
154                   BSP_Configuration.work_space_size) + 0x18000) & 0xffff0000;
155
156    heap_end = _heap_start + (uint32_t)&_HeapSize;
157
158    heap_size = (heap_end - heap_start);
159
160    _heap_start = heap_start;
161    _heap_end = heap_end;
162
163    _top_of_ram = heap_end;
164
165    bsp_libc_init((void *) heap_start, heap_size, 0); /* 64 * 1024 */
166
167/*
168  XAssertSetCallback((XAssertCallback*)bsp_XAssertHandler);
169*/
170
171#ifdef RTEMS_DEBUG
172    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
173#endif
174}
175
176/*
177 *  bsp_start
178 *
179 *  This routine does the bulk of the system initialization.
180 */
181
182
183void bsp_start( void )
184{
185  extern unsigned long *intrStackPtr;
186  register unsigned char* intrStack;
187  ppc_cpu_id_t myCpu;
188  ppc_cpu_revision_t myCpuRevision;
189
190  /*
191   * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
192   * function store the result in global variables
193   * so that it can be used latter...
194   */
195  myCpu             = get_ppc_cpu_type();
196  myCpuRevision = get_ppc_cpu_revision();
197
198  /*
199   *  initialize the device driver parameters
200   */
201
202  /* timebase register ticks/microsecond */
203  bsp_clicks_per_usec = (250000000 / 1000000);
204  bsp_serial_per_sec = 14625000;
205  bsp_serial_external_clock = 0;
206  bsp_timer_internal_clock  = 1;
207  bsp_serial_xon_xoff = 0;
208  bsp_serial_cts_rts = 0;
209  bsp_serial_rate = 115200;
210  bsp_timer_average_overhead = 2;
211  bsp_timer_least_valid = 3;
212
213  /*
214   * Initialize some SPRG registers related to irq handling
215   */
216
217  intrStack = (((unsigned char*)&intrStackPtr) - PPC_MINIMUM_STACK_FRAME_SIZE);
218  _write_SPRG1((unsigned int)intrStack);
219  /* signal them that we have fixed PR288 - eventually, this should go away */
220  _write_SPRG0(PPC_BSP_HAS_FIXED_PR288);
221
222
223  /*
224   * Initialize default raw exception handlers.
225   * See shared/vectors/vectors_init.c
226   */
227  initialize_exceptions();
228
229  /*
230   * Install our own set of exception vectors
231   */
232  BSP_rtems_irq_mng_init(0);
233
234  /*
235   *  Allocate the memory for the RTEMS Work Space.  This can come from
236   *  a variety of places: hard coded address, malloc'ed from outside
237   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
238   *  typically done by stock BSPs) by subtracting the required amount
239   *  of work space from the last physical address on the CPU board.
240   */
241
242  /*
243   *  Need to "allocate" the memory for the RTEMS Workspace and
244   *  tell the RTEMS configuration where it is.  This memory is
245   *  not malloc'ed.  It is just "pulled from the air".
246   */
247  /* FIME: plan usage of RAM better:
248     - make top of ram dynamic,
249     - make rest of ram to heap...
250     -remove RAM_END from bsp.h, this cannot be valid...
251      or must be a function call
252   */
253  {
254    extern int _end;
255
256    /* round _end up to next 64k boundary for start of workspace */
257    BSP_Configuration.work_space_start = (void *)((((uint32_t)&_end) + 0x18000) & 0xffff0000);
258  }
259
260}
261
262void BSP_ask_for_reset(void)
263{
264  printk("system stopped, press RESET");
265  while(1) {};
266}
267
268void BSP_panic(char *s)
269{
270  printk("%s PANIC %s\n",_RTEMS_version, s);
271  BSP_ask_for_reset();
272}
273
274void _BSP_Fatal_error(unsigned int v)
275{
276  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
277  BSP_ask_for_reset();
278}
279 
Note: See TracBrowser for help on using the repository browser.