1 | /* |
---|
2 | * This routine starts the application. It includes application, |
---|
3 | * board, and monitor specific initialization and configuration. |
---|
4 | * The generic CPU dependent initialization has been performed |
---|
5 | * before this routine is invoked. |
---|
6 | * |
---|
7 | * COPYRIGHT (c) 1989-2001. |
---|
8 | * On-Line Applications Research Corporation (OAR). |
---|
9 | * |
---|
10 | * The license and distribution terms for this file may be |
---|
11 | * found in the file LICENSE in this distribution or at |
---|
12 | * http://www.rtems.com/license/LICENSE. |
---|
13 | * |
---|
14 | * $Id$ |
---|
15 | * |
---|
16 | * Modification History: |
---|
17 | * 12/10/01 A.Ferrer, NASA/GSFC, Code 582 |
---|
18 | * Set interrupt mask to 0xAF00 (Line 139). |
---|
19 | */ |
---|
20 | |
---|
21 | #include <string.h> |
---|
22 | |
---|
23 | #include <bsp.h> |
---|
24 | #include <rtems/libio.h> |
---|
25 | #include <rtems/libcsupport.h> |
---|
26 | #include <libcpu/mongoose-v.h> |
---|
27 | |
---|
28 | /* |
---|
29 | * The original table from the application and our copy of it with |
---|
30 | * some changes. |
---|
31 | */ |
---|
32 | |
---|
33 | extern rtems_configuration_table Configuration; |
---|
34 | |
---|
35 | rtems_configuration_table BSP_Configuration; |
---|
36 | |
---|
37 | rtems_cpu_table Cpu_table; |
---|
38 | |
---|
39 | char *rtems_progname; |
---|
40 | |
---|
41 | /* |
---|
42 | * Use the shared implementations of the following routines |
---|
43 | */ |
---|
44 | |
---|
45 | void bsp_postdriver_hook(void); |
---|
46 | void bsp_libc_init( void *, uint32_t, int ); |
---|
47 | |
---|
48 | /* |
---|
49 | * Function: bsp_pretasking_hook |
---|
50 | * Created: 95/03/10 |
---|
51 | * |
---|
52 | * Description: |
---|
53 | * BSP pretasking hook. Called just before drivers are initialized. |
---|
54 | * Used to setup libc and install any BSP extensions. |
---|
55 | * |
---|
56 | * NOTES: |
---|
57 | * Must not use libc (to do io) from here, since drivers are |
---|
58 | * not yet initialized. |
---|
59 | * |
---|
60 | */ |
---|
61 | |
---|
62 | void bsp_pretasking_hook(void) |
---|
63 | { |
---|
64 | extern int HeapBase; |
---|
65 | extern int HeapSize; |
---|
66 | void *heapStart = &HeapBase; |
---|
67 | unsigned long heapSize = (unsigned long)&HeapSize; |
---|
68 | |
---|
69 | bsp_libc_init(heapStart, (uint32_t) heapSize, 0); |
---|
70 | |
---|
71 | #ifdef RTEMS_DEBUG |
---|
72 | rtems_debug_enable( RTEMS_DEBUG_ALL_MASK ); |
---|
73 | #endif |
---|
74 | |
---|
75 | } |
---|
76 | |
---|
77 | /* |
---|
78 | * bsp_start |
---|
79 | * |
---|
80 | * This routine does the bulk of the system initialization. |
---|
81 | */ |
---|
82 | |
---|
83 | void bsp_start( void ) |
---|
84 | { |
---|
85 | extern void _sys_exit(int); |
---|
86 | extern int WorkspaceBase; |
---|
87 | extern void mips_install_isr_entries(); |
---|
88 | extern void mips_gdb_stub_install(void); |
---|
89 | |
---|
90 | Cpu_table.interrupt_stack_size = 4096; |
---|
91 | |
---|
92 | /* HACK -- tied to value linkcmds */ |
---|
93 | if ( BSP_Configuration.work_space_size > (4096*1024) ) |
---|
94 | _sys_exit( 1 ); |
---|
95 | |
---|
96 | BSP_Configuration.work_space_start = (void *) &WorkspaceBase; |
---|
97 | |
---|
98 | /* mask off any interrupts */ |
---|
99 | MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_FUNCTION_INTERRUPT_MASK_REGISTER, 0 ); |
---|
100 | |
---|
101 | /* reset the config register & clear any pending peripheral interrupts */ |
---|
102 | MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, 0 ); |
---|
103 | MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, MONGOOSEV_UART_CMD_RESET_BOTH_PORTS ); |
---|
104 | MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_COMMAND_REGISTER, 0 ); |
---|
105 | |
---|
106 | /* reset both timers */ |
---|
107 | MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER1_BASE, MONGOOSEV_TIMER_INITIAL_COUNTER_REGISTER, 0xffffffff ); |
---|
108 | MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER1_BASE, MONGOOSEV_TIMER_CONTROL_REGISTER, 0); |
---|
109 | |
---|
110 | MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER2_BASE, MONGOOSEV_TIMER_INITIAL_COUNTER_REGISTER, 0xffffffff ); |
---|
111 | MONGOOSEV_WRITE_REGISTER( MONGOOSEV_TIMER2_BASE, MONGOOSEV_TIMER_CONTROL_REGISTER, 0); |
---|
112 | |
---|
113 | /* clear any pending interrupts */ |
---|
114 | MONGOOSEV_WRITE( MONGOOSEV_PERIPHERAL_STATUS_REGISTER, 0xffffffff ); |
---|
115 | |
---|
116 | /* clear any writable bits in the cause register */ |
---|
117 | mips_set_cause( 0 ); |
---|
118 | |
---|
119 | /* set interrupt mask, but globally off. */ |
---|
120 | |
---|
121 | /* |
---|
122 | ** Bit 15 | Bit 14 | Bit 13 | Bit 12 | Bit 11 | Bit 10 | Bit 9 | Bit 8 | |
---|
123 | ** periph | unused | FPU | unused | timer2 | timer1 | swint1 | swint2 | |
---|
124 | ** extern | | | | | | | | |
---|
125 | ** |
---|
126 | ** 1 0 1 0 0 1 0 0 |
---|
127 | ** |
---|
128 | ** 0x8C00 Enable only internal Mongoose V timers. |
---|
129 | ** 0xA400 Enable Peripherial ints, FPU and timer1 |
---|
130 | ** 0x0400 Timer1 only |
---|
131 | */ |
---|
132 | |
---|
133 | /* mips_set_sr( (SR_CU0 | SR_CU1 | 0xA400) ); */ |
---|
134 | |
---|
135 | /* to start up, only enable coprocessor 0 & timer int. per-task |
---|
136 | ** processor settings will be applied as they are created, this |
---|
137 | ** is just to configure the processor for startup |
---|
138 | */ |
---|
139 | mips_set_sr( (SR_CU0 | 0x400) ); |
---|
140 | |
---|
141 | mips_install_isr_entries(); |
---|
142 | } |
---|
143 | |
---|
144 | void clear_cache( void ) |
---|
145 | { |
---|
146 | extern void promCopyIcacheFlush(void); /* from start.S */ |
---|
147 | extern void promCopyDcacheFlush(void); |
---|
148 | |
---|
149 | promCopyIcacheFlush(); |
---|
150 | promCopyDcacheFlush(); |
---|
151 | } |
---|
152 | |
---|
153 | #if 0 |
---|
154 | |
---|
155 | /* Structure filled in by get_mem_info. */ |
---|
156 | |
---|
157 | struct s_mem |
---|
158 | { |
---|
159 | unsigned int size; |
---|
160 | unsigned int icsize; |
---|
161 | unsigned int dcsize; |
---|
162 | }; |
---|
163 | |
---|
164 | extern uint32_t _RamSize; |
---|
165 | |
---|
166 | void get_mem_info ( struct s_mem *mem ) |
---|
167 | { |
---|
168 | mem->size = (uint32_t)&_RamSize; |
---|
169 | mem->icsize = MONGOOSEV_IC_SIZE; |
---|
170 | mem->dcsize = MONGOOSEV_DC_SIZE; |
---|
171 | } |
---|
172 | |
---|
173 | #endif |
---|