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