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 | * $Id$ |
---|
55 | */ |
---|
56 | |
---|
57 | #include <string.h> |
---|
58 | #include <fcntl.h> |
---|
59 | |
---|
60 | #include <bsp.h> |
---|
61 | #include <rtems/libio.h> |
---|
62 | #include <rtems/libcsupport.h> |
---|
63 | #include <ictrl.h> |
---|
64 | |
---|
65 | void *bsp_ram_end = (void *)RAM_END; /* first addr behind avail. ram area */ |
---|
66 | |
---|
67 | /* |
---|
68 | * Driver configuration parameters |
---|
69 | */ |
---|
70 | uint32_t bsp_clicks_per_usec; |
---|
71 | uint32_t bsp_serial_per_sec; /* Serial clocks per second */ |
---|
72 | boolean bsp_serial_external_clock; |
---|
73 | boolean bsp_serial_xon_xoff; |
---|
74 | boolean bsp_serial_cts_rts; |
---|
75 | uint32_t bsp_serial_rate; |
---|
76 | uint32_t bsp_timer_average_overhead; /* Average overhead of timer in ticks */ |
---|
77 | uint32_t bsp_timer_least_valid; /* Least valid number from timer */ |
---|
78 | boolean bsp_timer_internal_clock; /* TRUE, when timer runs with CPU clk */ |
---|
79 | void (*bsp_spurious_handler)(uint32_t vector, CPU_Interrupt_frame *); |
---|
80 | |
---|
81 | /* Initialize whatever libc we are using |
---|
82 | * called from postdriver hook |
---|
83 | */ |
---|
84 | |
---|
85 | void bsp_postdriver_hook(void); |
---|
86 | void bsp_libc_init( void *, uint32_t, int ); |
---|
87 | |
---|
88 | /* |
---|
89 | * |
---|
90 | * bsp_predriver_hook |
---|
91 | * |
---|
92 | * Before drivers are setup. |
---|
93 | */ |
---|
94 | |
---|
95 | void bsp_predriver_hook(void) |
---|
96 | { |
---|
97 | rtems_status_code status; |
---|
98 | /* init the PPC403GA 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 | |
---|
116 | void bsp_pretasking_hook(void) |
---|
117 | { |
---|
118 | extern int _end; |
---|
119 | uint32_t heap_start; |
---|
120 | |
---|
121 | heap_start = (uint32_t) &_end; |
---|
122 | if (heap_start & (CPU_ALIGNMENT-1)) |
---|
123 | heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); |
---|
124 | |
---|
125 | bsp_libc_init((void *) heap_start, 64 * 1024, 0); |
---|
126 | |
---|
127 | #ifdef RTEMS_DEBUG |
---|
128 | rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); |
---|
129 | #endif |
---|
130 | } |
---|
131 | |
---|
132 | /* |
---|
133 | * bsp_start |
---|
134 | * |
---|
135 | * This routine does the bulk of the system initialization. |
---|
136 | */ |
---|
137 | |
---|
138 | void bsp_start( void ) |
---|
139 | { |
---|
140 | /* |
---|
141 | * Allocate the memory for the RTEMS Work Space. This can come from |
---|
142 | * a variety of places: hard coded address, malloc'ed from outside |
---|
143 | * RTEMS world (e.g. simulator or primitive memory manager), or (as |
---|
144 | * typically done by stock BSPs) by subtracting the required amount |
---|
145 | * of work space from the last physical address on the CPU board. |
---|
146 | */ |
---|
147 | |
---|
148 | /* |
---|
149 | * Need to "allocate" the memory for the RTEMS Workspace and |
---|
150 | * tell the RTEMS configuration where it is. This memory is |
---|
151 | * not malloc'ed. It is just "pulled from the air". |
---|
152 | */ |
---|
153 | /* FIME: plan usage of RAM better: |
---|
154 | - make top of ram dynamic, |
---|
155 | - take out some part for persistant log |
---|
156 | - make rest of ram to heap... |
---|
157 | -remove RAM_END from bsp.h, this cannot be valid... |
---|
158 | or must be a function call |
---|
159 | */ |
---|
160 | Configuration.work_space_start = (void *) |
---|
161 | ((char *)(bsp_ram_end)) - rtems_configuration_get_work_space_size(); |
---|
162 | |
---|
163 | /* |
---|
164 | * initialize the device driver parameters |
---|
165 | */ |
---|
166 | bsp_clicks_per_usec = 25; |
---|
167 | bsp_serial_per_sec = 25000000; |
---|
168 | bsp_serial_external_clock = 0; |
---|
169 | bsp_timer_internal_clock = 1; |
---|
170 | bsp_serial_xon_xoff = 0; |
---|
171 | bsp_serial_cts_rts = 1; |
---|
172 | bsp_serial_rate = 9600; |
---|
173 | bsp_timer_average_overhead = 2; |
---|
174 | bsp_timer_least_valid = 3; |
---|
175 | } |
---|