1 | /* bspstart.c |
---|
2 | * |
---|
3 | * This set of routines 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 any of these are invoked. |
---|
7 | * |
---|
8 | * COPYRIGHT (c) 1989, 1990, 1991, 1992, 1993, 1994, 1997. |
---|
9 | * On-Line Applications Research Corporation (OAR). |
---|
10 | * All rights assigned to U.S. Government, 1994. |
---|
11 | * |
---|
12 | * $Id$ |
---|
13 | */ |
---|
14 | |
---|
15 | #include <bsp.h> |
---|
16 | #include <rtems/libio.h> |
---|
17 | |
---|
18 | #include <libcsupport.h> |
---|
19 | |
---|
20 | #include <string.h> |
---|
21 | |
---|
22 | /* |
---|
23 | * The original table from the application and our copy of it with |
---|
24 | * some changes. |
---|
25 | */ |
---|
26 | |
---|
27 | extern rtems_configuration_table Configuration; |
---|
28 | rtems_configuration_table BSP_Configuration; |
---|
29 | rtems_cpu_table Cpu_table; |
---|
30 | rtems_unsigned32 bsp_isr_level; |
---|
31 | |
---|
32 | /* |
---|
33 | * Use the shared implementations of the following routines |
---|
34 | */ |
---|
35 | |
---|
36 | void bsp_postdriver_hook(void); |
---|
37 | void bsp_libc_init( void *, unsigned32, int ); |
---|
38 | |
---|
39 | /*PAGE |
---|
40 | * |
---|
41 | * bsp_pretasking_hook |
---|
42 | * |
---|
43 | * BSP pretasking hook. Called just before drivers are initialized. |
---|
44 | * Used to setup libc and install any BSP extensions. |
---|
45 | */ |
---|
46 | |
---|
47 | void bsp_pretasking_hook(void) |
---|
48 | { |
---|
49 | extern int end; |
---|
50 | rtems_unsigned32 heap_start; |
---|
51 | rtems_unsigned32 heap_size; |
---|
52 | |
---|
53 | heap_start = (rtems_unsigned32) &end; |
---|
54 | if (heap_start & (CPU_ALIGNMENT-1)) |
---|
55 | heap_start = (heap_start + CPU_ALIGNMENT) & ~(CPU_ALIGNMENT-1); |
---|
56 | |
---|
57 | heap_size = BSP_Configuration.work_space_start - (void *)&end; |
---|
58 | heap_size &= 0xfffffff0; /* keep it as a multiple of 16 bytes */ |
---|
59 | |
---|
60 | bsp_libc_init((void *) heap_start, heap_size, 0); |
---|
61 | |
---|
62 | #ifdef RTEMS_DEBUG |
---|
63 | rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); |
---|
64 | #endif |
---|
65 | |
---|
66 | } |
---|
67 | |
---|
68 | /* PAGE |
---|
69 | * |
---|
70 | * bsp_predriver_hook |
---|
71 | * |
---|
72 | * Initialization before drivers are setup. |
---|
73 | */ |
---|
74 | |
---|
75 | void bsp_predriver_hook(void) |
---|
76 | { |
---|
77 | initialize_external_exception_vector(); |
---|
78 | } |
---|
79 | |
---|
80 | /*PAGE |
---|
81 | * |
---|
82 | * bsp_start |
---|
83 | * |
---|
84 | * This routine does the bulk of the system initialization. |
---|
85 | */ |
---|
86 | |
---|
87 | void bsp_start( void ) |
---|
88 | { |
---|
89 | unsigned char *work_space_start; |
---|
90 | unsigned int msr_value = 0x2030; |
---|
91 | |
---|
92 | /* |
---|
93 | * Set BSP to initial value. Note: This value is a guess |
---|
94 | * check how the real board comes up. This is critical to |
---|
95 | * getting the source to work with the debugger. |
---|
96 | */ |
---|
97 | |
---|
98 | _CPU_MSR_SET( msr_value ); |
---|
99 | |
---|
100 | /* |
---|
101 | * Need to "allocate" the memory for the RTEMS Workspace and |
---|
102 | * tell the RTEMS configuration where it is. This memory is |
---|
103 | * not malloc'ed. It is just "pulled from the air". |
---|
104 | */ |
---|
105 | |
---|
106 | work_space_start = |
---|
107 | (unsigned char *)&RAM_END - BSP_Configuration.work_space_size; |
---|
108 | |
---|
109 | if ( work_space_start <= (unsigned char *)&end ) { |
---|
110 | DEBUG_puts( "bspstart: Not enough RAM!!!\n" ); |
---|
111 | bsp_cleanup(); |
---|
112 | } |
---|
113 | |
---|
114 | BSP_Configuration.work_space_start = work_space_start; |
---|
115 | |
---|
116 | /* |
---|
117 | * Account for the console's resources |
---|
118 | */ |
---|
119 | |
---|
120 | console_reserve_resources( &BSP_Configuration ); |
---|
121 | |
---|
122 | /* |
---|
123 | * initialize the CPU table for this BSP |
---|
124 | */ |
---|
125 | |
---|
126 | Cpu_table.exceptions_in_RAM = TRUE; |
---|
127 | Cpu_table.pretasking_hook = bsp_pretasking_hook; /* init libc, etc. */ |
---|
128 | Cpu_table.predriver_hook = bsp_predriver_hook; |
---|
129 | Cpu_table.postdriver_hook = bsp_postdriver_hook; |
---|
130 | /* Cpu_table.clicks_per_usec = 66666667 / 4000000; */ |
---|
131 | Cpu_table.clicks_per_usec = 66666667 / 4000000 / 2; |
---|
132 | |
---|
133 | Cpu_table.do_zero_of_workspace = TRUE; |
---|
134 | Cpu_table.interrupt_stack_size = (12 * 1024); |
---|
135 | } |
---|