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

4.104.114.95
Last change on this file since b9f34ad was e8beb870, checked in by Joel Sherrill <joel.sherrill@…>, on 08/23/06 at 11:25:54

2006-08-23 Joel Sherrill <joel@…>

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