##// END OF EJS Templates
minor typos
paul -
r284:c97e85c97b15 R3_plus draft
parent child
Show More
@@ -1,2 +1,2
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
1 3081d1f9bb20b2b64a192585337a292a9804e0c5 LFR_basic-parameters
2 81c3289ebd2a13e3b3147acdf60e34678378f905 header/lfr_common_headers
2 d867fbc1a62231ed43bdda3e91b3f45f45806c3d header/lfr_common_headers
@@ -1,926 +1,927
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 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
50 #ifdef CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
51 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
51 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GPTIMER
52 #endif
52 #endif
53 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
53 #ifdef CONFIGURE_APPLICATION_NEEDS_CONSOLE_DRIVER
54 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
54 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_APBUART
55 #endif
55 #endif
56 #endif
56 #endif
57 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
57 #define CONFIGURE_DRIVER_AMBAPP_GAISLER_GRSPW /* GRSPW Driver */
58 #include <drvmgr/drvmgr_confdefs.h>
58 #include <drvmgr/drvmgr_confdefs.h>
59 #endif
59 #endif
60
60
61 #include "fsw_init.h"
61 #include "fsw_init.h"
62 #include "fsw_config.c"
62 #include "fsw_config.c"
63 #include "GscMemoryLPP.hpp"
63 #include "GscMemoryLPP.hpp"
64
64
65 void initCache()
65 void initCache()
66 {
66 {
67 // ASI 2 contains a few control registers that have not been assigned as ancillary state registers.
67 // ASI 2 contains a few control registers that have not been assigned as ancillary state registers.
68 // These should only be read and written using 32-bit LDA/STA instructions.
68 // These should only be read and written using 32-bit LDA/STA instructions.
69 // All cache registers are accessed through load/store operations to the alternate address space (LDA/STA), using ASI = 2.
69 // All cache registers are accessed through load/store operations to the alternate address space (LDA/STA), using ASI = 2.
70 // The table below shows the register addresses:
70 // The table below shows the register addresses:
71 // 0x00 Cache control register
71 // 0x00 Cache control register
72 // 0x04 Reserved
72 // 0x04 Reserved
73 // 0x08 Instruction cache configuration register
73 // 0x08 Instruction cache configuration register
74 // 0x0C Data cache configuration register
74 // 0x0C Data cache configuration register
75
75
76 // Cache Control Register Leon3 / Leon3FT
76 // Cache Control Register Leon3 / Leon3FT
77 // 31..30 29 28 27..24 23 22 21 20..19 18 17 16
77 // 31..30 29 28 27..24 23 22 21 20..19 18 17 16
78 // RFT PS TB DS FD FI FT ST IB
78 // RFT PS TB DS FD FI FT ST IB
79 // 15 14 13..12 11..10 9..8 7..6 5 4 3..2 1..0
79 // 15 14 13..12 11..10 9..8 7..6 5 4 3..2 1..0
80 // IP DP ITE IDE DTE DDE DF IF DCS ICS
80 // IP DP ITE IDE DTE DDE DF IF DCS ICS
81
81
82 unsigned int cacheControlRegister;
82 unsigned int cacheControlRegister;
83
83
84 CCR_resetCacheControlRegister();
84 CCR_resetCacheControlRegister();
85 ASR16_resetRegisterProtectionControlRegister();
85 ASR16_resetRegisterProtectionControlRegister();
86
86
87 cacheControlRegister = CCR_getValue();
87 cacheControlRegister = CCR_getValue();
88 PRINTF1("(0) CCR - Cache Control Register = %x\n", cacheControlRegister);
88 PRINTF1("(0) CCR - Cache Control Register = %x\n", cacheControlRegister);
89 PRINTF1("(0) ASR16 = %x\n", *asr16Ptr);
89 PRINTF1("(0) ASR16 = %x\n", *asr16Ptr);
90
90
91 CCR_enableInstructionCache(); // ICS bits
91 CCR_enableInstructionCache(); // ICS bits
92 CCR_enableDataCache(); // DCS bits
92 CCR_enableDataCache(); // DCS bits
93 CCR_enableInstructionBurstFetch(); // IB bit
93 CCR_enableInstructionBurstFetch(); // IB bit
94
94
95 faultTolerantScheme();
95 faultTolerantScheme();
96
96
97 cacheControlRegister = CCR_getValue();
97 cacheControlRegister = CCR_getValue();
98 PRINTF1("(1) CCR - Cache Control Register = %x\n", cacheControlRegister);
98 PRINTF1("(1) CCR - Cache Control Register = %x\n", cacheControlRegister);
99 PRINTF1("(1) ASR16 Register protection control register = %x\n", *asr16Ptr);
99 PRINTF1("(1) ASR16 Register protection control register = %x\n", *asr16Ptr);
100
100
101 PRINTF("\n");
101 PRINTF("\n");
102 }
102 }
103
103
104 rtems_task Init( rtems_task_argument ignored )
104 rtems_task Init( rtems_task_argument ignored )
105 {
105 {
106 /** This is the RTEMS INIT taks, it is the first task launched by the system.
106 /** This is the RTEMS INIT taks, it is the first task launched by the system.
107 *
107 *
108 * @param unused is the starting argument of the RTEMS task
108 * @param unused is the starting argument of the RTEMS task
109 *
109 *
110 * The INIT task create and run all other RTEMS tasks.
110 * The INIT task create and run all other RTEMS tasks.
111 *
111 *
112 */
112 */
113
113
114 //***********
114 //***********
115 // INIT CACHE
115 // INIT CACHE
116
116
117 unsigned char *vhdlVersion;
117 unsigned char *vhdlVersion;
118
118
119 reset_lfr();
119 reset_lfr();
120
120
121 reset_local_time();
121 reset_local_time();
122
122
123 rtems_cpu_usage_reset();
123 rtems_cpu_usage_reset();
124
124
125 rtems_status_code status;
125 rtems_status_code status;
126 rtems_status_code status_spw;
126 rtems_status_code status_spw;
127 rtems_isr_entry old_isr_handler;
127 rtems_isr_entry old_isr_handler;
128
128
129 // UART settings
129 // UART settings
130 enable_apbuart_transmitter();
130 enable_apbuart_transmitter();
131 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
131 set_apbuart_scaler_reload_register(REGS_ADDR_APBUART, APBUART_SCALER_RELOAD_VALUE);
132
132
133 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
133 DEBUG_PRINTF("\n\n\n\n\nIn INIT *** Now the console is on port COM1\n")
134
134
135
135
136 PRINTF("\n\n\n\n\n")
136 PRINTF("\n\n\n\n\n")
137
137
138 initCache();
138 initCache();
139
139
140 PRINTF("*************************\n")
140 PRINTF("*************************\n")
141 PRINTF("** LFR Flight Software **\n")
141 PRINTF("** LFR Flight Software **\n")
142 PRINTF1("** %d.", SW_VERSION_N1)
142 PRINTF1("** %d.", SW_VERSION_N1)
143 PRINTF1("%d." , SW_VERSION_N2)
143 PRINTF1("%d." , SW_VERSION_N2)
144 PRINTF1("%d." , SW_VERSION_N3)
144 PRINTF1("%d." , SW_VERSION_N3)
145 PRINTF1("%d **\n", SW_VERSION_N4)
145 PRINTF1("%d **\n", SW_VERSION_N4)
146
146
147 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
147 vhdlVersion = (unsigned char *) (REGS_ADDR_VHDL_VERSION);
148 PRINTF("** VHDL **\n")
148 PRINTF("** VHDL **\n")
149 PRINTF1("** %d.", vhdlVersion[1])
149 PRINTF1("** %d.", vhdlVersion[1])
150 PRINTF1("%d." , vhdlVersion[2])
150 PRINTF1("%d." , vhdlVersion[2])
151 PRINTF1("%d **\n", vhdlVersion[3])
151 PRINTF1("%d **\n", vhdlVersion[3])
152 PRINTF("*************************\n")
152 PRINTF("*************************\n")
153 PRINTF("\n\n")
153 PRINTF("\n\n")
154
154
155 init_parameter_dump();
155 init_parameter_dump();
156 init_kcoefficients_dump();
156 init_kcoefficients_dump();
157 init_local_mode_parameters();
157 init_local_mode_parameters();
158 init_housekeeping_parameters();
158 init_housekeeping_parameters();
159 init_k_coefficients_prc0();
159 init_k_coefficients_prc0();
160 init_k_coefficients_prc1();
160 init_k_coefficients_prc1();
161 init_k_coefficients_prc2();
161 init_k_coefficients_prc2();
162 pa_bia_status_info = 0x00;
162 pa_bia_status_info = 0x00;
163 cp_rpw_sc_rw_f_flags = 0x00;
163 cp_rpw_sc_rw_f_flags = 0x00;
164 cp_rpw_sc_rw1_f1 = 0.0;
164 cp_rpw_sc_rw1_f1 = 0.0;
165 cp_rpw_sc_rw1_f2 = 0.0;
165 cp_rpw_sc_rw1_f2 = 0.0;
166 cp_rpw_sc_rw2_f1 = 0.0;
166 cp_rpw_sc_rw2_f1 = 0.0;
167 cp_rpw_sc_rw2_f2 = 0.0;
167 cp_rpw_sc_rw2_f2 = 0.0;
168 cp_rpw_sc_rw3_f1 = 0.0;
168 cp_rpw_sc_rw3_f1 = 0.0;
169 cp_rpw_sc_rw3_f2 = 0.0;
169 cp_rpw_sc_rw3_f2 = 0.0;
170 cp_rpw_sc_rw4_f1 = 0.0;
170 cp_rpw_sc_rw4_f1 = 0.0;
171 cp_rpw_sc_rw4_f2 = 0.0;
171 cp_rpw_sc_rw4_f2 = 0.0;
172 update_last_valid_transition_date( DEFAULT_LAST_VALID_TRANSITION_DATE );
172 update_last_valid_transition_date( DEFAULT_LAST_VALID_TRANSITION_DATE );
173
173
174 // waveform picker initialization
174 // waveform picker initialization
175 WFP_init_rings(); LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings
175 WFP_init_rings();
176 LEON_Clear_interrupt( IRQ_SPARC_GPTIMER_WATCHDOG ); // initialize the waveform rings
176 WFP_reset_current_ring_nodes();
177 WFP_reset_current_ring_nodes();
177 reset_waveform_picker_regs();
178 reset_waveform_picker_regs();
178
179
179 // spectral matrices initialization
180 // spectral matrices initialization
180 SM_init_rings(); // initialize spectral matrices rings
181 SM_init_rings(); // initialize spectral matrices rings
181 SM_reset_current_ring_nodes();
182 SM_reset_current_ring_nodes();
182 reset_spectral_matrix_regs();
183 reset_spectral_matrix_regs();
183
184
184 // configure calibration
185 // configure calibration
185 configureCalibration( false ); // true means interleaved mode, false is for normal mode
186 configureCalibration( false ); // true means interleaved mode, false is for normal mode
186
187
187 updateLFRCurrentMode( LFR_MODE_STANDBY );
188 updateLFRCurrentMode( LFR_MODE_STANDBY );
188
189
189 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
190 BOOT_PRINTF1("in INIT *** lfrCurrentMode is %d\n", lfrCurrentMode)
190
191
191 create_names(); // create all names
192 create_names(); // create all names
192
193
193 status = create_timecode_timer(); // create the timer used by timecode_irq_handler
194 status = create_timecode_timer(); // create the timer used by timecode_irq_handler
194 if (status != RTEMS_SUCCESSFUL)
195 if (status != RTEMS_SUCCESSFUL)
195 {
196 {
196 PRINTF1("in INIT *** ERR in create_timer_timecode, code %d", status)
197 PRINTF1("in INIT *** ERR in create_timer_timecode, code %d", status)
197 }
198 }
198
199
199 status = create_message_queues(); // create message queues
200 status = create_message_queues(); // create message queues
200 if (status != RTEMS_SUCCESSFUL)
201 if (status != RTEMS_SUCCESSFUL)
201 {
202 {
202 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
203 PRINTF1("in INIT *** ERR in create_message_queues, code %d", status)
203 }
204 }
204
205
205 status = create_all_tasks(); // create all tasks
206 status = create_all_tasks(); // create all tasks
206 if (status != RTEMS_SUCCESSFUL)
207 if (status != RTEMS_SUCCESSFUL)
207 {
208 {
208 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
209 PRINTF1("in INIT *** ERR in create_all_tasks, code %d\n", status)
209 }
210 }
210
211
211 // **************************
212 // **************************
212 // <SPACEWIRE INITIALIZATION>
213 // <SPACEWIRE INITIALIZATION>
213 status_spw = spacewire_open_link(); // (1) open the link
214 status_spw = spacewire_open_link(); // (1) open the link
214 if ( status_spw != RTEMS_SUCCESSFUL )
215 if ( status_spw != RTEMS_SUCCESSFUL )
215 {
216 {
216 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
217 PRINTF1("in INIT *** ERR spacewire_open_link code %d\n", status_spw )
217 }
218 }
218
219
219 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
220 if ( status_spw == RTEMS_SUCCESSFUL ) // (2) configure the link
220 {
221 {
221 status_spw = spacewire_configure_link( fdSPW );
222 status_spw = spacewire_configure_link( fdSPW );
222 if ( status_spw != RTEMS_SUCCESSFUL )
223 if ( status_spw != RTEMS_SUCCESSFUL )
223 {
224 {
224 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
225 PRINTF1("in INIT *** ERR spacewire_configure_link code %d\n", status_spw )
225 }
226 }
226 }
227 }
227
228
228 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
229 if ( status_spw == RTEMS_SUCCESSFUL) // (3) start the link
229 {
230 {
230 status_spw = spacewire_start_link( fdSPW );
231 status_spw = spacewire_start_link( fdSPW );
231 if ( status_spw != RTEMS_SUCCESSFUL )
232 if ( status_spw != RTEMS_SUCCESSFUL )
232 {
233 {
233 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
234 PRINTF1("in INIT *** ERR spacewire_start_link code %d\n", status_spw )
234 }
235 }
235 }
236 }
236 // </SPACEWIRE INITIALIZATION>
237 // </SPACEWIRE INITIALIZATION>
237 // ***************************
238 // ***************************
238
239
239 status = start_all_tasks(); // start all tasks
240 status = start_all_tasks(); // start all tasks
240 if (status != RTEMS_SUCCESSFUL)
241 if (status != RTEMS_SUCCESSFUL)
241 {
242 {
242 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
243 PRINTF1("in INIT *** ERR in start_all_tasks, code %d", status)
243 }
244 }
244
245
245 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
246 // start RECV and SEND *AFTER* SpaceWire Initialization, due to the timeout of the start call during the initialization
246 status = start_recv_send_tasks();
247 status = start_recv_send_tasks();
247 if ( status != RTEMS_SUCCESSFUL )
248 if ( status != RTEMS_SUCCESSFUL )
248 {
249 {
249 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
250 PRINTF1("in INIT *** ERR start_recv_send_tasks code %d\n", status )
250 }
251 }
251
252
252 // suspend science tasks, they will be restarted later depending on the mode
253 // suspend science tasks, they will be restarted later depending on the mode
253 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
254 status = suspend_science_tasks(); // suspend science tasks (not done in stop_current_mode if current mode = STANDBY)
254 if (status != RTEMS_SUCCESSFUL)
255 if (status != RTEMS_SUCCESSFUL)
255 {
256 {
256 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
257 PRINTF1("in INIT *** in suspend_science_tasks *** ERR code: %d\n", status)
257 }
258 }
258
259
259 // configure IRQ handling for the waveform picker unit
260 // configure IRQ handling for the waveform picker unit
260 status = rtems_interrupt_catch( waveforms_isr,
261 status = rtems_interrupt_catch( waveforms_isr,
261 IRQ_SPARC_WAVEFORM_PICKER,
262 IRQ_SPARC_WAVEFORM_PICKER,
262 &old_isr_handler) ;
263 &old_isr_handler) ;
263 // configure IRQ handling for the spectral matrices unit
264 // configure IRQ handling for the spectral matrices unit
264 status = rtems_interrupt_catch( spectral_matrices_isr,
265 status = rtems_interrupt_catch( spectral_matrices_isr,
265 IRQ_SPARC_SPECTRAL_MATRIX,
266 IRQ_SPARC_SPECTRAL_MATRIX,
266 &old_isr_handler) ;
267 &old_isr_handler) ;
267
268
268 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
269 // if the spacewire link is not up then send an event to the SPIQ task for link recovery
269 if ( status_spw != RTEMS_SUCCESSFUL )
270 if ( status_spw != RTEMS_SUCCESSFUL )
270 {
271 {
271 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
272 status = rtems_event_send( Task_id[TASKID_SPIQ], SPW_LINKERR_EVENT );
272 if ( status != RTEMS_SUCCESSFUL ) {
273 if ( status != RTEMS_SUCCESSFUL ) {
273 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
274 PRINTF1("in INIT *** ERR rtems_event_send to SPIQ code %d\n", status )
274 }
275 }
275 }
276 }
276
277
277 BOOT_PRINTF("delete INIT\n")
278 BOOT_PRINTF("delete INIT\n")
278
279
279 set_hk_lfr_sc_potential_flag( true );
280 set_hk_lfr_sc_potential_flag( true );
280
281
281 // start the timer to detect a missing spacewire timecode
282 // start the timer to detect a missing spacewire timecode
282 // the timeout is larger because the spw IP needs to receive several valid timecodes before generating a tickout
283 // the timeout is larger because the spw IP needs to receive several valid timecodes before generating a tickout
283 // if a tickout is generated, the timer is restarted
284 // if a tickout is generated, the timer is restarted
284 status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT_INIT, timecode_timer_routine, NULL );
285 status = rtems_timer_fire_after( timecode_timer_id, TIMECODE_TIMER_TIMEOUT_INIT, timecode_timer_routine, NULL );
285
286
286 grspw_timecode_callback = &timecode_irq_handler;
287 grspw_timecode_callback = &timecode_irq_handler;
287
288
288 status = rtems_task_delete(RTEMS_SELF);
289 status = rtems_task_delete(RTEMS_SELF);
289
290
290 }
291 }
291
292
292 void init_local_mode_parameters( void )
293 void init_local_mode_parameters( void )
293 {
294 {
294 /** This function initialize the param_local global variable with default values.
295 /** This function initialize the param_local global variable with default values.
295 *
296 *
296 */
297 */
297
298
298 unsigned int i;
299 unsigned int i;
299
300
300 // LOCAL PARAMETERS
301 // LOCAL PARAMETERS
301
302
302 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
303 BOOT_PRINTF1("local_sbm1_nb_cwf_max %d \n", param_local.local_sbm1_nb_cwf_max)
303 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
304 BOOT_PRINTF1("local_sbm2_nb_cwf_max %d \n", param_local.local_sbm2_nb_cwf_max)
304 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
305 BOOT_PRINTF1("nb_interrupt_f0_MAX = %d\n", param_local.local_nb_interrupt_f0_MAX)
305
306
306 // init sequence counters
307 // init sequence counters
307
308
308 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
309 for(i = 0; i<SEQ_CNT_NB_DEST_ID; i++)
309 {
310 {
310 sequenceCounters_TC_EXE[i] = 0x00;
311 sequenceCounters_TC_EXE[i] = 0x00;
311 sequenceCounters_TM_DUMP[i] = 0x00;
312 sequenceCounters_TM_DUMP[i] = 0x00;
312 }
313 }
313 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
314 sequenceCounters_SCIENCE_NORMAL_BURST = 0x00;
314 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
315 sequenceCounters_SCIENCE_SBM1_SBM2 = 0x00;
315 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
316 sequenceCounterHK = TM_PACKET_SEQ_CTRL_STANDALONE << 8;
316 }
317 }
317
318
318 void reset_local_time( void )
319 void reset_local_time( void )
319 {
320 {
320 time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000
321 time_management_regs->ctrl = time_management_regs->ctrl | 0x02; // [0010] software reset, coarse time = 0x80000000
321 }
322 }
322
323
323 void create_names( void ) // create all names for tasks and queues
324 void create_names( void ) // create all names for tasks and queues
324 {
325 {
325 /** This function creates all RTEMS names used in the software for tasks and queues.
326 /** This function creates all RTEMS names used in the software for tasks and queues.
326 *
327 *
327 * @return RTEMS directive status codes:
328 * @return RTEMS directive status codes:
328 * - RTEMS_SUCCESSFUL - successful completion
329 * - RTEMS_SUCCESSFUL - successful completion
329 *
330 *
330 */
331 */
331
332
332 // task names
333 // task names
333 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
334 Task_name[TASKID_RECV] = rtems_build_name( 'R', 'E', 'C', 'V' );
334 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
335 Task_name[TASKID_ACTN] = rtems_build_name( 'A', 'C', 'T', 'N' );
335 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
336 Task_name[TASKID_SPIQ] = rtems_build_name( 'S', 'P', 'I', 'Q' );
336 Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' );
337 Task_name[TASKID_LOAD] = rtems_build_name( 'L', 'O', 'A', 'D' );
337 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
338 Task_name[TASKID_AVF0] = rtems_build_name( 'A', 'V', 'F', '0' );
338 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
339 Task_name[TASKID_SWBD] = rtems_build_name( 'S', 'W', 'B', 'D' );
339 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
340 Task_name[TASKID_WFRM] = rtems_build_name( 'W', 'F', 'R', 'M' );
340 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
341 Task_name[TASKID_DUMB] = rtems_build_name( 'D', 'U', 'M', 'B' );
341 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
342 Task_name[TASKID_HOUS] = rtems_build_name( 'H', 'O', 'U', 'S' );
342 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
343 Task_name[TASKID_PRC0] = rtems_build_name( 'P', 'R', 'C', '0' );
343 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
344 Task_name[TASKID_CWF3] = rtems_build_name( 'C', 'W', 'F', '3' );
344 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
345 Task_name[TASKID_CWF2] = rtems_build_name( 'C', 'W', 'F', '2' );
345 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
346 Task_name[TASKID_CWF1] = rtems_build_name( 'C', 'W', 'F', '1' );
346 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
347 Task_name[TASKID_SEND] = rtems_build_name( 'S', 'E', 'N', 'D' );
347 Task_name[TASKID_LINK] = rtems_build_name( 'L', 'I', 'N', 'K' );
348 Task_name[TASKID_LINK] = rtems_build_name( 'L', 'I', 'N', 'K' );
348 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
349 Task_name[TASKID_AVF1] = rtems_build_name( 'A', 'V', 'F', '1' );
349 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
350 Task_name[TASKID_PRC1] = rtems_build_name( 'P', 'R', 'C', '1' );
350 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
351 Task_name[TASKID_AVF2] = rtems_build_name( 'A', 'V', 'F', '2' );
351 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
352 Task_name[TASKID_PRC2] = rtems_build_name( 'P', 'R', 'C', '2' );
352
353
353 // rate monotonic period names
354 // rate monotonic period names
354 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
355 name_hk_rate_monotonic = rtems_build_name( 'H', 'O', 'U', 'S' );
355
356
356 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
357 misc_name[QUEUE_RECV] = rtems_build_name( 'Q', '_', 'R', 'V' );
357 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
358 misc_name[QUEUE_SEND] = rtems_build_name( 'Q', '_', 'S', 'D' );
358 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
359 misc_name[QUEUE_PRC0] = rtems_build_name( 'Q', '_', 'P', '0' );
359 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
360 misc_name[QUEUE_PRC1] = rtems_build_name( 'Q', '_', 'P', '1' );
360 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
361 misc_name[QUEUE_PRC2] = rtems_build_name( 'Q', '_', 'P', '2' );
361
362
362 timecode_timer_name = rtems_build_name( 'S', 'P', 'T', 'C' );
363 timecode_timer_name = rtems_build_name( 'S', 'P', 'T', 'C' );
363 }
364 }
364
365
365 int create_all_tasks( void ) // create all tasks which run in the software
366 int create_all_tasks( void ) // create all tasks which run in the software
366 {
367 {
367 /** This function creates all RTEMS tasks used in the software.
368 /** This function creates all RTEMS tasks used in the software.
368 *
369 *
369 * @return RTEMS directive status codes:
370 * @return RTEMS directive status codes:
370 * - RTEMS_SUCCESSFUL - task created successfully
371 * - RTEMS_SUCCESSFUL - task created successfully
371 * - RTEMS_INVALID_ADDRESS - id is NULL
372 * - RTEMS_INVALID_ADDRESS - id is NULL
372 * - RTEMS_INVALID_NAME - invalid task name
373 * - RTEMS_INVALID_NAME - invalid task name
373 * - RTEMS_INVALID_PRIORITY - invalid task priority
374 * - RTEMS_INVALID_PRIORITY - invalid task priority
374 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
375 * - RTEMS_MP_NOT_CONFIGURED - multiprocessing not configured
375 * - RTEMS_TOO_MANY - too many tasks created
376 * - RTEMS_TOO_MANY - too many tasks created
376 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
377 * - RTEMS_UNSATISFIED - not enough memory for stack/FP context
377 * - RTEMS_TOO_MANY - too many global objects
378 * - RTEMS_TOO_MANY - too many global objects
378 *
379 *
379 */
380 */
380
381
381 rtems_status_code status;
382 rtems_status_code status;
382
383
383 //**********
384 //**********
384 // SPACEWIRE
385 // SPACEWIRE
385 // RECV
386 // RECV
386 status = rtems_task_create(
387 status = rtems_task_create(
387 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
388 Task_name[TASKID_RECV], TASK_PRIORITY_RECV, RTEMS_MINIMUM_STACK_SIZE,
388 RTEMS_DEFAULT_MODES,
389 RTEMS_DEFAULT_MODES,
389 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
390 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_RECV]
390 );
391 );
391 if (status == RTEMS_SUCCESSFUL) // SEND
392 if (status == RTEMS_SUCCESSFUL) // SEND
392 {
393 {
393 status = rtems_task_create(
394 status = rtems_task_create(
394 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2,
395 Task_name[TASKID_SEND], TASK_PRIORITY_SEND, RTEMS_MINIMUM_STACK_SIZE * 2,
395 RTEMS_DEFAULT_MODES,
396 RTEMS_DEFAULT_MODES,
396 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND]
397 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SEND]
397 );
398 );
398 }
399 }
399 if (status == RTEMS_SUCCESSFUL) // LINK
400 if (status == RTEMS_SUCCESSFUL) // LINK
400 {
401 {
401 status = rtems_task_create(
402 status = rtems_task_create(
402 Task_name[TASKID_LINK], TASK_PRIORITY_LINK, RTEMS_MINIMUM_STACK_SIZE,
403 Task_name[TASKID_LINK], TASK_PRIORITY_LINK, RTEMS_MINIMUM_STACK_SIZE,
403 RTEMS_DEFAULT_MODES,
404 RTEMS_DEFAULT_MODES,
404 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LINK]
405 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LINK]
405 );
406 );
406 }
407 }
407 if (status == RTEMS_SUCCESSFUL) // ACTN
408 if (status == RTEMS_SUCCESSFUL) // ACTN
408 {
409 {
409 status = rtems_task_create(
410 status = rtems_task_create(
410 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
411 Task_name[TASKID_ACTN], TASK_PRIORITY_ACTN, RTEMS_MINIMUM_STACK_SIZE,
411 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
412 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
412 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
413 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_ACTN]
413 );
414 );
414 }
415 }
415 if (status == RTEMS_SUCCESSFUL) // SPIQ
416 if (status == RTEMS_SUCCESSFUL) // SPIQ
416 {
417 {
417 status = rtems_task_create(
418 status = rtems_task_create(
418 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
419 Task_name[TASKID_SPIQ], TASK_PRIORITY_SPIQ, RTEMS_MINIMUM_STACK_SIZE,
419 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
420 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
420 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
421 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_SPIQ]
421 );
422 );
422 }
423 }
423
424
424 //******************
425 //******************
425 // SPECTRAL MATRICES
426 // SPECTRAL MATRICES
426 if (status == RTEMS_SUCCESSFUL) // AVF0
427 if (status == RTEMS_SUCCESSFUL) // AVF0
427 {
428 {
428 status = rtems_task_create(
429 status = rtems_task_create(
429 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
430 Task_name[TASKID_AVF0], TASK_PRIORITY_AVF0, RTEMS_MINIMUM_STACK_SIZE,
430 RTEMS_DEFAULT_MODES,
431 RTEMS_DEFAULT_MODES,
431 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
432 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF0]
432 );
433 );
433 }
434 }
434 if (status == RTEMS_SUCCESSFUL) // PRC0
435 if (status == RTEMS_SUCCESSFUL) // PRC0
435 {
436 {
436 status = rtems_task_create(
437 status = rtems_task_create(
437 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
438 Task_name[TASKID_PRC0], TASK_PRIORITY_PRC0, RTEMS_MINIMUM_STACK_SIZE * 2,
438 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
439 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
439 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
440 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC0]
440 );
441 );
441 }
442 }
442 if (status == RTEMS_SUCCESSFUL) // AVF1
443 if (status == RTEMS_SUCCESSFUL) // AVF1
443 {
444 {
444 status = rtems_task_create(
445 status = rtems_task_create(
445 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
446 Task_name[TASKID_AVF1], TASK_PRIORITY_AVF1, RTEMS_MINIMUM_STACK_SIZE,
446 RTEMS_DEFAULT_MODES,
447 RTEMS_DEFAULT_MODES,
447 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
448 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF1]
448 );
449 );
449 }
450 }
450 if (status == RTEMS_SUCCESSFUL) // PRC1
451 if (status == RTEMS_SUCCESSFUL) // PRC1
451 {
452 {
452 status = rtems_task_create(
453 status = rtems_task_create(
453 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
454 Task_name[TASKID_PRC1], TASK_PRIORITY_PRC1, RTEMS_MINIMUM_STACK_SIZE * 2,
454 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
455 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
455 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
456 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC1]
456 );
457 );
457 }
458 }
458 if (status == RTEMS_SUCCESSFUL) // AVF2
459 if (status == RTEMS_SUCCESSFUL) // AVF2
459 {
460 {
460 status = rtems_task_create(
461 status = rtems_task_create(
461 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
462 Task_name[TASKID_AVF2], TASK_PRIORITY_AVF2, RTEMS_MINIMUM_STACK_SIZE,
462 RTEMS_DEFAULT_MODES,
463 RTEMS_DEFAULT_MODES,
463 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
464 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_AVF2]
464 );
465 );
465 }
466 }
466 if (status == RTEMS_SUCCESSFUL) // PRC2
467 if (status == RTEMS_SUCCESSFUL) // PRC2
467 {
468 {
468 status = rtems_task_create(
469 status = rtems_task_create(
469 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
470 Task_name[TASKID_PRC2], TASK_PRIORITY_PRC2, RTEMS_MINIMUM_STACK_SIZE * 2,
470 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
471 RTEMS_DEFAULT_MODES | RTEMS_NO_PREEMPT,
471 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
472 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_PRC2]
472 );
473 );
473 }
474 }
474
475
475 //****************
476 //****************
476 // WAVEFORM PICKER
477 // WAVEFORM PICKER
477 if (status == RTEMS_SUCCESSFUL) // WFRM
478 if (status == RTEMS_SUCCESSFUL) // WFRM
478 {
479 {
479 status = rtems_task_create(
480 status = rtems_task_create(
480 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
481 Task_name[TASKID_WFRM], TASK_PRIORITY_WFRM, RTEMS_MINIMUM_STACK_SIZE,
481 RTEMS_DEFAULT_MODES,
482 RTEMS_DEFAULT_MODES,
482 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
483 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_WFRM]
483 );
484 );
484 }
485 }
485 if (status == RTEMS_SUCCESSFUL) // CWF3
486 if (status == RTEMS_SUCCESSFUL) // CWF3
486 {
487 {
487 status = rtems_task_create(
488 status = rtems_task_create(
488 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
489 Task_name[TASKID_CWF3], TASK_PRIORITY_CWF3, RTEMS_MINIMUM_STACK_SIZE,
489 RTEMS_DEFAULT_MODES,
490 RTEMS_DEFAULT_MODES,
490 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
491 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF3]
491 );
492 );
492 }
493 }
493 if (status == RTEMS_SUCCESSFUL) // CWF2
494 if (status == RTEMS_SUCCESSFUL) // CWF2
494 {
495 {
495 status = rtems_task_create(
496 status = rtems_task_create(
496 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
497 Task_name[TASKID_CWF2], TASK_PRIORITY_CWF2, RTEMS_MINIMUM_STACK_SIZE,
497 RTEMS_DEFAULT_MODES,
498 RTEMS_DEFAULT_MODES,
498 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
499 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF2]
499 );
500 );
500 }
501 }
501 if (status == RTEMS_SUCCESSFUL) // CWF1
502 if (status == RTEMS_SUCCESSFUL) // CWF1
502 {
503 {
503 status = rtems_task_create(
504 status = rtems_task_create(
504 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
505 Task_name[TASKID_CWF1], TASK_PRIORITY_CWF1, RTEMS_MINIMUM_STACK_SIZE,
505 RTEMS_DEFAULT_MODES,
506 RTEMS_DEFAULT_MODES,
506 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
507 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_CWF1]
507 );
508 );
508 }
509 }
509 if (status == RTEMS_SUCCESSFUL) // SWBD
510 if (status == RTEMS_SUCCESSFUL) // SWBD
510 {
511 {
511 status = rtems_task_create(
512 status = rtems_task_create(
512 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
513 Task_name[TASKID_SWBD], TASK_PRIORITY_SWBD, RTEMS_MINIMUM_STACK_SIZE,
513 RTEMS_DEFAULT_MODES,
514 RTEMS_DEFAULT_MODES,
514 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
515 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_SWBD]
515 );
516 );
516 }
517 }
517
518
518 //*****
519 //*****
519 // MISC
520 // MISC
520 if (status == RTEMS_SUCCESSFUL) // LOAD
521 if (status == RTEMS_SUCCESSFUL) // LOAD
521 {
522 {
522 status = rtems_task_create(
523 status = rtems_task_create(
523 Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE,
524 Task_name[TASKID_LOAD], TASK_PRIORITY_LOAD, RTEMS_MINIMUM_STACK_SIZE,
524 RTEMS_DEFAULT_MODES,
525 RTEMS_DEFAULT_MODES,
525 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD]
526 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_LOAD]
526 );
527 );
527 }
528 }
528 if (status == RTEMS_SUCCESSFUL) // DUMB
529 if (status == RTEMS_SUCCESSFUL) // DUMB
529 {
530 {
530 status = rtems_task_create(
531 status = rtems_task_create(
531 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
532 Task_name[TASKID_DUMB], TASK_PRIORITY_DUMB, RTEMS_MINIMUM_STACK_SIZE,
532 RTEMS_DEFAULT_MODES,
533 RTEMS_DEFAULT_MODES,
533 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
534 RTEMS_DEFAULT_ATTRIBUTES, &Task_id[TASKID_DUMB]
534 );
535 );
535 }
536 }
536 if (status == RTEMS_SUCCESSFUL) // HOUS
537 if (status == RTEMS_SUCCESSFUL) // HOUS
537 {
538 {
538 status = rtems_task_create(
539 status = rtems_task_create(
539 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
540 Task_name[TASKID_HOUS], TASK_PRIORITY_HOUS, RTEMS_MINIMUM_STACK_SIZE,
540 RTEMS_DEFAULT_MODES,
541 RTEMS_DEFAULT_MODES,
541 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS]
542 RTEMS_DEFAULT_ATTRIBUTES | RTEMS_FLOATING_POINT, &Task_id[TASKID_HOUS]
542 );
543 );
543 }
544 }
544
545
545 return status;
546 return status;
546 }
547 }
547
548
548 int start_recv_send_tasks( void )
549 int start_recv_send_tasks( void )
549 {
550 {
550 rtems_status_code status;
551 rtems_status_code status;
551
552
552 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
553 status = rtems_task_start( Task_id[TASKID_RECV], recv_task, 1 );
553 if (status!=RTEMS_SUCCESSFUL) {
554 if (status!=RTEMS_SUCCESSFUL) {
554 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
555 BOOT_PRINTF("in INIT *** Error starting TASK_RECV\n")
555 }
556 }
556
557
557 if (status == RTEMS_SUCCESSFUL) // SEND
558 if (status == RTEMS_SUCCESSFUL) // SEND
558 {
559 {
559 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
560 status = rtems_task_start( Task_id[TASKID_SEND], send_task, 1 );
560 if (status!=RTEMS_SUCCESSFUL) {
561 if (status!=RTEMS_SUCCESSFUL) {
561 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
562 BOOT_PRINTF("in INIT *** Error starting TASK_SEND\n")
562 }
563 }
563 }
564 }
564
565
565 return status;
566 return status;
566 }
567 }
567
568
568 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
569 int start_all_tasks( void ) // start all tasks except SEND RECV and HOUS
569 {
570 {
570 /** This function starts all RTEMS tasks used in the software.
571 /** This function starts all RTEMS tasks used in the software.
571 *
572 *
572 * @return RTEMS directive status codes:
573 * @return RTEMS directive status codes:
573 * - RTEMS_SUCCESSFUL - ask started successfully
574 * - RTEMS_SUCCESSFUL - ask started successfully
574 * - RTEMS_INVALID_ADDRESS - invalid task entry point
575 * - RTEMS_INVALID_ADDRESS - invalid task entry point
575 * - RTEMS_INVALID_ID - invalid task id
576 * - RTEMS_INVALID_ID - invalid task id
576 * - RTEMS_INCORRECT_STATE - task not in the dormant state
577 * - RTEMS_INCORRECT_STATE - task not in the dormant state
577 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
578 * - RTEMS_ILLEGAL_ON_REMOTE_OBJECT - cannot start remote task
578 *
579 *
579 */
580 */
580 // starts all the tasks fot eh flight software
581 // starts all the tasks fot eh flight software
581
582
582 rtems_status_code status;
583 rtems_status_code status;
583
584
584 //**********
585 //**********
585 // SPACEWIRE
586 // SPACEWIRE
586 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
587 status = rtems_task_start( Task_id[TASKID_SPIQ], spiq_task, 1 );
587 if (status!=RTEMS_SUCCESSFUL) {
588 if (status!=RTEMS_SUCCESSFUL) {
588 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
589 BOOT_PRINTF("in INIT *** Error starting TASK_SPIQ\n")
589 }
590 }
590
591
591 if (status == RTEMS_SUCCESSFUL) // LINK
592 if (status == RTEMS_SUCCESSFUL) // LINK
592 {
593 {
593 status = rtems_task_start( Task_id[TASKID_LINK], link_task, 1 );
594 status = rtems_task_start( Task_id[TASKID_LINK], link_task, 1 );
594 if (status!=RTEMS_SUCCESSFUL) {
595 if (status!=RTEMS_SUCCESSFUL) {
595 BOOT_PRINTF("in INIT *** Error starting TASK_LINK\n")
596 BOOT_PRINTF("in INIT *** Error starting TASK_LINK\n")
596 }
597 }
597 }
598 }
598
599
599 if (status == RTEMS_SUCCESSFUL) // ACTN
600 if (status == RTEMS_SUCCESSFUL) // ACTN
600 {
601 {
601 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
602 status = rtems_task_start( Task_id[TASKID_ACTN], actn_task, 1 );
602 if (status!=RTEMS_SUCCESSFUL) {
603 if (status!=RTEMS_SUCCESSFUL) {
603 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
604 BOOT_PRINTF("in INIT *** Error starting TASK_ACTN\n")
604 }
605 }
605 }
606 }
606
607
607 //******************
608 //******************
608 // SPECTRAL MATRICES
609 // SPECTRAL MATRICES
609 if (status == RTEMS_SUCCESSFUL) // AVF0
610 if (status == RTEMS_SUCCESSFUL) // AVF0
610 {
611 {
611 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
612 status = rtems_task_start( Task_id[TASKID_AVF0], avf0_task, LFR_MODE_STANDBY );
612 if (status!=RTEMS_SUCCESSFUL) {
613 if (status!=RTEMS_SUCCESSFUL) {
613 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
614 BOOT_PRINTF("in INIT *** Error starting TASK_AVF0\n")
614 }
615 }
615 }
616 }
616 if (status == RTEMS_SUCCESSFUL) // PRC0
617 if (status == RTEMS_SUCCESSFUL) // PRC0
617 {
618 {
618 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
619 status = rtems_task_start( Task_id[TASKID_PRC0], prc0_task, LFR_MODE_STANDBY );
619 if (status!=RTEMS_SUCCESSFUL) {
620 if (status!=RTEMS_SUCCESSFUL) {
620 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
621 BOOT_PRINTF("in INIT *** Error starting TASK_PRC0\n")
621 }
622 }
622 }
623 }
623 if (status == RTEMS_SUCCESSFUL) // AVF1
624 if (status == RTEMS_SUCCESSFUL) // AVF1
624 {
625 {
625 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
626 status = rtems_task_start( Task_id[TASKID_AVF1], avf1_task, LFR_MODE_STANDBY );
626 if (status!=RTEMS_SUCCESSFUL) {
627 if (status!=RTEMS_SUCCESSFUL) {
627 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
628 BOOT_PRINTF("in INIT *** Error starting TASK_AVF1\n")
628 }
629 }
629 }
630 }
630 if (status == RTEMS_SUCCESSFUL) // PRC1
631 if (status == RTEMS_SUCCESSFUL) // PRC1
631 {
632 {
632 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
633 status = rtems_task_start( Task_id[TASKID_PRC1], prc1_task, LFR_MODE_STANDBY );
633 if (status!=RTEMS_SUCCESSFUL) {
634 if (status!=RTEMS_SUCCESSFUL) {
634 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
635 BOOT_PRINTF("in INIT *** Error starting TASK_PRC1\n")
635 }
636 }
636 }
637 }
637 if (status == RTEMS_SUCCESSFUL) // AVF2
638 if (status == RTEMS_SUCCESSFUL) // AVF2
638 {
639 {
639 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
640 status = rtems_task_start( Task_id[TASKID_AVF2], avf2_task, 1 );
640 if (status!=RTEMS_SUCCESSFUL) {
641 if (status!=RTEMS_SUCCESSFUL) {
641 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
642 BOOT_PRINTF("in INIT *** Error starting TASK_AVF2\n")
642 }
643 }
643 }
644 }
644 if (status == RTEMS_SUCCESSFUL) // PRC2
645 if (status == RTEMS_SUCCESSFUL) // PRC2
645 {
646 {
646 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
647 status = rtems_task_start( Task_id[TASKID_PRC2], prc2_task, 1 );
647 if (status!=RTEMS_SUCCESSFUL) {
648 if (status!=RTEMS_SUCCESSFUL) {
648 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
649 BOOT_PRINTF("in INIT *** Error starting TASK_PRC2\n")
649 }
650 }
650 }
651 }
651
652
652 //****************
653 //****************
653 // WAVEFORM PICKER
654 // WAVEFORM PICKER
654 if (status == RTEMS_SUCCESSFUL) // WFRM
655 if (status == RTEMS_SUCCESSFUL) // WFRM
655 {
656 {
656 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
657 status = rtems_task_start( Task_id[TASKID_WFRM], wfrm_task, 1 );
657 if (status!=RTEMS_SUCCESSFUL) {
658 if (status!=RTEMS_SUCCESSFUL) {
658 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
659 BOOT_PRINTF("in INIT *** Error starting TASK_WFRM\n")
659 }
660 }
660 }
661 }
661 if (status == RTEMS_SUCCESSFUL) // CWF3
662 if (status == RTEMS_SUCCESSFUL) // CWF3
662 {
663 {
663 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
664 status = rtems_task_start( Task_id[TASKID_CWF3], cwf3_task, 1 );
664 if (status!=RTEMS_SUCCESSFUL) {
665 if (status!=RTEMS_SUCCESSFUL) {
665 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
666 BOOT_PRINTF("in INIT *** Error starting TASK_CWF3\n")
666 }
667 }
667 }
668 }
668 if (status == RTEMS_SUCCESSFUL) // CWF2
669 if (status == RTEMS_SUCCESSFUL) // CWF2
669 {
670 {
670 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
671 status = rtems_task_start( Task_id[TASKID_CWF2], cwf2_task, 1 );
671 if (status!=RTEMS_SUCCESSFUL) {
672 if (status!=RTEMS_SUCCESSFUL) {
672 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
673 BOOT_PRINTF("in INIT *** Error starting TASK_CWF2\n")
673 }
674 }
674 }
675 }
675 if (status == RTEMS_SUCCESSFUL) // CWF1
676 if (status == RTEMS_SUCCESSFUL) // CWF1
676 {
677 {
677 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
678 status = rtems_task_start( Task_id[TASKID_CWF1], cwf1_task, 1 );
678 if (status!=RTEMS_SUCCESSFUL) {
679 if (status!=RTEMS_SUCCESSFUL) {
679 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
680 BOOT_PRINTF("in INIT *** Error starting TASK_CWF1\n")
680 }
681 }
681 }
682 }
682 if (status == RTEMS_SUCCESSFUL) // SWBD
683 if (status == RTEMS_SUCCESSFUL) // SWBD
683 {
684 {
684 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
685 status = rtems_task_start( Task_id[TASKID_SWBD], swbd_task, 1 );
685 if (status!=RTEMS_SUCCESSFUL) {
686 if (status!=RTEMS_SUCCESSFUL) {
686 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
687 BOOT_PRINTF("in INIT *** Error starting TASK_SWBD\n")
687 }
688 }
688 }
689 }
689
690
690 //*****
691 //*****
691 // MISC
692 // MISC
692 if (status == RTEMS_SUCCESSFUL) // HOUS
693 if (status == RTEMS_SUCCESSFUL) // HOUS
693 {
694 {
694 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
695 status = rtems_task_start( Task_id[TASKID_HOUS], hous_task, 1 );
695 if (status!=RTEMS_SUCCESSFUL) {
696 if (status!=RTEMS_SUCCESSFUL) {
696 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
697 BOOT_PRINTF("in INIT *** Error starting TASK_HOUS\n")
697 }
698 }
698 }
699 }
699 if (status == RTEMS_SUCCESSFUL) // DUMB
700 if (status == RTEMS_SUCCESSFUL) // DUMB
700 {
701 {
701 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
702 status = rtems_task_start( Task_id[TASKID_DUMB], dumb_task, 1 );
702 if (status!=RTEMS_SUCCESSFUL) {
703 if (status!=RTEMS_SUCCESSFUL) {
703 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
704 BOOT_PRINTF("in INIT *** Error starting TASK_DUMB\n")
704 }
705 }
705 }
706 }
706 if (status == RTEMS_SUCCESSFUL) // LOAD
707 if (status == RTEMS_SUCCESSFUL) // LOAD
707 {
708 {
708 status = rtems_task_start( Task_id[TASKID_LOAD], load_task, 1 );
709 status = rtems_task_start( Task_id[TASKID_LOAD], load_task, 1 );
709 if (status!=RTEMS_SUCCESSFUL) {
710 if (status!=RTEMS_SUCCESSFUL) {
710 BOOT_PRINTF("in INIT *** Error starting TASK_LOAD\n")
711 BOOT_PRINTF("in INIT *** Error starting TASK_LOAD\n")
711 }
712 }
712 }
713 }
713
714
714 return status;
715 return status;
715 }
716 }
716
717
717 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
718 rtems_status_code create_message_queues( void ) // create the two message queues used in the software
718 {
719 {
719 rtems_status_code status_recv;
720 rtems_status_code status_recv;
720 rtems_status_code status_send;
721 rtems_status_code status_send;
721 rtems_status_code status_q_p0;
722 rtems_status_code status_q_p0;
722 rtems_status_code status_q_p1;
723 rtems_status_code status_q_p1;
723 rtems_status_code status_q_p2;
724 rtems_status_code status_q_p2;
724 rtems_status_code ret;
725 rtems_status_code ret;
725 rtems_id queue_id;
726 rtems_id queue_id;
726
727
727 //****************************************
728 //****************************************
728 // create the queue for handling valid TCs
729 // create the queue for handling valid TCs
729 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
730 status_recv = rtems_message_queue_create( misc_name[QUEUE_RECV],
730 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
731 MSG_QUEUE_COUNT_RECV, CCSDS_TC_PKT_MAX_SIZE,
731 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
732 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
732 if ( status_recv != RTEMS_SUCCESSFUL ) {
733 if ( status_recv != RTEMS_SUCCESSFUL ) {
733 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
734 PRINTF1("in create_message_queues *** ERR creating QUEU queue, %d\n", status_recv)
734 }
735 }
735
736
736 //************************************************
737 //************************************************
737 // create the queue for handling TM packet sending
738 // create the queue for handling TM packet sending
738 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
739 status_send = rtems_message_queue_create( misc_name[QUEUE_SEND],
739 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
740 MSG_QUEUE_COUNT_SEND, MSG_QUEUE_SIZE_SEND,
740 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
741 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
741 if ( status_send != RTEMS_SUCCESSFUL ) {
742 if ( status_send != RTEMS_SUCCESSFUL ) {
742 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
743 PRINTF1("in create_message_queues *** ERR creating PKTS queue, %d\n", status_send)
743 }
744 }
744
745
745 //*****************************************************************************
746 //*****************************************************************************
746 // create the queue for handling averaged spectral matrices for processing @ f0
747 // create the queue for handling averaged spectral matrices for processing @ f0
747 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
748 status_q_p0 = rtems_message_queue_create( misc_name[QUEUE_PRC0],
748 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
749 MSG_QUEUE_COUNT_PRC0, MSG_QUEUE_SIZE_PRC0,
749 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
750 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
750 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
751 if ( status_q_p0 != RTEMS_SUCCESSFUL ) {
751 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
752 PRINTF1("in create_message_queues *** ERR creating Q_P0 queue, %d\n", status_q_p0)
752 }
753 }
753
754
754 //*****************************************************************************
755 //*****************************************************************************
755 // create the queue for handling averaged spectral matrices for processing @ f1
756 // create the queue for handling averaged spectral matrices for processing @ f1
756 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
757 status_q_p1 = rtems_message_queue_create( misc_name[QUEUE_PRC1],
757 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
758 MSG_QUEUE_COUNT_PRC1, MSG_QUEUE_SIZE_PRC1,
758 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
759 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
759 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
760 if ( status_q_p1 != RTEMS_SUCCESSFUL ) {
760 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
761 PRINTF1("in create_message_queues *** ERR creating Q_P1 queue, %d\n", status_q_p1)
761 }
762 }
762
763
763 //*****************************************************************************
764 //*****************************************************************************
764 // create the queue for handling averaged spectral matrices for processing @ f2
765 // create the queue for handling averaged spectral matrices for processing @ f2
765 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
766 status_q_p2 = rtems_message_queue_create( misc_name[QUEUE_PRC2],
766 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
767 MSG_QUEUE_COUNT_PRC2, MSG_QUEUE_SIZE_PRC2,
767 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
768 RTEMS_FIFO | RTEMS_LOCAL, &queue_id );
768 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
769 if ( status_q_p2 != RTEMS_SUCCESSFUL ) {
769 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
770 PRINTF1("in create_message_queues *** ERR creating Q_P2 queue, %d\n", status_q_p2)
770 }
771 }
771
772
772 if ( status_recv != RTEMS_SUCCESSFUL )
773 if ( status_recv != RTEMS_SUCCESSFUL )
773 {
774 {
774 ret = status_recv;
775 ret = status_recv;
775 }
776 }
776 else if( status_send != RTEMS_SUCCESSFUL )
777 else if( status_send != RTEMS_SUCCESSFUL )
777 {
778 {
778 ret = status_send;
779 ret = status_send;
779 }
780 }
780 else if( status_q_p0 != RTEMS_SUCCESSFUL )
781 else if( status_q_p0 != RTEMS_SUCCESSFUL )
781 {
782 {
782 ret = status_q_p0;
783 ret = status_q_p0;
783 }
784 }
784 else if( status_q_p1 != RTEMS_SUCCESSFUL )
785 else if( status_q_p1 != RTEMS_SUCCESSFUL )
785 {
786 {
786 ret = status_q_p1;
787 ret = status_q_p1;
787 }
788 }
788 else
789 else
789 {
790 {
790 ret = status_q_p2;
791 ret = status_q_p2;
791 }
792 }
792
793
793 return ret;
794 return ret;
794 }
795 }
795
796
796 rtems_status_code create_timecode_timer( void )
797 rtems_status_code create_timecode_timer( void )
797 {
798 {
798 rtems_status_code status;
799 rtems_status_code status;
799
800
800 status = rtems_timer_create( timecode_timer_name, &timecode_timer_id );
801 status = rtems_timer_create( timecode_timer_name, &timecode_timer_id );
801
802
802 if ( status != RTEMS_SUCCESSFUL )
803 if ( status != RTEMS_SUCCESSFUL )
803 {
804 {
804 PRINTF1("in create_timer_timecode *** ERR creating SPTC timer, %d\n", status)
805 PRINTF1("in create_timer_timecode *** ERR creating SPTC timer, %d\n", status)
805 }
806 }
806 else
807 else
807 {
808 {
808 PRINTF("in create_timer_timecode *** OK creating SPTC timer\n")
809 PRINTF("in create_timer_timecode *** OK creating SPTC timer\n")
809 }
810 }
810
811
811 return status;
812 return status;
812 }
813 }
813
814
814 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
815 rtems_status_code get_message_queue_id_send( rtems_id *queue_id )
815 {
816 {
816 rtems_status_code status;
817 rtems_status_code status;
817 rtems_name queue_name;
818 rtems_name queue_name;
818
819
819 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
820 queue_name = rtems_build_name( 'Q', '_', 'S', 'D' );
820
821
821 status = rtems_message_queue_ident( queue_name, 0, queue_id );
822 status = rtems_message_queue_ident( queue_name, 0, queue_id );
822
823
823 return status;
824 return status;
824 }
825 }
825
826
826 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
827 rtems_status_code get_message_queue_id_recv( rtems_id *queue_id )
827 {
828 {
828 rtems_status_code status;
829 rtems_status_code status;
829 rtems_name queue_name;
830 rtems_name queue_name;
830
831
831 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
832 queue_name = rtems_build_name( 'Q', '_', 'R', 'V' );
832
833
833 status = rtems_message_queue_ident( queue_name, 0, queue_id );
834 status = rtems_message_queue_ident( queue_name, 0, queue_id );
834
835
835 return status;
836 return status;
836 }
837 }
837
838
838 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
839 rtems_status_code get_message_queue_id_prc0( rtems_id *queue_id )
839 {
840 {
840 rtems_status_code status;
841 rtems_status_code status;
841 rtems_name queue_name;
842 rtems_name queue_name;
842
843
843 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
844 queue_name = rtems_build_name( 'Q', '_', 'P', '0' );
844
845
845 status = rtems_message_queue_ident( queue_name, 0, queue_id );
846 status = rtems_message_queue_ident( queue_name, 0, queue_id );
846
847
847 return status;
848 return status;
848 }
849 }
849
850
850 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
851 rtems_status_code get_message_queue_id_prc1( rtems_id *queue_id )
851 {
852 {
852 rtems_status_code status;
853 rtems_status_code status;
853 rtems_name queue_name;
854 rtems_name queue_name;
854
855
855 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
856 queue_name = rtems_build_name( 'Q', '_', 'P', '1' );
856
857
857 status = rtems_message_queue_ident( queue_name, 0, queue_id );
858 status = rtems_message_queue_ident( queue_name, 0, queue_id );
858
859
859 return status;
860 return status;
860 }
861 }
861
862
862 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
863 rtems_status_code get_message_queue_id_prc2( rtems_id *queue_id )
863 {
864 {
864 rtems_status_code status;
865 rtems_status_code status;
865 rtems_name queue_name;
866 rtems_name queue_name;
866
867
867 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
868 queue_name = rtems_build_name( 'Q', '_', 'P', '2' );
868
869
869 status = rtems_message_queue_ident( queue_name, 0, queue_id );
870 status = rtems_message_queue_ident( queue_name, 0, queue_id );
870
871
871 return status;
872 return status;
872 }
873 }
873
874
874 void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max )
875 void update_queue_max_count( rtems_id queue_id, unsigned char*fifo_size_max )
875 {
876 {
876 u_int32_t count;
877 u_int32_t count;
877 rtems_status_code status;
878 rtems_status_code status;
878
879
879 status = rtems_message_queue_get_number_pending( queue_id, &count );
880 status = rtems_message_queue_get_number_pending( queue_id, &count );
880
881
881 count = count + 1;
882 count = count + 1;
882
883
883 if (status != RTEMS_SUCCESSFUL)
884 if (status != RTEMS_SUCCESSFUL)
884 {
885 {
885 PRINTF1("in update_queue_max_count *** ERR = %d\n", status)
886 PRINTF1("in update_queue_max_count *** ERR = %d\n", status)
886 }
887 }
887 else
888 else
888 {
889 {
889 if (count > *fifo_size_max)
890 if (count > *fifo_size_max)
890 {
891 {
891 *fifo_size_max = count;
892 *fifo_size_max = count;
892 }
893 }
893 }
894 }
894 }
895 }
895
896
896 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize )
897 void init_ring(ring_node ring[], unsigned char nbNodes, volatile int buffer[], unsigned int bufferSize )
897 {
898 {
898 unsigned char i;
899 unsigned char i;
899
900
900 //***************
901 //***************
901 // BUFFER ADDRESS
902 // BUFFER ADDRESS
902 for(i=0; i<nbNodes; i++)
903 for(i=0; i<nbNodes; i++)
903 {
904 {
904 ring[i].coarseTime = 0xffffffff;
905 ring[i].coarseTime = 0xffffffff;
905 ring[i].fineTime = 0xffffffff;
906 ring[i].fineTime = 0xffffffff;
906 ring[i].sid = 0x00;
907 ring[i].sid = 0x00;
907 ring[i].status = 0x00;
908 ring[i].status = 0x00;
908 ring[i].buffer_address = (int) &buffer[ i * bufferSize ];
909 ring[i].buffer_address = (int) &buffer[ i * bufferSize ];
909 }
910 }
910
911
911 //*****
912 //*****
912 // NEXT
913 // NEXT
913 ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ];
914 ring[ nbNodes - 1 ].next = (ring_node*) &ring[ 0 ];
914 for(i=0; i<nbNodes-1; i++)
915 for(i=0; i<nbNodes-1; i++)
915 {
916 {
916 ring[i].next = (ring_node*) &ring[ i + 1 ];
917 ring[i].next = (ring_node*) &ring[ i + 1 ];
917 }
918 }
918
919
919 //*********
920 //*********
920 // PREVIOUS
921 // PREVIOUS
921 ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ];
922 ring[ 0 ].previous = (ring_node*) &ring[ nbNodes - 1 ];
922 for(i=1; i<nbNodes; i++)
923 for(i=1; i<nbNodes; i++)
923 {
924 {
924 ring[i].previous = (ring_node*) &ring[ i - 1 ];
925 ring[i].previous = (ring_node*) &ring[ i - 1 ];
925 }
926 }
926 }
927 }
General Comments 0
You need to be logged in to leave comments. Login now