1 | /* |
---|
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 | * Author: Andrew Bray <andy@i-cubed.co.uk> |
---|
9 | * |
---|
10 | * COPYRIGHT (c) 1995 by i-cubed ltd. |
---|
11 | * |
---|
12 | * To anyone who acknowledges that this file is provided "AS IS" |
---|
13 | * without any express or implied warranty: |
---|
14 | * permission to use, copy, modify, and distribute this file |
---|
15 | * for any purpose is hereby granted without fee, provided that |
---|
16 | * the above copyright notice and this notice appears in all |
---|
17 | * copies, and that the name of i-cubed limited not be used in |
---|
18 | * advertising or publicity pertaining to distribution of the |
---|
19 | * software without specific, written prior permission. |
---|
20 | * i-cubed limited makes no representations about the suitability |
---|
21 | * of this software for any purpose. |
---|
22 | * |
---|
23 | * Derived from c/src/lib/libbsp/no_cpu/no_bsp/startup/bspstart.c: |
---|
24 | * |
---|
25 | * COPYRIGHT (c) 1989-1999. |
---|
26 | * On-Line Applications Research Corporation (OAR). |
---|
27 | * |
---|
28 | * The license and distribution terms for this file may be |
---|
29 | * found in the file LICENSE in this distribution or at |
---|
30 | * http://www.OARcorp.com/rtems/license.html. |
---|
31 | * |
---|
32 | * $Id$ |
---|
33 | */ |
---|
34 | |
---|
35 | #include <bsp.h> |
---|
36 | #include <rtems/libio.h> |
---|
37 | |
---|
38 | #include <libcsupport.h> |
---|
39 | |
---|
40 | #include <string.h> |
---|
41 | |
---|
42 | /* |
---|
43 | * The original table from the application and our copy of it with |
---|
44 | * some changes. |
---|
45 | */ |
---|
46 | |
---|
47 | extern rtems_configuration_table Configuration; |
---|
48 | |
---|
49 | rtems_configuration_table BSP_Configuration; |
---|
50 | |
---|
51 | rtems_cpu_table Cpu_table; |
---|
52 | |
---|
53 | char *rtems_progname; |
---|
54 | |
---|
55 | /* |
---|
56 | * Use the shared implementations of the following routines |
---|
57 | */ |
---|
58 | |
---|
59 | void bsp_postdriver_hook(void); |
---|
60 | void bsp_libc_init( void *, unsigned32, int ); |
---|
61 | |
---|
62 | /* |
---|
63 | * Function: bsp_pretasking_hook |
---|
64 | * Created: 95/03/10 |
---|
65 | * |
---|
66 | * Description: |
---|
67 | * BSP pretasking hook. Called just before drivers are initialized. |
---|
68 | * Used to setup libc and install any BSP extensions. |
---|
69 | * |
---|
70 | * NOTES: |
---|
71 | * Must not use libc (to do io) from here, since drivers are |
---|
72 | * not yet initialized. |
---|
73 | * |
---|
74 | */ |
---|
75 | |
---|
76 | void bsp_pretasking_hook(void) |
---|
77 | { |
---|
78 | extern int _end; |
---|
79 | rtems_unsigned32 heap_start; |
---|
80 | |
---|
81 | heap_start = (rtems_unsigned32) &_end; |
---|
82 | if (heap_start & (CPU_ALIGNMENT-1)) |
---|
83 | heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); |
---|
84 | |
---|
85 | bsp_libc_init((void *) heap_start, 64 * 1024, 0); |
---|
86 | |
---|
87 | #ifdef RTEMS_DEBUG |
---|
88 | rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); |
---|
89 | #endif |
---|
90 | } |
---|
91 | |
---|
92 | /* |
---|
93 | * bsp_start |
---|
94 | * |
---|
95 | * This routine does the bulk of the system initialization. |
---|
96 | */ |
---|
97 | |
---|
98 | void bsp_start( void ) |
---|
99 | { |
---|
100 | /* |
---|
101 | * Allocate the memory for the RTEMS Work Space. This can come from |
---|
102 | * a variety of places: hard coded address, malloc'ed from outside |
---|
103 | * RTEMS world (e.g. simulator or primitive memory manager), or (as |
---|
104 | * typically done by stock BSPs) by subtracting the required amount |
---|
105 | * of work space from the last physical address on the CPU board. |
---|
106 | */ |
---|
107 | |
---|
108 | /* |
---|
109 | * Need to "allocate" the memory for the RTEMS Workspace and |
---|
110 | * tell the RTEMS configuration where it is. This memory is |
---|
111 | * not malloc'ed. It is just "pulled from the air". |
---|
112 | */ |
---|
113 | |
---|
114 | BSP_Configuration.work_space_start = (void *) |
---|
115 | RAM_END - BSP_Configuration.work_space_size; |
---|
116 | |
---|
117 | /* |
---|
118 | * initialize the CPU table for this BSP |
---|
119 | */ |
---|
120 | |
---|
121 | Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ |
---|
122 | Cpu_table.postdriver_hook = bsp_postdriver_hook; |
---|
123 | Cpu_table.interrupt_stack_size = CONFIGURE_INTERRUPT_STACK_MEMORY; |
---|
124 | |
---|
125 | Cpu_table.clicks_per_usec = 10; |
---|
126 | Cpu_table.serial_per_sec = 10000000; |
---|
127 | Cpu_table.serial_external_clock = 1; |
---|
128 | Cpu_table.serial_xon_xoff = 0; |
---|
129 | Cpu_table.serial_cts_rts = 1; |
---|
130 | Cpu_table.serial_rate = 9600; |
---|
131 | Cpu_table.timer_average_overhead = 2; |
---|
132 | Cpu_table.timer_least_valid = 3; |
---|
133 | } |
---|