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