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

4.104.114.95
Last change on this file since 479f2555 was 479f2555, checked in by Till Straumann <strauman@…>, on 07/22/08 at 06:11:34

2008-07-21 Till Straumann <strauman@…>

  • startup/bspstart.c: Removed MSR_CE from interrupt mask - this was set for testing but should not be in the mask by default.
  • Property mode set to 100644
File size: 6.6 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
59#include <string.h>
60#include <fcntl.h>
61
62#include <bsp.h>
63#include <rtems/libio.h>
64#include <rtems/libcsupport.h>
65#include <bsp/irq.h>
66#include <rtems/bspIo.h>
67#include <libcpu/cpuIdent.h>
68#include <libcpu/spr.h>
69#include <rtems/powerpc/powerpc.h>
70
71#include RTEMS_XPARAMETERS_H
72#include <stdio.h>
73
74uint32_t _heap_start;
75uint32_t _heap_end;
76uint32_t _top_of_ram;
77
78/*
79 *  Driver configuration parameters
80 */
81uint32_t   bsp_clicks_per_usec;
82uint32_t   bsp_serial_per_sec;         /* Serial clocks per second */
83boolean    bsp_serial_external_clock;
84boolean    bsp_serial_xon_xoff;
85boolean    bsp_serial_cts_rts;
86uint32_t   bsp_serial_rate;
87uint32_t   bsp_timer_average_overhead; /* Average overhead of timer in ticks */
88uint32_t   bsp_timer_least_valid;      /* Least valid number from timer      */
89boolean    bsp_timer_internal_clock;   /* TRUE, when timer runs with CPU clk */
90
91
92/*      Initialize whatever libc we are using
93 *      called from postdriver hook
94 */
95
96void bsp_XAssertHandler(const char* file, int line);
97void bsp_libc_init( void *, uint32_t, int );
98
99
100void bsp_XAssertHandler(const char* file, int line) {
101  printf("\n***\n*** XAssert Failed!  File: %s, Line: %d\n***\n", file, line);
102}
103
104/*
105 *  Function:   bsp_pretasking_hook
106 *  Created:    95/03/10
107 *
108 *  Description:
109 *      BSP pretasking hook.  Called just before drivers are initialized.
110 *      Used to setup libc and install any BSP extensions.
111 *
112 *  NOTES:
113 *      Must not use libc (to do io) from here, since drivers are
114 *      not yet initialized.
115 *
116 */
117
118void bsp_pretasking_hook(void)
119{
120
121
122    uint32_t        heap_start;
123    uint32_t        heap_size;
124    uint32_t        heap_end;
125
126    /* round up from the top of workspace to next 64k boundary, get
127     * default heapsize from linker script  */
128    heap_start = (((uint32_t)Configuration.work_space_start +
129                   rtems_configuration_get_work_space_size()) + 0x18000) & 0xffff0000;
130
131    heap_end = _heap_start + (uint32_t)&_HeapSize;
132
133    heap_size = (heap_end - heap_start);
134
135    _heap_start = heap_start;
136    _heap_end = heap_end;
137
138    _top_of_ram = heap_end;
139
140    bsp_libc_init((void *) heap_start, heap_size, 0); /* 64 * 1024 */
141
142}
143
144/*
145 *  bsp_start
146 *
147 *  This routine does the bulk of the system initialization.
148 */
149
150
151void bsp_start( void )
152{
153  extern unsigned char IntrStack_start[];
154  extern unsigned char IntrStack_end[];
155  ppc_cpu_id_t myCpu;
156  ppc_cpu_revision_t myCpuRevision;
157
158  /*
159   * Get CPU identification dynamically. Note that the get_ppc_cpu_type()
160   * function store the result in global variables
161   * so that it can be used latter...
162   */
163  myCpu             = get_ppc_cpu_type();
164  myCpuRevision = get_ppc_cpu_revision();
165
166  /*
167   *  initialize the device driver parameters
168   */
169
170  /* timebase register ticks/microsecond */
171  bsp_clicks_per_usec = (250000000 / 1000000);
172  bsp_serial_per_sec = 14625000;
173  bsp_serial_external_clock = 0;
174  bsp_timer_internal_clock  = 1;
175  bsp_serial_xon_xoff = 0;
176  bsp_serial_cts_rts = 0;
177  bsp_serial_rate = 115200;
178  bsp_timer_average_overhead = 2;
179  bsp_timer_least_valid = 3;
180
181  /*
182   * Initialize default raw exception handlers.
183   */
184  ppc_exc_initialize(
185        PPC_INTERRUPT_DISABLE_MASK_DEFAULT,
186        (uint32_t)IntrStack_start,
187        IntrStack_end - IntrStack_start
188  );
189
190  /*
191   * Install our own set of exception vectors
192   */
193  BSP_rtems_irq_mng_init(0);
194
195  /*
196   *  Allocate the memory for the RTEMS Work Space.  This can come from
197   *  a variety of places: hard coded address, malloc'ed from outside
198   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
199   *  typically done by stock BSPs) by subtracting the required amount
200   *  of work space from the last physical address on the CPU board.
201   */
202
203  /*
204   *  Need to "allocate" the memory for the RTEMS Workspace and
205   *  tell the RTEMS configuration where it is.  This memory is
206   *  not malloc'ed.  It is just "pulled from the air".
207   */
208  /* FIME: plan usage of RAM better:
209     - make top of ram dynamic,
210     - make rest of ram to heap...
211     -remove RAM_END from bsp.h, this cannot be valid...
212      or must be a function call
213   */
214  {
215    extern int _end;
216
217    /* round _end up to next 64k boundary for start of workspace */
218    Configuration.work_space_start = (void *)((((uint32_t)&_end) + 0xffff) & 0xffff0000);
219  }
220
221}
222
223void BSP_ask_for_reset(void)
224{
225  printk("system stopped, press RESET");
226  while(1) {};
227}
228
229void BSP_panic(char *s)
230{
231  printk("%s PANIC %s\n",_RTEMS_version, s);
232  BSP_ask_for_reset();
233}
234
235void _BSP_Fatal_error(unsigned int v)
236{
237  printk("%s PANIC ERROR %x\n",_RTEMS_version, v);
238  BSP_ask_for_reset();
239}
240 
Note: See TracBrowser for help on using the repository browser.