##// END OF EJS Templates
Bug 801 Don_Initialisation_P2
paul -
r320:6303d998f250 R3_plus draft
parent child
Show More
@@ -1,938 +1,945
1 /** This is the RTEMS initialization module.
1 /** This is the RTEMS initialization module.
2 *
2 *
3 * @file
3 * @file
4 * @author P. LEROY
4 * @author P. LEROY
5 *
5 *
6 * This module contains two very different information:
6 * This module contains two very different information:
7 * - specific instructions to configure the compilation of the RTEMS executive
7 * - specific instructions to configure the compilation of the RTEMS executive
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
8 * - functions related to the fligth softwre initialization, especially the INIT RTEMS task
9 *
9 *
10 */
10 */
11
11
12 //*************************
12 //*************************
13 // GPL reminder to be added
13 // GPL reminder to be added
14 //*************************
14 //*************************
15
15
16 #include <rtems.h>
16 #include <rtems.h>
17
17
18 /* configuration information */
18 /* configuration information */
19
19
20 #define CONFIGURE_INIT
20 #define CONFIGURE_INIT
21
21
22 #include <bsp.h> /* for device driver prototypes */
22 #include <bsp.h> /* for device driver prototypes */
23
23
24 /* configuration information */
24 /* configuration information */
25
25
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
26 #define CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
27 #define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
28
28
29 #define CONFIGURE_MAXIMUM_TASKS 20
29 #define CONFIGURE_MAXIMUM_TASKS 20
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
30 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
31 #define CONFIGURE_EXTRA_TASK_STACKS (3 * RTEMS_MINIMUM_STACK_SIZE)
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
32 #define CONFIGURE_LIBIO_MAXIMUM_FILE_DESCRIPTORS 32
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
33 #define CONFIGURE_INIT_TASK_PRIORITY 1 // instead of 100
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
34 #define CONFIGURE_INIT_TASK_MODE (RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT)
35 #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
35 #define CONFIGURE_INIT_TASK_ATTRIBUTES (RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT)
36 #define CONFIGURE_MAXIMUM_DRIVERS 16
36 #define CONFIGURE_MAXIMUM_DRIVERS 16
37 #define CONFIGURE_MAXIMUM_PERIODS 5
37 #define CONFIGURE_MAXIMUM_PERIODS 5
38 #define CONFIGURE_MAXIMUM_TIMERS 5 // [spiq] [link] [spacewire_reset_link]
38 #define CONFIGURE_MAXIMUM_TIMERS 5 // [spiq] [link] [spacewire_reset_link]
39 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
39 #define CONFIGURE_MAXIMUM_MESSAGE_QUEUES 5
40 #ifdef PRINT_STACK_REPORT
40 #ifdef PRINT_STACK_REPORT
41 #define CONFIGURE_STACK_CHECKER_ENABLED
41 #define CONFIGURE_STACK_CHECKER_ENABLED
42 #endif
42 #endif
43
43
44 #include <rtems/confdefs.h>
44 #include <rtems/confdefs.h>
45
45
46 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
46 /* If --drvmgr was enabled during the configuration of the RTEMS kernel */
47 #ifdef RTEMS_DRVMGR_STARTUP
47 #ifdef RTEMS_DRVMGR_STARTUP
48 #ifdef LEON3
48 #ifdef LEON3
49 /* Add Timer and UART Driver */
49 /* Add Timer and UART Driver */
50
50
51 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
51 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
52 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
52 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
53 #endif
53 #endif
54
54
55 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
55 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
56 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
57 #endif
57 #endif
58
58
59 #endif
59 #endif
60 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
60 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
61
61
62 #include <drvmgr/drvmgr_confdefs.h>
62 #include <drvmgr/drvmgr_confdefs.h>
63 #endif
63 #endif
64
64
65 #include "fsw_init.h"
65 #include "fsw_init.h"
66 #include "fsw_config.c"
66 #include "fsw_config.c"
67 #include "GscMemoryLPP.hpp"
67 #include "GscMemoryLPP.hpp"
68
68
69 void initCache()
69 void initCache()
70 {
70 {
71 // ASI 2 contains a few control registers that have not been assigned as ancillary state registers.
71 // ASI 2 contains a few control registers that have not been assigned as ancillary state registers.
72 // These should only be read and written using 32-bit LDA/STA instructions.
72 // These should only be read and written using 32-bit LDA/STA instructions.
73 // All cache registers are accessed through load/store operations to the alternate address space (LDA/STA), using ASI = 2.
73 // All cache registers are accessed through load/store operations to the alternate address space (LDA/STA), using ASI = 2.
74 // The table below shows the register addresses:
74 // The table below shows the register addresses:
75 // 0x00 Cache control register
75 // 0x00 Cache control register
76 // 0x04 Reserved
76 // 0x04 Reserved
77 // 0x08 Instruction cache configuration register
77 // 0x08 Instruction cache configuration register
78 // 0x0C Data cache configuration register
78 // 0x0C Data cache configuration register
79
79
80 // Cache Control Register Leon3 / Leon3FT
80 // Cache Control Register Leon3 / Leon3FT
81 // 31..30 29 28 27..24 23 22 21 20..19 18 17 16
81 // 31..30 29 28 27..24 23 22 21 20..19 18 17 16
82 // RFT PS TB DS FD FI FT ST IB
82 // RFT PS TB DS FD FI FT ST IB
83 // 15 14 13..12 11..10 9..8 7..6 5 4 3..2 1..0
83 // 15 14 13..12 11..10 9..8 7..6 5 4 3..2 1..0
84 // IP DP ITE IDE DTE DDE DF IF DCS ICS
84 // IP DP ITE IDE DTE DDE DF IF DCS ICS
85
85
86 unsigned int cacheControlRegister;
86 unsigned int cacheControlRegister;
87
87
88 CCR_resetCacheControlRegister();
88 CCR_resetCacheControlRegister();
89 ASR16_resetRegisterProtectionControlRegister();
89 ASR16_resetRegisterProtectionControlRegister();
90
90
91 cacheControlRegister = CCR_getValue();
91 cacheControlRegister = CCR_getValue();
92 PRINTF1("(0) CCR - Cache Control Register = %x\n", cacheControlRegister);
92 PRINTF1("(0) CCR - Cache Control Register = %x\n", cacheControlRegister);
93 PRINTF1("(0) ASR16 = %x\n", *asr16Ptr);
93 PRINTF1("(0) ASR16 = %x\n", *asr16Ptr);
94
94
95 CCR_enableInstructionCache(); // ICS bits
95 CCR_enableInstructionCache(); // ICS bits
96 CCR_enableDataCache(); // DCS bits
96 CCR_enableDataCache(); // DCS bits
97 CCR_enableInstructionBurstFetch(); // IB bit
97 CCR_enableInstructionBurstFetch(); // IB bit
98
98
99 faultTolerantScheme();
99 faultTolerantScheme();
100
100
101 cacheControlRegister = CCR_getValue();
101 cacheControlRegister = CCR_getValue();
102 PRINTF1("(1) CCR - Cache Control Register = %x\n", cacheControlRegister);
102 PRINTF1("(1) CCR - Cache Control Register = %x\n", cacheControlRegister);
103 PRINTF1("(1) ASR16 Register protection control register = %x\n", *asr16Ptr);
103 PRINTF1("(1) ASR16 Register protection control register = %x\n", *asr16Ptr);
104
104
105 PRINTF("\n");
105 PRINTF("\n");
106 }
106 }
107
107
108 rtems_task Init( rtems_task_argument ignored )
108 rtems_task Init( rtems_task_argument ignored )
109 {
109 {
110 /** This is the RTEMS INIT taks, it is the first task launched by the system.
110 /** This is the RTEMS INIT taks, it is the first task launched by the system.
111 *
111 *
112 * @param unused is the starting argument of the RTEMS task
112 * @param unused is the starting argument of the RTEMS task
113 *
113 *
114 * The INIT task create and run all other RTEMS tasks.
114 * The INIT task create and run all other RTEMS tasks.
115 *
115 *
116 */
116 */
117
117
118 //***********
118 //***********
119 // INIT CACHE
119 // INIT CACHE
120
120
121 unsigned char *vhdlVersion;
121 unsigned char *vhdlVersion;
122
122
123 reset_lfr();
123 reset_lfr();
124
124
125 reset_local_time();
125 reset_local_time();
126
126
127 rtems_cpu_usage_reset();
127 rtems_cpu_usage_reset();
128
128
129 rtems_status_code status;
129 rtems_status_code status;
130 rtems_status_code status_spw;
130 rtems_status_code status_spw;
131 rtems_isr_entry old_isr_handler;
131 rtems_isr_entry old_isr_handler;
132
132
133 old_isr_handler = NULL;
134
133 // UART settings
135 // UART settings
134 enable_apbuart_transmitter();
136 enable_apbuart_transmitter();
135 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
137 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
136
138
137 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
139 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
138
140
139
141
140 PRINTF("\n\n\n\n\n")
142 PRINTF("\n\n\n\n\n")
141
143
142 initCache();
144 initCache();
143
145
144 PRINTF("*************************\n")
146 PRINTF("*************************\n")
145 PRINTF("** LFR Flight Software **\n")
147 PRINTF("** LFR Flight Software **\n")
146
148
147 PRINTF1("** %d-", SW_VERSION_N1)
149 PRINTF1("** %d-", SW_VERSION_N1)
148 PRINTF1("%d-" , SW_VERSION_N2)
150 PRINTF1("%d-" , SW_VERSION_N2)
149 PRINTF1("%d-" , SW_VERSION_N3)
151 PRINTF1("%d-" , SW_VERSION_N3)
150 PRINTF1("%d **\n", SW_VERSION_N4)
152 PRINTF1("%d **\n", SW_VERSION_N4)
151
153
152 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
154 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
153 PRINTF("** VHDL **\n")
155 PRINTF("** VHDL **\n")
154 PRINTF1("** %d.", vhdlVersion[1])
156 PRINTF1("** %d.", vhdlVersion[1])
155 PRINTF1("%d." , vhdlVersion[2])
157 PRINTF1("%d." , vhdlVersion[2])
156 PRINTF1("%d **\n", vhdlVersion[3])
158 PRINTF1("%d **\n", vhdlVersion[3])
157 PRINTF("*************************\n")
159 PRINTF("*************************\n")
158 PRINTF("\n\n")
160 PRINTF("\n\n")
159
161
160 init_parameter_dump();
162 init_parameter_dump();
161 init_kcoefficients_dump();
163 init_kcoefficients_dump();
162 init_local_mode_parameters();
164 init_local_mode_parameters();
163 init_housekeeping_parameters();
165 init_housekeeping_parameters();
164 init_k_coefficients_prc0();
166 init_k_coefficients_prc0();
165 init_k_coefficients_prc1();
167 init_k_coefficients_prc1();
166 init_k_coefficients_prc2();
168 init_k_coefficients_prc2();
167 pa_bia_status_info = INIT_CHAR;
169 pa_bia_status_info = INIT_CHAR;
168 cp_rpw_sc_rw_f_flags = INIT_CHAR;
170 cp_rpw_sc_rw_f_flags = INIT_CHAR;
169 cp_rpw_sc_rw1_f1 = INIT_FLOAT;
171 cp_rpw_sc_rw1_f1 = INIT_FLOAT;
170 cp_rpw_sc_rw1_f2 = INIT_FLOAT;
172 cp_rpw_sc_rw1_f2 = INIT_FLOAT;
171 cp_rpw_sc_rw2_f1 = INIT_FLOAT;
173 cp_rpw_sc_rw2_f1 = INIT_FLOAT;
172 cp_rpw_sc_rw2_f2 = INIT_FLOAT;
174 cp_rpw_sc_rw2_f2 = INIT_FLOAT;
173 cp_rpw_sc_rw3_f1 = INIT_FLOAT;
175 cp_rpw_sc_rw3_f1 = INIT_FLOAT;
174 cp_rpw_sc_rw3_f2 = INIT_FLOAT;
176 cp_rpw_sc_rw3_f2 = INIT_FLOAT;
175 cp_rpw_sc_rw4_f1 = INIT_FLOAT;
177 cp_rpw_sc_rw4_f1 = INIT_FLOAT;
176 cp_rpw_sc_rw4_f2 = INIT_FLOAT;
178 cp_rpw_sc_rw4_f2 = INIT_FLOAT;
177 // initialize filtering parameters
179 // initialize filtering parameters
178 filterPar.spare_sy_lfr_pas_filter_enabled = DEFAULT_SY_LFR_PAS_FILTER_ENABLED;
180 filterPar.spare_sy_lfr_pas_filter_enabled = DEFAULT_SY_LFR_PAS_FILTER_ENABLED;
179 filterPar.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
181 filterPar.sy_lfr_pas_filter_modulus = DEFAULT_SY_LFR_PAS_FILTER_MODULUS;
180 filterPar.sy_lfr_pas_filter_tbad = DEFAULT_SY_LFR_PAS_FILTER_TBAD;
182 filterPar.sy_lfr_pas_filter_tbad = DEFAULT_SY_LFR_PAS_FILTER_TBAD;
181 filterPar.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
183 filterPar.sy_lfr_pas_filter_offset = DEFAULT_SY_LFR_PAS_FILTER_OFFSET;
182 filterPar.sy_lfr_pas_filter_shift = DEFAULT_SY_LFR_PAS_FILTER_SHIFT;
184 filterPar.sy_lfr_pas_filter_shift = DEFAULT_SY_LFR_PAS_FILTER_SHIFT;
183 filterPar.sy_lfr_sc_rw_delta_f = DEFAULT_SY_LFR_SC_RW_DELTA_F;
185 filterPar.sy_lfr_sc_rw_delta_f = DEFAULT_SY_LFR_SC_RW_DELTA_F;
184 update_last_valid_transition_date( DEFAULT_LAST_VALID_TRANSITION_DATE );
186 update_last_valid_transition_date( DEFAULT_LAST_VALID_TRANSITION_DATE );
185
187
186 // waveform picker initialization
188 // waveform picker initialization
187 WFP_init_rings();
189 WFP_init_rings();
188 LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings
190 LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings
189 WFP_reset_current_ring_nodes();
191 WFP_reset_current_ring_nodes();
190 reset_waveform_picker_regs();
192 reset_waveform_picker_regs();
191
193
192 // spectral matrices initialization
194 // spectral matrices initialization
193 SM_init_rings(); // initialize spectral matrices rings
195 SM_init_rings(); // initialize spectral matrices rings
194 SM_reset_current_ring_nodes();
196 SM_reset_current_ring_nodes();
195 reset_spectral_matrix_regs();
197 reset_spectral_matrix_regs();
196
198
197 // configure calibration
199 // configure calibration
198 configureCalibration( false ); // true means interleaved mode, false is for normal mode
200 configureCalibration( false ); // true means interleaved mode, false is for normal mode
199
201
200 updateLFRCurrentMode( LFR_MODE_STANDBY );
202 updateLFRCurrentMode( LFR_MODE_STANDBY );
201
203
202 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
204 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
203
205
204 create_names(); // create all names
206 create_names(); // create all names
205
207
206 status = create_timecode_timer(); // create the timer used by timecode_irq_handler
208 status = create_timecode_timer(); // create the timer used by timecode_irq_handler
207 if (status != RTEMS_SUCCESSFUL)
209 if (status != RTEMS_SUCCESSFUL)
208 {
210 {
209 PRINTF1("in INIT *** ERR in create_timer_timecode, code %d", status)
211 PRINTF1("in INIT *** ERR in create_timer_timecode, code %d", status)
210 }
212 }
211
213
212 status = create_message_queues(); // create message queues
214 status = create_message_queues(); // create message queues
213 if (status != RTEMS_SUCCESSFUL)
215 if (status != RTEMS_SUCCESSFUL)
214 {
216 {
215 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
217 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
216 }
218 }
217
219
218 status = create_all_tasks(); // create all tasks
220 status = create_all_tasks(); // create all tasks
219 if (status != RTEMS_SUCCESSFUL)
221 if (status != RTEMS_SUCCESSFUL)
220 {
222 {
221 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
223 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
222 }
224 }
223
225
224 // **************************
226 // **************************
225 // <SPACEWIRE INITIALIZATION>
227 // <SPACEWIRE INITIALIZATION>
226 status_spw = spacewire_open_link(); // (1) open the link
228 status_spw = spacewire_open_link(); // (1) open the link
227 if ( status_spw != RTEMS_SUCCESSFUL )
229 if ( status_spw != RTEMS_SUCCESSFUL )
228 {
230 {
229 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
231 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
230 }
232 }
231
233
232 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
234 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
233 {
235 {
234 status_spw = spacewire_configure_link( fdSPW );
236 status_spw = spacewire_configure_link( fdSPW );
235 if ( status_spw != RTEMS_SUCCESSFUL )
237 if ( status_spw != RTEMS_SUCCESSFUL )
236 {
238 {
237 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
239 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
238 }
240 }
239 }
241 }
240
242
241 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
243 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
242 {
244 {
243 status_spw = spacewire_start_link( fdSPW );
245 status_spw = spacewire_start_link( fdSPW );
244 if ( status_spw != RTEMS_SUCCESSFUL )
246 if ( status_spw != RTEMS_SUCCESSFUL )
245 {
247 {
246 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
248 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
247 }
249 }
248 }
250 }
249 // </SPACEWIRE INITIALIZATION>
251 // </SPACEWIRE INITIALIZATION>
250 // ***************************
252 // ***************************
251
253
252 status = start_all_tasks(); // start all tasks
254 status = start_all_tasks(); // start all tasks
253 if (status != RTEMS_SUCCESSFUL)
255 if (status != RTEMS_SUCCESSFUL)
254 {
256 {
255 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
257 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
256 }
258 }
257
259
258 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
260 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
259 status = start_recv_send_tasks();
261 status = start_recv_send_tasks();
260 if ( status != RTEMS_SUCCESSFUL )
262 if ( status != RTEMS_SUCCESSFUL )
261 {
263 {
262 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
264 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
263 }
265 }
264
266
265 // suspend science tasks, they will be restarted later depending on the mode
267 // suspend science tasks, they will be restarted later depending on the mode
266 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
268 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
267 if (status != RTEMS_SUCCESSFUL)
269 if (status != RTEMS_SUCCESSFUL)
268 {
270 {
269 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
271 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
270 }
272 }
271
273
272 // configure IRQ handling for the waveform picker unit
274 // configure IRQ handling for the waveform picker unit
273 status = rtems_interrupt_catch( waveforms_isr,
275 status = rtems_interrupt_catch( waveforms_isr,
274 IRQ_SPARC_WAVEFORM_PICKER,
276 IRQ_SPARC_WAVEFORM_PICKER,
275 &old_isr_handler) ;
277 &old_isr_handler) ;
276 // configure IRQ handling for the spectral matrices unit
278 // configure IRQ handling for the spectral matrices unit
277 status = rtems_interrupt_catch( spectral_matrices_isr,
279 status = rtems_interrupt_catch( spectral_matrices_isr,
278 IRQ_SPARC_SPECTRAL_MATRIX,
280 IRQ_SPARC_SPECTRAL_MATRIX,
279 &old_isr_handler) ;
281 &old_isr_handler) ;
280
282
281 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
283 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
282 if ( status_spw != RTEMS_SUCCESSFUL )
284 if ( status_spw != RTEMS_SUCCESSFUL )
283 {
285 {
284 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
286 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
285 if ( status != RTEMS_SUCCESSFUL ) {
287 if ( status != RTEMS_SUCCESSFUL ) {
286 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
288 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
287 }
289 }
288 }
290 }
289
291
290 BOOT_PRINTF("delete INIT\n")
292 BOOT_PRINTF("delete INIT\n")
291
293
292 set_hk_lfr_sc_potential_flag( true );
294 set_hk_lfr_sc_potential_flag( true );
293
295
294 // start the timer to detect a missing spacewire timecode
296 // start the timer to detect a missing spacewire timecode
295 // the timeout is larger because the spw IP needs to receive several valid timecodes before generating a tickout
297 // the timeout is larger because the spw IP needs to receive several valid timecodes before generating a tickout
296 // if a tickout is generated, the timer is restarted
298 // if a tickout is generated, the timer is restarted
297 status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT_INIT, timecode_timer_routine, NULL );
299 status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT_INIT, timecode_timer_routine, NULL );
298
300
299 grspw_timecode_callback = &timecode_irq_handler;
301 grspw_timecode_callback = &timecode_irq_handler;
300
302
301 status = rtems_task_delete(RTEMS_SELF);
303 status = rtems_task_delete(RTEMS_SELF);
302
304
303 }
305 }
304
306
305 void init_local_mode_parameters( void )
307 void init_local_mode_parameters( void )
306 {
308 {
307 /** This function initialize the param_local global variable with default values.
309 /** This function initialize the param_local global variable with default values.
308 *
310 *
309 */
311 */
310
312
311 unsigned int i;
313 unsigned int i;
312
314
313 // LOCAL PARAMETERS
315 // LOCAL PARAMETERS
314
316
315 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
317 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
316 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
318 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
317
319
318 // init sequence counters
320 // init sequence counters
319
321
320 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
322 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
321 {
323 {
322 sequenceCounters_TC_EXE[i] = INIT_CHAR;
324 sequenceCounters_TC_EXE[i] = INIT_CHAR;
323 sequenceCounters_TM_DUMP[i] = INIT_CHAR;
325 sequenceCounters_TM_DUMP[i] = INIT_CHAR;
324 }
326 }
325 sequenceCounters_SCIENCE_NORMAL_BURST = INIT_CHAR;
327 sequenceCounters_SCIENCE_NORMAL_BURST = INIT_CHAR;
326 sequenceCounters_SCIENCE_SBM1_SBM2 = INIT_CHAR;
328 sequenceCounters_SCIENCE_SBM1_SBM2 = INIT_CHAR;
327 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << TM_PACKET_SEQ_SHIFT;
329 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << TM_PACKET_SEQ_SHIFT;
328 }
330 }
329
331
330 void reset_local_time( void )
332 void reset_local_time( void )
331 {
333 {
332 time_management_regs->ctrl = time_management_regs->ctrl | VAL_SOFTWARE_RESET; // [0010] software reset, coarse time = 0x80000000
334 time_management_regs->ctrl = time_management_regs->ctrl | VAL_SOFTWARE_RESET; // [0010] software reset, coarse time = 0x80000000
333 }
335 }
334
336
335 void create_names( void ) // create all names for tasks and queues
337 void create_names( void ) // create all names for tasks and queues
336 {
338 {
337 /** This function creates all RTEMS names used in the software for tasks and queues.
339 /** This function creates all RTEMS names used in the software for tasks and queues.
338 *
340 *
339 * @return RTEMS directive status codes:
341 * @return RTEMS directive status codes:
340 * - RTEMS_SUCCESSFUL - successful completion
342 * - RTEMS_SUCCESSFUL - successful completion
341 *
343 *
342 */
344 */
343
345
344 // task names
346 // task names
345 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
347 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
346 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
348 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
347 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
349 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
348 Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' );
350 Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' );
349 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
351 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
350 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
352 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
351 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
353 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
352 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
354 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
353 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
355 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
354 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
356 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
355 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
357 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
356 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
358 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
357 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
359 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
358 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
360 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
359 Task_name[TASKID_LINK] = rtems_build_name( 'L', 'I', 'N', 'K' );
361 Task_name[TASKID_LINK] = rtems_build_name( 'L', 'I', 'N', 'K' );
360 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
362 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
361 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
363 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
362 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
364 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
363 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
365 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
364
366
365 // rate monotonic period names
367 // rate monotonic period names
366 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
368 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
367
369
368 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
370 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
369 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
371 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
370 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
372 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
371 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
373 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
372 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
374 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
373
375
374 timecode_timer_name = rtems_build_name( 'S', 'P', 'T', 'C' );
376 timecode_timer_name = rtems_build_name( 'S', 'P', 'T', 'C' );
375 }
377 }
376
378
377 int create_all_tasks( void ) // create all tasks which run in the software
379 int create_all_tasks( void ) // create all tasks which run in the software
378 {
380 {
379 /** This function creates all RTEMS tasks used in the software.
381 /** This function creates all RTEMS tasks used in the software.
380 *
382 *
381 * @return RTEMS directive status codes:
383 * @return RTEMS directive status codes:
382 * - RTEMS_SUCCESSFUL - task created successfully
384 * - RTEMS_SUCCESSFUL - task created successfully
383 * - RTEMS_INVALID_ADDRESS - id is NULL
385 * - RTEMS_INVALID_ADDRESS - id is NULL
384 * - RTEMS_INVALID_NAME - invalid task name
386 * - RTEMS_INVALID_NAME - invalid task name
385 * - RTEMS_INVALID_PRIORITY - invalid task priority
387 * - RTEMS_INVALID_PRIORITY - invalid task priority
386 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
388 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
387 * - RTEMS_TOO_MANY - too many tasks created
389 * - RTEMS_TOO_MANY - too many tasks created
388 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
390 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
389 * - RTEMS_TOO_MANY - too many global objects
391 * - RTEMS_TOO_MANY - too many global objects
390 *
392 *
391 */
393 */
392
394
393 rtems_status_code status;
395 rtems_status_code status;
394
396
395 //**********
397 //**********
396 // SPACEWIRE
398 // SPACEWIRE
397 // RECV
399 // RECV
398 status = rtems_task_create(
400 status = rtems_task_create(
399 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
401 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
400 RTEMS_DEFAULT_MODES,
402 RTEMS_DEFAULT_MODES,
401 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
403 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
402 );
404 );
403 if (status == RTEMS_SUCCESSFUL) // SEND
405 if (status == RTEMS_SUCCESSFUL) // SEND
404 {
406 {
405 status = rtems_task_create(
407 status = rtems_task_create(
406 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT,
408 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT,
407 RTEMS_DEFAULT_MODES,
409 RTEMS_DEFAULT_MODES,
408 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND]
410 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND]
409 );
411 );
410 }
412 }
411 if (status == RTEMS_SUCCESSFUL) // LINK
413 if (status == RTEMS_SUCCESSFUL) // LINK
412 {
414 {
413 status = rtems_task_create(
415 status = rtems_task_create(
414 Task_name[TASKID_LINK], TASK_PRIORITY_LINK, RTEMS_MINIMUM_STACK_SIZE,
416 Task_name[TASKID_LINK], TASK_PRIORITY_LINK, RTEMS_MINIMUM_STACK_SIZE,
415 RTEMS_DEFAULT_MODES,
417 RTEMS_DEFAULT_MODES,
416 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LINK]
418 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LINK]
417 );
419 );
418 }
420 }
419 if (status == RTEMS_SUCCESSFUL) // ACTN
421 if (status == RTEMS_SUCCESSFUL) // ACTN
420 {
422 {
421 status = rtems_task_create(
423 status = rtems_task_create(
422 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
424 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
423 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
425 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
424 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
426 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
425 );
427 );
426 }
428 }
427 if (status == RTEMS_SUCCESSFUL) // SPIQ
429 if (status == RTEMS_SUCCESSFUL) // SPIQ
428 {
430 {
429 status = rtems_task_create(
431 status = rtems_task_create(
430 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
432 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
431 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
433 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
432 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
434 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
433 );
435 );
434 }
436 }
435
437
436 //******************
438 //******************
437 // SPECTRAL MATRICES
439 // SPECTRAL MATRICES
438 if (status == RTEMS_SUCCESSFUL) // AVF0
440 if (status == RTEMS_SUCCESSFUL) // AVF0
439 {
441 {
440 status = rtems_task_create(
442 status = rtems_task_create(
441 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
443 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
442 RTEMS_DEFAULT_MODES,
444 RTEMS_DEFAULT_MODES,
443 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
445 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
444 );
446 );
445 }
447 }
446 if (status == RTEMS_SUCCESSFUL) // PRC0
448 if (status == RTEMS_SUCCESSFUL) // PRC0
447 {
449 {
448 status = rtems_task_create(
450 status = rtems_task_create(
449 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT,
451 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT,
450 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
452 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
451 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
453 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
452 );
454 );
453 }
455 }
454 if (status == RTEMS_SUCCESSFUL) // AVF1
456 if (status == RTEMS_SUCCESSFUL) // AVF1
455 {
457 {
456 status = rtems_task_create(
458 status = rtems_task_create(
457 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
459 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
458 RTEMS_DEFAULT_MODES,
460 RTEMS_DEFAULT_MODES,
459 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
461 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
460 );
462 );
461 }
463 }
462 if (status == RTEMS_SUCCESSFUL) // PRC1
464 if (status == RTEMS_SUCCESSFUL) // PRC1
463 {
465 {
464 status = rtems_task_create(
466 status = rtems_task_create(
465 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT,
467 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT,
466 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
468 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
467 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
469 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
468 );
470 );
469 }
471 }
470 if (status == RTEMS_SUCCESSFUL) // AVF2
472 if (status == RTEMS_SUCCESSFUL) // AVF2
471 {
473 {
472 status = rtems_task_create(
474 status = rtems_task_create(
473 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
475 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
474 RTEMS_DEFAULT_MODES,
476 RTEMS_DEFAULT_MODES,
475 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
477 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
476 );
478 );
477 }
479 }
478 if (status == RTEMS_SUCCESSFUL) // PRC2
480 if (status == RTEMS_SUCCESSFUL) // PRC2
479 {
481 {
480 status = rtems_task_create(
482 status = rtems_task_create(
481 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT,
483 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * STACK_SIZE_MULT,
482 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
484 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
483 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
485 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
484 );
486 );
485 }
487 }
486
488
487 //****************
489 //****************
488 // WAVEFORM PICKER
490 // WAVEFORM PICKER
489 if (status == RTEMS_SUCCESSFUL) // WFRM
491 if (status == RTEMS_SUCCESSFUL) // WFRM
490 {
492 {
491 status = rtems_task_create(
493 status = rtems_task_create(
492 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
494 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
493 RTEMS_DEFAULT_MODES,
495 RTEMS_DEFAULT_MODES,
494 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
496 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
495 );
497 );
496 }
498 }
497 if (status == RTEMS_SUCCESSFUL) // CWF3
499 if (status == RTEMS_SUCCESSFUL) // CWF3
498 {
500 {
499 status = rtems_task_create(
501 status = rtems_task_create(
500 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
502 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
501 RTEMS_DEFAULT_MODES,
503 RTEMS_DEFAULT_MODES,
502 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
504 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
503 );
505 );
504 }
506 }
505 if (status == RTEMS_SUCCESSFUL) // CWF2
507 if (status == RTEMS_SUCCESSFUL) // CWF2
506 {
508 {
507 status = rtems_task_create(
509 status = rtems_task_create(
508 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
510 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
509 RTEMS_DEFAULT_MODES,
511 RTEMS_DEFAULT_MODES,
510 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
512 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
511 );
513 );
512 }
514 }
513 if (status == RTEMS_SUCCESSFUL) // CWF1
515 if (status == RTEMS_SUCCESSFUL) // CWF1
514 {
516 {
515 status = rtems_task_create(
517 status = rtems_task_create(
516 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
518 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
517 RTEMS_DEFAULT_MODES,
519 RTEMS_DEFAULT_MODES,
518 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
520 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
519 );
521 );
520 }
522 }
521 if (status == RTEMS_SUCCESSFUL) // SWBD
523 if (status == RTEMS_SUCCESSFUL) // SWBD
522 {
524 {
523 status = rtems_task_create(
525 status = rtems_task_create(
524 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
526 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
525 RTEMS_DEFAULT_MODES,
527 RTEMS_DEFAULT_MODES,
526 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
528 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
527 );
529 );
528 }
530 }
529
531
530 //*****
532 //*****
531 // MISC
533 // MISC
532 if (status == RTEMS_SUCCESSFUL) // LOAD
534 if (status == RTEMS_SUCCESSFUL) // LOAD
533 {
535 {
534 status = rtems_task_create(
536 status = rtems_task_create(
535 Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE,
537 Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE,
536 RTEMS_DEFAULT_MODES,
538 RTEMS_DEFAULT_MODES,
537 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD]
539 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD]
538 );
540 );
539 }
541 }
540 if (status == RTEMS_SUCCESSFUL) // DUMB
542 if (status == RTEMS_SUCCESSFUL) // DUMB
541 {
543 {
542 status = rtems_task_create(
544 status = rtems_task_create(
543 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
545 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
544 RTEMS_DEFAULT_MODES,
546 RTEMS_DEFAULT_MODES,
545 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
547 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
546 );
548 );
547 }
549 }
548 if (status == RTEMS_SUCCESSFUL) // HOUS
550 if (status == RTEMS_SUCCESSFUL) // HOUS
549 {
551 {
550 status = rtems_task_create(
552 status = rtems_task_create(
551 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
553 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
552 RTEMS_DEFAULT_MODES,
554 RTEMS_DEFAULT_MODES,
553 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS]
555 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS]
554 );
556 );
555 }
557 }
556
558
557 return status;
559 return status;
558 }
560 }
559
561
560 int start_recv_send_tasks( void )
562 int start_recv_send_tasks( void )
561 {
563 {
562 rtems_status_code status;
564 rtems_status_code status;
563
565
564 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
566 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
565 if (status!=RTEMS_SUCCESSFUL) {
567 if (status!=RTEMS_SUCCESSFUL) {
566 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
568 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
567 }
569 }
568
570
569 if (status == RTEMS_SUCCESSFUL) // SEND
571 if (status == RTEMS_SUCCESSFUL) // SEND
570 {
572 {
571 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
573 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
572 if (status!=RTEMS_SUCCESSFUL) {
574 if (status!=RTEMS_SUCCESSFUL) {
573 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
575 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
574 }
576 }
575 }
577 }
576
578
577 return status;
579 return status;
578 }
580 }
579
581
580 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
582 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
581 {
583 {
582 /** This function starts all RTEMS tasks used in the software.
584 /** This function starts all RTEMS tasks used in the software.
583 *
585 *
584 * @return RTEMS directive status codes:
586 * @return RTEMS directive status codes:
585 * - RTEMS_SUCCESSFUL - ask started successfully
587 * - RTEMS_SUCCESSFUL - ask started successfully
586 * - RTEMS_INVALID_ADDRESS - invalid task entry point
588 * - RTEMS_INVALID_ADDRESS - invalid task entry point
587 * - RTEMS_INVALID_ID - invalid task id
589 * - RTEMS_INVALID_ID - invalid task id
588 * - RTEMS_INCORRECT_STATE - task not in the dormant state
590 * - RTEMS_INCORRECT_STATE - task not in the dormant state
589 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
591 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
590 *
592 *
591 */
593 */
592 // starts all the tasks fot eh flight software
594 // starts all the tasks fot eh flight software
593
595
594 rtems_status_code status;
596 rtems_status_code status;
595
597
596 //**********
598 //**********
597 // SPACEWIRE
599 // SPACEWIRE
598 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
600 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
599 if (status!=RTEMS_SUCCESSFUL) {
601 if (status!=RTEMS_SUCCESSFUL) {
600 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
602 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
601 }
603 }
602
604
603 if (status == RTEMS_SUCCESSFUL) // LINK
605 if (status == RTEMS_SUCCESSFUL) // LINK
604 {
606 {
605 status = rtems_task_start( Task_id[TASKID_LINK], link_task, 1 );
607 status = rtems_task_start( Task_id[TASKID_LINK], link_task, 1 );
606 if (status!=RTEMS_SUCCESSFUL) {
608 if (status!=RTEMS_SUCCESSFUL) {
607 BOOT_PRINTF("in INIT *** Error starting TASK_LINK\n")
609 BOOT_PRINTF("in INIT *** Error starting TASK_LINK\n"