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