source: rtems/c/src/lib/libbsp/powerpc/gen405/startup/bspstart.c @ 357a9f0

4.104.114.84.95
Last change on this file since 357a9f0 was 57ed393, checked in by Joel Sherrill <joel.sherrill@…>, on 11/08/01 at 23:46:58

2001-11-08 Dennis Ehlin (ECS) <Dennis.Ehlin@…>

This modification is part of the submitted modifications necessary to
support the IBM PPC405 family. This submission was reviewed by
Thomas Doerfler <Thomas.Doerfler@…> who ensured it did
not negatively impact the ppc403 BSPs. The submission and tracking
process was captured as PR50.

  • ChangeLog?, Makefile.am, README, bsp_specs, bsp_specs.dl, configure.ac, times, dlentry/.cvsignore, dlentry/Makefile.am, dlentry/dlentry.S, include/.cvsignore, include/Makefile.am, include/bsp.h, include/bspopts.h.in, include/coverhd.h, startup/.cvsignore, startup/Makefile.am, startup/bspclean.c, startup/bspstart.c, startup/linkcmds, startup/linkcmds.dl, startup/setvec.c, wrapup/.cvsignore, wrapup/Makefile.am: New files that are part of the new gen405 BSP.
  • Property mode set to 100644
File size: 5.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 *  All rights assigned to U.S. Government, 1994.
54 *
55 *  This material may be reproduced by or for the U.S. Government pursuant
56 *  to the copyright license under the clause at DFARS 252.227-7013.  This
57 *  notice must appear in all copies of this file and its derivatives.
58 *
59 *  Modifications for PPC405GP by Dennis Ehlin
60 *
61 *  $Id$
62 */
63
64#include <string.h>
65#include <fcntl.h>
66
67#include <bsp.h>
68#include <rtems/libio.h>
69#include <rtems/libcsupport.h>
70#include <ictrl.h>
71 
72/*
73 *  The original table from the application and our copy of it with
74 *  some changes.
75 */
76
77extern rtems_configuration_table Configuration;
78
79rtems_configuration_table  BSP_Configuration;
80
81rtems_cpu_table Cpu_table;
82
83char *rtems_progname;
84void *bsp_ram_end = (void *)RAM_END;  /* first addr behind avail. ram area */
85
86/*      Initialize whatever libc we are using
87 *      called from postdriver hook
88 */
89 
90void bsp_postdriver_hook(void);
91void bsp_libc_init( void *, unsigned32, int );
92
93/*
94 *
95 *  bsp_predriver_hook
96 *
97 *  Before drivers are setup.
98 */
99
100void bsp_predriver_hook(void)
101{
102  rtems_status_code status;
103  /* init the PPC405 external interrupt controller handler... */
104  status = ictrl_init();
105}
106
107/*
108 *  Function:   bsp_pretasking_hook
109 *  Created:    95/03/10
110 *
111 *  Description:
112 *      BSP pretasking hook.  Called just before drivers are initialized.
113 *      Used to setup libc and install any BSP extensions.
114 *
115 *  NOTES:
116 *      Must not use libc (to do io) from here, since drivers are
117 *      not yet initialized.
118 *
119 */
120 
121void bsp_pretasking_hook(void)
122{
123    extern int _end;
124    extern int _heap_end;
125    rtems_unsigned32        heap_start;
126    rtems_unsigned32        heap_size;
127    rtems_unsigned32        heap_end;
128
129
130    heap_start = (rtems_unsigned32) &_end;
131    if (heap_start & (CPU_ALIGNMENT-1))
132        heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
133
134    heap_end = (rtems_unsigned32) &_heap_end;
135    if (heap_end & (CPU_ALIGNMENT-1))
136        heap_end = (heap_end + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1);
137
138    heap_size = heap_end - heap_start;
139
140    bsp_libc_init((void *) heap_start, heap_size, 0); /* 64 * 1024 */
141 
142#ifdef RTEMS_DEBUG
143    rtems_debug_enable( RTEMS_DEBUG_ALL_MASK );
144#endif
145
146}
147 
148
149/*
150 *  bsp_start
151 *
152 *  This routine does the bulk of the system initialization.
153 */
154
155void bsp_start( void )
156{
157  /*
158   *  Allocate the memory for the RTEMS Work Space.  This can come from
159   *  a variety of places: hard coded address, malloc'ed from outside
160   *  RTEMS world (e.g. simulator or primitive memory manager), or (as
161   *  typically done by stock BSPs) by subtracting the required amount
162   *  of work space from the last physical address on the CPU board.
163   */
164
165  /*
166   *  Need to "allocate" the memory for the RTEMS Workspace and
167   *  tell the RTEMS configuration where it is.  This memory is
168   *  not malloc'ed.  It is just "pulled from the air".
169   */
170  /* FIME: plan usage of RAM better:
171     - make top of ram dynamic,
172     - take out some part for persistant log
173     - make rest of ram to heap...
174     -remove RAM_END from bsp.h, this cannot be valid...
175      or must be a function call
176   */
177  BSP_Configuration.work_space_start = (void *)
178      ((char *)(bsp_ram_end)) - BSP_Configuration.work_space_size;
179
180  /*
181   *  initialize the CPU table for this BSP
182   */
183
184  Cpu_table.pretasking_hook = bsp_pretasking_hook;  /* init libc, etc. */
185  Cpu_table.predriver_hook  = bsp_predriver_hook;
186  Cpu_table.postdriver_hook = bsp_postdriver_hook;
187  Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY;
188
189  Cpu_table.clicks_per_usec = 300;
190  Cpu_table.serial_per_sec = 14625000; /* = (CPU Clock / UART Internal Clock Divisor) */
191  Cpu_table.serial_external_clock = 0;
192  Cpu_table.timer_internal_clock  = 1;
193  Cpu_table.serial_xon_xoff = 0;
194  Cpu_table.serial_cts_rts = 1;
195  Cpu_table.serial_rate = 115200;
196  Cpu_table.timer_average_overhead = 2;
197  Cpu_table.timer_least_valid = 3;
198  Cpu_table.exceptions_in_RAM = TRUE;
199}
Note: See TracBrowser for help on using the repository browser.